problem
stringlengths
26
131k
labels
class label
2 classes
creating array with non constant parameters : I'm currently working on an assignment where I must find a way to output the longest common sub-sequence of two strings. In all of the other places I have found implementations of this code, they all share one similarity which is, multiple arrays are initialized with non constant variables which I had always learned was not allowed, and the program does not compile. Is there some way around this rule or is there something I am missing? #include <iostream> #include <algorithm> #include <vector> using namespace std; //Prints the Longest common subsequence void printLCS(char *s1, char *s2, int m, int n); /* Driver program to test above function */ int main() { char s1[] = "ABCBDAB"; char s2[] = "BDCABA"; printLCS(s1, s2, strlen(s1), strlen(s2)); return 0; } void printLCS(char *s1, char *s2, const int m, const int n) { int L[m + 1][n + 1]; //Building L[m][n] as in algorithm for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0 || j == 0) L[i][j] = 0; else if (s1[i - 1] == s2[j - 1]) L[i][j] = L[i - 1][j - 1] + 1; else L[i][j] = max(L[i - 1][j], L[i][j - 1]); } } //To print LCS int index = L[m][n]; //charcater array to store LCS char LCS[index + 1]; LCS[index] = '\0'; // Set the terminating character //Stroing characters in LCS //Start from the right bottom corner character int i = m, j = n; while (i > 0 && j > 0) { //if current character in s1 and s2 are same, then include this character in LCS[] if (s1[i - 1] == s2[j - 1]) { LCS[index - 1] = s1[i - 1]; // Put current character in result i--; j--; index--; // reduce values of i, j and index } // compare values of L[i-1][j] and L[i][j-1] and go in direction of greater value. else if (L[i - 1][j] > L[i][j - 1]) i--; else j--; } // Print the LCS cout << "LCS of " << s1 << " and " << s2 << " is " << endl << LCS << endl; } Specifically the declarations for array L and array index. Sorry if this code is a mess I don't really post here. Any help would be greatly appreciated.
0debug
Push Notifications over WiFi : <p>I noticed by in Boingo's Wi-Finder iOS app, that the app pushes a notification to the user once he reaches an access point regestered at Boingo's database. The notification tells the user that he can access the wifi network.</p> <p>How is that done iOS?</p>
0debug
Please explain this line of javascript code : <pre><code>jBox.prototype.position = function (options) { // this line !options &amp;&amp; (options = {}); } </code></pre> <p>In conventional programming boolean statements are used in if else statements. What does !options &amp;&amp; (options = {}); translate too?</p> <p>options is a json or array. What does !options mean?</p> <p>options = {} is assigning a empty json to variable options, how does it return a boolean value to be used with &amp;&amp;.</p>
0debug
deleting elements from array containing specific string keywords : <p>i have an array <strong>$link</strong> which contains some links inside it and i wanna delete all the links which are from sites present in <strong>$Blocklinks</strong> </p> <pre><code> $links=array( 'http://ckfht.ca/sultan/files/2016/', 'http://dl1.uploadplus.net/dl2/2016/Sultan.2016/', 'http://www.google.com', 'http://subindomovie.xyz/film/indexof-sultan-720p' 'http://subindomovie.xyz/film/sultan-720-p' 'http://www.liveaccountbook.com/sultan/' ); $Blocklinks=array( 'subindomovie.xyz', 'www.liveaccountbook.com' ); /* remove urls containing link from $Blocklinks .. What should i do here??*/ $links=deletelinks($links,$Blocklinks); /* output */ print_r($links); output I want ------ Array ( [0] =&gt; http://ckfht.ca/sultan/files/2016/ [1] =&gt; http://dl1.uploadplus.net/dl2/2016/Sultan.2016/ [2] =&gt; http://www.google.com ) </code></pre>
0debug
void pc_hot_add_cpu(const int64_t id, Error **errp) { X86CPU *cpu; ObjectClass *oc; PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); int64_t apic_id = x86_cpu_apic_id_from_index(id); Error *local_err = NULL; if (id < 0) { error_setg(errp, "Invalid CPU id: %" PRIi64, id); return; } if (cpu_exists(apic_id)) { error_setg(errp, "Unable to add CPU: %" PRIi64 ", it already exists", id); return; } if (id >= max_cpus) { error_setg(errp, "Unable to add CPU: %" PRIi64 ", max allowed: %d", id, max_cpus - 1); return; } if (apic_id >= ACPI_CPU_HOTPLUG_ID_LIMIT) { error_setg(errp, "Unable to add CPU: %" PRIi64 ", resulting APIC ID (%" PRIi64 ") is too large", id, apic_id); return; } assert(pcms->possible_cpus->cpus[0].cpu); oc = OBJECT_CLASS(CPU_GET_CLASS(pcms->possible_cpus->cpus[0].cpu)); cpu = pc_new_cpu(object_class_get_name(oc), apic_id, &local_err); if (local_err) { error_propagate(errp, local_err); return; } object_unref(OBJECT(cpu)); }
1threat
static int h263_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int ret; AVPicture *pict = data; #ifdef DEBUG printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); #endif if (buf_size == 0) { *data_size = 0; return 0; } if(s->bitstream_buffer_size) init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); else init_get_bits(&s->gb, buf, buf_size); if (s->h263_msmpeg4) { ret = msmpeg4_decode_picture_header(s); } else if (s->h263_pred) { ret = mpeg4_decode_picture_header(s); s->has_b_frames= !s->low_delay; } else if (s->h263_intel) { ret = intel_h263_decode_picture_header(s); } else { ret = h263_decode_picture_header(s); } if (!s->context_initialized) { avctx->width = s->width; avctx->height = s->height; avctx->aspect_ratio_info= s->aspect_ratio_info; if (MPV_common_init(s) < 0) return -1; } else if (s->width != avctx->width || s->height != avctx->height) { MPV_common_end(s); if (MPV_common_init(s) < 0) return -1; } if(ret==FRAME_SKIPED) return 0; if (ret < 0) return -1; if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return 0; MPV_frame_start(s); #ifdef DEBUG printf("qscale=%d\n", s->qscale); #endif s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->mb_width*2 + 2; s->block_wrap[4]= s->block_wrap[5]= s->mb_width + 2; for(s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) { if (s->mb_y && !s->h263_pred) { s->first_gob_line = h263_decode_gob_header(s); } s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1; s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1); s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1; s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2); s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2); s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2); for(s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) { s->block_index[0]+=2; s->block_index[1]+=2; s->block_index[2]+=2; s->block_index[3]+=2; s->block_index[4]++; s->block_index[5]++; #ifdef DEBUG printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y); #endif if (s->h263_msmpeg4) { msmpeg4_dc_scale(s); } else if (s->h263_pred) { h263_dc_scale(s); } else { s->y_dc_scale = 8; s->c_dc_scale = 8; } clear_blocks(s->block[0]); s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; if (s->h263_msmpeg4) { if (msmpeg4_decode_mb(s, s->block) < 0) { fprintf(stderr,"\nError at MB: %d\n", (s->mb_y * s->mb_width) + s->mb_x); return -1; } } else { if (h263_decode_mb(s, s->block) < 0) { fprintf(stderr,"\nError at MB: %d\n", (s->mb_y * s->mb_width) + s->mb_x); return -1; } } MPV_decode_mb(s, s->block); } if ( avctx->draw_horiz_band && (s->num_available_buffers>=1 || (!s->has_b_frames)) ) { UINT8 *src_ptr[3]; int y, h, offset; y = s->mb_y * 16; h = s->height - y; if (h > 16) h = 16; offset = y * s->linesize; if(s->pict_type==B_TYPE || (!s->has_b_frames)){ src_ptr[0] = s->current_picture[0] + offset; src_ptr[1] = s->current_picture[1] + (offset >> 2); src_ptr[2] = s->current_picture[2] + (offset >> 2); } else { src_ptr[0] = s->last_picture[0] + offset; src_ptr[1] = s->last_picture[1] + (offset >> 2); src_ptr[2] = s->last_picture[2] + (offset >> 2); } avctx->draw_horiz_band(avctx, src_ptr, s->linesize, y, s->width, h); } } if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1; if(s->h263_pred && s->bitstream_buffer_size==0){ int current_pos= get_bits_count(&s->gb)/8; if( buf_size - current_pos > 5 && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){ memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); s->bitstream_buffer_size= buf_size - current_pos; } }else s->bitstream_buffer_size=0; MPV_frame_end(s); if(s->pict_type==B_TYPE || (!s->has_b_frames)){ pict->data[0] = s->current_picture[0]; pict->data[1] = s->current_picture[1]; pict->data[2] = s->current_picture[2]; } else { pict->data[0] = s->last_picture[0]; pict->data[1] = s->last_picture[1]; pict->data[2] = s->last_picture[2]; } pict->linesize[0] = s->linesize; pict->linesize[1] = s->linesize / 2; pict->linesize[2] = s->linesize / 2; avctx->quality = s->qscale; avctx->frame_number = s->picture_number - 1; if(s->num_available_buffers>=2 || (!s->has_b_frames)) *data_size = sizeof(AVPicture); return buf_size; }
1threat
void ff_slice_thread_free(AVCodecContext *avctx) { SliceThreadContext *c = avctx->internal->thread_ctx; int i; pthread_mutex_lock(&c->current_job_lock); c->done = 1; pthread_cond_broadcast(&c->current_job_cond); for (i = 0; i < c->thread_count; i++) pthread_cond_broadcast(&c->progress_cond[i]); pthread_mutex_unlock(&c->current_job_lock); for (i=0; i<avctx->thread_count; i++) pthread_join(c->workers[i], NULL); for (i = 0; i < c->thread_count; i++) { pthread_mutex_destroy(&c->progress_mutex[i]); pthread_cond_destroy(&c->progress_cond[i]); } pthread_mutex_destroy(&c->current_job_lock); pthread_cond_destroy(&c->current_job_cond); pthread_cond_destroy(&c->last_job_cond); av_freep(&c->entries); av_freep(&c->progress_mutex); av_freep(&c->progress_cond); av_freep(&c->workers); av_freep(&avctx->internal->thread_ctx); }
1threat
Used List<MapPdf> to var : I have a program that I used a variable of type List<MapPdf> that I will detach in variables when filling I would like to have the possibility to use it another time but I did not have the right to identify it again as <MapPdf> public static void Create(List<MapPdf> pps, Saison s, Agence agence) { foreach (var pelerins in grouped) { if (string.IsNullOrEmpty(pelerins.Key) || pelerins.Count() <= 0) break; if (writer.PageEvent == null) { writer.PageEvent = new Header_List() { travel = ctx.Travels.Include("Transport").First(v => v.UniqueId == pelerins.Key), travelretour = ctx.Travels.Find(pelerins.First().UniqueIdRetour), Agence = agence, CountAllPelerin = pelerins.Count().ToString(), CountFeminin = pelerins.Count(x => x.Sexe == PelerinSexe.Feminin).ToString(), CountMasculin = pelerins.Count(x => x.Sexe == PelerinSexe.Masculin).ToString(), NomGroupe = pelerins.First().Groupe, NumeroDoc = writer.PageNumber }; } } } And i want to use pls as a List<MapPdf> when i used in another function when it is of this declaration CreateFr(pls, false, cb, s); I used List < MapPdf > pls = pelerins.ToList(); but it does not work
0debug
Library for unpackaing BLOBS (MySQL) in c# : Is there any Library for unpackaing BLOBS (MySQL) in c#. I have tried using customized code but wondering if there must be any free library for the same. As I have some BLOBS column in MYSQL database and I want to unpack and read it and save unpacked data into another table. Thanks
0debug
Copy and paste value X amount of times : I'm currently working on a project on VBA that requires multiple manipulation on data. I need to create a macro that copies the information from cell "Q2" and pastes it on cell "A2", "B2","C2" and "D2". From there it needs to do the same with the information of cell "Q3" and paste it on "E2" and so on until there is no further data on "Q". At the moment it needs to paste the data a total of 4 times, but it needs to be modified later on for it to be 2 or 3 times. Any idea on how to make this? Thanks!
0debug
static int subtitle_thread(void *arg) { VideoState *is = arg; Frame *sp; int got_subtitle; double pts; int i, j; int r, g, b, y, u, v, a; for (;;) { while (is->paused && !is->subtitleq.abort_request) { SDL_Delay(10); } if (!(sp = frame_queue_peek_writable(&is->subpq))) return 0; if ((got_subtitle = decoder_decode_frame(&is->subdec, &sp->sub)) < 0) break; pts = 0; if (got_subtitle && sp->sub.format == 0) { if (sp->sub.pts != AV_NOPTS_VALUE) pts = sp->sub.pts / (double)AV_TIME_BASE; sp->pts = pts; sp->serial = is->subdec.pkt_serial; for (i = 0; i < sp->sub.num_rects; i++) { for (j = 0; j < sp->sub.rects[i]->nb_colors; j++) { RGBA_IN(r, g, b, a, (uint32_t*)sp->sub.rects[i]->pict.data[1] + j); y = RGB_TO_Y_CCIR(r, g, b); u = RGB_TO_U_CCIR(r, g, b, 0); v = RGB_TO_V_CCIR(r, g, b, 0); YUVA_OUT((uint32_t*)sp->sub.rects[i]->pict.data[1] + j, y, u, v, a); } } frame_queue_push(&is->subpq); } else if (got_subtitle) { avsubtitle_free(&sp->sub); } } return 0; }
1threat
Updating Android and iOS app : <p>Let me just say I'm not the developer. Is there a way to know if your app needs to be updated? I have an app published with Google and Apple. Do I have to update the APK every time that Google and Apple releases an new Operating System?? </p>
0debug
Jenkins Pipeline "node inside stage" vs "stage inside node" : <p>As both <code>node</code> step and <code>stage</code> step provide scoped <code>{}</code> syntax, what is the best practice for defining their topology inside groovy code?</p> <p><strong><em>Exhibit A</em></strong></p> <pre><code>node ("NodeName") { stage ("a stage inside node"){ // do stuff here } } </code></pre> <p><strong><em>Exhibit B</em></strong></p> <pre><code>stage ("a stage holding a node") { node ("NodeName"){ // do stuff here } } </code></pre>
0debug
static int decode_ext_header(Wmv2Context *w){ MpegEncContext * const s= &w->s; GetBitContext gb; int fps; int code; if(s->avctx->extradata_size<4) return -1; init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8); fps = get_bits(&gb, 5); s->bit_rate = get_bits(&gb, 11)*1024; w->mspel_bit = get_bits1(&gb); s->loop_filter = get_bits1(&gb); w->abt_flag = get_bits1(&gb); w->j_type_bit = get_bits1(&gb); w->top_left_mv_flag= get_bits1(&gb); w->per_mb_rl_bit = get_bits1(&gb); code = get_bits(&gb, 3); if(code==0) return -1; s->slice_height = s->mb_height / code; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, slices:%d\n", fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, s->loop_filter, code); } return 0; }
1threat
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix) { AVBPrint part[4]; format_line(ptr, level, fmt, vl, part, print_prefix, NULL); snprintf(line, line_size, "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str); av_bprint_finalize(part+3, NULL); }
1threat
void OPPROTO op_4xx_tlbsx_check (void) { int tmp; tmp = xer_so; if (T0 != -1) tmp |= 0x02; env->crf[0] = tmp; RETURN(); }
1threat
Replace Autoprefixer browsers option to Browserslist : <p>i am using [Metronic v6.03]</p> <p>I followed the Quick Start tutorial on documentation. <a href="https://keenthemes.com/metronic/?page=docs" rel="noreferrer">https://keenthemes.com/metronic/?page=docs</a></p> <p>If I give in the command ‘gulp build’ I get a message :</p> <p>“Replace Autoprefixer browsers option to Browserslist config. Use browserslist key in package.json or .browserslistrc file.</p> <p>Using browsers option cause some error. Browserslist config can be used for Babel, Autoprefixer, postcss-normalize and other tools.</p> <p>If you really need to use option, rename it to overrideBrowserslist.</p> <p>Learn more at: <a href="https://github.com/browserslist/browserslist#readme" rel="noreferrer">https://github.com/browserslist/browserslist#readme</a> <a href="https://twitter.com/browserslist" rel="noreferrer">https://twitter.com/browserslist</a>”</p> <p>The Theme don’t compiles correctly.</p> <p>NPM version : 6.9.0</p> <p>Yarn version : 1.16.0</p> <p>Gulb version</p> <p>CLI : 2.2.0</p> <p>Local version : 4.0.2</p> <p>I changed the line browserlist at package.json to</p> <p>"browserslist": [</p> <pre><code>"last 1 version", "&gt; 1%", "maintained node versions", "not dead" </code></pre> <p>]</p> <p>and try to replace the line with :</p> <p>"browserslist": [</p> <pre><code>"defaults" </code></pre> <p>]</p> <p>On Linux I added a file .browserslistrc with the lines above.</p>
0debug
How to create Fragment witch shows element clicked on RecyclerView? : I'm new at Android so maybe I'm just lack of understanding how things work. So what I have right now is RecyclerView of five elements. Each of them contains figure of different shape, different fruit name and different color bar. What I seek is to create Fragment which would show some background color, figure and fruit name inside that figure, depending on what Recyclerview element user clicks. How can I do that? That's my **MyAdapter.java** public class MyAdapter extends RecyclerView.Adapter <MyAdapter.MyViewHolder> { Context context; ArrayList<Information> data; public MyAdapter(Context context, ArrayList<Information> data) { this.context = context; this.data = data; } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_row,parent,false); MyViewHolder holder = new MyViewHolder(view); return holder; } @Override public void onBindViewHolder(final MyViewHolder holder, final int position) { holder.textView.setText(data.get(position).title); holder.relativeLayout.setBackground(context.getResources().getDrawable(data.get(position).shape)); holder.textView2.setBackground(context.getResources().getDrawable(data.get(position).color)); } @Override public int getItemCount() { return data.size(); } class MyViewHolder extends RecyclerView.ViewHolder { TextView textView,textView2; RelativeLayout relativeLayout; public MyViewHolder(View itemView) { super(itemView); textView = (TextView) itemView.findViewById(R.id.txt_view); relativeLayout = (RelativeLayout) itemView.findViewById(R.id.img_view); textView2 = (TextView) itemView.findViewById(R.id.textView); } } } **MyActivity.java** public class MyActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); MyAdapter adapter = new MyAdapter(this, Data.getData(this)); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new GridLayoutManager(this,1)); } } **activity_my.xml** <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" > <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="wrap_content"> </android.support.v7.widget.RecyclerView> </android.support.design.widget.CoordinatorLayout> and **fragment_layout.xml** <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/fragment_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" > <RelativeLayout android:id="@+id/fragment_img" android:layout_width="100dp" android:layout_height="100dp" android:layout_gravity="center" android:rotation="180" android:layout_centerVertical="true" android:layout_centerHorizontal="true"> <TextView android:id="@+id/fragment_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:rotation="180" android:textSize="20sp" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> </RelativeLayout> </RelativeLayout>
0debug
sh: 1: Syntax error: "(" unexpected python : I'm executing an awk which looks like this. `awk '{if(l1){print ($2-l1)/1024" kB/s",($10-l2)/1024" kB/s"} else{l1=$2; l2=$10;}}' <(grep eth0 /proc/net/dev) <(sleep 1; grep eth0 /proc/net/dev)` and I always got the `sh: 1: Syntax error: "(" unexpected` I tried writing it as a .sh file, and tried the different shebang lines. I need to create a script that will execute this. Somebody ? please, thanks
0debug
Java Binary Input / Output Help ( write to and read) : <p>I have to create a main program that will do the following. Create a single object of the class type that you added to your project. Write that single object to the binary file. After the data has been written, open the file to read and load the data back in. Print the data that was read from the file to demonstrate that the file can be read.</p> <p>Is there anyone that is able to help? </p>
0debug
what does this mean < die("Connection failed: " . $conn->connect_error); > : <p>I got to know this while learning PHP and I don't exactly know what is this used for, and this is while connecting to database</p>
0debug
What is difference in <? and <?php : <p>I've got some old legacy code written in PHP 5.3. </p> <p>All PHP blocks in this code are like</p> <pre><code>&lt;? some_php_code_here ?&gt; </code></pre> <p>and my Apache just ignores them, while works good with</p> <pre><code>&lt;?php some_php_code_here ?&gt; </code></pre> <p>Why old code contains invalid blocks, and why this old code works good on old server ? It's really hard to google something with so much special symbols, sorry for stupid question</p>
0debug
static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) { const char *filename = qemu_opt_get(opts, "path"); CharDriverState *chr; int fd; fd = open(filename, O_RDWR); if (fd < 0) return NULL; chr = g_malloc0(sizeof(CharDriverState)); chr->opaque = (void *)(intptr_t)fd; chr->chr_write = null_chr_write; chr->chr_ioctl = pp_ioctl; return chr; }
1threat
Uncaught Reference Error - $ is not defined + JQuery not defined : <p>I have been struggling to understand the errors on this page. Can someone help me and show me how to fix this page.</p> <p><a href="https://www.caternow.com.au/richmond-3121-caterers/Fabulous-Catering" rel="nofollow">https://www.caternow.com.au/richmond-3121-caterers/Fabulous-Catering</a></p> <p>It doesn't load properly and gives following error.</p> <ul> <li>Uncaught Reference Error - $ is not defined </li> <li>Uncaught Reference Error - JQuery is not defined </li> </ul> <p>While the same code and same css/js works fine at below test site.</p> <p><a href="http://cater2.tecexperts.com/richmond-3121-caterers/Fabulous-Catering" rel="nofollow">http://cater2.tecexperts.com/richmond-3121-caterers/Fabulous-Catering</a></p> <p>Any help is appreciated.</p> <p>Thanks, DK</p>
0debug
How to do Facebook Messenger Bot development locally? : <p>When setting webhooks, it's saying a <code>Secure URL</code> is required.</p>
0debug
script that log in mysql detects my password as a database : I am a noob in bash scripting, and i want to do a script that log in mySql for me: PASSWORD="MyPassword" sudo service mysql start mysql -u root -p $PASSWORD The problem is that it not works, and it no login, only throws an error telling that my password ($PASSWORD) is not a database. Are there any way to do it? Thanks and sorry if I am asking something RTFM or UTFM.
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
Relaunch the current Activity after Login Activity in Andoid : In my application when i click proceed button it checks weather user is logged in or not if user is logged in it goes to next page with all recorded information on the activity but if user is not logged in i have to launch login activity and than after login next step will be proceeded. But the problem is that after login success i am firing an intent for the app home page which i don't want to do, i want that whatever activity is currently open it should open the same after login success.
0debug
how to share captured bitmap image(via camera) pass between one fragment two another fragment in android : I tried lot to capture image via camera pass one fragment to another fragment I tried several ways but I cannot do that please help me do that. used intent and sharedpreference app closing
0debug
jquery returning object instead of id : <p>i have</p> <pre><code>&lt;li class="live_item" data-id="1"&gt; &lt;span class="number"&gt;1&lt;/span&gt; &lt;i class="fa fa-television" aria-hidden="true"&gt;&lt;/i&gt; &lt;label&gt;Test&lt;/label&gt; &lt;/li&gt; </code></pre> <p>And this</p> <pre><code>$(".live_item").on("click",function(){ alert($($(this).data("id"))); }); </code></pre> <p>Can you tell my why it is retuning an object and not the number 1? What i'm doing wrong?</p>
0debug
alert('Hello ' + user_input);
1threat
What is difference b/w "string" and string in javascript : I was reading you dont know js(Up and going) and i stumbled across this piece of line The return value from the typeof operator is always one of six (seven as of ES6!) string values. That is, typeof "abc" returns "string", not string. I am unable to understand diffence b/w "string" and string. Whenever i check any typeof for a string value, the value is "string". Can I get help in understanding this
0debug
Why the answer is 26 for this code? : public class Program { public static void main(String[] args) { int x=1; for(;x<6;x++) x=x*x; System.out.printf("%d",x); } } I have been learning java for months. What I'm amazed I have found this kind of a set question in sololearn and I have proved myself the answer is 26. I understand the normal for loop how it works, but I don't understand this kind of format.
0debug
static int img_snapshot(int argc, char **argv) { BlockDriverState *bs; QEMUSnapshotInfo sn; char *filename, *snapshot_name = NULL; int c, ret = 0, bdrv_oflags; int action = 0; qemu_timeval tv; bool quiet = false; bdrv_oflags = BDRV_O_FLAGS | BDRV_O_RDWR; for(;;) { c = getopt(argc, argv, "la:c:d:hq"); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); return 0; case 'l': if (action) { help(); return 0; } action = SNAPSHOT_LIST; bdrv_oflags &= ~BDRV_O_RDWR; break; case 'a': if (action) { help(); return 0; } action = SNAPSHOT_APPLY; snapshot_name = optarg; break; case 'c': if (action) { help(); return 0; } action = SNAPSHOT_CREATE; snapshot_name = optarg; break; case 'd': if (action) { help(); return 0; } action = SNAPSHOT_DELETE; snapshot_name = optarg; break; case 'q': quiet = true; break; } } if (optind != argc - 1) { help(); } filename = argv[optind++]; bs = bdrv_new_open(filename, NULL, bdrv_oflags, true, quiet); if (!bs) { return 1; } switch(action) { case SNAPSHOT_LIST: dump_snapshots(bs); break; case SNAPSHOT_CREATE: memset(&sn, 0, sizeof(sn)); pstrcpy(sn.name, sizeof(sn.name), snapshot_name); qemu_gettimeofday(&tv); sn.date_sec = tv.tv_sec; sn.date_nsec = tv.tv_usec * 1000; ret = bdrv_snapshot_create(bs, &sn); if (ret) { error_report("Could not create snapshot '%s': %d (%s)", snapshot_name, ret, strerror(-ret)); } break; case SNAPSHOT_APPLY: ret = bdrv_snapshot_goto(bs, snapshot_name); if (ret) { error_report("Could not apply snapshot '%s': %d (%s)", snapshot_name, ret, strerror(-ret)); } break; case SNAPSHOT_DELETE: ret = bdrv_snapshot_delete(bs, snapshot_name); if (ret) { error_report("Could not delete snapshot '%s': %d (%s)", snapshot_name, ret, strerror(-ret)); } break; } bdrv_unref(bs); if (ret) { return 1; } return 0; }
1threat
static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data, const char *json_string, va_list *ap) { visitor_input_teardown(data, NULL); data->obj = qobject_from_jsonv(json_string, ap); g_assert(data->obj); data->qiv = qobject_input_visitor_new(data->obj); g_assert(data->qiv); return data->qiv; }
1threat
static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) { MpegEncContext *s = &v->s; DSPContext *dsp = &v->s.dsp; uint8_t *srcY; int dxy, mx, my, src_x, src_y; int off; int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0; int v_edge_pos = s->v_edge_pos >> v->field_mode; if (!v->field_mode && !v->s.last_picture.f.data[0]) return; mx = s->mv[dir][n][0]; my = s->mv[dir][n][1]; if (!dir) { if (v->field_mode) { if ((v->cur_field_type != v->ref_field_type[dir]) && v->cur_field_type) srcY = s->current_picture.f.data[0]; else srcY = s->last_picture.f.data[0]; } else srcY = s->last_picture.f.data[0]; } else srcY = s->next_picture.f.data[0]; if (v->field_mode) { if (v->cur_field_type != v->ref_field_type[dir]) my = my - 2 + 4 * v->cur_field_type; } if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) { int same_count = 0, opp_count = 0, k; int chosen_mv[2][4][2], f; int tx, ty; for (k = 0; k < 4; k++) { f = v->mv_f[0][s->block_index[k] + v->blocks_off]; chosen_mv[f][f ? opp_count : same_count][0] = s->mv[0][k][0]; chosen_mv[f][f ? opp_count : same_count][1] = s->mv[0][k][1]; opp_count += f; same_count += 1 - f; } f = opp_count > same_count; switch (f ? opp_count : same_count) { case 4: tx = median4(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0], chosen_mv[f][3][0]); ty = median4(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1], chosen_mv[f][3][1]); break; case 3: tx = mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]); ty = mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]); break; case 2: tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2; ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2; break; } s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; for (k = 0; k < 4; k++) v->mv_f[1][s->block_index[k] + v->blocks_off] = f; } if (v->fcm == ILACE_FRAME) { int qx, qy; int width = s->avctx->coded_width; int height = s->avctx->coded_height >> 1; qx = (s->mb_x * 16) + (mx >> 2); qy = (s->mb_y * 8) + (my >> 3); if (qx < -17) mx -= 4 * (qx + 17); else if (qx > width) mx -= 4 * (qx - width); if (qy < -18) my -= 8 * (qy + 18); else if (qy > height + 1) my -= 8 * (qy - height - 1); } if ((v->fcm == ILACE_FRAME) && fieldmv) off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8; else off = s->linesize * 4 * (n & 2) + (n & 1) * 8; if (v->field_mode && v->cur_field_type) off += s->current_picture_ptr->f.linesize[0]; src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2); if (!fieldmv) src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2); else src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2); if (v->profile != PROFILE_ADVANCED) { src_x = av_clip(src_x, -16, s->mb_width * 16); src_y = av_clip(src_y, -16, s->mb_height * 16); } else { src_x = av_clip(src_x, -17, s->avctx->coded_width); if (v->fcm == ILACE_FRAME) { if (src_y & 1) src_y = av_clip(src_y, -17, s->avctx->coded_height + 1); else src_y = av_clip(src_y, -18, s->avctx->coded_height); } else { src_y = av_clip(src_y, -18, s->avctx->coded_height + 1); } } srcY += src_y * s->linesize + src_x; if (v->field_mode && v->ref_field_type[dir]) srcY += s->current_picture_ptr->f.linesize[0]; if (fieldmv && !(src_y & 1)) v_edge_pos--; if (fieldmv && (src_y & 1) && src_y < 4) src_y--; if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) || s->h_edge_pos < 13 || v_edge_pos < 23 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2 || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) { srcY -= s->mspel * (1 + (s->linesize << fieldmv)); s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 9 + s->mspel * 2, (9 + s->mspel * 2) << fieldmv, src_x - s->mspel, src_y - (s->mspel << fieldmv), s->h_edge_pos, v_edge_pos); srcY = s->edge_emu_buffer; if (v->rangeredfrm) { int i, j; uint8_t *src; src = srcY; for (j = 0; j < 9 + s->mspel * 2; j++) { for (i = 0; i < 9 + s->mspel * 2; i++) src[i] = ((src[i] - 128) >> 1) + 128; src += s->linesize << fieldmv; } } if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; uint8_t *src; src = srcY; for (j = 0; j < 9 + s->mspel * 2; j++) { for (i = 0; i < 9 + s->mspel * 2; i++) src[i] = v->luty[src[i]]; src += s->linesize << fieldmv; } } srcY += s->mspel * (1 + (s->linesize << fieldmv)); } if (s->mspel) { dxy = ((my & 3) << 2) | (mx & 3); v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd); } else { dxy = (my & 2) | ((mx & 2) >> 1); if (!v->rnd) dsp->put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); else dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); } }
1threat
Does the C# compiler treat a lambda expression as a public or private method? : <p>Internally, the compiler should be translating lambda expressions to methods. In that case, would these methods be private or public (or something else) and is it possible to change that?</p>
0debug
def merge_dict(d1,d2): d = d1.copy() d.update(d2) return d
0debug
Android sometimes force kills application : <p>I start activity A, then start activity B.<br> I press home button, then waiting long time.<br> When I resume application, it force stopped. </p> <pre><code>02-03 18:42:54.413 828-844/system_process I/ActivityManager: Force stopping ru.tabor.search appid=10089 user=0: from pid 20405 02-03 18:42:54.414 828-844/system_process I/ActivityManager: Killing 30212:ru.tabor.search/u0a89 (adj 7): stop ru.tabor.search 02-03 18:42:54.445 828-5948/system_process I/WindowState: WIN DEATH: Window{18b92c9b u0 ru.tabor.search/ru.tabor.search.modules.authorization.AuthorizationActivity} 02-03 18:42:54.447 828-845/system_process I/WindowState: WIN DEATH: Window{1cd0cfe4 u0 ru.tabor.search/ru.tabor.search.modules.registration.RegistrationActivity} 02-03 18:42:54.519 828-844/system_process I/ActivityManager: Force finishing activity 3 ActivityRecord{25a8977f u0 ru.tabor.search/.modules.authorization.AuthorizationActivity t2593} 02-03 18:42:54.520 828-844/system_process I/ActivityManager: Force finishing activity 3 ActivityRecord{d516838 u0 ru.tabor.search/.modules.registration.RegistrationActivity t2593} 02-03 18:42:54.523 828-20666/system_process W/ActivityManager: Spurious death for ProcessRecord{21ff313b 0:ru.tabor.search/u0a89}, curProc for 30212: null 02-03 18:42:59.890 828-1247/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10100000 cmp=ru.tabor.search/.modules.authorization.AuthorizationActivity} from uid 10089 on display 0 02-03 18:42:59.903 828-1247/system_process V/WindowManager: addAppToken: AppWindowToken{1c4987a0 token=Token{279a08a3 ActivityRecord{9f5afd2 u0 ru.tabor.search/.modules.authorization.AuthorizationActivity t2593}}} to stack=1 task=2593 at 0 02-03 18:42:59.919 828-891/system_process V/WindowManager: Adding window Window{1735e91b u0 Starting ru.tabor.search} at 4 of 8 (after Window{2ab6bf53 u0 com.cleanmaster.mguard/com.keniu.security.main.MainActivity}) 02-03 18:43:19.288 828-1673/system_process I/ActivityManager: Start proc 21366:ru.tabor.search/u0a89 for activity ru.tabor.search/.modules.authorization.AuthorizationActivity </code></pre> <p>How to fix it?</p>
0debug
replacing for loop with while in C : <p>i am trying to make a code that searchs for a "for" loop in the input file, replace it with its "while" equivalent, leaving the rest untouched, and create a new output file with the new code, i need ideas and some help, i dont exactly expect someone else to do it. (remember, there may be another for loop inside a for loop) ex.</p> <pre><code>for(i=0;i&lt;10;i++) { some stuff here; } </code></pre> <p>to</p> <pre><code>i=0; while(i&lt;10) { the exact same stuff here; i++; } </code></pre> <p>or</p> <pre><code>for(X;Y;Z) { K; } </code></pre> <p>to</p> <pre><code>A; while(Y) { K; Z; } </code></pre>
0debug
Setup Localhost and Wamp Server : <p>I need to setup localhost and wamp server on windows 10, can anybody point me to good website or youtube channel please. Thanks</p>
0debug
how to keep opened developer tools while running a selenium nightwatch.js test? : <p>I am starting to write e2e tests using nightwatch.js and I noticed some errors that I would like to inspect manually in the target browser's console (developer tools). but always when I open the developer console, it is automatically closed by the browser. is this a intended feature of either selenium or nightwatch.js, and, if it is the case, how can I disable it? </p>
0debug
static int slirp_guestfwd(SlirpState *s, const char *config_str, int legacy_format) { struct in_addr server = { .s_addr = 0 }; struct GuestFwd *fwd; const char *p; char buf[128]; char *end; int port; p = config_str; if (legacy_format) { if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } } else { if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (strcmp(buf, "tcp") && buf[0] != '\0') { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (buf[0] != '\0' && !inet_aton(buf, &server)) { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, '-') < 0) { goto fail_syntax; } } port = strtol(buf, &end, 10); if (*end != '\0' || port < 1 || port > 65535) { goto fail_syntax; } fwd = g_malloc(sizeof(struct GuestFwd)); snprintf(buf, sizeof(buf), "guestfwd.tcp.%d", port); if ((strlen(p) > 4) && !strncmp(p, "cmd:", 4)) { if (slirp_add_exec(s->slirp, 0, &p[4], &server, port) < 0) { error_report("conflicting/invalid host:port in guest forwarding " "rule '%s'", config_str); g_free(fwd); return -1; } } else { fwd->hd = qemu_chr_new(buf, p, NULL); if (!fwd->hd) { error_report("could not open guest forwarding device '%s'", buf); g_free(fwd); return -1; } if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) { error_report("conflicting/invalid host:port in guest forwarding " "rule '%s'", config_str); g_free(fwd); return -1; } fwd->server = server; fwd->port = port; fwd->slirp = s->slirp; qemu_chr_fe_claim_no_fail(fwd->hd); qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read, NULL, fwd); } return 0; fail_syntax: error_report("invalid guest forwarding rule '%s'", config_str); return -1; }
1threat
ebml_read_ascii (MatroskaDemuxContext *matroska, uint32_t *id, char **str) { ByteIOContext *pb = matroska->ctx->pb; int size, res; uint64_t rlength; if ((res = ebml_read_element_id(matroska, id, NULL)) < 0 || (res = ebml_read_element_length(matroska, &rlength)) < 0) return res; size = rlength; if (size < 0 || !(*str = av_malloc(size + 1))) { av_log(matroska->ctx, AV_LOG_ERROR, "Memory allocation failed\n"); return AVERROR(ENOMEM); } if (get_buffer(pb, (uint8_t *) *str, size) != size) { offset_t pos = url_ftell(pb); av_log(matroska->ctx, AV_LOG_ERROR, "Read error at pos. %"PRIu64" (0x%"PRIx64")\n", pos, pos); return AVERROR(EIO); } (*str)[size] = '\0'; return 0; }
1threat
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad) { AVFilterLink *link; if (src->nb_outputs <= srcpad || dst->nb_inputs <= dstpad || src->outputs[srcpad] || dst->inputs[dstpad]) return -1; if (src->output_pads[srcpad].type != dst->input_pads[dstpad].type) { av_log(src, AV_LOG_ERROR, "Media type mismatch between the '%s' filter output pad %d and the '%s' filter input pad %d\n", src->name, srcpad, dst->name, dstpad); return AVERROR(EINVAL); } src->outputs[srcpad] = dst-> inputs[dstpad] = link = av_mallocz(sizeof(AVFilterLink)); link->src = src; link->dst = dst; link->srcpad = &src->output_pads[srcpad]; link->dstpad = &dst->input_pads[dstpad]; link->type = src->output_pads[srcpad].type; assert(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1); link->format = -1; return 0; }
1threat
android can't show bitmap in imageView : I try show bitmap from gallery url.this is my url file:///storage/emulated/0/DCIM/Camera/IMG_20161103_180603.jpg I know how to get bitmap with onActivityResult,but i don't know how i get bitmap at the moment this is my source final ImageView imageView=(ImageView)findViewById(R.id.imageView); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; final Bitmap bitmap = BitmapFactory.decodeFile("file:///storage/emulated/0/DCIM/Camera/IMG_20161103_180603.jpg", options); runOnUiThread(new Runnable() { @Override public void run() { imageView.setImageBitmap(bitmap); } }); how i can solve my problem? thanks
0debug
static void coroutine_fn nest(void *opaque) { NestData *nd = opaque; nd->n_enter++; if (nd->n_enter < nd->max) { Coroutine *child; child = qemu_coroutine_create(nest); qemu_coroutine_enter(child, nd); } nd->n_return++; }
1threat
call service from diffrenent component to display a message : I have a a shared comPonent alert wHich display different alerts (error, success..) that uses a service alertService. and I have diffeent component that uses the alertServices. the alert component is called in the appComponent <app-alert></app-alert> when I call the service from another component the alert don't displayed it displyaed only when I call <app-alert></app-alert> in the component that call the service.
0debug
void pci_default_write_config(PCIDevice *d, uint32_t address, uint32_t val, int len) { int can_write, i; uint32_t end, addr; if (len == 4 && ((address >= 0x10 && address < 0x10 + 4 * 6) || (address >= 0x30 && address < 0x34))) { PCIIORegion *r; int reg; if ( address >= 0x30 ) { reg = PCI_ROM_SLOT; }else{ reg = (address - 0x10) >> 2; } r = &d->io_regions[reg]; if (r->size == 0) goto default_config; if (reg == PCI_ROM_SLOT) { val &= (~(r->size - 1)) | 1; } else { val &= ~(r->size - 1); val |= r->type; } *(uint32_t *)(d->config + address) = cpu_to_le32(val); pci_update_mappings(d); return; } default_config: addr = address; for(i = 0; i < len; i++) { switch(d->config[0x0e]) { case 0x00: case 0x80: switch(addr) { case 0x00: case 0x01: case 0x02: case 0x03: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0e: case 0x10 ... 0x27: case 0x2c ... 0x2f: case 0x30 ... 0x33: case 0x3d: can_write = 0; break; default: can_write = 1; break; } break; default: case 0x01: switch(addr) { case 0x00: case 0x01: case 0x02: case 0x03: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0e: case 0x2c ... 0x2f: case 0x38 ... 0x3b: case 0x3d: can_write = 0; break; default: can_write = 1; break; } break; } if (can_write) { switch (addr) { case 0x05: val &= ~PCI_COMMAND_RESERVED_MASK_HI; break; case 0x06: val &= ~PCI_STATUS_RESERVED_MASK_LO; break; case 0x07: val &= ~PCI_STATUS_RESERVED_MASK_HI; break; } d->config[addr] = val; } if (++addr > 0xff) break; val >>= 8; } end = address + len; if (end > PCI_COMMAND && address < (PCI_COMMAND + 2)) { pci_update_mappings(d); } }
1threat
void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event) { VirtQueueElement *elem; unsigned have, need; int i, len; if (!vinput->active) { return; } if (vinput->qindex == vinput->qsize) { vinput->qsize++; vinput->queue = g_realloc(vinput->queue, vinput->qsize * sizeof(virtio_input_event)); } vinput->queue[vinput->qindex++] = *event; if (event->type != cpu_to_le16(EV_SYN) || event->code != cpu_to_le16(SYN_REPORT)) { return; } need = sizeof(virtio_input_event) * vinput->qindex; virtqueue_get_avail_bytes(vinput->evt, &have, NULL, need, 0); if (have < need) { vinput->qindex = 0; trace_virtio_input_queue_full(); return; } for (i = 0; i < vinput->qindex; i++) { elem = virtqueue_pop(vinput->evt, sizeof(VirtQueueElement)); if (!elem) { fprintf(stderr, "%s: Huh? No vq elem available ...\n", __func__); return; } len = iov_from_buf(elem->in_sg, elem->in_num, 0, vinput->queue+i, sizeof(virtio_input_event)); virtqueue_push(vinput->evt, elem, len); g_free(elem); } virtio_notify(VIRTIO_DEVICE(vinput), vinput->evt); vinput->qindex = 0; }
1threat
static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ int delay = FFMAX(st->codec->has_b_frames, !!st->codec->max_b_frames); int num, den, frame_size, i; av_dlog(s, "compute_pkt_fields2: pts:%"PRId64" dts:%"PRId64" cur_dts:%"PRId64" b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, delay, pkt->size, pkt->stream_index); if (pkt->duration == 0) { compute_frame_duration(&num, &den, st, NULL, pkt); if (den && num) { pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den * st->codec->ticks_per_frame, den * (int64_t)st->time_base.num); } } if(pkt->pts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && delay==0) pkt->pts= pkt->dts; if((pkt->pts == 0 || pkt->pts == AV_NOPTS_VALUE) && pkt->dts == AV_NOPTS_VALUE && !delay){ pkt->dts= pkt->pts= st->pts.val; } if(pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY){ st->pts_buffer[0]= pkt->pts; for(i=1; i<delay+1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++) st->pts_buffer[i]= pkt->pts + (i-delay-1) * pkt->duration; for(i=0; i<delay && st->pts_buffer[i] > st->pts_buffer[i+1]; i++) FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i+1]); pkt->dts= st->pts_buffer[0]; } if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) && st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)){ av_log(s, AV_LOG_ERROR, "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %"PRId64" >= %"PRId64"\n", st->index, st->cur_dts, pkt->dts); return AVERROR(EINVAL); } if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts){ av_log(s, AV_LOG_ERROR, "pts < dts in stream %d\n", st->index); return AVERROR(EINVAL); } st->cur_dts= pkt->dts; st->pts.val= pkt->dts; switch (st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: frame_size = get_audio_frame_size(st->codec, pkt->size); if (frame_size >= 0 && (pkt->size || st->pts.num!=st->pts.den>>1 || st->pts.val)) { frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); } break; case AVMEDIA_TYPE_VIDEO: frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num); break; default: break; } return 0; }
1threat
static int write_abst(AVFormatContext *s, OutputStream *os, int final) { HDSContext *c = s->priv_data; AVIOContext *out; char filename[1024], temp_filename[1024]; int i, ret; int64_t asrt_pos, afrt_pos; int start = 0, fragments; int index = s->streams[os->first_stream]->id; int64_t cur_media_time = 0; if (c->window_size) start = FFMAX(os->nb_fragments - c->window_size, 0); fragments = os->nb_fragments - start; if (final) cur_media_time = os->last_ts; else if (os->nb_fragments) cur_media_time = os->fragments[os->nb_fragments - 1]->start_time; snprintf(filename, sizeof(filename), "%s/stream%d.abst", s->filename, index); snprintf(temp_filename, sizeof(temp_filename), "%s/stream%d.abst.tmp", s->filename, index); ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", temp_filename); return ret; } avio_wb32(out, 0); avio_wl32(out, MKTAG('a','b','s','t')); avio_wb32(out, 0); avio_wb32(out, os->fragment_index - 1); avio_w8(out, final ? 0 : 0x20); avio_wb32(out, 1000); avio_wb64(out, cur_media_time); avio_wb64(out, 0); avio_w8(out, 0); avio_w8(out, 0); avio_w8(out, 0); avio_w8(out, 0); avio_w8(out, 0); avio_w8(out, 1); asrt_pos = avio_tell(out); avio_wb32(out, 0); avio_wl32(out, MKTAG('a','s','r','t')); avio_wb32(out, 0); avio_w8(out, 0); avio_wb32(out, 1); avio_wb32(out, 1); avio_wb32(out, final ? (os->fragment_index - 1) : 0xffffffff); update_size(out, asrt_pos); avio_w8(out, 1); afrt_pos = avio_tell(out); avio_wb32(out, 0); avio_wl32(out, MKTAG('a','f','r','t')); avio_wb32(out, 0); avio_wb32(out, 1000); avio_w8(out, 0); avio_wb32(out, fragments); for (i = start; i < os->nb_fragments; i++) { avio_wb32(out, os->fragments[i]->n); avio_wb64(out, os->fragments[i]->start_time); avio_wb32(out, os->fragments[i]->duration); } update_size(out, afrt_pos); update_size(out, 0); avio_close(out); return ff_rename(temp_filename, filename); }
1threat
django QueryDict only returns the last value of a list : <p>Using django 1.8, I'm observing something strange. Here is my javascript:</p> <pre><code>function form_submit(){ var form = $('#form1_id'); request = $.post($(this).attr('action'), form.serialize(), function(response){ if(response.indexOf('Success') &gt;= 0){ alert(response); } },'text') .fail(function() { alert("Failed to save!"); }); return false; } </code></pre> <p>and here are the parameters displayed in views.py</p> <pre><code>print request.POST &lt;QueryDict: {u'form_4606-name': [u''], u'form_4606-parents': [u'4603', u'2231', u'2234']}&gt; </code></pre> <p>but I cannot extract the parents:</p> <pre><code>print request.POST['form_4606-parents'] 2234 </code></pre> <p>Why is it just giving me the last value? I think there is something wrong with the serialization, but I just cannot figure out how to resolve this.</p>
0debug
int av_parse_time(int64_t *timeval, const char *timestr, int duration) { const char *p; int64_t t; struct tm dt = { 0 }; int i; static const char * const date_fmt[] = { "%Y-%m-%d", "%Y%m%d", }; static const char * const time_fmt[] = { "%H:%M:%S", "%H%M%S", }; const char *q; int is_utc, len; char lastch; int negative = 0; #undef time time_t now = time(0); len = strlen(timestr); if (len > 0) lastch = timestr[len - 1]; else lastch = '\0'; is_utc = (lastch == 'z' || lastch == 'Z'); p = timestr; q = NULL; if (!duration) { if (!av_strncasecmp(timestr, "now", len)) { *timeval = (int64_t) now * 1000000; return 0; } for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) { q = small_strptime(p, date_fmt[i], &dt); if (q) { break; } } if (!q) { if (is_utc) { dt = *gmtime(&now); } else { dt = *localtime(&now); } dt.tm_hour = dt.tm_min = dt.tm_sec = 0; } else { p = q; } if (*p == 'T' || *p == 't' || *p == ' ') p++; for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) { q = small_strptime(p, time_fmt[i], &dt); if (q) { break; } } } else { if (p[0] == '-') { negative = 1; ++p; } q = small_strptime(p, time_fmt[0], &dt); if (!q) { dt.tm_sec = strtol(p, (void *)&q, 10); if (q == p) { *timeval = INT64_MIN; return AVERROR(EINVAL); } dt.tm_min = 0; dt.tm_hour = 0; } } if (!q) { *timeval = INT64_MIN; return AVERROR(EINVAL); } if (duration) { t = dt.tm_hour * 3600 + dt.tm_min * 60 + dt.tm_sec; } else { dt.tm_isdst = -1; if (is_utc) { t = av_timegm(&dt); } else { t = mktime(&dt); } } t *= 1000000; if (*q == '.') { int val, n; q++; for (val = 0, n = 100000; n >= 1; n /= 10, q++) { if (!isdigit(*q)) break; val += n * (*q - '0'); } t += val; } *timeval = negative ? -t : t; return 0; }
1threat
static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val) { ppc4xx_sdram_t *sdram; sdram = opaque; switch (dcrn) { case SDRAM0_CFGADDR: sdram->addr = val; break; case SDRAM0_CFGDATA: switch (sdram->addr) { case 0x00: sdram->besr0 &= ~val; break; case 0x08: sdram->besr1 &= ~val; break; case 0x10: sdram->bear = val; break; case 0x20: val &= 0xFFE00000; if (!(sdram->cfg & 0x80000000) && (val & 0x80000000)) { #ifdef DEBUG_SDRAM printf("%s: enable SDRAM controller\n", __func__); #endif sdram_map_bcr(sdram); sdram->status &= ~0x80000000; } else if ((sdram->cfg & 0x80000000) && !(val & 0x80000000)) { #ifdef DEBUG_SDRAM printf("%s: disable SDRAM controller\n", __func__); #endif sdram_unmap_bcr(sdram); sdram->status |= 0x80000000; } if (!(sdram->cfg & 0x40000000) && (val & 0x40000000)) sdram->status |= 0x40000000; else if ((sdram->cfg & 0x40000000) && !(val & 0x40000000)) sdram->status &= ~0x40000000; sdram->cfg = val; break; case 0x24: break; case 0x30: sdram->rtr = val & 0x3FF80000; break; case 0x34: sdram->pmit = (val & 0xF8000000) | 0x07C00000; break; case 0x40: sdram_set_bcr(&sdram->bcr[0], val, sdram->cfg & 0x80000000); break; case 0x44: sdram_set_bcr(&sdram->bcr[1], val, sdram->cfg & 0x80000000); break; case 0x48: sdram_set_bcr(&sdram->bcr[2], val, sdram->cfg & 0x80000000); break; case 0x4C: sdram_set_bcr(&sdram->bcr[3], val, sdram->cfg & 0x80000000); break; case 0x80: sdram->tr = val & 0x018FC01F; break; case 0x94: sdram->ecccfg = val & 0x00F00000; break; case 0x98: val &= 0xFFF0F000; if (sdram->eccesr == 0 && val != 0) qemu_irq_raise(sdram->irq); else if (sdram->eccesr != 0 && val == 0) qemu_irq_lower(sdram->irq); sdram->eccesr = val; break; default: break; } break; } }
1threat
How can I use is_authenticated() in django to redirect user to their own page? : <p>I am a beginner in django framework. I would to make my website to redirect users to the personal page if they already logged at the time they request the homepage like many websites. </p>
0debug
Swift - Change iPhone backround : I was thinking about changing iPhone background using app. Is there some code in Swift to change iPhone background ? I was trying to find something on the Google but nothing. I don´t mean change backround of app. I mean change bavkground totally of the iPhone. Thank you for evry help.
0debug
i have this error but i don't even know why ?! please help me : i have this error at line 3 (sup_id) however i don't know why? it should be correct right ?? this SQL language (DATABASE) ,i tried changing the name and the type everything nothing worked this part of my work for college project i will be thankfull for the help create table supplier ( sup_id number (12), contact number (12), Name varchar2 (30) NOT NULL, constraint id_pk primary key (sup_id)); at line 3 it says error
0debug
Retrieving all received messages of a particular user in Firebase : <p>How can I retrieve all received messages of a particular user from Firebase database?</p>
0debug
vcard_emul_mirror_card(VReader *vreader) { PK11GenericObject *firstObj, *thisObj; int cert_count; unsigned char **certs; int *cert_len; VCardKey **keys; PK11SlotInfo *slot; PRBool ret; slot = vcard_emul_reader_get_slot(vreader); if (slot == NULL) { return NULL; } firstObj = PK11_FindGenericObjects(slot, CKO_CERTIFICATE); if (firstObj == NULL) { return NULL; } cert_count = 0; for (thisObj = firstObj; thisObj; thisObj = PK11_GetNextGenericObject(thisObj)) { cert_count++; } if (cert_count == 0) { PK11_DestroyGenericObjects(firstObj); return NULL; } ret = vcard_emul_alloc_arrays(&certs, &cert_len, &keys, cert_count); if (ret == PR_FALSE) { return NULL; } cert_count = 0; for (thisObj = firstObj; thisObj; thisObj = PK11_GetNextGenericObject(thisObj)) { SECItem derCert; CERTCertificate *cert; SECStatus rv; rv = PK11_ReadRawAttribute(PK11_TypeGeneric, thisObj, CKA_VALUE, &derCert); if (rv != SECSuccess) { continue; } cert = CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &derCert, NULL, PR_FALSE, PR_TRUE); SECITEM_FreeItem(&derCert, PR_FALSE); if (cert == NULL) { continue; } certs[cert_count] = cert->derCert.data; cert_len[cert_count] = cert->derCert.len; keys[cert_count] = vcard_emul_make_key(slot, cert); cert_count++; CERT_DestroyCertificate(cert); } return vcard_emul_make_card(vreader, certs, cert_len, keys, cert_count); }
1threat
Does PHP have to go along with SQL? : <p>I have been researching Sql, Django, PhP,</p> <p>I saw this one tutorial on creating a social network website and they were using SQL in conjunction with PHP. Is this always required? What does the PHP do for the SQL? I know it is a server side, but isn't Django as well? So I can use Django/SQL instead of PHP/SQL?</p>
0debug
Array push with multidimensional array : <p>I have this multidimentional array:</p> <pre><code>array(1) { [0]=&gt; array(1) { ["service"]=&gt; string(3) "top" } } </code></pre> <p>and I want to push to the inner array the string below</p> <pre><code>string(3) "443" </code></pre> <p>the string above I got it from an array using array_shift</p> <pre><code>$id = array_shift($_POST['updateIDs']); </code></pre> <p>so it can become like this:</p> <pre><code>array(1) { [0]=&gt; array(1) { ["service"]=&gt; string(3) "top" ['id']=&gt;'443' } } </code></pre> <p>I think it must be done with array_push and foreach...i tried but I could not.</p>
0debug
ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[]) { int c; unsigned long long v; Error *errp = NULL; while ((c = getopt(argc, argv, "h" "v" "F" "p:" "S:" "m:" "l:" "n:" )) != -1) { switch (c) { case 'h': ivshmem_server_usage(argv[0], 0); break; case 'v': args->verbose = 1; break; case 'F': args->foreground = 1; break; case 'p': args->pid_file = strdup(optarg); break; case 'S': args->unix_socket_path = strdup(optarg); break; case 'm': args->shm_path = strdup(optarg); break; case 'l': parse_option_size("shm_size", optarg, &args->shm_size, &errp); if (errp) { fprintf(stderr, "cannot parse shm size: %s\n", error_get_pretty(errp)); error_free(errp); ivshmem_server_usage(argv[0], 1); } break; case 'n': if (parse_uint_full(optarg, &v, 0) < 0) { fprintf(stderr, "cannot parse n_vectors\n"); ivshmem_server_usage(argv[0], 1); } args->n_vectors = v; break; default: ivshmem_server_usage(argv[0], 1); break; } } if (args->n_vectors > IVSHMEM_SERVER_MAX_VECTORS) { fprintf(stderr, "too many requested vectors (max is %d)\n", IVSHMEM_SERVER_MAX_VECTORS); ivshmem_server_usage(argv[0], 1); } if (args->verbose == 1 && args->foreground == 0) { fprintf(stderr, "cannot use verbose in daemon mode\n"); ivshmem_server_usage(argv[0], 1); } }
1threat
auto generated value for primary key with primary numbers : I want to make auto generated value for primary key with primary numbers for example I have this table where `id` is the primary key: tags_table : id | name --------- 2 | some_text 3 | some_text 5 | some_text ... 997| some_text when ever new row inserted it will get the next primary number for the `id` . **is** there a way to achieve this in mysql or any other RDBMS ? if so **how** ?
0debug
Powershell script to validate if file exist and copy : Basically what I'm trying to do is validate using .csv if file exist in the folder copy to new location. If file doesn't exist create text file with missing items. This is what i currently have. It lacks in copying file that exist. Import-Csv .\files.csv | ForEach { If (Test-Path -Path $_.File) { Write-Output "$($_.File) exists" } Else { Write-Output "$($_.File) does NOT exist" $_.File | Out-File .\missingFiles.txt -Append } }
0debug
Github Pages site not detecting index.html : <p>I created a github pages repository. For some reason when I give <a href="https://[username].github.io/" rel="noreferrer">https://[username].github.io/</a>, it doesn't work. But is works when I give <a href="https://[username].github.io/index.html" rel="noreferrer">https://[username].github.io/index.html</a>. Whys is it not detecting index.html.</p>
0debug
Using self join on a table to compare two fields based on a linked field in the same table : I have the following: TableA ID|DocumentType|DocumentCode|DocumentDate|Warehouse|RefecenceCode| 1 |DeliveryNote| DOC-001 | 2017-04-21 | 1 | NULL | 2 |Invoice | DOC-002 | 2017-04-21 | 2 | DOC-001 | As you can see, the warehouse is different on each document and DOC-002 is related to DOC-001 through the information in `ReferenceCode` column (which means that was created starting from DOC-001 as a source document). It is supposed for the DOC-002 to have the same information but sometimes might be different and in this case, I was tried to create a query (I thing `self join` applies here) in order to check what information is different in the DOC-002 in this case compared to DOC-001, based on the reference code, but I couldn't managed to do it. If someone could give me a hand, I'll be very grateful. Thanks!
0debug
I am trying a program that is a password generator and I'm having an error that shows: TypeError: can only concatenate list (not "str") to list : <p>I am creating a program that is a password generator and while executing it is showing following error: TypeError: can only concatenate list (not "str") to list I'm new to python and need help regarding this.</p> <pre><code>import random import string adjectives = ['fast', 'slow', 'fat', 'red', 'smelly', 'wet', 'green', 'orange', 'blue', 'white', 'brave', 'purple'] nouns = ['apple', 'dinosaur', 'ball', 'toaster', 'dragon', 'panda', 'team', 'hammer'] print 'Welcome to password picker' adjective = random.choice(adjectives) noun = random.choice(nouns) number = random.randrange(0,100) special_char = random.choice(string.punctuation) password = adjectives + noun + str(number) + special_char print 'Your New Password is : %s' % password </code></pre> <p>It should print randomly generated password like OrangeDinosaur32! etc</p>
0debug
how to change the hint color property dynamically when its unfocsed state? : i need to change hint color property dynamically when its unfocused. Is it possible to change the hint color dynamically(Not in focused state). Actual Design[enter image description here][1] I got [enter image description here][2] [1]: https://i.stack.imgur.com/QP4F1.png [2]: https://i.stack.imgur.com/C7YVX.png i cant change the hint color property programmatically when its unfocused. i am stuck. Is it possible to do? Please help me.
0debug
TSQL Extract far right digits : <p>How can i extract the far right digits out of these strings?</p> <p>Appointment Regional Sales Manager changed from 5 to 6<br> Appointment Regional Sales Manager changed from to 8<br> Appointment Regional Sales Manager changed from 6 to 15<br> Appointment Regional Sales Manager changed from 11 to 16</p>
0debug
Read-Only properties : <p>I need help with "read-only" in swift. I tried various ways, but simply couldn't figure out how to compile it without errors. Here's the question and what i thought of.</p> <p>Create a read-only computed property named isEquilateral that checks to see whether all three sides of a triangle are the same length and returns true if they are and false if they are not.</p> <pre><code>var isEquilateral: Int { } </code></pre>
0debug
Why does iPhone layout look different in xCode and in Emulator : I've been developing a modified version of an iPad application, and try though I might, I've been unable to resolve the following issue. [App, as seen in xCode][1] I'm using a UITableView to display cells of information, however the cells have huge gaps between them in the iPad emulator. [App, as seen in emulator][2] If anyone has any ideas that I could try, I'd be happy to test out any different ideas to resolve the issue. [1]: http://i.stack.imgur.com/4Uapy.png [2]: http://i.stack.imgur.com/EnWTW.png
0debug
Pillow: libopenjp2.so.7: cannot open shared object file: No such file or directory : <p>I have a fresh, minimal Raspbian Stretch install. I have installed the PIXEL-dekstop by running <code>sudo apt-get install --no-install-recommends xserver-xorg </code> and am now trying to use Pillow in Python. Pillow was installed by running <code>sudo apt-get install pip3</code> and then <code>sudo pip3 install Pillow</code>. Whenever I try <code>from PIL import Image</code> I get the error <code>ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory</code>. </p> <p>I have attempted to reinstall Pillow under different versions but it does not help. I have also enabled apt-get sources in <code>/etc/apt/sources.txt</code> and ran <code>sudo apt-get build-dep python-imaging</code>, which also did not help. Any help is appreciated.</p> <p>Python version: 3.5.3, current Pillow version: 4.3.0</p>
0debug
When i run this code with a double it gives an error. An integer works fine what can be changed. : import java.util.*; public class Gramsfunction { public static void main(String[] args) { System.out.println("Input for t for A(t)=1500(1/2)^t/14"); Scanner sc= new Scanner(System.in); double t = sc.nextInt(); double a = 1500; double b = 0.5; double c = 2; double d = 14 ; double e = t /2; double f = 14/2; double g = e / f; double h = c * g; double i = a / d ; double j = c / d; double k = a / ( 15 / 7); double m = Math.pow(c , g); double n = Math.ceil( a / m); System.out.println("The total answer is " + n + " rounded to the nearest" + " tenth gram after " + t + " hours"); System.out.println("The exponent * 2 is " +m); System.out.println(g); } }
0debug
Mysql PHP exention unloaded! Error shows in PHP7 How can i solve it?​ : <pre><code> Mysql PHP exention unloaded! Error shows in PHP7 How can i solve it?​ Version: Windows Server 2012 64-bit XAMPP Version: 7.0.9 Control Panel Version: 3.2.2 </code></pre> <p><a href="http://i.stack.imgur.com/Z9NQQ.png" rel="nofollow">http://i.stack.imgur.com/Z9NQQ.png</a></p>
0debug
Do I need to delete this object? : <p>In MFC application using Direct2D I have very simple code:<br> //in ctor: </p> <pre><code>EnableD2DSupport(); m_pBlackBrush = new CD2DSolidColorBrush(GetRenderTarget(), D2D1::ColorF(D2D1::ColorF::Black)); </code></pre> <p>Now the question is, am I supposed to call delete on m_pBlackBrush? If so where? I've tried to call delete on it in destructor but I'm getting error thrown in my face saying that there is write access violation. Anyone knows if am I supposed to delete this brush or simply leave it (which seems like rather odd idea)?</p>
0debug
Strings as key in Hashmap : <p>I'm newbie with Java Is it possible to convert a String, or a String[] as the keys of an Hashmap? I mean:</p> <pre><code>String keysToConvert = "key1,key2,key3"; </code></pre> <p>into</p> <pre><code>HashMap&lt;String, Double&gt; hashmap = new HashMap&lt;String, Double&gt;(); [apply in some way the keys of the string] hashmap.get("key2"); </code></pre> <p>I know that <code>hashmap.get("key2");</code>has no value in this moment. I just would know if there is a way to load the keys in an HashMap.</p>
0debug
void cpu_dump_state(CPUState *env, FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...), int flags) { #if defined(TARGET_PPC64) || 1 #define FILL "" #define RGPL 4 #define RFPL 4 #else #define FILL " " #define RGPL 8 #define RFPL 4 #endif int i; cpu_fprintf(f, "NIP " REGX " LR " REGX " CTR " REGX "\n", env->nip, env->lr, env->ctr); cpu_fprintf(f, "MSR " REGX FILL " XER %08x TB %08x %08x " #if !defined(CONFIG_USER_ONLY) "DECR %08x" #endif "\n", do_load_msr(env), load_xer(env), cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) #if !defined(CONFIG_USER_ONLY) , cpu_ppc_load_decr(env) #endif ); for (i = 0; i < 32; i++) { if ((i & (RGPL - 1)) == 0) cpu_fprintf(f, "GPR%02d", i); cpu_fprintf(f, " " REGX, env->gpr[i]); if ((i & (RGPL - 1)) == (RGPL - 1)) cpu_fprintf(f, "\n"); } cpu_fprintf(f, "CR "); for (i = 0; i < 8; i++) cpu_fprintf(f, "%01x", env->crf[i]); cpu_fprintf(f, " ["); for (i = 0; i < 8; i++) { char a = '-'; if (env->crf[i] & 0x08) a = 'L'; else if (env->crf[i] & 0x04) a = 'G'; else if (env->crf[i] & 0x02) a = 'E'; cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); } cpu_fprintf(f, " ] " FILL "RES " REGX "\n", env->reserve); for (i = 0; i < 32; i++) { if ((i & (RFPL - 1)) == 0) cpu_fprintf(f, "FPR%02d", i); cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i])); if ((i & (RFPL - 1)) == (RFPL - 1)) cpu_fprintf(f, "\n"); } cpu_fprintf(f, "SRR0 " REGX " SRR1 " REGX " " FILL FILL FILL "SDR1 " REGX "\n", env->spr[SPR_SRR0], env->spr[SPR_SRR1], env->sdr1); #undef REGX #undef RGPL #undef RFPL #undef FILL }
1threat
static inline void RENAME(rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size) { const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif uint16_t *d = (uint16_t *)dst; end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm __volatile( "movq %0, %%mm7\n\t" "movq %1, %%mm6\n\t" ::"m"(red_15mask),"m"(green_15mask)); mm_end = end - 15; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "movd 3%1, %%mm3\n\t" "punpckldq 6%1, %%mm0\n\t" "punpckldq 9%1, %%mm3\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm3, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "psllq $7, %%mm0\n\t" "psllq $7, %%mm3\n\t" "pand %%mm7, %%mm0\n\t" "pand %%mm7, %%mm3\n\t" "psrlq $6, %%mm1\n\t" "psrlq $6, %%mm4\n\t" "pand %%mm6, %%mm1\n\t" "pand %%mm6, %%mm4\n\t" "psrlq $19, %%mm2\n\t" "psrlq $19, %%mm5\n\t" "pand %2, %%mm2\n\t" "pand %2, %%mm5\n\t" "por %%mm1, %%mm0\n\t" "por %%mm4, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "por %%mm5, %%mm3\n\t" "psllq $16, %%mm3\n\t" "por %%mm3, %%mm0\n\t" MOVNTQ" %%mm0, %0\n\t" :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); d += 4; s += 12; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { const int r= *s++; const int g= *s++; const int b= *s++; *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7); } }
1threat
PostgreSQL: Multi-column index and ARRAY : I'm new to database itself and trying to learn PostgreSQL. Question is: Is there a difference between CREATE INDEX the_index ON the_table (column1, column2); and CREATE INDEX the_index ON the_table (ARRAY[column1, column2]); ?
0debug
How to I keep a log of urls when a link is clicked? : <p>I have a link called "Click Me" on 100 pages on my website. When a person clicks this link, I need to be able to write the url of where the click came from into a txt file or send me an email everytime the link is clicked.</p> <p>Any ideas?</p>
0debug
Getting random words using python : <p>Im making a hangman game and instead of having a set list which contains a dozen or so words, I would like to have thousands(maybe millions) of words to my disposal and have python pick a random word. How can I do this without writing each words manually to a list?</p>
0debug
static void gen_sub_carry(TCGv dest, TCGv t0, TCGv t1) { TCGv tmp; tcg_gen_sub_i32(dest, t0, t1); tmp = load_cpu_field(CF); tcg_gen_add_i32(dest, dest, tmp); tcg_gen_subi_i32(dest, dest, 1); dead_tmp(tmp); }
1threat
static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; PCMDecode *s = avctx->priv_data; int sample_size, c, n, i; short *samples; const uint8_t *src, *src8, *src2[MAX_CHANNELS]; uint8_t *dstu8; int16_t *dst_int16_t; int32_t *dst_int32_t; int64_t *dst_int64_t; uint16_t *dst_uint16_t; uint32_t *dst_uint32_t; samples = data; src = buf; if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); return -1; } if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); return -1; } sample_size = av_get_bits_per_sample(avctx->codec_id)/8; if (CODEC_ID_PCM_DVD == avctx->codec_id) sample_size = avctx->bits_per_coded_sample * 2 / 8; else if (avctx->codec_id == CODEC_ID_PCM_LXF) sample_size = 5; if (sample_size == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n"); return AVERROR(EINVAL); } n = avctx->channels * sample_size; if(n && buf_size % n){ if (buf_size < n) { av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); return -1; }else buf_size -= buf_size % n; } buf_size= FFMIN(buf_size, *data_size/2); *data_size=0; n = buf_size/sample_size; switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: DECODE(int32_t, le24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_S24BE: DECODE(int32_t, be24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_U24LE: DECODE(uint32_t, le24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: DECODE(uint32_t, be24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;n>0;n--) { uint32_t v = bytestream_get_be24(&src); v >>= 4; *samples++ = av_reverse[(v >> 8) & 0xff] + (av_reverse[v & 0xff] << 8); } break; case CODEC_ID_PCM_S16LE_PLANAR: n /= avctx->channels; for(c=0;c<avctx->channels;c++) src2[c] = &src[c*n*2]; for(;n>0;n--) for(c=0;c<avctx->channels;c++) *samples++ = bytestream_get_le16(&src2[c]); src = src2[avctx->channels-1]; break; case CODEC_ID_PCM_U16LE: DECODE(uint16_t, le16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_U16BE: DECODE(uint16_t, be16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_S8: dstu8= (uint8_t*)samples; for(;n>0;n--) { *dstu8++ = *src++ + 128; } samples= (short*)dstu8; break; #if HAVE_BIGENDIAN case CODEC_ID_PCM_F64LE: DECODE(int64_t, le64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_F32LE: DECODE(int32_t, le32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16LE: DECODE(int16_t, le16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S16BE: #else case CODEC_ID_PCM_F64BE: DECODE(int64_t, be64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: DECODE(int32_t, be32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16BE: DECODE(int16_t, be16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S16LE: #endif case CODEC_ID_PCM_U8: memcpy(samples, src, n*sample_size); src += n*sample_size; samples = (short*)((uint8_t*)data + n*sample_size); break; case CODEC_ID_PCM_ZORK: for(;n>0;n--) { int x= *src++; if(x&128) x-= 128; else x = -x; *samples++ = x << 8; } break; case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: for(;n>0;n--) { *samples++ = s->table[*src++]; } break; case CODEC_ID_PCM_DVD: dst_int32_t = data; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { case 20: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 &0xf0) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ &0x0f) << 12); } src = src8; } break; case 24: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); } src = src8; } break; default: av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n"); return -1; } samples = (short *) dst_int32_t; break; case CODEC_ID_PCM_LXF: dst_int32_t = data; n /= avctx->channels; for (i = 0; i < n; i++) { for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) { *dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) | ((src8[2] & 0xF) << 8) | src8[1]; } for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) { *dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) | ((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4); } } src += n * avctx->channels * 5; samples = (short *) dst_int32_t; break; default: return -1; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; }
1threat
static void hid_pointer_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { static const int bmap[INPUT_BUTTON__MAX] = { [INPUT_BUTTON_LEFT] = 0x01, [INPUT_BUTTON_RIGHT] = 0x02, [INPUT_BUTTON_MIDDLE] = 0x04, }; HIDState *hs = (HIDState *)dev; HIDPointerEvent *e; InputMoveEvent *move; InputBtnEvent *btn; assert(hs->n < QUEUE_LENGTH); e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK]; switch (evt->type) { case INPUT_EVENT_KIND_REL: move = evt->u.rel; if (move->axis == INPUT_AXIS_X) { e->xdx += move->value; } else if (move->axis == INPUT_AXIS_Y) { e->ydy += move->value; } break; case INPUT_EVENT_KIND_ABS: move = evt->u.abs; if (move->axis == INPUT_AXIS_X) { e->xdx = move->value; } else if (move->axis == INPUT_AXIS_Y) { e->ydy = move->value; } break; case INPUT_EVENT_KIND_BTN: btn = evt->u.btn; if (btn->down) { e->buttons_state |= bmap[btn->button]; if (btn->button == INPUT_BUTTON_WHEEL_UP) { e->dz--; } else if (btn->button == INPUT_BUTTON_WHEEL_DOWN) { e->dz++; } } else { e->buttons_state &= ~bmap[btn->button]; } break; default: break; } }
1threat
smelly code the use of parentheses to deny the condition : Do you consider smelly code the use of parentheses to deny the condition? If so, then what would be the correct form? Ex: if (!(array.size() == i+1)) { test += ","; }
0debug
static av_cold int omx_try_load(OMXContext *s, void *logctx, const char *libname, const char *prefix) { s->lib = dlopen(libname, RTLD_NOW | RTLD_GLOBAL); if (!s->lib) { av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname); return AVERROR_ENCODER_NOT_FOUND; } s->ptr_Init = dlsym_prefixed(s->lib, "OMX_Init", prefix); s->ptr_Deinit = dlsym_prefixed(s->lib, "OMX_Deinit", prefix); s->ptr_ComponentNameEnum = dlsym_prefixed(s->lib, "OMX_ComponentNameEnum", prefix); s->ptr_GetHandle = dlsym_prefixed(s->lib, "OMX_GetHandle", prefix); s->ptr_FreeHandle = dlsym_prefixed(s->lib, "OMX_FreeHandle", prefix); s->ptr_GetComponentsOfRole = dlsym_prefixed(s->lib, "OMX_GetComponentsOfRole", prefix); s->ptr_GetRolesOfComponent = dlsym_prefixed(s->lib, "OMX_GetRolesOfComponent", prefix); if (!s->ptr_Init || !s->ptr_Deinit || !s->ptr_ComponentNameEnum || !s->ptr_GetHandle || !s->ptr_FreeHandle || !s->ptr_GetComponentsOfRole || !s->ptr_GetRolesOfComponent) { av_log(logctx, AV_LOG_WARNING, "Not all functions found in %s\n", libname); dlclose(s->lib); s->lib = NULL; return AVERROR_ENCODER_NOT_FOUND; } return 0; }
1threat
node.js - Loading html in a similar way to PHP : <p>I am learning Node.js for website development.<br> Previously I could use PHP to include something like a navigation bar on every page, using <code>&lt;?php include('blah.php') ?&gt;</code>. This works in the same way of me just using the actual code on the page.<br> My question is: is there any way to import HTML elements / pages from one page to another with JS / Node.js?<br> Bearing in mind, PHP integrates directly with HTML in the same file, and Node.js does not integrate so seamlessly, so what I'm asking might be impossible.</p>
0debug
how to iterate array in json : how to iterate array in json $(document).ready(function(){ $('#wardno').change(function(){ //any select change on the dropdown with id country trigger this code $("#wardname > option").remove(); //first of all clear select items var ward_id = $('#wardno').val(); // here we are taking country id of the selected one. $.ajax({ type: "POST", cache: false, url:"get_wardname/"+ward_id, //here we are calling our user controller and get_cities method with the country_id success: function(cities) //we're calling the response json array 'cities' { try{ $.each(cities,function(id,city) //here we're doing a foeach loop round each city with id as the key and city as the value { var opt = $('<option />'); // here we're creating a new select option with for each city opt.val(id[0]); opt.text(id[1]); $('#wardname').append(opt); var opt1 = $('<option />'); // here we're creating a new select option with for each city opt1.val(city[0]); opt1.text(city[1]); $('#koottaymaname').append(opt1); }); //here we will append these new select options to a dropdown with the id 'cities' }catch(e) { alert(e); } }, error: function (jqXHR, textStatus, errorThrown) { alert("jqXHR: " + jqXHR.status + "\ntextStatus: " + textStatus + "\nerrorThrown: " + errorThrown); } }); }); }); // ]]> </script> The output from the code is [{"1":"St. Sebastian"},{"1":"kudumbakoottayma1","2":"kudumbakoottayma2"}] How to iterate into two different drop down list
0debug
I want to continus display of button in wpf : In my application I have 4 button. If user will click on a button, that will disappear and remaining 3 still display. The problem is that I don't want a control (button) gap between button. I want remaining 3 should rearrange itself. Which control I should use or how I can implement that. I am using MVVM in my application.
0debug
eth_write(void *opaque, target_phys_addr_t addr, uint64_t val64, unsigned int size) { struct fs_eth *eth = opaque; uint32_t value = val64; addr >>= 2; switch (addr) { case RW_MA0_LO: case RW_MA0_HI: eth->regs[addr] = value; eth_update_ma(eth, 0); break; case RW_MA1_LO: case RW_MA1_HI: eth->regs[addr] = value; eth_update_ma(eth, 1); break; case RW_MGM_CTRL: if (value & 2) eth->mdio_bus.mdio = value & 1; if (eth->mdio_bus.mdc != (value & 4)) { mdio_cycle(&eth->mdio_bus); eth_validate_duplex(eth); } eth->mdio_bus.mdc = !!(value & 4); eth->regs[addr] = value; break; case RW_REC_CTRL: eth->regs[addr] = value; eth_validate_duplex(eth); break; default: eth->regs[addr] = value; D(printf ("%s %x %x\n", __func__, addr, value)); break; } }
1threat
OpenJDK8 for windows : <p>Im a bit confused about how to download openjdk8 for windows.</p> <p>If I go to <a href="http://openjdk.java.net/install/" rel="noreferrer">http://openjdk.java.net/install/</a> then under JDK 8 there are only two sections: "Debian, Ubuntu, etc." and "Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.". Where is windows?</p>
0debug
static void emulated_push_type(EmulatedState *card, uint32_t type) { EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent)); assert(event); event->p.gen.type = type; emulated_push_event(card, event); }
1threat
static int mxf_write_partition(AVFormatContext *s, int bodysid, int indexsid, const uint8_t *key, int write_metadata) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; int64_t header_byte_count_offset; unsigned index_byte_count = 0; uint64_t partition_offset = avio_tell(pb); int err; if (!mxf->edit_unit_byte_count && mxf->edit_units_count) index_byte_count = 85 + 12+(s->nb_streams+1)*6 + 12+mxf->edit_units_count*(11+mxf->slice_count*4); else if (mxf->edit_unit_byte_count && indexsid) index_byte_count = 80; if (index_byte_count) { index_byte_count += 16 + klv_ber_length(index_byte_count); index_byte_count += klv_fill_size(index_byte_count); } if (!memcmp(key, body_partition_key, 16)) { if ((err = av_reallocp_array(&mxf->body_partition_offset, mxf->body_partitions_count + 1, sizeof(*mxf->body_partition_offset))) < 0) { mxf->body_partitions_count = 0; return err; } mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset; } avio_write(pb, key, 16); klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count); avio_wb16(pb, 1); avio_wb16(pb, 2); avio_wb32(pb, KAG_SIZE); avio_wb64(pb, partition_offset); if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1) avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); else if (!memcmp(key, footer_partition_key, 16) && mxf->body_partitions_count) avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); else avio_wb64(pb, 0); avio_wb64(pb, mxf->footer_partition_offset); header_byte_count_offset = avio_tell(pb); avio_wb64(pb, 0); avio_wb64(pb, index_byte_count); avio_wb32(pb, index_byte_count ? indexsid : 0); if (bodysid && mxf->edit_units_count && mxf->body_partitions_count) { avio_wb64(pb, mxf->body_offset); } else avio_wb64(pb, 0); avio_wb32(pb, bodysid); avio_write(pb, op1a_ul, 16); mxf_write_essence_container_refs(s); if (write_metadata) { int64_t pos, start; unsigned header_byte_count; mxf_write_klv_fill(s); start = avio_tell(s->pb); mxf_write_primer_pack(s); mxf_write_header_metadata_sets(s); pos = avio_tell(s->pb); header_byte_count = pos - start + klv_fill_size(pos); avio_seek(pb, header_byte_count_offset, SEEK_SET); avio_wb64(pb, header_byte_count); avio_seek(pb, pos, SEEK_SET); } avio_flush(pb); return 0; }
1threat
retrieve data from table selenium java : I am trying to print the data of table from this site http://www.lufthansa.com/online/portal/lh/il/homepage try to make a book then you will see the availability of the flights this is my code : String from_to = driver.findElement(By.cssSelector("table.branded-fares-flights")).getText(); System.out.println(from_to); its not working ,, it tells me that there is no such element
0debug
static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, int rw, int tlb_error) { CPUState *cs = CPU(mips_env_get_cpu(env)); int exception = 0, error_code = 0; switch (tlb_error) { default: case TLBRET_BADADDR: if (rw == MMU_DATA_STORE) { exception = EXCP_AdES; } else { exception = EXCP_AdEL; } break; case TLBRET_NOMATCH: if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } error_code = 1; break; case TLBRET_INVALID: if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } break; case TLBRET_DIRTY: exception = EXCP_LTLBL; break; case TLBRET_XI: if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBXI; } else { exception = EXCP_TLBL; } break; case TLBRET_RI: if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBRI; } else { exception = EXCP_TLBL; } break; } env->CP0_BadVAddr = address; env->CP0_Context = (env->CP0_Context & ~0x007fffff) | ((address >> 9) & 0x007ffff0); env->CP0_EntryHi = (env->CP0_EntryHi & 0xFF) | (address & (TARGET_PAGE_MASK << 1)); #if defined(TARGET_MIPS64) env->CP0_EntryHi &= env->SEGMask; env->CP0_XContext = (env->CP0_XContext & ((~0ULL) << (env->SEGBITS - 7))) | ((address & 0xC00000000000ULL) >> (55 - env->SEGBITS)) | ((address & ((1ULL << env->SEGBITS) - 1) & 0xFFFFFFFFFFFFE000ULL) >> 9); #endif cs->exception_index = exception; env->error_code = error_code; }
1threat
int net_client_init(Monitor *mon, const char *device, const char *p) { char buf[1024]; int vlan_id, ret; VLANState *vlan; char *name = NULL; vlan_id = 0; if (get_param_value(buf, sizeof(buf), "vlan", p)) { vlan_id = strtol(buf, NULL, 0); } vlan = qemu_find_vlan(vlan_id, 1); if (get_param_value(buf, sizeof(buf), "name", p)) { name = qemu_strdup(buf); } if (!strcmp(device, "nic")) { static const char * const nic_params[] = { "vlan", "name", "macaddr", "model", "addr", "id", "vectors", NULL }; NICInfo *nd; uint8_t *macaddr; int idx = nic_get_free_idx(); if (check_params(buf, sizeof(buf), nic_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (idx == -1 || nb_nics >= MAX_NICS) { config_error(mon, "Too Many NICs\n"); ret = -1; goto out; } nd = &nd_table[idx]; memset(nd, 0, sizeof(*nd)); macaddr = nd->macaddr; macaddr[0] = 0x52; macaddr[1] = 0x54; macaddr[2] = 0x00; macaddr[3] = 0x12; macaddr[4] = 0x34; macaddr[5] = 0x56 + idx; if (get_param_value(buf, sizeof(buf), "macaddr", p)) { if (parse_macaddr(macaddr, buf) < 0) { config_error(mon, "invalid syntax for ethernet address\n"); ret = -1; goto out; } } if (get_param_value(buf, sizeof(buf), "model", p)) { nd->model = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "addr", p)) { nd->devaddr = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "id", p)) { nd->id = qemu_strdup(buf); } nd->nvectors = NIC_NVECTORS_UNSPECIFIED; if (get_param_value(buf, sizeof(buf), "vectors", p)) { char *endptr; long vectors = strtol(buf, &endptr, 0); if (*endptr) { config_error(mon, "invalid syntax for # of vectors\n"); ret = -1; goto out; } if (vectors < 0 || vectors > 0x7ffffff) { config_error(mon, "invalid # of vectors\n"); ret = -1; goto out; } nd->nvectors = vectors; } nd->vlan = vlan; nd->name = name; nd->used = 1; name = NULL; nb_nics++; vlan->nb_guest_devs++; ret = idx; } else if (!strcmp(device, "none")) { if (*p != '\0') { config_error(mon, "'none' takes no parameters\n"); ret = -1; goto out; } ret = 0; } else #ifdef CONFIG_SLIRP if (!strcmp(device, "user")) { static const char * const slirp_params[] = { "vlan", "name", "hostname", "restrict", "ip", "net", "host", "tftp", "bootfile", "dhcpstart", "dns", "smb", "smbserver", "hostfwd", "guestfwd", NULL }; struct slirp_config_str *config; int restricted = 0; char *vnet = NULL; char *vhost = NULL; char *vhostname = NULL; char *tftp_export = NULL; char *bootfile = NULL; char *vdhcp_start = NULL; char *vnamesrv = NULL; char *smb_export = NULL; char *vsmbsrv = NULL; const char *q; if (check_params(buf, sizeof(buf), slirp_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (get_param_value(buf, sizeof(buf), "ip", p)) { int vnet_buflen = strlen(buf) + strlen("/24") + 1; vnet = qemu_malloc(vnet_buflen); pstrcpy(vnet, vnet_buflen, buf); pstrcat(vnet, vnet_buflen, "/24"); } if (get_param_value(buf, sizeof(buf), "net", p)) { vnet = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "host", p)) { vhost = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "hostname", p)) { vhostname = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "restrict", p)) { restricted = (buf[0] == 'y') ? 1 : 0; } if (get_param_value(buf, sizeof(buf), "dhcpstart", p)) { vdhcp_start = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "dns", p)) { vnamesrv = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "tftp", p)) { tftp_export = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "bootfile", p)) { bootfile = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "smb", p)) { smb_export = qemu_strdup(buf); if (get_param_value(buf, sizeof(buf), "smbserver", p)) { vsmbsrv = qemu_strdup(buf); } } q = p; while (1) { config = qemu_malloc(sizeof(*config)); if (!get_next_param_value(config->str, sizeof(config->str), "hostfwd", &q)) { break; } config->flags = SLIRP_CFG_HOSTFWD; config->next = slirp_configs; slirp_configs = config; config = NULL; } q = p; while (1) { config = qemu_malloc(sizeof(*config)); if (!get_next_param_value(config->str, sizeof(config->str), "guestfwd", &q)) { break; } config->flags = 0; config->next = slirp_configs; slirp_configs = config; config = NULL; } qemu_free(config); vlan->nb_host_devs++; ret = net_slirp_init(mon, vlan, device, name, restricted, vnet, vhost, vhostname, tftp_export, bootfile, vdhcp_start, vnamesrv, smb_export, vsmbsrv); while (slirp_configs) { config = slirp_configs; slirp_configs = config->next; qemu_free(config); } qemu_free(vnet); qemu_free(vhost); qemu_free(vhostname); qemu_free(tftp_export); qemu_free(bootfile); qemu_free(vdhcp_start); qemu_free(vnamesrv); qemu_free(smb_export); qemu_free(vsmbsrv); } else if (!strcmp(device, "channel")) { if (QTAILQ_EMPTY(&slirp_stacks)) { struct slirp_config_str *config; config = qemu_malloc(sizeof(*config)); pstrcpy(config->str, sizeof(config->str), p); config->flags = SLIRP_CFG_LEGACY; config->next = slirp_configs; slirp_configs = config; } else { slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), mon, p, 1); } ret = 0; } else #endif #ifdef _WIN32 if (!strcmp(device, "tap")) { static const char * const tap_params[] = { "vlan", "name", "ifname", NULL }; char ifname[64]; if (check_params(buf, sizeof(buf), tap_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { config_error(mon, "tap: no interface name\n"); ret = -1; goto out; } vlan->nb_host_devs++; ret = tap_win32_init(vlan, device, name, ifname); } else #elif defined (_AIX) #else if (!strcmp(device, "tap")) { char ifname[64], chkbuf[64]; char setup_script[1024], down_script[1024]; TAPState *s; int fd; vlan->nb_host_devs++; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { static const char * const fd_params[] = { "vlan", "name", "fd", "sndbuf", NULL }; ret = -1; if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); goto out; } fd = net_handle_fd_param(mon, buf); if (fd == -1) { goto out; } fcntl(fd, F_SETFL, O_NONBLOCK); s = net_tap_fd_init(vlan, device, name, fd); if (!s) { close(fd); } } else { static const char * const tap_params[] = { "vlan", "name", "ifname", "script", "downscript", "sndbuf", NULL }; if (check_params(chkbuf, sizeof(chkbuf), tap_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { ifname[0] = '\0'; } if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); } if (get_param_value(down_script, sizeof(down_script), "downscript", p) == 0) { pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT); } s = net_tap_init(vlan, device, name, ifname, setup_script, down_script); } if (s != NULL) { const char *sndbuf_str = NULL; if (get_param_value(buf, sizeof(buf), "sndbuf", p)) { sndbuf_str = buf; } tap_set_sndbuf(s, sndbuf_str, mon); ret = 0; } else { ret = -1; } } else #endif if (!strcmp(device, "socket")) { char chkbuf[64]; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { static const char * const fd_params[] = { "vlan", "name", "fd", NULL }; int fd; ret = -1; if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); goto out; } fd = net_handle_fd_param(mon, buf); if (fd == -1) { goto out; } if (!net_socket_fd_init(vlan, device, name, fd, 1)) { close(fd); goto out; } ret = 0; } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) { static const char * const listen_params[] = { "vlan", "name", "listen", NULL }; if (check_params(chkbuf, sizeof(chkbuf), listen_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_listen_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) { static const char * const connect_params[] = { "vlan", "name", "connect", NULL }; if (check_params(chkbuf, sizeof(chkbuf), connect_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_connect_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) { static const char * const mcast_params[] = { "vlan", "name", "mcast", NULL }; if (check_params(chkbuf, sizeof(chkbuf), mcast_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_mcast_init(vlan, device, name, buf); } else { config_error(mon, "Unknown socket options: %s\n", p); ret = -1; goto out; } vlan->nb_host_devs++; } else #ifdef CONFIG_VDE if (!strcmp(device, "vde")) { static const char * const vde_params[] = { "vlan", "name", "sock", "port", "group", "mode", NULL }; char vde_sock[1024], vde_group[512]; int vde_port, vde_mode; if (check_params(buf, sizeof(buf), vde_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } vlan->nb_host_devs++; if (get_param_value(vde_sock, sizeof(vde_sock), "sock", p) <= 0) { vde_sock[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "port", p) > 0) { vde_port = strtol(buf, NULL, 10); } else { vde_port = 0; } if (get_param_value(vde_group, sizeof(vde_group), "group", p) <= 0) { vde_group[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "mode", p) > 0) { vde_mode = strtol(buf, NULL, 8); } else { vde_mode = 0700; } ret = net_vde_init(vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); } else #endif if (!strcmp(device, "dump")) { int len = 65536; if (get_param_value(buf, sizeof(buf), "len", p) > 0) { len = strtol(buf, NULL, 0); } if (!get_param_value(buf, sizeof(buf), "file", p)) { snprintf(buf, sizeof(buf), "qemu-vlan%d.pcap", vlan_id); } ret = net_dump_init(mon, vlan, device, name, buf, len); } else { config_error(mon, "Unknown network device: %s\n", device); ret = -1; goto out; } if (ret < 0) { config_error(mon, "Could not initialize device '%s'\n", device); } out: qemu_free(name); return ret; }
1threat
Simple Java programm runs slow on Windows 2008 Server : <p>Why is my simple Java programm runs quickly on my local computer and too slow on Windows 2008 Server?</p> <p>Programm code:</p> <pre><code>public static void main(String[] args) { long startTime; long endTime; long totalTime; startTime = System.currentTimeMillis(); for (int a=1; a &lt; 100000; a++) { System.out.println("Checking"); } endTime = System.currentTimeMillis(); totalTime = endTime - startTime; System.out.println("TEST1 time:"+totalTime); startTime = System.currentTimeMillis(); double sum = 0; for (int a=1; a &lt; 1000000; a++) { int input = 100; for(int counter=1;counter&lt;input;counter++){ sum += Math.pow(-1,counter + 1)/((2*counter) - 1); } } endTime = System.currentTimeMillis(); totalTime = endTime - startTime; System.out.println("TEST2 time:"+totalTime+" pi="+sum); } </code></pre> <p>Local computer output:</p> <pre><code>Checking Checking Checking Checking TEST1 time:427 TEST2 time:7261 pi=787922.5634628027 </code></pre> <p>Windows server output:</p> <pre><code>Checking Checking Checking Checking Checking Checking TEST1 time:15688 TEST2 time:25280 pi=787922.5634628027 </code></pre> <p>Local computer hardware and soft: Intel Core (TM) i7-2600 CPU @ 3.40GHz Windows 7 Professional 8G RAM</p> <p>Server hardware and soft:</p> <p>Intel Xeon(R) CPU E5-2603 @ 1.60GHz 8G RAM Windows Server 2008 Standart Version 6.0</p> <p>Both computer and server are free from another processes.</p> <p>May be I have to apply some parametrs to java vm? </p>
0debug
static int coroutine_fn bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov, bool is_write) { CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; BlockDriverAIOCB *acb; if (is_write) { acb = bdrv_aio_writev(bs, sector_num, iov, nb_sectors, bdrv_co_io_em_complete, &co); } else { acb = bdrv_aio_readv(bs, sector_num, iov, nb_sectors, bdrv_co_io_em_complete, &co); } trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb); if (!acb) { return -EIO; } qemu_coroutine_yield(); return co.ret; }
1threat
int init_put_byte(ByteIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)) { s->buffer = buffer; s->buffer_size = buffer_size; s->buf_ptr = buffer; url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY); s->opaque = opaque; s->write_packet = write_packet; s->read_packet = read_packet; s->seek = seek; s->pos = 0; s->must_flush = 0; s->eof_reached = 0; s->error = 0; s->is_streamed = 0; s->max_packet_size = 0; s->update_checksum= NULL; if(!read_packet && !write_flag){ s->pos = buffer_size; s->buf_end = s->buffer + buffer_size; } s->read_pause = NULL; s->read_seek = NULL; return 0; }
1threat