problem
stringlengths
26
131k
labels
class label
2 classes
Oracle 11g: ow to INSERT a row in a table if this row doesn't already exist in same table, in PL/SQL (oracle) : please guide how to INSERT a row in a table if this row doesn't already exist in same table, in PL/SQL (oracle)? I want something like this. insert into note (note_id, user_book_id, course_user_id, book_edition_id, book_id, role_type_id, page_id, book_page_number, xcoord, ycoord, width, height, share_across_courses, date_created, date_updated, created_by, updated_by, description, share_with_students,text) select note_s.nextval, i_user_book_id, i_course_user_id, book_edition_id, book_id, n.role_type_id, page_id, book_page_number, xcoord, ycoord, width, height, share_across_courses, sysdate, sysdate, i_user_id, i_user_id, description, share_with_students,text from note n inner join course_user cu on n.course_user_id = cu.course_user_id where cu.course_id = 23846 and where not exists (select note_s.nextval, i_user_book_id, i_course_user_id, book_edition_id, book_id, n.role_type_id, page_id, book_page_number, xcoord, ycoord, width, height, share_across_courses, sysdate, sysdate, i_user_id, i_user_id, description, share_with_students,text from note n inner join course_user cu on n.course_user_id = cu.course_user_id where cu.course_id = 23846); That is, in note table if record is already present for a particular course_user_id then do nothing. Otherwise if no entry for that particular course_user_id then insert into note for that course_user_id. But my code is not working. Pls Note - Here, note_id is PRIMARY KEY in note table and Course_user_id is PRIMARY KEY in course_user table.
0debug
what is the c++ equivalent of map(int,input().split()) of python? : <p>I find it hard to do all the string manipulation and then parsing into an array of integers in c++ while we could get away with only a single line in python.</p> <p>whats the easiest way to split the string of integers into an array of integers in c++ ? </p>
0debug
when to use move in function calls : <p>I am currently learning mor about all the c++11/14 features and wondering when to use std::move in function calls.</p> <p>I know I should not use it when returning local variables, because this breaks Return value optimisation, but I do not really understand where in function calls casting to a rvalue actually helps.</p>
0debug
static void bdrv_co_io_em_complete(void *opaque, int ret) { CoroutineIOCompletion *co = opaque; co->ret = ret; qemu_coroutine_enter(co->coroutine, NULL); }
1threat
Error:(1) Error parsing XML: XML declaration not well-formed : <pre><code>&lt;?xml version="1.0"encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schema.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.tk2323.ftsm.lab_ui_intent_a160158.MainActivity"&gt; </code></pre> <p>please help me this is the first time im using android studio and i have 3 errors and it said about xml. I'm not really sure about this.......</p> <pre><code> Error:(1) Error parsing XML: XML declaration not well-formed </code></pre>
0debug
Firebase Load Testing : <p><strong>How can we load test Firebase Realtime Database listener performance?</strong></p> <p>Firebase Realtime Database documentation says that we can have up to 100K concurrent users per database. If we have 100K concurrent users listening to the same node in a database, and that node updates, how quickly will the 100K users be notified of that update? (Obviously with just a few users, users are notified in less than a second, but how would it perform with 100K users listening at the same node?)</p> <p>We're trying to simulate 100K concurrent users listening on the same path. </p> <p><strong>What We've Tried</strong></p> <p><em>Attempt #1</em>: We tried using a for loop to attach 100K listeners, but those listeners are pipelined over the same socket, so Firebase only sees one listener. <em>Is there a way we can disable pipelining of listeners?</em></p> <p><em>Attempt #2</em>: Per this <a href="https://www.viget.com/articles/backend-as-a-service-at-scale/" rel="noreferrer">article</a> from Viget, we used a node script to spawn several child processes, each of which attaches a single listener to Firebase. See code below (from Viget). Unfortunately this isn't scalable to 100K - we can only realistically create a small handful of child processes per machine (generally equal to the number of CPUs the machine has). <em>Is there a way we can spawn significantly more child processes per machine (either with node, or something else)?</em></p> <pre><code>const spawn = require('child_process').spawn // How many connections to build with Firebase const maxChildren = {# of CPUs the machine has} // How long to keep child processes alive const timeout = 10 * 60 * 1000 // 10 minutes for (var i = 0; i &lt; maxChildren; i++) { // your-test.js should contain your application-specific test var child = spawn('node', ['your-test.js', `--id=${i}`, '-- timeout=${timeout}']) child.stdout.on('data', (data) =&gt; { console.log(`stdout: ${data}`) }); child.stderr.on('data', (data) =&gt; { console.log(`stderr: ${data}`) }); child.on('close', (code) =&gt; { if (code !== 0) console.log(`Child ${i} process exited with an error. Code ${code}`) }) } </code></pre> <p>I'm sure the engineers at Firebase must do some load testing, since there has to be a basis for the 100K concurrent connection limit. Does anyone have insight into the tools they use?</p>
0debug
Debug Assertion Failed? : <p>I'm fairly new to coding (currently learning C) and I'm confused as to why this error occurs when I'm running the console.</p> <p><a href="https://i.stack.imgur.com/JQ5XA.png" rel="nofollow noreferrer">The Error that I get.</a></p> <p>Here's the code that I wrote (it's a function that I call in the main to run a simple calculator program), I'm still not completely done my switch, but I'm pretty sure it should work with just that! (I think).</p> <pre><code>void part2() { printf("Welcome to Part 2!\n\n\nThis is a basic calculator!\nPlease select one of the following options:\n\n"); printf("1) - Addition\n"); printf("2) - Subtraction\n"); printf("3) - Multiplication\n"); printf("4) - Division\n"); printf("0) - Exit Program\n\n"); int selectionNum = 0; float operand1 = 0; float operand2 = 0; float result = 0; scanf_s("%d",selectionNum); switch (selectionNum) { case '1' : printf("_ + _ = _\n"); printf("Please enter the first addend: "); scanf_s("%f", operand1); printf("\n\n"); printf("%f", operand1); printf(" + _ = _\n"); printf("Please enter the second addend: "); scanf_s("%f", operand2); printf("\n\n"); result = operand1 + operand2; printf("%f", operand1); printf(" + "); printf("%f", operand2); printf(" = "); printf("%f", result); break; default : printf("\n\nYou entered an invalid option! :(\n Try again!"); } printf("done."); } </code></pre> <p>Does anyone know what might be the issue? :(</p>
0debug
How to increase The maximum size of one packet in MySQL Server : <p>**While trying to import full world database to mysql server i have occurred error attached , ** <a href="https://i.stack.imgur.com/NAQON.png" rel="nofollow noreferrer"> Screen</a> @Bogir[rus] have found solution for Me but i still want to share how to resolve this problem.</p> <p>Open mysql shell and enter SET GLOBAL max_allowed_packet=1073741824; (where "1073741824" is maximum size in kb)</p>
0debug
I can not edit date and time : when I try to edit date and time I can not, it shows the error: Cannot format given Object as a Date. this is RegistroBean public String Editar(Integer id){ Registros r=this.registrosFacade.find(id); DateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy"); String strDate = dateFormatter.format(fecha); fecha = strDate; this.fecha=r.getFecha().toString(); DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss 'Z'"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); String strHour = dateFormat.format(hora_in); hora_in = strHour; this.hora_in=r.getHoraIn().toString(); String strHour2 = dateFormat.format(hora_out); hora_out = strHour2; this.hora_out=r.getHoraOut().toString(); this.vehiculo=r.getIdVehiculo(); return "RegistroEdit"; } public String GuardarEdicion(RegistroController rc, int id) throws ParseException{ Registros r = new Registros(); Locale locale = new Locale("es","CO"); String datef = "MM/dd/yyyy"; SimpleDateFormat formatter = new SimpleDateFormat(datef, locale); Date parsedDate = formatter.parse(fecha); r.setFecha(parsedDate); String hourf = "HH:mm:ss 'Z'"; SimpleDateFormat format = new SimpleDateFormat(hourf, locale); format.setTimeZone(TimeZone.getTimeZone("GMT")); Date Hin = format.parse(hora_in); r.setHoraIn(Hin); Date Hout = format.parse(hora_out); r.setHoraOut(Hout); r.setIdVehiculo(vehiculosFacade.find(vehiculo.getId())); this.registrosFacade.edit(r); return "RegistroList"; } In the list view when I edit, I click on this button: <h:commandButton value="Editar" action="#{registroController.Editar(item.id)}"/> this is RegistroEdit.xhtml <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <f:view> <h:form> <h1><h:outputText value="Editar Registro"/></h1> <p:panelGrid columns="2"> <p:outputLabel value="Fecha:" for="fecha" /> <p:inputText id="fecha" value="#{registroController.fecha}" title="Fecha" > </p:inputText> <p:outputLabel value="HoraIn:" for="horaIn" /> <p:inputText id="horaIn" value="#{registroController.hora_in}" title="HoraIn" required="true" requiredMessage="The HoraIn field is required."> </p:inputText> <p:outputLabel value="HoraOut:" for="horaOut" /> <p:inputText id="horaOut" value="#{registroController.hora_out}" title="HoraOut" required="true" requiredMessage="The HoraOut field is required."> </p:inputText> <p:outputLabel value="IdVehiculo:" for="idVehiculo" /> <p:selectOneMenu id="idVehiculo" value="#{registroController.vehiculo.id}" required="true" requiredMessage="The IdVehiculo field is required."> <!-- TODO: update below reference to list of available items--> <f:selectItems value="#{vehiculoController.findAll()}" var="v" itemLabel="#{v.placa}" itemValue="#{v.id}"/> </p:selectOneMenu> </p:panelGrid> <h:panelGrid columns="2"> <h:commandButton id="registroCommand" value="Guardar" action="#{registroController.GuardarEdicion(registroController, registroController.id)}"/> <h:commandButton id="registroCommand1" value="Ir a Lista" action="#{registro.prepareList()}"/> </h:panelGrid> </h:form> </f:view> </h:body> </html> trying to edit date and time it appears in this format: fecha: Sun May 27 00:00:00 COT 2018 hora_in: Thu Jan 01 06:15:30 COT 1970 hora_out: Thu Jan 01 14:30:00 COT 1970 should appear the date and time in this format fecha: 05/27/2018 hora_in: 06:15:30 hora_out: 14:30:00 What should I change to convert date to string without any error?
0debug
static inline int put_dwords(uint32_t addr, uint32_t *buf, int num) { int i; for(i = 0; i < num; i++, buf++, addr += sizeof(*buf)) { uint32_t tmp = cpu_to_le32(*buf); cpu_physical_memory_rw(addr,(uint8_t *)&tmp, sizeof(tmp), 1); } return 1; }
1threat
loading fonts ttf crashes , error loading with libgdx : i have the problem with load the ttf file, my code: Label migliaLabel; migliaLabel = new Label("label", new Label.LabelStyle(new BitmapFont(Gdx.files.internal("Kalam-Regular.ttf")), Color.MAGENTA)); the file Kalam-Regular.ttf is in the folder assets/Kalam-Regular.ttf but when i run the game, android studio get in error: > FATAL EXCEPTION: GLThread 125 > com.badlogic.gdx.utils.GdxRuntimeException: Error loading font file: > Kalam-Regular.ttf > at > com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.load(BitmapFont.java:665) > at > com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.<init>(BitmapFont.java:475) > at > com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:114) > at > com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:107) > at com.surfsurvivor.game.GameClass.show(GameClass.java:181) > at com.badlogic.gdx.Game.setScreen(Game.java:61) > at com.surfsurvivor.game.SurfClass.create(SurfClass.java:26) > at > com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:254) > at > android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505) > at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) > Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Invalid > padding. > at > com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.load(BitmapFont.java:488) > at > com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.<init>(BitmapFont.java:475)  > at > com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:114)  > at > com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:107)  > at com.surfsurvivor.game.GameClass.show(GameClass.java:181)  > at com.badlogic.gdx.Game.setScreen(Game.java:61)  > at com.surfsurvivor.game.SurfClass.create(SurfClass.java:26)  > at > com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:254)  > at > android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)  > at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) how can solve ? Thanks
0debug
How to get start tensflow? : How to get start tensflow, is there any book to read? I'm good at java programming, and have some background of machine learning. I'd like to find a book or a course about tensflow. Is there any recommendation?
0debug
Difference between as_json and to_json method in Ruby : <p>What's the difference between the two methods <code>as_json</code> and <code>to_json</code>. Are they same? If not what's the difference between them?</p>
0debug
How to quickly replicate/update local library under $R_LIBS_USER? : <p>Suppose that</p> <ol> <li>the version of R I have installed is 3.3.1;</li> <li>my environment variable <code>$R_LIBS_USER</code> is set to <code>$HOME/my/R_lib/%V</code>; and</li> <li>I have a directory <code>$HOME/my/R_lib/3.3.1</code> containing a large number of packages I've installed over time.</li> </ol> <p>Now I want to upgrade my version of R, to 3.4.1, say.</p> <p>I'm looking for a convenient way to install a new collection of packages under the new directory <code>$HOME/my/R_lib/3.4.1</code> that is the "version-3.4.1-equivalent" of the library I currently have under <code>$HOME/my/R_lib/3.3.1</code>.</p> <p>(IOW, I'm looking for a functionality similar to what one can do with Python's <code>pip</code> installer's "freeze" option, which, essentially, produces the input one would have to give the installer in the future to reproduce the current installation.)</p>
0debug
What does "Limit of total fields [1000] in index [] has been exceeded" means in Elasticsearch : <p>I have Elasticsearch index created which has approx 350 fields (Including nested fields) , I have defined mapping only for few of them. While calling _update API I am getting below exception with 400 Bad request.</p> <p><strong>Limit of total fields [1000] in index [test_index] has been exceeded</strong><br> I want to understand the exact reason for this exception since my number of fields and fields for which mapping is defined both are less than 1000.<br> <strong>Note:</strong> I have nested fields and dynamic mapping enabled. </p> <p>Regards,<br> Sandeep</p>
0debug
When Memory is Allocated to Class in C++? : Class Sample { int a,b; public : int sum() { return (a+b); } }; int main() { Sample sm; } I am beginner to C++ so please provide keep language of your answer simple so that I understand well . Thanks in Advance :)
0debug
about c++ convert infix to postfix when it is tow power(^^) : #include<iostream> #include<stdio.h> using namespace std; #define size 100 int temp,length=0,inx=0,pos=0,top=-1; char symbol,infix[size],postfix[size],stack[size]; void push(char); char pop(); int precedence(char); void infix_to_postfix(char[]); void push(char symbol) { if(top>=size-1) cout<<"stack is over flow push not possible"<<endl; else{ top=top+1; stack[top]=symbol; } } char pop() { temp=stack[top]; top=top-1; return temp; } int precedence(char symbol) { int priority=0; switch(symbol) { case '+': case '-': priority=1; break; case '*': case '/': priority=2; break; case '^': priority=3; break; }//end of switch() return priority; }//end of precedence() void infix_to_postfix(char infix[]) { while(infix[inx]!='\0') { symbol=infix[inx++]; switch(symbol) { case '(': push(symbol); break; case ')': temp=pop(); while(temp!='(') { postfix[pos++]=temp; temp=pop(); } break; case '-': case '+': case '*': case '/': case '^': while(precedence(stack[top])>=precedence(symbol)) { temp=pop(); postfix[pos++]=temp; } push(symbol); break; default: postfix[pos++]=symbol; break; } } while(top>-1) { temp=pop(); postfix[pos++]=temp; postfix[pos]='\0'; } } int main() { cout<<"\nEnter an infix expression:\n"; cin>>infix; infix_to_postfix(infix); cout<<"\nThe equivalent postfix expression:\n";; cout<<postfix<<endl;; return 0; } this is code to covert infix expression to postfix expression when check the while(precedence(stack[top])>=precedence(symbol)) it it ok if it is tow++ or two** or / or two-- because it check from left but in case of power(^)it begin from the right I did not want if it is tow power(^^)to enter to this loop what can I do please help me
0debug
Appending lists according to a per of lists (IndexError: list index out of range) : I have these lists: n_crit = [[1, 2, 3, 4, 5, 6], [1, 1, 1, 1, 1, 1], [-1, 1, -1, -1, -1, 1], [2, 3, 5, 4, 1, 6], [10, 0, 0.5, 1, 0, 0], [0, 30, 5, 6, 0, 0], [0, 0, 0, 0, 0, 5]] crit = [[80, 90, 6, 5.4, 8, 5], [65, 58, 2, 9.7, 1, 1], [83, 60, 4, 7.2, 4, 7], [40, 80, 10, 7.5, 7, 10], [52, 72, 6, 2, 3, 8], [94, 96, 7, 3.6, 5, 6]] and i have these code: DivMatrix = [] for x in range(len(crit)): subList1 = [] for y in range(len(crit[x])): subList2 = [] if (n_crit[2][x]>0): for z in range(len(crit[x])): subList2.append(crit[y][x] - crit[z][x]) elif (n_crit[2][x]<0): for z in range(len(crit[x])): subList2.append(-(crit[y][x] - crit[z][x])) subList1.append(subList2) DivMatrix.append(subList1) Now i want to use the same code for another per of lists that are: n_crit = [[1, 2, 3, 4, 5], [0.23, 0.15, 0.15, 0.215, 0.255], [-1, -1, 1, 1, 1], [2, 6, 5, 4, 1], [4000, 0, 20, 0, 0], [0, 0, 40, 2, 0], [0, 1.5, 0, 0, 0]] crit = [[15000, 7, 60, 3, 3], [27000, 9, 120, 7, 7], [19000, 8.5, 90, 4, 5], [36000, 10, 140, 8, 7]] But instead i get this error message: subList2.append(-(crit[y][x] - crit[z][x])) IndexError: list index out of range I really dont know what is wrong but i want to use this code for any per of lists i want.
0debug
How to build dynamic where in EF 6 query : <p>How to dynamically filter the results received from the EF. I'm using EF 6. In previous versions of the EF it is very hard. Maybe something has changed? I know I can use filters, one after another, but it is not the most efficient way. Is there a way to do it efficiently and elegantly with the EF 6. On the internet I found a lot of information but they relate to previous versions of EF. </p>
0debug
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err) { return guest_fsfreeze_state.status; }
1threat
something related .get function i think : so basically i can't get my code running , when i use the next function to check if the entered password and name are right if always say wro no ng values entered, basically the variable entry_1 and entry_2 are not storing the input text and i want a solution for that. how to use .get function to solve this i have no idea i have tried assign entry_1 and entry_2 to a variable didnt work out. from tkinter import * root = Tk() # creates a window and initializes the interpreter root.geometry("500x300") name = Label(root, text = "Name") password = Label(root, text = "Password") entry_1 = Entry(root) entry_2 = Entry(root) name.grid(row = 0, column = 0, sticky = E) # for name to be at right use sticky = E (E means east) entry_1.grid(row = 0, column =1) x = "Taha" password.grid(row = 1, column = 0) entry_2.grid(row = 1, column =1) y = "123" c = Checkbutton(root, text = "Keep in logged in").grid(columnspan = 2 ) # mergers the two columns def next(): if a == entry_1 and b == entry_2: print ("Proceed") else: print("wrong values entered") def getname(): return name Next = Button(root, text = "Next", command=next).grid(row = 3, column = 1) root.mainloop() # keep runing the code i want it to say proceed once correct values are entered
0debug
İ couldnt create function to count the number of occurence : i wont create function to count the number of occurence in an array.İ cant compile and run it. Compiler gives the error: The method occurence(int[]) in the type countOfOccurence is not applicable for the arguments (int) public class countOfOccurence { public static void main(String[] args) { // TODO Auto-generated method stub int[] number = {15,16,14}; System.out.print(occurence(number[15])); } public static int occurence(int[] number) { int count = 0; for(int i = 0 ; i < number.length; i++) { for(int k = 0 ; i < number.length; i++) { if(number[k] == number[i]) { count++; } } } return count; } }
0debug
static int tee_write_trailer(AVFormatContext *avf) { TeeContext *tee = avf->priv_data; AVFormatContext *avf2; int ret_all = 0, ret; unsigned i; for (i = 0; i < tee->nb_slaves; i++) { avf2 = tee->slaves[i].avf; if ((ret = av_write_trailer(avf2)) < 0) if (!ret_all) ret_all = ret; if (!(avf2->oformat->flags & AVFMT_NOFILE)) ff_format_io_close(avf2, &avf2->pb); } close_slaves(avf); return ret_all; }
1threat
static void cpu_common_reset(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); int i; if (qemu_loglevel_mask(CPU_LOG_RESET)) { qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index); log_cpu_state(cpu, cc->reset_dump_flags); } cpu->interrupt_request = 0; cpu->halted = 0; cpu->mem_io_pc = 0; cpu->mem_io_vaddr = 0; cpu->icount_extra = 0; cpu->icount_decr.u32 = 0; cpu->can_do_io = 1; cpu->exception_index = -1; cpu->crash_occurred = false; if (tcg_enabled()) { for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) { atomic_set(&cpu->tb_jmp_cache[i], NULL); } #ifdef CONFIG_SOFTMMU tlb_flush(cpu, 0); #endif } }
1threat
I need a formula so that when the screen resolution decreases, objects go to the left : [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/mnl8M.png I have a menu with links and when I decrease the screen resolution, the last buttons shrink, and I need to move all the objects to the left when reducing the screen size
0debug
Please tell how ch[1] on printing gave answer as 2? : #include<stdio.h> int main() { union a { int i; char ch[2]; }; union a z={512}; printf("%d %d %d",z.i,z.ch[0],z.ch[1]); } //Output 512 0 2
0debug
How to Display images horizontally in php : Hi i am having portfolio page in php where i am displaying all the images in portfolio.I need to display the images in horizontal.All the images are fetching from admin panel.here is the code.But here all the images are displaying vertically. <div class="portfolioimages"><img src="image.png"/></div> <div class="portfolioimages"><img src="image1.png"/></div> <div class="portfolioimages"><img src="image2.png"/></div> <div class="portfolioimages"><img src="image3.png"/></div> <div class="portfolioimages"><img src="image4.png"/></div> <div class="portfolioimages"><img src="image5.png"/></div> <div class="portfolioimages"><img src="image6.png"/></div> <div class="portfolioimages"><img src="image7.png"/></div> <div class="portfolioimages"><img src="image8.png"/></div> Here is the fiddle link https://jsfiddle.net/2wzh1mk7/
0debug
void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, uint64_t mcg_status, uint64_t addr, uint64_t misc) { uint64_t mcg_cap = cenv->mcg_cap; unsigned bank_num = mcg_cap & 0xff; uint64_t *banks = cenv->mce_banks; if (bank >= bank_num || !(status & MCI_STATUS_VAL)) return; if (kvm_enabled()) { kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc); return; } if ((status & MCI_STATUS_UC) && (mcg_cap & MCG_CTL_P) && cenv->mcg_ctl != ~(uint64_t)0) return; banks += 4 * bank; if ((status & MCI_STATUS_UC) && banks[0] != ~(uint64_t)0) return; if (status & MCI_STATUS_UC) { if ((cenv->mcg_status & MCG_STATUS_MCIP) || !(cenv->cr[4] & CR4_MCE_MASK)) { fprintf(stderr, "injects mce exception while previous " "one is in progress!\n"); qemu_log_mask(CPU_LOG_RESET, "Triple fault\n"); qemu_system_reset_request(); return; } if (banks[1] & MCI_STATUS_VAL) status |= MCI_STATUS_OVER; banks[2] = addr; banks[3] = misc; cenv->mcg_status = mcg_status; banks[1] = status; cpu_interrupt(cenv, CPU_INTERRUPT_MCE); } else if (!(banks[1] & MCI_STATUS_VAL) || !(banks[1] & MCI_STATUS_UC)) { if (banks[1] & MCI_STATUS_VAL) status |= MCI_STATUS_OVER; banks[2] = addr; banks[3] = misc; banks[1] = status; } else banks[1] |= MCI_STATUS_OVER; }
1threat
How to build a website? : <p>I have a really really big question which is how to write a social networking website like facebook? I want to know which language should I use and why. And also the relationship of them or the whole structure of website. Only a general idea of blue print will be all right. However I don't mind if u can tell me things in detail. Thanks in advance. </p>
0debug
URL Rewriting in .htaccess for url friendly : I have a URL that looks like: > domain.com/category.php?id=5 and > domain.com/profile.php?id=2 How would I go about converting that URL to: > domain.com/categoryname > > domain.com/profilename .htaccess code: RewriteEngine on #category RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([^/.]*)$ category.php?id=$1 #profile RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([^/.]*)$ profile.php?&id=$1 But that works only for category ! Thanks
0debug
Configure time zone to mysql docker container : <p>I have a mysql 5.7 docker container. When I run the mysql command:</p> <pre><code>SELECT now(); </code></pre> <p>It shows the time -3 hours to my current time (which is logical). I want to set the time zone in a config file. Following the documentation in <a href="https://hub.docker.com/_/mysql/" rel="noreferrer">https://hub.docker.com/_/mysql/</a> I create a volume in my <code>docker-compose.yml</code> file like the following:</p> <pre><code>mysqldb: image: mysql:5.7.21 container_name: mysql_container ports: - "3306:3306" volumes: - ./.docker/etc/mysql/custom.cnf:/etc/mysql/conf.d/custom.cnf </code></pre> <p>When I browse the files inside the container the file <code>custom.cnf</code> is there. In that file, I tried some of the ways I found as solutions like:</p> <pre><code>[mysqld] default_time_zone='Europe/Sofia' </code></pre> <p>or a compromise solution which is less elegant as the zone will have to be changed twice a year (summer / winter):</p> <pre><code>[mysqld] default_time_zone='+03:00' </code></pre> <p>but none works. I have the sensation the this file is not loaded by mysql at all because if I try to put invalid configuration in there nothing happens either (the container starts normally). Any suggestions on that?</p>
0debug
JavaScirpt: Filter data from array based on index : I have an multidimensional array and want to filter is based on value at particular index value its look something like this : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> arr = [ [id, postID , title , like ], [1 , 101 , 'New post ', 0], [2 , 101 , 'New Post' , 1], [3 , 102 , 'another post' ,0], [4 , 101 , 'New post' ,1], [5 , 102 , 'another post' , 1], [6 , 103 , 'third post' ,1] ] <!-- end snippet --> I want to filter this array based on postId and get the sum of like with title(as title is same for same postId)and individual array of each, want the result like : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> result_arr = [ [101 , 'New post', 2], [102 , 'another post' ,1], [103 , 'third post' ,1] ] post_id_arry = [101, 102 , 103] title_array = ['New post' ,'another post','third post' ] likes_array - [2,1,1] <!-- end snippet -->
0debug
how can I change path to img src from java script? : <p>I have an image in my div:</p> <pre><code>&lt;div class="pressphone"&gt; &lt;img class="phone" src="../img/template/iphone3.png"&gt; &lt;/div&gt; </code></pre> <p>how can I switch the photo to <code>../img/template/iphone4.png</code> from javascript/jquery?</p>
0debug
equivalent of "canvas" in React Native : <p>I am currently working on an image processing mobile App based on React-Native. However, I can't find any related documents about the image crop, zoom, pan, and save functions (which can be easily achieved by the HTML5 canvas element) on the React-Native official site. </p> <p>I also do some google searches, but only find an "unmaintained" react-native-canvas (<a href="https://github.com/lwansbrough/react-native-canvas" rel="noreferrer">https://github.com/lwansbrough/react-native-canvas</a>). Is there any equivalent of the "canvas" in React Native? </p>
0debug
static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; const uint8_t *buf_end = buf + buf_size; DPCMContext *s = avctx->priv_data; int out = 0; int predictor[2]; int ch = 0; int stereo = s->channels - 1; int16_t *output_samples = data; if (!buf_size) return 0; switch(avctx->codec->id) { case CODEC_ID_ROQ_DPCM: out = buf_size - 8; break; case CODEC_ID_INTERPLAY_DPCM: out = buf_size - 6 - s->channels; break; case CODEC_ID_XAN_DPCM: out = buf_size - 2 * s->channels; break; case CODEC_ID_SOL_DPCM: if (avctx->codec_tag != 3) out = buf_size * 2; else out = buf_size; break; } out *= av_get_bytes_per_sample(avctx->sample_fmt); if (out < 0) { av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); return AVERROR(EINVAL); } if (*data_size < out) { av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); return AVERROR(EINVAL); } switch(avctx->codec->id) { case CODEC_ID_ROQ_DPCM: buf += 6; if (stereo) { predictor[1] = (int16_t)(bytestream_get_byte(&buf) << 8); predictor[0] = (int16_t)(bytestream_get_byte(&buf) << 8); } else { predictor[0] = (int16_t)bytestream_get_le16(&buf); } while (buf < buf_end) { predictor[ch] += s->roq_square_array[*buf++]; predictor[ch] = av_clip_int16(predictor[ch]); *output_samples++ = predictor[ch]; ch ^= stereo; } break; case CODEC_ID_INTERPLAY_DPCM: buf += 6; for (ch = 0; ch < s->channels; ch++) { predictor[ch] = (int16_t)bytestream_get_le16(&buf); *output_samples++ = predictor[ch]; } ch = 0; while (buf < buf_end) { predictor[ch] += interplay_delta_table[*buf++]; predictor[ch] = av_clip_int16(predictor[ch]); *output_samples++ = predictor[ch]; ch ^= stereo; } break; case CODEC_ID_XAN_DPCM: { int shift[2] = { 4, 4 }; for (ch = 0; ch < s->channels; ch++) predictor[ch] = (int16_t)bytestream_get_le16(&buf); ch = 0; while (buf < buf_end) { uint8_t n = *buf++; int16_t diff = (n & 0xFC) << 8; if ((n & 0x03) == 3) shift[ch]++; else shift[ch] -= (2 * (n & 3)); if (shift[ch] < 0) shift[ch] = 0; diff >>= shift[ch]; predictor[ch] += diff; predictor[ch] = av_clip_int16(predictor[ch]); *output_samples++ = predictor[ch]; ch ^= stereo; } break; } case CODEC_ID_SOL_DPCM: if (avctx->codec_tag != 3) { uint8_t *output_samples_u8 = data; while (buf < buf_end) { uint8_t n = *buf++; s->sample[0] += s->sol_table[n >> 4]; s->sample[0] = av_clip_uint8(s->sample[0]); *output_samples_u8++ = s->sample[0]; s->sample[stereo] += s->sol_table[n & 0x0F]; s->sample[stereo] = av_clip_uint8(s->sample[stereo]); *output_samples_u8++ = s->sample[stereo]; } } else { while (buf < buf_end) { uint8_t n = *buf++; if (n & 0x80) s->sample[ch] -= sol_table_16[n & 0x7F]; else s->sample[ch] += sol_table_16[n & 0x7F]; s->sample[ch] = av_clip_int16(s->sample[ch]); *output_samples++ = s->sample[ch]; ch ^= stereo; } } break; } *data_size = out; return buf_size; }
1threat
static int ide_handle_rw_error(IDEState *s, int error, int op) { bool is_read = (op & IDE_RETRY_READ) != 0; BlockErrorAction action = bdrv_get_error_action(s->bs, is_read, error); if (action == BLOCK_ERROR_ACTION_STOP) { s->bus->dma->ops->set_unit(s->bus->dma, s->unit); s->bus->error_status = op; } else if (action == BLOCK_ERROR_ACTION_REPORT) { if (op & IDE_RETRY_DMA) { dma_buf_commit(s); ide_dma_error(s); } else { ide_rw_error(s); } } bdrv_error_action(s->bs, action, is_read, error); return action != BLOCK_ERROR_ACTION_IGNORE; }
1threat
static int xmv_read_packet(AVFormatContext *s, AVPacket *pkt) { XMVDemuxContext *xmv = s->priv_data; int result; if (xmv->video.current_frame == xmv->video.frame_count) { result = xmv_fetch_new_packet(s); if (result) return result; } if (xmv->current_stream == 0) { result = xmv_fetch_video_packet(s, pkt); } else { result = xmv_fetch_audio_packet(s, pkt, xmv->current_stream - 1); } if (result) return result; if (++xmv->current_stream >= xmv->stream_count) { xmv->current_stream = 0; xmv->video.current_frame += 1; } return 0; }
1threat
static void dma_aio_cancel(BlockAIOCB *acb) { DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common); trace_dma_aio_cancel(dbs); if (dbs->acb) { bdrv_aio_cancel_async(dbs->acb); } }
1threat
Have to discard numeric decimal(25.0987)values with some string and keep those values who are decimal(25) : In some source table suppose a column there Column A 25.00 19.890 16 5.980 100 Write sql to show output Column A 25 Decimal values so discarded 16 Decimal values so discarded 100 Nothing coming in my mind
0debug
static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { DeviceState *dev = DEVICE(obj); Error *local_err = NULL; Property *prop = opaque; CharBackend *be = qdev_get_prop_ptr(dev, prop); CharDriverState *s; char *str; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } visit_type_str(v, name, &str, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (!*str) { g_free(str); be->chr = NULL; return; } s = qemu_chr_find(str); g_free(str); if (s == NULL) { error_setg(errp, "Property '%s.%s' can't find value '%s'", object_get_typename(obj), prop->name, str); return; } if (!qemu_chr_fe_init(be, s, errp)) { error_prepend(errp, "Property '%s.%s' can't take value '%s': ", object_get_typename(obj), prop->name, str); return; } }
1threat
static int ppc_hash32_check_prot(int prot, int rw, int access_type) { int ret; if (access_type == ACCESS_CODE) { if (prot & PAGE_EXEC) { ret = 0; } else { ret = -2; } } else if (rw) { if (prot & PAGE_WRITE) { ret = 0; } else { ret = -2; } } else { if (prot & PAGE_READ) { ret = 0; } else { ret = -2; } } return ret; }
1threat
how to round up time to two decimal places in js? : how to round variable x = 00:00:24.320, y = 00:00:19.968 to get final result x = 00:00:24 and y = 00:00:20 ?
0debug
void qmp_block_resize(bool has_device, const char *device, bool has_node_name, const char *node_name, int64_t size, Error **errp) { Error *local_err = NULL; BlockDriverState *bs; int ret; bs = bdrv_lookup_bs(has_device ? device : NULL, has_node_name ? node_name : NULL, &local_err); if (local_err) { error_propagate(errp, local_err); if (!bdrv_is_first_non_filter(bs)) { error_set(errp, QERR_FEATURE_DISABLED, "resize"); if (size < 0) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size"); bdrv_drain_all(); ret = bdrv_truncate(bs, size); switch (ret) { case 0: break; case -ENOMEDIUM: error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); break; case -ENOTSUP: error_set(errp, QERR_UNSUPPORTED); break; case -EACCES: error_set(errp, QERR_DEVICE_IS_READ_ONLY, device); break; case -EBUSY: break; default: error_setg_errno(errp, -ret, "Could not resize"); break;
1threat
static void print_formats(AVFilterContext *filter_ctx) { int i, j; #define PRINT_FMTS(inout, outin, INOUT) \ for (i = 0; i < filter_ctx->nb_##inout##puts; i++) { \ if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \ AVFilterFormats *fmts = \ filter_ctx->inout##puts[i]->outin##_formats; \ for (j = 0; j < fmts->nb_formats; j++) \ if(av_get_pix_fmt_name(fmts->formats[j])) \ printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ i, filter_ctx->filter->inout##puts[i].name, \ av_get_pix_fmt_name(fmts->formats[j])); \ } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \ AVFilterFormats *fmts; \ AVFilterChannelLayouts *layouts; \ \ fmts = filter_ctx->inout##puts[i]->outin##_formats; \ for (j = 0; j < fmts->nb_formats; j++) \ printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ i, filter_ctx->filter->inout##puts[i].name, \ av_get_sample_fmt_name(fmts->formats[j])); \ \ layouts = filter_ctx->inout##puts[i]->outin##_channel_layouts; \ for (j = 0; j < layouts->nb_channel_layouts; j++) { \ char buf[256]; \ av_get_channel_layout_string(buf, sizeof(buf), -1, \ layouts->channel_layouts[j]); \ printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ i, filter_ctx->filter->inout##puts[i].name, buf); \ } \ } \ } \ PRINT_FMTS(in, out, IN); PRINT_FMTS(out, in, OUT); }
1threat
javascript- How to parse JSON using javascript : <p>If my json is this:</p> <pre><code>[ ["cat1"], ["cat2"], ["cat3"], ["cat4"], ["cat5"] ] </code></pre> <p><strong>How to parse this in javascript</strong>. I am looking for some <strong>for loop kind of solution</strong> which can iterate over the json and can give me "cat1 ", "cat2" etc. </p> <p><strong>P.S.:</strong> My json list is dynamic which i am getting from some source. So, i dont know how my json elements are there and what are the fields. </p>
0debug
How do I access integers within an element of a list? : <p>Hi I am new to python and trying to do couple of small tasks in data manipulations. Please note this is not homework, I am aware of this forum. I just do not know how to access a digit within an element hence I do not have any code to start with:</p> <p>I have a list</p> <pre><code>numbers = [865, 1169, 1208, 1243, 329] </code></pre> <p>-How do I write a program that displays the values in the list numbers in descending order sorted by their last digit</p> <p>Output I desire:</p> <pre><code>Sorted by last digit: [1169, 1208, 865, 1243, 290] </code></pre> <p>-How can I display the values in the list numbers in descending order sorted by the sum of their digits that are odd numbers</p> <p>Output I desire:</p> <pre><code>Sorted by sum of odd digits: [1169, 290, 865, 1243, 1208] </code></pre>
0debug
Play musical notes in Swift Playground : <p>I am trying to play a short musical note sequence with a default sine wave as sound inside a Swift Playground. At a later point I'd like to replace the sound with a <em>Soundfont</em> but at the moment I'd be happy with just producing some sound. </p> <p>I want this to be a midi like sequence with direct control over the notes, not something purely audio based. The <code>AudioToolbox</code> seems to provide what I am looking for but I have troubles fully understanding its usage. Here's what I am currently trying</p> <pre><code>import AudioToolbox // Creating the sequence var sequence:MusicSequence = nil var musicSequence = NewMusicSequence(&amp;sequence) // Creating a track var track:MusicTrack = nil var musicTrack = MusicSequenceNewTrack(sequence, &amp;track) // Adding notes var time = MusicTimeStamp(1.0) for index:UInt8 in 60...72 { var note = MIDINoteMessage(channel: 0, note: index, velocity: 64, releaseVelocity: 0, duration: 1.0 ) musicTrack = MusicTrackNewMIDINoteEvent(track, time, &amp;note) time += 1 } // Creating a player var musicPlayer:MusicPlayer = nil var player = NewMusicPlayer(&amp;musicPlayer) player = MusicPlayerSetSequence(musicPlayer, sequence) player = MusicPlayerStart(musicPlayer) </code></pre> <p>As you can imagine, there's no sound playing. I appreciate any ideas on how to have that sound sequence playing aloud.</p>
0debug
wordpress site opening malware popups "onclkds.com" on mobile site : i made website on wordpress, till today it was working fine but now when i open my website on mobile it open popups of onclkds.com,i have searched for the solution and many of the forums have suggested that it is issue related to browser extensions. but as i totally researched on it, may be its because of some free plugins which is dynamically creating this dynamic popups. but i tried to deactivate this plugins nothing worked for me because it already added the code to my website. Thanks in advance
0debug
What Bearer token should I be using for Firebase Cloud Messaging testing? : <p>I am trying to send a test notification using Firebase Cloud Messaging via Postman. I'm doing a POST to this url</p> <pre><code>https://fcm.googleapis.com/v1/projects/[my project name]/messages:send </code></pre> <p>The Authorization tab in Postman is set to No Auth and my Headers tab looks like this</p> <pre><code>Content-Type: application/json Authorization: Bearer [server key] </code></pre> <p>[server key] is a newly generated server key in the 'Cloud Messaging' tab of my Firebase project's 'Settings' area. I keep getting this error in response.</p> <pre><code>"error": { "code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } </code></pre> <p>Based on everything I can find, I'm using the right token, but it seems Google disagrees. What should I be sending as the Authorization header to get past this error?</p>
0debug
static void dec_fpu(DisasContext *dc) { if ((dc->tb_flags & MSR_EE_FLAG) && !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) && !((dc->env->pvr.regs[2] & PVR2_USE_FPU_MASK))) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; } qemu_log ("unimplemented FPU insn pc=%x opc=%x\n", dc->pc, dc->opcode); dc->abort_at_next_insn = 1; }
1threat
how to solve the error: invalid conversion from " int* " to " int " : Need some help with the problem. When I compile my code below, it gives me this error: error: invalid conversion from " int* " to " int " I want to create a "calculatePercentage" function, so I can use the value when I call it. void calculatePercentage(int voteResult[],int percentage[]) const int NO_OF_CANDIDATE = 10; int main() { ifstream input("votes.txt",ios::in); string candidates[NUMBER_OF_CANDIDATE]; int voteResult[NUMBER_OF_CANDIDATE]; int percentage[NUMBER_OF_CANDIDATE]; for (int i = 0; i < NUMBER_OF_CANDIDATE; i++) { input >> candidates[i] >> voteResult[i]; } calculatePercentage(voteResult, percentage); // error happened here. return 0; } void calculatePercentage(int voteResult[],int percentage[]) { int totalVotes = 0; for (int i = 0; i < NUMBER_OF_CANDIDATE; i++) { totalVotes += votes[i]; } for (int j = 0; j < NUMBER_OF_CANDIDATE; j++) { double wk_percentage = static_cast<double>{votes[j])/totalVotes; percentage[j]=static_cast<int>(wk_percentage*100); } }
0debug
I want to know about print type explicitly : <p>Print type like %s, %d, %x, %p, ... I understand these things roughly. But when I have to choose one of these, I can't pick similar two of these. For example, when I try to print address of variable, I can have %p or %08X, they will be certainly different in special case. I want to know definition of these print type in order to make reasonable decision. I couldn't find any resource in C standard.</p>
0debug
Not using the Expo fork of react-native : <p>I'm using expo with react native. All is fine, but i get this warning and the app takes a long time in loading :</p> <pre><code> [exp] Warning: Not using the Expo fork of react-native. See https://docs.expo.io/. </code></pre> <p>How can i fix it please. </p>
0debug
Can we have search widget other than toolbar in android : <p>i understand we can have search widget in activity toolbar. As per my requirement we can't use tool bar for search widget, Is that possible we can have search widget as a separate entity in activity just below tool bar or some any where we want (just like Text View or button)?</p>
0debug
static inline void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0) { int i, d; for( i = 0; i < 4; i++ ) { const int tc = tc0[i]; if( tc <= 0 ) { pix += 2*ystride; continue; } for( d = 0; d < 2; d++ ) { const int p0 = pix[-1*xstride]; const int p1 = pix[-2*xstride]; const int q0 = pix[0]; const int q1 = pix[1*xstride]; if( FFABS( p0 - q0 ) < alpha && FFABS( p1 - p0 ) < beta && FFABS( q1 - q0 ) < beta ) { int delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-xstride] = av_clip_uint8( p0 + delta ); pix[0] = av_clip_uint8( q0 - delta ); } pix += ystride; } } }
1threat
How to remove bootstrap menu from my website? : <p>URL of my website.. <a href="http://www.moonli8photgrphy.move.pk/" rel="nofollow">http://www.moonli8photgrphy.move.pk/</a></p> <p>I'd downloaded bootstrap theme, and this menu of bootstrap is somewhere in the stylesheets, but i can't configure it out. I've edited almost website, but unable to disable this bootstrap menu. So i want to remove it and upload my proper website as soon as i can.</p>
0debug
What is the output? : <p>What is displayed by Line 1 Below? BlueJ prints out A@18fea98, but I don't think this is correct. Please help, thank you.</p> <pre><code>class A{ private int x; public A(){ x=0; } } //test code in client program A test = new A(); out.println(test);//LINE 1 </code></pre>
0debug
static int loadvm_postcopy_handle_run(MigrationIncomingState *mis) { PostcopyState ps = postcopy_state_set(POSTCOPY_INCOMING_RUNNING); trace_loadvm_postcopy_handle_run(); if (ps != POSTCOPY_INCOMING_LISTENING) { error_report("CMD_POSTCOPY_RUN in wrong postcopy state (%d)", ps); return -1; } mis->bh = qemu_bh_new(loadvm_postcopy_handle_run_bh, NULL); qemu_bh_schedule(mis->bh); return LOADVM_QUIT; }
1threat
String Resources in Angular : <p>I'm developing an Angular app and I'm looking for something similar to Android Resource available in Android development.</p> <p>Here is the way to get a string in Android:</p> <p><code>String mystring = getResources().getString(R.string.mystring);</code></p> <p>I would like to have the same in Angular.</p> <p>For example if I have few HTML templates in which there are the same message about the wrong email provided...</p> <pre><code>&lt;div class="alert alert-danger"&gt; &lt;strong&gt;Error!&lt;/strong&gt;Invalid e-mail &lt;/div&gt; </code></pre> <p>I would like to have the following:</p> <pre><code>&lt;div class="alert alert-danger"&gt; &lt;strong&gt;Error!&lt;/strong&gt;{{myStrings.INVALID_EMAIL}} &lt;/div&gt; </code></pre> <p>...or something like this...</p> <pre><code>&lt;div class="alert alert-danger"&gt; &lt;strong&gt;Error!&lt;/strong&gt;{{'INVALID_EMAIL' | stringGenerator}} &lt;/div&gt; </code></pre> <p>Do you know a way or addon I can install to reach that?</p>
0debug
Disable eslint for all files in directory and subdirectories : <p>I have some files that are in a certain folder and those files are from a vendor so I cannot control them. I would like to disable eslint for all the files in that directory and all subfolders. </p>
0debug
argument of type int is incompatible with parameter of type lpcwstr in Visual Studio resource files : I'm trying to add a .wav file as a resource into my C++ game and play it on runtime. Here's my code in my main class: `PlaySound(IDR_WAVE1, GetModuleHandle(NULL), SND_FILENAME);` My resource.h file: #define IDR_WAVE1 104 #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 105 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif And my .rc file: https://hastebin.com/evupijufiq.coffeescript Issue is I keep getting an error when trying to play this file from the resource. `argument of type int is incompatible with parameter of type lpcwstr` I've included the resource.h header and I've tried adding quotation marks in `PlaySound(IDR_WAVE1, GetModuleHandle(NULL), SND_FILENAME);` so it would end up being: `PlaySound("IDR_WAVE1", GetModuleHandle(NULL), SND_FILENAME);` however this only made the Windows machine beep once. I would appreciate any help as I've never worked with resource files. Cheers.
0debug
Dynamically changing number of columns in React Native Flat List : <p>I have a <code>FlatList</code> where I want to change the number of columns based on orientation. However, I get the red screen when I do this. As per the red screen error message, I'm not quite sure how I should be changing the key prop. Any help is appreciated.</p> <pre><code> // dynamically changing number of columns const numCols = orientation === constants.PORTRAIT ? 3 : 8 &lt;FlatList keyExtractor={(_, i) =&gt; i} numColumns={numCols} // assigning the number of columns horizontal={false} renderItem={({ item }) =&gt; &lt;ListItem imageUrl={item.url} /&gt;} /&gt;} </code></pre> <p><a href="https://i.stack.imgur.com/bcmS1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bcmS1.png" alt="red screen of death"></a></p>
0debug
Objecy.keys().map() VS Array.map() : <p>can you give me an argument why approach A is better than approach B.</p> <p>Approach A:</p> <pre><code>const transformCompanyOptions = (companies: Array&lt;{id: string, name: string}&gt;, selectedId: string) =&gt; { return companies.map(key =&gt; { return { value: key.id, label: key.name, checked: key.id === selectedId } }) }; </code></pre> <p>Approach B:</p> <pre><code>const transformCompanyOptions = (companies: Array&lt;{id: string, name: string}&gt;, selectedId: string) =&gt; { const ret = Object.keys(companies).map((key) =&gt; { const newCompany = {}; newCompany['value'] = companies[key].id; newCompany['label'] = companies[key].name; if (companies[key].id === selectedId) { newCompany['checked'] = true; } return newCompany; }); return ret; }; </code></pre> <p><strong>Thank you</strong></p>
0debug
Do objects with a lot of reference fields (except arrays) devastate Hotspot JVM's GC(s) heap traversal performance? : <p>Imagine that I define <a href="https://github.com/OpenHFT/SmoothieMap/blob/80a6a2f9dcba246cdf6c6c01259c7fca90a2fd68/src/main/java/net/openhft/smoothie/Segment.java#L860-L867" rel="noreferrer">a class with dozens of reference fields</a> (instead of using reference arrays such as <code>Object[]</code>), and instantiate this class pretty heavily in an application.</p> <p>Is it going to affect the performance of garbage collector in Hotspot JVM, when it traverses the heap to calculate reachable objects? Or, maybe, it would lead to significant extra memory consumption, for some JVM's internal data structures or class metadata? Or, is it going to affect the efficiency of an application in some other way?</p> <p>Are those aspects specific to each garbage collector algorithm in Hotspot, or those parts of Hotspot's mechanics are shared and used by all garbage collectors alike?</p>
0debug
static av_cold int avs_decode_init(AVCodecContext * avctx) { avctx->pix_fmt = PIX_FMT_PAL8; return 0; }
1threat
varia name as class name : i have started learning java made my progress till oops concept but i dnt understand below code while implementing a link list Class Node{ Node next; int i; } in above code i created a class named "Node" and create "Node" type of variable what that means Node is not a data type if i print that "next" it shows NULL i didnt understand that concept if that "next" holds reference of variable "Node" why it doesnt printed its address on the screen why it printed NULL
0debug
static gint range_compare(gconstpointer a, gconstpointer b) { Range *ra = (Range *)a, *rb = (Range *)b; if (ra->begin == rb->begin && ra->end == rb->end) { return 0; } else if (range_get_last(ra->begin, ra->end) < range_get_last(rb->begin, rb->end)) { return -1; } else { return 1; } }
1threat
static int test_vector_fmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const float *v1, const float *src0, float scale) { LOCAL_ALIGNED(32, float, cdst, [LEN]); LOCAL_ALIGNED(32, float, odst, [LEN]); int ret; memcpy(cdst, v1, LEN * sizeof(*v1)); memcpy(odst, v1, LEN * sizeof(*v1)); cdsp->vector_fmac_scalar(cdst, src0, scale, LEN); fdsp->vector_fmac_scalar(odst, src0, scale, LEN); if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST)) av_log(NULL, AV_LOG_ERROR, "vector_fmac_scalar failed\n"); return ret; }
1threat
How do i move this seach bar to the top right of the screen? : [enter image description here][1] [1]: https://i.stack.imgur.com/upgCP.png How do i move this to the top right corner (html/css) give me some of your examples guys ima need a lot of your help.im new to this programming thing. i hope i can be good in programming web(javascript and its components) in 6-12 months then go learn app development.
0debug
UISwitch setOn(:, animated:) does not work as document : <p>As Apple's document write, <code>UISwitch</code>'s function <code>setOn(on: Bool, animated: Bool)</code> does not send action. It works fine before iOS 10, but it will send action after I call it in iOS 10. I call it in "ValueChanged" event to force switch back, so I got this event action twice. is it a bug in iOS 10?</p>
0debug
Open file with system application in a Progressive Web App : <p>I'm trying to figure out if it is possible to open a file from a Progressive Web App with the default system application.</p> <p>The idea is that a PWA would store for offline use some files (e.g. a .docx file), and that the user would be able to open them without (re)downloading them. </p> <p>The ideal situation would be that the PWA is able to load into memory the file, make it accessible to the default system application for that file type (e.g. Word for .docx files), watch for changes (i.e. the user saves edits), and then store it back into the PWA storage. Even a read-only solution would be great.</p> <p>Since there are serious security issues implied, and since from a Google search nothing came up, my best bet is that this is not (yet) supported. However, I'm hoping that there might be a way to do it of which I'm unaware and that does not require the user to download a copy of the file.</p>
0debug
static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) { GetBitContext *gb=&vc->gb; uint_fast8_t i; vc->mode_count=get_bits(gb, 6)+1; vc->modes=av_mallocz(vc->mode_count * sizeof(vorbis_mode)); AV_DEBUG(" There are %d modes.\n", vc->mode_count); for(i=0;i<vc->mode_count;++i) { vorbis_mode *mode_setup=&vc->modes[i]; mode_setup->blockflag=get_bits1(gb); mode_setup->windowtype=get_bits(gb, 16); mode_setup->transformtype=get_bits(gb, 16); mode_setup->mapping=get_bits(gb, 8); AV_DEBUG(" %d mode: blockflag %d, windowtype %d, transformtype %d, mapping %d \n", i, mode_setup->blockflag, mode_setup->windowtype, mode_setup->transformtype, mode_setup->mapping); } return 0; }
1threat
static int init_poc(H264Context *h){ MpegEncContext * const s = &h->s; const int max_frame_num= 1<<h->sps.log2_max_frame_num; int field_poc[2]; if(h->nal_unit_type == NAL_IDR_SLICE){ h->frame_num_offset= 0; }else{ if(h->frame_num < h->prev_frame_num) h->frame_num_offset= h->prev_frame_num_offset + max_frame_num; else h->frame_num_offset= h->prev_frame_num_offset; } if(h->sps.poc_type==0){ const int max_poc_lsb= 1<<h->sps.log2_max_poc_lsb; if(h->nal_unit_type == NAL_IDR_SLICE){ h->prev_poc_msb= h->prev_poc_lsb= 0; } if (h->poc_lsb < h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb/2) h->poc_msb = h->prev_poc_msb + max_poc_lsb; else if(h->poc_lsb > h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb/2) h->poc_msb = h->prev_poc_msb - max_poc_lsb; else h->poc_msb = h->prev_poc_msb; field_poc[0] = field_poc[1] = h->poc_msb + h->poc_lsb; if(s->picture_structure == PICT_FRAME) field_poc[1] += h->delta_poc_bottom; }else if(h->sps.poc_type==1){ int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc; int i; if(h->sps.poc_cycle_length != 0) abs_frame_num = h->frame_num_offset + h->frame_num; else abs_frame_num = 0; if(h->nal_ref_idc==0 && abs_frame_num > 0) abs_frame_num--; expected_delta_per_poc_cycle = 0; for(i=0; i < h->sps.poc_cycle_length; i++) expected_delta_per_poc_cycle += h->sps.offset_for_ref_frame[ i ]; if(abs_frame_num > 0){ int poc_cycle_cnt = (abs_frame_num - 1) / h->sps.poc_cycle_length; int frame_num_in_poc_cycle = (abs_frame_num - 1) % h->sps.poc_cycle_length; expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle; for(i = 0; i <= frame_num_in_poc_cycle; i++) expectedpoc = expectedpoc + h->sps.offset_for_ref_frame[ i ]; } else expectedpoc = 0; if(h->nal_ref_idc == 0) expectedpoc = expectedpoc + h->sps.offset_for_non_ref_pic; field_poc[0] = expectedpoc + h->delta_poc[0]; field_poc[1] = field_poc[0] + h->sps.offset_for_top_to_bottom_field; if(s->picture_structure == PICT_FRAME) field_poc[1] += h->delta_poc[1]; }else{ int poc; if(h->nal_unit_type == NAL_IDR_SLICE){ poc= 0; }else{ if(h->nal_ref_idc) poc= 2*(h->frame_num_offset + h->frame_num); else poc= 2*(h->frame_num_offset + h->frame_num) - 1; } field_poc[0]= poc; field_poc[1]= poc; } if(s->picture_structure != PICT_BOTTOM_FIELD) s->current_picture_ptr->field_poc[0]= field_poc[0]; if(s->picture_structure != PICT_TOP_FIELD) s->current_picture_ptr->field_poc[1]= field_poc[1]; if(s->picture_structure == PICT_FRAME) s->current_picture_ptr->poc= FFMIN(field_poc[0], field_poc[1]); return 0; }
1threat
linux shell script source destination copy directory : <p>I want to copy files from my current directory to a directory which is pointed out by user(destination). Destination directory will be input by user during the execution of the script. Command should create directory and add write permission and check the required size. Basically a Linux installation kind of script. I have written a basic script using "cp" command , but I want advanced script which takes input from user and copies accordingly. Any idea on this?</p>
0debug
static uint32_t m5206_mbar_readw(void *opaque, target_phys_addr_t offset) { m5206_mbar_state *s = (m5206_mbar_state *)opaque; int width; offset &= 0x3ff; if (offset >= 0x200) { hw_error("Bad MBAR read offset 0x%x", (int)offset); } width = m5206_mbar_width[offset >> 2]; if (width > 2) { uint32_t val; val = m5206_mbar_readl(opaque, offset & ~3); if ((offset & 3) == 0) val >>= 16; return val & 0xffff; } else if (width < 2) { uint16_t val; val = m5206_mbar_readb(opaque, offset) << 8; val |= m5206_mbar_readb(opaque, offset + 1); return val; } return m5206_mbar_read(s, offset, 2); }
1threat
How to convert json array to json objects : I need to convert a JSON array to JSON objects by id as key for every object in javascript. What I have: [{ "author" : "aaaa", "catid" : 22, "id" : 23, "name" : "Book a", "size" : 56658 }, { "author" : "bbbb", "catid" : 22, "id" : 24, "logo" : "logo", "name" : "Book b", "size" : 73386 }, { "author" : "cccc", "catid" : 22, "id" : 25, "logo" : "logo", "name" : "Book c", "size" : 84777 }, { "author" : "ddd", "catid" : 22, "id" : 26, "logo" : "logo", "name" : "Book d", "size" : 105139 }] What I need: { "23":{ "author" : "aaaa", "catid" : 22, "name" : "Book a", "size" : 56658 }, "24":{ "author" : "bbbb", "catid" : 22, "logo" : "logo", "name" : "Book b", "size" : 73386 }, "25":{ "author" : "cccc", "catid" : 22, "logo" : "logo", "name" : "Book c", "size" : 84777 }, "26":{ "author" : "ddd", "catid" : 22, "logo" : "logo", "name" : "Book d", "size" : 105139 }}
0debug
static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext *c, int representation_id, int final) { int i, start_index = 0, start_number = 1; if (c->window_size) { start_index = FFMAX(os->nb_segments - c->window_size, 0); start_number = FFMAX(os->segment_index - c->window_size, 1); } if (c->use_template) { int timescale = c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE; avio_printf(out, "\t\t\t\t<SegmentTemplate timescale=\"%d\" ", timescale); if (!c->use_timeline) avio_printf(out, "duration=\"%"PRId64"\" ", c->last_duration); avio_printf(out, "initialization=\"%s\" media=\"%s\" startNumber=\"%d\">\n", c->init_seg_name, c->media_seg_name, c->use_timeline ? start_number : 1); if (c->use_timeline) { int64_t cur_time = 0; avio_printf(out, "\t\t\t\t\t<SegmentTimeline>\n"); for (i = start_index; i < os->nb_segments; ) { Segment *seg = os->segments[i]; int repeat = 0; avio_printf(out, "\t\t\t\t\t\t<S "); if (i == start_index || seg->time != cur_time) { cur_time = seg->time; avio_printf(out, "t=\"%"PRId64"\" ", seg->time); } avio_printf(out, "d=\"%d\" ", seg->duration); while (i + repeat + 1 < os->nb_segments && os->segments[i + repeat + 1]->duration == seg->duration && os->segments[i + repeat + 1]->time == os->segments[i + repeat]->time + os->segments[i + repeat]->duration) repeat++; if (repeat > 0) avio_printf(out, "r=\"%d\" ", repeat); avio_printf(out, "/>\n"); i += 1 + repeat; cur_time += (1 + repeat) * seg->duration; } avio_printf(out, "\t\t\t\t\t</SegmentTimeline>\n"); } avio_printf(out, "\t\t\t\t</SegmentTemplate>\n"); } else if (c->single_file) { avio_printf(out, "\t\t\t\t<BaseURL>%s</BaseURL>\n", os->initfile); avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%"PRId64"\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number); avio_printf(out, "\t\t\t\t\t<Initialization range=\"%"PRId64"-%"PRId64"\" />\n", os->init_start_pos, os->init_start_pos + os->init_range_length - 1); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; avio_printf(out, "\t\t\t\t\t<SegmentURL mediaRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->range_length - 1); if (seg->index_length) avio_printf(out, "indexRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->index_length - 1); avio_printf(out, "/>\n"); } avio_printf(out, "\t\t\t\t</SegmentList>\n"); } else { avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%"PRId64"\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number); avio_printf(out, "\t\t\t\t\t<Initialization sourceURL=\"%s\" />\n", os->initfile); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; avio_printf(out, "\t\t\t\t\t<SegmentURL media=\"%s\" />\n", seg->file); } avio_printf(out, "\t\t\t\t</SegmentList>\n"); } if (c->hls_playlist && start_index < os->nb_segments) { int timescale = os->ctx->streams[0]->time_base.den; char temp_filename_hls[1024]; char filename_hls[1024]; AVIOContext *out_hls = NULL; AVDictionary *http_opts = NULL; int target_duration = 0; int ret = 0; const char *proto = avio_find_protocol_name(c->dirname); int use_rename = proto && !strcmp(proto, "file"); get_hls_playlist_name(filename_hls, sizeof(filename_hls), c->dirname, representation_id); snprintf(temp_filename_hls, sizeof(temp_filename_hls), use_rename ? "%s.tmp" : "%s", filename_hls); set_http_options(&http_opts, c); avio_open2(&out_hls, temp_filename_hls, AVIO_FLAG_WRITE, NULL, &http_opts); av_dict_free(&http_opts); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; double duration = (double) seg->duration / timescale; if (target_duration <= duration) target_duration = hls_get_int_from_double(duration); } ff_hls_write_playlist_header(out_hls, 6, -1, target_duration, start_number, PLAYLIST_TYPE_NONE); ff_hls_write_init_file(out_hls, os->initfile, c->single_file, os->init_range_length, os->init_start_pos); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; ret = ff_hls_write_file_entry(out_hls, 0, c->single_file, (double) seg->duration / timescale, 0, seg->range_length, seg->start_pos, NULL, c->single_file ? os->initfile : seg->file, NULL); if (ret < 0) { av_log(os->ctx, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n"); } } if (final) ff_hls_write_end_list(out_hls); avio_close(out_hls); if (use_rename) avpriv_io_move(temp_filename_hls, filename_hls); } }
1threat
How to find the average of numbers within a specified range : I am using the 'diamonds' dataset from ggplot2 and am wanting to find the average of the 'carat' column. However, I want to find the average every 0.1: **Between** 0.2 and 0.29 0.3 and 0.39 0.4 and 0.49 etc.
0debug
Android design like shown in images below? : <p>I want home page like <a href="http://i.stack.imgur.com/PUYfB.png" rel="nofollow">this</a> and after selecting the category <a href="http://i.stack.imgur.com/VYqj7.png" rel="nofollow">this</a> view should overlap the homepage with slide in from right animation &amp; slide out from left on back pressed</p>
0debug
static int vhdx_update_header(BlockDriverState *bs, BDRVVHDXState *s, bool generate_data_write_guid, MSGUID *log_guid) { int ret = 0; int hdr_idx = 0; uint64_t header_offset = VHDX_HEADER1_OFFSET; VHDXHeader *active_header; VHDXHeader *inactive_header; if (s->curr_header == 0) { hdr_idx = 1; header_offset = VHDX_HEADER2_OFFSET; } active_header = s->headers[s->curr_header]; inactive_header = s->headers[hdr_idx]; inactive_header->sequence_number = active_header->sequence_number + 1; inactive_header->file_write_guid = s->session_guid; if (generate_data_write_guid) { vhdx_guid_generate(&inactive_header->data_write_guid); } if (log_guid) { inactive_header->log_guid = *log_guid; } vhdx_write_header(bs->file, inactive_header, header_offset, true); if (ret < 0) { goto exit; } s->curr_header = hdr_idx; exit: return ret; }
1threat
void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, unsigned int *out_bytes, unsigned max_in_bytes, unsigned max_out_bytes) { VirtIODevice *vdev = vq->vdev; unsigned int max, idx; unsigned int total_bufs, in_total, out_total; VRingMemoryRegionCaches *caches; MemoryRegionCache indirect_desc_cache = MEMORY_REGION_CACHE_INVALID; int64_t len = 0; int rc; if (unlikely(!vq->vring.desc)) { if (in_bytes) { *in_bytes = 0; } if (out_bytes) { *out_bytes = 0; } return; } rcu_read_lock(); idx = vq->last_avail_idx; total_bufs = in_total = out_total = 0; max = vq->vring.num; caches = atomic_rcu_read(&vq->vring.caches); if (caches->desc.len < max * sizeof(VRingDesc)) { virtio_error(vdev, "Cannot map descriptor ring"); goto err; } while ((rc = virtqueue_num_heads(vq, idx)) > 0) { MemoryRegionCache *desc_cache = &caches->desc; unsigned int num_bufs; VRingDesc desc; unsigned int i; num_bufs = total_bufs; if (!virtqueue_get_head(vq, idx++, &i)) { goto err; } vring_desc_read(vdev, &desc, desc_cache, i); if (desc.flags & VRING_DESC_F_INDIRECT) { if (desc.len % sizeof(VRingDesc)) { virtio_error(vdev, "Invalid size for indirect buffer table"); goto err; } if (num_bufs >= max) { virtio_error(vdev, "Looped descriptor"); goto err; } len = address_space_cache_init(&indirect_desc_cache, vdev->dma_as, desc.addr, desc.len, false); desc_cache = &indirect_desc_cache; if (len < desc.len) { virtio_error(vdev, "Cannot map indirect buffer"); goto err; } max = desc.len / sizeof(VRingDesc); num_bufs = i = 0; vring_desc_read(vdev, &desc, desc_cache, i); } do { if (++num_bufs > max) { virtio_error(vdev, "Looped descriptor"); goto err; } if (desc.flags & VRING_DESC_F_WRITE) { in_total += desc.len; } else { out_total += desc.len; } if (in_total >= max_in_bytes && out_total >= max_out_bytes) { goto done; } rc = virtqueue_read_next_desc(vdev, &desc, desc_cache, max, &i); } while (rc == VIRTQUEUE_READ_DESC_MORE); if (rc == VIRTQUEUE_READ_DESC_ERROR) { goto err; } if (desc_cache == &indirect_desc_cache) { address_space_cache_destroy(&indirect_desc_cache); total_bufs++; } else { total_bufs = num_bufs; } } if (rc < 0) { goto err; } done: address_space_cache_destroy(&indirect_desc_cache); if (in_bytes) { *in_bytes = in_total; } if (out_bytes) { *out_bytes = out_total; } rcu_read_unlock(); return; err: in_total = out_total = 0; goto done; }
1threat
static void rtc_get_date(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Error *err = NULL; RTCState *s = MC146818_RTC(obj); struct tm current_tm; rtc_update_time(s); rtc_get_time(s, &current_tm); visit_start_struct(v, NULL, "struct tm", name, 0, &err); if (err) { goto out; } visit_type_int32(v, &current_tm.tm_year, "tm_year", &err); if (err) { goto out_end; } visit_type_int32(v, &current_tm.tm_mon, "tm_mon", &err); if (err) { goto out_end; } visit_type_int32(v, &current_tm.tm_mday, "tm_mday", &err); if (err) { goto out_end; } visit_type_int32(v, &current_tm.tm_hour, "tm_hour", &err); if (err) { goto out_end; } visit_type_int32(v, &current_tm.tm_min, "tm_min", &err); if (err) { goto out_end; } visit_type_int32(v, &current_tm.tm_sec, "tm_sec", &err); if (err) { goto out_end; } out_end: error_propagate(errp, err); err = NULL; visit_end_struct(v, errp); out: error_propagate(errp, err); }
1threat
StringBuffer "eating" some characters : I came across a strange problem recently. I am using `StringBuffer` to create a string and when I added some white spaces to the string, I realized that some characters were gone. An example: StringBuffer sb = new StringBuffer(); sb.append("000.00 "); sb.append(filler(800)); sb.append(filler(800)); sb.append(filler(800)); sb.append(filler(800)); sb.append(filler(800)); System.out.println(sb.toString()); `filler` is a function to create blank strings: public String filler(Integer size) { return String.join("", Collections.nCopies(size, " ")); } When I run that, the last two zeros of my initial string simple disappears. Is that some kind of bug on StringBuffer class
0debug
how to integrate my app into facebook app in ios? : how to integrate my app into face book app in iOS?[like this screen(jasper app)][1] [1]: https://i.stack.imgur.com/TuZRt.png
0debug
MSBuild plugin configuration in not available in Jenkins Configuration page : <p>I have installed MSBuild plugin for jenkins using plugin management. It was installed successfully and I am able to see the options for MSBuild in Job configuration page. </p> <p>But, unfortunately I am not able to see MSBuild section in Jenkins configuration page. I need to provide the path for MSBuild.exe in that section.</p> <p>Any idea why?</p> <p>Thanks in advance!</p>
0debug
Why .substring() does not work well in my java proyect? : I'm trying to erase a row from a csv file with this function: public void borrarAlumno(String id) throws IOException { BufferedReader br = new BufferedReader(new FileReader(archivo)); StringBuffer sb = new StringBuffer(""); String line; while ((line = br.readLine()) != null) { System.out.println(line.substring((5))); if(line != " " && line != null){ if(!line.substring(0, 6).equals(id)){ sb.append(line); } } } br.close(); FileWriter fw = new FileWriter(new File(archivo)); fw.write(sb.toString()); fw.close(); } But i get this error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -5 at java.lang.String.substring(Unknown Source The firt line of the file is : Matricula,Nombre,Apellido i.e. it has something i dont get why the IndexOutOfBounds problem Help me please,
0debug
static inline bool cpu_handle_halt(CPUState *cpu) { if (cpu->halted) { #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) && replay_interrupt()) { X86CPU *x86_cpu = X86_CPU(cpu); qemu_mutex_lock_iothread(); apic_poll_irq(x86_cpu->apic_state); cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); qemu_mutex_unlock_iothread(); } #endif if (!cpu_has_work(cpu)) { current_cpu = NULL; return true; } cpu->halted = 0; } return false; }
1threat
Python: Unexpected behaviour with dict and a colon. ( my_dict['key']: None ) what does the colon ( : ) do? : <p>I have encountered some <em>unexpected</em> behavior with dicts in python.<br> It might be because of annotations, but i'm not sure.<br> Please see the snippet below: </p> <pre><code>&gt;&gt;&gt; d = {} # lets create a dictionary and add something to it. &gt;&gt;&gt; d['a'] = 'a' &gt;&gt;&gt; d {'a': 'a'} &gt;&gt;&gt; d['a'] 'a' &gt;&gt;&gt; # ok all well and good, we know how dicts work, right ? ... &gt;&gt;&gt; d['z'] Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; KeyError: 'z' &gt;&gt;&gt; &gt;&gt;&gt; # yea no key 'z' was inserted. Lets add a colon (:) in the mix ... &gt;&gt;&gt; d['z']: d &gt;&gt;&gt; &gt;&gt;&gt; # nothing happend! weird... ... &gt;&gt;&gt; d['z']: d['z'] Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; KeyError: 'z' &gt;&gt;&gt; # again 'z' was not added to the dict, but what did the colon ??? ... &gt;&gt;&gt; d['z']: d['z']: None File "&lt;stdin&gt;", line 1 d['z']: d['z']: None ^ SyntaxError: invalid syntax &gt;&gt;&gt; &gt;&gt;&gt; # NOW the colon gives an SyntaxError !?! &gt;&gt;&gt; # Lets try to directly use a colon after the dict ... &gt;&gt;&gt; {'a': 'a'}: () File "&lt;stdin&gt;", line 1 SyntaxError: illegal target for annotation &gt;&gt;&gt; &gt;&gt;&gt; # so annotation huh ? &gt;&gt;&gt; # is it possible to annotate on the fly ? ... &gt;&gt;&gt; def func(x): return x ... &gt;&gt;&gt; d = {'f': func} # overwrite previous dict &gt;&gt;&gt; d['f']: callable &gt;&gt;&gt; d['f'].__annotations__ {} &gt;&gt;&gt; # doesn't look like it was taken over ... # lets check if d['f'] returns the callable function: func ... &gt;&gt;&gt; &gt;&gt;&gt; def func(x: str) -&gt; callable: return x ... &gt;&gt;&gt; d = {'f': func} &gt;&gt;&gt; d['f'].__annotations__ # lets check for annotations !! {'x': &lt;class 'str'&gt;, 'return': &lt;built-in function callable&gt;} &gt;&gt;&gt; &gt;&gt;&gt; # I'm confused, what does the colon do? ... &gt;&gt;&gt; </code></pre> <p>I'm curious why the dict syntax doesn't always react on the given colon (:).<br> Also the annotations doesn't seem to be the case (or my conclusion is wrong)</p> <p>So dear readers, what is the purpose of the colon used in the context described above?</p>
0debug
Transform YYYYMM to DD-MM-YYY SQL Server : <p>I have a column in sql server like 201801. How can I transform this in DD-MM-YYYY? Thank you!</p>
0debug
Service compability : I have: public int onStartCommand(Intent intent, int flags, int startId) { try { player.start(); isRunning = true; } catch(Exception e) { isRunning = false; player.stop(); } return 1; } When you click to 1(return 1), you will see: > Must be one of: Service.START_STICKY_COMPATIBILITY, Service.START_STICKY, Service.START_NOT_STICKY, Service.START_REDELIVER_INTENT How do I fix it?
0debug
Unrecognized manifest key 'applications'. warning for Google Chrome : <p>I have created my Web Extension for Firefox which uses Chrome Extension API.</p> <p>But Firefox requires <code>application</code> key in <code>manifest.json</code></p> <p><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json" rel="noreferrer">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json</a></p> <p>If I load the same extension for Google Chrome, Chrome warns as:</p> <pre><code>There were warnings when trying to install this extension: Unrecognized manifest key 'applications'. </code></pre> <p>Although the extension works, I am not sure if I can send a Firefox Web Extension to Google Chrome Store with this manifest file.</p> <p>I can create another project for Google Chrome but I want to keep a single folder that may work for both Firefox and Google Chrome without any warnings.</p> <p>How I am suppose to fix this warning while keeping Firefox requirements?</p>
0debug
GitHub Pages https/www Redirect : <p>How can I get <a href="https://www.test.com" rel="noreferrer">https://www.test.com</a> to redirect to <a href="https://test.com" rel="noreferrer">https://test.com</a> when using GitHub pages to host a static website?</p> <p>I recently enabled TLS (provided by GitHub/Lets Encrypt) for my static site by setting A records at my DNS provider (namecheap). I've also chosen to "Enforce HTTPS" option in my GitHub repository's settings, which handles redirecting requests from <a href="http://test.com" rel="noreferrer">http://test.com</a> to <a href="https://test.com" rel="noreferrer">https://test.com</a>. I have a redirect configured through my DNS provider which forwards <a href="http://www.test.com" rel="noreferrer">http://www.test.com</a> to <a href="https://test.com" rel="noreferrer">https://test.com</a>, but the one missing piece of the puzzle is forwarding <a href="https://www.test.com" rel="noreferrer">https://www.test.com</a> to <a href="https://test.com" rel="noreferrer">https://test.com</a>. </p> <p>Regarding this issue, GitHub says, "If your domain has HTTPS enforcement enabled, GitHub Pages' servers will not automatically route redirects. You must configure www subdomain and root domain redirects with your domain registrar."</p> <p>... and my DNS provider says, "It is not possible to set up a URL redirect in the account for the TCP port forwarding from <a href="http://www.domain.tld" rel="noreferrer">http://www.domain.tld</a> (uses port 80) to <a href="https://www.domain.tld" rel="noreferrer">https://www.domain.tld</a> (working via port 443)."</p> <p>I seem to be caught in an infinite loop of the two services saying the other should provide this functionality.</p>
0debug
Kotlin - Heart equation : i'm trying to position 100 hundred particles in a heart shape. The particles are circles and have a x and y position in the pane. [![This is what happens][1]][1] [1]: https://i.stack.imgur.com/s49Ja.png for (p in ps) { val index = ps.indexOf(p).toDouble() var x = 16 * Math.pow(Math.sin(index * angle.toDouble()), 3.0) //var y = Math.sqrt(Math.cos(index)) * Math.cos(400 * index) + Math.sqrt(Math.abs(index) - 0.4) * Math.pow((4 - index * index), 0.1) var y = (13 * Math.cos(index * angle.toDouble())) -(5 * Math.cos(2 * index * angle.toDouble())) -(2 * Math.cos(3 * index * angle.toDouble())) -(Math.cos(4 * index * angle.toDouble())) p.layoutX = startX + x p.layoutY = startY + y } p = particle ps = particles (list) I have no idea what i did wrong with the equation implementation. I also tried to use Math.toRadians in cos, sin since i read that they require that i order to work. Thank you very much.
0debug
Conemu doesn't work with wsl since windows update : <p>Since I have updated windows, my conemu terminal is giving me the following error each time a session is created: </p> <pre><code>wslbridge error: failed to start backend process note: backend error output: -v: -c: line 0: unexpected EOF while looking for matching `'' -v: -c: line 1: syntax error: unexpected end of file ConEmuC: Root process was alive less than 10 sec, ExitCode=0. Press Enter or Esc to close console... </code></pre> <p>Has anyone an idea to bring conemu to a wsl terminal? Thank you</p>
0debug
Accessing Perl array in bash : <p>I have a perl code where I execute some bash commands using backticks. I want to read a perl array in that bash command. My array has some strings and I want to read them in a for loop of bash.</p> <pre><code>my @aArray = (1,2,3,4); my $command = 'for i in $@aArray; do xxxxx $i; done;'; `$command` </code></pre> <p>I also want to catch error if any part of the loop fails. Thanks</p>
0debug
GoLang size of compressed JSON madness : I'll try to clear up my question. myJSON is a simple JSON string. `len(myJSON)` = 78 e is `json.Marshal(myJSON)` From what I understand, e is now a `[]byte` Then I gzip e like this: var buf bytes.Buffer gz := gzip.NewWriter(&buf) gz.Write(e) gz.Close() And `buf.Len()` = 96 So... why is my compressed buffer bigger than the original non-compressed string?
0debug
static uint64_t iack_read(void *opaque, target_phys_addr_t addr, unsigned size) { return pic_read_irq(isa_pic); }
1threat
static int scsi_disk_emulate_command(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); uint64_t nb_sectors; uint8_t *outbuf; int buflen = 0; if (!r->iov.iov_base) { if (req->cmd.xfer > 65536) { goto illegal_request; } r->buflen = MAX(4096, req->cmd.xfer); r->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, r->buflen); } outbuf = r->iov.iov_base; switch (req->cmd.buf[0]) { case TEST_UNIT_READY: assert(!s->tray_open && bdrv_is_inserted(s->qdev.conf.bs)); break; case INQUIRY: buflen = scsi_disk_emulate_inquiry(req, outbuf); if (buflen < 0) { goto illegal_request; } break; case MODE_SENSE: case MODE_SENSE_10: buflen = scsi_disk_emulate_mode_sense(r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_TOC: buflen = scsi_disk_emulate_read_toc(req, outbuf); if (buflen < 0) { goto illegal_request; } break; case RESERVE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RESERVE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case RELEASE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RELEASE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case START_STOP: if (scsi_disk_emulate_start_stop(r) < 0) { return -1; } break; case ALLOW_MEDIUM_REMOVAL: s->tray_locked = req->cmd.buf[4] & 1; bdrv_lock_medium(s->qdev.conf.bs, req->cmd.buf[4] & 1); break; case READ_CAPACITY_10: memset(outbuf, 0, 8); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; nb_sectors--; s->qdev.max_lba = nb_sectors; if (nb_sectors > UINT32_MAX) { nb_sectors = UINT32_MAX; } outbuf[0] = (nb_sectors >> 24) & 0xff; outbuf[1] = (nb_sectors >> 16) & 0xff; outbuf[2] = (nb_sectors >> 8) & 0xff; outbuf[3] = nb_sectors & 0xff; outbuf[4] = 0; outbuf[5] = 0; outbuf[6] = s->qdev.blocksize >> 8; outbuf[7] = 0; buflen = 8; break; case REQUEST_SENSE: buflen = scsi_build_sense(NULL, 0, outbuf, r->buflen, (req->cmd.buf[1] & 1) == 0); break; case MECHANISM_STATUS: buflen = scsi_emulate_mechanism_status(s, outbuf); if (buflen < 0) { goto illegal_request; } break; case GET_CONFIGURATION: buflen = scsi_get_configuration(s, outbuf); if (buflen < 0) { goto illegal_request; } break; case GET_EVENT_STATUS_NOTIFICATION: buflen = scsi_get_event_status_notification(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_DISC_INFORMATION: buflen = scsi_read_disc_information(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_DVD_STRUCTURE: buflen = scsi_read_dvd_structure(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case SERVICE_ACTION_IN_16: if ((req->cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) { DPRINTF("SAI READ CAPACITY(16)\n"); memset(outbuf, 0, req->cmd.xfer); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; nb_sectors--; s->qdev.max_lba = nb_sectors; outbuf[0] = (nb_sectors >> 56) & 0xff; outbuf[1] = (nb_sectors >> 48) & 0xff; outbuf[2] = (nb_sectors >> 40) & 0xff; outbuf[3] = (nb_sectors >> 32) & 0xff; outbuf[4] = (nb_sectors >> 24) & 0xff; outbuf[5] = (nb_sectors >> 16) & 0xff; outbuf[6] = (nb_sectors >> 8) & 0xff; outbuf[7] = nb_sectors & 0xff; outbuf[8] = 0; outbuf[9] = 0; outbuf[10] = s->qdev.blocksize >> 8; outbuf[11] = 0; outbuf[12] = 0; outbuf[13] = get_physical_block_exp(&s->qdev.conf); if (s->qdev.conf.discard_granularity) { outbuf[14] = 0x80; } buflen = req->cmd.xfer; break; } DPRINTF("Unsupported Service Action In\n"); goto illegal_request; case SYNCHRONIZE_CACHE: scsi_req_ref(&r->req); bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH); r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r); return 0; case SEEK_10: DPRINTF("Seek(10) (sector %" PRId64 ")\n", r->req.cmd.lba); if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } break; #if 0 case MODE_SELECT: DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer); if (r->req.cmd.xfer > 12) { goto illegal_request; } break; case MODE_SELECT_10: DPRINTF("Mode Select(10) (len %lu)\n", (long)r->req.cmd.xfer); if (r->req.cmd.xfer > 16) { goto illegal_request; } break; #endif case WRITE_SAME_10: nb_sectors = lduw_be_p(&req->cmd.buf[7]); goto write_same; case WRITE_SAME_16: nb_sectors = ldl_be_p(&req->cmd.buf[10]) & 0xffffffffULL; write_same: if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } if (!(req->cmd.buf[1] & 0x8)) { goto illegal_request; } scsi_req_ref(&r->req); r->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs, r->req.cmd.lba * (s->qdev.blocksize / 512), nb_sectors * (s->qdev.blocksize / 512), scsi_aio_complete, r); return 0; default: scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); return -1; } assert(r->sector_count == 0); buflen = MIN(buflen, req->cmd.xfer); return buflen; illegal_request: if (r->req.status == -1) { scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); } return -1; illegal_lba: scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); return 0; }
1threat
static void rtas_nvram_store(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { sPAPRNVRAM *nvram = spapr->nvram; hwaddr offset, buffer, len; int alen; void *membuf; if ((nargs != 3) || (nret != 2)) { rtas_st(rets, 0, -3); return; } if (!nvram) { rtas_st(rets, 0, -1); return; } offset = rtas_ld(args, 0); buffer = rtas_ld(args, 1); len = rtas_ld(args, 2); if (((offset + len) < offset) || ((offset + len) > nvram->size)) { rtas_st(rets, 0, -3); return; } membuf = cpu_physical_memory_map(buffer, &len, 0); if (nvram->drive) { alen = bdrv_pwrite(nvram->drive, offset, membuf, len); } else { assert(nvram->buf); memcpy(nvram->buf + offset, membuf, len); alen = len; } cpu_physical_memory_unmap(membuf, len, 0, len); rtas_st(rets, 0, (alen < len) ? -1 : 0); rtas_st(rets, 1, (alen < 0) ? 0 : alen); }
1threat
I'm trying to write the 101010 pattern to the few memory location's, Is the logic correct? : The error while compiling the code is and I notice the error while compiling "a value of type "int *" cannot be assigned to an entity of type "int". I'm concerned about the logic, someone help me? #include <stdio.h> #include <stdlib.h> int main() { int memory =0x10101010u; // printf("the value of memory %d",memory); int n = 1024; int* mem_allocate; int loop = 0; int i = 0; mem_allocate = (int*) malloc(n*sizeof(int)); for(i=0; i<10; i++) { int* temp; temp = ((int*) mem_allocate + i); *temp = (int*)memory; *mem_allocate = temp; if (i == 9) { loop = 1; } } if (loop == 1) { free(mem_allocate); } return 0; }
0debug