problem
stringlengths
26
131k
labels
class label
2 classes
Laravel: Where selection for Eloquent Eager Loading relationship : <p>I got two DB tables:</p> <p><strong>Posts</strong></p> <pre><code>$table-&gt;increments('id'); $table-&gt;integer('country_id')-&gt;unsigned(); $table-&gt;foreign('country_id')-&gt;references('id')-&gt;on('countries'); </code></pre> <p><strong>Countries</strong> </p> <pre><code>$table-&gt;increments('id'); $table-&gt;string('name', 70); </code></pre> <p>I use laravel as back-end. Now I want to implement filtering data for my front-end. So the user can select a country name and laravel should answer the request only with posts that have a country with the specified name.</p> <p>How could I add this condition to my existing pagination query? I tried this:</p> <pre><code>$query = app(Post::class)-&gt;with('country')-&gt;newQuery(); // ... if ($request-&gt;exists('country')) { $query-&gt;where('country.name', $request-&gt;country); } // ... </code></pre> <p>... resulting in the following error:</p> <pre><code>Column not found: 1054 Unknown column 'country.name' in 'where clause' (SQL: select count(*) as aggregate from `posts` where `country`.`name` = Albania) </code></pre>
0debug
ngIf angular and getting rid of components in Angular 6 : <p>I am trying to get rid of my header and footer components in just one specific component and don't know how to go about it. I am treating the app component as the index.html component. When I create a new component, these are always there and I need to figure out how to make it so my new component is blank. </p>
0debug
Insufficient Memory error beng thrown : private void findManagerForSelectedDate(String dateSelected) { dateSelected = dateTimePicker1.Value.ToShortDateString(); List<String> managerNames = new List<String>(); foreach(var item in managers) { foreach (var subitem in item) { CalendarModel c = subitem; Console.WriteLine(c.date); c.name = new CultureInfo("en-US", false).TextInfo.ToTitleCase(c.name); if (userSelection.Count > 0) { foreach (var addedUser in userSelection.ToArray()) { if (!addedUser.Contains(c.name)) { userSelection.Add(c.name); } } } else { userSelection.Add(c.name); } } } Console.WriteLine(); } I keep running out of memory. managers contains 23 items item may have up to 3 entries (1 entry is a CalendarModel) I am expecting a very large number of entries to be in 'item' once the app is finished. I am also getting a ridiculous number of items in "userSelection" when it crashed. It was like 61K!!!
0debug
How to find the median for an array of numbers for java? : <pre><code>public double median(){ double input =0; double answer =sum() * (input) / data.length; return answer; } </code></pre> <p>This is my code I have for median but it keeps returning as zero when I run the program. The array of numbers are: {3.0, 15.0, 7.0, 27.0};</p>
0debug
how to define dynamic getelementbyid in code? : We can use this code to get id : document.getElementById("exampleid").value = 1; and for example page code is <input id="exampleid" value="" /> but we cannot use high code for this once . because id is different . <input id="exampleid2" value="" /> and we should change our code to document.getElementById("exampleid2").value = 1; now , how can we define dynamic id ? like : document.getElementById('/^exampleid/').value = 1; note , We do not want every time Change the code when html id changed .
0debug
Cywin64 - command not working as expected : The following command string will working fine in Cygwin32 but no longer works under Cygwin64. Does anyone have a clue why? All packages are installed as expected. $svn status | sort | cut -c2- | xargs cksum : No such file or directory I am running on Windows 7 x64 Thank you. Amad
0debug
How to use & after const string in c++ : virtual const string & getType() const = 0; What does & mean after const string? I am a newbie and trying to understand how basic c++ works.
0debug
document.write('<script src="evil.js"></script>');
1threat
static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int pitch, const uint8_t *table) { int j; int out = 0; int c; int t; if (width & 1) for (j = 0; j < height; j++) { out = 0; while (out < width) { c = ir2_get_code(&ctx->gb); if (c >= 0x80) { c -= 0x7F; out += c * 2; } else { t = dst[out] + (((table[c * 2] - 128)*3) >> 2); t = av_clip_uint8(t); dst[out] = t; out++; t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); t = av_clip_uint8(t); dst[out] = t; out++; } } dst += pitch; } return 0; }
1threat
Why redux store should be serializable? : <p>When reading the redux doc I found that the doc mentioned this:</p> <blockquote> <p>Still, you should do your best to keep the state serializable. Don't put anything inside it that you can't easily turn into JSON.</p> </blockquote> <p>So my question is, what's the benefit of keeping state serializable? Or, what difficulties I may have if I put non-serializable data into store?</p> <p>And I believe this is not unique to redux - Flux, even React local state suggest the same thing.</p> <hr> <p>To make me clear here is an example. Suppose the store structure is like this.</p> <pre><code>{ books: { 1: { id: 1, name: "Book 1", author_id: 4 } }, authors: { 4: { id: 4, name: "Author 4" } } } </code></pre> <p>This should all looks good. However when I try to access "the author of Book 1", I have to write code like this:</p> <pre><code>let book = store.getState().books[book_id]; let author = store.getState().authors[book.author_id]; </code></pre> <p>Now, I'm going to define a class:</p> <pre><code>class Book { getAuthor() { return store.getState().authors[this.author_id]; } } </code></pre> <p>And my store will be:</p> <pre><code>{ books: { 1: Book(id=1, name="Book 1") }, ... } </code></pre> <p>So that I can get the author easily by using:</p> <pre><code>let author = store.getState().books[book_id].getAuthor(); </code></pre> <p>The 2nd approach could make the "book" object aware of how to retrieve the author data, so the caller does not need to know the relation between books and authors. Then, why we are not using it, instead of keeping "plain object" in the store just as approach #1?</p> <p>Any ideas are appreciated.</p>
0debug
YouTube video playback stopped due to unauthorized overlay on top of player.getting error : I have trouble using the YouTubePlayerSupportFragment inside a (Support)ViewPager. Everything works fine except when i come resume method youtube player playing few seconds, and then it will be paused. getting error .. My Layout.. <?xml version="1.0" encoding="utf-8"?> <LinearLayout ..> .. <FrameLayout android:id="@+id/youtube_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" /> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipeRefreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" > <android.support.v7.widget.RecyclerView android:id="@+id/recyclerCardList" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:divider="@color/colorPrimaryDark" android:dividerHeight="8dp" android:scrollbars="vertical" /> </android.support.v4.widget.SwipeRefreshLayout> </LinearLayout> </LinearLayout> My Code : private void setYoutubePlayer() { YouTubePlayerSupportFragment youTubePlayerFragment = YouTubePlayerSupportFragment.newInstance(); FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.add(R.id.youtube_layout, youTubePlayerFragment) .addToBackStack(youTubePlayerFragment.getClass().getName()).commitAllowingStateLoss(); youTubePlayerFragment.initialize(Config.DEVELOPER_KEY, new OnInitializedListener() { @Override public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) { if (!wasRestored) { player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT); player.loadVideo(Config.YOUTUBE_VIDEO_CODE); player.play(); } } @Override public void onInitializationFailure(Provider provider, YouTubeInitializationResult error) { // YouTube error String errorMessage = error.toString(); Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show(); Log.d("errorMessage:", errorMessage); } }); } Kindly help me as soon as possible.
0debug
How to get android actionbar back button width programatically? : I am setting toolbar to my actionbar,but I have activities when I disable home button and the title in toolbar is not centrilized so I would like to get actionbar back button with programtically to set `toolbar.setContentInsetsAbsolute(0, 0);`
0debug
python text.count do no return the correct number of occurences : <p>I have a question regarding the text.count() function in python. Suppose I have the following text and I want to return the number of occurrences of "CCC":</p> <pre><code>text = "ACCCGTTGCCCC" print text.count("CCC") </code></pre> <p>why it returns 2 and not 3?</p>
0debug
static int test_vector_fmul_add(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const float *v1, const float *v2, const float *v3) { LOCAL_ALIGNED(32, float, cdst, [LEN]); LOCAL_ALIGNED(32, float, odst, [LEN]); int ret; cdsp->vector_fmul_add(cdst, v1, v2, v3, LEN); fdsp->vector_fmul_add(odst, v1, v2, v3, LEN); if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST)) av_log(NULL, AV_LOG_ERROR, "vector_fmul_add failed\n"); return ret; }
1threat
static inline void downmix_3f_1r_to_stereo(float *samples) { int i; for (i = 0; i < 256; i++) { samples[i] += (samples[i + 256] + samples[i + 768]); samples[i + 256] += (samples[i + 512] + samples[i + 768]); samples[i + 512] = samples[i + 768] = 0; } }
1threat
I dont want the users to log in two times from Wordpress and cakephp : <p>im developing a webapp using cakephp and i want to merge it with WordPress ,is there any solution that user will only login once (i dont want the users to log in two times.)</p>
0debug
static void encode_gray_bitstream(HYuvContext *s, int count){ int i; count/=2; if(s->flags&CODEC_FLAG_PASS1){ for(i=0; i<count; i++){ s->stats[0][ s->temp[0][2*i ] ]++; s->stats[0][ s->temp[0][2*i+1] ]++; } }else if(s->context){ for(i=0; i<count; i++){ s->stats[0][ s->temp[0][2*i ] ]++; put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]); s->stats[0][ s->temp[0][2*i+1] ]++; put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]); } }else{ for(i=0; i<count; i++){ put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]); put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]); } } }
1threat
static void ide_resize_cb(void *opaque) { IDEState *s = opaque; uint64_t nb_sectors; if (!s->identify_set) { return; } bdrv_get_geometry(s->bs, &nb_sectors); s->nb_sectors = nb_sectors; if (s->drive_kind == IDE_CFATA) { ide_cfata_identify_size(s); } else { assert(s->drive_kind != IDE_CD); ide_identify_size(s); } }
1threat
React Native: JAVA_HOME is not set and no 'java' command could be found in your PATH : <p>I've followed step by step the official <a href="https://facebook.github.io/react-native/docs/getting-started.html" rel="noreferrer">Getting Started</a>. I started from a clean linux install and installed everything required as per the "Building Projects with Native Code" tab. I have also read the troubleshooting section. I've already created the project using the terminal.</p> <p>This is the error when I run <code>react-native run-android</code>:</p> <pre><code> Starting JS server... Building and installing the app on the device (cd android &amp;&amp; ./gradlew installDebug)... ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation. Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html </code></pre> <p>It does not find JAVA_HOME because the latest versions of Android Studio don't require Java to be installed in the system. Instead an internal JRE is used. </p> <p><strong>Duplicate disclaimer</strong>: I've already read <a href="https://stackoverflow.com/questions/34375542/error-java-home-is-not-set-and-no-java-command-could-be-found-in-your-path">this question</a>. This is not what I want. I know how to set the Java home. I just want to run the react project WITHOUT having to install a separate Java.</p> <p>Questions:</p> <ol> <li>How could I find the internal Java inside the Android Studio folder so that I could point JAVA_HOME to it?</li> <li>If not possible, could I open and run the project inside the <code>android</code> folder with Android Studio? How would I refresh this project after modifying the React JavaScript code in the parent folder?</li> </ol>
0debug
static void buffer_append(Buffer *buffer, const void *data, size_t len) { memcpy(buffer->buffer + buffer->offset, data, len); buffer->offset += len; }
1threat
def count_range_in_list(li, min, max): ctr = 0 for x in li: if min <= x <= max: ctr += 1 return ctr
0debug
If it is possible to focus the hidden input field : How to trigger the hidden input field when we click the parent element.When i use the hidden field is not worked. here is my html code: <table> <th colspan="2">Date</th> <td id="dateContainer" > currentData </td> <td><input id="thedate" type="text" type="hidden" /></td> <table> jquery code: $(function(){ $(this).click(function() { $(this).children().children().find('.datepicker-input').focus(); }); });
0debug
Flutter: animate item removal in ListView : <p>I am building a ListView from a Stream. I need to animate deletions and insertions to that list, but have no idea how.</p> <p>I have seen this sample by Flutter but it is not related to streams in any way: <a href="https://flutter.io/catalog/samples/animated-list/" rel="noreferrer">https://flutter.io/catalog/samples/animated-list/</a></p> <p>Any help greatly appreciated :)</p> <pre><code>new StreamBuilder( stream: feed.stream, // this is a Stream&lt;List&lt;Product&gt;&gt; builder: (context, snapshot) { if (!snapshot.hasData) return const Text('Loading products'); return new ListView.builder( itemCount: snapshot.data.length, itemBuilder: (context, index) { Product product = snapshot.data[index]; return new ProductWidget(product); }); }); </code></pre>
0debug
static void decode_format80(const unsigned char *src, int src_size, unsigned char *dest, int dest_size, int check_size) { int src_index = 0; int dest_index = 0; int count; int src_pos; unsigned char color; int i; while (src_index < src_size) { av_dlog(NULL, " opcode %02X: ", src[src_index]); if (src[src_index] == 0x80) if (dest_index >= dest_size) { av_log(NULL, AV_LOG_ERROR, " VQA video: decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n", dest_index, dest_size); } if (src[src_index] == 0xFF) { src_index++; count = AV_RL16(&src[src_index]); src_index += 2; src_pos = AV_RL16(&src[src_index]); src_index += 2; av_dlog(NULL, "(1) copy %X bytes from absolute pos %X\n", count, src_pos); CHECK_COUNT(); if (src_pos + count > dest_size) for (i = 0; i < count; i++) dest[dest_index + i] = dest[src_pos + i]; dest_index += count; } else if (src[src_index] == 0xFE) { src_index++; count = AV_RL16(&src[src_index]); src_index += 2; color = src[src_index++]; av_dlog(NULL, "(2) set %X bytes to %02X\n", count, color); CHECK_COUNT(); memset(&dest[dest_index], color, count); dest_index += count; } else if ((src[src_index] & 0xC0) == 0xC0) { count = (src[src_index++] & 0x3F) + 3; src_pos = AV_RL16(&src[src_index]); src_index += 2; av_dlog(NULL, "(3) copy %X bytes from absolute pos %X\n", count, src_pos); CHECK_COUNT(); if (src_pos + count > dest_size) for (i = 0; i < count; i++) dest[dest_index + i] = dest[src_pos + i]; dest_index += count; } else if (src[src_index] > 0x80) { count = src[src_index++] & 0x3F; av_dlog(NULL, "(4) copy %X bytes from source to dest\n", count); CHECK_COUNT(); memcpy(&dest[dest_index], &src[src_index], count); src_index += count; dest_index += count; } else { count = ((src[src_index] & 0x70) >> 4) + 3; src_pos = AV_RB16(&src[src_index]) & 0x0FFF; src_index += 2; av_dlog(NULL, "(5) copy %X bytes from relpos %X\n", count, src_pos); CHECK_COUNT(); for (i = 0; i < count; i++) dest[dest_index + i] = dest[dest_index - src_pos + i]; dest_index += count; } } if (check_size) if (dest_index < dest_size) av_log(NULL, AV_LOG_ERROR, " VQA video: decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n", dest_index, dest_size); }
1threat
how to allow use of a specific character - REGEX : <p>I'm actually using this code to check if my string have any special characters:</p> <pre><code>var regex = /[^\w\s!?]/g; if (regex.test(message)) { notify('error', 'Special characters are not allowed!'); return; } </code></pre> <p>but I want to allow '/' too.</p>
0debug
static void tcg_out_op (TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args) { int c; switch (opc) { case INDEX_op_exit_tb: tcg_out_movi (s, TCG_TYPE_I64, TCG_REG_R3, args[0]); tcg_out_b (s, 0, (tcg_target_long) tb_ret_addr); break; case INDEX_op_goto_tb: if (s->tb_jmp_offset) { s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; s->code_ptr += 28; } else { tcg_abort (); } s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; break; case INDEX_op_br: { TCGLabel *l = &s->labels[args[0]]; if (l->has_value) { tcg_out_b (s, 0, l->u.value); } else { uint32_t val = *(uint32_t *) s->code_ptr; tcg_out32 (s, B | (val & 0x3fffffc)); tcg_out_reloc (s, s->code_ptr - 4, R_PPC_REL24, args[0], 0); } } break; case INDEX_op_call: tcg_out_call (s, args[0], const_args[0]); break; case INDEX_op_jmp: if (const_args[0]) { tcg_out_b (s, 0, args[0]); } else { tcg_out32 (s, MTSPR | RS (args[0]) | CTR); tcg_out32 (s, BCCTR | BO_ALWAYS); } break; case INDEX_op_movi_i32: tcg_out_movi (s, TCG_TYPE_I32, args[0], args[1]); break; case INDEX_op_movi_i64: tcg_out_movi (s, TCG_TYPE_I64, args[0], args[1]); break; case INDEX_op_ld8u_i32: case INDEX_op_ld8u_i64: tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX); break; case INDEX_op_ld8s_i32: case INDEX_op_ld8s_i64: tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX); tcg_out32 (s, EXTSB | RS (args[0]) | RA (args[0])); break; case INDEX_op_ld16u_i32: case INDEX_op_ld16u_i64: tcg_out_ldst (s, args[0], args[1], args[2], LHZ, LHZX); break; case INDEX_op_ld16s_i32: case INDEX_op_ld16s_i64: tcg_out_ldst (s, args[0], args[1], args[2], LHA, LHAX); break; case INDEX_op_ld_i32: case INDEX_op_ld32u_i64: tcg_out_ldst (s, args[0], args[1], args[2], LWZ, LWZX); break; case INDEX_op_ld32s_i64: tcg_out_ldsta (s, args[0], args[1], args[2], LWA, LWAX); break; case INDEX_op_ld_i64: tcg_out_ldsta (s, args[0], args[1], args[2], LD, LDX); break; case INDEX_op_st8_i32: case INDEX_op_st8_i64: tcg_out_ldst (s, args[0], args[1], args[2], STB, STBX); break; case INDEX_op_st16_i32: case INDEX_op_st16_i64: tcg_out_ldst (s, args[0], args[1], args[2], STH, STHX); break; case INDEX_op_st_i32: case INDEX_op_st32_i64: tcg_out_ldst (s, args[0], args[1], args[2], STW, STWX); break; case INDEX_op_st_i64: tcg_out_ldsta (s, args[0], args[1], args[2], STD, STDX); break; case INDEX_op_add_i32: if (const_args[2]) ppc_addi32 (s, args[0], args[1], args[2]); else tcg_out32 (s, ADD | TAB (args[0], args[1], args[2])); break; case INDEX_op_sub_i32: if (const_args[2]) ppc_addi32 (s, args[0], args[1], -args[2]); else tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1])); break; case INDEX_op_and_i64: case INDEX_op_and_i32: if (const_args[2]) { if ((args[2] & 0xffff) == args[2]) tcg_out32 (s, ANDI | RS (args[1]) | RA (args[0]) | args[2]); else if ((args[2] & 0xffff0000) == args[2]) tcg_out32 (s, ANDIS | RS (args[1]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); else { tcg_out_movi (s, (opc == INDEX_op_and_i32 ? TCG_TYPE_I32 : TCG_TYPE_I64), 0, args[2]); tcg_out32 (s, AND | SAB (args[1], args[0], 0)); } } else tcg_out32 (s, AND | SAB (args[1], args[0], args[2])); break; case INDEX_op_or_i64: case INDEX_op_or_i32: if (const_args[2]) { if (args[2] & 0xffff) { tcg_out32 (s, ORI | RS (args[1]) | RA (args[0]) | (args[2] & 0xffff)); if (args[2] >> 16) tcg_out32 (s, ORIS | RS (args[0]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); } else { tcg_out32 (s, ORIS | RS (args[1]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); } } else tcg_out32 (s, OR | SAB (args[1], args[0], args[2])); break; case INDEX_op_xor_i64: case INDEX_op_xor_i32: if (const_args[2]) { if ((args[2] & 0xffff) == args[2]) tcg_out32 (s, XORI | RS (args[1]) | RA (args[0]) | (args[2] & 0xffff)); else if ((args[2] & 0xffff0000) == args[2]) tcg_out32 (s, XORIS | RS (args[1]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); else { tcg_out_movi (s, (opc == INDEX_op_and_i32 ? TCG_TYPE_I32 : TCG_TYPE_I64), 0, args[2]); tcg_out32 (s, XOR | SAB (args[1], args[0], 0)); } } else tcg_out32 (s, XOR | SAB (args[1], args[0], args[2])); break; case INDEX_op_mul_i32: if (const_args[2]) { if (args[2] == (int16_t) args[2]) tcg_out32 (s, MULLI | RT (args[0]) | RA (args[1]) | (args[2] & 0xffff)); else { tcg_out_movi (s, TCG_TYPE_I32, 0, args[2]); tcg_out32 (s, MULLW | TAB (args[0], args[1], 0)); } } else tcg_out32 (s, MULLW | TAB (args[0], args[1], args[2])); break; case INDEX_op_div_i32: tcg_out32 (s, DIVW | TAB (args[0], args[1], args[2])); break; case INDEX_op_divu_i32: tcg_out32 (s, DIVWU | TAB (args[0], args[1], args[2])); break; case INDEX_op_rem_i32: tcg_out32 (s, DIVW | TAB (0, args[1], args[2])); tcg_out32 (s, MULLW | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_remu_i32: tcg_out32 (s, DIVWU | TAB (0, args[1], args[2])); tcg_out32 (s, MULLW | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_shl_i32: if (const_args[2]) { tcg_out32 (s, (RLWINM | RA (args[0]) | RS (args[1]) | SH (args[2]) | MB (0) | ME (31 - args[2]) ) ); } else tcg_out32 (s, SLW | SAB (args[1], args[0], args[2])); break; case INDEX_op_shr_i32: if (const_args[2]) { tcg_out32 (s, (RLWINM | RA (args[0]) | RS (args[1]) | SH (32 - args[2]) | MB (args[2]) | ME (31) ) ); } else tcg_out32 (s, SRW | SAB (args[1], args[0], args[2])); break; case INDEX_op_sar_i32: if (const_args[2]) tcg_out32 (s, SRAWI | RS (args[1]) | RA (args[0]) | SH (args[2])); else tcg_out32 (s, SRAW | SAB (args[1], args[0], args[2])); break; case INDEX_op_brcond_i32: tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 0); break; case INDEX_op_brcond_i64: tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 1); break; case INDEX_op_neg_i32: case INDEX_op_neg_i64: tcg_out32 (s, NEG | RT (args[0]) | RA (args[1])); break; case INDEX_op_not_i32: case INDEX_op_not_i64: tcg_out32 (s, NOR | SAB (args[1], args[0], args[1])); break; case INDEX_op_add_i64: if (const_args[2]) ppc_addi64 (s, args[0], args[1], args[2]); else tcg_out32 (s, ADD | TAB (args[0], args[1], args[2])); break; case INDEX_op_sub_i64: if (const_args[2]) ppc_addi64 (s, args[0], args[1], -args[2]); else tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1])); break; case INDEX_op_shl_i64: if (const_args[2]) tcg_out_rld (s, RLDICR, args[0], args[1], args[2], 63 - args[2]); else tcg_out32 (s, SLD | SAB (args[1], args[0], args[2])); break; case INDEX_op_shr_i64: if (const_args[2]) tcg_out_rld (s, RLDICL, args[0], args[1], 64 - args[2], args[2]); else tcg_out32 (s, SRD | SAB (args[1], args[0], args[2])); break; case INDEX_op_sar_i64: if (const_args[2]) { int sh = SH (args[2] & 0x1f) | (((args[2] >> 5) & 1) << 1); tcg_out32 (s, SRADI | RA (args[0]) | RS (args[1]) | sh); } else tcg_out32 (s, SRAD | SAB (args[1], args[0], args[2])); break; case INDEX_op_mul_i64: tcg_out32 (s, MULLD | TAB (args[0], args[1], args[2])); break; case INDEX_op_div_i64: tcg_out32 (s, DIVD | TAB (args[0], args[1], args[2])); break; case INDEX_op_divu_i64: tcg_out32 (s, DIVDU | TAB (args[0], args[1], args[2])); break; case INDEX_op_rem_i64: tcg_out32 (s, DIVD | TAB (0, args[1], args[2])); tcg_out32 (s, MULLD | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_remu_i64: tcg_out32 (s, DIVDU | TAB (0, args[1], args[2])); tcg_out32 (s, MULLD | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_qemu_ld8u: tcg_out_qemu_ld (s, args, 0); break; case INDEX_op_qemu_ld8s: tcg_out_qemu_ld (s, args, 0 | 4); break; case INDEX_op_qemu_ld16u: tcg_out_qemu_ld (s, args, 1); break; case INDEX_op_qemu_ld16s: tcg_out_qemu_ld (s, args, 1 | 4); break; case INDEX_op_qemu_ld32: case INDEX_op_qemu_ld32u: tcg_out_qemu_ld (s, args, 2); break; case INDEX_op_qemu_ld32s: tcg_out_qemu_ld (s, args, 2 | 4); break; case INDEX_op_qemu_ld64: tcg_out_qemu_ld (s, args, 3); break; case INDEX_op_qemu_st8: tcg_out_qemu_st (s, args, 0); break; case INDEX_op_qemu_st16: tcg_out_qemu_st (s, args, 1); break; case INDEX_op_qemu_st32: tcg_out_qemu_st (s, args, 2); break; case INDEX_op_qemu_st64: tcg_out_qemu_st (s, args, 3); break; case INDEX_op_ext8s_i32: case INDEX_op_ext8s_i64: c = EXTSB; goto gen_ext; case INDEX_op_ext16s_i32: case INDEX_op_ext16s_i64: c = EXTSH; goto gen_ext; case INDEX_op_ext32s_i64: c = EXTSW; goto gen_ext; gen_ext: tcg_out32 (s, c | RS (args[1]) | RA (args[0])); break; case INDEX_op_ext32u_i64: tcg_out_rld (s, RLDICR, args[0], args[1], 0, 32); break; case INDEX_op_setcond_i32: tcg_out_setcond (s, TCG_TYPE_I32, args[3], args[0], args[1], args[2], const_args[2]); break; case INDEX_op_setcond_i64: tcg_out_setcond (s, TCG_TYPE_I64, args[3], args[0], args[1], args[2], const_args[2]); break; default: tcg_dump_ops (s, stderr); tcg_abort (); } }
1threat
How to replace string to anther string which can back to original using c# : I want to replace string to anther string which can back to original using c# For example If I entered > "XcXa$2A" then clicked on button, Output will be the following string: > "t6tYQA*" That's because for my example X replaced by t c replaced by 6 a replaced by Y A replaced by * $ replaced by Q 2 replaced by A And Also the output string can be back to the original string from another button "t6tYQA*" can be back to original "XcXa$2A" So I need all characters in keyboard can be replaced to another and output can be back to original Thanks in advance. I need that for secure all my string and don't need to use encrypt and decrypt.
0debug
can anyone share experience find max date using jquery : how to get max date dates = [2016/11/10,2016/11/20,2016/11/30] here is code =============== var maxDate = new Date(Math.max.apply(null, dates)); but it is returning invalid date can anyine share any idea to find the maximum date
0debug
static uint64_t ahci_alloc(AHCIQState *ahci, size_t bytes) { return qmalloc(ahci->parent, bytes); }
1threat
static void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename) { GList *l; for (l = global_props; l; l = l->next) { GlobalProperty *prop = l->data; Error *err = NULL; if (strcmp(typename, prop->driver) != 0) { continue; } prop->used = true; object_property_parse(OBJECT(dev), prop->value, prop->property, &err); if (err != NULL) { error_prepend(&err, "can't apply global %s.%s=%s: ", prop->driver, prop->property, prop->value); if (!dev->hotplugged && prop->errp) { error_propagate(prop->errp, err); } else { assert(prop->user_provided); warn_report_err(err); } } } }
1threat
Dynamic certificate pinning : <p>I have an iOS application that will be distributed to multiple customers, each using their own network infrastructure. I would like to add some certificate pinning capabilities, but I need to do it in a dynamic fashion since I cannot ship the app with the cert/pubkey bundled, as doing so would require a different build for each customer.</p> <p>My idea is to query the per-client configured HTTPS server on app startup, get the certificate, potentially extract the public key and then pin it.</p> <p>Is it possible to do this in Swift or Objective-C? I have not been able to find relevant code samples or documentation.</p>
0debug
static inline void gen_evmwumia(DisasContext *ctx) { TCGv_i64 tmp; if (unlikely(!ctx->spe_enabled)) { gen_exception(ctx, POWERPC_EXCP_APU); return; } gen_evmwumi(ctx); tmp = tcg_temp_new_i64(); gen_load_gpr64(tmp, rD(ctx->opcode)); tcg_gen_st_i64(tmp, cpu_env, offsetof(CPUState, spe_acc)); tcg_temp_free_i64(tmp); }
1threat
static void gen_spr_power8_tce_address_control(CPUPPCState *env) { spr_register(env, SPR_TAR, "TAR", &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); }
1threat
Can I create multiple canvas elements on same page using p5js : <p>I tried using p5js to draw some points it does work well but I also wanted another canvas element which can show the live video from camera. When I added another canvas element the first canvas goes blank. For now I tried using multiple javascript files to process different canvas.</p> <p>camera.js</p> <pre><code>var capture; function setup() { var video=createCanvas(390, 240); capture = createCapture(VIDEO); capture.size(320, 240); capture.hide(); //set parent to div with id left video.parent("left"); } function draw() { background(255); image(capture, 0, 0, 320, 240); filter('INVERT'); } </code></pre> <p>drawshapes.js</p> <pre><code>function setup() { // Create the canvas var plot=createCanvas(720, 400); background(200); //set parent to div with id right plot.parent("right"); // Set colors fill(204, 101, 192, 127); stroke(127, 63, 120); // A rectangle rect(40, 120, 120, 40); // An ellipse ellipse(240, 240, 80, 80); // A triangle triangle(300, 100, 320, 100, 310, 80); // A design for a simple flower translate(580, 200); noStroke(); for (var i = 0; i &lt; 10; i ++) { ellipse(0, 30, 20, 80); rotate(PI/5); } } </code></pre> <p>index.html</p> <pre><code>&lt;div class="container"&gt; &lt;div id="left"&gt;&lt;/div&gt; &lt;div id="right"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
0debug
static int vhost_sync_dirty_bitmap(struct vhost_dev *dev, MemoryRegionSection *section, hwaddr start_addr, hwaddr end_addr) { int i; if (!dev->log_enabled || !dev->started) { return 0; } for (i = 0; i < dev->mem->nregions; ++i) { struct vhost_memory_region *reg = dev->mem->regions + i; vhost_dev_sync_region(dev, section, start_addr, end_addr, reg->guest_phys_addr, range_get_last(reg->guest_phys_addr, reg->memory_size)); } for (i = 0; i < dev->nvqs; ++i) { struct vhost_virtqueue *vq = dev->vqs + i; vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys, range_get_last(vq->used_phys, vq->used_size)); } return 0; }
1threat
Convert casual language to date : <p>I'm looking for a library for .NET which will take a date string like "two hours ago" or "3", meaning today at 3PM, and convert it to an actual date. <a href="https://github.com/Humanizr/Humanizer#humanize-datetime" rel="nofollow noreferrer">Humanizer</a> seems to do the opposite, taking a date and converting it to a more human-readable date, but I can't find anything that does it this way round. Any suggestions?</p>
0debug
static void virtio_scsi_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSCSI *s = VIRTIO_SCSI(dev); static int virtio_scsi_id; Error *err = NULL; virtio_scsi_common_realize(dev, &err); if (err != NULL) { error_propagate(errp, err); return; } scsi_bus_new(&s->bus, sizeof(s->bus), dev, &virtio_scsi_scsi_info, vdev->bus_name); if (!dev->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus, &err); if (err != NULL) { error_propagate(errp, err); return; } } register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1, virtio_scsi_save, virtio_scsi_load, s); }
1threat
static VirtIOSerialBus *virtser_bus_new(DeviceState *dev) { VirtIOSerialBus *bus; bus = FROM_QBUS(VirtIOSerialBus, qbus_create(&virtser_bus_info, dev, NULL)); bus->qbus.allow_hotplug = 1; return bus; }
1threat
int kvm_arch_init_vcpu(CPUX86State *env) { struct { struct kvm_cpuid2 cpuid; struct kvm_cpuid_entry2 entries[100]; } QEMU_PACKED cpuid_data; KVMState *s = env->kvm_state; uint32_t limit, i, j, cpuid_i; uint32_t unused; struct kvm_cpuid_entry2 *c; uint32_t signature[3]; int r; env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); j = env->cpuid_ext_features & CPUID_EXT_TSC_DEADLINE_TIMER; env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX); if (j && kvm_irqchip_in_kernel() && kvm_check_extension(s, KVM_CAP_TSC_DEADLINE_TIMER)) { env->cpuid_ext_features |= CPUID_EXT_TSC_DEADLINE_TIMER; } env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_EDX); env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_ECX); env->cpuid_svm_features &= kvm_arch_get_supported_cpuid(s, 0x8000000A, 0, R_EDX); cpuid_i = 0; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = KVM_CPUID_SIGNATURE; if (!hyperv_enabled()) { 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->cpuid_kvm_features & kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX); if (hyperv_enabled()) { 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 (hyperv_relaxed_timing_enabled()) { c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE; } if (hyperv_vapic_recommended()) { 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 (hyperv_relaxed_timing_enabled()) { c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED; } if (hyperv_vapic_recommended()) { c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED; } c->ebx = hyperv_get_spinlock_retries(); 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); cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); for (i = 0; i <= limit; i++) { 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) { 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; } 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; } } cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused); for (i = 0x80000000; i <= limit; i++) { 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) { env->cpuid_ext4_features &= kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX); cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused); for (i = 0xC0000000; i <= limit; i++) { 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->cpuid_features&(CPUID_MCE|CPUID_MCA)) == (CPUID_MCE|CPUID_MCA) && kvm_check_extension(env->kvm_state, KVM_CAP_MCE) > 0) { uint64_t mcg_cap; int banks; int ret; ret = kvm_get_mce_cap_supported(env->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(env, 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); cpuid_data.cpuid.padding = 0; r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); if (r) { return r; } r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL); if (r && env->tsc_khz) { r = kvm_vcpu_ioctl(env, 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
How do I sum across certain columns? : <p>I have a data frame called <code>df</code> that looks like this:</p> <pre><code>name score1 score2 score3 Joe 1 NA 3 Jane NA 2 3 </code></pre> <p>How do I make a column named <code>sum</code> that sums non-empty cells in <code>score1</code>, <code>score2</code> and <code>score3</code>?</p>
0debug
void isa_ne2000_init(int base, int irq, NICInfo *nd) { ISADevice *dev; qemu_check_nic_model(nd, "ne2k_isa"); dev = isa_create("ne2k_isa"); dev->qdev.nd = nd; qdev_prop_set_uint32(&dev->qdev, "iobase", base); qdev_prop_set_uint32(&dev->qdev, "irq", irq); qdev_init(&dev->qdev); }
1threat
void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp) { int64_t value; if (!error_is_set(errp)) { if (v->type_uint8) { v->type_uint8(v, obj, name, errp); } else { value = *obj; v->type_int(v, &value, name, errp); if (value < 0 || value > UINT8_MAX) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", "uint8_t"); return; } *obj = value; } } }
1threat
How to share my app developed in android studio : I made an app in Android Studio and I built it and developed an apk which is stored in debug folder so I copied that apk in my phone and installed it ,it is working good in my phone and I am able to share it too ..I tried through Xender and tried to install it on my friend's phone ,app was installed but it was not working ..can anyone help me with this..Thanks in advance!
0debug
Should I create a module per component in Angular 4+ app? : <p>We have a medium sized Angular 4 application (+-150 components).</p> <p>Many of these components require the injection of service classes and require the declaration of other components in the app.</p> <p>An approach we have been experimenting with, and have found to be much more developer friendly, is to create a module per component. The module imports the child component modules and provides (or imports) all the services needed by the component. It also exports the component itself so that other components can reference it through the module.</p> <p>It makes the composition of components a breeze and the setup of the test fixture of a component very simple (this is where there was previously a lot of repetition of dependencies and child component tree dependencies).<br> This approach seems to match the component based architecture and allows for a form of encapsulation around what a components dependencies are.<br> It feels just too good to be true ;)</p> <p>My question is, what is the performance (or other) impact of having so many modules?</p>
0debug
Stopwatch and ReadKey doesn't work properly : I'm working on my multi threading password cracker, only numbers. It must show the how much time has passed to find the password. I used Stopwatch to find it, but in functions, stopwatch doesn't works.. here is my code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Diagnostics; using System.Threading; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { int psw = 14995399; Stopwatch time = new Stopwatch(); Thread Thread1 = new Thread(islem1); Thread Thread2 = new Thread(islem2); Thread Thread3 = new Thread(islem3); Thread Thread4 = new Thread(islem4); time.Start(); Thread1.Start(); Thread2.Start(); Thread3.Start(); Thread4.Start(); Thread.Sleep(1000); time.Stop(); System.Console.WriteLine("Time elapsed: {0}", time.Elapsed); Console.ReadKey(); } static void islem1() { for (int i = 00000000; i < 25000000; i++) { int psw = 14995399; if (i == psw) { System.Console.WriteLine("Şifre=" + i); time.Stop(); Console.WriteLine("Time elapsed: {0}", time.Elapsed); Console.ReadKey(); } } } static void islem2() { for (int i = 25000000; i < 50000000; i++) { int psw = 14995399; if (i == psw) { System.Console.WriteLine("Şifre=" + i); time.Stop(); Console.WriteLine("Time elapsed: {0}", time.Elapsed); Console.ReadKey(); } } } static void islem3() { for (int i = 50000000; i < 75000000; i++) { int psw = 14995399; if (i == psw) { System.Console.WriteLine("Şifre=" + i); time.Stop(); Console.WriteLine("Time elapsed: {0}", time.Elapsed); Console.ReadKey(); } } } static void islem4() { for (int i = 75000000; i < 100000000; i++) { int psw = 14995399; if (i == psw) { System.Console.WriteLine("Şifre=" + i); time.Stop(); Console.WriteLine("Time elapsed: {0}", time.Elapsed); Console.ReadKey(); } } } } }
0debug
sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn, size_t window_size) { sPAPRTCETable *tcet; if (spapr_tce_find_by_liobn(liobn)) { fprintf(stderr, "Attempted to create TCE table with duplicate" " LIOBN 0x%x\n", liobn); return NULL; } if (!window_size) { return NULL; } tcet = g_malloc0(sizeof(*tcet)); tcet->liobn = liobn; tcet->window_size = window_size; if (kvm_enabled()) { tcet->table = kvmppc_create_spapr_tce(liobn, window_size, &tcet->fd); } if (!tcet->table) { size_t table_size = (window_size >> SPAPR_TCE_PAGE_SHIFT) * sizeof(sPAPRTCE); tcet->table = g_malloc0(table_size); } #ifdef DEBUG_TCE fprintf(stderr, "spapr_iommu: New TCE table @ %p, liobn=0x%x, " "table @ %p, fd=%d\n", tcet, liobn, tcet->table, tcet->fd); #endif memory_region_init_iommu(&tcet->iommu, OBJECT(owner), &spapr_iommu_ops, "iommu-spapr", UINT64_MAX); QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); return tcet; }
1threat
Most efficient method to print "test"? : <p>To print something while consuming the least amount of resources.</p> <p>it can even be a <code>0</code> or <code>1</code> not necessarily <code>test</code></p> <pre><code>fputs("test",stdout); printf("%s", "test"); puts("test"); </code></pre> <p>Which one of the above commands is the most efficient ?</p> <p>is there something else that is more efficient ?</p>
0debug
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) { MOVFragment *frag = &c->fragment; AVStream *st = NULL; MOVStreamContext *sc; MOVStts *ctts_data; uint64_t offset; int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; int flags, distance, i, found_keyframe = 0, err; for (i = 0; i < c->fc->nb_streams; i++) { if (c->fc->streams[i]->id == frag->track_id) { st = c->fc->streams[i]; break; } } if (!st) { av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id); return AVERROR_INVALIDDATA; } sc = st->priv_data; if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1) return 0; avio_r8(pb); flags = avio_rb24(pb); entries = avio_rb32(pb); av_dlog(c->fc, "flags 0x%x entries %d\n", flags, entries); if (!sc->ctts_count && sc->sample_count) { ctts_data = av_realloc(NULL, sizeof(*sc->ctts_data)); if (!ctts_data) return AVERROR(ENOMEM); sc->ctts_data = ctts_data; sc->ctts_data[sc->ctts_count].count = sc->sample_count; sc->ctts_data[sc->ctts_count].duration = 0; sc->ctts_count++; } if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) return AVERROR_INVALIDDATA; if ((err = av_reallocp_array(&sc->ctts_data, entries + sc->ctts_count, sizeof(*sc->ctts_data))) < 0) { sc->ctts_count = 0; return err; } if (flags & MOV_TRUN_DATA_OFFSET) data_offset = avio_rb32(pb); if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb); dts = sc->track_end - sc->time_offset; offset = frag->base_data_offset + data_offset; distance = 0; av_dlog(c->fc, "first sample flags 0x%x\n", first_sample_flags); for (i = 0; i < entries && !pb->eof_reached; i++) { unsigned sample_size = frag->size; int sample_flags = i ? frag->flags : first_sample_flags; unsigned sample_duration = frag->duration; int keyframe = 0; int sample_cts = 0; int64_t cts; if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_CTS) sample_cts = avio_rb32(pb); sc->ctts_data[sc->ctts_count].count = 1; sc->ctts_data[sc->ctts_count].duration = sample_cts; mov_update_dts_shift(sc, sc->ctts_data[sc->ctts_count].duration); if (frag->time != AV_NOPTS_VALUE) { if (c->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) { int64_t pts = frag->time; av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64 " sc->dts_shift %d ctts.duration %d" " sc->time_offset %"PRId64" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts, sc->dts_shift, sc->ctts_data[sc->ctts_count].duration, sc->time_offset, flags & MOV_TRUN_SAMPLE_CTS); dts = pts - sc->dts_shift; if (flags & MOV_TRUN_SAMPLE_CTS) { dts -= sc->ctts_data[sc->ctts_count].duration; } else { dts -= sc->time_offset; } av_log(c->fc, AV_LOG_DEBUG, "calculated into dts %"PRId64"\n", dts); } else { dts = frag->time; av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64 ", using it for dts\n", dts); } frag->time = AV_NOPTS_VALUE; } cts = dts + sample_cts; sc->ctts_count++; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) keyframe = 1; else if (!found_keyframe) keyframe = found_keyframe = !(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC | MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES)); if (keyframe) distance = 0; err = av_add_index_entry(st, offset, INT64_MAX/2, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); if (err < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n"); } else st->index_entries[st->nb_index_entries - 1].timestamp = cts; av_dlog(c->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", cts %"PRId64", " "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i, offset, cts, sample_size, distance, keyframe); distance++; dts += sample_duration; offset += sample_size; sc->data_size += sample_size; sc->duration_for_fps += sample_duration; sc->nb_frames_for_fps ++; } if (pb->eof_reached) return AVERROR_EOF; frag->implicit_offset = offset; st->duration = sc->track_end = dts + sc->time_offset; return 0; }
1threat
How get cpu cpuserial in python? : i write a program in python 3.6.2, i want get cpuserial.i wrote bellow program : def getserial(): # Extract serial from cpuinfo file cpuserial = "0000000000000000" try: f = open('/proc/cpuinfo','r') for line in f: if line[0:6]=='Serial': cpuserial = line[10:26] f.close() except: cpuserial = "ERROR000000000" return cpuserial print(getserial()) when ran program ,it print ERROR000000000. How fix it?
0debug
alert('Hello ' + user_input);
1threat
Whats the Oracle equivalent of SELECT 'TEST' as MyColumn : <p>In MSSQL I can type into script editor and execute the following:</p> <pre><code>SELECT 'TEST' AS MyColumn </code></pre> <p>Which will output a single row containing TEST in a column called MyColumn</p> <p><a href="https://i.stack.imgur.com/ynH6a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ynH6a.png" alt="enter image description here"></a></p> <p>What is the equivalent in Oracle?</p>
0debug
How to find if type is float64 : <p>I am trying to find if a variable is of type float64: </p> <pre><code>package main import ("fmt") func main() { myvar := 12.34 if myvar.(type) == float64 { fmt.Println("Type is float64.") } } </code></pre> <p>However, it is not working and giving following error: </p> <pre><code>./rnFindType.go:6:10: use of .(type) outside type switch ./rnFindType.go:6:21: type float64 is not an expression </code></pre> <p>What is the problem and how can it be solved?</p>
0debug
Kotline : Recyclerview and Fragment Error E/RecyclerView: No adapter attached; skipping layout : <p>I create a recyclerview in activity and when I'm trying to incorporate Fragment it giving me <strong>"Error E/RecyclerView: No adapter attached; skipping layout"</strong></p> <p>My old sample Output <a href="https://i.stack.imgur.com/NCmTI.png" rel="nofollow noreferrer">My old sample Output</a></p> <p>Now I wanted to place bottom navigation and Fragment. Below is my code</p> <p>my Activity file : <strong>activity_main.xml</strong></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-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingView" android:background="@color/colorAccent" tools:context=".MainActivity"&gt; &lt;!-- &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /&gt; --&gt; &lt;TextView android:id="@+id/Voc" android:layout_height="wrap_content" android:text="Section 1" android:layout_width="wrap_content" android:paddingTop="3dp" android:paddingBottom="3dp" android:paddingLeft="10dp" android:textSize="25sp" app:layout_constraintTop_toTopOf="parent"/&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/my_recycler_view" android:layout_width="0dp" android:layout_height="wrap_content" android:paddingLeft="10dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@id/Voc" /&gt; &lt;TextView android:id="@+id/sep_id" android:layout_height="wrap_content" android:text="Section 2" android:layout_width="wrap_content" android:paddingTop="6dp" android:paddingBottom="3dp" android:textSize="25sp" android:paddingLeft="10dp" app:layout_constraintTop_toBottomOf="@id/my_recycler_view"/&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/speaking" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@id/sep_id" android:paddingLeft="10dp"/&gt; &lt;/android.support.constraint.ConstraintLayout&gt;</code></pre> </div> </div> </p> <p>Recycler layout : <strong>row_post.xml</strong></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-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="120dp" android:layout_height="120dp" &gt; &lt;!-- &lt;LinearLayout android:id="@+id/view_main_layout" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"&gt; --&gt; &lt;ImageView android:id="@+id/image_view_id_row" android:layout_width="match_parent" android:layout_marginRight="10dp" android:src="@drawable/sp2" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" android:layout_height="90dp" android:background="@color/colorPrimary" android:scaleType="fitXY" /&gt; &lt;TextView android:id="@+id/username" android:text="Loading Username.." android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15sp" app:layout_constraintTop_toBottomOf="@id/image_view_id_row" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" android:textAlignment="center" android:layout_marginRight="10dp" /&gt; &lt;!-- " android:src="@drawable/sp1"--&gt; &lt;/android.support.constraint.ConstraintLayout&gt;</code></pre> </div> </div> </p> <p>Main Layout or landing page with Frame : activity_main2.xml</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-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/containerm" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;FrameLayout android:id="@+id/frame_layout_id" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;android.support.design.widget.BottomNavigationView android:id="@+id/navigationView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="0dp" android:layout_marginStart="0dp" android:layout_gravity="bottom" android:layout_weight="0" android:background="?android:attr/windowBackground" app:itemBackground="@color/colorPrimary" app:itemIconTint="@color/white" app:itemTextColor="@color/white" app:menu="@menu/navigation"/&gt; &lt;/LinearLayout&gt;</code></pre> </div> </div> </p> <p>kotlin class : FragmentCall(link to activity_main.xml)</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>package com.ammara.ammara.TEST import android.content.Context import android.os.Bundle import android.support.v4.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.net.Uri import android.support.v7.widget.LinearLayoutManager import kotlinx.android.synthetic.main.activity_main.* import com.ammara.ammara.ielts.model.Samples class FragmentCall:Fragment() { val TAG="Call Fragment" override fun onAttach(context: Context?) { super.onAttach(context) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater!!.inflate(R.layout.activity_main,container,false) } override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) } override fun onStart() { super.onStart() } override fun onResume() { super.onResume() } override fun onPause() { super.onPause() } override fun onStop() { super.onStop() } override fun onDestroyView() { super.onDestroyView() } override fun onDestroy() { super.onDestroy() } override fun onDetach() { super.onDetach() } }</code></pre> </div> </div> </p> <p>kotlin class Main2Activity (link to activity_main2.xml)</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>package com.ammara.ammara.TEST import android.app.AlertDialog import android.content.Intent import android.net.Uri import android.os.Bundle import android.support.design.widget.BottomNavigationView import android.support.v7.app.AppCompatActivity import android.support.v7.widget.LinearLayoutManager import com.ammara.ammara.ielts.R.menu.navigation import com.ammara.ammara.ielts.model.Samples import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main2.* class Main2Activity : AppCompatActivity() { var isFragmentOneLoaded=true val manager=supportFragmentManager private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item -&gt; when (item.itemId) { R.id.navigation_home -&gt; { ShowFragmentOne() return@OnNavigationItemSelectedListener true } R.id.navigation_dashboard -&gt; { ShowFragmentOne() return@OnNavigationItemSelectedListener true } R.id.navigation_notifications -&gt; { ShowFragmentOne() return@OnNavigationItemSelectedListener true } } false } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main2) ShowFragmentOne() navigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) } fun ShowFragmentOne(){ val transaction=manager.beginTransaction() val fragment=FragmentCall() transaction.replace(R.id.frame_layout_id,fragment) transaction.addToBackStack(null) transaction.commit() AlertDialog.Builder( this) .setMessage(this.packageName) .setPositiveButton("ok") { p0, p1 -&gt; } .create() .show() } }</code></pre> </div> </div> </p> <p>Adaptor class link to row_post</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>package com.ammara.ammara.TEST import android.content.Intent import android.os.Parcel import android.os.Parcelable import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import com.ammara.ammara.TEST.model.Samples import com.squareup.picasso.Picasso import kotlinx.android.synthetic.main.row_post.view.* import android.os.Bundle import android.support.v4.content.ContextCompat.startActivity class PostsAdapter (val posts: ArrayList&lt;Samples&gt;) : RecyclerView.Adapter&lt;PostsAdapter.PostsViewHolder&gt; (){ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PostsAdapter.PostsViewHolder { val view: View = LayoutInflater.from(parent.context).inflate(R.layout.row_post,parent,false) val holder= PostsViewHolder(view) view.setOnClickListener{ val intent= Intent(parent.context, SampleTest::class.java) val extras = Bundle() extras.putString("title",posts[holder.adapterPosition].title) extras.putString("photoUrl",posts[holder.adapterPosition].photoUrl.toString()) intent.putExtras(extras) parent.context.startActivity(intent) } return holder } override fun getItemCount() = posts.size override fun onBindViewHolder(holder: PostsViewHolder, position: Int) { holder.title.text=posts[position].title holder.image.setImageURI(posts[position].photoUrl) // Picasso.get().load(posts[position].photoUrl).into(holder.image) } class PostsViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) { val image: ImageView=itemView.findViewById(R.id.image_view_id_row) val title: TextView=itemView.findViewById(R.id.username) } }</code></pre> </div> </div> </p> <p>Now the problem is that....earlier I was having below lines of code in my activity, now activity is not getting call due to fragment. where do i put below line of 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> val myImageList = intArrayOf(R.drawable.sp1, R.drawable.sp2, R.drawable.sp3, R.drawable.sp4, R.drawable.sp5, R.drawable.sp6, R.drawable.sp7, R.drawable.sp8, R.drawable.sp9, R.drawable.sp10) val myImageList1 = arrayListOf("@drawable/sp1", "@drawable/sp2", "@drawable/sp3", "@drawable/sp4", "@drawable/sp5", "@drawable/sp6", "@drawable/sp7", "@drawable/sp8", "@drawable/sp9", "@drawable/sp10") val myImageList2 = arrayListOf("sp1", "sp2", "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp9", "sp10") val samples= arrayListOf&lt;Samples&gt;() for (i in 0..9){ val imgUri = Uri.parse("android.resource://com.ammara.ammara.ielts/"+myImageList[i]) samples.add(Samples("Sample# $i", photoUrl=imgUri,price=1.99)) } val vSpeaking= arrayListOf&lt;Samples&gt;() for (i in 0..9){ val imgUri = Uri.parse("android.resource://com.ammara.ammara.ielts/"+myImageList[i]) vSpeaking.add(Samples("Sample# $i",photoUrl=imgUri,price=1.99)) } my_recycler_view.layoutManager =LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL,false) my_recycler_view.adapter = PostsAdapter(samples) speaking.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL,false) speaking.adapter = PostsAdapter(vSpeaking)</code></pre> </div> </div> </p>
0debug
static uint64_t get_guest_rtc_ns(RTCState *s) { uint64_t guest_rtc; uint64_t guest_clock = qemu_clock_get_ns(rtc_clock); guest_rtc = s->base_rtc * NANOSECONDS_PER_SECOND + guest_clock - s->last_update + s->offset; return guest_rtc; }
1threat
how do i check 2 strings in an if statement : i have 2 strings stored in my data base which are longitude and latitude location of the device my app is installed on. i only want an activity to start once it reaches a certain location. i thought writing an if statement something like below but it wouldnt work. is there another way of doing it or am i typing something wrong tvLatitude.setText(String.valueOf(gps.getLatitude())); tvLongitude.setText(String.valueOf(gps.getLongitude())); String longi = tvLongitude.getText().toString(); String lati = tvLatitude.getText().toString(); String WorkLocationlongi = "REQUIRED LONGITUDE"; String WorkLocationlati = "REQUIRED LATITUDE"; mRootRef.child("Longitude").setValue(longi); mRootRef.child("Latitude").setValue(lati); if (longi.equals(WorkLocationlati)&& lati.equals(WorkLocationlongi)){ String dtbClockon = tvClock.getText().toString(); mRootRef.child("Dave_Clock_on_date").setValue(formattedDateOnly); mRootRef .child("Dave_Clock_on").setValue(dtbClockon); startActivity(new Intent(getBaseContext(), MainActivity.class)); }else{ Toast.makeText(context,"Not in work area please enter the yard and try again",Toast.LENGTH_SHORT).show(); }
0debug
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) { unsigned int i; x86_def_t *def; char *s = strdup(cpu_model); char *featurestr, *name = strtok(s, ","); uint32_t plus_features = 0, plus_ext_features = 0, plus_ext2_features = 0, plus_ext3_features = 0; uint32_t minus_features = 0, minus_ext_features = 0, minus_ext2_features = 0, minus_ext3_features = 0; int family = -1, model = -1, stepping = -1; def = NULL; for (i = 0; i < ARRAY_SIZE(x86_defs); i++) { if (strcmp(name, x86_defs[i].name) == 0) { def = &x86_defs[i]; break; } } if (kvm_enabled() && strcmp(name, "host") == 0) { cpu_x86_fill_host(x86_cpu_def); } else if (!def) { goto error; } else { memcpy(x86_cpu_def, def, sizeof(*def)); } add_flagname_to_bitmaps("hypervisor", &plus_features, &plus_ext_features, &plus_ext2_features, &plus_ext3_features); featurestr = strtok(NULL, ","); while (featurestr) { char *val; if (featurestr[0] == '+') { add_flagname_to_bitmaps(featurestr + 1, &plus_features, &plus_ext_features, &plus_ext2_features, &plus_ext3_features); } else if (featurestr[0] == '-') { add_flagname_to_bitmaps(featurestr + 1, &minus_features, &minus_ext_features, &minus_ext2_features, &minus_ext3_features); } else if ((val = strchr(featurestr, '='))) { *val = 0; val++; if (!strcmp(featurestr, "family")) { char *err; family = strtol(val, &err, 10); if (!*val || *err || family < 0) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } x86_cpu_def->family = family; } else if (!strcmp(featurestr, "model")) { char *err; model = strtol(val, &err, 10); if (!*val || *err || model < 0 || model > 0xff) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } x86_cpu_def->model = model; } else if (!strcmp(featurestr, "stepping")) { char *err; stepping = strtol(val, &err, 10); if (!*val || *err || stepping < 0 || stepping > 0xf) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } x86_cpu_def->stepping = stepping; } else if (!strcmp(featurestr, "vendor")) { if (strlen(val) != 12) { fprintf(stderr, "vendor string must be 12 chars long\n"); goto error; } x86_cpu_def->vendor1 = 0; x86_cpu_def->vendor2 = 0; x86_cpu_def->vendor3 = 0; for(i = 0; i < 4; i++) { x86_cpu_def->vendor1 |= ((uint8_t)val[i ]) << (8 * i); x86_cpu_def->vendor2 |= ((uint8_t)val[i + 4]) << (8 * i); x86_cpu_def->vendor3 |= ((uint8_t)val[i + 8]) << (8 * i); } x86_cpu_def->vendor_override = 1; } else if (!strcmp(featurestr, "model_id")) { pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id), val); } else { fprintf(stderr, "unrecognized feature %s\n", featurestr); goto error; } } else { fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr); goto error; } featurestr = strtok(NULL, ","); } x86_cpu_def->features |= plus_features; x86_cpu_def->ext_features |= plus_ext_features; x86_cpu_def->ext2_features |= plus_ext2_features; x86_cpu_def->ext3_features |= plus_ext3_features; x86_cpu_def->features &= ~minus_features; x86_cpu_def->ext_features &= ~minus_ext_features; x86_cpu_def->ext2_features &= ~minus_ext2_features; x86_cpu_def->ext3_features &= ~minus_ext3_features; free(s); return 0; error: free(s); return -1; }
1threat
How to Delete the cell value in a given range if it contains a string value using excel vba : Can anybody tell me how to delete the cells value in a given range if the cell value is String (Not a particular string, in general any String)
0debug
Enabling/Disabling Buttons via function/method (C#) : 1. I have 8 buttons, each performs a different task, i.e. edit, delete, create etc, and a context​Menu for each of the task 2. I've a table called *Moderations* in DB, which consists of bools i.e. groupTitle, canEdit, canDelete, canCreate..... groupTitle is string not bool 3. I have a bool function *canDoIt(task, userid)* to check whether the logged in user (which will have specific groupTitle), can perform or can't (function return true or false for provided task, in short) Suppose, I want to check whether a logged in user can perform the task or not, check via canDoit(task, userid), and If he cannot, the button will be disabled otherwise won't.... OnForm_Load I throw the function (or may be another time when I need it) and check for each button, i.e. btnEdit.Enabled = canDo("canEdit", userID) btnDelete.Enabled = canDo("canDelete", userID) btnCreate.Enabled = canDo("canCreat", userID) cnxMenuEdit.Enabled = canDo("canEdit", userID) cnxMenuDelete.Enabled = canDo("canDelete", userID) . . . .....and so on and so forth. My method work fine and good but I have doubts and questions.... First question, is good to be so? Second question, is it professional? Another is, will that effect program or database performance? Sorry if same has already asked/posted.....
0debug
Python http lib supporting CONNECT http verbs, header manipulation, and TLS/SSL : I am looking for a Python http lib supporting the CONNECT http verb, http header manipulation, and TLS/SSL support. Unfortunately requests/urllib don't support this (https://lukasa.co.uk/2013/07/Python_Requests_And_Proxies/). Trying to avoid manually doing this with openssl + sockets. Thanks!
0debug
Looping over unique values : <p>I have a data frame in long format, with one observation row per measurement. I want to loop through each unique ID and find the "minimum" date for each unique individual. For example, patient 1 may be measured at three different times, but I want the earliest time. I thought about sorting the dataset by the date (in increasing order) and removing all duplicates, but I'm not sure if this is the best way to go. Any help or suggestions would be greatly appreciated. Thank you!</p>
0debug
RStudio installation failure under Debian sid: libgstreamer dependency problems : <p>I use Debian sid (amd64), rolling updates as often as weekly. I downloaded recently the desktop version 0.99.902 of RStudio from their offical site and issued (as root, of course):</p> <p>dpkg -i rstudio-0.99.902-amd64.deb</p> <p>to no avail:</p> <p>dpkg: dependency problems prevent configuration of rstudio: rstudio depends on libgstreamer0.10-0; however: Package libgstreamer0.10-0 is not installed. rstudio depends on libgstreamer-plugins-base0.10-0; however: Package libgstreamer-plugins-base0.10-0 is not installed.</p> <p>Newer versions (1.0-0) of these 2 packages are installed on the system, but those older ones (0.10-0) are not available anymore on the official Debian repos.</p> <p>What should be done to have RStudio installed and fully operational under Debian sid? I have, of course, installed R debs, from official Debian repositories, without any issues...</p> <p>Thanks for any help!</p>
0debug
The length of childNodes XML : <blockquote> <p>I have 2 same together,First: </p> </blockquote> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;p id="demo"&gt;&lt;/p&gt; &lt;script&gt; var x, i, xmlDoc; var txt = ""; var text = "&lt;book&gt;" + "&lt;title&gt;Everyday Italian&lt;/title&gt;" + "&lt;author&gt;Giada De Laurentiis&lt;/author&gt;" + "&lt;year&gt;2005&lt;/year&gt;" + "&lt;/book&gt;"; parser = new DOMParser(); xmlDoc = parser.parseFromString(text,"text/xml"); x = xmlDoc.documentElement.childNodes; document.write(x.length); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <blockquote> <p>Second File</p> </blockquote> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;DOM XML&lt;/title&gt; &lt;script language = "javascript" type = "text/javascript"&gt; xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function(){ if(xhttp.readyState == 4 &amp;&amp; xhttp.status == 200){ xmlDoc = xhttp.responseXML; x = xmlDoc.documentElement.childNodes; document.write(x.length); } }; xhttp.open('get','book3.xml',true); xhttp.send(); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <blockquote> <p>and book3.xml file </p> </blockquote> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;book&gt; &lt;title&gt;Everyday Italian&lt;/title&gt; &lt;author&gt;Giada De Laurentiis&lt;/author&gt; &lt;year&gt;2005&lt;/year&gt; &lt;/book&gt; </code></pre> <p>I think text variable in the first code same with code in book3.xml, but when I print x.length, so the result in top is "3" and below in is "7". I try to many times but It's not change. Can you help me for the reason ???</p>
0debug
Prolog recursive logic : I'm trying to implement a method to work as follows foo(5) = 5^4 + 4^3 + 3^2 + 2^1 + 1^0 = 701 using recursion. I've been trying to follow the logic but I keep getting errors. can someone guide me? (define (foo n) ; size-n problem ( cond ( (= (- n 1) 0 ) ; stopping condition 0 ); return value (else (+ ( expt n (- n 1) ) ( foo (- n 1) ) ) ))) ; size-m problems
0debug
Is there any difference between return and raise an Exception? : <p>Consider the following code:</p> <pre><code> def f(x): if x &lt; 10: return Exception("error") else: raise Exception("error2") if __name__ == "__main__": try: f(5) # f(20) except Exception: print str(Exception) </code></pre> <p>Is there any difference? When should I use return Exception and When should I use raise?</p>
0debug
void ff_print_debug_info(MpegEncContext *s, Picture *p) { AVFrame *pict; if (s->avctx->hwaccel || !p || !p->mb_type) return; pict = &p->f; if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) { int x,y; av_log(s->avctx,AV_LOG_DEBUG,"New frame, type: "); switch (pict->pict_type) { case AV_PICTURE_TYPE_I: av_log(s->avctx,AV_LOG_DEBUG,"I\n"); break; case AV_PICTURE_TYPE_P: av_log(s->avctx,AV_LOG_DEBUG,"P\n"); break; case AV_PICTURE_TYPE_B: av_log(s->avctx,AV_LOG_DEBUG,"B\n"); break; case AV_PICTURE_TYPE_S: av_log(s->avctx,AV_LOG_DEBUG,"S\n"); break; case AV_PICTURE_TYPE_SI: av_log(s->avctx,AV_LOG_DEBUG,"SI\n"); break; case AV_PICTURE_TYPE_SP: av_log(s->avctx,AV_LOG_DEBUG,"SP\n"); break; } for (y = 0; y < s->mb_height; y++) { for (x = 0; x < s->mb_width; x++) { if (s->avctx->debug & FF_DEBUG_SKIP) { int count = s->mbskip_table[x + y * s->mb_stride]; if (count > 9) count = 9; av_log(s->avctx, AV_LOG_DEBUG, "%1d", count); } if (s->avctx->debug & FF_DEBUG_QP) { av_log(s->avctx, AV_LOG_DEBUG, "%2d", p->qscale_table[x + y * s->mb_stride]); } if (s->avctx->debug & FF_DEBUG_MB_TYPE) { int mb_type = p->mb_type[x + y * s->mb_stride]; if (IS_PCM(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "P"); else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "A"); else if (IS_INTRA4x4(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "i"); else if (IS_INTRA16x16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "I"); else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "d"); else if (IS_DIRECT(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "D"); else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "g"); else if (IS_GMC(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "G"); else if (IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "S"); else if (!USES_LIST(mb_type, 1)) av_log(s->avctx, AV_LOG_DEBUG, ">"); else if (!USES_LIST(mb_type, 0)) av_log(s->avctx, AV_LOG_DEBUG, "<"); else { assert(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1)); av_log(s->avctx, AV_LOG_DEBUG, "X"); } if (IS_8X8(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "+"); else if (IS_16X8(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "-"); else if (IS_8X16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "|"); else if (IS_INTRA(mb_type) || IS_16X16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, " "); else av_log(s->avctx, AV_LOG_DEBUG, "?"); if (IS_INTERLACED(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "="); else av_log(s->avctx, AV_LOG_DEBUG, " "); } } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } } }
1threat
React testing library: The given element does not have a value setter when fireEvent change on input form : <p>I want to change the value of <a href="https://material-ui.com/components/text-fields/" rel="noreferrer">material UI</a> <code>TextField</code> in react testing library. I already set up the data-testid. Then using <code>getByTestId</code> i picked up the input element.</p> <pre><code>// the component &lt;TextField data-testid="input-email" variant="outlined" margin="normal" required fullWidth id="email" label="Email Address" name="email" value={email} onChange={e =&gt; setEmail(e.target.value)} autoComplete="email" autoFocus /&gt; // the test //... let userInput = getByTestId('input-email') fireEvent.change(userInput, { target: { value: 'correct@mail.com' } }) </code></pre> <p>but this doesn't work as it's returning error: <code>The given element does not have a value setter</code>. Isn't the element uses <code>e.target.value</code> on it's <code>onChange</code> attribute? What am I do wrong?</p>
0debug
Can't install Django 2.0 by pip : <p>I am building new Django app with a new version of Django. I found Django 2.0 is available (2.0.2) <a href="https://www.djangoproject.com/download/" rel="noreferrer">https://www.djangoproject.com/download/</a>, and now trying to install it with pip.</p> <blockquote> <p>pip install Django==2.0.2</p> </blockquote> <p>But it's not working for me.</p> <blockquote> <p>Could not find a version that satisfies the requirement Django==2.0 (from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.4.18, 1.4.19, 1.4.20, 1.4.21, 1.4.22, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11, 1.5.12, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.10, 1.6.11, 1.7, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.7.10, 1.7.11, 1.8a1, 1.8b1, 1.8b2, 1.8rc1, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.11, 1.8.12, 1.8.13, 1.8.14, 1.8.15, 1.8.16, 1.8.17, 1.8.18, 1.9a1, 1.9b1, 1.9rc1, 1.9rc2, 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8, 1.9.9, 1.9.10, 1.9.11, 1.9.12, 1.9.13, 1.10a1, 1.10b1, 1.10rc1, 1.10, 1.10.1, 1.10.2, 1.10.3, 1.10.4, 1.10.5, 1.10.6, 1.10.7, 1.10.8, 1.11a1, 1.11b1, 1.11rc1, 1.11, 1.11.1, 1.11.2, 1.11.3, 1.11.4, 1.11.5, 1.11.6, 1.11.7, 1.11.8, 1.11.9, 1.11.10) No matching distribution found for Django==2.0</p> </blockquote> <p>I am using python 2.7.14 and pip 9.0.1. What's wrong here?</p>
0debug
static void qmp_input_optional(Visitor *v, const char *name, bool *present) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, false, NULL); if (!qobj) { *present = false; return; } *present = true; }
1threat
writing with python into a csv file with multiple lines in one cell : <p>im using writer.writerow(groupOfUsers) where groupOfUsers is a list of users ex: ['joe','john','jane'] i want all 3 names printed with a new line into one cell but with the current command it writes the 3 names into 3 different new rows</p> <p>i want it to look like joe john jane</p> <p>and not</p> <p>joe</p> <hr> <p>john</p> <hr> <p>jane</p>
0debug
Convert List to Dataframe Python : data = open("state_towns.txt") for line in data: print(line) returns the following list: Colorado[edit] Alamosa (Adams State College)[2] Boulder (University of Colorado at Boulder)[12] Durango (Fort Lewis College)[2] Connecticut[edit] Fairfield (Fairfield University, Sacred Heart University) Middletown (Wesleyan University) New Britain (Central Connecticut State University) I want to return a dataframe with two columns, state and region, that would look like this: State Town 0 Colorado Auburn 1 Colorado Florence 2 Colorado Jacksonville 3 Connecticut Fairfield 4 Connecticut Middletown 5 Connecticut New Britain How do i split the list so that any line that contains '[edit]' will be added to the state column? Also how to I delete all the text in the brackets from the town entries? thanks
0debug
Please help me with this assembly code : [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/KQFZi.png I thought since condition is a >= 3, we should use jl (less) But the answer is jle (less or equal). It make no sense to me, please help, thank you
0debug
scala - declare list that holds anything? : In Scala, how do i declare a list that holds anything? List[Object] gets upset if I try and put a tuple in it, scala errors sayi type mismatch; found : java.util.List[Triple[Integer,Integer, Integer]] required: java.util.List[Object] Note: Triple[Integer,Integer, Integer] <: Object, but Java-defined trait List is invariant in type E. You may wish to investigate a wildcard type such as `_ <: Object`. (SLS 3.2.10) I don't know what this means, how do I declare the list to hold a triple (or a tuple, or *anything*) My code looks like this (it is twirl, so it has @, but it is just Scala code): @import java.util.List; @(field:List[Object], min:Int=1)(f: Object, Int) => Html) @{ (0 until math.max(if (field.isEmpty) 0 else field.size, min)) .map(i => f(field.get(i),i)) }
0debug
How to make vawe effect around the circle when clicked using CSS, HTML? : Can someone help me making vawe effect around the circle when circle is clicked. Here is GIF image of what I should achieve - http://g.recordit.co/lEhuqjj5tU.gif Thanks in advance!
0debug
Why is this reference not working/ valid? : <p>I'm learning referencing in C and here is my code:</p> <pre><code>#include &lt;stdio.h&gt; int main(void) { int x = 5; int &amp;ref = x; printf("%d\n", x); printf("%p\n", &amp;x); printf("%p\n", &amp;ref); return 0; } </code></pre> <p>When i compile, it shows these errors:</p> <blockquote> <p>reference.c:7:6: error: expected identifier or '('</p> <p>int &amp;ref = x;</p> <p>reference.c:11:18: error: use of undeclared identifier 'ref'</p> <p>printf("%p\n", &amp;ref);</p> <p>2 errors generated.</p> </blockquote> <p>What should i do to fix this and thanks in advance.</p>
0debug
Software design consulting needed (Android Library Project) : - I have an App with my main Activity ("MainActivity") - I have a View in a "Android Project Library". I would like to use this view in several Apps, thats why I added this view in a library. - I can use the view from my App But now comes the problem. I would like to interact with my Apps MainActivity from my view. If the view would be in the app insteed of library I would simply call... (MainActivity)context.myfunction() ... in my view. But in case of the library, my view doesn't know about the MainActivity, because its out of the project-scope. How can I interact with the Activity from my view, which is placed in a library ? Any hints ?
0debug
Fullscreen the Exoplayer : <p>I try to show the show video (.mp4) with <strong>exoplayer</strong> in <strong>RecyclerView</strong> and <strong>ViewPager</strong>. I show the video controller with custom layout. so far so good.</p> <p>Now try to fullscreen the video like other video player how use before but can't find a good way in the <strong>exoplayer</strong> doc. </p> <p>can anyone help me?</p>
0debug
I have a problem when I install angular on terminal macOs : <p>I would like to install angular but when I type the command these error messages appear. Could someone help me? Thank you in advance. <a href="https://i.stack.imgur.com/RDxRm.png" rel="nofollow noreferrer">enter image description here</a></p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
static uint64_t vgafb_read(void *opaque, target_phys_addr_t addr, unsigned size) { MilkymistVgafbState *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_CTRL: case R_HRES: case R_HSYNC_START: case R_HSYNC_END: case R_HSCAN: case R_VRES: case R_VSYNC_START: case R_VSYNC_END: case R_VSCAN: case R_BASEADDRESS: case R_BURST_COUNT: case R_DDC: case R_SOURCE_CLOCK: r = s->regs[addr]; break; case R_BASEADDRESS_ACT: r = s->regs[R_BASEADDRESS]; break; default: error_report("milkymist_vgafb: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_milkymist_vgafb_memory_read(addr << 2, r); return r; }
1threat
Select Mysql not return row when field is NULL and filter LIKE '%' : I have a table with a field: - field1 (Varchar(10)) Default NULL; When I run this sql: - SELECT * FROM table WHERE field1 LIKE '%'; That query does not return rows where Field1 IS NULL; Why NULL it is not considered as any value? What solution do I have? I do not have to know the default value of the fields in a table to make a query. Thanks.
0debug
Check if a number entered by the user with gets.chomp is a float in ruby : <p>I have looked for this a long time now and can't find a satisfactory answer. I wold like to know how can I check if the number entered by the user is a float. If is a float it is supposed to be an invalid number.</p> <p>I have something but the result is always true/Integer</p> <p>Here is what I have so far.</p> <pre><code>puts "What are the first number you want to divide" number1 = gets.chomp.to_i puts "What is the second number?" number2 = gets.chomp.to_i def is_float(variable) return variable % 1 == 0 end if (number1 == 0) &amp;&amp; (number2 == 0) puts "Invalid input" elsif (is_float(number1) == false) || (is_float(number2) == false) puts "Invalid input" else def divide(number1, number2) return number1 / number2 end division_result = divide(number1, number2) def reminder(number1, number2) return number1 % number2 end reminder_results = reminder(number1, number2) puts "" puts "Your result is #{division_result}" puts "Your reminder is #{reminder_results}" end </code></pre>
0debug
Sitecore 8: MVC or Web Forms? : <p>I am new to Sitecore but I need to develop a all new Sitecore project. Although I have some experience with ASP.Net MVC and web form but I don't which is better for Sitecore 8.0.</p> <p>Here is the only related information that I found. <a href="https://www.cmssource.co.uk/blog/2013/october/sitecore-mvc-or-webforms" rel="nofollow">https://www.cmssource.co.uk/blog/2013/october/sitecore-mvc-or-webforms</a></p> <p>What technology should i choose- MVC or Web Forms ?</p>
0debug
(Delphi) I set a button to add a bold line to a rich edit, but the first time I click the button it doesn't come out bold? : I have set a button to add a line(bold) to a rich edit, but the first time I click the button it doesn't come out bold? eg: line1, **line2**, **line3** Code: red1.SelAttributes.Style := [fsBold]; red1.Lines.Add(' Name: ' + Edit1.Text); Does anyone know what I have done wrong? -Thanks
0debug
static void nvdimm_build_structure_dcr(GArray *structures, DeviceState *dev) { NvdimmNfitControlRegion *nfit_dcr; int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, NULL); uint32_t sn = nvdimm_slot_to_sn(slot); nfit_dcr = acpi_data_push(structures, sizeof(*nfit_dcr)); nfit_dcr->type = cpu_to_le16(4 ); nfit_dcr->length = cpu_to_le16(sizeof(*nfit_dcr)); nfit_dcr->dcr_index = cpu_to_le16(nvdimm_slot_to_dcr_index(slot)); nfit_dcr->vendor_id = cpu_to_le16(0x8086); nfit_dcr->device_id = cpu_to_le16(1); nfit_dcr->revision_id = cpu_to_le16(1 ); nfit_dcr->serial_number = cpu_to_le32(sn); nfit_dcr->fic = cpu_to_le16(0x201 ); }
1threat
how to get current location latitude and longitude using javascript : i am using below code in my project <script> var x=document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else{x.innerHTML="Geolocation is not supported by this browser.";} } function showPosition(position) { //x.innerHTML="Latitude:" + position.coords.latitude + //"<br>Longitude: " + position.coords.longitude; var dataString = 'Latitude='+ position.coords.latitude + '&Longitude='+ position.coords.longitude; alert(dataString); //AJAX code to submit form. //$('#loginprocessing').html('<img src="../images/loading2.gif" alt=" " title="" id="loads" style="margin-left: 0PX;">Loading...'); $.ajax({ type: "GET", url: "getvalue.php", data: dataString, cache: false, success: function(result){ $("#demovalues").html(result); } }); } </script> its working fine in my local but in server i got an error like Deceptive site ahead Attackers on geospeedy.com may trick you into doing something dangerous like installing software or revealing your personal information (for example, passwords, phone numbers, or credit cards). Learn more Automatically send some system information and page content to Google to help detect dangerous apps and sites. Privacy policy please suggest any one its very urgent
0debug
Oracle SQL developer select query on stored procedure with out parameters : I wrote Oracle stored procedure on oracle SQL developer with out parameters as below create or replace PROCEDURE "SYSLOCKDAILY" Is BEGIN select * from PDB2B_SYSTEMLOCKINFO where ISDAILY = 1 and active = 1 and TO_TIMESTAMP (to_char(sysdate,'HH12:MI AM'),'HH12:MI AM') >=TO_TIMESTAMP (STIME,'HH12:MI AM') and TO_TIMESTAMP (to_char(SYSDATE,'HH12:MI AM'),'HH12:MI AM') <= TO_TIMESTAMP (ETIME,'HH12:MI AM'); COMMIT; END SYSLOCKDAILY; But I got error as below on error log. Pls help me fix this. Error(9,2): PLS-00428: an INTO clause is expected in this SELECT statement
0debug
Return user Highest number and Unique number in table : <p>I has table user_data: <br> <a href="https://i.stack.imgur.com/MRGOB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MRGOB.png" alt="enter image description here"></a></p> <p>I want return user has Highest number and Unique number! <br> => User id=5, name= E, number=3<br> Thanks!</p>
0debug
unit tests with SQL : i am doing a project software, working with data base and java code and in the unitys tests, we have to test the selects....i mean, the expectable is that the table that results from the selects, have to corresponde with the output in the intellij..... in a few words, how i compare a table origined from sql with a output(system.out.println())
0debug
static inline void gen_cond_branch(DisasContext *dc, int cond) { int l1; l1 = gen_new_label(); tcg_gen_brcond_tl(cond, cpu_R[dc->r0], cpu_R[dc->r1], l1); gen_goto_tb(dc, 0, dc->pc + 4); gen_set_label(l1); gen_goto_tb(dc, 1, dc->pc + (sign_extend(dc->imm16 << 2, 16))); dc->is_jmp = DISAS_TB_JUMP; }
1threat
Simplest way to validate string (Java) : <p>I want to check that a string meets the following criteria:</p> <ul> <li>Consists of exactly two words</li> <li>Each word contains only letters (A-Z and a-z), and is at least two letters long</li> <li>The two words are separated by exactly one space</li> </ul> <p>For example, "Jon Snow" should validate, and any other name consisting of only one given name and one family name, and no special characters.</p> <p>What is the simplest way to ensure this validation?</p> <p>Thanks!</p>
0debug
assembly character uppercase lowercase looping : i need help creating a program in assembly with ms-dos that will output something like this AbCdEfGhIjKl also vertically the closest thing i can make is something like AbCbEbGbH i don't know how to increment the in between stuff
0debug
static void blkverify_refresh_filename(BlockDriverState *bs) { BDRVBlkverifyState *s = bs->opaque; bdrv_refresh_filename(s->test_file->bs); if (bs->file->bs->full_open_options && s->test_file->bs->full_open_options) { QDict *opts = qdict_new(); qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify"))); QINCREF(bs->file->bs->full_open_options); qdict_put_obj(opts, "raw", QOBJECT(bs->file->bs->full_open_options)); QINCREF(s->test_file->bs->full_open_options); qdict_put_obj(opts, "test", QOBJECT(s->test_file->bs->full_open_options)); bs->full_open_options = opts; } if (bs->file->bs->exact_filename[0] && s->test_file->bs->exact_filename[0]) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "blkverify:%s:%s", bs->file->bs->exact_filename, s->test_file->bs->exact_filename); } }
1threat
Can I invoke another form 's task : <p>in form1 , there are two functions , one for a button 's click event </p> <pre><code> private void bQuery_Click(object sender, EventArgs e) { string sPrefix = tbPrefix.Text.Trim(); QueryAll(sPrefix); } </code></pre> <p>another one is a task </p> <pre><code> async Task QueryAll(string sPrefix) { } </code></pre> <p>now I need invoke form1 's task in form2 certain function , such as </p> <pre><code> string prefix = "abc"; frm = new form1(); frm.ShowDialog(); frm.Dispose(); frm.QueryAll(sPrefix); </code></pre> <p>I know this statement </p> <pre><code>frm.QueryAll(sPrefix); </code></pre> <p>can not compile , just to show what I want to do , anyone knows how to call this task "QueryAll" ? thanks for your help </p>
0debug
static int read_line(AVIOContext * pb, char* line, int bufsize) { int i; for (i = 0; i < bufsize - 1; i++) { int b = avio_r8(pb); if (b == 0) break; if (b == '\n') { line[i] = '\0'; return 0; } line[i] = b; } line[i] = '\0'; return -1; }
1threat
void qemu_acl_reset(qemu_acl *acl) { qemu_acl_entry *entry; acl->defaultDeny = 1; QTAILQ_FOREACH(entry, &acl->entries, next) { QTAILQ_REMOVE(&acl->entries, entry, next); free(entry->match); free(entry); } acl->nentries = 0; }
1threat
int uuid_is_null(const uuid_t uu) { uuid_t null_uuid = { 0 }; return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0; }
1threat
I want to save a MP4 Video from array list of frames : <p>i want to extract frames from a video and add effect in this frames then i want to save this frames as mp4 Video <a href="https://github.com/MuhammadNasser/VideoEffects/blob/master/app/src/main/java/com/example/mondy/videoeffects/MainActivity.java" rel="nofollow">here is</a> what i use in my code and it didn't work </p> <p>ineed help please </p>
0debug
How to Send, Receive, and Print a File in Java? : <p>So, I've seen several of posts like this on Stackoverflow, but I am completely confused here after taking resources from like 10 posts. And the fact that I'm relatively new to Java isn't really helping. So, my goal is to get a file, convert it to a byte array, send that, have the client put that into a byte array, and convert that byte array to a string.</p> <p>So here's the relevant server code (this is in a try/catch just so you know):</p> <pre><code>System.out.println("Waiting for a client..."); // Start a server ServerSocket server = new ServerSocket(3210); // Listen for anyone at that port Socket socket = server.accept(); System.out.println("A client has connected!"); DataOutputStream outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); // Get file File file = new File("history.txt"); // Convert file to byte array byte[] bytes = new byte[(int) file.length()]; // Send bytes outputStream.write(bytes); // Close everything down socket.close(); outputStream.close(); server.close(); </code></pre> <p>If you read the comments, you get a basic idea of what I think is/should be done in the client and server. Here's the client (again, surrounded in a try/catch):</p> <pre><code>Socket socket = new Socket(desktopName, 3210); // Get stream DataInputStream inputStream = new DataInputStream(new BufferedInputStream(socket.getInputStream())); // Create a byte array byte[] bytes = new byte[1024 * 16]; // Convert byte array to string allMessagesTextBox.setText(new String(bytes)); inputStream.close(); socket.close(); </code></pre> <p>And when that code is run in Eclipse, I get a java.lang.NullPointerException on the client on the line where it converts the byte array to string and prints it out. I've tried dozens of different techniques provided by websites and QA sites, but they all lead me to this error. Any ideas on what's wrong here, and how to fix it?</p>
0debug
Tensorflow: Confusion regarding the adam optimizer : <p>I'm confused regarding as to how the adam optimizer actually works in tensorflow.</p> <p>The way I read the <a href="https://www.tensorflow.org/versions/r0.9/api_docs/python/train.html#AdamOptimizer" rel="noreferrer">docs</a>, it says that the learning rate is changed every gradient descent iteration. </p> <p>But when I call the function I give it a learning rate. And I don't call the function to let's say, do one epoch (implicitly calling # iterations so as to go through my data training). I call the function for each batch explicitly like</p> <pre><code>for epoch in epochs for batch in data sess.run(train_adam_step, feed_dict={eta:1e-3}) </code></pre> <p>So my eta cannot be changing. And I'm not passing a time variable in. Or is this some sort of generator type thing where upon session creation <code>t</code> is incremented each time I call the optimizer?</p> <p>Assuming it is some generator type thing and the learning rate is being invisibly reduced: How could I get to run the adam optimizer without decaying the learning rate? It seems to me like <a href="https://www.tensorflow.org/versions/r0.9/api_docs/python/train.html#RMSPropOptimizer" rel="noreferrer">RMSProp</a> is basically the same, the only thing I'd have to do to make it equal (learning rate disregarded) is to change the hyperparameters <code>momentum</code> and <code>decay</code> to match <code>beta1</code> and <code>beta2</code> respectively. Is that correct?</p>
0debug
How to change First letter of each word to Uppercase in Textview xml : <p>i need to change the <strong>text="font roboto regular"</strong> to <strong>Font Roboto Regular</strong> in xml itself, how to do? </p> <pre><code>&lt;TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textSize="18sp" android:textColor="@android:color/black" android:fontFamily="roboto-regular" android:text="font roboto regular" android:inputType="textCapWords" android:capitalize="words"/&gt; </code></pre>
0debug