problem
stringlengths
26
131k
labels
class label
2 classes
static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSList *group, GtkWidget *view_menu) { #if defined(CONFIG_VTE) const char *label; char buffer[32]; char path[32]; #if VTE_CHECK_VERSION(0, 26, 0) VtePty *pty; #endif GIOChannel *chan; GtkWidget *scrolled_window; GtkAdjustment *vadjustment; int master_fd, slave_fd; snprintf(buffer, sizeof(buffer), "vc%d", index); snprintf(path, sizeof(path), "<QEMU>/View/VC%d", index); vc->chr = vcs[index]; if (vc->chr->label) { label = vc->chr->label; } else { label = buffer; } vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, label); group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item)); gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path); gtk_accel_map_add_entry(path, GDK_KEY_2 + index, HOTKEY_MODIFIERS); vc->terminal = vte_terminal_new(); master_fd = qemu_openpty_raw(&slave_fd, NULL); g_assert(master_fd != -1); #if VTE_CHECK_VERSION(0, 26, 0) pty = vte_pty_new_foreign(master_fd, NULL); vte_terminal_set_pty_object(VTE_TERMINAL(vc->terminal), pty); #else vte_terminal_set_pty(VTE_TERMINAL(vc->terminal), master_fd); #endif vte_terminal_set_scrollback_lines(VTE_TERMINAL(vc->terminal), -1); #if VTE_CHECK_VERSION(0, 28, 0) && GTK_CHECK_VERSION(3, 0, 0) vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vc->terminal)); #else vadjustment = vte_terminal_get_adjustment(VTE_TERMINAL(vc->terminal)); #endif scrolled_window = gtk_scrolled_window_new(NULL, vadjustment); gtk_container_add(GTK_CONTAINER(scrolled_window), vc->terminal); vte_terminal_set_size(VTE_TERMINAL(vc->terminal), 80, 25); vc->fd = slave_fd; vc->chr->opaque = vc; vc->scrolled_window = scrolled_window; gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vc->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), scrolled_window, gtk_label_new(label)); g_signal_connect(vc->menu_item, "activate", G_CALLBACK(gd_menu_switch_vc), s); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item); qemu_chr_be_generic_open(vc->chr); if (vc->chr->init) { vc->chr->init(vc->chr); } chan = g_io_channel_unix_new(vc->fd); g_io_add_watch(chan, G_IO_IN, gd_vc_in, vc); #endif return group; }
1threat
static int opt_show_format_entry(void *optctx, const char *opt, const char *arg) { char *buf = av_asprintf("format=%s", arg); int ret; av_log(NULL, AV_LOG_WARNING, "Option '%s' is deprecated, use '-show_entries format=%s' instead\n", opt, arg); ret = opt_show_entries(optctx, opt, buf); av_free(buf); return ret; }
1threat
Why npm init is used in any JS projects? : <p>Recently I started learning typescript and little new to NPM, wants know about why npm init is used. can anyone please explain real time example. and most importantly please don't say question is asked here, there i am not satisfied with those answers so i am asking again here.</p> <p>$ npm init</p>
0debug
switch case two is generated after case one : //this is my java code public static void main(String[] args) { try { FirefoxDriver driver = new FirefoxDriver(); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedReader reader1 = new BufferedReader(new InputStreamReader(System.in)); Login module = new Login(driver, "http://180.211.114.147:97/Account/Login"); module.doLogin("devrana","dev123"); Demat_Account dmat = new Demat_Account(); Will_Mgmt wmgt = new Will_Mgmt(); System.out.println("-----Select Module-----"); System.out.println("1. Demat Account"); System.out.println("2. Will Management"); System.out.println("Select Module :"); try{ int role = Integer.parseInt(reader.readLine()); switch (role) { case 1: System.out.println("you have selected Demat Account "); dmat.gotoDemat(); System.out.println("-----Select Operation-----"); System.out.println("1. Add Demat Account"); System.out.println("2. Edit Demat Account"); System.out.println("3. Delete Demat Account"); int operation = Integer.parseInt(reader.readLine()); switch (operation) { case 1: System.out.println("1. you have selected Add Demat Account"); dmat.AddDemat(); break; case 2: { System.out.println("2. you have selected Edit Demat Account"); break; } case 3 : { System.out.println("3.you have selected Delete Demat Account"); dmat.deleteDemat(); break; } } case 2: System.out.println("you have selected Will Management "); wmgt.gotoWillmgt(); System.out.println("-----Select Operation-----"); System.out.println("11. Edit will Template"); System.out.println("22. Proceed to will Distribution"); int will_operation=Integer.parseInt(reader1.readLine()); switch(will_operation) { case 11 : break; case 22: wmgt.AddWill(); break; } } }catch(NumberFormatException nfe) { System.err.println("Invalid Format!"); } } catch (Exception ex) { } } //Out put of console Login success!! -----Select Module----- 1. Demat Account 2. Will Management Select Module : 1 you have selected Demat Account gotoDemat method -----Select Operation----- 1. Add Demat Account 2. Edit Demat Account 3. Delete Demat Account 1 1. you have selected Add Demat Account Success!! you have selected Will Management Will Mgt method Success 1 !! -----Select Operation----- 11. Edit will Template 22. Proceed to will Distribution
0debug
static void put_float64(QEMUFile *f, void *pv, size_t size) { uint64_t *v = pv; qemu_put_be64(f, float64_val(*v)); }
1threat
Date and Time Formatting error : <p><strong>I'm having the date "2016-08-05 14:46:53 +05:30" and the date and time format which i have used is "yyyy-MM-DD HH:mm:ss +05:30"</strong> the problem is that when i'm parsing this date i get the output <strong>"Tue Jan 05 14:46:53 GMT+05:30 2016"</strong> i don't get what is the problem. The code which i'm using is posted below.</p> <pre><code>public class DateFormater { private static String DATE_TIME_FORMAT = "yyyy-MM-DD HH:mm:ss +05:30"; private static String TAG = DateFormater.class.getSimpleName(); public static Date getDate(String s) { //Input s = 2016-08-05 14:46:53 +05:30 Date date = null; try { SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_TIME_FORMAT); date=dateFormat.parse(s); } catch (ParseException e) { e.printStackTrace(); } return date; } public static String getCurrentDateString(Date date) { DateFormat dateFormat=SimpleDateFormat.getDateInstance(DateFormat.MEDIUM); Log.i(TAG, "getCurrentDateString: "+dateFormat.format(date)); return dateFormat.format(date); } public static String getCurrentTimeString(Date date) { DateFormat dateFormat=SimpleDateFormat.getTimeInstance(DateFormat.SHORT); return dateFormat.format(date);//Tue Jan 05 14:46:53 GMT+05:30 2016 }} </code></pre>
0debug
static void monitor_data_destroy(Monitor *mon) { QDECREF(mon->outbuf); qemu_mutex_destroy(&mon->out_lock);
1threat
int qemu_paio_read(struct qemu_paiocb *aiocb) { return qemu_paio_submit(aiocb, QEMU_PAIO_READ); }
1threat
Can I take an input using InputStreamReader in static block? : <p><a href="https://i.stack.imgur.com/uLwM6.png" rel="nofollow noreferrer">Code has been written. Can I use this code to take user input?</a></p>
0debug
How I can use docker-registry with login/password? : <p>I have my docker-registry in localhost and I can pull/push with command: <code>docker push localhost:5000/someimage</code> How I can push it with command like <code>docker push username@password:localhost:5000/someimage</code>?</p>
0debug
ksh. want to remove particular block of line : below is the sample text in a file AAA ccc ddd eee XXX AAA lll mmm eee YYY from the above text, I want to print only the line between AAA and XXX and final output will be like AAA ccc ddd eee XXX thanks in advance
0debug
sql for loop to include returned values as part of a sql insert : i need to insert rows from another query into a single row that is then inserted into another table. it works if there is only one row returned; however, if the row count is greater than 1 it fails. i can't figure out the for loop - indicated with the --** section. declare @cn as int, @i as int set @cn = 569 declare @dM table(dM varchar(max)) declare @rowNum table (rowNum int) set @i = 0 insert @rowNum exec ('select count(*) from table1 where c = ' + @cn) --select rowNum from @rowNum as NumberRows --return 2 rows if (select rowNum from @rowNum as NumberRows) > 1 begin insert @dM exec ('select d.d + '' '' + o.o + '' '' + d.v as rtM from table where c = ' + @countNumber) --returns 2 rows as rtM so there will be two inserted rows --going now okay --going later okay --** --while (@i <= (select count(*) from @rowNum)) --didn't work --for each row returned in rtM in need to include as part of the overall insert insert into table2 (cn, rtM, idate) select @cn ,'Message is: ' + (select dM from @dM) + ' - the message.' cz.idate + ' ' + qw.txt from table3 as cz inner join table4 as qw on cz.id = qw.id where cz.cn = @cn --set @i = @i + 1 --** end else begin --there is only 1 row returned from rtM so there will be a single inserted row insert @dM exec ('select d.d + '' '' + o.o + '' '' + d.v as rtM from table where c = ' + @countNumber) insert into table2 (cn, rtM, idate) select @cn ,'Message is: ' + (select dM from @dM) + ' - the message.' cz.idate + ' ' + qw.txt from table3 as cz inner join table4 as qw on cz.id = qw.id where cz.cn = @cn end
0debug
getting started with tensorflow | tensorflow : I am pretty new to tensorflow,and i am currently learning it through given website https://www.tensorflow.org/get_started/get_started it is given that, "We've created a model, but we don't know how good it is yet. To evaluate the model on training data, we need a y placeholder to provide the desired values, and we need to write a loss function. A loss function measures how far apart the current model is from the provided data. We'll use a standard loss model for linear regression, which sums the squares of the deltas between the current model and the provided data. linear_model - y creates a vector where each element is the corresponding example's error delta. We call tf.square to square that error. Then, we sum all the squared errors to create a single scalar that abstracts the error of all examples using tf.reduce_sum:" Image of the above quote :https://i.stack.imgur.com/ztdpB.png q1."we dont know how good it is yet.", i did'nt understand this quote as the simple model created is a simple slope equation and on what it should train for?, as the model is a simple slope. Is it require an perfect slope or what? why am i training that model and for what? q2.what is a loss function? Is loss function is used to determine the accuracy of the model? Why is it required? q3. I did'nt understand " 'sums the squares of the deltas' between the current model and the provided data." q4.I did'nt understood this part of code,"`squared_deltas = tf.square(linear_model - y)` this is the code: `y = tf.placeholder(tf.float32) squared_deltas = tf.square(linear_model - y) loss = tf.reduce_sum(squared_deltas) print(sess.run(loss, {x:[1,2,3,4], y:[0,-1,-2,-3]}))` this may be simple questions, but i am a beginner to tensorflow and having a hard time understanding it. Could any one please help me out, thanks :)
0debug
static int do_compress_ram_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset) { RAMState *rs = &ram_state; int bytes_sent, blen; uint8_t *p = block->host + (offset & TARGET_PAGE_MASK); bytes_sent = save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS_PAGE); blen = qemu_put_compression_data(f, p, TARGET_PAGE_SIZE, migrate_compress_level()); if (blen < 0) { bytes_sent = 0; qemu_file_set_error(migrate_get_current()->to_dst_file, blen); error_report("compressed data failed!"); } else { bytes_sent += blen; ram_release_pages(block->idstr, offset & TARGET_PAGE_MASK, 1); } return bytes_sent; }
1threat
How can i show same result jquery (inset a sapn tag after input element ) to javascript. : i am new learner to JavaScript. I have lot of try for inser a span tag after input element. I can do it by jQuery ,But i want to convert it JavaScript. please tell me anyone for my problem. This is my jQuery code i want to same result by JavaScript `jQuery(document).ready(function(){ jQuery('#selector_id').after('<span class="arrow"></span>'); });`
0debug
Having problem with opening 2nd page of blogger : <p>I have a website on blogger and I have posted 7 posts in it. But, whenever I open my website it shows only 3 posts on my main page and it's not showing 2nd main page. My website name - www.BlueWOrld.ooo have a look and please help me to fix it</p>
0debug
def count_bidirectional(test_list): res = 0 for idx in range(0, len(test_list)): for iidx in range(idx + 1, len(test_list)): if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]: res += 1 return (str(res))
0debug
How to use "BinaryString.uncons()" but with a type distinct from Word8? : <p>I have a binary string. I want to split it into head and tail. The close candidate is from <code>bytestring</code> is:</p> <pre><code>uncons :: ByteString -&gt; Maybe (Word8, ByteString) </code></pre> <p>But I want to split it such that the head would be, say, of type <code>Word16</code> instead of <code>Word8</code>. Or <code>Word32</code>. Or anything else.</p> <p>How can I do that?</p>
0debug
.Net SqlClient Data Provider : Incorrect syntax near 'f' : I'm trying to run the following query, where the id is a primary key. The F from 425F is underlined red and the following error is given: Incorrect syntax near 'f'. Does anybody know what's going on? SELECT * FROM table WHERE id = E9485FD0-0888-425F-B1B6-BC32B4B5045E I don't have the option of declaring it as a varchar variable, although that did fix the error.
0debug
How can I get Java date in another Language : <p>I am living in Austria and if I print the date in Java I get in the german format. But I want to have it in the english format.</p> <p>I already tried it with the following code.</p> <pre><code>import java.util.Date; import java.text.*; public class Calendar extends JFrame { public static void main(String[] args) { Date currentDate = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy", Locale.UK); System.out.println(dateFormat.format(currentDate)); </code></pre>
0debug
How to .catch a Promise.reject : <p>I have a helper function for using <code>fetch</code> with CouchDB which ends as:</p> <pre><code>... return fetch(...) .then(resp =&gt; resp.ok ? resp.json() : Promise.reject(resp)) .then(json =&gt; json.error ? Promise.reject(json) : json) </code></pre> <p>and when I use it elsewhere, I was under the impression that I could <code>.catch</code> those explicit rejections:</p> <pre><code> above_function(its_options) .then(do_something) .catch(err =&gt; do_something_with_the_json_error_rejection_or_resp_not_ok_rejection_or_the_above(err)) </code></pre> <p>but alas, I can't seem to be able to get a hold of the rejections. The specific error I'm after is a HTTP 401 response.</p> <p>What gives?</p> <p>(Please note that there are implicit ES6 <code>return</code>'s in the <code>.then</code>s)</p>
0debug
array multidimensionnelle angular : Helle guys, I work on the application under angular, and I would like to display data from a table like this: http://prntscr.com/onbcqb Example of an array ``` [ { "Noms": "Boizard Clement ", "Enfants": null, "FP": true, "Adresse": null, "Brunch": "Oui", "OK": "Oui", "OK enfant": null, "KO": null, "Attente": null, "mail cadeau": null, "Remerciements": null, "Sexe": "Homme" }, { "Noms": "Camille Giroud ", "Enfants": null, "FP": true, "Adresse": null, "Brunch": "Oui", "OK": "Oui", "OK enfant": null, "KO": null, "Attente": null, "mail cadeau": null, "Remerciements": null, "Sexe": "Femme" } ]; ```
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Convert Bitbucket Mercurial repository to Git. Maintain branches and history. Online solution : <p>How do I convert a Bitbucket Mercurial repository (Hg repository) to a Git repository? I want to keep branches and commit history.</p>
0debug
static int avi_sync(AVFormatContext *s, int exit_early) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; int n; unsigned int d[8]; unsigned int size; int64_t i, sync; start_sync: memset(d, -1, sizeof(d)); for(i=sync=avio_tell(pb); !url_feof(pb); i++) { int j; for(j=0; j<7; j++) d[j]= d[j+1]; d[7]= avio_r8(pb); size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24); n= get_stream_idx(d+2); if(i + (uint64_t)size > avi->fsize || d[0] > 127) if( (d[0] == 'i' && d[1] == 'x' && n < s->nb_streams) ||(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K') ||(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')){ avio_skip(pb, size); goto start_sync; if(d[0] == 'L' && d[1] == 'I' && d[2] == 'S' && d[3] == 'T'){ avio_skip(pb, 4); goto start_sync; n= get_stream_idx(d); if(!((i-avi->last_pkt_pos)&1) && get_stream_idx(d+1) < s->nb_streams) if(d[2] == 'i' && d[3] == 'x' && n < s->nb_streams){ avio_skip(pb, size); goto start_sync; if(n < s->nb_streams){ AVStream *st; AVIStream *ast; st = s->streams[n]; ast = st->priv_data; if(s->nb_streams>=2){ AVStream *st1 = s->streams[1]; AVIStream *ast1= st1->priv_data; if( d[2] == 'w' && d[3] == 'b' && n==0 && st ->codec->codec_type == AVMEDIA_TYPE_VIDEO && st1->codec->codec_type == AVMEDIA_TYPE_AUDIO && ast->prefix == 'd'*256+'c' && (d[2]*256+d[3] == ast1->prefix || !ast1->prefix_count) ){ n=1; st = st1; ast = ast1; av_log(s, AV_LOG_WARNING, "Invalid stream + prefix combination, assuming audio.\n"); if( (st->discard >= AVDISCARD_DEFAULT && size==0) || st->discard >= AVDISCARD_ALL){ if (!exit_early) { ast->frame_offset += get_duration(ast, size); avio_skip(pb, size); goto start_sync; if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) { int k = avio_r8(pb); int last = (k + avio_r8(pb) - 1) & 0xFF; avio_rl16(pb); for (; k <= last; k++) ast->pal[k] = 0xFF<<24 | avio_rb32(pb)>>8; ast->has_pal= 1; goto start_sync; } else if( ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) || d[2]*256+d[3] == ast->prefix ) { if (exit_early) return 0; if(d[2]*256+d[3] == ast->prefix) ast->prefix_count++; else{ ast->prefix= d[2]*256+d[3]; ast->prefix_count= 0; avi->stream_index= n; ast->packet_size= size + 8; ast->remaining= size; if(size || !ast->sample_size){ uint64_t pos= avio_tell(pb) - 8; if(!st->index_entries || !st->nb_index_entries || st->index_entries[st->nb_index_entries - 1].pos < pos){ av_add_index_entry(st, pos, ast->frame_offset, size, 0, AVINDEX_KEYFRAME); return 0; if(pb->error) return pb->error; return AVERROR_EOF;
1threat
i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq) { struct menelaus_s *s = (struct menelaus_s *) i2c_slave_init(bus, 0, sizeof(struct menelaus_s)); s->i2c.event = menelaus_event; s->i2c.recv = menelaus_rx; s->i2c.send = menelaus_tx; s->irq = irq; s->rtc.hz = qemu_new_timer(rt_clock, menelaus_rtc_hz, s); s->in = qemu_allocate_irqs(menelaus_gpio_set, s, 3); s->pwrbtn = qemu_allocate_irqs(menelaus_pwrbtn_set, s, 1)[0]; menelaus_reset(&s->i2c); register_savevm("menelaus", -1, 0, menelaus_save, menelaus_load, s); return &s->i2c; }
1threat
Symfony no muestra la barra de Debug : Buenas , tengo montado una instancia de Symfony el linux con apache y NGINX. Lo que hago es arrancar el servidor de symfony con el comando php bin/console server:start Ahora arranco en mi navegador y me carga la página inicial de Symfony pero no me muestra la barra inferior (barra de profiler) He revisado el fichero "config_dev.yml" y creo que lo tengo correcto imports: - { resource: config.yml } framework: router: resource: '%kernel.project_dir%/app/config/routing_dev.yml' strict_requirements: true profiler: { only_exceptions: false } web_profiler: toolbar: true intercept_redirects: false En cambio si lanzo una ***RUTA*** que no tengo me da error y me sale la barra en la parte inferior [Imagen][1] Gracias, [1]: https://i.stack.imgur.com/dZ5IP.png
0debug
Importing CSV data into MYSQL via PHP : <p>I am working on a website which uses data from a CRM system, this data is in CSV format but when im trying to import into MYSQL via php something is corrupting and forcing a record to split and take 2 rows. Example of CSV field below - something in it is causing the error/split to another row in the database. It seems to be some kind of character but ive tried to replace the culprit ones. Any ideas would be GREATLY appreciated as I have spent ages trying to figure this out!! im using fgetcsv to import. I can import the csv file no problem via phpmyadmin</p> <p>"GREAT FIRST TIME PURCHASE TWO BED END TERRACED IN A POPULAR LOCATION. Pleased to have available this well presented two bed end terraced situated in an ideal location for all local amenities, just a short stroll to the Stretford Arndale Centre and close proximity to the Metrolink tram station for commuting into the city centre and Media city. The accommodation briefly comprising, lounge with staircase leading to first floor, kitchen/diner and cellar used for storage. Whilst to the first floor there are two double bedrooms and a family bathroom. OUTSIDE Enclosed Court yard to the rear. Private parking space."</p>
0debug
SourceTree gives me a login Error when I try to add my gitlab account : <p>I would like to add my gitlab account to sourcetree. Inside Preferences -> Accounts, I tried the 'add' button</p> <pre><code>host: GitLab.com Auth type: greyed out username xxxxxx password: xxxxxx protocol: https </code></pre> <p>when I go to save. I get a pop up screen that says: "We couldn't connect to GitLab with your (XXXXXX) credentials. Check your username and try the password again."</p> <p>I've double checked both username and password.</p>
0debug
Python script- need help understanding this while loop : <p>My gf is studying CS and needs help understanding how this script runs and why?</p> <p>What value does mystery(9870) return?</p> <pre><code>def mystery(n): m = " " while n &gt; 0: m += str(n % 10) n //= 10 return m </code></pre> <p>The possible answers are- "789" "0789" "7890" "987" "9870"</p> <p>We just need to know how the code runs?</p> <p>Can anyone help?</p>
0debug
Public alias for non-public type : <p>I wonder if it is valid C++ :</p> <pre><code>class Test { struct PrivateInner { PrivateInner(std::string const &amp;str) { std::cout &lt;&lt; str &lt;&lt; "\n"; } }; public: using PublicInner = PrivateInner; }; //Test::PrivateInner priv("Hello world"); // Ok, private so we can't use that Test::PublicInner publ("Hello World"); // ?, by using public alias we can access private type, is it ok ? </code></pre>
0debug
static int scsi_disk_emulate_read_toc(SCSIRequest *req, uint8_t *outbuf) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); int start_track, format, msf, toclen; uint64_t nb_sectors; msf = req->cmd.buf[1] & 2; format = req->cmd.buf[2] & 0xf; start_track = req->cmd.buf[6]; bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); DPRINTF("Read TOC (track %d format %d msf %d)\n", start_track, format, msf >> 1); nb_sectors /= s->qdev.blocksize / 512; switch (format) { case 0: toclen = cdrom_read_toc(nb_sectors, outbuf, msf, start_track); break; case 1: toclen = 12; memset(outbuf, 0, 12); outbuf[1] = 0x0a; outbuf[2] = 0x01; outbuf[3] = 0x01; break; case 2: toclen = cdrom_read_toc_raw(nb_sectors, outbuf, msf, start_track); break; default: return -1; } if (toclen > req->cmd.xfer) { toclen = req->cmd.xfer; } return toclen; }
1threat
My PHP script is not returning data to AJAX script : <p>PHP script:- </p> <pre><code>&lt;?php header('Access-Control-Allow-Origin: *'); echo "Done"; ?&gt; </code></pre> <p>AJAX script:-</p> <pre><code>$(document).ready(function(){ $('#submit').click(function(){ $.ajax({ type : "POST", url : "http://127.0.0.1/ionic/retri.php", success : function(data){ alert(data); $('#card').text(data); } }) }); }); </code></pre> <p>HTML:-</p> <pre><code> &lt;button id="submit" class="button button-block button-positive"&gt; Submit &lt;/button&gt; &lt;div class="card"&gt; &lt;div id="card" class="item item-text-wrap"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I have just started learning AJAX and wrote this script just to echo simple text and update the html div but I am not getting any output. </p>
0debug
Cannot build APK - DexExcepction : When I'm building my project by "Run (applicaton)" build-in function - everything's fine, I can test my app through phone, but I want to create standalone application by gradle. I'm using **gradle :client:clean :client:assemble** task, and that's my output: Dex: Error converting bytecode to dex:sesWithDexForDebug Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; By [this link][1] I've searched for some dependencies between my modules. I checked, that appcompat-v7 and design library have support-v4 library build-in, so I removed it from design library. My **build.gradle** file: dependencies { //compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) //Support Design compile ('com.android.support:appcompat-v7:23.4.0') compile ('com.android.support:design:23.4.0') { exclude module: 'support-v4' } //Butter Knife compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' //Retrofit compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' //JSON Utils compile 'com.google.code.gson:gson:2.5' compile 'com.squareup.retrofit2:converter-gson:2.1.0' //Dagger 2 compile 'com.google.dagger:dagger:2.9' annotationProcessor 'com.google.dagger:dagger-compiler:2.9' provided 'javax.annotation:jsr250-api:1.0' //Android Plot compile 'com.github.PhilJay:MPAndroidChart:v3.0.1' //Apache Commons compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0' //RxJava compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxjava:2.0.1' //Tests testCompile 'junit:junit:4.12' } How can I fix it? Regards [1]: http://stackoverflow.com/questions/20989317/multiple-dex-files-define-landroid-support-v4-accessibilityservice-accessibility
0debug
make pip ignore an existing wheel : <p>If a <code>.whl</code> is available online, <code>pip</code> always installs it rather than compiling from source. However, for some specific module, the wheel happened to be compiled for the next processor generation and doesn't run on a specific machine.</p> <p>If I command it to just download the package, then it still downloads the wheel rather than source. Does <code>pip</code> have some mechanism to override this preference?</p>
0debug
Unable to instantiate activity ComponentInfo{com.example.rajafarid.valentines/com.example.rajafarid.valentines.MainActivity2} : i am going to create a valentines app as i am a beginner so i have a first activity(MainActivity) that have a button which activate second Activity(MainActivity 2) the problem is that it says instantiate problem it says in manifest file com.example.rajafarid.valentines.MainActivity 2' has no default constructor. Validates resource references inside Android XML files. here is the menifest file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.rajafarid.valentines"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity2"> <intent-filter> <action android:name="com.example.rajafarid.valentines.MainActivity2" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".DetailActivity"> <intent-filter> <action android:name="com.example.rajafarid.valentines.DetailActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest> package com.example.rajafarid.valentines; import java.util.ArrayList; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.media.Image; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class MainActivity2 extends ArrayAdapter<ImageITem> { private Context context; private int layoutResourceId; private ArrayList<ImageITem> data = new ArrayList<ImageITem>(); public MainActivity2(Context context, int layoutResourceId, ArrayList<ImageITem> data) { super(context, layoutResourceId, data); this.layoutResourceId = layoutResourceId; this.context = context; this.data = data; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; ViewHolder holder; if (row == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new ViewHolder(); holder.imageTitle = (TextView) row.findViewById(R.id.text); holder.image = (ImageView) row.findViewById(R.id.image); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } ImageITem item = data.get(position); holder.imageTitle.setText(item.getTitle()); holder.image.setImageBitmap(item.getImage()); return row; } static class ViewHolder { TextView imageTitle; ImageView image; } } LogCat View java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.rajafarid.valentines/com.example.rajafarid.valentines.MainActivity2}: java.lang.InstantiationException: class com.example.rajafarid.valentines.MainActivity2 has no zero argument constructor at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2515) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) at android.app.ActivityThread.access$900(ActivityThread.java:172) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5832) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) Caused by: java.lang.InstantiationException: class com.example.rajafarid.valentines.MainActivity2 has no zero argument constructor at java.lang.Class.newInstance(Class.java:1641) at android.app.Instrumentation.newActivity(Instrumentation.java:1079) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)  at android.app.ActivityThread.access$900(ActivityThread.java:172)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5832)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)  Caused by: java.lang.NoSuchMethodException: <init> [] at java.lang.Class.getConstructor(Class.java:531) at java.lang.Class.getDeclaredConstructor(Class.java:510) at java.lang.Class.newInstance(Class.java:1639) at android.app.Instrumentation.newActivity(Instrumentation.java:1079)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)  at android.app.ActivityThread.access$900(ActivityThread.java:172)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5832)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 
0debug
get object from json array : May i know how to get JSON object from an json array?? JSON: [ { "id": 1, "region": "Ilocos Region (Region I)", "province": "Ilocos Norte", "city": "Laoag City" }, { "id": 2, "region": "Ilocos Region (Region I)", "province": "Ilocos Norte", "city": "Batac City" }, { "id": 3, "region": "Ilocos Region (Region I)", "province": "Ilocos Sur", "city": "Vigan City" } ] I can get the region province and city but i cant get the id here is my code im using. try { br = new BufferedReader(new FileReader(path+"json/src_city.json")); try { while ((inputline = br.readLine()) != null) { JSONArray a = (JSONArray) parser.parse(inputline); for (Object o : a) { JSONObject sample = (JSONObject) o; id = (int) sample.get("id"); }}
0debug
static int get_stream_info(AVCodecContext *avctx) { FDKAACDecContext *s = avctx->priv_data; CStreamInfo *info = aacDecoder_GetStreamInfo(s->handle); int channel_counts[0x24] = { 0 }; int i, ch_error = 0; uint64_t ch_layout = 0; if (!info) { av_log(avctx, AV_LOG_ERROR, "Unable to get stream info\n"); return AVERROR_UNKNOWN; } if (info->sampleRate <= 0) { av_log(avctx, AV_LOG_ERROR, "Stream info not initialized\n"); return AVERROR_UNKNOWN; } avctx->sample_rate = info->sampleRate; avctx->frame_size = info->frameSize; for (i = 0; i < info->numChannels; i++) { AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i]; if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(channel_counts)) { av_log(avctx, AV_LOG_WARNING, "unknown channel type\n"); break; } channel_counts[ctype]++; } av_log(avctx, AV_LOG_DEBUG, "%d channels - front:%d side:%d back:%d lfe:%d top:%d\n", info->numChannels, channel_counts[ACT_FRONT], channel_counts[ACT_SIDE], channel_counts[ACT_BACK], channel_counts[ACT_LFE], channel_counts[ACT_FRONT_TOP] + channel_counts[ACT_SIDE_TOP] + channel_counts[ACT_BACK_TOP] + channel_counts[ACT_TOP]); switch (channel_counts[ACT_FRONT]) { case 4: ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER; break; case 3: ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER; break; case 2: ch_layout |= AV_CH_LAYOUT_STEREO; break; case 1: ch_layout |= AV_CH_FRONT_CENTER; break; default: av_log(avctx, AV_LOG_WARNING, "unsupported number of front channels: %d\n", channel_counts[ACT_FRONT]); ch_error = 1; break; } if (channel_counts[ACT_SIDE] > 0) { if (channel_counts[ACT_SIDE] == 2) { ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT; } else { av_log(avctx, AV_LOG_WARNING, "unsupported number of side channels: %d\n", channel_counts[ACT_SIDE]); ch_error = 1; } } if (channel_counts[ACT_BACK] > 0) { switch (channel_counts[ACT_BACK]) { case 3: ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | AV_CH_BACK_CENTER; break; case 2: ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT; break; case 1: ch_layout |= AV_CH_BACK_CENTER; break; default: av_log(avctx, AV_LOG_WARNING, "unsupported number of back channels: %d\n", channel_counts[ACT_BACK]); ch_error = 1; break; } } if (channel_counts[ACT_LFE] > 0) { if (channel_counts[ACT_LFE] == 1) { ch_layout |= AV_CH_LOW_FREQUENCY; } else { av_log(avctx, AV_LOG_WARNING, "unsupported number of LFE channels: %d\n", channel_counts[ACT_LFE]); ch_error = 1; } } if (!ch_error && av_get_channel_layout_nb_channels(ch_layout) != info->numChannels) { av_log(avctx, AV_LOG_WARNING, "unsupported channel configuration\n"); ch_error = 1; } if (ch_error) avctx->channel_layout = 0; else avctx->channel_layout = ch_layout; avctx->channels = info->numChannels; return 0; }
1threat
static void virtio_setup(void) { struct irb irb; int i; int r; bool found = false; blk_schid.one = 1; for (i = 0; i < 0x10000; i++) { blk_schid.sch_no = i; r = tsch(blk_schid, &irb); if (r != 3) { if (virtio_is_blk(blk_schid)) { found = true; break; } } } if (!found) { virtio_panic("No virtio-blk device found!\n"); } virtio_setup_block(blk_schid); }
1threat
Noob questiion about adding number to string : I have this line of code: `($(".contact-msg-inpt").prop("scrollHeight"))` and I'm trying to figure out how can I add a number, say 5 or 8, or 10 or whatever to this value, but in one line? I tried this one, but it didn't work: `parseInt("(($(".contact-msg-inpt").prop("scrollHeight"))", 10)`
0debug
long do_sigreturn(CPUMBState *env) { struct target_signal_frame *frame; abi_ulong frame_addr; target_sigset_t target_set; sigset_t set; int i; frame_addr = env->regs[R_SP]; trace_user_do_sigreturn(env, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1)) goto badframe; __get_user(target_set.sig[0], &frame->uc.tuc_mcontext.oldmask); for(i = 1; i < TARGET_NSIG_WORDS; i++) { __get_user(target_set.sig[i], &frame->extramask[i - 1]); } target_to_host_sigset_internal(&set, &target_set); do_sigprocmask(SIG_SETMASK, &set, NULL); restore_sigcontext(&frame->uc.tuc_mcontext, env); env->regs[14] = env->sregs[SR_PC]; unlock_user_struct(frame, frame_addr, 0); return env->regs[10]; badframe: force_sig(TARGET_SIGSEGV); }
1threat
static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { BDRVQcowState *s = bs->opaque; int l2_index; uint64_t *l2_table; uint64_t entry; unsigned int nb_clusters; int ret; uint64_t alloc_cluster_offset; trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset, *bytes); assert(*bytes > 0); nb_clusters = size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); if (ret < 0) { return ret; entry = be64_to_cpu(l2_table[l2_index]); if (entry & QCOW_OFLAG_COMPRESSED) { nb_clusters = 1; } else { nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index); assert(nb_clusters > 0); ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { return ret; alloc_cluster_offset = start_of_cluster(s, *host_offset); ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset, &nb_clusters); if (ret < 0) { if (nb_clusters == 0) { *bytes = 0; return 0; int requested_sectors = (*bytes + offset_into_cluster(s, guest_offset)) >> BDRV_SECTOR_BITS; int avail_sectors = nb_clusters << (s->cluster_bits - BDRV_SECTOR_BITS); int alloc_n_start = offset_into_cluster(s, guest_offset) >> BDRV_SECTOR_BITS; int nb_sectors = MIN(requested_sectors, avail_sectors); QCowL2Meta *old_m = *m; *m = g_malloc0(sizeof(**m)); **m = (QCowL2Meta) { .next = old_m, .alloc_offset = alloc_cluster_offset, .offset = start_of_cluster(s, guest_offset), .nb_clusters = nb_clusters, .nb_available = nb_sectors, .cow_start = { .offset = 0, .nb_sectors = alloc_n_start, }, .cow_end = { .offset = nb_sectors * BDRV_SECTOR_SIZE, .nb_sectors = avail_sectors - nb_sectors, }, }; qemu_co_queue_init(&(*m)->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); *host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset); *bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE) - offset_into_cluster(s, guest_offset)); assert(*bytes != 0); return 1; fail: if (*m && (*m)->nb_clusters > 0) { QLIST_REMOVE(*m, next_in_flight); return ret;
1threat
Issue when copying blocks of memory using memcpy : <p>In my following code, I made <code>buffer</code> as a 2D array created using <code>malloc(r * c * sizeof(double*));</code>. I want to copy the first 12 elements of <code>buffer</code> (i.e. the first 4 rows) into the second one <code>temp</code> using <code>memcpy</code>.</p> <pre><code>double *buffer = malloc(10 * 3 * sizeof(double*)); double *temp = malloc(4 * 3 * sizeof(double*)); for (int i = 0; i &lt; 4; ++i) { memcpy(*(temp+ i*3), *(buffer + i*3), 3 * sizeof(double)); } </code></pre> <p>I get this error:</p> <pre><code>memcpy(*(temp+ i*3), *(buffer + i*3), 3 * sizeof(double)); ^~~~~~~~~~~~~~~~~~~~~~~~~~ </code></pre> <p>Can someone tell me why?</p> <p>Thank you in advance.</p>
0debug
void bdrv_drain_all_begin(void) { bool waited = true; BlockDriverState *bs; BdrvNextIterator it; GSList *aio_ctxs = NULL, *ctx; block_job_pause_all(); for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); bdrv_parent_drained_begin(bs); aio_disable_external(aio_context); aio_context_release(aio_context); if (!g_slist_find(aio_ctxs, aio_context)) { aio_ctxs = g_slist_prepend(aio_ctxs, aio_context); } } while (waited) { waited = false; for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) { AioContext *aio_context = ctx->data; aio_context_acquire(aio_context); for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { if (aio_context == bdrv_get_aio_context(bs)) { bdrv_drain_invoke(bs, true); waited |= bdrv_drain_recurse(bs, true); } } aio_context_release(aio_context); } } g_slist_free(aio_ctxs); }
1threat
Firebase Signin with phone verification and user profile creation with could functions : <p>I'm creating a server side rendered Angular application and i'am using firebase for backend tasks.</p> <p>I would like to know the best ways to achieve my authentication requirement that are as follow : </p> <ul> <li>user enter his name, email, password..etc.</li> <li>After hiting submit button a SMS must be sent to the user phone number with a 6 digits code.</li> <li>the user enter the code provided by sms, his account is created and his is redirected to login page.</li> </ul> <p>What is the best ways to create the user profile ? Cloud functions or client side ? how can i perfome SMS verification with Firebase ?</p>
0debug
Horizontal RecyclerView with items that have dynamic height : <p>So I need a horizontal RecyclerView. However the items in them have dynamic height based on what's returned from the backend.</p> <p>The RecyclerView and its items have height of "wrap_content"</p> <p>The problem is if the first visible items in the RecyclerView are small, then when the user scrolls to the larger items, they appear cut off.</p> <p>Ideally we want the RecyclerView to be large enough to hold the largest item in the group (but only the largest existing item... not the hypothetically largest item). The RecyclerView dynamically changing its height is also acceptable.</p> <p>I wrote an example app to illustrate the problem. In this app, we have a horizontal list. The first 33 items should show 1 line of text, while the next should show 3 lines of text, and the last 34 should show 2 lines. However, they all show 1 line, because the height of the RecyclerView doesn't change.</p> <p>I've tried calling requestLayout() on the RecyclerView (and on the TextView) from onBindViewHolder(), but it doesn't seem to do anything.</p> <p><strong>MainActivity</strong>:</p> <pre><code>public class MainActivity extends AppCompatActivity { private RecyclerView mRecyclerView; private RecyclerView.Adapter mAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mAdapter = createAdapter(); mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); mRecyclerView.setAdapter(mAdapter); } private RecyclerView.Adapter&lt;ViewHolder&gt; createAdapter() { RecyclerView.Adapter adapter = new RecyclerView.Adapter&lt;ViewHolder&gt;() { @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false); return new ViewHolder(v); } @Override public void onBindViewHolder(ViewHolder holder, int position) { if (position &lt; 33) { holder.mText.setText("1 line"); } else if (position &gt; 66) { holder.mText.setText("2 lines\n2 lines"); } else { holder.mText.setText("3 lines\n3 lines\n3 lines"); } } @Override public int getItemCount() { return 100; } }; return adapter; } private static class ViewHolder extends RecyclerView.ViewHolder { TextView mText; public ViewHolder(View itemView) { super(itemView); mText = (TextView) itemView.findViewById(R.id.text); } } } </code></pre> <p><strong>activity_main.xml:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>item.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#888888"&gt; &lt;TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hi" android:textSize="30sp" /&gt; &lt;/LinearLayout&gt; </code></pre>
0debug
How a delivery boy will get notification of each order placed customer : <p>I have developed an online food ordering app for restaurant , Now need to develop an delivery boy app , I am confused about how to get notification on delivery boy app of each orders placed by customer , i googled a lot , i could not find the exact solution.Can you please help me. Thank you in advance</p>
0debug
Siemens PLC programming best practices : <p>My question is pretty simple. Is there any useful place for learning to work with Siemens PLCs?</p>
0debug
How to display an element on hovering a different element : <p>I know this question has been asked many times but I could not find the answer based on my requirement. The screenshot here is from flat icon. So when i hover an icon two icons appear which I can click. How to achieve that?<a href="https://i.stack.imgur.com/XquMH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XquMH.jpg" alt="Screenshot of the example"></a></p>
0debug
void dsputil_init_mmi(void) { clear_blocks = clear_blocks_mmi; put_pixels_tab[1][0] = put_pixels8_mmi; put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi; put_pixels_tab[0][0] = put_pixels16_mmi; put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi; get_pixels = get_pixels_mmi; }
1threat
How to merge lines split with "\" at the very end with Python? : <p>I am now parsing some text. Some lines are very long such that they are splitted into several sub-lines with a "\" at the very end.</p> <p>I try to use regular expression to merge these sub-lines. However the escaped character "\n" and "\" make me confusing.</p> <p>Can someone show me how to accomplish this task with Python?</p>
0debug
concurrent map read and write when there is no concurrency : <p>The following go play example shows in a simplistic way what I have defined. I am passing a map as a copied value to a function (not a reference) as well as there is a recursion in my function which I assume passes by value as well. </p> <p><a href="https://play.golang.org/p/na6y6Wih4M" rel="nofollow noreferrer">https://play.golang.org/p/na6y6Wih4M</a></p> <pre><code>// this function has no write operations to dataMap, just reads // dataMap, in fact, has no write operations since it was copied func findParentAncestors(ID int, dataMap map[int]Data) []Data { results := []Data{} if _, ok := dataMap[ID]; ok { if parentData, ok := dataMap[dataMap[ID].ParentID]; ok { results = append(results, parentData) // recursion results = append(results, findParentAncestors(parentData.ID, dataMap)...) } } return results } </code></pre> <p>PROBLEM: somehow along my program execution, which involves much more data than this example (obviusly), an error <strong>"fatal error: concurrent map read and map write"</strong> points function <em>findParentAncestors()</em>:</p> <pre><code>main.findParentAncestors(0x39e3, 0xc82013ac90, 0x0, 0x0, 0x0) /opt/test/src/test.go:17 +0xa6 fp=0xc820269fb8 sp=0xc820269bd0 main.findParentAncestors(0x5d25, 0xc82013ac90, 0x0, 0x0, 0x0) /opt/test/src/test.go:21 +0x239 fp=0xc82026a3a0 sp=0xc820269fb8 </code></pre>
0debug
Xcode Objective C Yaw Pitch Roll : I'm trying to display the yaw pitch and roll of the device in a label. I cannot seem to get the values to display, it only shows a '...' where the numbers should be. This is my code, any help is greatly appreciated. #import "ViewController.h" #import <CoreMotion/CoreMotion.h> @interface ViewController (){ } @property (strong, nonatomic) CMMotionManager *motionManager; @end @implementation ViewController @synthesize motionManager; @synthesize roll; @synthesize pitch; @synthesize yaw; @synthesize xLabel; @synthesize yLabel; @synthesize zLabel; - (void)viewDidLoad { [super viewDidLoad]; /** Do any additional setup after loading the view, typically from a nib. UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer]; accelerometer.updateInterval = 1.0f/60.0f; accelerometer.delegate = self; **/ //motionManager = [[CMMotionManager alloc] init]; //motionManager.deviceMotionUpdateInterval = 1.0 / 60.0; motionManager = [[CMMotionManager alloc] init]; NSTimer *timer; timer = [NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(doGyroUpdate) userInfo:nil repeats:YES]; //CMDeviceMotion *deviceMotion = motionManager.deviceMotion; //CMAttitude *attitude = deviceMotion.attitude; [motionManager startDeviceMotionUpdates]; } -(void)doGyroUpdate { double x = motionManager.deviceMotion.attitude.roll*180/M_PI; double y = motionManager.deviceMotion.attitude.pitch*180/M_PI; double z = motionManager.deviceMotion.attitude.yaw*180/M_PI; NSString *myString = [NSString stringWithFormat:@"%g", x]; xLabel.text = myString; myString = [NSString stringWithFormat:@"%f", y]; yLabel.text = myString; myString = [NSString stringWithFormat:@"%f", z]; zLabel.text = myString; }
0debug
SimpleJson: String to JSONArray : <p>I get the following JSON:</p> <pre><code>[ { "user_id": "someValue" } ] </code></pre> <p>It's saved inside a String.</p> <p>I would like to convert it to a <code>JSONObject</code> which fails (as the constructor assumes a JSON to start with <code>{</code>). As this doesn't seem to be possible I'd like to convert it to a <code>JSONArray</code>. How can I do that with SimpleJson?</p>
0debug
Angular 2: formGroup expects a FormGroup instance. Please pass one in : <p>I am creating a form in Angular 2. My goal is to get data from the API and pass it into the form for editing purposes. However, I am running into this error:</p> <blockquote> <p>EXCEPTION: Uncaught (in promise): Error: Error in ./EditPatientComponent class EditPatientComponent - inline template:1:10 caused by: formGroup expects a FormGroup instance. Please pass one in.</p> </blockquote> <p>Here is the current code with the error.</p> <p><strong>html</strong></p> <pre><code>&lt;section class="CreatePatient"&gt; &lt;form [formGroup]="patientForm" (ngSubmit)="onSubmit()"&gt; &lt;div class="row"&gt; &lt;div class="form-group col-12 col-lg-3"&gt; &lt;label for="firstName"&gt;First Name&lt;/label&gt; &lt;input formControlName="firstName" type="text" class="form-control" id="firstName" &gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="col-12 col-lg-2"&gt; &lt;button type="submit" name="submit" class="btn btn-block btn-primary"&gt;Save&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/section&gt; </code></pre> <p><strong>ts</strong></p> <pre><code>import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormBuilder, FormGroup, FormControl } from '@angular/forms'; import { PatientService } from './patient.service'; import { Patient } from './patient'; @Component({ templateUrl: 'editpatient.component.html' }) export class EditPatientComponent implements OnInit { errorMessage: string; id: string; editMode = true; private patientForm: FormGroup; private patient: Patient; constructor( private patientService: PatientService, private router: Router, private activatedRoute: ActivatedRoute, private formBuilder: FormBuilder) { console.log("routes"); console.log(activatedRoute.snapshot.url[1].path); } ngOnInit() { this.getPatient(); } getPatient() { this.patientService.getPatient(this.activatedRoute.snapshot.url[1].path) .subscribe( patient =&gt; { this.id = this.activatedRoute.snapshot.url[1].path; this.patient = patient; this.initForm(); }, error =&gt; this.errorMessage = &lt;any&gt;error); } onSubmit(form){ console.log(this.patientForm); // Post the API }; initForm() { let patientFirstName = ''; if (this.editMode) { console.log(this.patient.firstName); console.log(this.patient.lastName); console.log(this.patient.participantUuid); patientFirstName = this.patient.firstName; } this.patientForm = new FormGroup({ 'firstName': new FormControl(patientFirstName) }) }; } </code></pre> <p>Any help/pointing me in the right direction would be great! Thanks!</p>
0debug
static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset, bool write) { BDRVVPCState *s = bs->opaque; uint64_t bitmap_offset, block_offset; uint32_t pagetable_index, offset_in_block; pagetable_index = offset / s->block_size; offset_in_block = offset % s->block_size; if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff) return -1; bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index]; block_offset = bitmap_offset + s->bitmap_size + offset_in_block; if (write && (s->last_bitmap_offset != bitmap_offset)) { uint8_t bitmap[s->bitmap_size]; s->last_bitmap_offset = bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size); } return block_offset; }
1threat
static USBDevice *usb_msd_init(USBBus *bus, const char *filename) { static int nr=0; char id[8]; QemuOpts *opts; DriveInfo *dinfo; USBDevice *dev; const char *p1; char fmt[32]; do { snprintf(id, sizeof(id), "usb%d", nr++); opts = qemu_opts_create(qemu_find_opts("drive"), id, 1, NULL); } while (!opts); p1 = strchr(filename, ':'); if (p1++) { const char *p2; if (strstart(filename, "format=", &p2)) { int len = MIN(p1 - p2, sizeof(fmt)); pstrcpy(fmt, len, p2); qemu_opt_set(opts, "format", fmt); } else if (*filename != ':') { error_report("unrecognized USB mass-storage option %s", filename); return NULL; } filename = p1; } if (!*filename) { error_report("block device specification needed"); return NULL; } qemu_opt_set(opts, "file", filename); qemu_opt_set(opts, "if", "none"); dinfo = drive_new(opts, 0); if (!dinfo) { qemu_opts_del(opts); return NULL; } dev = usb_create(bus, "usb-storage"); if (!dev) { return NULL; } if (qdev_prop_set_drive(&dev->qdev, "drive", blk_bs(blk_by_legacy_dinfo(dinfo))) < 0) { object_unparent(OBJECT(dev)); return NULL; } if (qdev_init(&dev->qdev) < 0) return NULL; return dev; }
1threat
Changing image Dynamically in android uisng thread : <p>I want to change the image dynamically with its link in a thread. </p> <pre><code>public class MainActivity extends AppCompatActivity { public static final Integer[] images = { R.drawable.vr_final_icon, R.drawable.playnew }; public static final String[] Links = { "http://stackoverflow.com/questions/541487/implements-runnable-vs-extends-thread", "http://www.facebook.com", }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new Thread(new Runnable() { @Override public void run() { try { Random r = new Random(); int Low = 0; int High = images.length; final int Result = r.nextInt(High - Low) + Low; INCP(Result); Thread.sleep(6000); run(); } catch (Exception e) { e.printStackTrace(); } } public void INCP(final int incp) { Drawable res = getResources().getDrawable(images[incp]); ImageView INCPimage = (ImageView) findViewById(R.id.INCP); INCPimage.setImageDrawable(res); INCPimage.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse(Links[incp])); startActivity(intent); } }); } }).start(); } </code></pre> <p>}</p> <p>But it gives me error that </p> <blockquote> <p>Only the original thread that created a view hierarchy can touch its views.</p> </blockquote> <p>How can i solve it ! I want image to change dynamically with its link on run time.</p>
0debug
Can scoped_lock lock a shared_mutex in read mode? : <p>C++17 introduced both <code>std::shared_mutex</code> and <code>std::scoped_lock</code>. My problem is now, that it seems, that <code>scoped_lock</code> will lock a shared mutex always in exclusive (writer) mode, when it is passed as an argument, and not in shared (reader) mode. In my app, I need to update an object <code>dst</code> with data from an object <code>src</code>. I want to lock <code>src</code> shared and <code>dst</code> exclusive. Unfortunately, this has the potential for deadlock, if a call to another update method with <code>src</code> and <code>dst</code> switched occurs at the same time. So I would like to use the fancy deadlock avoidance mechanisms of <code>std::scoped_lock</code>.</p> <p>I could use <code>scoped_lock</code> to lock both <code>src</code> and <code>dst</code> in exclusive mode, but that unnecessarily strict lock has performance backdraws elsewhere. However, it seems, that it is possible to wrap <code>src</code>'s <code>shared_mutex</code> into a <code>std::shared_lock</code> and use that with the <code>scoped_lock</code>: When the <code>scoped_lock</code> during its locking action calls <code>try_lock()</code> on the <code>shared_lock</code>, the later will actually call <code>try_shared_lock()</code> on <code>src</code>'s <code>shared_mutex</code>, and that's what I need.</p> <p>So my code looks as simple as this:</p> <pre><code>struct data { mutable std::shared_mutex mutex; // actual data follows }; void update(const data&amp; src, data&amp; dst) { std::shared_lock slock(src.mutex, std::defer_lock); std::scoped_lock lockall(slock, dst.mutex); // now can safely update dst with src??? } </code></pre> <p>Is it safe to use a (shared) lock guard like this inside another (deadlock avoidance) lock guard?</p>
0debug
PaaS Offerings for Node.js : <p>I keep finding blogs and articles that list Digital Ocean and Linode as having PaaS offerings for Node.js. This is bothering me because I've hosted apps on both Linode and Digital Ocean and although they do have one-click installs of Node.js or MongoDB stacks, You are still responsible as a developer for securing your infrastructure, managing it, upgrading it, etc.</p> <p><a href="https://modulus.io/nodejs" rel="nofollow noreferrer">Modulus</a> is something i've been looking at that seems to be a truly PaaS platform for Node.js.</p> <p>Am i misunderstanding the definition of PaaS or are all these blogs/articles talking about Digital Ocean and Linode having PaaS offerings for Node.js actually incorrect?</p>
0debug
static void selfTest(uint8_t *src[3], int stride[3], int w, int h){ enum PixelFormat srcFormat, dstFormat; int srcW, srcH, dstW, dstH; int flags; for(srcFormat = 0; srcFormat < PIX_FMT_NB; srcFormat++) { for(dstFormat = 0; dstFormat < PIX_FMT_NB; dstFormat++) { printf("%s -> %s\n", sws_format_name(srcFormat), sws_format_name(dstFormat)); srcW= w; srcH= h; for(dstW=w - w/3; dstW<= 4*w/3; dstW+= w/3){ for(dstH=h - h/3; dstH<= 4*h/3; dstH+= h/3){ for(flags=1; flags<33; flags*=2) { int res; res = doTest(src, stride, w, h, srcFormat, dstFormat, srcW, srcH, dstW, dstH, flags); if (res < 0) { dstW = 4 * w / 3; dstH = 4 * h / 3; flags = 33; } } } } } } }
1threat
Having mounted() only run once on a component Vue.js : <p>I have two components that conditionally render with <code>v-if</code>:</p> <pre><code>&lt;Element v-if="this.mode === 'mode'"/&gt; &lt;OtherElement v-if="this.mode !== 'mode'"/&gt; </code></pre> <p>I have load-in animations for both components that I have under <code>mounted()</code>, that I only want to run the <em>first</em> time they are loaded. But with mounted, each time the component is recreated when <code>this.mode</code> changes, the animations trigger again. How can I avoid this?</p>
0debug
static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long sval) { static const S390Opcode lli_insns[4] = { RI_LLILL, RI_LLILH, RI_LLIHL, RI_LLIHH }; tcg_target_ulong uval = sval; int i; if (type == TCG_TYPE_I32) { uval = (uint32_t)sval; sval = (int32_t)sval; } if (sval >= -0x8000 && sval < 0x8000) { tcg_out_insn(s, RI, LGHI, ret, sval); return; } for (i = 0; i < 4; i++) { tcg_target_long mask = 0xffffull << i*16; if ((uval & mask) == uval) { tcg_out_insn_RI(s, lli_insns[i], ret, uval >> i*16); return; } } if (facilities & FACILITY_EXT_IMM) { if (sval == (int32_t)sval) { tcg_out_insn(s, RIL, LGFI, ret, sval); return; } if (uval <= 0xffffffff) { tcg_out_insn(s, RIL, LLILF, ret, uval); return; } if ((uval & 0xffffffff) == 0) { tcg_out_insn(s, RIL, LLIHF, ret, uval >> 31 >> 1); return; } } if ((sval & 1) == 0) { ptrdiff_t off = tcg_pcrel_diff(s, (void *)sval) >> 1; if (off == (int32_t)off) { tcg_out_insn(s, RIL, LARL, ret, off); return; } } if (!(facilities & FACILITY_EXT_IMM)) { if (uval <= 0xffffffff) { tcg_out_insn(s, RI, LLILL, ret, uval); tcg_out_insn(s, RI, IILH, ret, uval >> 16); return; } if (sval >> 31 >> 1 == -1) { if (uval & 0x8000) { tcg_out_insn(s, RI, LGHI, ret, uval); } else { tcg_out_insn(s, RI, LGHI, ret, -1); tcg_out_insn(s, RI, IILL, ret, uval); } tcg_out_insn(s, RI, IILH, ret, uval >> 16); return; } } tcg_out_movi(s, TCG_TYPE_I64, ret, uval & 0xffffffff); uval = uval >> 31 >> 1; if (facilities & FACILITY_EXT_IMM) { if (uval < 0x10000) { tcg_out_insn(s, RI, IIHL, ret, uval); } else if ((uval & 0xffff) == 0) { tcg_out_insn(s, RI, IIHH, ret, uval >> 16); } else { tcg_out_insn(s, RIL, IIHF, ret, uval); } } else { if (uval & 0xffff) { tcg_out_insn(s, RI, IIHL, ret, uval); } if (uval & 0xffff0000) { tcg_out_insn(s, RI, IIHH, ret, uval >> 16); } } }
1threat
How can i get my C# application on another computer? : <p>I have created a small C# application on my home computer using Visual Studio 2015 and Id like to use this small application on my computer at work. Can someone point me to a tutorial/video to help me accomplish this? thanks. </p>
0debug
int bdrv_open(BlockDriverState *bs, const char *filename, int flags, BlockDriver *drv) { int ret; char tmp_filename[PATH_MAX]; if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; int is_protocol = 0; BlockDriver *bdrv_qcow2; QEMUOptionParameter *options; char backing_filename[PATH_MAX]; bs1 = bdrv_new(""); ret = bdrv_open(bs1, filename, 0, drv); if (ret < 0) { bdrv_delete(bs1); return ret; } total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK; if (bs1->drv && bs1->drv->protocol_name) is_protocol = 1; bdrv_delete(bs1); get_tmp_filename(tmp_filename, sizeof(tmp_filename)); if (is_protocol) snprintf(backing_filename, sizeof(backing_filename), "%s", filename); else if (!realpath(filename, backing_filename)) return -errno; bdrv_qcow2 = bdrv_find_format("qcow2"); options = parse_option_parameters("", bdrv_qcow2->create_options, NULL); set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size); set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename); if (drv) { set_option_parameter(options, BLOCK_OPT_BACKING_FMT, drv->format_name); } ret = bdrv_create(bdrv_qcow2, tmp_filename, options); free_option_parameters(options); if (ret < 0) { return ret; } filename = tmp_filename; drv = bdrv_qcow2; bs->is_temporary = 1; } if (!drv) { ret = find_image_format(filename, &drv); } if (!drv) { goto unlink_and_fail; } ret = bdrv_open_common(bs, filename, flags, drv); if (ret < 0) { goto unlink_and_fail; } if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') { char backing_filename[PATH_MAX]; int back_flags; BlockDriver *back_drv = NULL; bs->backing_hd = bdrv_new(""); bdrv_get_full_backing_filename(bs, backing_filename, sizeof(backing_filename)); if (bs->backing_format[0] != '\0') { back_drv = bdrv_find_format(bs->backing_format); } back_flags = flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); ret = bdrv_open(bs->backing_hd, backing_filename, back_flags, back_drv); if (ret < 0) { bdrv_close(bs); return ret; } if (bs->is_temporary) { bs->backing_hd->keep_read_only = !(flags & BDRV_O_RDWR); } else { bs->backing_hd->keep_read_only = bs->keep_read_only; } } if (!bdrv_key_required(bs)) { bdrv_dev_change_media_cb(bs, true); } if (bs->io_limits_enabled) { bdrv_io_limits_enable(bs); } return 0; unlink_and_fail: if (bs->is_temporary) { unlink(filename); } return ret; }
1threat
ListView add item android studio : XML <?xml version="1.0"?> <FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorBackground"> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="51dp" android:layout_height="51dp" android:layout_gravity="bottom" android:layout_margin="16dp" android:layout_marginBottom="8dp" android:layout_marginEnd="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:clickable="true" android:onClick="add_item" android:src="@mipmap/plus_two" app:backgroundTint="@color/colorPrimary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="0.984" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.982" /> </android.support.constraint.ConstraintLayout> <ListView android:id="@+id/lv" android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawSelectorOnTop="false" tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteY="16dp" /> </FrameLayout> http://prntscr.com/fuk5x8 I would like to add an item when I click the FAB, And even when you left the app, it kept your data saved. I've been trying all afternoon and I was not successful ;-; thanks in advance
0debug
static int aiff_probe(AVProbeData *p) { if (p->buf_size < 16) return 0; if (p->buf[0] == 'F' && p->buf[1] == 'O' && p->buf[2] == 'R' && p->buf[3] == 'M' && p->buf[8] == 'A' && p->buf[9] == 'I' && p->buf[10] == 'F' && (p->buf[11] == 'F' || p->buf[11] == 'C')) return AVPROBE_SCORE_MAX; else return 0; }
1threat
static int nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { NVENCSTATUS nv_status; NvencOutputSurface *tmpoutsurf; int res, i = 0; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; NV_ENC_PIC_PARAMS pic_params = { 0 }; pic_params.version = NV_ENC_PIC_PARAMS_VER; if (frame) { NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 }; NvencInputSurface *inSurf = NULL; for (i = 0; i < ctx->max_surface_count; ++i) { if (!ctx->input_surfaces[i].lockCount) { inSurf = &ctx->input_surfaces[i]; break; } } av_assert0(inSurf); inSurf->lockCount = 1; lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER; lockBufferParams.inputBuffer = inSurf->input_surface; nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed locking nvenc input buffer\n"); return 0; } if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) { uint8_t *buf = lockBufferParams.bufferDataPtr; av_image_copy_plane(buf, lockBufferParams.pitch, frame->data[0], frame->linesize[0], avctx->width, avctx->height); buf += inSurf->height * lockBufferParams.pitch; av_image_copy_plane(buf, lockBufferParams.pitch >> 1, frame->data[2], frame->linesize[2], avctx->width >> 1, avctx->height >> 1); buf += (inSurf->height * lockBufferParams.pitch) >> 2; av_image_copy_plane(buf, lockBufferParams.pitch >> 1, frame->data[1], frame->linesize[1], avctx->width >> 1, avctx->height >> 1); } else if (avctx->pix_fmt == AV_PIX_FMT_NV12) { uint8_t *buf = lockBufferParams.bufferDataPtr; av_image_copy_plane(buf, lockBufferParams.pitch, frame->data[0], frame->linesize[0], avctx->width, avctx->height); buf += inSurf->height * lockBufferParams.pitch; av_image_copy_plane(buf, lockBufferParams.pitch, frame->data[1], frame->linesize[1], avctx->width, avctx->height >> 1); } else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P) { uint8_t *buf = lockBufferParams.bufferDataPtr; av_image_copy_plane(buf, lockBufferParams.pitch, frame->data[0], frame->linesize[0], avctx->width, avctx->height); buf += inSurf->height * lockBufferParams.pitch; av_image_copy_plane(buf, lockBufferParams.pitch, frame->data[1], frame->linesize[1], avctx->width, avctx->height); buf += inSurf->height * lockBufferParams.pitch; av_image_copy_plane(buf, lockBufferParams.pitch, frame->data[2], frame->linesize[2], avctx->width, avctx->height); } else { av_log(avctx, AV_LOG_FATAL, "Invalid pixel format!\n"); return AVERROR(EINVAL); } nv_status = p_nvenc->nvEncUnlockInputBuffer(ctx->nvencoder, inSurf->input_surface); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed unlocking input buffer!\n"); return AVERROR_EXTERNAL; } for (i = 0; i < ctx->max_surface_count; ++i) if (!ctx->output_surfaces[i].busy) break; if (i == ctx->max_surface_count) { inSurf->lockCount = 0; av_log(avctx, AV_LOG_FATAL, "No free output surface found!\n"); return AVERROR_EXTERNAL; } ctx->output_surfaces[i].input_surface = inSurf; pic_params.inputBuffer = inSurf->input_surface; pic_params.bufferFmt = inSurf->format; pic_params.inputWidth = avctx->width; pic_params.inputHeight = avctx->height; pic_params.outputBitstream = ctx->output_surfaces[i].output_surface; pic_params.completionEvent = 0; if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { if (frame->top_field_first) { pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM; } else { pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP; } } else { pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FRAME; } pic_params.encodePicFlags = 0; pic_params.inputTimeStamp = frame->pts; pic_params.inputDuration = 0; switch (avctx->codec->id) { case AV_CODEC_ID_H264: pic_params.codecPicParams.h264PicParams.sliceMode = ctx->encode_config.encodeCodecConfig.h264Config.sliceMode; pic_params.codecPicParams.h264PicParams.sliceModeData = ctx->encode_config.encodeCodecConfig.h264Config.sliceModeData; break; case AV_CODEC_ID_H265: pic_params.codecPicParams.hevcPicParams.sliceMode = ctx->encode_config.encodeCodecConfig.hevcConfig.sliceMode; pic_params.codecPicParams.hevcPicParams.sliceModeData = ctx->encode_config.encodeCodecConfig.hevcConfig.sliceModeData; break; default: av_log(avctx, AV_LOG_ERROR, "Unknown codec name\n"); return AVERROR(EINVAL); } res = timestamp_queue_enqueue(&ctx->timestamp_list, frame->pts); if (res) return res; } else { pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS; } nv_status = p_nvenc->nvEncEncodePicture(ctx->nvencoder, &pic_params); if (frame && nv_status == NV_ENC_ERR_NEED_MORE_INPUT) { res = out_surf_queue_enqueue(&ctx->output_surface_queue, &ctx->output_surfaces[i]); if (res) return res; ctx->output_surfaces[i].busy = 1; } if (nv_status != NV_ENC_SUCCESS && nv_status != NV_ENC_ERR_NEED_MORE_INPUT) { av_log(avctx, AV_LOG_ERROR, "EncodePicture failed!\n"); return AVERROR_EXTERNAL; } if (nv_status != NV_ENC_ERR_NEED_MORE_INPUT) { while (ctx->output_surface_queue.count) { tmpoutsurf = out_surf_queue_dequeue(&ctx->output_surface_queue); res = out_surf_queue_enqueue(&ctx->output_surface_ready_queue, tmpoutsurf); if (res) return res; } if (frame) { res = out_surf_queue_enqueue(&ctx->output_surface_ready_queue, &ctx->output_surfaces[i]); if (res) return res; ctx->output_surfaces[i].busy = 1; } } if (ctx->output_surface_ready_queue.count && (!frame || ctx->output_surface_ready_queue.count + ctx->output_surface_queue.count >= ctx->buffer_delay)) { tmpoutsurf = out_surf_queue_dequeue(&ctx->output_surface_ready_queue); res = process_output_surface(avctx, pkt, tmpoutsurf); if (res) return res; tmpoutsurf->busy = 0; av_assert0(tmpoutsurf->input_surface->lockCount); tmpoutsurf->input_surface->lockCount--; *got_packet = 1; } else { *got_packet = 0; } return 0; }
1threat
C store digit and spaces in char array : <p>How can i store digits and spaces in an array? I am using a char array. Here is my code: </p> <pre><code>char m[100]; int i; for(i = 0; i &lt; 5; i++) if(i == 2) m[i] = ' '; else m[i] = i; </code></pre> <p>How can i print the content of m? (01 34)</p>
0debug
int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { int offset = 0; int ret; while (nb_sectors > NBD_MAX_SECTORS) { ret = nbd_co_writev_1(client, sector_num, NBD_MAX_SECTORS, qiov, offset); if (ret < 0) { return ret; } offset += NBD_MAX_SECTORS * 512; sector_num += NBD_MAX_SECTORS; nb_sectors -= NBD_MAX_SECTORS; } return nbd_co_writev_1(client, sector_num, nb_sectors, qiov, offset); }
1threat
Overwrite wordpress css? : <p>So i am currently creating a website for a eSports team in wordpress, and i have just ran into a problem, that i do not remember how to sort out. I remember from making chrome extensions there is a method for doing this, but i do not remember, and that is why i am here now :)</p> <p><a href="https://i.stack.imgur.com/0nLYB.png" rel="nofollow noreferrer">First code</a> As you can see on the picture, that is what is in the CSS, and i need to keep that for other pages, but i want my one page to overwrite that. I have a box where i am allowed to add custom CSS, but when i add the code, it gets overwritten by the old code. I know why this happends, but not how to fix it without changing the original css (which i would prefer to avoid)</p> <p><a href="https://i.gyazo.com/823cdc79449f2bb2905eab8a1828f338.png" rel="nofollow noreferrer">Overwritten code</a></p> <p>So my question is, how to i make my new css overwrite my old css? (i have tried !important and it does nothing)</p>
0debug
Relative import error with py2exe : <p>I was trying to generate an executable for a simple Python script. My setup.py code looks like this:</p> <pre><code>from distutils.core import setup import py2exe setup(console=["script.py"]) </code></pre> <p>However, I am getting the error shown in the screenshot. Is there something I could try to fix this? I am using Windows 10.</p> <p><a href="https://i.stack.imgur.com/LDbbL.png"><img src="https://i.stack.imgur.com/LDbbL.png" alt="enter image description here"></a></p>
0debug
case when in where in sql : DECLARE @ONum int --variable DECLARE @CrUsId nvarchar(128)='D901D15C-62FA-4243-A3DB-D3D448DC3F91'--assign value DECLARE @From Datetime =4/2/2017 --assign value DECLARE @To Datetime = 25/2/2017 --assign value `declare @day nvarchar(50)` `select * from PurchaseOrder` where CreateUserID = CASE @CrUsId WHEN @CrUsId = '' THEN CreateUserID WHEN @CrUsId <> CreateUserID THEN NULL -- if input is some text but WHEN @CrUsId IS NULL THEN CreateUserID WHEN @CrUsId != '' AND CreateUserID = @CrUsId THEN CreateUserID END
0debug
m_free(struct mbuf *m) { DEBUG_CALL("m_free"); DEBUG_ARG("m = %lx", (long )m); if(m) { if (m->m_flags & M_USEDLIST) remque(m); if (m->m_flags & M_EXT) free(m->m_ext); if (m->m_flags & M_DOFREE) { free(m); m->slirp->mbuf_alloced--; } else if ((m->m_flags & M_FREELIST) == 0) { insque(m,&m->slirp->m_freelist); m->m_flags = M_FREELIST; } } }
1threat
PDO Btc number addition error : $score = $_GET['score']; $ht = $ayarcek['total']; $total = $ht+$score;`` echo $total; Result: 6.0E-8 I want to summarize the numbers 1.000000 + 0 or 1.000000 + 1.000000 but when I do the collection I get the above result. Where could I have done wrong? (BTC)
0debug
Programming language to write logic for microsoft sql server : I've been using microsoft sql server to write queries. I was browsing online and i found that python and c# can be used to write query logic as well. I was wondering is it more efficient to use another programming language instead of SQL for microsoft sql server?
0debug
tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr) { tcg_target_ulong next_tb = 0; env = cpustate; tci_reg[TCG_AREG0] = (tcg_target_ulong)env; assert(tb_ptr); for (;;) { #if defined(GETPC) tci_tb_ptr = (uintptr_t)tb_ptr; #endif TCGOpcode opc = tb_ptr[0]; #if !defined(NDEBUG) uint8_t op_size = tb_ptr[1]; uint8_t *old_code_ptr = tb_ptr; #endif tcg_target_ulong t0; tcg_target_ulong t1; tcg_target_ulong t2; tcg_target_ulong label; TCGCond condition; target_ulong taddr; #ifndef CONFIG_SOFTMMU tcg_target_ulong host_addr; #endif uint8_t tmp8; uint16_t tmp16; uint32_t tmp32; uint64_t tmp64; #if TCG_TARGET_REG_BITS == 32 uint64_t v64; #endif tb_ptr += 2; switch (opc) { case INDEX_op_end: case INDEX_op_nop: break; case INDEX_op_nop1: case INDEX_op_nop2: case INDEX_op_nop3: case INDEX_op_nopn: case INDEX_op_discard: TODO(); break; case INDEX_op_set_label: TODO(); break; case INDEX_op_call: t0 = tci_read_ri(&tb_ptr); #if TCG_TARGET_REG_BITS == 32 tmp64 = ((helper_function)t0)(tci_read_reg(TCG_REG_R0), tci_read_reg(TCG_REG_R1), tci_read_reg(TCG_REG_R2), tci_read_reg(TCG_REG_R3), tci_read_reg(TCG_REG_R5), tci_read_reg(TCG_REG_R6), tci_read_reg(TCG_REG_R7), tci_read_reg(TCG_REG_R8), tci_read_reg(TCG_REG_R9), tci_read_reg(TCG_REG_R10)); tci_write_reg(TCG_REG_R0, tmp64); tci_write_reg(TCG_REG_R1, tmp64 >> 32); #else tmp64 = ((helper_function)t0)(tci_read_reg(TCG_REG_R0), tci_read_reg(TCG_REG_R1), tci_read_reg(TCG_REG_R2), tci_read_reg(TCG_REG_R3), tci_read_reg(TCG_REG_R5)); tci_write_reg(TCG_REG_R0, tmp64); #endif break; case INDEX_op_br: label = tci_read_label(&tb_ptr); assert(tb_ptr == old_code_ptr + op_size); tb_ptr = (uint8_t *)label; continue; case INDEX_op_setcond_i32: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); condition = *tb_ptr++; tci_write_reg32(t0, tci_compare32(t1, t2, condition)); break; #if TCG_TARGET_REG_BITS == 32 case INDEX_op_setcond2_i32: t0 = *tb_ptr++; tmp64 = tci_read_r64(&tb_ptr); v64 = tci_read_ri64(&tb_ptr); condition = *tb_ptr++; tci_write_reg32(t0, tci_compare64(tmp64, v64, condition)); break; #elif TCG_TARGET_REG_BITS == 64 case INDEX_op_setcond_i64: t0 = *tb_ptr++; t1 = tci_read_r64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); condition = *tb_ptr++; tci_write_reg64(t0, tci_compare64(t1, t2, condition)); break; #endif case INDEX_op_mov_i32: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); tci_write_reg32(t0, t1); break; case INDEX_op_movi_i32: t0 = *tb_ptr++; t1 = tci_read_i32(&tb_ptr); tci_write_reg32(t0, t1); break; case INDEX_op_ld8u_i32: t0 = *tb_ptr++; t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); tci_write_reg8(t0, *(uint8_t *)(t1 + t2)); break; case INDEX_op_ld8s_i32: case INDEX_op_ld16u_i32: TODO(); break; case INDEX_op_ld16s_i32: TODO(); break; case INDEX_op_ld_i32: t0 = *tb_ptr++; t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); tci_write_reg32(t0, *(uint32_t *)(t1 + t2)); break; case INDEX_op_st8_i32: t0 = tci_read_r8(&tb_ptr); t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); *(uint8_t *)(t1 + t2) = t0; break; case INDEX_op_st16_i32: t0 = tci_read_r16(&tb_ptr); t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); *(uint16_t *)(t1 + t2) = t0; break; case INDEX_op_st_i32: t0 = tci_read_r32(&tb_ptr); t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); *(uint32_t *)(t1 + t2) = t0; break; case INDEX_op_add_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 + t2); break; case INDEX_op_sub_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 - t2); break; case INDEX_op_mul_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 * t2); break; #if TCG_TARGET_HAS_div_i32 case INDEX_op_div_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, (int32_t)t1 / (int32_t)t2); break; case INDEX_op_divu_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 / t2); break; case INDEX_op_rem_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, (int32_t)t1 % (int32_t)t2); break; case INDEX_op_remu_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 % t2); break; #elif TCG_TARGET_HAS_div2_i32 case INDEX_op_div2_i32: case INDEX_op_divu2_i32: TODO(); break; #endif case INDEX_op_and_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 & t2); break; case INDEX_op_or_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 | t2); break; case INDEX_op_xor_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 ^ t2); break; case INDEX_op_shl_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 << t2); break; case INDEX_op_shr_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, t1 >> t2); break; case INDEX_op_sar_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, ((int32_t)t1 >> t2)); break; #if TCG_TARGET_HAS_rot_i32 case INDEX_op_rotl_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, (t1 << t2) | (t1 >> (32 - t2))); break; case INDEX_op_rotr_i32: t0 = *tb_ptr++; t1 = tci_read_ri32(&tb_ptr); t2 = tci_read_ri32(&tb_ptr); tci_write_reg32(t0, (t1 >> t2) | (t1 << (32 - t2))); break; #endif #if TCG_TARGET_HAS_deposit_i32 case INDEX_op_deposit_i32: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); t2 = tci_read_r32(&tb_ptr); tmp16 = *tb_ptr++; tmp8 = *tb_ptr++; tmp32 = (((1 << tmp8) - 1) << tmp16); tci_write_reg32(t0, (t1 & ~tmp32) | ((t2 << tmp16) & tmp32)); break; #endif case INDEX_op_brcond_i32: t0 = tci_read_r32(&tb_ptr); t1 = tci_read_ri32(&tb_ptr); condition = *tb_ptr++; label = tci_read_label(&tb_ptr); if (tci_compare32(t0, t1, condition)) { assert(tb_ptr == old_code_ptr + op_size); tb_ptr = (uint8_t *)label; continue; } break; #if TCG_TARGET_REG_BITS == 32 case INDEX_op_add2_i32: t0 = *tb_ptr++; t1 = *tb_ptr++; tmp64 = tci_read_r64(&tb_ptr); tmp64 += tci_read_r64(&tb_ptr); tci_write_reg64(t1, t0, tmp64); break; case INDEX_op_sub2_i32: t0 = *tb_ptr++; t1 = *tb_ptr++; tmp64 = tci_read_r64(&tb_ptr); tmp64 -= tci_read_r64(&tb_ptr); tci_write_reg64(t1, t0, tmp64); break; case INDEX_op_brcond2_i32: tmp64 = tci_read_r64(&tb_ptr); v64 = tci_read_ri64(&tb_ptr); condition = *tb_ptr++; label = tci_read_label(&tb_ptr); if (tci_compare64(tmp64, v64, condition)) { assert(tb_ptr == old_code_ptr + op_size); tb_ptr = (uint8_t *)label; continue; } break; case INDEX_op_mulu2_i32: t0 = *tb_ptr++; t1 = *tb_ptr++; t2 = tci_read_r32(&tb_ptr); tmp64 = tci_read_r32(&tb_ptr); tci_write_reg64(t1, t0, t2 * tmp64); break; #endif #if TCG_TARGET_HAS_ext8s_i32 case INDEX_op_ext8s_i32: t0 = *tb_ptr++; t1 = tci_read_r8s(&tb_ptr); tci_write_reg32(t0, t1); break; #endif #if TCG_TARGET_HAS_ext16s_i32 case INDEX_op_ext16s_i32: t0 = *tb_ptr++; t1 = tci_read_r16s(&tb_ptr); tci_write_reg32(t0, t1); break; #endif #if TCG_TARGET_HAS_ext8u_i32 case INDEX_op_ext8u_i32: t0 = *tb_ptr++; t1 = tci_read_r8(&tb_ptr); tci_write_reg32(t0, t1); break; #endif #if TCG_TARGET_HAS_ext16u_i32 case INDEX_op_ext16u_i32: t0 = *tb_ptr++; t1 = tci_read_r16(&tb_ptr); tci_write_reg32(t0, t1); break; #endif #if TCG_TARGET_HAS_bswap16_i32 case INDEX_op_bswap16_i32: t0 = *tb_ptr++; t1 = tci_read_r16(&tb_ptr); tci_write_reg32(t0, bswap16(t1)); break; #endif #if TCG_TARGET_HAS_bswap32_i32 case INDEX_op_bswap32_i32: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); tci_write_reg32(t0, bswap32(t1)); break; #endif #if TCG_TARGET_HAS_not_i32 case INDEX_op_not_i32: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); tci_write_reg32(t0, ~t1); break; #endif #if TCG_TARGET_HAS_neg_i32 case INDEX_op_neg_i32: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); tci_write_reg32(t0, -t1); break; #endif #if TCG_TARGET_REG_BITS == 64 case INDEX_op_mov_i64: t0 = *tb_ptr++; t1 = tci_read_r64(&tb_ptr); tci_write_reg64(t0, t1); break; case INDEX_op_movi_i64: t0 = *tb_ptr++; t1 = tci_read_i64(&tb_ptr); tci_write_reg64(t0, t1); break; case INDEX_op_ld8u_i64: t0 = *tb_ptr++; t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); tci_write_reg8(t0, *(uint8_t *)(t1 + t2)); break; case INDEX_op_ld8s_i64: case INDEX_op_ld16u_i64: case INDEX_op_ld16s_i64: TODO(); break; case INDEX_op_ld32u_i64: t0 = *tb_ptr++; t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); tci_write_reg32(t0, *(uint32_t *)(t1 + t2)); break; case INDEX_op_ld32s_i64: t0 = *tb_ptr++; t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); tci_write_reg32s(t0, *(int32_t *)(t1 + t2)); break; case INDEX_op_ld_i64: t0 = *tb_ptr++; t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); tci_write_reg64(t0, *(uint64_t *)(t1 + t2)); break; case INDEX_op_st8_i64: t0 = tci_read_r8(&tb_ptr); t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); *(uint8_t *)(t1 + t2) = t0; break; case INDEX_op_st16_i64: t0 = tci_read_r16(&tb_ptr); t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); *(uint16_t *)(t1 + t2) = t0; break; case INDEX_op_st32_i64: t0 = tci_read_r32(&tb_ptr); t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); *(uint32_t *)(t1 + t2) = t0; break; case INDEX_op_st_i64: t0 = tci_read_r64(&tb_ptr); t1 = tci_read_r(&tb_ptr); t2 = tci_read_i32(&tb_ptr); *(uint64_t *)(t1 + t2) = t0; break; case INDEX_op_add_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 + t2); break; case INDEX_op_sub_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 - t2); break; case INDEX_op_mul_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 * t2); break; #if TCG_TARGET_HAS_div_i64 case INDEX_op_div_i64: case INDEX_op_divu_i64: case INDEX_op_rem_i64: case INDEX_op_remu_i64: TODO(); break; #elif TCG_TARGET_HAS_div2_i64 case INDEX_op_div2_i64: case INDEX_op_divu2_i64: TODO(); break; #endif case INDEX_op_and_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 & t2); break; case INDEX_op_or_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 | t2); break; case INDEX_op_xor_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 ^ t2); break; case INDEX_op_shl_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 << t2); break; case INDEX_op_shr_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, t1 >> t2); break; case INDEX_op_sar_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(&tb_ptr); t2 = tci_read_ri64(&tb_ptr); tci_write_reg64(t0, ((int64_t)t1 >> t2)); break; #if TCG_TARGET_HAS_rot_i64 case INDEX_op_rotl_i64: case INDEX_op_rotr_i64: TODO(); break; #endif #if TCG_TARGET_HAS_deposit_i64 case INDEX_op_deposit_i64: t0 = *tb_ptr++; t1 = tci_read_r64(&tb_ptr); t2 = tci_read_r64(&tb_ptr); tmp16 = *tb_ptr++; tmp8 = *tb_ptr++; tmp64 = (((1ULL << tmp8) - 1) << tmp16); tci_write_reg64(t0, (t1 & ~tmp64) | ((t2 << tmp16) & tmp64)); break; #endif case INDEX_op_brcond_i64: t0 = tci_read_r64(&tb_ptr); t1 = tci_read_ri64(&tb_ptr); condition = *tb_ptr++; label = tci_read_label(&tb_ptr); if (tci_compare64(t0, t1, condition)) { assert(tb_ptr == old_code_ptr + op_size); tb_ptr = (uint8_t *)label; continue; } break; #if TCG_TARGET_HAS_ext8u_i64 case INDEX_op_ext8u_i64: t0 = *tb_ptr++; t1 = tci_read_r8(&tb_ptr); tci_write_reg64(t0, t1); break; #endif #if TCG_TARGET_HAS_ext8s_i64 case INDEX_op_ext8s_i64: t0 = *tb_ptr++; t1 = tci_read_r8s(&tb_ptr); tci_write_reg64(t0, t1); break; #endif #if TCG_TARGET_HAS_ext16s_i64 case INDEX_op_ext16s_i64: t0 = *tb_ptr++; t1 = tci_read_r16s(&tb_ptr); tci_write_reg64(t0, t1); break; #endif #if TCG_TARGET_HAS_ext16u_i64 case INDEX_op_ext16u_i64: t0 = *tb_ptr++; t1 = tci_read_r16(&tb_ptr); tci_write_reg64(t0, t1); break; #endif #if TCG_TARGET_HAS_ext32s_i64 case INDEX_op_ext32s_i64: t0 = *tb_ptr++; t1 = tci_read_r32s(&tb_ptr); tci_write_reg64(t0, t1); break; #endif #if TCG_TARGET_HAS_ext32u_i64 case INDEX_op_ext32u_i64: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); tci_write_reg64(t0, t1); break; #endif #if TCG_TARGET_HAS_bswap16_i64 case INDEX_op_bswap16_i64: TODO(); t0 = *tb_ptr++; t1 = tci_read_r16(&tb_ptr); tci_write_reg64(t0, bswap16(t1)); break; #endif #if TCG_TARGET_HAS_bswap32_i64 case INDEX_op_bswap32_i64: t0 = *tb_ptr++; t1 = tci_read_r32(&tb_ptr); tci_write_reg64(t0, bswap32(t1)); break; #endif #if TCG_TARGET_HAS_bswap64_i64 case INDEX_op_bswap64_i64: t0 = *tb_ptr++; t1 = tci_read_r64(&tb_ptr); tci_write_reg64(t0, bswap64(t1)); break; #endif #if TCG_TARGET_HAS_not_i64 case INDEX_op_not_i64: t0 = *tb_ptr++; t1 = tci_read_r64(&tb_ptr); tci_write_reg64(t0, ~t1); break; #endif #if TCG_TARGET_HAS_neg_i64 case INDEX_op_neg_i64: t0 = *tb_ptr++; t1 = tci_read_r64(&tb_ptr); tci_write_reg64(t0, -t1); break; #endif #endif #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS case INDEX_op_debug_insn_start: TODO(); break; #else case INDEX_op_debug_insn_start: TODO(); break; #endif case INDEX_op_exit_tb: next_tb = *(uint64_t *)tb_ptr; goto exit; break; case INDEX_op_goto_tb: t0 = tci_read_i32(&tb_ptr); assert(tb_ptr == old_code_ptr + op_size); tb_ptr += (int32_t)t0; continue; case INDEX_op_qemu_ld8u: t0 = *tb_ptr++; taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp8 = helper_ldb_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp8 = *(uint8_t *)(host_addr + GUEST_BASE); #endif tci_write_reg8(t0, tmp8); break; case INDEX_op_qemu_ld8s: t0 = *tb_ptr++; taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp8 = helper_ldb_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp8 = *(uint8_t *)(host_addr + GUEST_BASE); #endif tci_write_reg8s(t0, tmp8); break; case INDEX_op_qemu_ld16u: t0 = *tb_ptr++; taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp16 = helper_ldw_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp16 = tswap16(*(uint16_t *)(host_addr + GUEST_BASE)); #endif tci_write_reg16(t0, tmp16); break; case INDEX_op_qemu_ld16s: t0 = *tb_ptr++; taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp16 = helper_ldw_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp16 = tswap16(*(uint16_t *)(host_addr + GUEST_BASE)); #endif tci_write_reg16s(t0, tmp16); break; #if TCG_TARGET_REG_BITS == 64 case INDEX_op_qemu_ld32u: t0 = *tb_ptr++; taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp32 = helper_ldl_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp32 = tswap32(*(uint32_t *)(host_addr + GUEST_BASE)); #endif tci_write_reg32(t0, tmp32); break; case INDEX_op_qemu_ld32s: t0 = *tb_ptr++; taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp32 = helper_ldl_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp32 = tswap32(*(uint32_t *)(host_addr + GUEST_BASE)); #endif tci_write_reg32s(t0, tmp32); break; #endif case INDEX_op_qemu_ld32: t0 = *tb_ptr++; taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp32 = helper_ldl_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp32 = tswap32(*(uint32_t *)(host_addr + GUEST_BASE)); #endif tci_write_reg32(t0, tmp32); break; case INDEX_op_qemu_ld64: t0 = *tb_ptr++; #if TCG_TARGET_REG_BITS == 32 t1 = *tb_ptr++; #endif taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU tmp64 = helper_ldq_mmu(env, taddr, tci_read_i(&tb_ptr)); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); tmp64 = tswap64(*(uint64_t *)(host_addr + GUEST_BASE)); #endif tci_write_reg(t0, tmp64); #if TCG_TARGET_REG_BITS == 32 tci_write_reg(t1, tmp64 >> 32); #endif break; case INDEX_op_qemu_st8: t0 = tci_read_r8(&tb_ptr); taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU t2 = tci_read_i(&tb_ptr); helper_stb_mmu(env, taddr, t0, t2); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); *(uint8_t *)(host_addr + GUEST_BASE) = t0; #endif break; case INDEX_op_qemu_st16: t0 = tci_read_r16(&tb_ptr); taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU t2 = tci_read_i(&tb_ptr); helper_stw_mmu(env, taddr, t0, t2); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); *(uint16_t *)(host_addr + GUEST_BASE) = tswap16(t0); #endif break; case INDEX_op_qemu_st32: t0 = tci_read_r32(&tb_ptr); taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU t2 = tci_read_i(&tb_ptr); helper_stl_mmu(env, taddr, t0, t2); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); *(uint32_t *)(host_addr + GUEST_BASE) = tswap32(t0); #endif break; case INDEX_op_qemu_st64: tmp64 = tci_read_r64(&tb_ptr); taddr = tci_read_ulong(&tb_ptr); #ifdef CONFIG_SOFTMMU t2 = tci_read_i(&tb_ptr); helper_stq_mmu(env, taddr, tmp64, t2); #else host_addr = (tcg_target_ulong)taddr; assert(taddr == host_addr); *(uint64_t *)(host_addr + GUEST_BASE) = tswap64(tmp64); #endif break; default: TODO(); break; } assert(tb_ptr == old_code_ptr + op_size); } exit: return next_tb; }
1threat
Why you would choose ASP.NET MVC over SPA + ASP.NET WebAPI? : <p>I'm asking this just to see experiences from others. For most of the cases having ASP MVC web site is an overhead. At least for me it's much cleaner and easier to have WebAPI which responds with JSON and then you can attach either SPA application or Mobile app or whatever.</p> <p>I have a feeling that if you are using ASP MVC controllers will not be controllers, but controllers full of the if conditions and some session bags which are hanging around. Views are combination of HTML and Razor which in most cases looks really ugly and full of "TODOs" ;) </p> <p>I can understand if it's used in older projects and now we just need to maintain them. But when you are starting a new one, why you would choose ASP.NET MVC or any other similar framework?</p>
0debug
How to encrypt and decrypt the password in android : <p>I have explored a lot to search encryption and decryption of passwords in android, I have found many algorithms but not able to find the one which is most secure. I want to first encrypt the password using some key and that should be decrypted using the same key. Which algorithm should I use for this ? Can someone please give an example for this.</p> <p>Thanks a lot for all your help.</p>
0debug
static int pci_vmsvga_initfn(PCIDevice *dev) { struct pci_vmsvga_state_s *s = DO_UPCAST(struct pci_vmsvga_state_s, card, dev); pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE); pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID); pci_config_set_class(s->card.config, PCI_CLASS_DISPLAY_VGA); s->card.config[PCI_CACHE_LINE_SIZE] = 0x08; s->card.config[PCI_LATENCY_TIMER] = 0x40; s->card.config[PCI_SUBSYSTEM_VENDOR_ID] = PCI_VENDOR_ID_VMWARE & 0xff; s->card.config[PCI_SUBSYSTEM_VENDOR_ID + 1] = PCI_VENDOR_ID_VMWARE >> 8; s->card.config[PCI_SUBSYSTEM_ID] = SVGA_PCI_DEVICE_ID & 0xff; s->card.config[PCI_SUBSYSTEM_ID + 1] = SVGA_PCI_DEVICE_ID >> 8; s->card.config[PCI_INTERRUPT_LINE] = 0xff; pci_register_bar(&s->card, 0, 0x10, PCI_BASE_ADDRESS_SPACE_IO, pci_vmsvga_map_ioport); pci_register_bar(&s->card, 1, VGA_RAM_SIZE, PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_mem); pci_register_bar(&s->card, 2, SVGA_FIFO_SIZE, PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_fifo); vmsvga_init(&s->chip, VGA_RAM_SIZE); if (!dev->rom_bar) { vga_init_vbe(&s->chip.vga); } return 0; }
1threat
how to prioritize a variable (Python) : Okay so I have been having a problem making a variable prioritized without anything to do with length. I want D to be prioritized because it his the highest variable then after I want it to prioritize C so on and so on, until it reaches 80 I've only seen example so far about using max() which is not what I need a = 60 b = 30 c = 50 d = 20 so i want it to select the 20 D then the 50 C then 10 B
0debug
print a particular string based on the count of paranthesis occurs : my_stng = " Einstein found out (apple) (fruit) which is (red)(green) in colour" REQUIREMENT: ------------- in the above string, count the number of times the paranthesis occurs and print the whole string that many times. if the count of paranthesis is 3, i need to print the above string 3 times. CAN ANY ONE HELP ME OUT IN THIS....?
0debug
static int vp8_packet(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + idx; uint8_t *p = os->buf + os->pstart; if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) { int seg; int duration; uint8_t *last_pkt = p; uint8_t *next_pkt; seg = os->segp; duration = (last_pkt[0] >> 4) & 1; next_pkt = last_pkt += os->psize; for (; seg < os->nsegs; seg++) { if (os->segments[seg] < 255) { duration += (last_pkt[0] >> 4) & 1; last_pkt = next_pkt + os->segments[seg]; } next_pkt += os->segments[seg]; } os->lastpts = os->lastdts = vp8_gptopts(s, idx, os->granule, NULL) - duration; if(s->streams[idx]->start_time == AV_NOPTS_VALUE) { s->streams[idx]->start_time = os->lastpts; if (s->streams[idx]->duration) s->streams[idx]->duration -= s->streams[idx]->start_time; } } if (os->psize > 0) os->pduration = (p[0] >> 4) & 1; return 0; }
1threat
static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs) { int i; NetClientState *nc; n->mergeable_rx_bufs = mergeable_rx_bufs; n->guest_hdr_len = n->mergeable_rx_bufs ? sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr); for (i = 0; i < n->max_queues; i++) { nc = qemu_get_subqueue(n->nic, i); if (peer_has_vnet_hdr(n) && tap_has_vnet_hdr_len(nc->peer, n->guest_hdr_len)) { tap_set_vnet_hdr_len(nc->peer, n->guest_hdr_len); n->host_hdr_len = n->guest_hdr_len; } } }
1threat
Good way to chain filter functions in javascript : <p>I've got large json array of objects that I need to filter down based on multiple user select inputs. Currently I'm chaining filter functions together but I've got a feeling this is most likely not the most performant way to do this.</p> <p>Currently I'm doing this:</p> <pre><code>var filtered = data.filter(function(data) { return Conditional1 }) .filter(function(data) { return Conditional2 }) .filter(function(data) { return Conditional3 }) etc...; </code></pre> <p>Although (I think) with each iteration 'data' could be less, I'm wondering if a better practice would be to do something like this:</p> <pre><code>var condition1 = Conditional1 var condition2 = Conditional2 var condition3 = Conditional3 etc... var filtered = data.filter(function(data) { return condition1 &amp;&amp; condition2 &amp;&amp; condition3 &amp;&amp; etc... }); </code></pre> <p>I've looked into multiple chains of higher order functions, specifically the filter function - but I haven't seen anything on best practice (or bad practice, nor have I timed and compared the two I've suggested).</p> <p>In a use case with a large data set and many conditionals which would be preferred (I reckon they are both fairly easily readable)?</p> <p>Or maybe there is a more performant way that I'm missing (but still using higher-order functions).</p>
0debug
C# regex to remove non - printable characters, and control characters, in a text that has a mix of many different languages, unicode letters : <p>i would appreciate your help on this, since i do not know which range of characters to use, or if there is a character class like [[:cntrl:]] that i have found in ruby?</p> <p>by means of non printable, i mean delete all characters that are not shown in ie output, when one prints the input string. Please note, i look for a c# regex, i do not have a problem with my code</p>
0debug
How to unset "ENV" in dockerfile? : <p>For some certain reasons, I have to set "http_proxy" and "https_proxy" <code>ENV</code> in my dockerfile. I would like to now unset them because there are also some building process can't be done through the proxy.</p> <pre><code># dockerfile # ... some process ENV http_proxy=http://... ENV https_proxy=http://... # ... some process that needs the proxy to finish UNSET ENV http_proxy # how to I unset the proxy ENV here? UNSET ENV https_proxy # ... some process that can't use the proxy </code></pre>
0debug
static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, int q_dc, int q_ac1, int q_ac2) { int coeffs[4]; coeffs[0] = modulo_three_table[code][0]; coeffs[1] = modulo_three_table[code][1]; coeffs[2] = modulo_three_table[code][2]; coeffs[3] = modulo_three_table[code][3]; decode_coeff(dst , coeffs[0], 3, gb, vlc, q_dc); if(is_block2){ decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q_ac1); decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q_ac1); }else{ decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q_ac1); decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q_ac1); } decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q_ac2); }
1threat
How to gracefully handle exceptions in Spring Security not handled by ControllerAdvice? : <p>I have recently implemented Spring Security in my Spring 4 / Hibernate Web application to handle logging in/out and different user roles. </p> <p>After a lot of reading it appears to work pretty fine now, but I noticed that exceptions thrown due to a wrong Spring Security configuration were not handled gracefully using my custom handler but shown as an ugly Tomcat error page (showing HTTP Status 500 - UserDetailsService is required followed by a stacktrace). </p> <p>Solving the particular error was not difficult (adding userDetailsService(userDetailsService) in the RememberMe configuration) but the fact remains that some exceptions thrown are not handled by the ControllerAdvice shown below handling MaxUploadSizeExceededException and all other runtime exceptions:</p> <pre><code>@ControllerAdvice public class ExceptionHandlingControllerAdvice { public static final String DEFAULT_ERROR_VIEW = "genericerror"; @ExceptionHandler(value = MaxUploadSizeExceededException.class) public View maxUploadSizeExceededExceptionHandler( HttpServletRequest req) throws IOException { String redirectUrl = req.getRequestURL().toString(); RedirectView rv = new RedirectView(redirectUrl); FlashMap outputFlashMap = RequestContextUtils.getOutputFlashMap(req); if (outputFlashMap != null) { outputFlashMap.put(KeyConstants.FLASH_ERROR_KEY, "Bestand is te groot"); } return rv; } @ExceptionHandler(value = RuntimeException.class) public View defaultErrorHandler(HttpServletRequest req, Exception e) { RedirectView rv = new RedirectView("/error", true); //context relative StackTraceElement[] steArray = e.getStackTrace(); StringBuilder stackTrace = new StringBuilder(); for (StackTraceElement element: steArray) { stackTrace.append(element.toString() + "\n"); } FlashMap outputFlashMap = RequestContextUtils.getOutputFlashMap(req); if (outputFlashMap != null) { outputFlashMap.put("url", req.getRequestURL()); outputFlashMap.put("excClassName", e.getClass().getName()); outputFlashMap.put("excMessage", e.getMessage()); outputFlashMap.put("excStacktrace", stackTrace.toString()); } e.printStackTrace(); return rv; } } </code></pre> <p>But the exception thrown by the incomplete configured Security is probably not caught by this mechanism because the login POST request is intercepted by Spring Security before any controller method is called. I would like to show ALL exceptions in graceful way on a custom error page, also the ones thrown before a Controller comes into place.</p> <p>I cannot find much information about that, all error handling techniques described in the Spring manual (<a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-exceptionhandlers" rel="noreferrer">http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-exceptionhandlers</a>) seems to use a Controller advice. </p> <p>Is there a convenient way to handle ALL exceptions in a generic way? And makes that my Controller advice class to handle exceptions superfluous?</p>
0debug
Difference between new Observable(...) and Rx.Observable.create(...)? : <p>I'm updating our software substituting all promises (and other hairy junk) for observables. To make sure that I'm following best practices, I made a quick googlearch and noticed that in <a href="https://angular-2-training-book.rangle.io/handout/observables/error_handling.html" rel="noreferrer">some cases</a>, the suggested syntax is by instance whereas in <a href="https://xgrommx.github.io/rx-book/content/getting_started_with_rxjs/creating_and_querying_observable_sequences/creating_and_subscribing_to_simple_observable_sequences.html" rel="noreferrer">other cases</a>, the examples perform a call by factory. </p> <pre><code>const byInstance = new Observable(_ =&gt; { ... }); const byFactory = Rx.Observable.create(_ =&gt; { ... }); </code></pre> <p>I'm curious what's the actual difference. Are they precisely interchangeable? Is it an older/newer syntax/approach? Is it framework related? And, of course, which is to be preferred (<strong>under the condition that</strong> it's not opinionated, disputed etc.).</p>
0debug
String check with list of strings : <p>What would be the quickest way to make sure the following is trusted:</p> <pre><code>email = "foobar@gmail.com" trusted = [".co.uk", ".com", ".net", ".edu", ".ac.uk"] </code></pre>
0debug
void acpi_build(AcpiBuildTables *tables, MachineState *machine) { PCMachineState *pcms = PC_MACHINE(machine); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; AcpiPmInfo pm; AcpiMiscInfo misc; AcpiMcfgInfo mcfg; Range pci_hole, pci_hole64; uint8_t *u; size_t aml_len = 0; GArray *tables_blob = tables->table_data; AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL }; Object *vmgenid_dev; acpi_get_pm_info(&pm); acpi_get_misc_info(&misc); acpi_get_pci_holes(&pci_hole, &pci_hole64); acpi_get_slic_oem(&slic_oem); table_offsets = g_array_new(false, true , sizeof(uint32_t)); ACPI_BUILD_DPRINTF("init ACPI tables\n"); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, tables_blob, 64 , false ); facs = tables_blob->len; build_facs(tables_blob, tables->linker); dsdt = tables_blob->len; build_dsdt(tables_blob, tables->linker, &pm, &misc, &pci_hole, &pci_hole64, machine); aml_len += tables_blob->len - dsdt; fadt = tables_blob->len; acpi_add_table(table_offsets, tables_blob); build_fadt(tables_blob, tables->linker, &pm, facs, dsdt, slic_oem.id, slic_oem.table_id); aml_len += tables_blob->len - fadt; acpi_add_table(table_offsets, tables_blob); build_madt(tables_blob, tables->linker, pcms); vmgenid_dev = find_vmgenid_dev(); if (vmgenid_dev) { acpi_add_table(table_offsets, tables_blob); vmgenid_build_acpi(VMGENID(vmgenid_dev), tables_blob, tables->vmgenid, tables->linker); } if (misc.has_hpet) { acpi_add_table(table_offsets, tables_blob); build_hpet(tables_blob, tables->linker); } if (misc.tpm_version != TPM_VERSION_UNSPEC) { acpi_add_table(table_offsets, tables_blob); build_tpm_tcpa(tables_blob, tables->linker, tables->tcpalog); if (misc.tpm_version == TPM_VERSION_2_0) { acpi_add_table(table_offsets, tables_blob); build_tpm2(tables_blob, tables->linker); } } if (pcms->numa_nodes) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, machine); if (have_numa_distance) { acpi_add_table(table_offsets, tables_blob); build_slit(tables_blob, tables->linker); } } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); build_mcfg_q35(tables_blob, tables->linker, &mcfg); } if (x86_iommu_get_default()) { IommuType IOMMUType = x86_iommu_get_type(); if (IOMMUType == TYPE_AMD) { acpi_add_table(table_offsets, tables_blob); build_amd_iommu(tables_blob, tables->linker); } else if (IOMMUType == TYPE_INTEL) { acpi_add_table(table_offsets, tables_blob); build_dmar_q35(tables_blob, tables->linker); } } if (pcms->acpi_nvdimm_state.is_enabled) { nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, &pcms->acpi_nvdimm_state, machine->ram_slots); } for (u = acpi_table_first(); u; u = acpi_table_next(u)) { unsigned len = acpi_table_len(u); acpi_add_table(table_offsets, tables_blob); g_array_append_vals(tables_blob, u, len); } rsdt = tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets, slic_oem.id, slic_oem.table_id); build_rsdp(tables->rsdp, tables->linker, rsdt); if (pcmc->legacy_acpi_table_size) { int legacy_aml_len = pcmc->legacy_acpi_table_size + ACPI_BUILD_LEGACY_CPU_AML_SIZE * pcms->apic_id_limit; int legacy_table_size = ROUND_UP(tables_blob->len - aml_len + legacy_aml_len, ACPI_BUILD_ALIGN_SIZE); if (tables_blob->len > legacy_table_size) { error_report("Warning: migration may not work."); } g_array_set_size(tables_blob, legacy_table_size); } else { if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) { error_report("Warning: ACPI tables are larger than 64k."); error_report("Warning: migration may not work."); error_report("Warning: please remove CPUs, NUMA nodes, " "memory slots or PCI bridges."); } acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE); } acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE); g_array_free(table_offsets, true); }
1threat
$_SESSION['foo'] not defined allthough it should be : <p>This is really annoying, i dont get it... Icheck the Isset and if not then i assign the veraialbe.. But i get to the next check and allthough the veriable should be set its then not... And why does the if(!isset($_SESSION['foo'] through a hissy fit if theres no veriable/index, i dont get it, thats the whole point of (!isset aint it.. anyway, look at my code. can anybody see a reason why this would not be set.. Thanks..</p> <p>SESSION['loggedin'] problem.</p> <pre><code> if ($_SESSION['homepage']='001') {$_SESSION['message']==$_SESSION['message']; unset($_SESSION['homepage']);} // if message comes from anything other than the login post (!isset($_SESSION['homepage'])) { $_SESSION['message']==$_SESSION['message']}; // if message comes from anything other than the login post if (isset($_SESSION['loggedin'])) {$_SESSION['loggedin']=$_SESSION['loggedin'];} else {$_SESSION['loggedin=']='000';} </code></pre> <p>if (!isset($_SESSION['loggedin'])) {$_SESSION['loggedin']='000';} </p> <pre><code> if (!isset($_SESSION['message'])) { $_SESSION['message']='Please Log into an Account';} if (isset($_POST['email'])) { unset($_POST['email']); unset($_POST['confirmemail']); unset($_POST['password']); unset($_POST['confirmpassword']); } else if (isset($_POST['email'])) { unset($_POST['email']); unset($_POST['confirmemail']); unset($_POST['password']); unset($_POST['confirmpassword']); } else if (isset($_POST['confirmemail'])) { unset($_POST['email']); unset($_POST['confirmemail']); unset($_POST['password']); unset($_POST['confirmpassword']); } else if (isset($_POST['confirmpassword'])) { unset($_POST['email']); unset($_POST['confirmemail']); unset($_POST['password']); unset($_POST['confirmpassword']); }; ........THROWS index not defined here...... if (!isset($_SESSION['loggedin'])) {$_SESSION['loggedin']=='000'; $_SESSION['message'] = 'You are NOT Logged into your account &lt;br&gt; Please Log in';} </code></pre>
0debug
static target_ulong h_register_process_table(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { qemu_log_mask(LOG_UNIMP, "Unimplemented SPAPR hcall 0x"TARGET_FMT_lx"%s\n", opcode, " (H_REGISTER_PROC_TBL)"); return H_FUNCTION; }
1threat
static struct omap_rtc_s *omap_rtc_init(MemoryRegion *system_memory, target_phys_addr_t base, qemu_irq *irq, omap_clk clk) { struct omap_rtc_s *s = (struct omap_rtc_s *) g_malloc0(sizeof(struct omap_rtc_s)); s->irq = irq[0]; s->alarm = irq[1]; s->clk = qemu_new_timer_ms(rt_clock, omap_rtc_tick, s); omap_rtc_reset(s); memory_region_init_io(&s->iomem, &omap_rtc_ops, s, "omap-rtc", 0x800); memory_region_add_subregion(system_memory, base, &s->iomem); return s; }
1threat
How to map two-letter country codes to Emoji in Golang? : Anyone fiddled with https://en.wikipedia.org/wiki/Regional_Indicator_Symbol? I am wondering how to get US printed as a flag 🇺🇸 https://play.golang.org/p/UErXxL645rV IIUC I need to add 0x1F1A5 to capital latin letters, but I don't how to do this in Golang. Update: Eric Hill suggested: https://play.golang.org/p/hEsScaZSh1I .. can anyone come up with improvements?
0debug
How should I interpret "size" parameter in Doc2Vec function of gensim? : <p>I am using <code>Doc2Vec</code> function of <a href="https://radimrehurek.com/gensim/models/doc2vec.html" rel="noreferrer">gensim</a> in Python to convert a document to a vector.</p> <p>An example of usage</p> <p><code>model = Doc2Vec(documents, size=100, window=8, min_count=5, workers=4)</code></p> <p>How should I interpret the <code>size</code> parameter. I know that if I set <code>size = 100</code>, the length of output vector will be 100, but what does it mean? For instance, if I increase <code>size</code> to 200, what is the difference?</p>
0debug
CASE IN WHERE CONDITION : CASE IN WHERE CONDITION DECLARE @id INT= 1; SELECT * FROM TABLE1 WHERE ETID = CASE WHEN ID = @id THEN 1 ELSE @id=0 END
0debug
NumberFormatException error confusion on online editor (Java) : <p>Zybooks keeps throwing this error: </p> <p>Exception in thread "main" java.lang.NumberFormatException: For input string: "JaneAusten" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615)</p> <p>I have posted a picture of my code, thanks.</p> <p><a href="https://i.stack.imgur.com/GzeGU.jpg" rel="nofollow noreferrer">image 1</a></p> <p><a href="https://i.stack.imgur.com/Aeh3B.jpg" rel="nofollow noreferrer">image 2</a></p> <p><a href="https://i.stack.imgur.com/aqg4q.jpg" rel="nofollow noreferrer">image 3</a></p>
0debug
static void svq1_parse_string(GetBitContext *bitbuf, uint8_t *out) { uint8_t seed; int i; out[0] = get_bits(bitbuf, 8); seed = string_table[out[0]]; for (i = 1; i <= out[0]; i++) { out[i] = get_bits(bitbuf, 8) ^ seed; seed = string_table[out[i] ^ seed]; } }
1threat