problem
stringlengths
26
131k
labels
class label
2 classes
inner join query for my android application : So I'm making this android application. A page on the application has to display data from 2 different columns in my database it has to collect the data from the workshops table, and the schedules table where the workshopid is equal. I know I have to use an innerjoin on the workshopid, but this doesnt seem to work for me. this is my code right now. i hope someone can help me with my problem. private void GetInfo(String eventName, String workshopName) { String GetInfo = null; String dbResult = "empty"; dbConnect database = new dbConnect(this); try{ String query = "SELECT workshopid, scedules.workshopid, scedules.starttime, scedules.endtime, workshopname, workshopdesc FROM workshops INNER JOIN scedules ON workshops.workshopid = scedules.workshopid WHERE workshopname = '" + workshopName + "';"; GetInfo = "?query=" + URLEncoder.encode(query, "UTF-8"); String link = "https://jackstest.000webhostapp.com/androiddbconnect.php" + GetInfo; dbResult = database.execute(link).get(); } catch(Exception e){ Header.setText("Workshop"); } try{ JSONArray ja = new JSONArray(dbResult); JSONObject jo = null; data = new String[ja.length()]; data2 = new String[ja.length()]; for (int i = 0;i < 1 ; i++){ jo = ja.getJSONObject(i); data[i] = jo.getString("workshopname"); data2[i] = jo.getString("workshopdesc"); } Header.setText(data[0]); Content.setText(data2[0]); Location.setText("Locatie : " + eventName); } catch(Exception e){ e.printStackTrace(); }
0debug
Typescript error: TS7053 Element implicitly has an 'any' type : <p>this is part of my code:</p> <pre class="lang-js prettyprint-override"><code>const myObj: object = {} const propname = 'propname' myObj[propname] = 'string' </code></pre> <p>but I got error:</p> <pre class="lang-sh prettyprint-override"><code>ERROR in path/to/file.ts(4,1) TS7053: Element implicitly has an 'any' type because expression of type '"propname"' can't be used to index type '{}'. Property 'propname' does not exist on type '{}'. </code></pre> <p>What is wrong here, and how can I fix it?</p>
0debug
static CURLState *curl_init_state(BDRVCURLState *s) { CURLState *state = NULL; int i, j; do { for (i=0; i<CURL_NUM_STATES; i++) { for (j=0; j<CURL_NUM_ACB; j++) if (s->states[i].acb[j]) continue; if (s->states[i].in_use) continue; state = &s->states[i]; state->in_use = 1; break; } if (!state) { qemu_aio_wait(); } } while(!state); if (!state->curl) { state->curl = curl_easy_init(); if (!state->curl) { return NULL; } curl_easy_setopt(state->curl, CURLOPT_URL, s->url); curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER, (long) s->sslverify); curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5); curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb); curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state); curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state); curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1); curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg); curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1); #if LIBCURL_VERSION_NUM >= 0x071304 curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS); curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS); #endif #ifdef DEBUG_VERBOSE curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1); #endif } state->s = s; return state; }
1threat
Passing data intent to fragment to activity : In my getview it already can intent to my second activity but it still cant passing the value for second activity. Is it the problem in my passing data or my receive data **First Fragment** @Override public View getView(final int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflater.inflate(R.layout.detailsitem, null); } if(position ==0) { }else { final Product myObj = DetailList.get(position); final TextView Detailtext = (TextView) convertView.findViewById(R.id.detailsitem); Detailtext.setText("" + myObj.getProductName()); final TextView Detailsprice= (TextView)convertView.findViewById(R.id.detailsprice); Detailsprice.setText("" + myObj.getProductPrice()); preview = (ImageButton) convertView.findViewById(R.id.preview); preview.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent=new Intent(getActivity().getApplicationContext(),details_gridview_view.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("title", "1"); getActivity().getApplicationContext().startActivity(intent); startActivity(intent); } }); } return convertView; } **Second Activity** @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.details_gridview_view); String name = getIntent().getStringExtra("title"); String price =getIntent().getStringExtra("price"); String qty =getIntent().getStringExtra("qty"); TextView titleTextView = (TextView) findViewById(R.id.title); titleTextView.setText(name); TextView priceTextView = (TextView) findViewById(R.id.price); titleTextView.setText(price); TextView qtyTextView = (TextView) findViewById(R.id.qty); titleTextView.setText(qty);
0debug
I need to make a 3d list with 216 items and count the results in a dict : I need to create a 6 x 6 x 6 table that has all the 216 possible three dice results. Considering that the same dice values in whatever order they come is the same result (eg (1,4,6) is the same as all the 1, 4, 6 transformations, ie (6,4,1) or (4,6,1), and so on). Then i want to calculate the frequency of different results and print them sorted by increasing incidence.(maybe with dictionary?) so i made this list: mylist = [[[(x,y,z) for z in range (1,7)]for y in range(1,7)]for x in range (1,7)] and i have all the 216 possible results. But i can't make it work for counting them and find the same results... Can you help me?
0debug
Angular 2: sanitizing HTML stripped some content with div id - this is bug or feature? : <p>I use <code>&lt;div [innerHTML]="body"&gt;&lt;/div&gt;</code> to pass unescaped HTML to my template, and when I pass to <code>body</code> <code>div</code> with attribute <code>id</code>, Angular throw:</p> <blockquote> <p>WARNING: sanitizing HTML stripped some content (see <a href="http://g.co/ng/security#xss" rel="noreferrer">http://g.co/ng/security#xss</a>). WARNING: sanitizing HTML stripped some content (see <a href="http://g.co/ng/security#xss" rel="noreferrer">http://g.co/ng/security#xss</a>). WARNING: sanitizing HTML stripped some content (see <a href="http://g.co/ng/security#xss" rel="noreferrer">http://g.co/ng/security#xss</a>).</p> </blockquote> <p><a href="http://plnkr.co/edit/noTI3NKSBlq3W1CwrZkt?p=preview" rel="noreferrer">See. plunker</a></p> <p>So why it says this? What can be dangerous <code>id</code> in <code>div</code>? Could this bug?</p>
0debug
static int sdp_probe(AVProbeData *p1) { const char *p = p1->buf, *p_end = p1->buf + p1->buf_size; while (p < p_end && *p != '\0') { if (p + sizeof("c=IN IP") - 1 < p_end && av_strstart(p, "c=IN IP", NULL)) return AVPROBE_SCORE_EXTENSION; while (p < p_end - 1 && *p != '\n') p++; if (++p >= p_end) break; if (*p == '\r') p++; } return 0; }
1threat
C++ - why does sizeof return the false value for an array when used as return value in a function : <p>I have a little problem regarding the size of an array (int, char, etc.). First of all I need to tell you, that I am a beginner in C++ with some background in some other programming languages. Now let us consider the following program: </p> <pre><code>int IntArrayLength(int Array[]){ return (sizeof(Array) / sizeof(Array[0])); } int main(){ int array[] = {10,20,30,40,50}; cout &lt;&lt; (sizeof(array) / sizeof(array[0])) &lt;&lt; endl; // returns 5, which is the correct value cout &lt;&lt; IntArrayLength(array) &lt;&lt; endl; // returns 2, no matter how many elements are in the array } </code></pre> <p>Why does the function <code>IntArrayLength</code> return the value of 2 while the expression <code>(sizeof(array) / sizeof(array[0]))</code> returns the correct value, when not put into a function.</p> <p>Thanks in advance!</p>
0debug
Because when I search with child is null? : I have this code: String email = FirebaseAuth.getInstance().getCurrentUser().getEmail(); myRef = database.getReference("reserva/"); myRef.orderByChild("email").equalTo(email).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { String value = dataSnapshot.child("reserva/1/status").getValue(String.class); String status; TextView textview2 = (TextView) findViewById(R.id.TextView2); if (value != null) { status = dataSnapshot.getKey() + getString(R.string.statusreservafeita); textview2.setText(status + value); } else textview2.setText(R.string.statusreservafail ); } @Override public void onCancelled(DatabaseError error) { TextView textview2 = (TextView) findViewById(R.id.TextView2); textview2.setText(R.string.statusreservafail ); } }); My bank : "reserva" : { "1" : { "email" : "teste@teste.com", "status" : "check in" }, "2" : { "email" : "fabio@ciaf.com.br", "status" : "check out" }, "123" : { "email" : "fbaoo07@gmail.com", "status" : "reservado" } } When I put an email teste@teste.com returns null. I need it returns the status and he is coming null. I need to help me, I think he To him this missing child.
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
YAML, Docker Compose, Spaces & Quotes : <p>Under what circumstances <strong>must</strong> one use quotes in a YAML file, specifically when using <code>docker-compose</code>.</p> <p>For instance,</p> <pre><code>service: image: "my-registry/repo:tag1" environment: ENV1: abc ENV2: "abc" ENV3: "a b c" </code></pre> <p>If spaces are required, for example, must one use quotes around the environment variable, as depicted in <code>ENV3</code>?</p>
0debug
To better understand recursion : <p>I am making an attempt to learn recursion better so I have been practicing some problems. </p> <p>A common problem is flatten an list of lists to a single list. For example</p> <pre><code>[3,4,[1,2]] so the desired result will be [3,4,1,2]. </code></pre> <p>The way I am approaching the problem is:</p> <ol> <li>is 0 element a list - no </li> <li>is 1 element a list - no </li> <li><p>is 2 element a list - yes</p> <p>call the function again and do tests again</p></li> </ol> <p>My base case will be to return if element is not a list.</p> <p>Is there a better approach to understand recursion better?</p>
0debug
int main(int argc, char **argv) { TestInputVisitorData testdata; g_test_init(&argc, &argv, NULL); validate_test_add("/visitor/input-strict/pass/struct", &testdata, test_validate_struct); validate_test_add("/visitor/input-strict/pass/struct-nested", &testdata, test_validate_struct_nested); validate_test_add("/visitor/input-strict/pass/list", &testdata, test_validate_list); validate_test_add("/visitor/input-strict/pass/union", &testdata, test_validate_union); validate_test_add("/visitor/input-strict/pass/union-flat", &testdata, test_validate_union_flat); validate_test_add("/visitor/input-strict/pass/union-anon", &testdata, test_validate_union_anon); validate_test_add("/visitor/input-strict/fail/struct", &testdata, test_validate_fail_struct); validate_test_add("/visitor/input-strict/fail/struct-nested", &testdata, test_validate_fail_struct_nested); validate_test_add("/visitor/input-strict/fail/list", &testdata, test_validate_fail_list); validate_test_add("/visitor/input-strict/fail/union", &testdata, test_validate_fail_union); validate_test_add("/visitor/input-strict/fail/union-flat", &testdata, test_validate_fail_union_flat); validate_test_add("/visitor/input-strict/fail/union-flat-no-discriminator", &testdata, test_validate_fail_union_flat_no_discrim); validate_test_add("/visitor/input-strict/fail/union-anon", &testdata, test_validate_fail_union_anon); g_test_run(); return 0; }
1threat
static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access, bool may_lookup_pt) { bool dtlb = is_write != 2; uint32_t wi; uint32_t ei; uint8_t ring; uint32_t vpn; uint32_t pte; const xtensa_tlb_entry *entry = NULL; xtensa_tlb_entry tmp_entry; int ret = xtensa_tlb_lookup(env, vaddr, dtlb, &wi, &ei, &ring); if ((ret == INST_TLB_MISS_CAUSE || ret == LOAD_STORE_TLB_MISS_CAUSE) && may_lookup_pt && get_pte(env, vaddr, &pte) == 0) { ring = (pte >> 4) & 0x3; wi = 0; split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei); if (update_tlb) { wi = ++env->autorefill_idx & 0x3; xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, pte); env->sregs[EXCVADDR] = vaddr; qemu_log("%s: autorefill(%08x): %08x -> %08x\n", __func__, vaddr, vpn, pte); } else { xtensa_tlb_set_entry_mmu(env, &tmp_entry, dtlb, wi, ei, vpn, pte); entry = &tmp_entry; } ret = 0; } if (ret != 0) { return ret; } if (entry == NULL) { entry = xtensa_tlb_get_entry(env, dtlb, wi, ei); } if (ring < mmu_idx) { return dtlb ? LOAD_STORE_PRIVILEGE_CAUSE : INST_FETCH_PRIVILEGE_CAUSE; } *access = mmu_attr_to_access(entry->attr); if (!is_access_granted(*access, is_write)) { return dtlb ? (is_write ? STORE_PROHIBITED_CAUSE : LOAD_PROHIBITED_CAUSE) : INST_FETCH_PROHIBITED_CAUSE; } *paddr = entry->paddr | (vaddr & ~xtensa_tlb_get_addr_mask(env, dtlb, wi)); *page_size = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1; return 0; }
1threat
static void tgen_ext16u(TCGContext *s, TCGType type, TCGReg dest, TCGReg src) { if (facilities & FACILITY_EXT_IMM) { tcg_out_insn(s, RRE, LLGHR, dest, src); return; } if (dest == src) { tcg_out_movi(s, type, TCG_TMP0, 0xffff); src = TCG_TMP0; } else { tcg_out_movi(s, type, dest, 0xffff); } if (type == TCG_TYPE_I32) { tcg_out_insn(s, RR, NR, dest, src); } else { tcg_out_insn(s, RRE, NGR, dest, src); } }
1threat
How to configure VS Code to remember proxy settings (Windows) : <p>I'm a little bit fed up of this window:</p> <p><a href="https://i.stack.imgur.com/Vm6Ry.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Vm6Ry.png" alt="VS Code proxy authentication window"></a></p> <p>I checked the configuration and I added the proxy URL to the <code>http.proxy</code> entry as described <a href="https://code.visualstudio.com/docs/getstarted/settings" rel="noreferrer">here</a>:</p> <pre><code>"http.proxy": "http://frustratedusername:password@pesky.proxy.com:8080/" </code></pre> <p>But it didn't work. Then, I tried setting the <code>http_proxy</code> and <code>https_proxy</code> environment variables, but it didn't work neither.</p> <p>Is there any way to make VS Code remember the proxy settings?</p>
0debug
static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], const DVprofile *sys) { int size, chan, i, j, d, of, smpls, freq, quant, half_ch; uint16_t lc, rc; const uint8_t* as_pack; uint8_t *pcm, ipcm; as_pack = dv_extract_pack(frame, dv_audio_source); if (!as_pack) return 0; smpls = as_pack[1] & 0x3f; freq = (as_pack[4] >> 3) & 0x07; quant = as_pack[4] & 0x07; if (quant > 1) return -1; size = (sys->audio_min_samples[freq] + smpls) * 4; half_ch = sys->difseg_size / 2; ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0; pcm = ppcm[ipcm++]; for (chan = 0; chan < sys->n_difchan; chan++) { for (i = 0; i < sys->difseg_size; i++) { frame += 6 * 80; if (quant == 1 && i == half_ch) { pcm = ppcm[ipcm++]; if (!pcm) break; } for (j = 0; j < 9; j++) { for (d = 8; d < 80; d += 2) { if (quant == 0) { of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride; if (of*2 >= size) continue; pcm[of*2] = frame[d+1]; pcm[of*2+1] = frame[d]; if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00) pcm[of*2+1] = 0; } else { lc = ((uint16_t)frame[d] << 4) | ((uint16_t)frame[d+2] >> 4); rc = ((uint16_t)frame[d+1] << 4) | ((uint16_t)frame[d+2] & 0x0f); lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc)); of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride; if (of*2 >= size) continue; pcm[of*2] = lc & 0xff; pcm[of*2+1] = lc >> 8; of = sys->audio_shuffle[i%half_ch+half_ch][j] + (d - 8) / 3 * sys->audio_stride; pcm[of*2] = rc & 0xff; pcm[of*2+1] = rc >> 8; ++d; } } frame += 16 * 80; } } pcm = ppcm[ipcm++]; if (!pcm) break; } return size; }
1threat
calculate the difference between 2 timestamps in php : <p>I am using 2 timestamp in my table which is starttime datatype- timestamp and as current timestamp. endtime datatype-timestamp and default as 0000-00-00 00:00:00</p> <p>how to calculate the difference between 2 timestamps in php starttime:2016-11-30 03:55:06 endtimetime: 2016-11-30 11:55:06</p>
0debug
static void x86_cpu_register_feature_bit_props(X86CPU *cpu, FeatureWord w, int bitnr) { Object *obj = OBJECT(cpu); int i; char **names; FeatureWordInfo *fi = &feature_word_info[w]; if (!fi->feat_names[bitnr]) { return; } names = g_strsplit(fi->feat_names[bitnr], "|", 0); feat2prop(names[0]); x86_cpu_register_bit_prop(cpu, names[0], &cpu->env.features[w], bitnr); for (i = 1; names[i]; i++) { feat2prop(names[i]); object_property_add_alias(obj, names[i], obj, names[0], &error_abort); } g_strfreev(names); }
1threat
void bdrv_io_limits_enable(BlockDriverState *bs) { qemu_co_queue_init(&bs->throttled_reqs); bs->block_timer = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs); bs->io_limits_enabled = true; }
1threat
static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { int i; int width; int height; int64_t disp_transform[2]; int display_matrix[3][2]; AVStream *st = c->fc->streams[c->fc->nb_streams-1]; MOVStreamContext *sc = st->priv_data; int version = get_byte(pb); get_be24(pb); if (version == 1) { get_be64(pb); get_be64(pb); } else { get_be32(pb); get_be32(pb); } st->id = (int)get_be32(pb); get_be32(pb); (version == 1) ? get_be64(pb) : get_be32(pb); get_be32(pb); get_be32(pb); get_be16(pb); get_be16(pb); get_be16(pb); get_be16(pb); for (i = 0; i < 3; i++) { display_matrix[i][0] = get_be32(pb); display_matrix[i][1] = get_be32(pb); get_be32(pb); } width = get_be32(pb); track width height = get_be32(pb); track height sc->width = width >> 16; sc->height = height >> 16; if (width && height && (display_matrix[0][0] != 65536 || display_matrix[0][1] || display_matrix[1][0] || display_matrix[1][1] != 65536 || display_matrix[2][0] || display_matrix[2][1])) { for (i = 0; i < 2; i++) disp_transform[i] = (int64_t) width * display_matrix[0][i] + (int64_t) height * display_matrix[1][i] + ((int64_t) display_matrix[2][i] << 16); st->sample_aspect_ratio = av_d2q( ((double) disp_transform[0] * height) / ((double) disp_transform[1] * width), INT_MAX); } return 0; }
1threat
Hi can someone help me in setw in c++ : Hi first here is my program i want to make all the output of my program is segregate in column [Here is the Output of my program right now i want to make the output is all line in in age and section][1] #include<iostream> #include <iomanip> using namespace std; struct student { string fullname[200]; string course[200]; int age[200]; }; student p1; main() { int input; cout<<"How many Student do you like to Add:"; cin>>input; for(int i=0; i!=input; i++) { cout<<"----------Input #"<<i+1<<"----------"<<endl; cout<<"Enter Name: "; cin.ignore(); getline (cin,p1.fullname[i]); cout<<"Enter Age: "; cin>>p1.age[i]; cout<<"Enter Section: "; cin>>p1.course[i]; } cout<<"\n\n----------------- List of Student that is 19 Above -----------------"<<endl; cout<<"\nFull Name:"<<setw(20)<<"Age:"<<setw(20)<<"Section:"<<endl; for(int i=0; i!=input; i++) { if(p1.age[i] >= 19) { cout<<p1.fullname[i]<< setfill(' ') <<setw(20) <<p1.age[i]<< setfill(' ') <<setw(20)<<p1.course[i]<<endl; } } system("PAUSE"); } [1]: https://i.stack.imgur.com/lPEv4.png
0debug
Background color not changing in Google Chrome even after running "npm run dev" command in integrated terminal of VS Code : <p>I am learning Laravel. I tried to change the background color of web page. The course suggested to run -> "npm run dev" command in integrated terminal of Visual studio code which I indeed run to get a "Build successful" message. However, the background color still remains the same. Also, I run npm install dev, npm install webpack --save, npm install --ignore-platform-reqs , npm install --dev. However, nothing changes and the background color still remains same.</p> <p>Any suggestion is welcome.</p>
0debug
Golang, a proper way to rewind file pointer : <pre><code>package main import ( "bufio" "encoding/csv" "fmt" "io" "log" "os" ) func main() { data, err := os.Open("cc.csv") defer data.Close() if err != nil { log.Fatal(err) } s := bufio.NewScanner(data) for s.Scan() { fmt.Println(s.Text()) if err := s.Err(); err != nil { panic(err) } } // Is it a proper way? data.Seek(0, 0) r := csv.NewReader(data) for { if record, err := r.Read(); err == io.EOF { break } else if err != nil { log.Fatal(err) } else { fmt.Println(record) } } } </code></pre> <p>I use two readers here to read from a csv file. To rewind a file I use <code>data.Seek(0, 0)</code> is it a good way? Or it's better to close the file and open again before second reading.</p> <p>Is it also correct to use <code>*File</code> as an <code>io.Reader</code> ? Or it's better to do <code>r := ioutil.NewReader(data)</code> </p>
0debug
SFTP Password $ Sign issue while sending password in Unix : I need urgent help , i need to SFTP file to server and passowrd has $ sign and i need to escape \\$ i tried with perl and sed commands i am able to replace but proble is , the next string after $ is not getting appended, getting replaced entire string after $. Example: echo "Np4$g" | perl -pe 's/$/\\\\\$/g' output is Np4\\$. It supposed to be Np4\\$g, g is not getting appended. Please help its urgent requirement for me. Code: /usr/bin/expect <<EOF set timeout -1 spawn sftp -C -oPort=$port $sftp_username@$host_name expect "password:" send "$password\r" expect "sftp>" cd $remote_dir send "mput *.txt\r" expect "sftp>" send Its urgent please help. Thanks in advance.
0debug
Sending Email in PHP and Localhost : <p>i've searched for hours for a solution but i just don't get it. I'm fairly new to PHP, I'm doing a project where i need an email to be sent, the problem is that I can't figure how to do it. Others who had the same problem, fixed it by configuring the php.ini and the sendemail.ini</p> <p>This is my current code for testing:</p> <pre><code>&lt;?php $subject="Hi There!!"; $to="mygmail@gmail.com"; $body="This is a demo email sent using PHP on XAMPP"; if (mail($to,$subject,$body)){ echo "Mail sent successfully!"; } else{ echo "Mail not sent!"; } ?&gt; </code></pre> <p>I receive the "Mail sent successfully" but there is nothing on my inbox, not even on the spam folder. I also tried to use PHPMailer but (like i said) im fairly new to php and i don't get how to enable it on my code. What do you guys think?</p>
0debug
static void compute_pkt_fields2(AVStream *st, AVPacket *pkt){ int b_frames = FFMAX(st->codec.has_b_frames, st->codec.max_b_frames); int num, den, frame_size; if(pkt->pts != AV_NOPTS_VALUE) pkt->pts = av_rescale(pkt->pts, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); if(pkt->dts != AV_NOPTS_VALUE) pkt->dts = av_rescale(pkt->dts, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); pkt->duration = av_rescale(pkt->duration, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); if (pkt->duration == 0) { compute_frame_duration(&num, &den, st, NULL, pkt); if (den && num) { pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num); } } if((pkt->pts == 0 || pkt->pts == AV_NOPTS_VALUE) && pkt->dts == AV_NOPTS_VALUE && !b_frames){ pkt->dts= pkt->pts= st->pts.val; } if(pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE){ if(b_frames){ if(st->last_IP_pts == AV_NOPTS_VALUE){ st->last_IP_pts= -pkt->duration; } if(st->last_IP_pts < pkt->pts){ pkt->dts= st->last_IP_pts; st->last_IP_pts= pkt->pts; }else pkt->dts= pkt->pts; }else pkt->dts= pkt->pts; } st->cur_dts= pkt->dts; st->pts.val= pkt->dts; switch (st->codec.codec_type) { case CODEC_TYPE_AUDIO: frame_size = get_audio_frame_size(&st->codec, pkt->size); if (frame_size >= 0 && (pkt->size || st->pts.num!=st->pts.den>>1 || st->pts.val)) { av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); } break; case CODEC_TYPE_VIDEO: av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec.frame_rate_base); break; default: break; } }
1threat
static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov, int iovcnt) { TAPState *s = opaque; ssize_t len; do { len = writev(s->fd, iov, iovcnt); } while (len == -1 && (errno == EINTR || errno == EAGAIN)); return len; }
1threat
using regex in javascript to check if foreign characters : <p>I'm trying to create a simple function that checks if there are foreign characters in my string. Essentially, this is what I'm trying to get:</p> <pre><code>var str_1 = "отправка.py" // should return true var str_2 = "bla.py" // should return false var str_3 = "bla23.py" // should return false var str_4 = "bla23_.py" // should return false </code></pre> <p>I want to make sure that there aren't any foreign characters, while still making sure that I allow everything else (characters like "_", "-", ...). </p> <p>I'm just trying to avoid the Russian, Mandarin, etc.. alphabets.</p>
0debug
Automatically add copyright banner in VS Code : <p>Is there an easy way to configure VS Code to add a custom Copyright banner to a file? I was thinking of using a <a href="https://code.visualstudio.com/docs/customization/userdefinedsnippets" rel="noreferrer">code snippet</a>. Is there a better way of achieving the same thing? Thanks! </p>
0debug
static void sbr_qmf_analysis(AVFixedDSPContext *dsp, FFTContext *mdct, #else static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, #endif SBRDSPContext *sbrdsp, const INTFLOAT *in, INTFLOAT *x, INTFLOAT z[320], INTFLOAT W[2][32][32][2], int buf_idx) { int i; int j; memcpy(x , x+1024, (320-32)*sizeof(x[0])); memcpy(x+288, in, 1024*sizeof(x[0])); for (i = 0; i < 32; i++) { dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); sbrdsp->sum64x5(z); sbrdsp->qmf_pre_shuffle(z); mdct->imdct_half(mdct, z, z+64); sbrdsp->qmf_post_shuffle(W[buf_idx][i], z); x += 32;
1threat
VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) { VirtIOBlock *s; int cylinders, heads, secs; static int virtio_blk_id; DriveInfo *dinfo; if (!conf->bs) { error_report("virtio-blk-pci: drive property not set"); s = (VirtIOBlock *)virtio_common_init("virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config), sizeof(VirtIOBlock)); s->vdev.get_config = virtio_blk_update_config; s->vdev.get_features = virtio_blk_get_features; s->vdev.reset = virtio_blk_reset; s->bs = conf->bs; s->conf = conf; s->rq = NULL; s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1; bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); dinfo = drive_get_by_blockdev(s->bs); strncpy(s->sn, dinfo->serial, sizeof (s->sn)); s->vq = virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output); qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_removable(s->bs, 0); return &s->vdev;
1threat
Resources, scopes, permissions and policies in keycloak : <p>I want to create a fairly simple role-based access control system using Keycloak's authorizaion system. The system Keycloak is replacing allows us to create a "user", who is a member of one or more "groups". In this legacy system, a user is given "permission" to access each of about 250 "capabilities" either through group membership (where groups are assigned permissions) or a direct grant of a permission to the user.</p> <p>I would like to map the legacy system to keycloak authorizations.</p> <p>It should be simple for me to map each "capability" in the existing system to a keycloak resource and a set of keycloak scopes. For example, a "viewAccount" capability would obviously map to an "account" resource and a "view" scope; and "viewTransaction" maps to a "transaction" resource... but is it best practice to create just one "view" scope, and use it across multiple resources (account, transaction, etc)? Or should I create a "viewAccount" scope, a "viewTransaction" scope, etc?</p> <p>Similarly, I'm a little confused about permissions. For each practical combination of resource and scope, is it usual practice to create a permission? If there are multiple permissions matching a given resource/scope, what does Keycloak do? I'm guessing that the intention of Keycloak is to allow me to configure a matrix of permissions against resources and scopes, so for example I could have permission to access "accounts" and permission for "view" scope, so therefore I would have permission to view accounts?</p> <p>I ask because the result of all this seems to be that my old "viewAccount" capability ends up creating an "Account" resource, with "View" scope, and a "viewAccount" permission, which seems to get me back where I was. Which is fine, if it's correct.</p> <p>Finally, obviously I need a set of policies that determine if viewAccount should be applied. But am I right that this means I need a policy for each of the legacy groups that a user could belong to? For example, if I have a "helpdesk" role, then I need a "helpdesk membership" policy, which I could then add to the "viewAccount" permission. Is this correct?</p> <p>Thanks,</p> <p>Mark</p>
0debug
iOS 10 doesn't print NSLogs : <p>Nothing prints from <code>NSLog</code> on Xcode 8.0 beta (8S128d). <code>printf</code> is unchanged</p> <p>Here's my code:</p> <pre><code>NSLog(@"hello from NSLog"); printf("hello from printf"); </code></pre> <p>Here's the output on iOS 9 Simulator:</p> <pre><code>2016-06-17 09:49:10.887 calmapp-dev[28517:567025] hello from NSLog hello from printf </code></pre> <p>Here's the output on iOS 10 Simulator:</p> <pre><code>hello from printf </code></pre>
0debug
Not able to copy files between ubuntu machines using scp : <p>when i copy a file from one machine to another (both are ubuntu 16.04) the following error will be shown. But i ping the machines it will connect each other. root@192.168.1.114's password: Permission denied, please try again. root@192.168.1.114's password: Permission denied, please try again. root@192.168.1.114's password: Permission denied (publickey,password).</p> <p>i disables the firewall of both. But no change .Please advise.</p>
0debug
how to create a slice from a list that contains all entries equal to 5? : x=r'C:\Users\beladiy\Desktop\python\DAT210x-master\Module2\Datasets\Servo.data' df=pd.read_csv(x,names=['motor', 'screw', 'pgain', 'vgain', 'class'],header=None) *import data* how can I create slice from vgain that contains values equals to 5?
0debug
How to make app alway running in background , so user alway get notif even the app is close? : hello what must i do to make my app(android) that integrate wit smooch SDK always running in background. example if you have BBM ,Facebook ,or Gmail , when you close the app with back button or exit . the app will send you a notification even you dont open the app.
0debug
static void sx1_init(MachineState *machine, const int version) { struct omap_mpu_state_s *mpu; MemoryRegion *address_space = get_system_memory(); MemoryRegion *flash = g_new(MemoryRegion, 1); MemoryRegion *flash_1 = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); static uint32_t cs0val = 0x00213090; static uint32_t cs1val = 0x00215070; static uint32_t cs2val = 0x00001139; static uint32_t cs3val = 0x00001139; DriveInfo *dinfo; int fl_idx; uint32_t flash_size = flash0_size; int be; if (version == 2) { flash_size = flash2_size; } mpu = omap310_mpu_init(address_space, sx1_binfo.ram_size, machine->cpu_model); memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size, &error_abort); vmstate_register_ram_global(flash); memory_region_set_readonly(flash, true); memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash); memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "sx1.cs0", OMAP_CS0_SIZE - flash_size); memory_region_add_subregion(address_space, OMAP_CS0_BASE + flash_size, &cs[0]); memory_region_init_io(&cs[2], NULL, &static_ops, &cs2val, "sx1.cs2", OMAP_CS2_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[2]); memory_region_init_io(&cs[3], NULL, &static_ops, &cs3val, "sx1.cs3", OMAP_CS3_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[3]); fl_idx = 0; #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { if (!pflash_cfi01_register(OMAP_CS0_BASE, NULL, "omap_sx1.flash0-1", flash_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash_size / sector_size, 4, 0, 0, 0, 0, be)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", fl_idx); } fl_idx++; } if ((version == 1) && (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0", flash1_size, &error_abort); vmstate_register_ram_global(flash_1); memory_region_set_readonly(flash_1, true); memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1); memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "sx1.cs1", OMAP_CS1_SIZE - flash1_size); memory_region_add_subregion(address_space, OMAP_CS1_BASE + flash1_size, &cs[1]); if (!pflash_cfi01_register(OMAP_CS1_BASE, NULL, "omap_sx1.flash1-1", flash1_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash1_size / sector_size, 4, 0, 0, 0, 0, be)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", fl_idx); } fl_idx++; } else { memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "sx1.cs1", OMAP_CS1_SIZE); memory_region_add_subregion(address_space, OMAP_CS1_BASE, &cs[1]); } if (!machine->kernel_filename && !fl_idx && !qtest_enabled()) { fprintf(stderr, "Kernel or Flash image must be specified\n"); exit(1); } sx1_binfo.kernel_filename = machine->kernel_filename; sx1_binfo.kernel_cmdline = machine->kernel_cmdline; sx1_binfo.initrd_filename = machine->initrd_filename; arm_load_kernel(mpu->cpu, &sx1_binfo); }
1threat
How to make a keylogger on android with adb? : is ther a way to see all screen touch's from my android divec on my pc with adb ? like every time thet I touch the screen it will print me wear I touch'd ...
0debug
int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt, int is_vp7) { VP8Context *s = avctx->priv_data; int ret, i, referenced, num_jobs; enum AVDiscard skip_thresh; VP8Frame *av_uninit(curframe), *prev_frame; if (is_vp7) ret = vp7_decode_frame_header(s, avpkt->data, avpkt->size); else ret = vp8_decode_frame_header(s, avpkt->data, avpkt->size); if (ret < 0) goto err; prev_frame = s->framep[VP56_FRAME_CURRENT]; referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT || s->update_altref == VP56_FRAME_CURRENT; skip_thresh = !referenced ? AVDISCARD_NONREF : !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL; if (avctx->skip_frame >= skip_thresh) { s->invisible = 1; memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4); goto skip_decode; } s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh; for (i = 0; i < 5; i++) if (s->frames[i].tf.f->data[0] && &s->frames[i] != prev_frame && &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) vp8_release_frame(s, &s->frames[i]); curframe = s->framep[VP56_FRAME_CURRENT] = vp8_find_free_buffer(s); if (!s->colorspace) avctx->colorspace = AVCOL_SPC_BT470BG; if (s->fullrange) avctx->color_range = AVCOL_RANGE_JPEG; else avctx->color_range = AVCOL_RANGE_MPEG; if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] || !s->framep[VP56_FRAME_GOLDEN] || !s->framep[VP56_FRAME_GOLDEN2])) { av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n"); ret = AVERROR_INVALIDDATA; goto err; } curframe->tf.f->key_frame = s->keyframe; curframe->tf.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; if ((ret = vp8_alloc_frame(s, curframe, referenced)) < 0) goto err; if (s->update_altref != VP56_FRAME_NONE) s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref]; else s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[VP56_FRAME_GOLDEN2]; if (s->update_golden != VP56_FRAME_NONE) s->next_framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden]; else s->next_framep[VP56_FRAME_GOLDEN] = s->framep[VP56_FRAME_GOLDEN]; if (s->update_last) s->next_framep[VP56_FRAME_PREVIOUS] = curframe; else s->next_framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_PREVIOUS]; s->next_framep[VP56_FRAME_CURRENT] = curframe; if (avctx->codec->update_thread_context) ff_thread_finish_setup(avctx); s->linesize = curframe->tf.f->linesize[0]; s->uvlinesize = curframe->tf.f->linesize[1]; memset(s->top_nnz, 0, s->mb_width * sizeof(*s->top_nnz)); if (!s->mb_layout) memset(s->macroblocks + s->mb_height * 2 - 1, 0, (s->mb_width + 1) * sizeof(*s->macroblocks)); if (!s->mb_layout && s->keyframe) memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width * 4); memset(s->ref_count, 0, sizeof(s->ref_count)); if (s->mb_layout == 1) { if (prev_frame && s->segmentation.enabled && !s->segmentation.update_map) ff_thread_await_progress(&prev_frame->tf, 1, 0); if (is_vp7) vp7_decode_mv_mb_modes(avctx, curframe, prev_frame); else vp8_decode_mv_mb_modes(avctx, curframe, prev_frame); } if (avctx->active_thread_type == FF_THREAD_FRAME) num_jobs = 1; else num_jobs = FFMIN(s->num_coeff_partitions, avctx->thread_count); s->num_jobs = num_jobs; s->curframe = curframe; s->prev_frame = prev_frame; s->mv_bounds.mv_min.y = -MARGIN; s->mv_bounds.mv_max.y = ((s->mb_height - 1) << 6) + MARGIN; for (i = 0; i < MAX_THREADS; i++) { VP8ThreadData *td = &s->thread_data[i]; atomic_init(&td->thread_mb_pos, 0); atomic_init(&td->wait_mb_pos, INT_MAX); } if (is_vp7) avctx->execute2(avctx, vp7_decode_mb_row_sliced, s->thread_data, NULL, num_jobs); else avctx->execute2(avctx, vp8_decode_mb_row_sliced, s->thread_data, NULL, num_jobs); ff_thread_report_progress(&curframe->tf, INT_MAX, 0); memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4); skip_decode: if (!s->update_probabilities) s->prob[0] = s->prob[1]; if (!s->invisible) { if ((ret = av_frame_ref(data, curframe->tf.f)) < 0) return ret; *got_frame = 1; } return avpkt->size; err: memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4); return ret; }
1threat
static uint32_t softfloat_mul(uint32_t x, uint64_t mantissa) { uint64_t l = x * (mantissa & 0xffffffff); uint64_t h = x * (mantissa >> 32); h += l >> 32; l &= 0xffffffff; l += 1 << av_log2(h >> 21); h += l >> 32; return h >> 20; }
1threat
HOW ? javascript 3 dijital take random number? : i want to make random just 3digit number but when i run it , its use alphabet and number i want just get random number generate: function () { this.newItem.st = Math.random().toString(36).substring(2, 3).toUpperCase() + Math.random().toString(36).substring(2, 4).toUpperCase()
0debug
Shuffle an array in a specific format : I need to shuffle an array in such a way that in each shuffle third element of the array should change to the first one For Eg : My array is array(1,2,3,4,5,6,7,8,9); in first shuffle I want the array to array(4,5,6,7,8,9,1,2,3) next array(7,8,9,1,2,3,4,5,6) and so on... Hope any one will help me Thanks in advance !
0debug
Not finding occurences as intended : I have the following program, the programs purpose is to display how many times each value in the list vector occurred. if the tuple 2:3 occurs 3 times in the array, then the program displays this to the user. **Expected output** - 0:8 occurred 1 time %x - 2:3 occurred 3 time %x - 1:5 occurred 1 time %x - 9:5 occurred 2 time %x **Actual Output:** - 2:3 occurred 3 time %42 - 8:9 occurred 1 time %14 - 9:5 occurred 3 time %42 Any idea what I'm doing incorrectly? Here's a complete and verifiable working version of the code I'm using Any assistance is greatly appreciated. #include <vector> #include <iostream> #include <tuple> using namespace std; int counter = 0; double percentage; int val = 0; vector<tuple<int, int>> list = { make_tuple(2, 3), make_tuple(0, 8), make_tuple(2, 3), make_tuple(8, 9), make_tuple(9, 5), make_tuple(9, 5), make_tuple(2, 3) }; int binarysearch(vector<tuple<int, int>> list, int low, int high, tuple<int, int> number) { int index = low; int mid = 0; // loop till the condition is true while (low <= high) { // divide the array for search mid = (low + high) / 2; if (list.at(mid) > number) { high = mid - 1; } else { low = mid + 1; } }return (high - index + 1); } int main() { while (counter <= list.size() - 1) { val = binarysearch(list, counter, list.size() - 1, list.at(counter)); percentage = val * 100 / list.size(); cout << "Value: " << get<0>(list.at(counter)) << ":" << get<1>(list.at(counter)) << " Occurs: " << val << " Time(s)" << " %" << percentage << endl; counter += val; } return 0; }
0debug
static int nbd_send_rep_list(int csock, NBDExport *exp) { uint64_t magic, name_len; uint32_t opt, type, len; name_len = strlen(exp->name); magic = cpu_to_be64(NBD_REP_MAGIC); if (write_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) { LOG("write failed (magic)"); return -EINVAL; } opt = cpu_to_be32(NBD_OPT_LIST); if (write_sync(csock, &opt, sizeof(opt)) != sizeof(opt)) { LOG("write failed (opt)"); return -EINVAL; } type = cpu_to_be32(NBD_REP_SERVER); if (write_sync(csock, &type, sizeof(type)) != sizeof(type)) { LOG("write failed (reply type)"); return -EINVAL; } len = cpu_to_be32(name_len + sizeof(len)); if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) { LOG("write failed (length)"); return -EINVAL; } len = cpu_to_be32(name_len); if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) { LOG("write failed (length)"); return -EINVAL; } if (write_sync(csock, exp->name, name_len) != name_len) { LOG("write failed (buffer)"); return -EINVAL; } return 0; }
1threat
i am using 'com.android.support:appcompat-v7:22.0.1' android studio : protected void setupView(){ // TourGuide can only be setup after all the views is ready and obtain it's position/measurement // so when this is the 1st time TourGuide is being added, // else block will be executed, and ViewTreeObserver will make TourGuide setup process to be delayed until everything is ready // when this is run the 2nd or more times, if block will be executed if (ViewCompat.isAttachedToWindow(mHighlightedView)){ startView(); } else { final ViewTreeObserver viewTreeObserver = mHighlightedView.getViewTreeObserver(); viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { //noinspection deprecation mHighlightedView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { mHighlightedView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } startView(); } }); } } getting error Error:(198, 23) error: cannot find symbol method isAttachedToWindow(View)
0debug
static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, const char *name, const char *default_type, const char *description) { DevicePropertyInfo *info; Property *prop; do { for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) { if (strcmp(name, prop->name) != 0) { continue; } if (!prop->info->set) { return NULL; } info = g_malloc0(sizeof(*info)); info->name = g_strdup(prop->name); info->type = g_strdup(prop->info->name); info->has_description = !!prop->info->description; info->description = g_strdup(prop->info->description); return info; } klass = object_class_get_parent(klass); } while (klass != object_class_by_name(TYPE_DEVICE)); info = g_malloc0(sizeof(*info)); info->name = g_strdup(name); info->type = g_strdup(default_type); info->has_description = !!description; info->description = g_strdup(description); return info; }
1threat
PHP code is not running before loop : <pre><code>&lt;?php $date = '2017-08-22'; $year = substr($date, 0, 4); $month = substr($date, 5, 2); $day = substr($date, 8, 2); ?&gt; &lt;select&gt; &lt;?php for ($i=1; $i &lt; 30; $i++) { ?&gt; &lt;option value="&lt;?php echo $i; ?&gt;" &lt;?php if($day === $i){ echo "selected"; }; ?&gt;&gt;&lt;?php echo $i; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; </code></pre> <p>the code is not executing because <code>substr</code> is not running before the for loop. the select should be selected on day 22 but it is not selecting anything. if i change <code>$day = 22;</code>, it works. how can i fix this with the substring?</p>
0debug
stack new command failing to download build plan for lts-14.1 : <p>Stack fails with a 404 HTTP status to download a build plan for lts-14.1:</p> <pre><code>$ stack new my-project [...] Downloading lts-14.1 build plan ... RedownloadInvalidResponse Request { host = "raw.githubusercontent.com" port = 443 secure = True requestHeaders = [] path = "/fpco/lts-haskell/master//lts-14.1.yaml" queryString = "" method = "GET" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 } "/home/michid/.stack/build-plan/lts-14.1.yaml" (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Security-Policy","default-src 'none'; style-src 'unsafe-inline'; sandbox"),("Strict-Transport-Security","max-age=31536000"),("X-Content-Type-Options","nosniff"),("X-Frame-Options","deny"),("X-XSS-Protection","1; mode=block"),("X-GitHub-Request-Id","10DA:4457:1D507:285B9:5D55DA2D"),("Content-Length","15"),("Accept-Ranges","bytes"),("Date","Thu, 15 Aug 2019 22:18:21 GMT"),("Via","1.1 varnish"),("Connection","keep-alive"),("X-Served-By","cache-mxp19828-MXP"),("X-Cache","MISS"),("X-Cache-Hits","0"),("X-Timer","S1565907502.529821,VS0,VE176"),("Vary","Authorization,Accept-Encoding"),("Access-Control-Allow-Origin","*"),("X-Fastly-Request-ID","9f869169dd207bbd8bb8a8fd4b274acf6580ba4f"),("Expires","Thu, 15 Aug 2019 22:23:21 GMT"),("Source-Age","0")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) </code></pre> <p>Everything works fine if I specify <code>--resolver lts-13.19</code> on the command line so I'm assuming this is a bug.</p> <ul> <li>Anything I can do locally to work around this problem?</li> <li>What is the best place to report the issue or check whether it is a known one? I came across <a href="https://github.com/commercialhaskell/stack" rel="noreferrer">https://github.com/commercialhaskell/stack</a> but am not sure whether this is the right place. </li> </ul>
0debug
How to check if string contains at least one alphabetical letter (a-z,A-Z) C# : <p>could someone telle me please how to check if a string contains at least one alphabetical letter? I tryed:</p> <pre><code>if (StringName.Text.Contains(Char.IsLetter())) { //Do Something } </code></pre> <p>But it doesn't work.</p>
0debug
static int decode_audio_specific_config(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, const uint8_t *data, int bit_size, int sync_extension) { GetBitContext gb; int i, ret; av_dlog(avctx, "extradata size %d\n", avctx->extradata_size); for (i = 0; i < avctx->extradata_size; i++) av_dlog(avctx, "%02x ", avctx->extradata[i]); av_dlog(avctx, "\n"); init_get_bits(&gb, data, bit_size); if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, sync_extension)) < 0) return AVERROR_INVALIDDATA; if (m4ac->sampling_index > 12) { av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index); return AVERROR_INVALIDDATA; } skip_bits_long(&gb, i); switch (m4ac->object_type) { case AOT_AAC_MAIN: case AOT_AAC_LC: case AOT_AAC_LTP: if ((ret = decode_ga_specific_config(ac, avctx, &gb, m4ac, m4ac->chan_config)) < 0) return ret; break; default: av_log(avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n", m4ac->sbr == 1 ? "SBR+" : "", m4ac->object_type); return AVERROR(ENOSYS); } av_dlog(avctx, "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n", m4ac->object_type, m4ac->chan_config, m4ac->sampling_index, m4ac->sample_rate, m4ac->sbr, m4ac->ps); return get_bits_count(&gb); }
1threat
Swift: Howto change from proportional to tabulated digits in menu items? : Swift 3, Xcode 8. I want to change from proportional to tabulated digits in menu items? It's possible? [Menu without tabulated digits][1] [1]: https://i.stack.imgur.com/DMQ2v.png
0debug
How to get the status bar height in iOS 13? : <p>In iOS 13 <code>UIApplication.shared.statusBarFrame.height</code> warns</p> <blockquote> <p>'statusBarFrame' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.</p> </blockquote> <p>How do you get the status bar height without using a deprecated API in iOS 13?</p>
0debug
Trying to switch divs onclick using javascript : <p>I am making a virtual business card, and my javascript code isnt working. Im trying to make it so that when you click the button, the card switches to the other div (The back of the card) but the code isn't working. Here's my code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var cardFront = document.getElementsByClassName("CardBackground"); var cardBack = document.getElementsByClassName("CardBackground2"); function front() { cardFront.style.display = "block"; } function frontOff() { cardFront.style.display = "none"; } function back() { cardBack.style.display = "block"; } function backOff() { cardBack.style.display = "none"; } function flip() { if(cardFront.style.display === "block"){ cardFront.style.display = "none"; } }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.CardBackground{ background: rgb(45,45,45); /* Old browsers */ background: -moz-linear-gradient(top, rgba(45,45,45,1) 0%, rgba(0,0,0,1) 100%); /* FF3.6-15 */ background: -webkit-linear-gradient(top, rgba(45,45,45,1) 0%,rgba(0,0,0,1) 100%); /* Chrome10-25,Safari5.1-6 */ background: linear-gradient(to bottom, rgba(45,45,45,1) 0%,rgba(0,0,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d2d2d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */ border:1px white solid; position:absolute; width:60%; height:80%; left:20%; top:10%; border-radius: 20px 20px 20px 20px; overflow-y:auto; display: block; } .CardBackground2{ background: rgb(45,45,45); /* Old browsers */ background: -moz-linear-gradient(top, rgba(45,45,45,1) 0%, rgba(0,0,0,1) 100%); /* FF3.6-15 */ background: -webkit-linear-gradient(top, rgba(45,45,45,1) 0%,rgba(0,0,0,1) 100%); /* Chrome10-25,Safari5.1-6 */ background: linear-gradient(to bottom, rgba(45,45,45,1) 0%,rgba(0,0,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d2d2d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */ border:1px white solid; position:absolute; width:60%; height:80%; left:20%; top:10%; border-radius: 20px 20px 20px 20px; overflow-y:auto; display:none; z-index:2; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="CardBackground2"&gt; &lt;input type="button" value="Flip Card" class="flip" onclick="flip()"&gt; &lt;/div&gt; &lt;div class="CardBackground"&gt; &lt;input type="button" value="Flip Card" class="flip"&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0debug
This MySQL syntax (function) is error. I had checked it, but I can't repaired. How I can repair it? : CREATE FUNCTION FC_IDKRITERIA() RETURNS CHAR(3) AS BEGIN DECLARE @MAX INT , @KODEBARU CHAR(3) SELECT @MAX = MAX (RIGHT(IDKRITERIA,2)) FROM KRITERIA IF @MAX IS NULL SET @MAX = 0 SET @KODEBARU = 'K' + RIGHT('0'+CONVERT(VARCHAR(3),@MAX+ 1 ) ,2) RETURN @KODEBARU END
0debug
how to automatically refresh the chat on receiving gcm notification : <p>i am developing chat application. I want to automatically refresh the chat on receiving notification. I have tried using timer but its not that good as it refreshes after certain time period.</p>
0debug
Writing WHERE output to variable : <p>I'm using the <code>WHERE</code> command as a search feature to find a specific file type within a group of folders, but I can't figure out how to export the results as a variable or something that I can reference to <code>COPY</code> the files that the <code>WHICH</code> command found. Any suggestions?</p>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
servlet db connection with schema.tableName : My query is select* from "Table"."SampleDB"; My servlet code is String dbURL = "jdbc:postgresql://localhost:5433/Table.SampleDB"; String user = "postgres"; String pass = "pass"; conn = DriverManager.getConnection(dbURL, user, pass); I am not able to connect to the database. How to call a "schema.TableName" in servlet getConnection. Please help me fix the issue.
0debug
Pausing videos in view pagers : i am displaying videos using view pagers in each view pager plays a separate video and how can the video will be paused after swiping to next view pager like in Facebook or Instagram.
0debug
Error:(35, 62) java: void cannot be dereferenced : I'm trying to call a stored procedure using CallableStament, but when I do call the method for it returns Error:(35, 62) java: void cannot be dereferenced. Code: > public class Connect { > > public void connDB() throws Exception { > > > Class.forName("oracle.jdbc.driver.OracleDriver"); > > try (Connection conn = DriverManager.getConnection( > "jdbc:oracle:thin:@test123:4321:test1", "test", "test")) { > > if (conn != null) { > System.out.println("Connected to the database!"); > } else { > System.out.println("Failed to make connection!"); > } > > } catch (SQLException e) { > System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); > } > catch (Exception e) { > > } > } > > public void callablestatement(int resync_value){ > Connect conectivitateDb = new Connect(); > > CallableStatement stmt = conectivitateDb.connDB().prepareCall("{call > resync_entity.resync_this_entity(?)}"); > > stmt.setInt(1, resync_value); > stmt.execute(); > } } If I do the callable statement in the try catch block in from the conndb method, it works just fine.
0debug
how can I unifiy mdf database connection string across all users ? [windows forms] : I'm developing windows form application and I'm facing a problem that I use connection string path to the mdf database in my computer but when running the app on another computer the path will be different ? how can I figure it our programmatically ؟
0debug
Where can I find the ports of all running pm2 apps? : <p>I have a server with PM2 installed and 10 running node apps. Every App should run with a different port number. When I install a new App on the server I need the information about the used ports. With 'pm2 list' I get much info about the apps but not the port.</p> <pre><code>pm2 list App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching example_name │ 1 │ 0.0.0 │ fork │ 25651 │ online │ 0 │ 37D │ 0% │ 386.3 MB │ root │ disabled </code></pre> <p>I can not find a overview of all used ports and I can't believe that this important information is not given by PM2. Does anyone have any idea where I see a list with all used ports in PM2?</p>
0debug
Why does Object.keys() and Object.getOwnPropertyNames() produce different output when called on a Proxy object with ownKeys handler? : <p>I have the following proxy:</p> <pre><code>const p = new Proxy({}, { ownKeys(target) { return ['a', 'b']; }, }); </code></pre> <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys#Interceptions" rel="noreferrer">MDN</a> says that:</p> <blockquote> <p>This trap can intercept these operations:</p> <ul> <li><code>Object.getOwnPropertyNames()</code></li> <li><code>Object.getOwnPropertySymbols()</code></li> <li><code>Object.keys()</code></li> <li><code>Reflect.ownKeys()</code></li> </ul> </blockquote> <p>Therefore, I expected <code>Object.getOwnPropertyNames()</code> and <code>Object.keys()</code> to produce the same output. However, <code>Object.getOwnPropertyNames(p)</code> returns <code>['a', 'b']</code> (as expected), but <code>Object.keys(p)</code> returns an empty array. Why is that?</p> <p>Also, if I add a property to this object which is not returned by the <code>ownKeys</code> handler (for example <code>c</code>), it gets ignored by both functions (they don't change their output). However, when I add a property which is returned by the <code>ownKeys</code> handler (for example <code>a</code>), <code>Object.keys(p)</code> now returns <code>['a']</code>.</p> <p>Code snippet:</p> <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const p = new Proxy({}, { ownKeys(target) { return ['a', 'b']; }, }); console.log(Object.getOwnPropertyNames(p)); // ['a', 'b'] console.log(Object.keys(p)); // [] p.c = true; console.log(Object.getOwnPropertyNames(p)); // ['a', 'b'] console.log(Object.keys(p)); // [] p.a = true; console.log(Object.getOwnPropertyNames(p)); // ['a', 'b'] console.log(Object.keys(p)); // ['a']</code></pre> </div> </div> </p>
0debug
uint8_t *smbios_get_table(size_t *length) { smbios_validate_table(); *length = smbios_entries_len; return smbios_entries; }
1threat
shared_ptr strangeness with null values and custom deleter : <p>We recently came across a crash when moving from a unique_ptr to a shared_ptr, using a custom deleter. The crash happened when the pointer used to create the smart pointer was null. Below is code that reproduces the problem, and shows two cases that work.</p> <p>In the source below, One and Two run happily, while Three crashes in "ReleaseDestroy". The crash appears to be happening when the class being used in the smart pointer has a virtual "Release" and so the program is trying to look up the V-Table. unique_ptr looks like it checks for null pointers and doesn't run the destructor. Shared pointer seems to neglect this. </p> <p>Does anyone know if this is by design, or is it a bug in the stl implementation? We are using Visual Studio 2015.</p> <pre><code>#include &lt;iostream&gt; #include &lt;memory&gt; template&lt;class R&gt; void ReleaseDestroy(R* r) { r-&gt;Release(); }; class FlatDestroy { public : void Release() { delete this; } }; class VirtualDestroy { public: virtual void Release() { delete this; } }; class SimpleOne { public : }; void main() { std::shared_ptr&lt;SimpleOne&gt; One(nullptr); std::shared_ptr&lt;FlatDestroy&gt; Two(nullptr, ReleaseDestroy&lt;FlatDestroy&gt;); std::shared_ptr&lt;VirtualDestroy&gt; Three(nullptr, ReleaseDestroy&lt;VirtualDestroy&gt;); One.reset(); Two.reset(); Three.reset(); } </code></pre>
0debug
Identifying use case diagram elements : <p>To map the User Stories, Epics, and Roles to Use Case diagram elements what are the possible methods of we can follow?</p>
0debug
static bool e1000_full_mac_needed(void *opaque) { E1000State *s = opaque; return s->compat_flags & E1000_FLAG_MAC; }
1threat
matplotlib and subplots properties : <p>I'm adding a matplotlib figure to a canvas so that I may integrate it with pyqt in my application. I were looking around and using <code>plt.add_subplot(111)</code> seem to be the way to go(?) But I cannot add any properties to the subplot as I may with an "ordinary" plot</p> <p>figure setup</p> <pre><code>self.figure1 = plt.figure() self.canvas1 = FigureCanvas(self.figure1) self.graphtoolbar1 = NavigationToolbar(self.canvas1, frameGraph1) hboxlayout = qt.QVBoxLayout() hboxlayout.addWidget(self.graphtoolbar1) hboxlayout.addWidget(self.canvas1) frameGraph1.setLayout(hboxlayout) </code></pre> <p>creating subplot and adding data</p> <pre><code>df = self.quandl.getData(startDate, endDate, company) ax = self.figure1.add_subplot(111) ax.hold(False) ax.plot(df['Close'], 'b-') ax.legend(loc=0) ax.grid(True) </code></pre> <p>I'd like to set x and y labels, but if I do <code>ax.xlabel("Test")</code></p> <pre><code>AttributeError: 'AxesSubplot' object has no attribute 'ylabel' </code></pre> <p>which is possible if I did it by not using subplot </p> <pre><code>plt.figure(figsize=(7, 4)) plt.plot(df['Close'], 'k-') plt.grid(True) plt.legend(loc=0) plt.xlabel('value') plt.ylabel('frequency') plt.title('Histogram') locs, labels = plt.xticks() plt.setp(labels, rotation=25) plt.show() </code></pre> <p>So I guess my question is, is it not possible to modify subplots further? Or is it possible for me to plot graphs in a pyqt canvas, without using subplots so that I may get benefit of more properties for my plots.</p>
0debug
type_init(vmgenid_register_types) GuidInfo *qmp_query_vm_generation_id(Error **errp) { GuidInfo *info; VmGenIdState *vms; Object *obj = find_vmgenid_dev(); if (!obj) { return NULL; } vms = VMGENID(obj); info = g_malloc0(sizeof(*info)); info->guid = qemu_uuid_unparse_strdup(&vms->guid); return info; }
1threat
Can I use NSNotificationCenter selector method in multiple view controllers? : <p>I have this <code>ViewControllerA</code> that pushes <code>ViewControllerB</code> onto the navigation stack, which pushes <code>ViewControllerC</code> onto the stack.</p> <p>From <code>ViewControllerB</code>, I can pop to <code>ViewControllerA</code>. And from <code>ViewControllerC</code>, I can pop to <code>ViewControllerA</code>. </p> <p>I need to pass an <code>NSNumber</code> to <code>ViewControllerA</code> from either <code>B</code> and <code>C</code> (depending on which controller I'm using to pop to <code>A</code>). </p> <p>I am going to incorporate the following:</p> <pre><code>- (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getUpdate:) name:@"getUpdateForCell" object:nil]; } </code></pre> <p>and implement:</p> <pre><code>- (void)getUpdate:(NSNotification *)notification { NSDictionary *data = [notification userInfo]; // pop } </code></pre> <p>Can I use/implement <code>getUpdate:</code> in both <code>ViewControllerB</code> and <code>ViewControllerC</code>?</p>
0debug
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) { MOVContext *mov = s->priv_data; MOVStreamContext *sc; AVIndexEntry *sample; AVStream *st = NULL; int ret; mov->fc = s; retry: sample = mov_find_next_sample(s, &st); if (!sample) { mov->found_mdat = 0; if (!mov->next_root_atom) return AVERROR_EOF; avio_seek(s->pb, mov->next_root_atom, SEEK_SET); mov->next_root_atom = 0; if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || url_feof(s->pb)) return AVERROR_EOF; av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); goto retry; sc = st->priv_data; sc->current_sample++; if (st->discard != AVDISCARD_ALL) { if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n", sc->ffindex, sample->pos); return AVERROR_INVALIDDATA; ret = av_get_packet(sc->pb, pkt, sample->size); if (ret < 0) return ret; if (sc->has_palette) { uint8_t *pal; pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); if (!pal) { av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n"); } else { memcpy(pal, sc->palette, AVPALETTE_SIZE); sc->has_palette = 0; #if CONFIG_DV_DEMUXER if (mov->dv_demux && sc->dv_audio_container) { avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); av_free(pkt->data); pkt->size = 0; ret = avpriv_dv_get_packet(mov->dv_demux, pkt); if (ret < 0) return ret; #endif pkt->stream_index = sc->ffindex; pkt->dts = sample->timestamp; if (sc->ctts_data && sc->ctts_index < sc->ctts_count) { pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration; sc->ctts_sample++; if (sc->ctts_index < sc->ctts_count && sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) { sc->ctts_index++; sc->ctts_sample = 0; if (sc->wrong_dts) pkt->dts = AV_NOPTS_VALUE; } else { int64_t next_dts = (sc->current_sample < st->nb_index_entries) ? st->index_entries[sc->current_sample].timestamp : st->duration; pkt->duration = next_dts - pkt->dts; pkt->pts = pkt->dts; if (st->discard == AVDISCARD_ALL) goto retry; pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; pkt->pos = sample->pos; av_dlog(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration); return 0;
1threat
can any body tell me that if public static class name variable can call without object : public class StateCacheManager { public static StateCacheManager mInstance;} my question is the variable mInstance can call without object ,if no then what this above statement significant
0debug
static void MPV_encode_defaults(MpegEncContext *s){ static int done=0; MPV_common_defaults(s); if(!done){ int i; done=1; for(i=-16; i<16; i++){ default_fcode_tab[i + MAX_MV]= 1; } } s->me.mv_penalty= default_mv_penalty; s->fcode_tab= default_fcode_tab; }
1threat
Global variables in Javascript and ESLint : <p>I have got multiple javascript files and I have defined some global variable in a file which loads before the others. As a consequence all of the files loaded after the first have access to the global variable. However ESLint shows the global variable as "not defined". I don't want to change the rules of ESLint and I would like to find an elegant way to get rid of these error messages. Any clue? Thanks</p>
0debug
void hmp_cont(Monitor *mon, const QDict *qdict) { Error *errp = NULL; qmp_cont(&errp); if (error_is_set(&errp)) { if (error_is_type(errp, QERR_DEVICE_ENCRYPTED)) { const char *device; device = error_get_field(errp, "device"); assert(device != NULL); monitor_read_block_device_key(mon, device, hmp_cont_cb, mon); error_free(errp); return; } hmp_handle_error(mon, &errp); } }
1threat
How to set a checkbox based on a string : <p>I have a function which reads some data from a txt file and than writes the data into my project.</p> <p>My problem is that i can't fill my checkboxes because they don't recognize strings.</p> <p>For example</p> <pre><code>CheckBox1.IsChecked = File.ReadLines(filename).Skip(0).Take(1).First(); </code></pre> <p>It says that a string can't be converted into a bool value.</p> <p>The first line in my txt file is obviously false in this example so the Output is not the problem.</p>
0debug
What language standards allow ignoring null terminators on fixed size arrays? : <p>We are transitioning C code into C++.<br> I noticed that the following code is well defined in C, </p> <pre><code>int main(){ //length is valid. '\0' is ignored char str[3]="abc"; } </code></pre> <p>as it is stated in <a href="http://en.cppreference.com/w/c/language/array_initialization">Array initialization</a> that: </p> <blockquote> <p>"If the size of the array is known, it may be one less than the size of the string literal, in which case the terminating null character is ignored."</p> </blockquote> <p>However, if I were to build the same code in C++, I get the following C++ error: </p> <pre><code>error: initializer-string for array of chars is too long [-fpermissive] char str[3]="abc"; </code></pre> <p>I'm hoping someone can expound on this. </p> <p><strong>Questions:</strong><br> Is the code example valid in all C language standards?<br> Is it invalid in all C++ language standards?<br> Is there a reason that is valid in one language but not another?</p>
0debug
Pass function arguments by column position to mutate_at : <p>I'm trying to tighten up a <code>%&gt;%</code> piped workflow where I need to apply the same function to several columns but with one argument changed each time. I feel like <code>purrr</code>'s <code>map</code> or <code>invoke</code> functions should help, but I can't wrap my head around it.</p> <p>My data frame has columns for life expectancy, poverty rate, and median household income. I can pass all these column names to <code>vars</code> in <code>mutate_at</code>, use <code>round</code> as the function to apply to each, and optionally supply a <code>digits</code> argument. But I can't figure out a way, if one exists, to pass different values for <code>digits</code> associated with each column. I'd like life expectancy rounded to 1 digit, poverty rounded to 2, and income rounded to 0.</p> <p>I can call <code>mutate</code> on each column, but given that I might have more columns all receiving the same function with only an additional argument changed, I'd like something more concise.</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) df &lt;- tibble::tribble( ~name, ~life_expectancy, ~poverty, ~household_income, "New Haven", 78.0580437642378, 0.264221051111753, 42588.7592521085 ) </code></pre> <p>In my imagination, I could do something like this:</p> <pre class="lang-r prettyprint-override"><code>df %&gt;% mutate_at(vars(life_expectancy, poverty, household_income), round, digits = c(1, 2, 0)) </code></pre> <p>But get the error</p> <blockquote> <p>Error in mutate_impl(.data, dots) : Column <code>life_expectancy</code> must be length 1 (the number of rows), not 3</p> </blockquote> <p>Using <code>mutate_at</code> instead of <code>mutate</code> just to have the same syntax as in my ideal case:</p> <pre class="lang-r prettyprint-override"><code>df %&gt;% mutate_at(vars(life_expectancy), round, digits = 1) %&gt;% mutate_at(vars(poverty), round, digits = 2) %&gt;% mutate_at(vars(household_income), round, digits = 0) #&gt; # A tibble: 1 x 4 #&gt; name life_expectancy poverty household_income #&gt; &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; #&gt; 1 New Haven 78.1 0.26 42589 </code></pre> <p>Mapping over the digits uses each of the <code>digits</code> options for <em>each</em> column, not by position, giving me 3 rows each rounded to a different number of digits.</p> <pre class="lang-r prettyprint-override"><code>df %&gt;% mutate_at(vars(life_expectancy, poverty, household_income), function(x) map(x, round, digits = c(1, 2, 0))) %&gt;% unnest() #&gt; # A tibble: 3 x 4 #&gt; name life_expectancy poverty household_income #&gt; &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; #&gt; 1 New Haven 78.1 0.3 42589. #&gt; 2 New Haven 78.1 0.26 42589. #&gt; 3 New Haven 78 0 42589 </code></pre> <p><sup>Created on 2018-11-13 by the <a href="https://reprex.tidyverse.org" rel="noreferrer">reprex package</a> (v0.2.1)</sup></p>
0debug
Resources containing OCR benchmark test-sets for free : <p>I want to do an OCR benchmark for scanned text (typically any scan, i.e. A4). I was able to find some NEOCR datasets <a href="http://datasets.visionbib.com/" rel="noreferrer">here</a>, but NEOCR is not really what I want.</p> <p>I would appreciate links to sources of free databases that have appropriate images and the actual texts (contained in the images) referenced.</p> <p>I hope this thread will also be useful for other people doing OCR surfing for datasets, since I didn't find any good reference to such sources.</p> <p>Thanks! </p>
0debug
Trying to create a sqlite table : <p>I have a database class in java where i'm trying to create a new table in sqlite. Tables get created when the app compiles but for some reason when i add a new line to add a new table it doesn't get created. My db class looks like this: </p> <pre><code>public static final String DATABASE_NAME = "something_db"; private Lock writeLock; private boolean locked; private DataBase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); writeLock = new ReentrantLock(); } @Override public void onCreate(SQLiteDatabase db) { onCreateV1(db); onCreateV2(db); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { if(oldVersion == 1 &amp;&amp; newVersion == 2) { onCreateV2(db); } } private void onCreateV1(SQLiteDatabase db) { db.execSQL("create table schedule (id integer, day integer, start text, end text, points double, unique(id) on conflict replace)"); db.execSQL("create table zone(id integer, name text, imageUrl text, imageFileName text, points double, unique(id) on conflict replace)"); db.execSQL("create table zoneLocation(zoneId integer, locationOrder integer, latitude double, longitude double, unique(zoneId, locationOrder) on conflict replace)"); db.execSQL("create table userLocation(id integer primary key, timestamp integer, latitude double, longitude double, speed double)"); db.execSQL("create table userPoint(id integer primary key, timestamp text, scheduleId integer, scheduleMultiplier double, speedRangeId integer, speedRangeMultiplier double, zoneId integer, zoneMultiplier double, latitude double, longitude double, total double, sent integer)"); db.execSQL("create table userTransaction(userId integer, date text, points double, unique(userId, date) on conflict replace)"); db.execSQL("create table speedRange(id integer, name text, lowerLimit double, points double, unique(id) on conflict replace)"); </code></pre> <p>I tried adding a new line to create a new table but every time i compile the app it tells me </p> <blockquote> <p>E/SQLiteLog: (1) no such table: UserTopChallengers</p> </blockquote> <p>Shouldn't just be adding the line along the others table being created should be enough? Why is the table i added not being created with the others. </p>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
uint64_t helper_fctiwz(CPUPPCState *env, uint64_t arg) { CPU_DoubleU farg; farg.ll = arg; if (unlikely(float64_is_signaling_nan(farg.d))) { farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); } else if (unlikely(float64_is_quiet_nan(farg.d) || float64_is_infinity(farg.d))) { farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI); } else { farg.ll = float64_to_int32_round_to_zero(farg.d, &env->fp_status); farg.ll |= 0xFFF80000ULL << 32; } return farg.ll; }
1threat
How to fix it **no crontab for root - using an empty one 888**? : <p>I want to set cron in ubuntu server,but when I run command crontab -e, I see this status or error. no crontab for root - using an empty one 888 How can I fix this.</p>
0debug
Hello guys i need help for a single SQL query to: : List the names of all students who are enrolled on the Computer Science and are doing the Database module. tables below.[Tables are in the image][1] [1]: https://i.stack.imgur.com/ATaIY.jpg
0debug
static void test_acpi_asl(test_data *data) { int i; AcpiSdtTable *sdt, *exp_sdt; test_data exp_data; gboolean exp_err, err; memset(&exp_data, 0, sizeof(exp_data)); exp_data.tables = load_expected_aml(data); dump_aml_files(data, false); for (i = 0; i < data->tables->len; ++i) { GString *asl, *exp_asl; sdt = &g_array_index(data->tables, AcpiSdtTable, i); exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i); err = load_asl(data->tables, sdt); asl = normalize_asl(sdt->asl); exp_err = load_asl(exp_data.tables, exp_sdt); exp_asl = normalize_asl(exp_sdt->asl); g_assert(!err || exp_err); if (g_strcmp0(asl->str, exp_asl->str)) { uint32_t signature = cpu_to_le32(exp_sdt->header.signature); sdt->tmp_files_retain = true; exp_sdt->tmp_files_retain = true; fprintf(stderr, "acpi-test: Warning! %.4s mismatch. " "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n", (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); } g_string_free(asl, true); g_string_free(exp_asl, true); } free_test_data(&exp_data); }
1threat
static int v4l2_set_parameters(AVFormatContext *s1) { struct video_data *s = s1->priv_data; struct v4l2_standard standard = { 0 }; struct v4l2_streamparm streamparm = { 0 }; struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; AVRational framerate_q = { 0 }; int i, ret; streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); return ret; } if (s->standard) { av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n", s->standard); for(i=0;;i++) { standard.index = i; ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) break; } if (ret < 0) { av_log(s1, AV_LOG_ERROR, "Unknown standard '%s'\n", s->standard); return ret; } av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n", s->standard, (uint64_t)standard.id); if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n", s->standard); return AVERROR(EIO); } } if (framerate_q.num && framerate_q.den) { av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", framerate_q.den, framerate_q.num); tpf->numerator = framerate_q.den; tpf->denominator = framerate_q.num; if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl set time per frame(%d/%d) failed\n", framerate_q.den, framerate_q.num); return AVERROR(EIO); } if (framerate_q.num != tpf->denominator || framerate_q.den != tpf->numerator) { av_log(s1, AV_LOG_INFO, "The driver changed the time per frame from " "%d/%d to %d/%d\n", framerate_q.den, framerate_q.num, tpf->numerator, tpf->denominator); } } else { if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno)); return AVERROR(errno); } } s1->streams[0]->avg_frame_rate.num = tpf->denominator; s1->streams[0]->avg_frame_rate.den = tpf->numerator; return 0; }
1threat
What's the difference between Variable and ResourceVariable in Tensorflow : <p>In tensorflow, Variable is a resource, inherited from ResourceBase and managed by ResourceMgr. But why there is another thing named ResourceVariable? Both of them can be used for optimizers like gradient_descent(see this <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/training/gradient_descent_test.py" rel="noreferrer">example</a>). What's the difference? I know the former one is well documented and most often used. What's the purpose of the later one?</p>
0debug
What does this code concerning sys.args mean? : <p>What does the following chunk of code mean? I don't understand the concept of sys.argv. I heard it has something to do with command-line prompts but my vocabulary isn't good enough to understand that. Also the output is strange. I don't understand how a list is pulled up nor how the elements get in there or even where they come from and what they mean. This is really confusing me, so help understanding it would be much appreciated. Please use beinner terms so I can understand it.</p> <pre><code>import sys print 'Number of arguments:', len(sys.argv), 'arguments.' print 'Argument List:', str(sys.argv) </code></pre>
0debug
Need helps whit sql querry : I have this data base. **Users**: Nick CodCountry BirthDate Chekov 1 2001-09-15 Kirk 1 1982-01-27 McCoy 3 2002-02-12 Scott 3 2001-03-31 Spock 2 2002-02-12 Sulu 4 1991-05-02 Uhura 2 1989-12-21 **Play**: Nick CodTrivia MoneyEarned Chekov 2 5 Kirk 1 500 Kirk 3 400 Kirk 4 200 Kirk 7 300 McCoy 2 15 McCoy 6 10 Scott 6 25 Spock 2 50 Spock 6 50 Sulu 1 200 Sulu 4 500 Sulu 7 500 Uhura 3 200 Uhura 7 0 and i need to : List the users who reached the end of more trivia without having lost. So far i have this: select * from usuario where nick in ( select nick from participa where MontoAcumulado>0 group by nick having count(nick) =(select top 1 count(nick))) But my mind go blank after that...can some one help me? Pd: it need to show Kirk because he win 4 time
0debug
PHP - How to detect second vowel and trim the word? : <p>How can I detect the second vowel of a given word with php and trim the word by following consonant? I tried with preg_match function but couldn't find a proper solution.</p> <pre><code>//given word $string = "engineering"; //output should be echo "engin"; </code></pre>
0debug
void scsi_req_cancel_async(SCSIRequest *req, Notifier *notifier) { trace_scsi_req_cancel(req->dev->id, req->lun, req->tag); if (notifier) { notifier_list_add(&req->cancel_notifiers, notifier); scsi_req_ref(req); scsi_req_dequeue(req); req->io_canceled = true; if (req->aiocb) { blk_aio_cancel_async(req->aiocb); } else { scsi_req_cancel_complete(req);
1threat
Keep getting "tsc.exe" exited with code 1 : <p>As soon as I add a tsconfig.json file to my Visual Studio 2015 web solution I get the above error. </p> <p>Also this stops the compiler from re-generating js files even when I set "compileOnSave": true.</p> <p>When I double click the error it takes me into the Microsoft.Typescript.Targets file which contains a lot of issues such as Unknown Item Group "TypeScriptCompile". In the error list these appear as warnings but they are there whether I have a tsconfig.json file or not.</p> <p>Is there any way of solving it or getting more information on what the problem is?</p>
0debug
ReferenceError: getElementsById is not defined why? : <p>I am trying to set a variable. </p> <pre><code>var fname = getElementsById(fname); </code></pre> <p>A function will then reference this variable on body load</p> <p>But the console returns ReferenceError: getElementsById is not defined</p> <p>Why?</p>
0debug
static inline void writer_print_string(WriterContext *wctx, const char *key, const char *val, int opt) { const struct section *section = wctx->section[wctx->level]; if (opt && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS)) return; if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) { wctx->writer->print_string(wctx, key, val); wctx->nb_item[wctx->level]++; } }
1threat
Android Studio 3.0 Flavor Dimension Issue : <p>Upgraded to Studio Canary build. My previous project of Telegram Messenger is giving following error.</p> <blockquote> <p>Error:All flavors must now belong to a named flavor dimension. The flavor 'armv7' is not assigned to a flavor dimension. Learn more at <a href="https://d.android.com/r/tools/flavorDimensions-missing-error-message.html" rel="noreferrer">https://d.android.com/r/tools/flavorDimensions-missing-error-message.html</a></p> </blockquote> <p>What should I do? I have already seen that link but couldn't understand what to do. I have 3 build variants now, release,debug and foss.</p>
0debug
yuv2rgb_2_c_template(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target, int hasAlpha) { int yalpha1 = 4095 - yalpha; int uvalpha1 = 4095 - uvalpha; int i; for (i = 0; i < (dstW >> 1); i++) { int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19; int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19; int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19; int A1, A2; const void *r = c->table_rV[V], *g = (c->table_gU[U] + c->table_gV[V]), *b = c->table_bU[U]; if (hasAlpha) { A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19; A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19; } yuv2rgb_write(dest, i, Y1, Y2, U, V, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0, r, g, b, y, target, hasAlpha); } }
1threat
Detect is child container at the bottom of the parent - jQuery : I have HTML like this: <div class="cont"> <!-- some elements --> <div class="child fixed">Child</div> </div> `child` is with position `fixed` (class `fixed`). Inside `cont` there are another elements, which make it with higher height than `child`. I have scroll event on document: $(document).scroll(function(e) { ... } I want when some1 scroll and child is at the bottom of `cont` to remove `fixed` class. How can I detect on scroll (`document` scroll) that some element is at the bottom of some parent element ?
0debug
PPC_OP(addze) { T1 = T0; T0 += xer_ca; if (T0 < T1) { xer_ca = 1; } else { xer_ca = 0; } RETURN(); }
1threat
Is there a way in pure javascript to get the input id with the max value within 4 input? : Javascript noob here :) I've got 4 inputs with number values. How can I find the input "id" with the max value, in order to manipulate the css of thi element? I'd like to code pure javascript... Thanks
0debug