problem
stringlengths
26
131k
labels
class label
2 classes
Python Flask send_file StringIO blank files : <p>I'm using python 3.5 and flask 0.10.1 and liking it, but having a bit of trouble with send_file. I ultimately want to process a pandas dataframe (from Form data, which is unused in this example but necessary in the future) and send it to download as a csv (without a temp file). The best way to accomplish this I've seen is to us StringIO.</p> <p>Here is the code I'm attempting to use:</p> <pre><code>@app.route('/test_download', methods = ['POST']) def test_download(): buffer = StringIO() buffer.write('Just some letters.') buffer.seek(0) return send_file(buffer, as_attachment = True,\ attachment_filename = 'a_file.txt', mimetype = 'text/csv') </code></pre> <p>A file downloads with the proper name, however the file is completely blank.</p> <p>Any ideas? Issues with encoding? Has this been answered elsewhere? Thanks!</p>
0debug
how do i handle nested json objects in android : I have a nested jsonobjects with jsonarray which I have to post it a volley request. how should i do it. sample json below. { "type":"invoice", "customer":{ "name": "Deepak", "email":"test@test.com", "contact":"912345678", "billing_address":{ "line1":"Bangalore", "city":"Bangalore", "state":"Karnataka", "zipcode":"000000", "country":"India" } }, "line_items":[ { "name":"News Paper", "description":"Times of India", "amount":10000, "currency":"INR", "quantity":1 }, { "name":"News Paper", "description":"Bangalore Mirror", "amount":10000, "currency":"INR", "quantity":1 } ], "currency":"INR", "sms_notify": "1", "email_notify": "1" } The above is the jsonobject structure i want to send to volley request. This is what i have done but not getting the right jsonobject. try { objMainList = new JSONObject(); objMainList.put("type","invoice"); headobj = new JSONObject(); detobj = new JSONObject(); addrobj = new JSONObject(); footobj = new JSONObject(); headobj.put("name", custname); headobj.put("email", custemail); headobj.put("contact", "1234567"); addrobj.put("line1",custaddr); addrobj.put("city",custcity); addrobj.put("state",custstate); addrobj.put("zipcode",pincode); addrobj.put("country",country); objMainList.put("customer",headobj); objMainList.put("billing_address",headobj); JSONArray prodarray = new JSONArray(); for (int i = 0; i < pvt_list_prodlist.size(); i++) { JSONObject detobj = new JSONObject(); detobj.put("name", pvt_list_prodlist.get(i).getProductcatg()); detobj.put("description", pvt_list_prodlist.get(i).getProductname()); Float total = Float.parseFloat(pvt_list_prodlist.get(i).getProductprice()); Integer gtotal = (int)Math.ceil(total); gtotal = gtotal * 100; detobj.put("amount",gtotal ); detobj.put("currency", "INR"); detobj.put("quantity", 1); prodarray.put(detobj); } objMainList.put("line_items",prodarray); objMainList.put("currency","INR"); objMainList.put("sms_notify",1); objMainList.put("email_notify",1); } catch (JSONException e) { // JSON error e.printStackTrace(); Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show(); } This is what I am getting from the above code... {"type":"invoice","customer":{"name":"Deepak","email":"test_test.com","contact":"1234567"},"billing_address":{"line1":"Bangalore","city":"Bangalore","state":"Karnataka","zipcode":"000001","country":"India"},"line_items":[{"name":"NEWS","description":"Times of India","amount":500,"currency":"INR","quantity":1}],"currency":"INR","sms_notify":1,"email_notify":1} before billing_address it is getting closed. I want it in the above mentioned format. { "type":"invoice", "customer":{ "name": "Deepak", "email":"test@test.com", "contact":"912345678", "billing_address":{ "line1":"Bangalore", "city":"Bangalore", "state":"Karnataka", "zipcode":"000000", "country":"India" } }, "line_items":[ { "name":"News Paper", "description":"Times of India", "amount":10000, "currency":"INR", "quantity":1 }, { "name":"News Paper", "description":"Bangalore Mirror", "amount":10000, "currency":"INR", "quantity":1 } ], "currency":"INR", "sms_notify": "1", "email_notify": "1" } The above is the jsonobject structure i want to send to volley request. This is what i have done but not getting the right jsonobject. try { objMainList = new JSONObject(); objMainList.put("type","invoice"); headobj = new JSONObject(); detobj = new JSONObject(); addrobj = new JSONObject(); footobj = new JSONObject(); headobj.put("name", custname); headobj.put("email", custemail); headobj.put("contact", "1234567"); addrobj.put("line1",custaddr); addrobj.put("city",custcity); addrobj.put("state",custstate); addrobj.put("zipcode",pincode); addrobj.put("country",country); objMainList.put("customer",headobj); objMainList.put("billing_address",headobj); JSONArray prodarray = new JSONArray(); for (int i = 0; i < pvt_list_prodlist.size(); i++) { JSONObject detobj = new JSONObject(); detobj.put("name", pvt_list_prodlist.get(i).getProductcatg()); detobj.put("description", pvt_list_prodlist.get(i).getProductname()); Float total = Float.parseFloat(pvt_list_prodlist.get(i).getProductprice()); Integer gtotal = (int)Math.ceil(total); gtotal = gtotal * 100; detobj.put("amount",gtotal ); detobj.put("currency", "INR"); detobj.put("quantity", 1); prodarray.put(detobj); } objMainList.put("line_items",prodarray); objMainList.put("currency","INR"); objMainList.put("sms_notify",1); objMainList.put("email_notify",1); } catch (JSONException e) { // JSON error e.printStackTrace(); Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show(); } This is what I am getting from the above code... {"type":"invoice","customer":{"name":"Deepak","email":"test_test.com","contact":"1234567"},"billing_address":{"line1":"Bangalore","city":"Bangalore","state":"Karnataka","zipcode":"000001","country":"India"},"line_items":[{"name":"NEWS","description":"Times of India","amount":500,"currency":"INR","quantity":1}],"currency":"INR","sms_notify":1,"email_notify":1} before billing_address it is getting closed. I want it in the above mentioned format. this is the output i should get as jsonobject . { "type":"invoice", "customer":{ "name": "Deepak", "email":"test@test.com", "contact":"912345678", "billing_address":{ "line1":"Bangalore", "city":"Bangalore", "state":"Karnataka", "zipcode":"000000", "country":"India" } }, "line_items":[ { "name":"News Paper", "description":"Times of India", "amount":10000, "currency":"INR", "quantity":1 }, { "name":"News Paper", "description":"Bangalore Mirror", "amount":10000, "currency":"INR", "quantity":1 } ], "currency":"INR", "sms_notify": "1", "email_notify": "1" }
0debug
I'm very new to python and I'm stuck with a basic function. Any help is appreciated : def func(i): numbers=[] for x in range(0,i): print "At the top x is %d" %x numbers.append(x) x=x+1 print "At the bottom x is %d" %x print "The numbers:" for i in numbers: print i print "I'm going to print the numbers!" i=raw_input("Enter the number: ") func(i) #I'm using python 3.0 and using textwrangler and terminal to code. The code is supposed to print all numbers from zero to the input.
0debug
Is there any point of using private / protected instead of public in c# apart from having 'clean code'? : <p>Apart from the code being cleaner or to maintain the object-oriented status of c#, is there really any point in using private / protected instead of public?</p>
0debug
Android radio button not accepting input : I have two classes: **QuestionModel.java** package com.invertemotech.quizapp; public class QuestionModel { public QuestionModel(String questionString, String answer ,String optA, String optB, String optC , String optD) { QuestionString = questionString; Answer = answer; OptA = optA; OptB = optB; OptC = optC; OptD= optD; } public String getQuestionString() { return QuestionString; } public void setQuestionString (String questionString) { QuestionString = questionString; } public void setOptA(String optA) { OptA = optA; } public String getOptA() { return OptA; } public void setOptB(String optB) { OptB = optB; } public String getOptB() { return OptB; } public String getOptC() { return OptC; } public void setOptC(String optC) { OptC = optC; } public String getOptD() { return OptD; } public void setOptD(String optD) { OptD = optD; } public String getAnswer() { return Answer; } public void setAnswer(String answer) { Answer = answer; } private String QuestionString; private String OptA; private String OptB; private String OptC; private String OptD; private String Answer; } **MainActivity.java** package com.invertemotech.quizapp; import android.support.v7.app.AppCompat Activity; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import cn.pedant.SweetAlert.SweetAlertDialog; public class MainActivity extends AppCompatActivity { ArrayList<QuestionModel> questionModelArraylist; TextView questionLabel, questionCountLabel, scoreLabel ; // EditText answerEdt; // TextView txtQuestion; RadioButton option1, option2 , option3 ; Button submitButton; ProgressBar progressBar; QuestionModel currentQuestion; int currentPosition = 0; int numberOfCorrectAnswer = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); questionCountLabel = findViewById(R.id.noQuestion); questionLabel = findViewById(R.id.question); scoreLabel = findViewById(R.id.score); option1 = findViewById(R.id.option1); option2 = findViewById(R.id.option2); option3 = findViewById(R.id.option3); // option4 = findViewById(R.id.option4); submitButton = findViewById(R.id.submit); progressBar = findViewById(R.id.progress); questionModelArraylist = new ArrayList<>(); questionModelArraylist.add(new QuestionModel("Which company is the largest manufacturer of network equipment ?", "IBM", "A: IBM", "B: CICSO", "C: DELL" , "D: HP")); questionModelArraylist.add(new QuestionModel("Which of the following is NOT an operating system ?", "Bios", "A: BIOS", "B: LINUX", "C: WINDOWS" , "D: MAC")); questionModelArraylist.add(new QuestionModel("Who is the first cricketer to score an international double century in 50-over match ?", "Sachin Tendulkar", "A: Sachin Tendulkar", "B: Brian Lara", "C: Rohit Sharma" , "D: Rahul Dravid")); questionModelArraylist.add(new QuestionModel("Who is the founder of Apple Inc. ?", "Steve", "A: Bill Gates", "B: Steve Jobs", "C: Suresh" , "D: Mark")); questionModelArraylist.add(new QuestionModel("Which is the biggest largest city in the world ?", "Reno", "A: Shanghai", "B: Vienna", "C: Reno" , "D: Hong Kong")); Collections.shuffle(questionModelArraylist , new Random()); currentQuestion = questionModelArraylist.get(currentPosition); setData(); // setUpQuestion(); submitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkAnswer(); } }); } public void checkAnswer(){ RadioGroup grp = findViewById(R.id.options); RadioButton answer = findViewById(grp.getCheckedRadioButtonId()); String newAnswer = String.valueOf(answer.getText()); if(newAnswer.equalsIgnoreCase(questionModelArraylist .get(currentPosition).getAnswer())){ numberOfCorrectAnswer ++; Log.d("Score", "Your score: "+ newAnswer); new SweetAlertDialog(MainActivity.this, SweetAlertDialog.SUCCESS_TYPE) .setTitleText("Good job! Keep Going") .setContentText("Right Answer") .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sweetAlertDialog) { currentPosition ++; setData(); // answerEdt.setText(""); sweetAlertDialog.dismiss(); } }) .show(); }else { new SweetAlertDialog(MainActivity.this, SweetAlertDialog.WARNING_TYPE) .setTitleText("Wrong Answer") .setContentText("The right answer is : "+questionModelArraylist.get(currentPosition).getAnswer()) .setConfirmText("OK") .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { sDialog.dismiss(); currentPosition ++; setData(); // answerEdt.setText(""); } }) .show(); } int x = ((currentPosition+1) * 100) / questionModelArraylist.size(); progressBar.setProgress(x); } public void setData(){ if(questionModelArraylist.size()>currentPosition) { questionLabel.setText(questionModelArraylist .get(currentPosition).getQuestionString()); option1.setText(questionModelArraylist.get(currentPosition).getOptA()); option2.setText(questionModelArraylist.get(currentPosition).getOptB()); option3.setText(questionModelArraylist.get(currentPosition).getOptC()); // option4.setText(questionModelArraylist.get(currentPosition).getOptD()); scoreLabel.setText("Score :" + numberOfCorrectAnswer + "/" + questionModelArraylist.size()); questionCountLabel.setText("Question No : " + (currentPosition + 1)); }else{ new SweetAlertDialog(MainActivity.this, SweetAlertDialog.SUCCESS_TYPE) .setTitleText("You have successfully completed the quiz") .setContentText("Your score is : "+ numberOfCorrectAnswer + "/" + questionModelArraylist.size()) .setConfirmText("Restart") .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { sDialog.dismissWithAnimation(); currentPosition = 0; numberOfCorrectAnswer = 0; progressBar.setProgress(0); setData(); } }) .setCancelText("Close") .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { sDialog.dismissWithAnimation(); finish(); } }) .show(); } } } When i run the program and click on radio button it doesnt take my answer as input instead it always show right answer where i selected correct answer or not. i have an arraylist on the same mainactivity class and model on other class. It a simple bignner android application.
0debug
aio_ctx_finalize(GSource *source) { AioContext *ctx = (AioContext *) source; thread_pool_free(ctx->thread_pool); aio_set_event_notifier(ctx, &ctx->notifier, NULL); event_notifier_cleanup(&ctx->notifier); rfifolock_destroy(&ctx->lock); qemu_mutex_destroy(&ctx->bh_lock); timerlistgroup_deinit(&ctx->tlg);
1threat
Filter a complicated string containing email addresses using jquery (Get string containing email addresses split by one or more commas) : I need to split a specific string by a single comma containing email addresses. The string can be complicated like `"abc@xyz.com,xyz@xyz.com,,,pqr@xyz.com,,,,123@xyz.com,"` And preferred output is as follows `"abc@xyz.com,xyz@xyz.com,pqr@xyz.com,123@xyz.com"` I tried using jquery `split()` but cannot find a proper way of doing this
0debug
Why String concat(String) method is acting differently? : <p>I please check the code below.</p> <p>I can understand that String s1 is not assigned and so even though concat(string) method is used it is giving the original output.</p> <p>But also, in case of String s2 no variable is assigned but concatenation worked.</p> <p>Can someone please explain?</p> <pre><code>package com.stringconcat.main; public class StringConcat { public static void main(String[] args) { String s1 = "Hello"; s1.concat(" World"); System.out.println("String s1 output: " + s1); String s2 = "Hello" /*s1*/; System.out.println("String s2 output: " + s2.concat(" World")); } } </code></pre> <p>The outputs are: String s1 output: Hello String s2 output: Hello World</p>
0debug
static void pcx_palette(const uint8_t **src, uint32_t *dst, unsigned int pallen) { unsigned int i; for (i=0; i<pallen; i++) *dst++ = 0xFF000000 | bytestream_get_be24(src); if (pallen < 256) memset(dst, 0, (256 - pallen) * sizeof(*dst)); }
1threat
Why my <div class="header"> doesn't display full width 100% in smallscreen : <p><a href="https://i.stack.imgur.com/kGvkD.jpg" rel="nofollow noreferrer">enter image description here</a></p> <p>Here is the problem</p>
0debug
I can't reach static class field from instance variable : <p>I'm wondering I can't reach static class field from instance variable</p> <pre><code> class aa { public static string b = "bb"; } Console.WriteLine(aa.b); //fine aa f = new aa(); f.b //error </code></pre> <p>Why? Do I make something wrong?</p>
0debug
special charater not reading in txt file : i am using stream reader for reading text file. This is my content which is have txt file **Schools 's are a suitable public** when i read that text i got **Schoolss are a suitable public** this output. i did't receive quotation. how to receive special charater is stream reader? i used following code using (StreamReader reader = new StreamReader(CommonGetSet.FileName, System.Text.Encoding.UTF8)) { docKeyword = XDocument.Load(reader); }
0debug
void json_end_array(QJSON *json) { qstring_append(json->str, " ]"); json->omit_comma = false; }
1threat
Python function printing output during variable assignment : <p>I want the following code to run the defined function, and save the output of the defined function in the specified variable "functionsOutput". And then, I want to replace the new lines in the variable with spaces. </p> <p>But my code below isn't doing that. What am i doing wrong? The assignment of the function output to a variable is printing out the output. I don't want that. I want the output stored in the variable. </p> <pre><code>#!/usr/bin/python2.7 mylist = [ "hello", "you", "are", "so", "cool" ] def printWithoutNewlines(): for objects in mylist: objects = objects.replace('hello', "hi") print objects functionsOutput = printWithoutNewlines() functionsOutput.replace('\n', ' ') </code></pre>
0debug
static bool ga_open_pidfile(const char *pidfile) { int pidfd; char pidstr[32]; pidfd = open(pidfile, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR); if (pidfd == -1 || lockf(pidfd, F_TLOCK, 0)) { g_critical("Cannot lock pid file, %s", strerror(errno)); if (pidfd != -1) { close(pidfd); } return false; } if (ftruncate(pidfd, 0) || lseek(pidfd, 0, SEEK_SET)) { g_critical("Failed to truncate pid file"); goto fail; } snprintf(pidstr, sizeof(pidstr), "%d\n", getpid()); if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr)) { g_critical("Failed to write pid file"); goto fail; } return true; fail: unlink(pidfile); return false; }
1threat
static inline abi_long host_to_target_sockaddr(abi_ulong target_addr, struct sockaddr *addr, socklen_t len) { struct target_sockaddr *target_saddr; if (len == 0) { return 0; } target_saddr = lock_user(VERIFY_WRITE, target_addr, len, 0); if (!target_saddr) return -TARGET_EFAULT; memcpy(target_saddr, addr, len); if (len >= offsetof(struct target_sockaddr, sa_family) + sizeof(target_saddr->sa_family)) { target_saddr->sa_family = tswap16(addr->sa_family); } if (addr->sa_family == AF_NETLINK && len >= sizeof(struct sockaddr_nl)) { struct sockaddr_nl *target_nl = (struct sockaddr_nl *)target_saddr; target_nl->nl_pid = tswap32(target_nl->nl_pid); target_nl->nl_groups = tswap32(target_nl->nl_groups); } else if (addr->sa_family == AF_PACKET) { struct sockaddr_ll *target_ll = (struct sockaddr_ll *)target_saddr; target_ll->sll_ifindex = tswap32(target_ll->sll_ifindex); target_ll->sll_hatype = tswap16(target_ll->sll_hatype); } else if (addr->sa_family == AF_INET6 && len >= sizeof(struct target_sockaddr_in6)) { struct target_sockaddr_in6 *target_in6 = (struct target_sockaddr_in6 *)target_saddr; target_in6->sin6_scope_id = tswap16(target_in6->sin6_scope_id); } unlock_user(target_saddr, target_addr, len); return 0; }
1threat
String Compare in VBA? : There is two variables I am Assigning them two numbers given below Dim string a,b a="100" and b="65" if a<=b ? True Why? i want to be false?
0debug
static int hash32_bat_601_prot(CPUPPCState *env, target_ulong batu, target_ulong batl) { int key, pp; pp = batu & BATU32_601_PP; if (msr_pr == 0) { key = !!(batu & BATU32_601_KS); } else { key = !!(batu & BATU32_601_KP); } return ppc_hash32_pp_check(key, pp, 0); }
1threat
int kvm_arch_init_vcpu(CPUState *cs) { struct { struct kvm_cpuid2 cpuid; struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES]; } QEMU_PACKED cpuid_data; X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; uint32_t limit, i, j, cpuid_i; uint32_t unused; struct kvm_cpuid_entry2 *c; uint32_t signature[3]; int r; cpuid_i = 0; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = KVM_CPUID_SIGNATURE; if (!hyperv_enabled(cpu)) { memcpy(signature, "KVMKVMKVM\0\0\0", 12); c->eax = 0; } else { memcpy(signature, "Microsoft Hv", 12); c->eax = HYPERV_CPUID_MIN; } c->ebx = signature[0]; c->ecx = signature[1]; c->edx = signature[2]; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = KVM_CPUID_FEATURES; c->eax = env->features[FEAT_KVM]; if (hyperv_enabled(cpu)) { memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12); c->eax = signature[0]; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = HYPERV_CPUID_VERSION; c->eax = 0x00001bbc; c->ebx = 0x00060001; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = HYPERV_CPUID_FEATURES; if (cpu->hyperv_relaxed_timing) { c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE; } if (cpu->hyperv_vapic) { c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE; c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE; } c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = HYPERV_CPUID_ENLIGHTMENT_INFO; if (cpu->hyperv_relaxed_timing) { c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED; } if (cpu->hyperv_vapic) { c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED; } c->ebx = cpu->hyperv_spinlock_attempts; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = HYPERV_CPUID_IMPLEMENT_LIMITS; c->eax = 0x40; c->ebx = 0x40; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = KVM_CPUID_SIGNATURE_NEXT; memcpy(signature, "KVMKVMKVM\0\0\0", 12); c->eax = 0; c->ebx = signature[0]; c->ecx = signature[1]; c->edx = signature[2]; } has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF); has_msr_pv_eoi_en = c->eax & (1 << KVM_FEATURE_PV_EOI); has_msr_kvm_steal_time = c->eax & (1 << KVM_FEATURE_STEAL_TIME); cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); for (i = 0; i <= limit; i++) { if (cpuid_i == KVM_MAX_CPUID_ENTRIES) { fprintf(stderr, "unsupported level value: 0x%x\n", limit); abort(); } c = &cpuid_data.entries[cpuid_i++]; switch (i) { case 2: { int times; c->function = i; c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC | KVM_CPUID_FLAG_STATE_READ_NEXT; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); times = c->eax & 0xff; for (j = 1; j < times; ++j) { if (cpuid_i == KVM_MAX_CPUID_ENTRIES) { fprintf(stderr, "cpuid_data is full, no space for " "cpuid(eax:2):eax & 0xf = 0x%x\n", times); abort(); } c = &cpuid_data.entries[cpuid_i++]; c->function = i; c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); } break; } case 4: case 0xb: case 0xd: for (j = 0; ; j++) { if (i == 0xd && j == 64) { break; } c->function = i; c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX; c->index = j; cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx); if (i == 4 && c->eax == 0) { break; } if (i == 0xb && !(c->ecx & 0xff00)) { break; } if (i == 0xd && c->eax == 0) { continue; } if (cpuid_i == KVM_MAX_CPUID_ENTRIES) { fprintf(stderr, "cpuid_data is full, no space for " "cpuid(eax:0x%x,ecx:0x%x)\n", i, j); abort(); } c = &cpuid_data.entries[cpuid_i++]; } break; default: c->function = i; c->flags = 0; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); break; } } if (limit >= 0x0a) { uint32_t ver; cpu_x86_cpuid(env, 0x0a, 0, &ver, &unused, &unused, &unused); if ((ver & 0xff) > 0) { has_msr_architectural_pmu = true; num_architectural_pmu_counters = (ver & 0xff00) >> 8; if (num_architectural_pmu_counters > MAX_GP_COUNTERS) { num_architectural_pmu_counters = MAX_GP_COUNTERS; } } } cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused); for (i = 0x80000000; i <= limit; i++) { if (cpuid_i == KVM_MAX_CPUID_ENTRIES) { fprintf(stderr, "unsupported xlevel value: 0x%x\n", limit); abort(); } c = &cpuid_data.entries[cpuid_i++]; c->function = i; c->flags = 0; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); } if (env->cpuid_xlevel2 > 0) { cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused); for (i = 0xC0000000; i <= limit; i++) { if (cpuid_i == KVM_MAX_CPUID_ENTRIES) { fprintf(stderr, "unsupported xlevel2 value: 0x%x\n", limit); abort(); } c = &cpuid_data.entries[cpuid_i++]; c->function = i; c->flags = 0; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); } } cpuid_data.cpuid.nent = cpuid_i; if (((env->cpuid_version >> 8)&0xF) >= 6 && (env->features[FEAT_1_EDX] & (CPUID_MCE | CPUID_MCA)) == (CPUID_MCE | CPUID_MCA) && kvm_check_extension(cs->kvm_state, KVM_CAP_MCE) > 0) { uint64_t mcg_cap; int banks; int ret; ret = kvm_get_mce_cap_supported(cs->kvm_state, &mcg_cap, &banks); if (ret < 0) { fprintf(stderr, "kvm_get_mce_cap_supported: %s", strerror(-ret)); return ret; } if (banks > MCE_BANKS_DEF) { banks = MCE_BANKS_DEF; } mcg_cap &= MCE_CAP_DEF; mcg_cap |= banks; ret = kvm_vcpu_ioctl(cs, KVM_X86_SETUP_MCE, &mcg_cap); if (ret < 0) { fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-ret)); return ret; } env->mcg_cap = mcg_cap; } qemu_add_vm_change_state_handler(cpu_update_state, env); c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0); if (c) { has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) || !!(c->ecx & CPUID_EXT_SMX); } cpuid_data.cpuid.padding = 0; r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data); if (r) { return r; } r = kvm_check_extension(cs->kvm_state, KVM_CAP_TSC_CONTROL); if (r && env->tsc_khz) { r = kvm_vcpu_ioctl(cs, KVM_SET_TSC_KHZ, env->tsc_khz); if (r < 0) { fprintf(stderr, "KVM_SET_TSC_KHZ failed\n"); return r; } } if (kvm_has_xsave()) { env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave)); } return 0; }
1threat
Is it possible in Typescript to iterate over a const enum? : <p>Similar to this <a href="https://stackoverflow.com/questions/39372804/typescript-how-to-loop-through-enum-values-for-display-in-radio-buttons">question</a>, but with the enumeration marked as a constant: How do you go about iterating or producing an array of from the const enum?</p> <p><strong>Example</strong></p> <pre><code>declare const enum FanSpeed { Off = 0, Low, Medium, High } </code></pre> <p><strong>Desireable Results</strong></p> <pre><code>type enumItem = {index: number, value: string}; let result: Array&lt;enumItem&gt; = [ {index: 0, value: "Off"}, {index: 1, value: "Low"}, {index: 2, value: "Medium"}, {index: 3, value: "High"} ]; </code></pre>
0debug
Bulk insert in MongoDB using mongoose : <p>I currently have a collection in Mongodb say "Collection1". I have the following array of objects that need to be into inserted into MongoDB. I am using Mongoose API. For now, I am iterating through the array and inserting each of them into mongo. This is ok for now, but will be a problem when the data is too big. I need a way of inserting the data in bulk into MongoDB without repetition. I am not sure how to do this. I could not find a bulk option in Mongoose.</p> <p>My code below</p> <pre><code>myData = [Obj1,Obj2,Obj3.......] myData.forEach(function(ele){ //console.log(ele) saveToMongo(ele); }); function saveToMongo(obj){ (new Collection1(obj)).save(function (err, response) { if (err) { // console.log('Error while inserting: ' + obj.name + " " +err); } else { // console.log('Data successfully inserted'); } }); return Collection1(obj); } </code></pre>
0debug
R- combining two list of values into a data frame: error arguments imply differing number of rows: : I have two lists that I would like to combine into a dataframe. The lists follows this basic logic: list1<-list("A", "C", "B") list2<-list(c("la la", "po sdfejn kfgndñflgn"), "characther(0)", c("4 5","baby", "yeah")) # note that characther(0) means that there is no data The outcome I want is like this: output <- data.frame( V1 = c(rep("A",3), "C", rep("B",3)), V2 = c(1,2,3, NA, 4,5,6)) I have used codes that I have seen in this page such as: ```solution1 <- do.call(rbind, Map(data.frame, a = list1, b= list2))```as I often do. This code works for the example. However, I obtain the following error message when I use this formula for the large lists I am working on, : Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 1, 0 I have tried to ```unlist(list1), unlist(list1)``` but it does not work. If both list are identical, where is really the source of problem and how can I solve in order to have the desired output?
0debug
static IOMMUTLBEntry s390_translate_iommu(MemoryRegion *iommu, hwaddr addr, bool is_write) { uint64_t pte; uint32_t flags; S390PCIBusDevice *pbdev = container_of(iommu, S390PCIBusDevice, mr); S390pciState *s; IOMMUTLBEntry ret = { .target_as = &address_space_memory, .iova = 0, .translated_addr = 0, .addr_mask = ~(hwaddr)0, .perm = IOMMU_NONE, }; if (!pbdev->configured || !pbdev->pdev) { return ret; } DPRINTF("iommu trans addr 0x%" PRIx64 "\n", addr); s = S390_PCI_HOST_BRIDGE(pci_device_root_bus(pbdev->pdev)->qbus.parent); if (addr == ZPCI_MSI_ADDR) { ret.target_as = &s->msix_notify_as; ret.iova = addr; ret.translated_addr = addr; ret.addr_mask = 0xfff; ret.perm = IOMMU_RW; return ret; } if (!pbdev->g_iota) { pbdev->error_state = true; pbdev->lgstg_blocked = true; s390_pci_generate_error_event(ERR_EVENT_INVALAS, pbdev->fh, pbdev->fid, addr, 0); return ret; } if (addr < pbdev->pba || addr > pbdev->pal) { pbdev->error_state = true; pbdev->lgstg_blocked = true; s390_pci_generate_error_event(ERR_EVENT_OORANGE, pbdev->fh, pbdev->fid, addr, 0); return ret; } pte = s390_guest_io_table_walk(s390_pci_get_table_origin(pbdev->g_iota), addr); if (!pte) { pbdev->error_state = true; pbdev->lgstg_blocked = true; s390_pci_generate_error_event(ERR_EVENT_SERR, pbdev->fh, pbdev->fid, addr, ERR_EVENT_Q_BIT); return ret; } flags = pte & ZPCI_PTE_FLAG_MASK; ret.iova = addr; ret.translated_addr = pte & ZPCI_PTE_ADDR_MASK; ret.addr_mask = 0xfff; if (flags & ZPCI_PTE_INVALID) { ret.perm = IOMMU_NONE; } else { ret.perm = IOMMU_RW; } return ret; }
1threat
How to restore a model by filename in Tensorflow r12? : <p>I have run the distributed mnist example: <a href="https://github.com/tensorflow/tensorflow/blob/r0.12/tensorflow/tools/dist_test/python/mnist_replica.py" rel="noreferrer">https://github.com/tensorflow/tensorflow/blob/r0.12/tensorflow/tools/dist_test/python/mnist_replica.py</a></p> <p>Though I have set the </p> <p><code>saver = tf.train.Saver(max_to_keep=0)</code></p> <p>In previous release, like r11, I was able to run over each check point model and evaluate the precision of the model. This gave me a plot of the progress of the precision versus global steps (or iterations). </p> <p>Prior to r12, tensorflow checkpoint models were saved in two files, <code>model.ckpt-1234</code> and <code>model-ckpt-1234.meta</code>. One could restore a model by passing the <code>model.ckpt-1234</code> filename like so <code>saver.restore(sess,'model.ckpt-1234')</code>. </p> <p>However, I've noticed that in r12, there are now three output files <code>model.ckpt-1234.data-00000-of-000001</code>, <code>model.ckpt-1234.index</code>, and <code>model.ckpt-1234.meta</code>. </p> <p>I see that the the restore documentation says that a path such as <code>/train/path/model.ckpt</code> should be given to restore instead of a filename. Is there any way to load one checkpoint file at a time to evaluate it? I have tried passing the <code>model.ckpt-1234.data-00000-of-000001</code>, <code>model.ckpt-1234.index</code>, and <code>model.ckpt-1234.meta</code> files, but get errors like below:</p> <p><code>W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open logdir/2016-12-08-13-54/model.ckpt-0.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?</code></p> <p><code>NotFoundError (see above for traceback): Tensor name "hid_b" not found in checkpoint files logdir/2016-12-08-13-54/model.ckpt-0.index [[Node: save/RestoreV2_1 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_1/tensor_names, save/RestoreV2_1/shape_and_slices)]]</code></p> <p><code>W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open logdir/2016-12-08-13-54/model.ckpt-0.meta: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?</code></p> <p>I'm running on OSX Sierra with tensorflow r12 installed via pip.</p> <p>Any guidance would be helpful.</p> <p>Thank you.</p>
0debug
static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr, MSIMessage *msg, IOHandler *handler) { VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev); VFIOMSIVector *vector; int ret; trace_vfio_msix_vector_do_use(vdev->vbasedev.name, nr); vector = &vdev->msi_vectors[nr]; if (!vector->use) { vector->vdev = vdev; vector->virq = -1; if (event_notifier_init(&vector->interrupt, 0)) { error_report("vfio: Error: event_notifier_init failed"); } vector->use = true; msix_vector_use(pdev, nr); } qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt), handler, NULL, vector); if (vector->virq >= 0) { if (!msg) { vfio_remove_kvm_msi_virq(vector); } else { vfio_update_kvm_msi_virq(vector, *msg); } } else { vfio_add_kvm_msi_virq(vector, msg, true); } if (vdev->nr_vectors < nr + 1) { vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); vdev->nr_vectors = nr + 1; ret = vfio_enable_vectors(vdev, true); if (ret) { error_report("vfio: failed to enable vectors, %d", ret); } } else { int argsz; struct vfio_irq_set *irq_set; int32_t *pfd; argsz = sizeof(*irq_set) + sizeof(*pfd); irq_set = g_malloc0(argsz); irq_set->argsz = argsz; irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX; irq_set->start = nr; irq_set->count = 1; pfd = (int32_t *)&irq_set->data; if (vector->virq >= 0) { *pfd = event_notifier_get_fd(&vector->kvm_interrupt); } else { *pfd = event_notifier_get_fd(&vector->interrupt); } ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set); g_free(irq_set); if (ret) { error_report("vfio: failed to modify vector, %d", ret); } } return 0; }
1threat
Is that possible to get data from an API automatically recognized as JSON with JQuery? : <p>I'd like to consume an API (Python Django) that produce data under 'String' JSON format.</p> <p>Is there an option to recognize it automatically as a JavaScript object with JQuery?</p>
0debug
def count_elim(num): count_elim = 0 for n in num: if isinstance(n, tuple): break count_elim += 1 return count_elim
0debug
Create package.json from package-lock.json : <p>I downloaded a theme and it has a package-lock.json file but no package.json file. Is there a way I can generate the package.json from the package-lock.json file. How do I install the node modules with just the package-lock.json file. Is there a way to do that?</p>
0debug
How to make this in Javascript, jQuery or Angular : <p>I've been trying to google this for hours, and I'm just totally clueless. I want to make something similar to the "Recent Vehicles" section at the bottom of this site, where you can click the arrow and the cars slide on and off the screen. </p> <p>I have no idea what's the correct thing to google. I know it's not a slider or a carousel, because that's what I've been searching all night.</p> <p>If someone can show me the basic idea of how to do this in Javascript, jQuery or Angular that would be awesome. Thanks in advance! =)</p> <p><a href="http://demo.themesuite.com/index.php?theme=Automotive-WP" rel="nofollow">http://demo.themesuite.com/index.php?theme=Automotive-WP</a></p>
0debug
static int nbd_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVNBDState *s = bs->opaque; char *export = NULL; int result, sock; Error *local_err = NULL; nbd_config(s, options, &export, &local_err); if (local_err) { error_propagate(errp, local_err); return -EINVAL; } sock = nbd_establish_connection(bs, errp); if (sock < 0) { return sock; } result = nbd_client_init(bs, sock, export, errp); return result; }
1threat
static int print_uint64(DeviceState *dev, Property *prop, char *dest, size_t len) { uint64_t *ptr = qdev_get_prop_ptr(dev, prop); return snprintf(dest, len, "%" PRIu64, *ptr); }
1threat
static int apng_read_packet(AVFormatContext *s, AVPacket *pkt) { APNGDemuxContext *ctx = s->priv_data; int64_t ret; int64_t size; AVIOContext *pb = s->pb; uint32_t len, tag; if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 46)) < 0) return ret; len = avio_rb32(pb); tag = avio_rl32(pb); switch (tag) { case MKTAG('f', 'c', 'T', 'L'): if (len != 26) return AVERROR_INVALIDDATA; if ((ret = decode_fctl_chunk(s, ctx, pkt)) < 0) return ret; len = avio_rb32(pb); tag = avio_rl32(pb); if (len > 0x7fffffff || tag != MKTAG('f', 'd', 'A', 'T') && tag != MKTAG('I', 'D', 'A', 'T')) return AVERROR_INVALIDDATA; size = 38 + 8 + len + 4 ; if (size > INT_MAX) return AVERROR(EINVAL); if ((ret = avio_seek(pb, -46, SEEK_CUR)) < 0 || (ret = av_append_packet(pb, pkt, size)) < 0) return ret; if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 8)) < 0) return ret; len = avio_rb32(pb); tag = avio_rl32(pb); while (tag && tag != MKTAG('f', 'c', 'T', 'L') && tag != MKTAG('I', 'E', 'N', 'D')) { if (len > 0x7fffffff) return AVERROR_INVALIDDATA; if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 || (ret = av_append_packet(pb, pkt, len + 12)) < 0) return ret; if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 8)) < 0) return ret; len = avio_rb32(pb); tag = avio_rl32(pb); } if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0) return ret; if (ctx->is_key_frame) pkt->flags |= AV_PKT_FLAG_KEY; pkt->pts = ctx->pkt_pts; pkt->duration = ctx->pkt_duration; ctx->pkt_pts += ctx->pkt_duration; return send_extradata(ctx, pkt); case MKTAG('I', 'E', 'N', 'D'): ctx->cur_loop++; if (ctx->ignore_loop || ctx->num_play >= 1 && ctx->cur_loop == ctx->num_play) { avio_seek(pb, -8, SEEK_CUR); return AVERROR_EOF; } if ((ret = avio_seek(pb, ctx->extra_data_size + 8, SEEK_SET)) < 0) return ret; return send_extradata(ctx, pkt); default: { char tag_buf[32]; av_get_codec_tag_string(tag_buf, sizeof(tag_buf), tag); avpriv_request_sample(s, "In-stream tag=%s (0x%08X) len=%"PRIu32, tag_buf, tag, len); avio_skip(pb, len + 4); } } return AVERROR_PATCHWELCOME; }
1threat
Running JupyterLab as a Desktop Application in Windows 10 : <p>Cristopher Roach wrote the blog of "<a href="http://christopherroach.com/articles/jupyterlab-desktop-app/" rel="noreferrer">Running Jupyter Lab as a Desktop Application</a>" for Mac users. It did not work for Anaconda users in Windows 10. Eventually, what I did is the below:</p> <ol> <li>Go to the directory of C:\ProgramData\Anaconda3\Scripts </li> <li>Find the file of jupyter-lab.exe and make the link of the file in Taskbars. Note: With some reasons, the message of the "Widows could not create the shortcut. Check to see if the disk is full" popped up when I tried to make the link on the Desktop.</li> <li>Right click on the link of jupyter-lab.exe and go to Properties.</li> <li>Download the icon file of Jupyterlab and save it as Jupyterlab.ico in the folder of C:\ProgramData\Anaconda3\Menu\Jupyterlab.ico (=`%ALLUSERSPROFILE%\Anaconda3\Menu\Jupyterlab.ico )</li> <li>Click Change Icon and copy %ALLUSERSPROFILE%\Anaconda3\Menu\Jupyterlab.ico in "Look for icons in this file".</li> <li>Done!</li> </ol> <p>Many steps were required to go through. Is there any simpler way? </p>
0debug
static void write_odml_master(AVFormatContext *s, int stream_index) { AVIOContext *pb = s->pb; AVStream *st = s->streams[stream_index]; AVCodecContext *enc = st->codec; AVIStream *avist = st->priv_data; unsigned char tag[5]; int j; avist->indexes.entry = avist->indexes.ents_allocated = 0; avist->indexes.indx_start = ff_start_tag(pb, "JUNK"); avio_wl16(pb, 4); avio_w8(pb, 0); avio_w8(pb, 0); avio_wl32(pb, 0); ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, enc->codec_type)); avio_wl64(pb, 0); avio_wl32(pb, 0); for (j = 0; j < AVI_MASTER_INDEX_SIZE * 2; j++) avio_wl64(pb, 0); ff_end_tag(pb, avist->indexes.indx_start); }
1threat
Force Equal width columns in CSS FlexBox : <p>I don't think what I'm trying to do is possible.</p> <pre><code>&lt;div class="row"&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I want all the <code>.item</code>s to take up <strong>the maximum, identical horizontal space</strong>, that is (about) 33% in the 1st one, 50% in the second one, and 100% in the last.</p> <p>The idea here is to <strong>not set the size</strong> of the <code>.item</code>s (and avoiding setting <code>id</code>s to elements) for maximum flexibility and minimum error surface ; If this is impossible with FlexBox but doable using another strategy, please share it.</p>
0debug
How can I create a template that will auto populate/calculate cells based on a SKU value? : <p>Every day I work with product data, both product creation and listing creation for the web, eBay, and Amazon. To speed up the process and better maintain data originality I am trying to create a workbook that automates the process. The goal is to be able to enter/copy an individual or list of unique SKU numbers. I have created formulas that then interpret the SKU pattern and pull out vital product information. My problem is that I then need to drag the fill handle to begin calculating that information. Is there any way in Excel that I can auto-populate cells in each SKU row? The list of SKU's is always changing from 1 SKU to thousands. I could fill the formula down to the end of each column, however, this drastically slows down my processing. I need a fast and dynamic way to autofill my entire spreadsheet based on a SKU or SKU's. </p>
0debug
How can i write the sql query for this question below? : Among the students registered for the course "Psychology". what % of them have a GPA > 3? Student: student_id* | student_name | student_gender Course: course_id* | course_name | course_type Student_course_grade: student_id | course_id | grade Please note : 1. Grade field in Student_course_grade table is a number in (5,4,3,2,1) instead of a letter grade like (A,B,C,D,E) 2. For a student who has registered for a course and has not completed it yet, the grade will be null. 3. GPA= Grade Point Average ( average of all grades scored by the student)
0debug
Bower install fails to find satisfying version, although there is a matching tag on GitHub : <p>I am having problems installing bower dependencies on a Windows installation. Installation fails for me on Windows 7 x64, with git <code>2.6.4.windows.1</code>, node <code>v5.4.1</code>, npm <code>3.3.12</code>, bower <code>1.7.2</code>.</p> <p>It works for a colleague on OSX (git <code>2.5.4</code>, node <code>v4.1.1</code>, npm <code>2.14.4</code>, bower <code>1.5.3</code>) and for a colleague on Windows 10 (git <code>2.5.0.windows.1</code>, node <code>v4.2.2</code>, npm <code>2.14.7</code>, bower <code>1.3.11</code>).</p> <p>The error message I am getting basically tells mit that <code>bower-angular-translate</code> does not have a version tag that satisfies <code>2.8.1</code>, but the GitHub repository <a href="https://github.com/angular-translate/bower-angular-translate/releases/tag/2.8.1"><em>does</em> have a version 2.8.1</a>.<br> The failing packages are <code>angular-ui-router</code>, <code>angular-local-storage</code> and <code>angular-translate</code>.</p> <p>I tried downgrading node to <code>0.10.x</code> and <code>4.x.x</code> and reinstalling bower, both did not work.</p> <p>If anyone has experienced the same error message behavior with bower (on windows?) and has successfully solved it, <a href="https://xkcd.com/138/">any pointers</a> would be greatly appreciated.</p> <hr> <p>The error message after running <code>bower install</code>:</p> <pre class="lang-none prettyprint-override"><code>bower angular-translate#~2.8.1 ENORESTARGET No tag found that was able to satisfy ~2.8.1 Additional error details: No versions found in git://github.com/PascalPrecht/bower-angular-translate.git </code></pre> <hr> <p>My <code>bower.json</code>:</p> <pre class="lang-json prettyprint-override"><code>{ "name": "My App Name", "version": "0.0.1", "dependencies": { "angular": "1.4.7", "angular-animate": "1.4.7", "angular-aria": "1.4.7", "angular-cookies": "1.4.7", "angular-resource": "1.4.7", "angular-sanitize": "1.4.7", "angular-material": "0.11.2", "angular-ui-router": "0.2.5", "angular-local-storage": "0.2.x", "angular-translate": "~2.8.1" } } </code></pre> <hr> <p>Just in case, my <code>package.json</code>:</p> <p><div class="snippet" data-lang="js" data-hide="true"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>{ "author": "My Name", "name": "My App Name", "version": "0.0.1", "dependencies": {}, "devDependencies": { "chai": "2.2.0", "gulp": "3.9.x", "gulp-angular-filesort": "1.1.1", "gulp-bower-files": "0.1.x", "gulp-clean": "0.2.x", "gulp-debug": "2.1.x", "gulp-concat": "2.2.x", "gulp-filter": "1.0.x", "gulp-inject": "0.4.x", "gulp-less": "1.2.3", "gulp-livereload": "1.3.x", "gulp-tsc": "0.10.x", "gulp-uglify": "1.2.x", "gulp-util": "2.2.x", "gulp-watch": "0.6.x", "karma-coverage": "~0.2.4", "karma-mocha": "~0.1.6", "karma-phantomjs-launcher": "^0.1.4", "karma-sinon-chai": "~0.2.0", "merge-stream": "0.1.x", "mocha": "~1.20.1", "phantomjs": "^1.9.17", "q": "1.0.x", "run-sequence": "0.3.x" } }</code></pre> </div> </div> </p>
0debug
insert values from a drop down list to mysql table : i'm trying to insert values from a drop down list to my database table it's actually register but shows only two letters as you can see in the picture [enter image description here][1] [1]: https://i.stack.imgur.com/0PtAS.png <form method="post" action="#" role="login" id="formID" > <select name="states" id="state" required class="form-control input-lg"> <option value="" selected="selected">select an option</option> <option value="AL">ADRAR</option> <option value="AK">AIN DEFLA </option> </select> </form> $servername = "localhost" ; $username = "root" ; $password = "" ; $db_name = "me" ; mysql_connect($servername,$username,$password); mysql_select_db($db_name); $uwilaya = $_POST ['states'] ; $sql= "INSERT INTO userz (wilaya) VALUES ('$uwilaya')"; if($_POST['submit']) { $query=mysql_query($sql); }
0debug
Identity auto jumping in sql local db : Hi All friend i have a application that coded with c# and it has Sql Local Db Database as i know one time i attached my database in sql server 2012 and then detach it now one of my user inform me that table id jump from 36 to 1036 after that i change user database to new again it jump from 2 to 1003 i see many solution for this problem but i dont have like this problem to my old user that they have old version and database my new user have this problem also they dont have sql server 2012 on system just local db in your idea if i remove whole database and create new one from c# it can help me or no
0debug
Get base url in AngularJS : <p>I want to get the base path of my Angular app.</p> <p>Right now I'm doing this: <code>$scope.baseUrl = '$location.host()</code></p> <p>But I only get this: <code>/localhost</code>. My current baseURL is <code>http://localhost:9000/</code>.</p>
0debug
static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, int* buf_size, int type, uint32_t **lace_buf, int *laces) { int res = 0, n, size = *buf_size; uint8_t *data = *buf; uint32_t *lace_size; if (!type) { *laces = 1; *lace_buf = av_mallocz(sizeof(int)); if (!*lace_buf) return AVERROR(ENOMEM); *lace_buf[0] = size; return 0; } av_assert0(size > 0); *laces = *data + 1; data += 1; size -= 1; lace_size = av_mallocz(*laces * sizeof(int)); if (!lace_size) return AVERROR(ENOMEM); switch (type) { case 0x1: { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < *laces - 1; n++) { while (1) { if (size == 0) { res = AVERROR_INVALIDDATA; break; } temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) break; } total += lace_size[n]; } if (size <= total) { res = AVERROR_INVALIDDATA; break; } lace_size[n] = size - total; break; } case 0x2: if (size % (*laces)) { res = AVERROR_INVALIDDATA; break; } for (n = 0; n < *laces; n++) lace_size[n] = size / *laces; break; case 0x3: { uint64_t num; uint64_t total; n = matroska_ebmlnum_uint(matroska, data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); res = n; break; } data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < *laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint(matroska, data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); res = r; break; } data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; } if (size <= total) { res = AVERROR_INVALIDDATA; break; } lace_size[*laces - 1] = size - total; break; } } *buf = data; *lace_buf = lace_size; *buf_size = size; return res; }
1threat
I want to create a function in sql but i am getting many errors : **I want to create function in sql(in SQL Server Management studio) for :** Input: 7589586586 Output: (758) 958-6586 Input: 758ABC6586 Output: (758) 222-6586 Input: 758ABC65 Output: Invalid Formats (like mobile keypad) **this is my sql code which is giving many errors:** CREATE FUNCTION fn_bhagyashreed_phonenumber(@input VARCHAR(20)) RETURNS VARCHAR(50) BEGIN DECLARE @compare VARCHAR(30) = ''; DECLARE @cnt INT = 1; DECLARE @varout VARCHAR(30) = ''; DECLARE @val VARCHAR(30) = ''; DECLARE @Phoutput VARCHAR(50) = ''; DECLARE @var INT; SET @var = LEN(@input); IF @var <> 10 OR @input NOT REGEXP '^[[:alnum:]]+$' THEN SET @Phoutput = 'Invalid Format'; ELSE WHILE @cnt <= 10 BEGIN SET @compare = SUBSTRING(@input, @cnt, 1); IF @compare IN('a','b','c','2') BEGIN SET @val=2; ELSE IF @compare IN('d','e','f','3') BEGIN SET @val=3; ELSE IF @compare IN('g','h','i','4') BEGIN SET @val=4; ELSE IF @compare IN('j','k','l','5') BEGIN SET @val=5; ELSE IF @compare IN('m','n','o','6') BEGIN SET @val=6; ELSE IF @compare IN('p','q','r','s','7') BEGIN SET @val=7; ELSE IF @compare IN('t','u','v','8') BEGIN SET @val=8; ELSE IF @compare IN('w','x','y','z','9') BEGIN SET @val=9; ELSE IF @compare = '1' BEGIN SET @val=1; ELSE IF @compare = '0' BEGIN SET @val=0; END SET @varout = CONCAT(@varout,@val); SET @cnt = @cnt + 1; END; SET @Phoutput = CONCAT('(',SUBSTRING(@varout,1,3),')',' ',SUBSTRING(@varout,4,3),'-',SUBSTRING(@varout,7,4)); END; IF; RETURN Phoutput; END$$ **these are the errors:** Msg 102, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 13 Incorrect syntax near 'REGEXP'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 15 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 20 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 22 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 24 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 26 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 28 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 30 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 32 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 34 Incorrect syntax near the keyword 'ELSE'. Msg 156, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 36 Incorrect syntax near the keyword 'ELSE'. Msg 195, Level 15, State 10, Procedure fn_bhagyashreed_phonenumber, Line 39 'CONCAT' is not a recognized built-in function name. Msg 195, Level 15, State 10, Procedure fn_bhagyashreed_phonenumber, Line 42 'CONCAT' is not a recognized built-in function name. Msg 102, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 43 Incorrect syntax near ';'. Msg 102, Level 15, State 1, Procedure fn_bhagyashreed_phonenumber, Line 45 Incorrect syntax near 'END$$'. ***KINDLY Help me.Its urgent.***
0debug
Google Play shows Unoptimized APK for Cordova App : <p>I was trying to publish my first Cordova app on Google Playstore. When I upload my release apk, it shows below warning and I cannot rollout the release.</p> <p>Unoptimized APK</p> <p>Warning:</p> <p>This APK results in unused code and resources being sent to users. Your app could be smaller if you used the Android App Bundle. By not optimizing your app for device configurations, your app is larger to download and install on users’ devices than it needs to be. Larger apps see lower install success rates and take up storage on users’ devices.</p>
0debug
Issue in saving contact number into database : <p>I'm giving correct contact number in the form field but it gets saved into database in some random digits,Why so?.i'm not using any encryption method! </p>
0debug
static uint64_t *l2_allocate(BlockDriverState *bs, int l1_index) { BDRVQcowState *s = bs->opaque; int min_index; uint64_t old_l2_offset; uint64_t *l2_table, l2_offset; old_l2_offset = s->l1_table[l1_index]; l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t)); if (l2_offset < 0) { return NULL; } s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED; if (write_l1_entry(s, l1_index) < 0) { return NULL; } min_index = l2_cache_new_entry(bs); l2_table = s->l2_cache + (min_index << s->l2_bits); if (old_l2_offset == 0) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); } else { if (bdrv_pread(s->hd, old_l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return NULL; } if (bdrv_pwrite(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return NULL; s->l2_cache_offsets[min_index] = l2_offset; s->l2_cache_counts[min_index] = 1; return l2_table; }
1threat
How to get data using fetch API with mode 'no-cors'? : <p>code looks like this, not sure how to read response data. Any idea?.</p> <pre><code>var url = 'http://www.bbc.co.uk/sport/football'; fetch(url, { mode : 'no-cors' }).then(function(response) { console.log(response); }); </code></pre> <p><a href="https://i.stack.imgur.com/IwmJu.png" rel="noreferrer">Response Object</a></p>
0debug
Unity Export Android 64-bit : <p>I've been trying to upload .abb to the google play console. When I upload it, it gives me this error:</p> <p>This release is not compliant with the Google Play 64-bit requirement</p> <p>The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code: 2.</p> <p>From 1. August 2019 all releases must be compliant with the Google Play 64-bit requirement.</p> <p>Include 64-bit and 32-bit native code in your app. Use the Android App Bundle publishing format to automatically ensure that each device architecture receives only the native code it needs. This avoids increasing the overall size of your app.</p> <p>I tried to export an 64-bit version but I couldnt do it.</p>
0debug
how to use VBA to copy paste in a determinate cell, changing the variable every week (not in the code) : I receive a weekly table and I've to update various columns in the whole document. Every week has a target number from 1 to 52. I tried to make the VBA copy paste in the next free column, but I realized that It can lead you to an error if you don't update it in the proper way. So I was thinking, do you know a vba code that allows me to decide in the Excel sheet, where the Macro has to copy? Like I choose the right weekly number in the excel sheet and then run the macro to make it copy in the rightful column in every designated sheet. Thanks!
0debug
how to make from real IP into automatic IP range in python? : <p>how do I make an IP range, for example my original IP there are the first 2 127.0.0.1 the second 128.0.0.1, I want if I use that IP for the IP range will be: 127.0.0.1 - 127.0.255.255 and so on, this my example code :</p> <pre><code>list_data = ["127.0.0.1", "128.0.0.1"] for i in range(255): for j in range(255): ip = list_data+".%d.%d" % (i, j) print (sb+fg+'[RANGE-IP] ===&gt; '+ip) open('IP.txt', 'a').write(ip + "\n") </code></pre>
0debug
How I can see and display the use space and Total Space of a hard disk or USB, and have this space use in percentage with jProgressBar Java : <p>How I can see and display the use space and TotalSpace of a hard disk or usb, and have this space use in percentage with jProgressBar Java</p>
0debug
Is bool booly; the same as bool booly = false; when declared? : <p>Is there any difference functionally between this:</p> <pre><code>bool boolean; </code></pre> <p>and:</p> <pre><code>bool boolean = false; </code></pre> <p>?</p>
0debug
static long do_sigreturn_v2(CPUARMState *env) { abi_ulong frame_addr; struct sigframe_v2 *frame = NULL; frame_addr = env->regs[13]; trace_user_do_sigreturn(env, frame_addr); if (frame_addr & 7) { goto badframe; } if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; } if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) { goto badframe; } unlock_user_struct(frame, frame_addr, 0); return env->regs[0]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV ); return 0; }
1threat
Rails 5.2 Active Storage add custom attributes : <p>I have a model with attachments:</p> <pre class="lang-rb prettyprint-override"><code>class Project &lt; ApplicationRecord has_many_attached :images end </code></pre> <p>When I attach and save the image I also want to save an additional custom attribute - <code>display_order</code> (integer) with the attached image. I want to use it to sort the attached images and display them in the order I specified in this custom attribute. I've reviewed ActiveStorage source code for <code>#attach</code> method as well as <code>ActiveStorage::Blob</code> model but it looks like there is no built in method to pass some custom metadata.</p> <p>I wonder, what's the idiomatic way to solve this problem with ActiveStorage? In the past I would usually just add a <code>display_order</code> attribute to the ActiveRecord model which represents my attachment and then simply use it with <code>.order(display_order: :asc)</code> query.</p>
0debug
SwiftUI Optional TextField : <p>Can SwiftUI Text Fields work with optional Bindings? Currently this code:</p> <pre><code>struct SOTestView : View { @State var test: String? = "Test" var body: some View { TextField($test) } } </code></pre> <p>produces the following error:</p> <blockquote> <p>Cannot convert value of type 'Binding&lt; String?>' to expected argument type 'Binding&lt; String>'</p> </blockquote> <p>Is there any way around this? Using Optionals in data models is a very common pattern - in fact it's the default in Core Data so it seems strange that SwiftUI wouldn't support them</p>
0debug
static void ivshmem_check_version(void *opaque, const uint8_t * buf, int size) { IVShmemState *s = opaque; int tmp; int64_t version; if (!fifo_update_and_get_i64(s, buf, size, &version)) { return; } tmp = qemu_chr_fe_get_msgfd(s->server_chr); if (tmp != -1 || version != IVSHMEM_PROTOCOL_VERSION) { fprintf(stderr, "incompatible version, you are connecting to a ivshmem-" "server using a different protocol please check your setup\n"); qemu_chr_add_handlers(s->server_chr, NULL, NULL, NULL, s); return; } IVSHMEM_DPRINTF("version check ok, switch to real chardev handler\n"); qemu_chr_add_handlers(s->server_chr, ivshmem_can_receive, ivshmem_read, NULL, s); }
1threat
How to Make Undo in unity : <p>I am doing Coloring Game. Where i am doing coloring the picture. I have done that. But i have to undo the color . It should revert back .</p> <p>For eg: windows paint. Draw and Undo Same Feature. can any one can post sample code. </p>
0debug
Get coordinates from string in c++ : So I have a string like this(all positive int, no spaces in square brackets): "[(1,2),(10,4),(5,12),... ]" And I would like extract int like this: 1,2,10,4,5,12. I'm now using the following code which does not handle int >=10 std::istringstream coor(coorstring); std::vector<int> num; char c; while (coor.get(c)){ if (isdigit(c)){ unsigned int a = c - '0'; if (a<max) {num.push_back(a);} } } For example my current output is `1,2,1,0,4...` rather than `1,2,10,4...` I'm new to c++ and I'm curious what needs to be modified to get the output I want(without using regex)? And by the way, instead of using int vector, what is a good data structure to store these coordinates in c++ for a later use of drawing a graph?
0debug
void run_on_cpu(CPUState *env, void (*func)(void *data), void *data) { func(data); }
1threat
C# forming nested List of child objects from parent object : <p>I have got a class structure like below,</p> <pre><code>class Employees { public string Id {get;set;} public string BossId {get;set;} public List&lt;Employees&gt; Subordinates {get;set;} } </code></pre> <p>Currently I have got a List with 4 records.</p> <pre><code>1. Id = 1, BossId = null 2. Id = 2, BossId = 1 3. Id = 3, BossId = 2 4. Id = 4, BossId = null </code></pre> <p>Now I need to form a List object as below by populating the Subordinates property.</p> <pre><code>Employees { Id: 1 Subordinates : { Employees : { Id : 2 Subordinates : { Employees: { Id: 3 Subordinates : null } } } } }, Id: 2 Subordinates: null } </code></pre> <p>Please help</p>
0debug
void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout) { VP8Macroblock *mb_edge[3] = { 0 , mb - 1 , 0 }; enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV }; enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT }; int idx = CNT_ZERO; int cur_sign_bias = s->sign_bias[mb->ref_frame]; int8_t *sign_bias = s->sign_bias; VP56mv near_mv[4]; uint8_t cnt[4] = { 0 }; VP56RangeCoder *c = &s->c; if (!layout) { mb_edge[0] = mb + 2; mb_edge[2] = mb + 1; } else { mb_edge[0] = mb - s->mb_width - 1; mb_edge[2] = mb - s->mb_width - 2; } AV_ZERO32(&near_mv[0]); AV_ZERO32(&near_mv[1]); AV_ZERO32(&near_mv[2]); #define MV_EDGE_CHECK(n) \ { \ VP8Macroblock *edge = mb_edge[n]; \ int edge_ref = edge->ref_frame; \ if (edge_ref != VP56_FRAME_CURRENT) { \ uint32_t mv = AV_RN32A(&edge->mv); \ if (mv) { \ if (cur_sign_bias != sign_bias[edge_ref]) { \ \ mv = ~mv; \ mv = ((mv & 0x7fff7fff) + \ 0x00010001) ^ (mv & 0x80008000); \ } \ if (!n || mv != AV_RN32A(&near_mv[idx])) \ AV_WN32A(&near_mv[++idx], mv); \ cnt[idx] += 1 + (n != 2); \ } else \ cnt[CNT_ZERO] += 1 + (n != 2); \ } \ } MV_EDGE_CHECK(0) MV_EDGE_CHECK(1) MV_EDGE_CHECK(2) mb->partitioning = VP8_SPLITMVMODE_NONE; if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) { mb->mode = VP8_MVMODE_MV; if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT])) cnt[CNT_NEAREST] += 1; if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) { FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]); FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]); } if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) { if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) { clamp_mv(s, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]); cnt[CNT_SPLITMV] = ((mb_edge[VP8_EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) + (mb_edge[VP8_EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 + (mb_edge[VP8_EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT); if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) { mb->mode = VP8_MVMODE_SPLIT; mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout) - 1]; } else { mb->mv.y += read_mv_component(c, s->prob->mvc[0]); mb->mv.x += read_mv_component(c, s->prob->mvc[1]); mb->bmv[0] = mb->mv; } } else { clamp_mv(s, &mb->mv, &near_mv[CNT_NEAR]); mb->bmv[0] = mb->mv; } } else { clamp_mv(s, &mb->mv, &near_mv[CNT_NEAREST]); mb->bmv[0] = mb->mv; } } else { mb->mode = VP8_MVMODE_ZERO; AV_ZERO32(&mb->mv); mb->bmv[0] = mb->mv; } }
1threat
DownloadString value check for a if statement in c# : im new to c# so sorry in advance. i am attempting to create a crawler that returns only links from a website and i have it to a point that it returns the htmlscript. i am now wanting to use a if statement to check that the string is returned and if it is returned, it searches for all <a tags and shows me the href link. but i dont know what object to check or what value i should be checking for. here is what i have so far namespace crawler_pt._2 { class Program { static void Main(string[] args) { System.Net.WebClient wc = new System.Net.WebClient(); string WebData wc.DownloadString("https://www.abc.net.au/news/science/"); Console.WriteLine(WebData); if } }
0debug
Declaring Const With Curly Braces in JSX : <p>I'm just getting started with React Native and getting used to JSX syntax. Is that what I'm talking about? Or am I talking about TypeScript? Or... ES6? Anyway...</p> <p>I've seen this:</p> <pre><code>const { foo } = this.props; </code></pre> <p>Inside a class function. What is the purpose of the curly braces and what's the difference between using them and not using them?</p>
0debug
static int deband_16_coupling_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { DebandContext *s = ctx->priv; ThreadData *td = arg; AVFrame *in = td->in; AVFrame *out = td->out; const int start = (s->planeheight[0] * jobnr ) / nb_jobs; const int end = (s->planeheight[0] * (jobnr+1)) / nb_jobs; int x, y, p, z; for (y = start; y < end; y++) { const int pos = y * s->planewidth[0]; for (x = 0; x < s->planewidth[p]; x++) { const int x_pos = s->x_pos[pos + x]; const int y_pos = s->y_pos[pos + x]; int avg[4], cmp[4] = { 0 }, src[4]; for (p = 0; p < s->nb_components; p++) { const uint16_t *src_ptr = (const uint16_t *)in->data[p]; const int src_linesize = in->linesize[p] / 2; const int thr = s->thr[p]; const int w = s->planewidth[p] - 1; const int h = s->planeheight[p] - 1; const int ref0 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; const int ref1 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; const int ref2 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; const int ref3 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; const int src0 = src_ptr[y * src_linesize + x]; src[p] = src0; avg[p] = get_avg(ref0, ref1, ref2, ref3); if (s->blur) { cmp[p] = FFABS(src0 - avg[p]) < thr; } else { cmp[p] = (FFABS(src0 - ref0) < thr) && (FFABS(src0 - ref1) < thr) && (FFABS(src0 - ref2) < thr) && (FFABS(src0 - ref3) < thr); } } for (z = 0; z < s->nb_components; z++) if (!cmp[z]) break; if (z == s->nb_components) { for (p = 0; p < s->nb_components; p++) { const int dst_linesize = out->linesize[p] / 2; uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x; dst[0] = avg[p]; } } else { for (p = 0; p < s->nb_components; p++) { const int dst_linesize = out->linesize[p] / 2; uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x; dst[0] = src[p]; } } } } return 0; }
1threat
How to split number each two length in angular : I have a number 112233445566 How can I spilt it and put it into array so that I can get Array[11,22,33,44,55,66]
0debug
access violation using simple server with indy code : In the following code i have a simple server that send a message 2 times a second and another message 8-10 times in a minute at all client. The problem is an "access violation at 00479740 read address FFFFFFD0" only in a few system and only 1 or 2 times a day. This software work about 10 hours a day. I have tried, with same code, to use ICS library and is seems working well. Whats wrong in this code? A better way to code it? Thanks! void __fastcall TDataNet::DataModuleCreate(TObject *Sender) { listaClient= new TThreadList(); psTx= new TStringList(); psRx= new TStringList(); } void __fastcall TDataNet::DataModuleDestroy(TObject *Sender) { IdTCPServer1->Active= false; listaClient->Free(); delete psTx; delete psRx; } void __fastcall TDataNet::Send( TStrings *ps, TIdContext *AContext) { TList *lista; static int cntSend= 0; try { lista= listaClient->LockList(); if( AContext != NULL ) { AContext->Connection->IOHandler->Write( ps, true, TIdTextEncoding_UTF8); } else { for( int i=0; i < lista->Count; i++ ) ((TDatiClient*)lista->Items[i])->pThread->Connection->IOHandler->Write( ps, true, TIdTextEncoding_UTF8); } } __finally { listaClient->UnlockList(); } } void __fastcall TDataNet::SetCambioPilota( void) { unsigned short hh, mm, ss, ms, hh1, mm1, ss1, ms1; unsigned short hh2, mm2, ss2, ms2, hh3, mm3, ss3, ms3; unsigned short hh4, mm4, ss4, ms4, dd4; unsigned short hh5, mm5, ss5, ms5, dd5; TStrings *ps; UnicodeString s; try { ps= psTx; ps->Clear(); s= "<CAMBIO_PILOTA>"; ps->Add( s); for( int i=0; i < MAX_PILOTI; i++ ) { s.sprintf( L"<Pilota%02x= I%x,\"A%s\",\"C%s\",\"F%s\",f%x>", i+1, gara.pilota[i].idnome, gara.pilota[i].nome.c_str(), gara.pilota[i].nick.c_str(), gara.pilota[i].nomeTeam.c_str(), gara.pilota[i].idPilotaT ); ps->Add( s); } s= "<END_CAMBIO_PILOTA>"; ps->Add( s); Send( ps ); } catch(...){} } void __fastcall TDataNet::SetDatiGara( void) { TStrings *ps; UnicodeString s; try { ps= psTx; ps->Clear(); s= "<DATI_GARA>"; ps->Add( s); s.sprintf( L"<eve=%d,A%x,B%x,C%x,D%x,E%x,F%x,G%x,H%x,I%x,J%x,K%x>", DataB->GetEventoInCorso().idEvento, DataB->GetEventoInCorso().numEvento, DataB->GetEventoInCorso().subEvento, DataB->GetNextEvento().idEvento, DataB->GetNextEvento().numEvento, DataB->GetNextEvento().subEvento, gara.tkTempo, gara.tkDurata - gara.tkTempo, gara.laps, gara.gDurata > 0 ? (gara.gDurata - gara.laps):0, gara.flInCorso ? (gara.gDurata > 0 ? 2:1):0, gara.flFineGara ); ps->Add( s); s= "<END_DATI_GARA>"; ps->Add( s); Send( ps ); } catch(...){} } void __fastcall TDataNet::Timer1Timer(TObject *Sender) { Timer1->Enabled= false; SetDatiGara(); Timer1->Enabled= true; } void __fastcall TDataNet::IdTCPServer1Connect(TIdContext *AContext) { TDatiClient* dati; dati= new TDatiClient; dati->pThread= AContext; AContext->Connection->IOHandler->ReadTimeout= 200; AContext->Data= (TObject*)dati; try { TList* lista; lista= listaClient->LockList(); lista->Add( dati); connessioni= lista->Count; if( FmainWnd ) PostMessage( FmainWnd, WM_EVENTO_TCP, ID_CONNESSO, lista->Count); int idEvento= DataB->GetEventoInCorso().idEvento; if( idEvento ) SetCambioStato( idEvento, STATO_EVENTO_START, AContext); } __finally { listaClient->UnlockList(); } } void __fastcall TDataNet::IdTCPServer1Disconnect(TIdContext *AContext) { TDatiClient* dati; dati= (TDatiClient*)AContext->Data; AContext->Data= NULL; try { listaClient->Remove( dati); TList* lista; lista= listaClient->LockList(); connessioni= lista->Count; if( FmainWnd ) PostMessage( FmainWnd, WM_EVENTO_TCP, ID_DISCONNESSO, lista->Count); } __finally { listaClient->UnlockList(); } delete dati; } void __fastcall TDataNet::IdTCPServer1Execute(TIdContext *AContext) { Sleep( 100); try { AContext->Connection->IOHandler->ReadStrings( psRx, -1); if( psRx->Count >= 2 && psRx->Strings[0] == "<LAST_MINUTE>" && psRx->Strings[psRx->Count-1] == "<END_LAST_MINUTE>" ) { psRx->Delete(0); psRx->Delete(psRx->Count-1); if( FmainWnd ) SendMessage( FmainWnd, WM_EVENTO_TCP, ID_LAST_MINUTE, (unsigned int)psRx); } psRx->Clear(); } catch( ...) {} AContext->Connection->CheckForGracefulDisconnect(); }
0debug
static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win) { Exynos4210fimdWindow *w = &s->window[win]; target_phys_addr_t fb_start_addr, fb_mapped_len; if (!s->enabled || !(w->wincon & FIMD_WINCON_ENWIN) || FIMD_WINDOW_PROTECTED(s->shadowcon, win)) { return; } if (w->host_fb_addr) { cpu_physical_memory_unmap(w->host_fb_addr, w->fb_len, 0, 0); w->host_fb_addr = NULL; w->fb_len = 0; } fb_start_addr = w->buf_start[fimd_get_buffer_id(w)]; w->fb_len = fb_mapped_len = (w->virtpage_width + w->virtpage_offsize) * (w->rightbot_y - w->lefttop_y + 1); w->mem_section = memory_region_find(sysbus_address_space(&s->busdev), fb_start_addr, w->fb_len); assert(w->mem_section.mr); assert(w->mem_section.offset_within_address_space == fb_start_addr); DPRINT_TRACE("Window %u framebuffer changed: address=0x%08x, len=0x%x\n", win, fb_start_addr, w->fb_len); if (w->mem_section.size != w->fb_len || !memory_region_is_ram(w->mem_section.mr)) { DPRINT_ERROR("Failed to find window %u framebuffer region\n", win); goto error_return; } w->host_fb_addr = cpu_physical_memory_map(fb_start_addr, &fb_mapped_len, 0); if (!w->host_fb_addr) { DPRINT_ERROR("Failed to map window %u framebuffer\n", win); goto error_return; } if (fb_mapped_len != w->fb_len) { DPRINT_ERROR("Window %u mapped framebuffer length is less then " "expected\n", win); cpu_physical_memory_unmap(w->host_fb_addr, fb_mapped_len, 0, 0); goto error_return; } return; error_return: w->mem_section.mr = NULL; w->mem_section.size = 0; w->host_fb_addr = NULL; w->fb_len = 0; }
1threat
Is there a way to get an email when your HTML5 site goes down like Wordpress? : <p>I have wordpress sites that go down at around 12am because of my web host provider. I get emails every time they shut down. With my HTML5 sites I do not know if you can do the same thing? Is there a free service or something I can make from scratch that can do the same thing.</p> <p>Thanks!</p>
0debug
What's the use of double boolean variables? : <p>I am looking at a JSON dataset from an API and I see stuff like this:</p> <pre><code> "lights_on":1, "lights_off":0, "doors_locked":0, "doors_unlocked":1, "sensors_tripped":0, "sensors_not_tripped":1 </code></pre> <p>Is it just me, or is it kinda silly to have a variable for both states of a boolean? in this example, wouldn't it make more sense to check the value of <code>lights_on</code> and if <code>0</code> it must be <code>false</code>, if <code>1</code> it must be <code>true</code></p> <p>What is the advantage of the above JSON data set with variables for both the <code>true</code> and <code>false</code> states and should I be using this in my programs?</p>
0debug
How to create custom REST API endpoint correctly : <p>Suppose we have customers: /api/customers (/api/customers/{id})</p> <p>With the following content:</p> <pre><code>[{ name: "Mike", age: 20, amount: 300 }, { name: "John", age: 30, amount: 600 }] </code></pre> <p>But there are different tasks when you have to perform various data manipulations.</p> <p>Suppose we need to display the client who spent the most (in the "amount" field).</p> <p>What the endpoint should look like for this request?</p> <p>I have a few suggestions how to do this, please correct me:</p> <pre><code>1. /api/customers/spent-more 2. /api/customers-spent-more 3. /api/customers?action=spent-more </code></pre> <p>How do you perform similar tasks, share experiences</p>
0debug
static inline void downmix_mono_to_stereo(float *samples) { int i; for (i = 0; i < 256; i++) samples[i + 256] = samples[i]; }
1threat
Iterating over a string in R : <p>I was wandering if it is possible to iterate over an string in R as we can do it with pyhon:</p> <pre><code>import numpy as np import pandas as pd myvector=[] for string in dataframe.columns: myvector.append(int(string[:-2])) #deleting identifiers myvector = np.array(sorted(list(set(myvector)))) </code></pre> <p>BR</p>
0debug
VBA macro Excel : I've never done macros before so please bear with me while I try to explain what I want to accomplish: I have a sheet that has some `names` and `SSN's` and then has 4 columns filled with the following values: `S`, `MB`, `B`. For said columns I wish to replace `S` with the number `4`, `MB` with the number 3 and `B` with the number 2. I have thousands of excel files that will need this change and doing it manually with a `CTRL+F` and replacing for each excel sheet is not going to cut it, timewise. Can anyone get me started on how to accomplish this?
0debug
Php/mysql: Data isn't inserting into the table : <p>So I am trying to create this form however, I am not able to enter the data into the table. Whenever I click on continue button, nothing really happens. I don't get an error or anything. and when I check my database, the values have not been added. Idk how its happening. I spent hours trying to understand what the issue is but i am not able to identify it and it got to the point where I felt hopeless and decided to post this question so please help me. Here's my code:</p> <pre><code>&lt;?php $conn = new mysqli("localhost", "root", "", "KFC"); if(isset($_POST['Submit_btn'])) { session_start(); $RID= $_POST['R_ID']; $Name= $_POST['Name']; $S_Description=($_POST['S_Description']); $L_Description=($_POST['L_Description']); $Nutritional_value=($_POST['Nutritional_value']); $Cost=($_POST['Cost']); $TypeOfMeal=($_POST['TypeOfMeal']); $SubmittedBy=($_POST['SubmittedBy']); $sql= "INSERT INTO `recipe`(`R_ID`, `Name`, `S_Description`, `L_Description`, `Nutritional_value`, `Cost`, `TypeOfMeal`, `SubmittedBy`) VALUES ($RID,$Name,$S_Description,$L_Description,$Nutritional_value,$Cost,$TypeOfMeal,$SubmittedBy)"; mysqli_query($conn,$sql); } mysqli_close($conn); ?&gt; &lt;html&gt; &lt;body&gt; &lt;div id="bodyContent"&gt; &lt;h1&gt; Registration &lt;/h1&gt; &lt;/div&gt; &lt;form method="post"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;R_ID: &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="R_ID" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Name: &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="Name" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Small Description: &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="S_Description" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Long Description: &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="L_Description" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Nutritional value: &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="Nutritional_value" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Cost: &lt;/td&gt; &lt;td&gt; &lt;input type="number" name="Cost" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Type Of Meal: &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="TypeOfMeal" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;UserID: &lt;/td&gt; &lt;td&gt; &lt;input type="Number" name="SubmittedBy" class="textInput"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="submit" name="Submit_btn" value="Continue"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
how to get coordinates from polyline (google maps api) : i am able to draw a polyline between source and destination using google maps api on android. Now, I want to get locations from the polyline for let's say every 25meter. So, as the polyline is generated between two points, app must generate coordinates for the points on polyline at a distance of 25meter. So as you can see in image i need coordinates for blue crosses. [need coordiantes for all the blue crosses] [1]imgur.com/AHcCY.png
0debug
static void lm32_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); LM32CPU *cpu = LM32_CPU(obj); CPULM32State *env = &cpu->env; static bool tcg_initialized; cs->env_ptr = env; cpu_exec_init(cs, &error_abort); env->flags = 0; if (tcg_enabled() && !tcg_initialized) { tcg_initialized = true; lm32_translate_init(); } }
1threat
How to find if there is a even or a odd number of "1" bit : <p>Is it possible to say if there is a even or a odd number of "1" bit in a binary representation of an int in C with a single test ? If no what is the fastest way to do it ?</p>
0debug
Resuming interrupted s3 download with awscli : <p>I was downloading a file using awscli:</p> <pre><code>$ aws s3 cp s3://mybucket/myfile myfile </code></pre> <p>But the download was interrupted (computer went to sleep). How can I continue the download? S3 supports the Range header, but <code>awscli s3 cp</code> doesn't let me specify it.</p> <p>The file is not publicly accessible so I can't use curl to specify the header manually.</p>
0debug
C Programming- declaring a character variable : What happens when we declare a character variable without using single quotes? For eg: char ch=5; char ch= a;
0debug
i want to join column with specific match case : i have two tables TableA and TableB the TableA having column called Code Like 'A','AB','B','BB' in TableB i have column called pnrcode like 'A001','AB001','B001','BC001' both table has no relationship i want to join this two table based on TableA code with TableB pnrcode with matching the characters based on TableA
0debug
int qemu_recvv(int sockfd, struct iovec *iov, int len, int iov_offset) { return do_sendv_recvv(sockfd, iov, len, iov_offset, 0); }
1threat
In php How can i hide the path of line shown in the browser : I'm using phpstorm with xdebug When i use something like `var_dump` how can i hide this part shown in the browser [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/4HkuL.png
0debug
New list per user Entry : <p>I am busy doing a school assignment and i have gotten stuck at this piece of code, any assistance would be greatly appreciated. Please see the following code:</p> <pre><code>from tkinter import * student_list = [['Tom','Information Systems'],['John','Computers'],['Johannes','Information Systems']] class App(Frame): def __init__(self,parent=None,**kw): Frame.__init__(self,master=parent,**kw) self.searchValue = StringVar() self.searchBox = Entry(self,textvariable=self.searchValue) self.searchBox.pack() self.resultList = Listbox(self) self.resultList.pack() self.searchBox.bind('&lt;Return&gt;',self.update) def update(self,e): print("*") self.resultList.delete(0,END) searchkey = self.searchValue.get() for student in student_list: if searchkey == student[0]: self.resultList.insert(END,str(student)) elif searchkey == student[1]: self.resultList.insert(END,str(student)) if __name__ == '__main__': root = Tk() app = App(root) app.pack() root.mainloop() </code></pre> <p>Is it possible to create a new list per user entry or any alternate method?</p>
0debug
python pandas - dividing column by another column : <p>I'm trying to add a column to my <code>DataFrame</code> which is the product of division of two other columns, like so:</p> <pre><code>df['$/hour'] = df['$']/df['hours'] </code></pre> <p>This works fine, but if the value in <code>['hours']</code> is less than <code>1</code>, then the <code>['$/hour']</code> value is greater than the value in <code>['$']</code>, which is not what I want.</p> <p>Is there a way of controlling the operation so that if <code>['hours'] &lt; 1</code> then <code>df['$/hour'] = df['$']</code>?</p>
0debug
IO delay causes 2 iterations in for loop in JAVA : <p>I was testing some piece of code and came across something interesting on which I would need some expert opinion.</p> <p>A simple program that stops the loop when the input is <code>s</code> but seems the on each input the loop is iterated twice, i guess that's because of the IO delay. Correct me if I am wrong.</p> <pre><code>public static void main(String[] args) throws java.io.IOException { int i; System.out.println("Type s to stop."); for(i = 0; ; i++) { char value = (char) System.in.read(); if(value=='s'){ break; } System.out.println("Pass # " + i); } } </code></pre> <p><strong>output:</strong></p> <p><a href="https://i.stack.imgur.com/rE5IZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rE5IZ.png" alt="enter image description here"></a></p>
0debug
Merge sort algorithm - the implementation in java : <p>Is the anybody who can give a link where is explained the implementation of merge sort algorithm in java? I understand how the algorithm works but I don't know how to implement it in java. What I have found on the internet couldn't make me to figure out what is doing each condition or loop of the code. Thank you in advance.</p>
0debug
Why do I get Error when calling library (rdd) in R : - I installed rdd package, when calling library(rdd) get error message "Loading required package: AER Error: package ‘car’ required by ‘AER’ could not be found" I have used functions from car (like anova) so I know I have it I have MAC OS 10.15.1, R 3.6.1 , I reinstalled R and R studio Install.packages("rdd") library(rdd) "Loading required package: AER Error: package ‘car’ required by ‘AER’ could not be found"
0debug
a warning about func unc createDirectoryAtURL(value of the type '()' ) : <p>I am learner on iOS Development,today i try to code something<a href="http://i.stack.imgur.com/Xf52o.png" rel="nofollow">enter image description here</a> about FileManger,but this method return a type '()',how can i to resolve it?</p> <p>the warning code as follow:</p>
0debug
my dates changed to a several digits combination - Sql Server : I have a column in my DB named `BirthDate`. SomeHow (Unfortunately I can't say how and why) the dates became just to several digits and the column type is now `char`. Sorry I can't tell more since it's a new project for me, and I just got some assignments to do. For instance, a date now represented as : 081101 (and it's not 08/11/2001 , that's for sure) Any chance I can get back to original? what are these digits at all? any clue?
0debug
static void test_visitor_out_bool(TestOutputVisitorData *data, const void *unused) { bool value = true; QObject *obj; visit_type_bool(data->ov, NULL, &value, &error_abort); obj = visitor_get(data); g_assert(qobject_type(obj) == QTYPE_QBOOL); g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value); }
1threat
Is there a way to change a buttons text using Selenium Python (MacOS)? : I want to basically do a temporary edit to a webpage (like how people do it using inspect element) but have it done automatically using selenium. For example this is an image from google.ca : https://imgur.com/nAVquUF I simply want to change the text of "Gmail" and "Images" into whatever I want. I only have this so far: ``` from selenium import webdriver from selenium.webdriver.common.keys import Keys browser = webdriver.Chrome('/Users/--------/Downloads/chromedriver') browser.get("https://google.ca/") x = browser.find_element_by_id('Gmail') ``` **Is there a way I can do this?**
0debug
static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, TCGMemOp opc, int mem_index, bool is_load) { TCGReg base = TCG_AREG0; int cmp_off = (is_load ? offsetof(CPUArchState, tlb_table[mem_index][0].addr_read) : offsetof(CPUArchState, tlb_table[mem_index][0].addr_write)); int add_off = offsetof(CPUArchState, tlb_table[mem_index][0].addend); unsigned s_bits = opc & MO_SIZE; unsigned a_bits = get_alignment_bits(opc); if (use_armv7_instructions) { tcg_out_extract(s, COND_AL, TCG_REG_R0, addrlo, TARGET_PAGE_BITS, CPU_TLB_BITS); } else { tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP, 0, addrlo, SHIFT_IMM_LSR(TARGET_PAGE_BITS)); } if (add_off > 0xfff || (use_armv6_instructions && cmp_off > 0xff)) { tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R2, base, (24 << 7) | (cmp_off >> 8)); base = TCG_REG_R2; add_off -= cmp_off & 0xff00; cmp_off &= 0xff; } if (!use_armv7_instructions) { tcg_out_dat_imm(s, COND_AL, ARITH_AND, TCG_REG_R0, TCG_REG_TMP, CPU_TLB_SIZE - 1); } tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R2, base, TCG_REG_R0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS)); if (use_armv6_instructions && TARGET_LONG_BITS == 64) { tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_REG_R2, cmp_off); } else { tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_R2, cmp_off); if (TARGET_LONG_BITS == 64) { tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R2, cmp_off + 4); } } tcg_out_ld32_12(s, COND_AL, TCG_REG_R2, TCG_REG_R2, add_off); if (a_bits < s_bits) { a_bits = s_bits; } if (use_armv7_instructions) { tcg_target_ulong mask = ~(TARGET_PAGE_MASK | ((1 << a_bits) - 1)); int rot = encode_imm(mask); if (rot >= 0) { tcg_out_dat_imm(s, COND_AL, ARITH_BIC, TCG_REG_TMP, addrlo, rotl(mask, rot) | (rot << 7)); } else { tcg_out_movi32(s, COND_AL, TCG_REG_TMP, mask); tcg_out_dat_reg(s, COND_AL, ARITH_BIC, TCG_REG_TMP, addrlo, TCG_REG_TMP, 0); } tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R0, TCG_REG_TMP, 0); } else { if (a_bits) { tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo, (1 << a_bits) - 1); } tcg_out_dat_reg(s, (a_bits ? COND_EQ : COND_AL), ARITH_CMP, 0, TCG_REG_R0, TCG_REG_TMP, SHIFT_IMM_LSL(TARGET_PAGE_BITS)); } if (TARGET_LONG_BITS == 64) { tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0, TCG_REG_R1, addrhi, 0); } return TCG_REG_R2; }
1threat
void palette8tobgr32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) { unsigned i; for(i=0; i<num_pixels; i++) { #ifdef WORDS_BIGENDIAN dst[3]= palette[ src[i]*4+0 ]; dst[2]= palette[ src[i]*4+1 ]; dst[1]= palette[ src[i]*4+2 ]; #else dst[0]= palette[ src[i]*4+0 ]; dst[1]= palette[ src[i]*4+1 ]; dst[2]= palette[ src[i]*4+2 ]; #endif dst+= 4; } }
1threat
Javascript - how to combine AJAX with JSON? : I'm trying to read all information from the JSON string. I'm also trying to read it with the help of AJAX. The purpose is to fill an innerHTML with the information, but nothing happends. What is wrong with the code and how can it be solved? function getResults() { var obj = [ { "number": "Bob", "position": "forward", "shoots": "left" }, { "number": "John", "position": "forward", "shoots": "right" } ]; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (xhttp.readyState == 4 && xhttp.status == 200) { var return_data = request.responseText; document.getElementById("sportresults").innerHTML = return_data; } }; xhttp.open("GET", obj, true); xhttp.send(); }
0debug
Expected '(end)' and instead saw '}' : <p>I'm using jslint to help fix some javascript and it returned with at the end of this script. </p> <pre><code>$("ul").wrap("&lt;p class='content'&gt;&lt;/p&gt;"); $("hr.x-gap").css("border-top",""); } </code></pre> <p>I have been trying to fix it, but I have been unable to find the solution. </p>
0debug
CSS Grid - Aligning content in columns : I'm playing about with CSS grid at the moment and I'm creating a grid which has three columns. The grid boxes each have a div inside which has a maximum width of `280px`, and sometimes the grid columns are wider than this. I want to align the content in the grid boxes so that the left column are aligned to the left, the central column is aligned to the center, and the right column is aligned to the right. See the image below for my **desired result**: [![enter image description here][1]][1] Currently I'm using the CSS `justify-items: justify` rule on the grid container element. My **current result** is below: [![enter image description here][2]][2] What can I do with CSS to produce the layout in my desired layout diagram? Thanks in advance. [1]: https://i.stack.imgur.com/6K0dI.png [2]: https://i.stack.imgur.com/Tqjsq.png
0debug
Homework help - new programmer! Python calculating minimum max and average of a list : I'm new to python and my professor has not explained this assignment very well, many of my classmates are confused. He is an adjunct so he does not have office hours as well so I would be grateful for any sort of assistance or knowledge on how I can complete this. So, the prompt is "Write, debug, and test a program to calculate and print the minimum, maximum, and average of a list of positive test scores. Prompt the user for how many scores are to be entered. Expect each score will be entered one per line. Provide a prompt for each score." So this what I currently have, but I'm stuck at finding the min, max, and avg. def scores(): print('we are starting') count = int(input('Enter amount of scores: ')) print('Each will be entered one per line') scoreList = [] for i in range(1, count+1): scoreList.append(int(input('Enter score: '))) print(scoreList) print(scoreList) print('thank you the results are:') mysum = sum(count) # mysum needs to be a float average = 1.0*mysum / n print ('Total: ', str(count)) print ('Average: ', str(average)) print ('Minimum: ', str(min(count))) print ('Maximum: ', str(max(count))) scores() I'm not sure if it would be easier to do an elif type statement as I said I'm really new to this and I'm still just trying to understand whats going on in this code. next, I need to "expand the program to generate a score by grade table. For each rank of grade [A,B,C,D,F] the program counts the number of grades in the rank. The program prints a table of count by rank and provides the percentage of total grades in each rank. The ranks are as follows: A = 91 - 100 B = 81 - 90 C = 71 - 80 D = 61 - 70 F = 0 - 60" I understand this is a lot, I would just appreciate some assistance or some input as any and all are very appreciated. Thanks in advance to anyone that responds and I will be updating if I get any further on this on my own.
0debug
int img_convert(AVPicture *dst, int dst_pix_fmt, AVPicture *src, int src_pix_fmt, int src_width, int src_height) { static int inited; int i, ret, dst_width, dst_height, int_pix_fmt; PixFmtInfo *src_pix, *dst_pix; ConvertEntry *ce; AVPicture tmp1, *tmp = &tmp1; if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB || dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB) return -1; if (src_width <= 0 || src_height <= 0) return 0; if (!inited) { inited = 1; img_convert_init(); } dst_width = src_width; dst_height = src_height; dst_pix = &pix_fmt_info[dst_pix_fmt]; src_pix = &pix_fmt_info[src_pix_fmt]; if (src_pix_fmt == dst_pix_fmt) { for(i = 0; i < dst_pix->nb_components; i++) { int w, h; w = dst_width; h = dst_height; if (is_yuv_planar(dst_pix) && (i == 1 || i == 2)) { w >>= dst_pix->x_chroma_shift; h >>= dst_pix->y_chroma_shift; } img_copy(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], w, h); } return 0; } ce = &convert_table[src_pix_fmt][dst_pix_fmt]; if (ce->convert) { ce->convert(dst, src, dst_width, dst_height); return 0; } if (is_yuv_planar(dst_pix) && src_pix_fmt == PIX_FMT_GRAY8) { int w, h, y; uint8_t *d; if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_jpeg_to_ccir); } w = dst_width; h = dst_height; w >>= dst_pix->x_chroma_shift; h >>= dst_pix->y_chroma_shift; for(i = 1; i <= 2; i++) { d = dst->data[i]; for(y = 0; y< h; y++) { memset(d, 128, w); d += dst->linesize[i]; } } return 0; } if (is_yuv_planar(src_pix) && dst_pix_fmt == PIX_FMT_GRAY8) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_ccir_to_jpeg); } return 0; } if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) { int x_shift, y_shift, w, h; void (*resize_func)(uint8_t *dst, int dst_wrap, uint8_t *src, int src_wrap, int width, int height); w = dst_width; h = dst_height; if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift) w >>= dst_pix->x_chroma_shift; else w >>= src_pix->x_chroma_shift; if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift) h >>= dst_pix->y_chroma_shift; else h >>= src_pix->y_chroma_shift; x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift); y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift); if (x_shift == 0 && y_shift == 0) { resize_func = img_copy; } else if (x_shift == 0 && y_shift == 1) { resize_func = shrink2; } else if (x_shift == 1 && y_shift == 1) { resize_func = shrink22; } else if (x_shift == -1 && y_shift == -1) { resize_func = grow22; } else if (x_shift == -1 && y_shift == 1) { resize_func = conv411; } else { return -1; } img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); for(i = 1;i <= 2; i++) resize_func(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift); if (dst_pix->color_type != src_pix->color_type) { const uint8_t *y_table, *c_table; if (dst_pix->color_type == FF_COLOR_YUV) { y_table = y_jpeg_to_ccir; c_table = c_jpeg_to_ccir; } else { y_table = y_ccir_to_jpeg; c_table = c_ccir_to_jpeg; } img_apply_table(dst->data[0], dst->linesize[0], dst->data[0], dst->linesize[0], dst_width, dst_height, y_table); for(i = 1;i <= 2; i++) img_apply_table(dst->data[i], dst->linesize[i], dst->data[i], dst->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift, c_table); } return 0; } if (src_pix_fmt == PIX_FMT_YUV422 || dst_pix_fmt == PIX_FMT_YUV422) { int_pix_fmt = PIX_FMT_YUV422P; } else if ((src_pix->color_type == FF_COLOR_GRAY && src_pix_fmt != PIX_FMT_GRAY8) || (dst_pix->color_type == FF_COLOR_GRAY && dst_pix_fmt != PIX_FMT_GRAY8)) { int_pix_fmt = PIX_FMT_GRAY8; } else if ((is_yuv_planar(src_pix) && src_pix_fmt != PIX_FMT_YUV444P && src_pix_fmt != PIX_FMT_YUVJ444P)) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else if ((is_yuv_planar(dst_pix) && dst_pix_fmt != PIX_FMT_YUV444P && dst_pix_fmt != PIX_FMT_YUVJ444P)) { if (dst_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else { if (src_pix->is_alpha && dst_pix->is_alpha) int_pix_fmt = PIX_FMT_RGBA32; else int_pix_fmt = PIX_FMT_RGB24; } if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0) return -1; ret = -1; if (img_convert(tmp, int_pix_fmt, src, src_pix_fmt, src_width, src_height) < 0) goto fail1; if (img_convert(dst, dst_pix_fmt, tmp, int_pix_fmt, dst_width, dst_height) < 0) goto fail1; ret = 0; fail1: avpicture_free(tmp); return ret; }
1threat
AWS Cognito - Enabling MFA | Error: MFA cannot be turned off if an SMS role is configured : <p>Im trying to enable MFA for an existing AWS Cognito user pool. Im editing the user-pool configuration, but trying to save the new configuration results in a <code>MFA cannot be turned off if an SMS role is configured</code> error (see picture). I don't understand that error message, and Google is no help.</p> <p><strong>Question:</strong> What am I do wrong, how can I enable MFA for an existing user pool?</p> <p><a href="https://i.stack.imgur.com/hDEqZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hDEqZ.png" alt="enter image description here"></a></p>
0debug
Java string repalceAll method : hi i want to use Java string repalceAll() method to replace "x3" with "multiplied by 3" in my text file. But there is a string occurence "xxx3" which i do not want to replace. how can I do it
0debug