problem
stringlengths
26
131k
labels
class label
2 classes
Flutter app slow : <p>I'm trying out Flutter and my app is responding very very slow on both the emulator and real device. I get warnings like this </p> <blockquote> <p>Skipped 51 frames! The application may be doing too much work on its main thread.</p> </blockquote> <p>I'm aware Dart is a single-threaded programming language and in Android I used to solve this with the good old <code>new Thread();</code> block for async. I am trying to apply the same in Flutter and I reading through <code>Future</code> <code>await</code> <code>async</code> and the sorts but the examples seem to be addressing when you reading data from the internet. My app doesn't read anything online at this stage, I'm getting Skipped x frames when my screen has progress dialog, when I am opening a new screen/page, and with every animation on the app. Here is an example of the class where I am getting the issue:</p> <pre><code>_buildContent(){ return new Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: &lt;Widget&gt;[ new InkWell( onTap: (){ Navigator.push(context, new MaterialPageRoute(builder: (context) =&gt; new LoginScreen())); }, child: new Container( height: 150.0, width: 150.0, child: new Image.asset("images/logo.png", fit: BoxFit.cover,), ), ), new Container( margin: const EdgeInsets.all(16.0), child: new CircularProgressIndicator( value: null, strokeWidth: 1.0, valueColor: new AlwaysStoppedAnimation&lt;Color&gt;( Colors.white ) ), ) ], ); } </code></pre> <p>I'm assuming the skipped x frames warning is caused by the progress dialog? I have another screen (Login Screen) which animates widgets into place when opened, the animations move so slow, I can literally see each frame being rendered. Is there a tutorial online that can assist with addressing this or just understanding Dart's Asynchronous Programming? </p>
0debug
static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset, int check_copied) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, l2_entry; int i, l2_size, nb_csectors, refcount; l2_size = s->l2_size * sizeof(uint64_t); l2_table = g_malloc(l2_size); if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size) goto fail; for(i = 0; i < s->l2_size; i++) { l2_entry = be64_to_cpu(l2_table[i]); switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: if (l2_entry & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", l2_entry >> s->cluster_bits); l2_entry &= ~QCOW_OFLAG_COPIED; res->corruptions++; } nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1; l2_entry &= s->cluster_offset_mask; inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_entry & ~511, nb_csectors * 512); break; case QCOW2_CLUSTER_ZERO: if ((l2_entry & L2E_OFFSET_MASK) == 0) { break; } case QCOW2_CLUSTER_NORMAL: { uint64_t offset = l2_entry & L2E_OFFSET_MASK; if (check_copied) { refcount = get_refcount(bs, offset >> s->cluster_bits); if (refcount < 0) { fprintf(stderr, "Can't get refcount for offset %" PRIx64 ": %s\n", l2_entry, strerror(-refcount)); goto fail; } if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED: offset=%" PRIx64 " refcount=%d\n", l2_entry, refcount); res->corruptions++; } } inc_refcounts(bs, res, refcount_table,refcount_table_size, offset, s->cluster_size); if (offset & (s->cluster_size - 1)) { fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " "properly aligned; L2 entry corrupted.\n", offset); res->corruptions++; } break; } case QCOW2_CLUSTER_UNALLOCATED: break; default: abort(); } } g_free(l2_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); g_free(l2_table); return -EIO; }
1threat
New to C#, can anyone explain to me how enums and setting variables for enums works? : <p>I'm sure this is a very simple question, but I'm learning how to program in C# and the "flow" of this text adventure program makes perfect sense to me, but I'm confused how the third line "private States myState;" works. </p> <p>As you can see, the program starts by setting the variable myState to States.cell, which calls a void method (not shown below) that waits for a key that changes the variable "myState" thus updating the update function.</p> <p>My question is, how does the "enum" class work? It seems as though it's possible to make a variable from the "enum States" line, but I don't understand why that is. Sorry if this is a really stupid question.</p> <p>Here's the code:</p> <pre><code> public Text text; private enum States {cell, sheets_0, mirror, lock_0, sheets_1, cell_mirror, lock_1, freedom}; private States myState; // Use this for initialization void Start () { myState = States.cell; } // Update is called once per frame void Update () { print (myState); if (myState == States.cell){ state_cell();} else if (myState == States.sheets_0){ state_sheets_0();} else if (myState == States.mirror){ state_mirror();} else if (myState == States.lock_0){ state_lock_0();} else if (myState == States.sheets_1){ state_sheets_1();} else if (myState == States.cell_mirror){ state_cell_mirror();} else if (myState == States.lock_1){ state_lock_1();} else if (myState == States.freedom){ state_freedom();} } </code></pre>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
void qemu_chr_be_generic_open(CharDriverState *s) { if (s->idle_tag == 0) { s->idle_tag = g_idle_add(qemu_chr_be_generic_open_bh, s); } }
1threat
How do get a timestamp on an ASP.NET MVC App : <p>On web apps, you commonly see something like "Last Logged In: 3 hours 42 minutes ago". What is the best way to go about doing this.? Use strings or Dates? Also, i'm bringing that timestamp back into a Kendo MVC Grid. The column looks as such.</p> <pre><code>columns.Bound(c =&gt; c.LastStatusDateDiff).Title("Updated"); </code></pre> <p>My Linq code looks as such</p> <pre><code>select new ATSReDto { CreatedDate = atsr.CreatedDt, Desciption = atsr.Description, LastStatusDateDiff = laststatus.CreatedDt - DateTime.Now // get date difference between now "DateTime.Now" and // date/time pulled from SQL Server to display in Grid }; </code></pre> <p>Any suggestions greatly appreciated</p>
0debug
static void bswap_note(struct elf_note *en) { bswap32s(&en->n_namesz); bswap32s(&en->n_descsz); bswap32s(&en->n_type); }
1threat
JpaSpecificationExecutor JOIN + ORDER BY in Specification : <p>I have a query using a JOIN and ORDER BY and want to use it within my repository using the Criteria Api.</p> <p>Here I found, how to wrap such a query into a CriteriaQuery (<a href="http://docs.oracle.com/javaee/6/tutorial/doc/gjivm.html" rel="noreferrer">Link</a>).</p> <pre><code>CriteriaQuery&lt;Pet&gt; cq = cb.createQuery(Pet.class); Root&lt;Pet&gt; pet = cq.from(Pet.class); Join&lt;Pet, Owner&gt; owner = cq.join(Pet_.owners); cq.select(pet); cq.orderBy(cb.asc(owner.get(Owner_.lastName),owner.get(Owner_.firstName))); </code></pre> <p>On the other side, I found some examples to use the Criteria Api in Combination with a JpaRepository (<a href="http://www.cubrid.org/wiki_ngrinder/entry/how-to-create-dynamic-queries-in-springdata" rel="noreferrer">example</a>).</p> <p>The Problem is that all methods in the repository expect a Specification:</p> <pre><code>T findOne(Specification&lt;T&gt; spec); </code></pre> <p>which is always build like this:</p> <pre><code>public static Specification&lt;PerfTest&gt; statusSetEqual(final Status... statuses) { return new Specification&lt;PerfTest&gt;() { @Override public Predicate toPredicate(Root&lt;PerfTest&gt; root, CriteriaQuery&lt;?&gt; query, CriteriaBuilder cb) { return cb.not(root.get("status").in((Object[]) statuses)); } }; } </code></pre> <p>So at one side I know how to create a CriteriaQuery, and on the other side I need a Specification which is build from a Predicate, and I can not figure out how to parse the CriteriaQuery into a Specification/Predicate.</p>
0debug
JSON to PHP error - array : <p>I'm having problems getting data from JSON with PHP. </p> <p>json string</p> <pre><code>{"cpresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}} </code></pre> <p>Same json decoded</p> <pre><code> array ( 'cpresult' =&gt; array ( 'apiversion' =&gt; '2', 'error' =&gt; 'Access denied', 'data' =&gt; array ( 'reason' =&gt; 'Access denied', 'result' =&gt; '0', ), 'type' =&gt; 'text', ), ) </code></pre> <p>PHP code</p> <pre><code> $get_accounts = json_decode($get_accounts); echo $get_accounts['cpresult']['data'][0]['result']; </code></pre> <p>error: Fatal error: Cannot use object of type stdClass as array</p>
0debug
"Variable context not set" error with mutate_at, dplyr version >= 0.7 : <p>This code used to work, as of about May 1 2017 (<code>dplyr</code> version 0.5.0). With <code>dplyr</code> version 0.7 it fails with <code>Error: Variable context not set</code>. I couldn't find the solution googling around or looking in the <a href="https://github.com/tidyverse/dplyr/blob/master/NEWS.md" rel="noreferrer">dplyr NEWS file</a>.</p> <p>This part is fine (setting up the example - could probably be simplified ...)</p> <pre><code>xx &lt;- data.frame(stud_number=1:3,HW1=rep(0,3),HW2=c(NA,1,1),junk=rep(NA,3)) repl_1_NA &lt;- function(x) { return(replace(x,which(x==1),NA)) } hw1 &lt;- xx %&gt;% select(c(stud_number,starts_with("HW"))) </code></pre> <p>Now try to use <code>mutate_at()</code>: fails with <code>dplyr</code> version >= 0.7.0</p> <pre><code>hw1 %&gt;% mutate_at(starts_with("HW"),repl_1_NA) </code></pre>
0debug
How to stop Refersh/Reload of page in asp.net : I think page load is bigest issue of asp.net(webform) I reserach alot about but i not get any solution I use update panel but update panel not work So please expect update panel give any other solution e.g I have button i click onbutton after that full page goes refersh but i dnt want this Is this possible when i click on button just show some progress bar for refershing page Please give some suitable example Because Page load so irrating me Thanks :)
0debug
Incorrect syntax near the keyword 'PRIMARY' : <code> USE db_Airline; CREATE TABLE AIRPORT ( Airport_code NVARCHAR(10) PRIMARY KEY, Name NVARCHAR(25) NOT NULL, City NVARCHAR(25) NOT NULL, State NVARCHAR(25) NOT NULL ); CREATE TABLE FLIGHT ( Flight_number NVARCHAR(15) PRIMARY KEY, Airline NVARCHAR(25) NOT NULL, Weekdays INTEGER DEFAULT 0 ); CREATE TABLE FLIGHT_LEG ( Flight_number NVARCHAR(15) NOT NULL, Leg_number INTEGER NOT NULL, Departure_airport_code NVARCHAR(10) NOT NULL, Scheduled_departure_time TIME NOT NULL, Arrival_airport_code NVARCHAR(10) NOT NULL, Scheduled_arrival_time TIME NOT NULL, CONSTRAINT PRIMARY KEY Pk_Flight_Leg (Flight_number, Leg_number), CONSTRAINT FOREIGN KEY Fk_Flight_Leg_Flight (Flight_number) REFERENCES FLIGHT (Flight_number) ON UPDATE CASCADE ON DELETE CASCADE ); CREATE TABLE FARE ( Flight_number NVARCHAR(15) NOT NULL, Fare_code NVARCHAR(15) NOT NULL, Amount DECIMAL(10,2) NOT NULL, Restrictions NVARCHAR(50), CONSTRAINT PRIMARY KEY Pk_Fare (Flight_number, Fare_code), CONSTRAINT FOREIGN KEY Fk_Fare_Flight (Flight_number) REFERENCES FLIGHT (Flight_number) ON UPDATE CASCADE ON DELETE CASCADE ); CREATE TABLE AIRPLANE_TYPE ( Airplane_type_name NVARCHAR(25) PRIMARY KEY, Max_seats INTEGER NOT NULL, Company NVARCHAR(25) ); CREATE TABLE AIRPLANE ( Airplane_id NVARCHAR(25) PRIMARY KEY, Total_number_of_seats INTEGER NOT NULL, Airplane_type NVARCHAR(25) NOT NULL, CONSTRAINT FOREIGN KEY Fk_Airplane_Airplane_Type (Airplane_type) REFERENCES AIRPLANE_TYPE (Airplane_type_name) ON UPDATE CASCADE ON DELETE CASCADE ); CREATE TABLE LEG_INSTANCE ( Flight_number NVARCHAR(15) NOT NULL, Leg_number INTEGER NOT NULL, Leg_instance_date Date NOT NULL, Number_of_available_seats INTEGER, Airplane_id NVARCHAR(25) NOT NULL, Departure_airport_code NVARCHAR(10) NOT NULL, Departure_time TIME NOT NULL, Arrival_airport_code NVARCHAR(10) NOT NULL, Arrival_time TIME NOT NULL, CONSTRAINT PRIMARY KEY Pk_Leg_Instance (Flight_number, Leg_number, Leg_instance_date), CONSTRAINT FOREIGN KEY Fk_Leg_Instance_Flight_Leg (Flight_number, Leg_number) REFERENCES FLIGHT_LEG (Flight_number, Leg_number) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT FOREIGN KEY Fk_Leg_Instance_Airplane (Airplane_id) REFERENCES AIRPLANE (Airplane_id) ON UPDATE CASCADE ON DELETE CASCADE ); CREATE TABLE CAN_LAND ( Airplane_type_name NVARCHAR(25) NOT NULL, Airport_code NVARCHAR(10) NOT NULL, CONSTRAINT PRIMARY KEY Pk_Can_Land (Airplane_type_name, Airport_code), CONSTRAINT FOREIGN KEY Fk_Can_Land_Airplane_Type (Airplane_type_name) REFERENCES AIRPLANE_TYPE (Airplane_type_name) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT FOREIGN KEY Fk_Can_Land_Airport (Airport_code) REFERENCES AIRPORT (Airport_code) ON UPDATE CASCADE ON DELETE CASCADE ); CREATE TABLE SEAT_RESERVATION ( Flight_number NVARCHAR(15) NOT NULL, Leg_number INTEGER NOT NULL, Leg_instance_date Date NOT NULL, Seat_number INTEGER NOT NULL, Customer_name NVARCHAR(50) NOT NULL, Customer_phone NVARCHAR(20), CONSTRAINT PRIMARY KEY Pk_Seat_Reservation (Flight_number, Leg_number, Leg_instance_date, Seat_number), CONSTRAINT FOREIGN KEY Fk_Seat_Reservation_Leg_Instance (Flight_number, Leg_number, Leg_instance_date) REFERENCES LEG_INSTANCE (Flight_number, Leg_number, Leg_instance_date) ); </code> > Msg 156, Level 15, State 1, Line 23 Incorrect syntax near the keyword 'PRIMARY'. Msg 156, Level 15, State 1, Line 37 Incorrect syntax near the keyword 'PRIMARY'. Msg 156, Level 15, State 1, Line 56 Incorrect syntax near the keyword 'FOREIGN'. Msg 156, Level 15, State 1, Line 73 Incorrect syntax near the keyword 'PRIMARY'. Msg 156, Level 15, State 1, Line 90 Incorrect syntax near the keyword 'PRIMARY'. Msg 156, Level 15, State 1, Line 111 Incorrect syntax near the keyword 'PRIMARY'.
0debug
def sum_Square(n) : i = 1 while i*i <= n : j = 1 while (j*j <= n) : if (i*i+j*j == n) : return True j = j+1 i = i+1 return False
0debug
Detect if a command is piped or not : <p>Is there a way to detect if a command in go is piped or not?</p> <p>Example:</p> <pre><code>cat test.txt | mygocommand #Piped, this is how it should be used mygocommand # Not piped, this should be blocked </code></pre> <p>I'm reading from the Stdin <code>reader := bufio.NewReader(os.Stdin)</code>.</p>
0debug
How can I make a desktop app with node.js in the backend for APIs : <p>What would be the best set of technologies to use if I want to make a desktop application which would fetch data from server through JSON (node.js with MYSQL).</p> <p>Side note: Currently we are using angular.js for frontend but the client wants a desktop app and is adamant. Don't want to change anything server side.</p>
0debug
line chart with {x, y} point data displays only 2 values : <p><a href="https://codepen.io/shaz1234/pen/PEKjOV" rel="noreferrer">https://codepen.io/shaz1234/pen/PEKjOV</a></p> <p>The codepen has my code</p> <pre><code>new Chart(document.getElementById("chartjs-0"), { "type":"line", "data": { "datasets": [ { "label":"My First Dataset", "data": [ {x: 0, y: 65}, {x: 4, y: 59}, {x: 100, y: 80}, {x: 110, y: 81}, {x: 125, y: 56} ], "fill":false, "borderColor":"rgb(75, 192, 192)", "lineTension":0.1 } ] }, "options":{ } } ); </code></pre> <p>Very simple example but the chart displays only the first two points. I would have expected the chart to scale to the min and max provided <code>x</code> values. Do I misunderstand how point line charts are designed to work or do I have a bug? </p> <p>Thanks in advance for looking. </p>
0debug
static int txd_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_TXD; st->codec->time_base.den = 5; st->codec->time_base.num = 1; return 0; }
1threat
e1000_autoneg_timer(void *opaque) { E1000State *s = opaque; qemu_get_queue(s->nic)->link_down = false; e1000_link_up(s); s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE; DBGOUT(PHY, "Auto negotiation is completed\n"); }
1threat
static void tcg_out_brcond_i32(TCGContext *s, TCGCond cond, TCGReg arg1, int32_t arg2, int const_arg2, int label) { tcg_out_cmp(s, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_ICC | BPCC_PT, label); tcg_out_nop(s); }
1threat
static void tcg_target_qemu_prologue (TCGContext *s) { int i, frame_size; #ifndef __APPLE__ uint64_t addr; #endif frame_size = 0 + 8 + 8 + 8 + 8 + 8 + 8 + TCG_STATIC_CALL_ARGS_SIZE + ARRAY_SIZE (tcg_target_callee_save_regs) * 8 ; frame_size = (frame_size + 15) & ~15; #ifndef __APPLE__ addr = (uint64_t) s->code_ptr + 24; tcg_out32 (s, addr >> 32); tcg_out32 (s, addr); s->code_ptr += 16; #endif tcg_out32 (s, MFSPR | RT (0) | LR); tcg_out32 (s, STDU | RS (1) | RA (1) | (-frame_size & 0xffff)); for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) tcg_out32 (s, (STD | RS (tcg_target_callee_save_regs[i]) | RA (1) | (i * 8 + 48 + TCG_STATIC_CALL_ARGS_SIZE) ) ); tcg_out32 (s, STD | RS (0) | RA (1) | (frame_size + 16)); #ifdef CONFIG_USE_GUEST_BASE if (GUEST_BASE) { tcg_out_movi (s, TCG_TYPE_I64, TCG_GUEST_BASE_REG, GUEST_BASE); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif tcg_out32 (s, MTSPR | RS (3) | CTR); tcg_out32 (s, BCCTR | BO_ALWAYS); tb_ret_addr = s->code_ptr; for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) tcg_out32 (s, (LD | RT (tcg_target_callee_save_regs[i]) | RA (1) | (i * 8 + 48 + TCG_STATIC_CALL_ARGS_SIZE) ) ); tcg_out32 (s, LD | RT (0) | RA (1) | (frame_size + 16)); tcg_out32 (s, MTSPR | RS (0) | LR); tcg_out32 (s, ADDI | RT (1) | RA (1) | frame_size); tcg_out32 (s, BCLR | BO_ALWAYS); }
1threat
target_ulong helper_rdhwr_cc(CPUMIPSState *env) { if ((env->hflags & MIPS_HFLAG_CP0) || (env->CP0_HWREna & (1 << 2))) { #ifdef CONFIG_USER_ONLY return env->CP0_Count; #else return (int32_t)cpu_mips_get_count(env); #endif } else { do_raise_exception(env, EXCP_RI, GETPC()); } return 0; }
1threat
static void gen_imull(TCGv a, TCGv b) { TCGv tmp1 = tcg_temp_new(TCG_TYPE_I64); TCGv tmp2 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_ext_i32_i64(tmp1, a); tcg_gen_ext_i32_i64(tmp2, b); tcg_gen_mul_i64(tmp1, tmp1, tmp2); tcg_gen_trunc_i64_i32(a, tmp1); tcg_gen_shri_i64(tmp1, tmp1, 32); tcg_gen_trunc_i64_i32(b, tmp1); }
1threat
static void ide_dma_cb(void *opaque, int ret) { IDEState *s = opaque; int n; int64_t sector_num; bool stay_active = false; if (ret == -ECANCELED) { return; } if (ret < 0) { int op = IDE_RETRY_DMA; if (s->dma_cmd == IDE_DMA_READ) op |= IDE_RETRY_READ; else if (s->dma_cmd == IDE_DMA_TRIM) op |= IDE_RETRY_TRIM; if (ide_handle_rw_error(s, -ret, op)) { return; } } n = s->io_buffer_size >> 9; if (n > s->nsector) { n = s->nsector; stay_active = true; } sector_num = ide_get_sector(s); if (n > 0) { assert(s->io_buffer_size == s->sg.size); dma_buf_commit(s, s->io_buffer_size); sector_num += n; ide_set_sector(s, sector_num); s->nsector -= n; } if (s->nsector == 0) { s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); goto eot; } n = s->nsector; s->io_buffer_index = 0; s->io_buffer_size = n * 512; if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) < 512) { s->status = READY_STAT | SEEK_STAT; dma_buf_commit(s, 0); goto eot; } #ifdef DEBUG_AIO printf("ide_dma_cb: sector_num=%" PRId64 " n=%d, cmd_cmd=%d\n", sector_num, n, s->dma_cmd); #endif if ((s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) && !ide_sect_range_ok(s, sector_num, n)) { ide_dma_error(s); return; } switch (s->dma_cmd) { case IDE_DMA_READ: s->bus->dma->aiocb = dma_blk_read(s->blk, &s->sg, sector_num, ide_dma_cb, s); break; case IDE_DMA_WRITE: s->bus->dma->aiocb = dma_blk_write(s->blk, &s->sg, sector_num, ide_dma_cb, s); break; case IDE_DMA_TRIM: s->bus->dma->aiocb = dma_blk_io(s->blk, &s->sg, sector_num, ide_issue_trim, ide_dma_cb, s, DMA_DIRECTION_TO_DEVICE); break; } return; eot: if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) { block_acct_done(blk_get_stats(s->blk), &s->acct); } ide_set_inactive(s, stay_active); }
1threat
is there any fast way to query average without including itself in mysql : for below table name: team_score "Team" "score" "date" "A" "1" "2017-07-01" "B" "2" "2017-07-02" "A" "3" "2017-07-02" "B" "4" "2017-07-01" "C" "5" "2017-07-02" "C" "6" "2017-07-01" to get this table "team" "avg" "avg_excluding_itself" "A" "2.00000000" "4.25000000" "B" "3.00000000" "3.75000000" "C" "5.50000000" "2.50000000" what will be the most efficient way? below query will not work as it is too resource consuming. imaging the table is 100GB in size. select a.team, avg(a.score) as avg,avg(b.score) as avg_excluding_itself from team_score a join team_score b on a.team<>b.team group by a.team
0debug
Simple Example SwingUtilities : <p>I have a probably annoying request. Could someone demonstrate how to use one of these static Java swing utility methods? I am looking for a simple, extremely simple, example.</p> <pre><code>public static void paintComponent(java.awt.Graphics, java.awt.Component, java. awt.Container, int, int, int, int); public static void paintComponent(java.awt.Graphics, java.awt.Component, java. awt.Container, java.awt.Rectangle); </code></pre> <p>These static Java swing methods are found in the <code>javax.swing.SwingUtilities</code> package. </p> <p>Thank-you for reading this and any help given.</p>
0debug
How to persist data in Prometheus running in a Docker container? : <p>I'm developing something that needs Prometheus to persist its data between restarts. Having followed the instructions </p> <pre><code>$ docker volume create a-new-volume $ docker run \ --publish 9090:9090 \ --volume a-new-volume:/prometheus-data \ --volume "$(pwd)"/prometheus.yml:/etc/prometheus/prometheus.yml \ prom/prometheus </code></pre> <p>I have a valid <code>prometheus.yml</code> in the right directory on the host machine and it's being read by Prometheus from within the container. I'm just scraping a couple of HTTP endpoints for testing purposes at the moment.</p> <p>But when I restart the container it's empty, no data from the previous run. What am I missing from my <code>docker run ...</code> command to persist the data into the <code>a-new-volume</code> volume?</p>
0debug
How to allocate more memory to my Virtual Machine running on Fedora to avoid Heap out of Memory Error : <p>I'm running Jenkins on a Fedora Virtual Machine and have an app created by <a href="https://github.com/facebook/create-react-app" rel="noreferrer">create-react-app</a> . </p> <p>When I try to build for production on my local machine, after ~8 minutes, it does get compiled successfully (although with the message: 'the bundle size is significantly larger than recommended...' </p> <p>However, when I run the same script during my Jenkins build process, I get the following error: <code>FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory</code>.</p> <p>The build script is as follows: <code>npm run build-css &amp;&amp; node --max_old_space_size=8192 node_modules/.bin/react-scripts-ts build &amp;&amp; npm run copy-to-build</code>.</p> <p>My question is, how can I allocate more memory for my Virtual Machine running on Fedora so the script can run successfully before throwing the <code>FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory</code> .</p>
0debug
How would I setup a HTML page to have a new title each new day? : <p>So my ultimate goal here is to have the site have a new title each day (24 hours).</p> <p>I am not a very experienced program, but, I am aware something similar could be done with JS.</p> <p>I saw this idea:</p> <pre><code>setInterval(function() { //change title //document.title = "Some new title"; }, 3000); </code></pre> <p>I'm not sure how I can take this idea above, which I do not fully understand and make it use, for example, a large array or predefined titles and select one at random each day.</p> <p>Would it be possible to select the title out of another file or should I have them all in the JS file? On the question just asked, should I have the JS code in the HTML file itself or referenced as a file like a CSS file?</p> <p>I really appreciate any walkthrough/help I can get on this. I hope your days are well all.</p>
0debug
static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel) { const char *rn = "invalid"; if (sel != 0) check_insn(ctx, ISA_MIPS64); if (use_icount) gen_io_start(); switch (reg) { case 0: switch (sel) { case 0: gen_helper_mtc0_index(cpu_env, arg); rn = "Index"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_mvpcontrol(cpu_env, arg); rn = "MVPControl"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); rn = "MVPConf0"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); rn = "MVPConf1"; break; default: goto cp0_unimplemented; } break; case 1: switch (sel) { case 0: rn = "Random"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpecontrol(cpu_env, arg); rn = "VPEControl"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeconf0(cpu_env, arg); rn = "VPEConf0"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeconf1(cpu_env, arg); rn = "VPEConf1"; break; case 4: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_yqmask(cpu_env, arg); rn = "YQMask"; break; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPESchedule)); rn = "VPESchedule"; break; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPEScheFBack)); rn = "VPEScheFBack"; break; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeopt(cpu_env, arg); rn = "VPEOpt"; break; default: goto cp0_unimplemented; } break; case 2: switch (sel) { case 0: gen_helper_dmtc0_entrylo0(cpu_env, arg); rn = "EntryLo0"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcstatus(cpu_env, arg); rn = "TCStatus"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcbind(cpu_env, arg); rn = "TCBind"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcrestart(cpu_env, arg); rn = "TCRestart"; break; case 4: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tchalt(cpu_env, arg); rn = "TCHalt"; break; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tccontext(cpu_env, arg); rn = "TCContext"; break; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcschedule(cpu_env, arg); rn = "TCSchedule"; break; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcschefback(cpu_env, arg); rn = "TCScheFBack"; break; default: goto cp0_unimplemented; } break; case 3: switch (sel) { case 0: gen_helper_dmtc0_entrylo1(cpu_env, arg); rn = "EntryLo1"; break; default: goto cp0_unimplemented; } break; case 4: switch (sel) { case 0: gen_helper_mtc0_context(cpu_env, arg); rn = "Context"; break; case 1: rn = "ContextConfig"; goto cp0_unimplemented; case 2: CP0_CHECK(ctx->ulri); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, active_tc.CP0_UserLocal)); rn = "UserLocal"; break; default: goto cp0_unimplemented; } break; case 5: switch (sel) { case 0: gen_helper_mtc0_pagemask(cpu_env, arg); rn = "PageMask"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_pagegrain(cpu_env, arg); rn = "PageGrain"; break; default: goto cp0_unimplemented; } break; case 6: switch (sel) { case 0: gen_helper_mtc0_wired(cpu_env, arg); rn = "Wired"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf0(cpu_env, arg); rn = "SRSConf0"; break; case 2: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf1(cpu_env, arg); rn = "SRSConf1"; break; case 3: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf2(cpu_env, arg); rn = "SRSConf2"; break; case 4: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf3(cpu_env, arg); rn = "SRSConf3"; break; case 5: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf4(cpu_env, arg); rn = "SRSConf4"; break; default: goto cp0_unimplemented; } break; case 7: switch (sel) { case 0: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_hwrena(cpu_env, arg); ctx->bstate = BS_STOP; rn = "HWREna"; break; default: goto cp0_unimplemented; } break; case 8: switch (sel) { case 0: rn = "BadVAddr"; break; case 1: rn = "BadInstr"; break; case 2: rn = "BadInstrP"; break; default: goto cp0_unimplemented; } break; case 9: switch (sel) { case 0: gen_helper_mtc0_count(cpu_env, arg); rn = "Count"; break; default: goto cp0_unimplemented; } ctx->bstate = BS_STOP; break; case 10: switch (sel) { case 0: gen_helper_mtc0_entryhi(cpu_env, arg); rn = "EntryHi"; break; default: goto cp0_unimplemented; } break; case 11: switch (sel) { case 0: gen_helper_mtc0_compare(cpu_env, arg); rn = "Compare"; break; default: goto cp0_unimplemented; } ctx->bstate = BS_STOP; break; case 12: switch (sel) { case 0: save_cpu_state(ctx, 1); gen_helper_mtc0_status(cpu_env, arg); gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; rn = "Status"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_intctl(cpu_env, arg); ctx->bstate = BS_STOP; rn = "IntCtl"; break; case 2: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsctl(cpu_env, arg); ctx->bstate = BS_STOP; rn = "SRSCtl"; break; case 3: check_insn(ctx, ISA_MIPS32R2); gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_SRSMap)); ctx->bstate = BS_STOP; rn = "SRSMap"; break; default: goto cp0_unimplemented; } break; case 13: switch (sel) { case 0: save_cpu_state(ctx, 1); if (use_icount) { gen_io_start(); } gen_helper_mtc0_cause(cpu_env, arg); if (use_icount) { gen_io_end(); } ctx->bstate = BS_STOP; rn = "Cause"; break; default: goto cp0_unimplemented; } break; case 14: switch (sel) { case 0: tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EPC)); rn = "EPC"; break; default: goto cp0_unimplemented; } break; case 15: switch (sel) { case 0: rn = "PRid"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_ebase(cpu_env, arg); rn = "EBase"; break; default: goto cp0_unimplemented; } break; case 16: switch (sel) { case 0: gen_helper_mtc0_config0(cpu_env, arg); rn = "Config"; ctx->bstate = BS_STOP; break; case 1: rn = "Config1"; break; case 2: gen_helper_mtc0_config2(cpu_env, arg); rn = "Config2"; ctx->bstate = BS_STOP; break; case 3: rn = "Config3"; break; case 4: rn = "Config4"; break; case 5: gen_helper_mtc0_config5(cpu_env, arg); rn = "Config5"; ctx->bstate = BS_STOP; break; default: rn = "Invalid config selector"; goto cp0_unimplemented; } break; case 17: switch (sel) { case 0: gen_helper_mtc0_lladdr(cpu_env, arg); rn = "LLAddr"; break; default: goto cp0_unimplemented; } break; case 18: switch (sel) { case 0 ... 7: gen_helper_0e1i(mtc0_watchlo, arg, sel); rn = "WatchLo"; break; default: goto cp0_unimplemented; } break; case 19: switch (sel) { case 0 ... 7: gen_helper_0e1i(mtc0_watchhi, arg, sel); rn = "WatchHi"; break; default: goto cp0_unimplemented; } break; case 20: switch (sel) { case 0: check_insn(ctx, ISA_MIPS3); gen_helper_mtc0_xcontext(cpu_env, arg); rn = "XContext"; break; default: goto cp0_unimplemented; } break; case 21: CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6)); switch (sel) { case 0: gen_helper_mtc0_framemask(cpu_env, arg); rn = "Framemask"; break; default: goto cp0_unimplemented; } break; case 22: rn = "Diagnostic"; break; case 23: switch (sel) { case 0: gen_helper_mtc0_debug(cpu_env, arg); gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; rn = "Debug"; break; case 1: ctx->bstate = BS_STOP; rn = "TraceControl"; case 2: ctx->bstate = BS_STOP; rn = "TraceControl2"; case 3: ctx->bstate = BS_STOP; rn = "UserTraceData"; case 4: ctx->bstate = BS_STOP; rn = "TraceBPC"; default: goto cp0_unimplemented; } break; case 24: switch (sel) { case 0: tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_DEPC)); rn = "DEPC"; break; default: goto cp0_unimplemented; } break; case 25: switch (sel) { case 0: gen_helper_mtc0_performance0(cpu_env, arg); rn = "Performance0"; break; case 1: rn = "Performance1"; case 2: rn = "Performance2"; case 3: rn = "Performance3"; case 4: rn = "Performance4"; case 5: rn = "Performance5"; case 6: rn = "Performance6"; case 7: rn = "Performance7"; default: goto cp0_unimplemented; } break; case 26: rn = "ECC"; break; case 27: switch (sel) { case 0 ... 3: rn = "CacheErr"; break; default: goto cp0_unimplemented; } break; case 28: switch (sel) { case 0: case 2: case 4: case 6: gen_helper_mtc0_taglo(cpu_env, arg); rn = "TagLo"; break; case 1: case 3: case 5: case 7: gen_helper_mtc0_datalo(cpu_env, arg); rn = "DataLo"; break; default: goto cp0_unimplemented; } break; case 29: switch (sel) { case 0: case 2: case 4: case 6: gen_helper_mtc0_taghi(cpu_env, arg); rn = "TagHi"; break; case 1: case 3: case 5: case 7: gen_helper_mtc0_datahi(cpu_env, arg); rn = "DataHi"; break; default: rn = "invalid sel"; goto cp0_unimplemented; } break; case 30: switch (sel) { case 0: tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC)); rn = "ErrorEPC"; break; default: goto cp0_unimplemented; } break; case 31: switch (sel) { case 0: gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_DESAVE)); rn = "DESAVE"; break; case 2 ... 7: CP0_CHECK(ctx->kscrexist & (1 << sel)); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_KScratch[sel-2])); rn = "KScratch"; break; default: goto cp0_unimplemented; } ctx->bstate = BS_STOP; break; default: goto cp0_unimplemented; } (void)rn; LOG_DISAS("dmtc0 %s (reg %d sel %d)\n", rn, reg, sel); if (use_icount) { gen_io_end(); ctx->bstate = BS_STOP; } return; cp0_unimplemented: LOG_DISAS("dmtc0 %s (reg %d sel %d)\n", rn, reg, sel); }
1threat
Python performance : <p>I have a question regarding the performance of my python program. The part which is written down is very essential and I already increased the performance with numpy. I would like to know if it is possible to make this part even faster? A 10x speed up would already be nice.. </p> <pre><code>u = numpy.zeros((a**l, a**l)) re = numpy.zeros((a**l, a**l, a**l)) wp = numpy.zeros((a**l, 2)) ...Some code which edits u,re and wp... for x in range(N): wavg = numpy.dot(wp[:, 0], wp[:, 1]) wp[:, 0] = 1.0/wavg*numpy.dot(u, numpy.multiply(wp[:, 0], wp[:, 1])) wp[:, 0] = numpy.tensordot(numpy.tensordot(re, wp[:, 0], axes=1), wp[:, 0], axes=1) </code></pre>
0debug
Simple password hashing program c++ : <p>Im trying to add the output together. So instead of the output being 12 I want it to be 3, but I have no idea how to. Help is much appreciated. </p> <pre><code>int returnVal(char x) { return x - 96; } int main() { string s = "ab"; for (int i = 0; i &lt; s.length(); i++) { cout &lt;&lt; returnVal(s[i]); } return 0; } </code></pre>
0debug
Get Top Few Rows which satifies the Condition : <p>I need to get First Two Rows which are having C = '1', I'm ordering the query by TimeStamp Descending, I dont want the Last row to be Fetched by query</p> <pre><code> A B C TimeStamp ------------------------------------ foo one 1 20180405153936 foo two 1 20180405153936 foo two 2 20180405115417 foo one 2 20180405115053 foo three 1 20180405113923 </code></pre>
0debug
Connect to docker-machine using 'localhost' : <p>There are certain features, like JavaScript service workers without https, that only work on localhost, but when I run my app inside a docker container, using docker-compose, which runs on top of docker-machine, I need to connect to it using the address I get from </p> <pre><code>docker-machine ip default </code></pre> <p>Is there a way to map <code>localhost</code> to that ip?</p>
0debug
static void __attribute__((constructor)) st_init(void) { atexit(st_flush_trace_buffer); }
1threat
Is the "files" property necessary in package.json? : <p>It looks like the package will include all files (that are not ignored), even if the <code>package.json</code> has no <code>"files"</code> array.</p> <p>Is that property necessary?</p>
0debug
static int proxy_mknod(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { int retval; V9fsString fullname; v9fs_string_init(&fullname); v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); retval = v9fs_request(fs_ctx->private, T_MKNOD, NULL, "sdqdd", &fullname, credp->fc_mode, credp->fc_rdev, credp->fc_uid, credp->fc_gid); v9fs_string_free(&fullname); if (retval < 0) { errno = -retval; retval = -1; } return retval; }
1threat
how do i fix this horriable working c# access code : I have multiple people connecting to my access database and if two people happen to be searching at the same time i get an error so i did this to fix it and it cut down on the error alot but i still get it some times is there a better way ? public partial class Form2 : Form { private OleDbConnection connection = new OleDbConnection(); public Form2() { InitializeComponent(); connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=S:\Documents\2015\Db12.accdb"; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=S:\Documents\2015\Db12.accdb"; } protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == WM_NCHITTEST) m.Result = (IntPtr)(HT_CAPTION); } private const int WM_NCHITTEST = 0x84; private const int HT_CLIENT = 0x1; private const int HT_CAPTION = 0x2; private void lRead(string query, ListBox lbox) { OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = query; OleDbDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { lbox.Items.Add(reader["UAS"].ToString()); } } catch (Exception ex) { MessageBox.Show("error LREAD" + ex); } finally { if (reader != null) { reader.Dispose(); } } } private void textBox1_TextChanged(object sender, EventArgs e) { try { connection.Open(); listBox1.Items.Clear(); lRead($"select * from Table1 where UAS Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Customer Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Description Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Detail Like '%{textBox1.Text}%'", listBox1); //select * from SomeTable Where SomeColumn Like '* PARMA *' dont use * use % connection.Close(); } catch { System.Threading.Thread.Sleep(500); try { connection.Open(); listBox1.Items.Clear(); lRead($"select * from Table1 where UAS Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Customer Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Description Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Detail Like '%{textBox1.Text}%'", listBox1); //select * from SomeTable Where SomeColumn Like '* PARMA *' dont use * use % connection.Close(); } catch { System.Threading.Thread.Sleep(500); try { connection.Open(); listBox1.Items.Clear(); lRead($"select * from Table1 where UAS Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Customer Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Description Like '%{textBox1.Text}%'", listBox1); lRead($"select * from Table1 where Detail Like '%{textBox1.Text}%'", listBox1); //select * from SomeTable Where SomeColumn Like '* PARMA *' dont use * use % connection.Close(); } catch { MessageBox.Show("Error too many People Searching "); } } }
0debug
void do_POWER_divo (void) { int64_t tmp; if ((Ts0 == INT32_MIN && Ts1 == -1) || Ts1 == 0) { T0 = (long)((-1) * (T0 >> 31)); env->spr[SPR_MQ] = 0; xer_ov = 1; xer_so = 1; } else { tmp = ((uint64_t)T0 << 32) | env->spr[SPR_MQ]; env->spr[SPR_MQ] = tmp % T1; tmp /= Ts1; if (tmp > (int64_t)INT32_MAX || tmp < (int64_t)INT32_MIN) { xer_ov = 1; xer_so = 1; } else { xer_ov = 0; } T0 = tmp; } }
1threat
What is "playground mode" in Google's Colaboratory? : <p>I recently discovered Colaboratory. After playing with it for a few minutes, I have some idea what "playground mode" is - that no output is saved in that mode, but couldn't find a formal note in the FAQ or other help material (intro notebook) that I located. I'm wondering if there are more details to know about this mode and when is it suggested to be used?</p> <p>Thanks.</p>
0debug
Accessing elements from 2 JSON arrays and combining them together in a specific order in Javascript : So I have console.log output to show what I want. Array [ "srs-rt3" ] Array [ ] Array [ "srs-rt3" ] Array [ "srs-rt3", "atla-cr5" ] Array [ "srs-rt3:ge-0/1/0 -- atla-cr5:10/1/3" ] Array [ "srs-rt3", "atla-cr5", "srs-rt3:ge-0/1/0 -- atla-cr5:10/1/3" ] Array [ "srs-rt3", "atla-cr5", "ornl-cr5" ] Array [ "srs-rt3:ge-0/1/0 -- atla-cr5:10/1/3", "atla-cr5:3/1/1 -- ornl-cr5:6/1/1" ] The output is logged as and when I select each node in a network on the web UI. The first array is for nodes selected and second is for links(It is empty because only one node is selected and there is no second node to link it). When a second node is selected a link between 2 ports gets updated in the fourth array and this goes on as and when I keep selecting nodes.[Web UI][2] **What I want is an array with something like this** Array [srs-rt3, srs-rt3:ge-0/1/0,atla-cr5:10/1/3,atla-cr5, atla-cr5:3/1/1, ornl-cr5:6/1/1, ornl-cr5 ] **So the array should be ideally** {deviceA, firstPort, secondPort, deviceB, firstPort, secondPort, deviceC} [1]: https://i.stack.imgur.com/bRFLP.jpg [2]: https://i.stack.imgur.com/vhu2A.png Any inputs would be greatly appreciated
0debug
In which case does TaskCompletionSource.SetResult() run the continuation synchronously? : <p>Initially I thought that all continuations are executed on the threadpool (given a default synchronization context). This however doesn't seem to be the case when I use a <code>TaskCompletionSource</code>.</p> <p>My code looks something like this:</p> <pre><code>Task&lt;int&gt; Foo() { _tcs = new TaskCompletionSource&lt;int&gt;(); return _tcs.Task; } async void Bar() { Console.WriteLine(Thread.Current.ManagedThreadId); Console.WriteLine($"{Thread.Current.ManagedThreadId} - {await Foo()}"); } </code></pre> <p><code>Bar</code> gets called on a specific thread and the <code>TaskCompletionSource</code> stays unset for some time, meaning the returned tasks <code>IsComplete = false</code>. Then after some time, the same thread would proceed to call <code>_tcs.SetResult(x)</code>, which by my understanding should run the continuation on the threadpool.</p> <p>But what I observed in my application is that the thread running the continuation is in fact still the same thread, as if the continuation was invoked synchronously right as <code>SetResult</code> is called.</p> <p>I even tried setting a breakpoint on the <code>SetResult</code> and stepping over it (and having a breakpoint in the continuation), which in turn actually goes on to call the continuation synchronously.</p> <p><strong>When exactly does <code>SetResult()</code> immediately call the continuation synchronously?</strong></p>
0debug
Someone have a look at my source code for a number guessing game that seems to keep failing : <p>Hello please may someone run my code and assist me in debugging it. I'm having a lot of troubles trying to figure it out and i have not a lot of guidance when it comes to coding.</p> <p>the problem with my code right now is that it runs certain parts twice. please annotate the issue and any reccomendations to fix it. Thanks in advance</p> <p>a brief of what i'm trying to do: number guessing game the idea is that the computer will generate a random number and will ask the user if they know the number if the user gets the answer correct they will get a congrats message and then the game will end but if the user enters a wrong number they get a try again message and then they will try again</p> <pre><code>import javax.swing.*; import java.lang.*; public class Main { public static void main(String[] args) { /* number guessing game the idea is that the computer will generate a random number and will ask the user if they know the number if the user gets the answer correct they will get a congrats message and then the game will end but if the user enters a wrong number they get a try again message and then they will try again the problem with my code right now is that it runs certain parts twice. please annotate the issue and any recomendations to fix it. Thanks in advance */ enterScreen(); if (enterScreen() == 0){ number(); userIn(); answer(); } } public static int enterScreen (){ String[] options = {"Ofcourse", "Not today"}; int front = JOptionPane.showOptionDialog(null, "I'm thinking of a number between 0 and 100, can you guess what is is?", "Welcome", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, "Yes" ); if(front == 0){ JOptionPane.showMessageDialog(null, "Goodluck then, you might need it. :D"); } else { JOptionPane.showMessageDialog(null, "okay i dont mind"); } return front; } private static int number(){ double numD; numD = (Math.random() * Math.random()) * 100; int numI = (int) numD; System.out.println(numD); return numI; } private static int userIn(){ String userStr = JOptionPane.showInputDialog("What number do you think im thinking of?"); int user = Integer.parseInt(userStr); return 0; } private static void answer(){ // here is the problem if(userIn() == number()){ JOptionPane.showMessageDialog(null, "Well done! You must be a genius."); } else { JOptionPane.showMessageDialog(null, "Shame, TRY AGAIN!"); userIn(); } } </code></pre> <p>}</p>
0debug
static int configure_filters(AVInputStream *ist, AVOutputStream *ost) { AVFilterContext *curr_filter; AVCodecContext *codec = ost->st->codec; AVCodecContext *icodec = ist->st->codec; char args[255]; filt_graph_all = av_mallocz(sizeof(AVFilterGraph)); if(!(ist->input_video_filter = avfilter_open(avfilter_get_by_name("buffer"), "src"))) return -1; if(!(ist->out_video_filter = avfilter_open(&output_filter, "out"))) return -1; snprintf(args, 255, "%d:%d:%d", ist->st->codec->width, ist->st->codec->height, ist->st->codec->pix_fmt); if(avfilter_init_filter(ist->input_video_filter, args, NULL)) return -1; if(avfilter_init_filter(ist->out_video_filter, NULL, &codec->pix_fmt)) return -1; avfilter_graph_add_filter(filt_graph_all, ist->input_video_filter); avfilter_graph_add_filter(filt_graph_all, ist->out_video_filter); curr_filter = ist->input_video_filter; if(ost->video_crop) { char crop_args[255]; AVFilterContext *filt_crop; snprintf(crop_args, 255, "%d:%d:%d:%d", ost->leftBand, ost->topBand, codec->width - (frame_padleft + frame_padright), codec->height - (frame_padtop + frame_padbottom)); filt_crop = avfilter_open(avfilter_get_by_name("crop"), NULL); if (!filt_crop) return -1; if (avfilter_init_filter(filt_crop, crop_args, NULL)) return -1; if (avfilter_link(curr_filter, 0, filt_crop, 0)) return -1; curr_filter = filt_crop; avfilter_graph_add_filter(filt_graph_all, curr_filter); } if((codec->width != icodec->width - (frame_leftBand + frame_rightBand) + (frame_padleft + frame_padright)) || (codec->height != icodec->height - (frame_topBand + frame_bottomBand) + (frame_padtop + frame_padbottom))) { char scale_args[255]; AVFilterContext *filt_scale; snprintf(scale_args, 255, "%d:%d:flags=0x%X", codec->width - (frame_padleft + frame_padright), codec->height - (frame_padtop + frame_padbottom), (int)av_get_int(sws_opts, "sws_flags", NULL)); filt_scale = avfilter_open(avfilter_get_by_name("scale"), NULL); if (!filt_scale) return -1; if (avfilter_init_filter(filt_scale, scale_args, NULL)) return -1; if (avfilter_link(curr_filter, 0, filt_scale, 0)) return -1; curr_filter = filt_scale; avfilter_graph_add_filter(filt_graph_all, curr_filter); } if(vfilters) { AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); outputs->name = av_strdup("in"); outputs->filter = curr_filter; outputs->pad_idx = 0; outputs->next = NULL; inputs->name = av_strdup("out"); inputs->filter = ist->out_video_filter; inputs->pad_idx = 0; inputs->next = NULL; if (avfilter_graph_parse(filt_graph_all, vfilters, inputs, outputs, NULL) < 0) return -1; av_freep(&vfilters); } else { if(avfilter_link(curr_filter, 0, ist->out_video_filter, 0) < 0) return -1; } { char scale_sws_opts[128]; snprintf(scale_sws_opts, sizeof(scale_sws_opts), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL)); filt_graph_all->scale_sws_opts = av_strdup(scale_sws_opts); } if(avfilter_graph_check_validity(filt_graph_all, NULL)) return -1; if(avfilter_graph_config_formats(filt_graph_all, NULL)) return -1; if(avfilter_graph_config_links(filt_graph_all, NULL)) return -1; codec->width = ist->out_video_filter->inputs[0]->w; codec->height = ist->out_video_filter->inputs[0]->h; return 0; }
1threat
static size_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...) { size_t old_offset = offset; va_list ap; int i; va_start(ap, fmt); for (i = 0; fmt[i]; i++) { switch (fmt[i]) { case 'b': { uint8_t val = va_arg(ap, int); offset += pdu_pack(pdu, offset, &val, sizeof(val)); break; } case 'w': { uint16_t val; cpu_to_le16w(&val, va_arg(ap, int)); offset += pdu_pack(pdu, offset, &val, sizeof(val)); break; } case 'd': { uint32_t val; cpu_to_le32w(&val, va_arg(ap, uint32_t)); offset += pdu_pack(pdu, offset, &val, sizeof(val)); break; } case 'q': { uint64_t val; cpu_to_le64w(&val, va_arg(ap, uint64_t)); offset += pdu_pack(pdu, offset, &val, sizeof(val)); break; } case 'v': { struct iovec *iov = va_arg(ap, struct iovec *); int *iovcnt = va_arg(ap, int *); *iovcnt = pdu_copy_sg(pdu, offset, 1, iov); break; } case 's': { V9fsString *str = va_arg(ap, V9fsString *); offset += pdu_marshal(pdu, offset, "w", str->size); offset += pdu_pack(pdu, offset, str->data, str->size); break; } case 'Q': { V9fsQID *qidp = va_arg(ap, V9fsQID *); offset += pdu_marshal(pdu, offset, "bdq", qidp->type, qidp->version, qidp->path); break; } case 'S': { V9fsStat *statp = va_arg(ap, V9fsStat *); offset += pdu_marshal(pdu, offset, "wwdQdddqsssssddd", statp->size, statp->type, statp->dev, &statp->qid, statp->mode, statp->atime, statp->mtime, statp->length, &statp->name, &statp->uid, &statp->gid, &statp->muid, &statp->extension, statp->n_uid, statp->n_gid, statp->n_muid); break; } case 'A': { V9fsStatDotl *statp = va_arg(ap, V9fsStatDotl *); offset += pdu_marshal(pdu, offset, "qQdddqqqqqqqqqqqqqqq", statp->st_result_mask, &statp->qid, statp->st_mode, statp->st_uid, statp->st_gid, statp->st_nlink, statp->st_rdev, statp->st_size, statp->st_blksize, statp->st_blocks, statp->st_atime_sec, statp->st_atime_nsec, statp->st_mtime_sec, statp->st_mtime_nsec, statp->st_ctime_sec, statp->st_ctime_nsec, statp->st_btime_sec, statp->st_btime_nsec, statp->st_gen, statp->st_data_version); break; } default: break; } } va_end(ap); return offset - old_offset; }
1threat
Predicting a users next password : <p>I need to be able to predict what a users password is next <em>likley</em> to be, given a list of historic passwords they have used before.</p> <p>For example let's say I have used the passwords: Password1, Password2, Password3. You could take a good guess that my next password is likely to be Password4. Or given January2017!, March2017!, May2017!, July2017! you could guess my next password would be September2017!.</p> <p>The number of historic passwords I have could be as few as 2, but as many as ~50. The use case here is to prevent them from choosing a password that is "predicatable" and use it as a training aid.</p> <p>Is Machine Learning the best solution here? I'm guessing not as my "training data" would be very limited per user. Guessing number increases like in my first example would be fairly straight forward and I could write a simple algorithm. But what about +2 month password? I don't want to write in all edge cases of passwords.</p> <p>Any suggestions?</p>
0debug
prompt a serie of 3 number javascript : > hi im looking to *create* a <prompt> function asking the user for how many numbers must be generated randomly in a serie of 200 numbers,from 0 to 200. THanks
0debug
convert Swift 2.3 to Swift 4 : <p>I am new in Swift 4 and I want to resolve the Swift version 2.0 Project with Uitextview error</p> <p>here is error in Swift 4 </p> <pre><code>let textView = UITextView(frame: CGRectInset(view.bounds, 10, 10)) </code></pre> <p>I will change with <strong>'CGRectInset' has been replaced by instance method 'CGRect.insetBy(dx:dy:)'</strong></p> <p>but I don't know how </p> <p>I change with let textView = UITextView(frame: CGRect.insetBy(view.bounds, 10, 10)) but error again </p> <p>and here is other problem </p> <pre><code>textView.textContainerInset = UIEdgeInsetsZero </code></pre> <p>I will change the <code>UIEdgeInsetsZero</code></p>
0debug
uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2) { HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); return mvc_asc(env, l, a1, PSW_ASC_SECONDARY, a2, PSW_ASC_PRIMARY); }
1threat
How to use the dotnet-pack --version-suffix with csproj? : <p>I'm trying to use the .net Core tools RC4 dotnet pack command to create a nuget package with a suffix.</p> <p>I can create "MyProject.1.2.3.nupkg" successfully but I want "MyProject.1.2.3-beta.nupkg".</p> <p>According to the documentation <a href="https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/dotnet-pack" rel="noreferrer">here</a> the --version-suffix "Updates the star in -* package version suffix with a specified string."</p> <p>I've managed to find where dotnet pack is getting it's version from - dotnet pack uses msbuild under the <a href="https://github.com/NuGet/Home/wiki/Adding-nuget-pack-as-a-msbuild-target" rel="noreferrer">covers which uses the <code>&lt;version/&gt;</code> element</a> in the csproj file. For example <code>&lt;version&gt;1.2.3&lt;/version&gt;</code> creates a file called "MyProject.1.2.3.nupkg".</p> <p>If I set the <code>&lt;version/&gt;</code> in the csproj to something like 1.2.3 and specify --version-suffix beta then it doesn't append the -beta but it does build.</p> <p>If I set version to be <code>&lt;version&gt;1.2.3-*&lt;/version&gt;</code> then dotnet restore breaks saying '1.2.3-*' is not a valid version string.</p> <p>I think I'm close; what have I got wrong?</p>
0debug
which type of argument passes a value to a procedure from the calling environment : which type of argument passes a value to a procedure from the calling environment 1.IN 2.IN OUT 3.OUT 4.OUT IN if more than one answer is possible than give the answer.
0debug
int ff_vaapi_decode_init(AVCodecContext *avctx) { VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data; VAStatus vas; int err; ctx->va_config = VA_INVALID_ID; ctx->va_context = VA_INVALID_ID; #if FF_API_VAAPI_CONTEXT if (avctx->hwaccel_context) { av_log(avctx, AV_LOG_WARNING, "Using deprecated struct " "vaapi_context in decode.\n"); ctx->have_old_context = 1; ctx->old_context = avctx->hwaccel_context; ctx->device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI); if (!ctx->device_ref) { err = AVERROR(ENOMEM); goto fail; } ctx->device = (AVHWDeviceContext*)ctx->device_ref->data; ctx->hwctx = ctx->device->hwctx; ctx->hwctx->display = ctx->old_context->display; ctx->hwctx->driver_quirks = AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS; } else #endif if (avctx->hw_frames_ctx) { ctx->frames = (AVHWFramesContext*)avctx->hw_frames_ctx->data; ctx->hwfc = ctx->frames->hwctx; ctx->device = ctx->frames->device_ctx; ctx->hwctx = ctx->device->hwctx; } else if (avctx->hw_device_ctx) { ctx->device = (AVHWDeviceContext*)avctx->hw_device_ctx->data; ctx->hwctx = ctx->device->hwctx; if (ctx->device->type != AV_HWDEVICE_TYPE_VAAPI) { av_log(avctx, AV_LOG_ERROR, "Device supplied for VAAPI " "decoding must be a VAAPI device (not %d).\n", ctx->device->type); err = AVERROR(EINVAL); goto fail; } } else { av_log(avctx, AV_LOG_ERROR, "A hardware device or frames context " "is required for VAAPI decoding.\n"); err = AVERROR(EINVAL); goto fail; } #if FF_API_VAAPI_CONTEXT if (ctx->have_old_context) { ctx->va_config = ctx->old_context->config_id; ctx->va_context = ctx->old_context->context_id; av_log(avctx, AV_LOG_DEBUG, "Using user-supplied decoder " "context: %#x/%#x.\n", ctx->va_config, ctx->va_context); } else { #endif err = vaapi_decode_make_config(avctx); if (err) goto fail; if (!avctx->hw_frames_ctx) { avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx); if (!avctx->hw_frames_ctx) { err = AVERROR(ENOMEM); goto fail; } ctx->frames = (AVHWFramesContext*)avctx->hw_frames_ctx->data; ctx->frames->format = AV_PIX_FMT_VAAPI; ctx->frames->width = avctx->coded_width; ctx->frames->height = avctx->coded_height; ctx->frames->sw_format = ctx->surface_format; ctx->frames->initial_pool_size = ctx->surface_count; err = av_hwframe_ctx_init(avctx->hw_frames_ctx); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to initialise internal " "frames context: %d.\n", err); goto fail; } ctx->hwfc = ctx->frames->hwctx; } vas = vaCreateContext(ctx->hwctx->display, ctx->va_config, avctx->coded_width, avctx->coded_height, VA_PROGRESSIVE, ctx->hwfc->surface_ids, ctx->hwfc->nb_surfaces, &ctx->va_context); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to create decode " "context: %d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail; } av_log(avctx, AV_LOG_DEBUG, "Decode context initialised: " "%#x/%#x.\n", ctx->va_config, ctx->va_context); #if FF_API_VAAPI_CONTEXT } #endif return 0; fail: ff_vaapi_decode_uninit(avctx); return err; }
1threat
static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { const VC1Context *v = avctx->priv_data; const MpegEncContext *s = &v->s; struct vaapi_context * const vactx = avctx->hwaccel_context; VAPictureParameterBufferVC1 *pic_param; vactx->slice_param_size = sizeof(VASliceParameterBufferVC1); pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1)); if (!pic_param) return -1; pic_param->forward_reference_picture = VA_INVALID_ID; pic_param->backward_reference_picture = VA_INVALID_ID; pic_param->inloop_decoded_picture = VA_INVALID_ID; pic_param->sequence_fields.value = 0; pic_param->sequence_fields.bits.pulldown = v->broadcast; pic_param->sequence_fields.bits.interlace = v->interlace; pic_param->sequence_fields.bits.tfcntrflag = v->tfcntrflag; pic_param->sequence_fields.bits.finterpflag = v->finterpflag; pic_param->sequence_fields.bits.psf = v->psf; pic_param->sequence_fields.bits.multires = v->multires; pic_param->sequence_fields.bits.overlap = v->overlap; pic_param->sequence_fields.bits.syncmarker = v->resync_marker; pic_param->sequence_fields.bits.rangered = v->rangered; pic_param->sequence_fields.bits.max_b_frames = s->avctx->max_b_frames; #if VA_CHECK_VERSION(0,32,0) pic_param->sequence_fields.bits.profile = v->profile; #endif pic_param->coded_width = s->avctx->coded_width; pic_param->coded_height = s->avctx->coded_height; pic_param->entrypoint_fields.value = 0; pic_param->entrypoint_fields.bits.broken_link = v->broken_link; pic_param->entrypoint_fields.bits.closed_entry = v->closed_entry; pic_param->entrypoint_fields.bits.panscan_flag = v->panscanflag; pic_param->entrypoint_fields.bits.loopfilter = s->loop_filter; pic_param->conditional_overlap_flag = v->condover; pic_param->fast_uvmc_flag = v->fastuvmc; pic_param->range_mapping_fields.value = 0; pic_param->range_mapping_fields.bits.luma_flag = v->range_mapy_flag; pic_param->range_mapping_fields.bits.luma = v->range_mapy; pic_param->range_mapping_fields.bits.chroma_flag = v->range_mapuv_flag; pic_param->range_mapping_fields.bits.chroma = v->range_mapuv; pic_param->b_picture_fraction = v->bfraction_lut_index; pic_param->cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0; pic_param->mb_mode_table = 0; pic_param->range_reduction_frame = v->rangeredfrm; pic_param->rounding_control = v->rnd; pic_param->post_processing = v->postproc; pic_param->picture_resolution_index = v->respic; pic_param->luma_scale = v->lumscale; pic_param->luma_shift = v->lumshift; pic_param->picture_fields.value = 0; pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(v); pic_param->picture_fields.bits.frame_coding_mode = v->fcm; pic_param->picture_fields.bits.top_field_first = v->tff; pic_param->picture_fields.bits.is_first_field = v->fcm == 0; pic_param->picture_fields.bits.intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP; pic_param->raw_coding.value = 0; pic_param->raw_coding.flags.mv_type_mb = v->mv_type_is_raw; pic_param->raw_coding.flags.direct_mb = v->dmb_is_raw; pic_param->raw_coding.flags.skip_mb = v->skip_is_raw; pic_param->raw_coding.flags.field_tx = 0; pic_param->raw_coding.flags.forward_mb = 0; pic_param->raw_coding.flags.ac_pred = v->acpred_is_raw; pic_param->raw_coding.flags.overflags = v->overflg_is_raw; pic_param->bitplane_present.value = 0; pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v); pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(v); pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(v); pic_param->bitplane_present.flags.bp_field_tx = 0; pic_param->bitplane_present.flags.bp_forward_mb = 0; pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(v); pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(v); pic_param->reference_fields.value = 0; pic_param->reference_fields.bits.reference_distance_flag = v->refdist_flag; pic_param->reference_fields.bits.reference_distance = 0; pic_param->reference_fields.bits.num_reference_pictures = 0; pic_param->reference_fields.bits.reference_field_pic_indicator = 0; pic_param->mv_fields.value = 0; pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(v); pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(v); pic_param->mv_fields.bits.mv_table = s->mv_table_index; pic_param->mv_fields.bits.two_mv_block_pattern_table = 0; pic_param->mv_fields.bits.four_mv_switch = 0; pic_param->mv_fields.bits.four_mv_block_pattern_table = 0; pic_param->mv_fields.bits.extended_mv_flag = v->extended_mv; pic_param->mv_fields.bits.extended_mv_range = v->mvrange; pic_param->mv_fields.bits.extended_dmv_flag = v->extended_dmv; pic_param->mv_fields.bits.extended_dmv_range = 0; pic_param->pic_quantizer_fields.value = 0; pic_param->pic_quantizer_fields.bits.dquant = v->dquant; pic_param->pic_quantizer_fields.bits.quantizer = v->quantizer_mode; pic_param->pic_quantizer_fields.bits.half_qp = v->halfpq; pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = v->pq; pic_param->pic_quantizer_fields.bits.pic_quantizer_type = v->pquantizer; pic_param->pic_quantizer_fields.bits.dq_frame = v->dquantfrm; pic_param->pic_quantizer_fields.bits.dq_profile = v->dqprofile; pic_param->pic_quantizer_fields.bits.dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0; pic_param->pic_quantizer_fields.bits.dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0; pic_param->pic_quantizer_fields.bits.dq_binary_level = v->dqbilevel; pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = v->altpq; pic_param->transform_fields.value = 0; pic_param->transform_fields.bits.variable_sized_transform_flag = v->vstransform; pic_param->transform_fields.bits.mb_level_transform_type_flag = v->ttmbf; pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(v); pic_param->transform_fields.bits.transform_ac_codingset_idx1 = v->c_ac_table_index; pic_param->transform_fields.bits.transform_ac_codingset_idx2 = v->y_ac_table_index; pic_param->transform_fields.bits.intra_transform_dc_table = v->s.dc_table_index; switch (s->pict_type) { case AV_PICTURE_TYPE_B: pic_param->backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f); case AV_PICTURE_TYPE_P: pic_param->forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f); break; } if (pic_param->bitplane_present.value) { uint8_t *bitplane; const uint8_t *ff_bp[3]; int x, y, n; switch (s->pict_type) { case AV_PICTURE_TYPE_P: ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL; break; case AV_PICTURE_TYPE_B: if (!v->bi_type) { ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; ff_bp[2] = NULL; break; } case AV_PICTURE_TYPE_I: ff_bp[0] = NULL; ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL; ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL; break; default: ff_bp[0] = NULL; ff_bp[1] = NULL; ff_bp[2] = NULL; break; } bitplane = ff_vaapi_alloc_bitplane(vactx, (s->mb_width * s->mb_height + 1) / 2); if (!bitplane) return -1; n = 0; for (y = 0; y < s->mb_height; y++) for (x = 0; x < s->mb_width; x++, n++) vc1_pack_bitplanes(bitplane, n, ff_bp, x, y, s->mb_stride); if (n & 1) bitplane[n/2] <<= 4; } return 0; }
1threat
Xcode 8 beta simulator fails to run app after accidentally running Xcode8 simulator : <p>"Failed to initiate service connection to simulator"</p> <p>Tried to clean app, reinstall it, delete derived data, reset simulator settings, restart xCode. I've also heard other people solved problems with their simulators by recreating the simulator. I tried that as well. When I press create, I get the very same error message: "Error returned in reply: Connection invalid"</p> <p><a href="https://i.stack.imgur.com/ImzkA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ImzkA.png" alt="Failed to initiate service connection to simulator"></a></p>
0debug
PPC_OP(test_ctrz_false) { T0 = (regs->ctr == 0 && (T0 & PARAM(1)) == 0); RETURN(); }
1threat
cannot be resolved to a variable eclipse main class : <p>I am fairly new at this and have been looking for a solution on Internet for two days, yet, I could not find any.</p> <p>This is the class that I identified and initialized variables.</p> <pre><code> package HelloWorld; import java.awt.*; public class Car { double averageMilesPerGallon; String licensePlate; Color paintColor; boolean areTaillightsWorking; public Car(double inputAverageMPG, String inputLicensePlate, Color inputPaintColor, boolean inputAreTaillightsWorking) { this.averageMilesPerGallon = inputAverageMPG; this.licensePlate = inputLicensePlate; this.paintColor = inputPaintColor; this.areTaillightsWorking = inputAreTaillightsWorking; } } </code></pre> <p>Then, I wanted use these variables in my main class; however, it did not work. I received an error that was saying; "inputAverageMPG cannot be resolved to a variable" and "inputLicensePlate cannot be resolved to a variable." Please refer below to see the main class wherein I received the error.</p> <pre><code>package HelloWorld; public class Main { public static void main(String[] args) { System.out.println("yes"); Car myCar = new Car(inputAverageMPG = 25.5, inputLicensePlate "12HTHF"); } } </code></pre>
0debug
static always_inline int get_segment (CPUState *env, mmu_ctx_t *ctx, target_ulong eaddr, int rw, int type) { target_phys_addr_t sdr, hash, mask, sdr_mask, htab_mask; target_ulong sr, vsid, vsid_mask, pgidx, page_mask; #if defined(TARGET_PPC64) int attr; #endif int ds, vsid_sh, sdr_sh, pr; int ret, ret2; pr = msr_pr; #if defined(TARGET_PPC64) if (env->mmu_model == POWERPC_MMU_64B) { #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "Check SLBs\n"); } #endif ret = slb_lookup(env, eaddr, &vsid, &page_mask, &attr); if (ret < 0) return ret; ctx->key = ((attr & 0x40) && (pr != 0)) || ((attr & 0x80) && (pr == 0)) ? 1 : 0; ds = 0; ctx->nx = attr & 0x20 ? 1 : 0; vsid_mask = 0x00003FFFFFFFFF80ULL; vsid_sh = 7; sdr_sh = 18; sdr_mask = 0x3FF80; } else #endif { sr = env->sr[eaddr >> 28]; page_mask = 0x0FFFFFFF; ctx->key = (((sr & 0x20000000) && (pr != 0)) || ((sr & 0x40000000) && (pr == 0))) ? 1 : 0; ds = sr & 0x80000000 ? 1 : 0; ctx->nx = sr & 0x10000000 ? 1 : 0; vsid = sr & 0x00FFFFFF; vsid_mask = 0x01FFFFC0; vsid_sh = 6; sdr_sh = 16; sdr_mask = 0xFFC0; #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "Check segment v=0x" ADDRX " %d 0x" ADDRX " nip=0x" ADDRX " lr=0x" ADDRX " ir=%d dr=%d pr=%d %d t=%d\n", eaddr, (int)(eaddr >> 28), sr, env->nip, env->lr, (int)msr_ir, (int)msr_dr, pr != 0 ? 1 : 0, rw, type); } #endif } #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "pte segment: key=%d ds %d nx %d vsid " ADDRX "\n", ctx->key, ds, ctx->nx, vsid); } #endif ret = -1; if (!ds) { if (type != ACCESS_CODE || ctx->nx == 0) { sdr = env->sdr1; pgidx = (eaddr & page_mask) >> TARGET_PAGE_BITS; #if defined(TARGET_PPC64) if (env->mmu_model == POWERPC_MMU_64B) { htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F)); hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask; } else #endif { htab_mask = sdr & 0x000001FF; hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask; } mask = (htab_mask << sdr_sh) | sdr_mask; #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask " PADDRX " " ADDRX "\n", sdr, sdr_sh, hash, mask, page_mask); } #endif ctx->pg_addr[0] = get_pgaddr(sdr, sdr_sh, hash, mask); hash = (~hash) & vsid_mask; #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask " PADDRX "\n", sdr, sdr_sh, hash, mask); } #endif ctx->pg_addr[1] = get_pgaddr(sdr, sdr_sh, hash, mask); #if defined(TARGET_PPC64) if (env->mmu_model == POWERPC_MMU_64B) { ctx->ptem = (vsid << 12) | ((pgidx >> 4) & 0x0F80); } else #endif { ctx->ptem = (vsid << 7) | (pgidx >> 10); } ctx->raddr = (target_ulong)-1; if (unlikely(env->mmu_model == POWERPC_MMU_SOFT_6xx || env->mmu_model == POWERPC_MMU_SOFT_74xx)) { ret = ppc6xx_tlb_check(env, ctx, eaddr, rw, type); } else { #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "0 sdr1=0x" PADDRX " vsid=0x%06x " "api=0x%04x hash=0x%07x pg_addr=0x" PADDRX "\n", sdr, (uint32_t)vsid, (uint32_t)pgidx, (uint32_t)hash, ctx->pg_addr[0]); } #endif ret = find_pte(env, ctx, 0, rw, type); if (ret < 0) { #if defined (DEBUG_MMU) if (eaddr != 0xEFFFFFFF && loglevel != 0) { fprintf(logfile, "1 sdr1=0x" PADDRX " vsid=0x%06x api=0x%04x " "hash=0x%05x pg_addr=0x" PADDRX "\n", sdr, (uint32_t)vsid, (uint32_t)pgidx, (uint32_t)hash, ctx->pg_addr[1]); } #endif ret2 = find_pte(env, ctx, 1, rw, type); if (ret2 != -1) ret = ret2; } } #if defined (DUMP_PAGE_TABLES) if (loglevel != 0) { target_phys_addr_t curaddr; uint32_t a0, a1, a2, a3; fprintf(logfile, "Page table: " PADDRX " len " PADDRX "\n", sdr, mask + 0x80); for (curaddr = sdr; curaddr < (sdr + mask + 0x80); curaddr += 16) { a0 = ldl_phys(curaddr); a1 = ldl_phys(curaddr + 4); a2 = ldl_phys(curaddr + 8); a3 = ldl_phys(curaddr + 12); if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) { fprintf(logfile, PADDRX ": %08x %08x %08x %08x\n", curaddr, a0, a1, a2, a3); } } } #endif } else { #if defined (DEBUG_MMU) if (loglevel != 0) fprintf(logfile, "No access allowed\n"); #endif ret = -3; } } else { #if defined (DEBUG_MMU) if (loglevel != 0) fprintf(logfile, "direct store...\n"); #endif switch (type) { case ACCESS_INT: break; case ACCESS_CODE: return -4; case ACCESS_FLOAT: return -4; case ACCESS_RES: return -4; case ACCESS_CACHE: ctx->raddr = eaddr; return 0; case ACCESS_EXT: return -4; default: if (logfile) { fprintf(logfile, "ERROR: instruction should not need " "address translation\n"); } return -4; } if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) { ctx->raddr = eaddr; ret = 2; } else { ret = -2; } } return ret; }
1threat
react-table add edit/delete column : <p>I use Rails and React-Table to display tables. It works fine so far. But How can one add an edit/delete column to the React-Table?</p> <p>Is it even possible?</p> <pre><code>return ( &lt;ReactTable data={this.props.working_hours} columns={columns} defaultPageSize={50} className="-striped -highlight" /&gt; ) </code></pre>
0debug
dplyr rename error: contains unknown variables : <p>Very simple, renaming colnames with dplyr gives me an odd error.</p> <pre><code> library(dplyr) df &lt;- data.frame(var1=c("one","two","three"),var2=c(1,2,3)) df &lt;- df %&gt;% rename(var1=are.letters, var2=are.numbers) Error: `are.letters`, `are.numbers` contains unknown variables </code></pre> <p>second try </p> <pre><code> df &lt;- rename(df, var1=are.letters, var2=are.numbers) Error: `are.letters`, `are.numbers` contains unknown variables </code></pre> <p>Wondering if quoting....</p> <pre><code>df &lt;- df %&gt;% rename('var1'='are.letters', 'var2'='are.numbers') Error: `are.letters`, `are.numbers` contains unknown variables </code></pre>
0debug
What is the output of this python code? : So the code is: X = range(4, 7) Y = range(2) X[2] = Y print X[2][0] print X[2][1] X[2][0] = 9 print Y[0] And the output is 0 1 9 What exactly is the code doing to get that output? Also if the code looked like X = range(4, 7) print X[-1] Then what would the output be because I'm confused about what negative values do.
0debug
QByteArray to Double in QT C++ 5.8.0 : Im beginner in QT C++, I get struck here from last few days. Actually I have serial comport data read write program, Data is been read from the comport 4 (Eg: 1022). but when i m trying to do a mathematical calculation of the data 1022/2 then its give me output as 0.5 5.0 51.00 511.0 means its not taking the whole 1022 as a single number for the mathematical calculation. Its take 1 first then divide 1/2=0.5 then once 0 digit receive it take as 10/2=5 and so on. But i want 1022 as a single number like (eg: 1022/2=511) [I have tried to convert the QbyteArray into Double for the calculation.] Your help will be so helpful the finished my project thanks a lot. here is the output [output][1] [1]: https://i.stack.imgur.com/97Y7z.png void MainWindow::readData() { QByteArray data = serial->readAll(); bool ok; QByteArray cata= QByteArray::number(data.toDouble(&ok)/2); console->putData(cata); }
0debug
Code to build all possible strings, and find a specific one doesen't work as expected : <p>Part of a task I'm trying to solve is building all possible combinations of letters and whitespace. I'm trying to find a specific String, while building the combinations. I think i implemented the solution well, but my test tells me otherwise.</p> <p>I'm taking the chars from an array and in a for loop I build a String from them, then print the solution. When I built all the combinations of let's say "1 character combinations", then i move on to "2 character combinations". I have a boolean to check if the contents of the StringBuilder is equal to the given String that i want to find. I checked, and the example String was indeed built, but the boolean didn't change.</p> <pre><code>public static void main(String[] args) throws InterruptedException { findString("rxc"); } public static void findString(String string) { boolean isFound = false; String allChars = "abcdefghijklmnopqrstuvwxyz "; char[] sequence = allChars.toCharArray(); int lengthOfExpression = 3; //builder contains 3 whitespaces at the beginning StringBuilder builder = new StringBuilder(" "); int[] pos = new int[lengthOfExpression]; int total = (int) Math.pow(allChars.length(), lengthOfExpression); for (int i = 0; i &lt; total; i++) { for (int x = 0; x &lt; lengthOfExpression; x++) { if (pos[x] == sequence.length) { pos[x] = 0; if (x + 1 &lt; lengthOfExpression) { pos[x + 1]++; } } builder.setCharAt(x, sequence[pos[x]]); } pos[0]++; if (builder.toString() == string) { isFound = true; } System.out.println(builder.toString()); } System.out.println(isFound); } </code></pre> <p>Expected result would be a 'true' printed at the end. Instead, my result is as follows:</p> <p>//lots of lines of combinations omitted</p> <p>r<br> s<br> t<br> u<br> v<br> w<br> x<br> y<br> z </p> <p>false</p>
0debug
int av_tempfile(char *prefix, char **filename) { int fd=-1; #ifdef __MINGW32__ *filename = tempnam(".", prefix); #else size_t len = strlen(prefix) + 12; *filename = av_malloc(len); #endif if (*filename == NULL) { av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n"); return -1; } #ifdef __MINGW32__ fd = open(*filename, _O_RDWR | _O_BINARY | _O_CREAT, 0444); #else snprintf(*filename, len, "/tmp/%sXXXXXX", prefix); fd = mkstemp(*filename); if (fd < 0) { snprintf(*filename, len, "./%sXXXXXX", prefix); fd = mkstemp(*filename); } #endif if (fd < 0) { av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename); return -1; } return fd; }
1threat
How to remove all instances of 'a' and 'c' in a string in Javascript? : <p>How do I remove all instances of two different letters in a string?</p> <p>For example, I want to remove 'a' and 'c' from 'abcabc' so that it becomes 'bb'.</p> <p>I know I can't do <code>'abcabc'.replace(/a/g, '').replace(/c/g, '')</code> but is there another regEx I can use so that I don't have to chain the <code>replace</code> function?</p> <p>Thanks!</p>
0debug
How is JobIntentService related to JobService? : <p>In case of <code>Service</code> and <code>IntentService</code> the main differences are <code>Service</code> runs on the main thread while <code>IntentService</code> is not, and the latter finishes itself when the work is done while we have to call either <code>stopService()</code> or <code>stopSelf()</code> to stop a <code>Service</code>.</p> <p>Both of these can be simply passed to <code>startService()</code>.</p> <p>What about <code>JobService</code> and <code>JobIntentService</code>?</p> <p>Let's take the following code snippet:</p> <pre><code>JobInfo job = new JobInfo.Builder(id, new ComponentName(context, ExampleJobService.class)) .build(); JobScheduler scheduler = (JobScheduler) context .getSystemService(Context.JOB_SCHEDULER_SERVICE); scheduler.schedule(job); </code></pre> <p>Can <code>ExampleJobService.class</code> refer to both a <code>JobService</code> and a <code>JobIntentService</code>?</p> <p>Will the behaviour be the same as with <code>Service</code> and <code>IntentService</code> (apart from the <code>JobScheduler</code> may not start the jobs immediately)?</p>
0debug
how do you stop search in a loop once you meet the condition : how do you stop the for each loop from proceeding when the condition is false? because I can only let x = newX when all the object in the collection is true to the condition. thank you for help. break won't help, I tried. for (char h : collection){ if ( condition == false ) { } else{ x = newX; } }
0debug
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) { GuestNetworkInterfaceList *head = NULL, *cur_item = NULL; struct ifaddrs *ifap, *ifa; if (getifaddrs(&ifap) < 0) { error_setg_errno(errp, errno, "getifaddrs failed"); goto error; } for (ifa = ifap; ifa; ifa = ifa->ifa_next) { GuestNetworkInterfaceList *info; GuestIpAddressList **address_list = NULL, *address_item = NULL; char addr4[INET_ADDRSTRLEN]; char addr6[INET6_ADDRSTRLEN]; int sock; struct ifreq ifr; unsigned char *mac_addr; void *p; g_debug("Processing %s interface", ifa->ifa_name); info = guest_find_interface(head, ifa->ifa_name); if (!info) { info = g_malloc0(sizeof(*info)); info->value = g_malloc0(sizeof(*info->value)); info->value->name = g_strdup(ifa->ifa_name); if (!cur_item) { head = cur_item = info; } else { cur_item->next = info; cur_item = info; } } if (!info->value->has_hardware_address && ifa->ifa_flags & SIOCGIFHWADDR) { sock = socket(PF_INET, SOCK_STREAM, 0); if (sock == -1) { error_setg_errno(errp, errno, "failed to create socket"); goto error; } memset(&ifr, 0, sizeof(ifr)); pstrcpy(ifr.ifr_name, IF_NAMESIZE, info->value->name); if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) { error_setg_errno(errp, errno, "failed to get MAC address of %s", ifa->ifa_name); goto error; } mac_addr = (unsigned char *) &ifr.ifr_hwaddr.sa_data; info->value->hardware_address = g_strdup_printf("%02x:%02x:%02x:%02x:%02x:%02x", (int) mac_addr[0], (int) mac_addr[1], (int) mac_addr[2], (int) mac_addr[3], (int) mac_addr[4], (int) mac_addr[5]); info->value->has_hardware_address = true; close(sock); } if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { address_item = g_malloc0(sizeof(*address_item)); address_item->value = g_malloc0(sizeof(*address_item->value)); p = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; if (!inet_ntop(AF_INET, p, addr4, sizeof(addr4))) { error_setg_errno(errp, errno, "inet_ntop failed"); goto error; } address_item->value->ip_address = g_strdup(addr4); address_item->value->ip_address_type = GUEST_IP_ADDRESS_TYPE_IPV4; if (ifa->ifa_netmask) { p = &((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr; address_item->value->prefix = ctpop32(((uint32_t *) p)[0]); } } else if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET6) { address_item = g_malloc0(sizeof(*address_item)); address_item->value = g_malloc0(sizeof(*address_item->value)); p = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr; if (!inet_ntop(AF_INET6, p, addr6, sizeof(addr6))) { error_setg_errno(errp, errno, "inet_ntop failed"); goto error; } address_item->value->ip_address = g_strdup(addr6); address_item->value->ip_address_type = GUEST_IP_ADDRESS_TYPE_IPV6; if (ifa->ifa_netmask) { p = &((struct sockaddr_in6 *)ifa->ifa_netmask)->sin6_addr; address_item->value->prefix = ctpop32(((uint32_t *) p)[0]) + ctpop32(((uint32_t *) p)[1]) + ctpop32(((uint32_t *) p)[2]) + ctpop32(((uint32_t *) p)[3]); } } if (!address_item) { continue; } address_list = &info->value->ip_addresses; while (*address_list && (*address_list)->next) { address_list = &(*address_list)->next; } if (!*address_list) { *address_list = address_item; } else { (*address_list)->next = address_item; } info->value->has_ip_addresses = true; } freeifaddrs(ifap); return head; error: freeifaddrs(ifap); qapi_free_GuestNetworkInterfaceList(head); return NULL; }
1threat
AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame, int perms) { AVFilterBufferRef *samplesref = avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms, frame->nb_samples, frame->format, av_frame_get_channel_layout(frame)); if (!samplesref) return NULL; if (avfilter_copy_frame_props(samplesref, frame) < 0) { samplesref->buf->data[0] = NULL; avfilter_unref_bufferp(&samplesref); } return samplesref; }
1threat
when i trying new a SQLiteOpenHelper in my another class, i can't add parameter 'this' : [enter image description here][1] [private WeatherDBHelper weatherDBHelper = new WeatherDBHelper(this); it works in MainAcitvity.class, but doesn't work in QueryUtils.class][2] [1]: https://i.stack.imgur.com/T9W8K.png [2]: https://i.stack.imgur.com/lcn0p.png
0debug
Display raw styled XML code in PRE tag : <p>I have a very simple XML code. I want to show it in a div but properly styled. I tried <code>run_prettify.js</code> &amp; use pre tag, but it is not showing raw xml, but parsing it.</p> <p>Please help.</p> <p>JSBIn link is <a href="https://jsbin.com/dibikonuke/edit?html,output" rel="nofollow noreferrer">jsbin</a></p> <pre><code>&lt;note&gt; &lt;to&gt;Tove&lt;/to&gt; &lt;from&gt;Jani&lt;/from&gt; &lt;heading&gt;Reminder&lt;/heading&gt; &lt;body&gt;Don't forget me this weekend!&lt;/body&gt; &lt;/note&gt; </code></pre>
0debug
static void mptsas_scsi_uninit(PCIDevice *dev) { MPTSASState *s = MPT_SAS(dev); qemu_bh_delete(s->request_bh); if (s->msi_in_use) { msi_uninit(dev); } }
1threat
static void fdt_add_timer_nodes(const VirtBoardInfo *vbi) { uint32_t irqflags = GIC_FDT_IRQ_FLAGS_EDGE_LO_HI; irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, GIC_FDT_IRQ_PPI_CPU_WIDTH, (1 << vbi->smp_cpus) - 1); qemu_fdt_add_subnode(vbi->fdt, "/timer"); qemu_fdt_setprop_string(vbi->fdt, "/timer", "compatible", "arm,armv7-timer"); qemu_fdt_setprop_cells(vbi->fdt, "/timer", "interrupts", GIC_FDT_IRQ_TYPE_PPI, 13, irqflags, GIC_FDT_IRQ_TYPE_PPI, 14, irqflags, GIC_FDT_IRQ_TYPE_PPI, 11, irqflags, GIC_FDT_IRQ_TYPE_PPI, 10, irqflags); }
1threat
static void sigp_cpu_start(void *arg) { CPUState *cs = arg; S390CPU *cpu = S390_CPU(cs); s390_cpu_set_state(CPU_STATE_OPERATING, cpu); DPRINTF("DONE: KVM cpu start: %p\n", &cpu->env); }
1threat
static int http_send_data(HTTPContext *c) { int len, ret; while (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c); if (ret < 0) return -1; else if (ret == 0) { break; } else { return 0; } } if (c->buffer_end > c->buffer_ptr) { len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { return -1; } } else { c->buffer_ptr += len; c->data_count += len; } } return 0; }
1threat
static void qpci_spapr_io_writel(QPCIBus *bus, void *addr, uint32_t value) { QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); uint64_t port = (uintptr_t)addr; value = bswap32(value); if (port < s->pio.size) { writel(s->pio_cpu_base + port, value); } else { writel(s->mmio_cpu_base + port, value); } }
1threat
static void bit_prop_set(DeviceState *dev, Property *props, bool val) { uint32_t *p = qdev_get_prop_ptr(dev, props); uint32_t mask = qdev_get_prop_mask(props); if (val) *p |= ~mask; else *p &= ~mask; }
1threat
get blog page url in WordPress : <p>The blog page on my WordPress website is set to be a different page other than the home page. I want to get the link to this blog page from any other pages.</p> <p>How can I get blog page url?</p>
0debug
View Holder cannot be Null is the error message. Please help me to fix this : I am trying to build and weather app and on Menu List Adapter class i am getting the error message saying " View Holder() in View Holder cannot be null". Could you please help me to get this issue fixed? This is the android code i am tying to build the application using android studio import android.annotation.SuppressLint; import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.FrameLayout; import android.widget.TextView; import java.util.ArrayList; import com.weather.queensland.weather.pojo.MenuListPojo; public class MenuListAdapter extends ArrayAdapter<MenuListPojo> { Activity activity; private ArrayList<MenuListPojo> dataSet; private int lastPosition = -1; @SuppressLint("ResourceType") public MenuListAdapter(ArrayList<MenuListPojo> paramArrayList, Activity paramActivity) { super(paramActivity, 2131296289, paramArrayList); this.dataSet = paramArrayList; this.activity = paramActivity; } @SuppressLint("ResourceType") public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { MenuListPojo localMenuListPojo = (MenuListPojo)getItem(paramInt); ViewHolder localViewHolder; if (paramView == null) { localViewHolder = new ViewHolder(null); paramView = LayoutInflater.from(getContext()).inflate(2131296289, paramViewGroup, false); localViewHolder.nav_new_title = ((TextView)paramView.findViewById(2131165332)); localViewHolder.nav_new = ((FrameLayout)paramView.findViewById(2131165321)); paramView.setTag(localViewHolder); } for (paramViewGroup = localViewHolder;; paramViewGroup = (ViewHolder)paramView.getTag()) { this.lastPosition = paramInt; paramViewGroup.nav_new_title.setText(localMenuListPojo.getTitle()); paramViewGroup.nav_new.setOnClickListener(new View.OnClickListener() { public void onClick(View paramAnonymousView) { int i = ((Integer)paramAnonymousView.getTag()).intValue(); paramAnonymousView = (MenuListPojo)MenuListAdapter.this.getItem(i); ((ForecastWeatherActivity)MenuListAdapter.this.activity).callOnMenuItemSelection(paramAnonymousView.getLink()); } }); paramViewGroup.nav_new.setTag(Integer.valueOf(paramInt)); return paramView; } } private static class ViewHolder { FrameLayout nav_new; TextView nav_new_title; } }
0debug
static void avc_wgt_8width_msa(uint8_t *data, int32_t stride, int32_t height, int32_t log2_denom, int32_t src_weight, int32_t offset_in) { uint8_t cnt; v16u8 zero = { 0 }; v16u8 src0, src1, src2, src3; v8u16 src0_r, src1_r, src2_r, src3_r; v8u16 temp0, temp1, temp2, temp3; v8u16 wgt, denom, offset; offset_in <<= (log2_denom); if (log2_denom) { offset_in += (1 << (log2_denom - 1)); } wgt = (v8u16) __msa_fill_h(src_weight); offset = (v8u16) __msa_fill_h(offset_in); denom = (v8u16) __msa_fill_h(log2_denom); for (cnt = height / 4; cnt--;) { LOAD_4VECS_UB(data, stride, src0, src1, src2, src3); ILVR_B_4VECS_UH(src0, src1, src2, src3, zero, zero, zero, zero, src0_r, src1_r, src2_r, src3_r); temp0 = wgt * src0_r; temp1 = wgt * src1_r; temp2 = wgt * src2_r; temp3 = wgt * src3_r; ADDS_S_H_4VECS_UH(temp0, offset, temp1, offset, temp2, offset, temp3, offset, temp0, temp1, temp2, temp3); MAXI_S_H_4VECS_UH(temp0, temp1, temp2, temp3, 0); SRL_H_4VECS_UH(temp0, temp1, temp2, temp3, temp0, temp1, temp2, temp3, denom); SAT_U_H_4VECS_UH(temp0, temp1, temp2, temp3, 7); PCKEV_B_STORE_8_BYTES_4(temp0, temp1, temp2, temp3, data, stride); data += (4 * stride); } }
1threat
static void virtio_queue_guest_notifier_read(EventNotifier *n) { VirtQueue *vq = container_of(n, VirtQueue, guest_notifier); if (event_notifier_test_and_clear(n)) { virtio_irq(vq); } }
1threat
void block_job_user_resume(BlockJob *job) { if (job && job->user_paused && job->pause_count > 0) { job->user_paused = false; block_job_iostatus_reset(job); block_job_resume(job); } }
1threat
Get the Data from one sheet to aother Sheet by applying multiple conditions : I am very new to this VBA Coding. Someone can help me with this please. I have some data in Sheet1 and I would like to copy the data to Sheet2.But I wanna see data like A2,B2,C2,D2,E2,F2,G2,H2,I2,J2 in 2nd row and if "K2" = "Yes" then A2,B2,C2,D2,E2 in 3rd row followed by L2,M2,N2,O2,P2 and if "Q2" = "Yes" Then A2,B2,C2,D2,E2 in 4th row followed by R2,S2,T2,U2,V2 and in the same way if "W2"="Yes" then print next 5 columns and 1st 5 columns in next row. Here is the Sample [enter image description here][1] Thanks In advance. Output expected as [enter image description here][2] [1]: https://i.stack.imgur.com/biQcy.png [2]: https://i.stack.imgur.com/v3Rbq.png
0debug
void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra) { int qscale; int shift = 0; for (qscale = qmin; qscale <= qmax; qscale++) { int i; if (dsp->fdct == ff_jpeg_fdct_islow_8 || dsp->fdct == ff_jpeg_fdct_islow_10 || dsp->fdct == ff_faandct) { for (i = 0; i < 64; i++) { const int j = dsp->idct_permutation[i]; qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); } } else if (dsp->fdct == ff_fdct_ifast) { for (i = 0; i < 64; i++) { const int j = dsp->idct_permutation[i]; qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) / (ff_aanscales[i] * qscale * quant_matrix[j])); } } else { for (i = 0; i < 64; i++) { const int j = dsp->idct_permutation[i]; qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]); if (qmat16[qscale][0][i] == 0 || qmat16[qscale][0][i] == 128 * 256) qmat16[qscale][0][i] = 128 * 256 - 1; qmat16[qscale][1][i] = ROUNDED_DIV(bias << (16 - QUANT_BIAS_SHIFT), qmat16[qscale][0][i]); } } for (i = intra; i < 64; i++) { int64_t max = 8191; if (dsp->fdct == ff_fdct_ifast) { max = (8191LL * ff_aanscales[i]) >> 14; } while (((max * qmat[qscale][i]) >> shift) > INT_MAX) { shift++; } } } if (shift) { av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger than %d, overflows possible\n", QMAT_SHIFT - shift); } }
1threat
static void test_after_failed_device_add(void) { QDict *response; QDict *error; qtest_start("-drive if=none,id=drive0"); response = qmp("{'execute': 'device_add'," " 'arguments': {" " 'driver': 'virtio-blk-pci'," " 'drive': 'drive0'" "}}"); g_assert(response); error = qdict_get_qdict(response, "error"); g_assert_cmpstr(qdict_get_try_str(error, "class"), ==, "GenericError"); QDECREF(response); drive_del(); drive_add(); qtest_end(); }
1threat
Android Studio Show backgrounds tasks in the status bar instead of a floating window : <pre><code>Android Studio 2.0 Beta 5 </code></pre> <p>Every time I build and deploy I get this floating background task appear.</p> <p><a href="https://i.stack.imgur.com/Rt3E8.png"><img src="https://i.stack.imgur.com/Rt3E8.png" alt="enter image description here"></a></p> <p>Normally I click the minimize button to get it to display in the status bar. However, can we change the default behaviour to always show in the status bar.</p> <p>I couldn't find anything in the settings so not sure if Android Studio designed this way.</p> <p>I just find this thing annoying.</p> <p>Many thanks for any suggestions,</p>
0debug
static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters) { static const enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE }; char sws_flags_str[128]; char buffersrc_args[256]; int ret; AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc(); AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format; AVCodecContext *codec = is->video_st->codec; snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); graph->scale_sws_opts = av_strdup(sws_flags_str); snprintf(buffersrc_args, sizeof(buffersrc_args), "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d", codec->width, codec->height, codec->pix_fmt, is->video_st->time_base.num, is->video_st->time_base.den, codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den); if ((ret = avfilter_graph_create_filter(&filt_src, avfilter_get_by_name("buffer"), "ffplay_buffer", buffersrc_args, NULL, graph)) < 0) return ret; buffersink_params->pixel_fmts = pix_fmts; ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "ffplay_buffersink", NULL, buffersink_params, graph); av_freep(&buffersink_params); if (ret < 0) return ret; if ((ret = avfilter_graph_create_filter(&filt_format, avfilter_get_by_name("format"), "format", "yuv420p", NULL, graph)) < 0) return ret; if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0) return ret; if (vfilters) { AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); outputs->name = av_strdup("in"); outputs->filter_ctx = filt_src; outputs->pad_idx = 0; outputs->next = NULL; inputs->name = av_strdup("out"); inputs->filter_ctx = filt_format; inputs->pad_idx = 0; inputs->next = NULL; if ((ret = avfilter_graph_parse(graph, vfilters, &inputs, &outputs, NULL)) < 0) return ret; } else { if ((ret = avfilter_link(filt_src, 0, filt_format, 0)) < 0) return ret; } if ((ret = avfilter_graph_config(graph, NULL)) < 0) return ret; is->in_video_filter = filt_src; is->out_video_filter = filt_out; if (codec->codec->capabilities & CODEC_CAP_DR1) { is->use_dr1 = 1; codec->get_buffer = codec_get_buffer; codec->release_buffer = codec_release_buffer; codec->opaque = &is->buffer_pool; } return ret; }
1threat
how to reverse the URL of a ViewSet's custom action in django restframework : <p>I have defined a custom action for a ViewSet</p> <pre><code>from rest_framework import viewsets class UserViewSet(viewsets.ModelViewSet): @action(methods=['get'], detail=False, permission_classes=[permissions.AllowAny]) def gender(self, request): .... </code></pre> <p>And the viewset is registered to url in the conventional way</p> <pre><code>from django.conf.urls import url, include from rest_framework import routers from api import views router = routers.DefaultRouter() router.register(r'users', views.UserViewSet, base_name='myuser') urlpatterns = [ url(r'^', include(router.urls)), ] </code></pre> <p>The URL <code>/api/users/gender/</code> works. But I don't know how to get it using <code>reverse</code> in unit test. (I can surely hard code this URL, but it'll be nice to get it from code) </p> <p>According to the <a href="https://docs.djangoproject.com/en/1.11/ref/urlresolvers/#reverse" rel="noreferrer">django documentation</a>, the following code should work</p> <pre><code>reverse('admin:app_list', kwargs={'app_label': 'auth'}) # '/admin/auth/' </code></pre> <p>But I tried the following and they don't work</p> <pre><code>reverse('myuser-list', kwargs={'app_label':'gender'}) # errors out reverse('myuser-list', args=('gender',)) # '/api/users.gender' </code></pre> <p>In the <a href="http://www.django-rest-framework.org/api-guide/viewsets/#reversing-action-urls" rel="noreferrer">django-restframework documentation</a>, there is a function called <code>reverse_action</code>. However, my attempts didn't work</p> <pre><code>from api.views import UserViewSet a = UserViewSet() a.reverse_action('gender') # error out from django.http import HttpRequest req = HttpRequest() req.method = 'GET' a.reverse_action('gender', request=req) # still error out </code></pre> <p>What is the proper way to reverse the URL of that action?</p>
0debug
static int eth_can_receive(void *opaque) { return 1; }
1threat
My SharedPreferences is null . This is the error SharedPreferences.edit() is a null object references : <p>I'm using Model View Presenter in my application, and i try to save a value token in SharedPreferences. But, I got the SharedPreferences null, the error is SharedPreferences.edit() is a null object references. Please, help me to solve this. Thank you</p> <p>This is my Fragment</p> <pre><code>public class SignUpFragment extends BaseFragment { @NotEmpty(messageResId = R.string.rules_no_empty) @Bind(R.id.Name) EditText etName; @NotEmpty(messageResId = R.string.rules_no_empty) @Bind(R.id.email) EditText etEmail; @NotEmpty(messageResId = R.string.rules_no_empty) @Bind(R.id.phone) EditText etPhone; @Bind(R.id.btnSignUp) Button btnSignUp; public static final String TAG = SignUpFragment.class.getSimpleName(); private SignUpPresenter presenter; SharedPreferences sharedpreferences; public static final String MyPREFERENCES = "MyPrefs" ; public static void showFragment(BaseActivity sourceActivity) { if (!sourceActivity.isFragmentNotNull(TAG)) { FragmentTransaction fragmentTransaction = sourceActivity.getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_question, new SignUpFragment(), TAG); fragmentTransaction.commit(); } } @Override protected int getLayout() { return R.layout.activity_sign_up; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); presenter = new SignUpPresenter(this); sharedpreferences = getActivity().getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE); } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); initview(); } @Override public void onResume() { super.onResume(); } private void initview (){ btnSignUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!validate()) { onSignupFailed(); return; } else { presenter.signup(); } } }); } @Override public void onValidationSucceeded() { super.onValidationSucceeded(); presenter.signup(); } public void onSignupFailed() { Toast.makeText(getContext(), "Login failed", Toast.LENGTH_LONG).show(); btnSignUp.setEnabled(true); } public boolean validate() { boolean valid = true; String name = etName.getText().toString(); String email = etEmail.getText().toString(); String password = etPhone.getText().toString(); if (name.isEmpty() || name.length() &lt; 3) { etName.setError("at least 3 characters"); valid = false; } else { etName.setError(null); } if (email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) { etEmail.setError("enter a valid email address"); valid = false; } if (password.isEmpty() || password.length() &lt; 4 || password.length() &gt; 10) { etPhone.setError("between 4 and 10 alphanumeric characters"); valid = false; } else { etPhone.setError(null); } return valid; } public void gotoQuestionActivity(String email, String name, String phone) { QuestionActivity.startActivity((BaseActivity) getActivity(), email, name, phone); getActivity().finish(); } } </code></pre> <p>and this my Presenter</p> <pre><code>public class SignUpPresenter { private SignUpFragment fragment; public String token = "token"; SharedPreferences sharedpreferences; private Context mContext; public static final String MyPREFERENCES = "MyPrefs" ; public SignUpPresenter(SignUpFragment fragment) { this.fragment = fragment; } public SignUpRequest constructSignUpRequest() { SignUpRequest request = new SignUpRequest(); request.setName(getAndTrimValueFromEditText(fragment.etName)); request.setEmail(getAndTrimValueFromEditText(fragment.etEmail)); request.setMobile(getAndTrimValueFromEditText(fragment.etPhone)); return request; } private String getAndTrimValueFromEditText(EditText e) { return e.getText().toString().trim(); } public SharedPreferences getSharedPreferences() { return sharedpreferences; } void signup (){ this.register(constructSignUpRequest()); } void register(final SignUpRequest signUpRequest) { fragment.showProgressDialog(fragment.loading); fragment.getApi().regsiterCustomer(constructSignUpRequest()) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Observer&lt;GenericResponse&gt;() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { fragment.dismissProgressDialog(); Timber.e(e.getLocalizedMessage()); Toast.makeText(fragment.getContext(), fragment.connectionError, Toast.LENGTH_SHORT).show(); } @Override public void onNext(GenericResponse signUpResponse) { fragment.dismissProgressDialog(); Toast.makeText(fragment.getContext(), signUpResponse.getInfo(), Toast.LENGTH_SHORT).show(); if (signUpResponse.getCode() == fragment.successCode) { /*fragment.gotoActivationCodeActivity(SignUpRequest.getEmail(), SignUpRequest.get());*/ fragment.gotoQuestionActivity(signUpRequest.getEmail(), signUpRequest.getName(), signUpRequest.getMobile()); SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(token, signUpResponse.getData().getToken()); editor.commit(); } } }); } } </code></pre>
0debug
What is the equivalent of django.db.models.loading.get_model() in Django 1.9? : <p>I want to use <code>get_model()</code> to avoid cyclic imports in my models, but I get <code>name 'get_model' is not defined</code> error. I read that <code>get_model()</code> was depreciated in 1.8 and apparently is not present in 1.9. What is the equivalent call? Or is there another way to avoid cyclic imports in two <code>models.py</code> files?</p>
0debug
How to fix ctrl+c inside a docker container : <p>If I connect to a docker container</p> <pre><code>$&gt; docker exec -it my_container zsh </code></pre> <p>and inside it I want to kill something I started with <code>ctrl+c</code> I noticed that it takes forever to complete. I've googled around and it seems that <code>ctrl+c</code> works a bit different than you would expect. My question, how can I fix <code>ctrl+c</code> inside a container ?</p>
0debug
static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFContext *mxf = arg; int item_num = avio_rb32(pb); int item_len = avio_rb32(pb); if (item_len != 18) { av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n"); return -1; } if (item_num > UINT_MAX / item_len) return -1; mxf->local_tags_count = item_num; mxf->local_tags = av_malloc(item_num*item_len); if (!mxf->local_tags) return -1; avio_read(pb, mxf->local_tags, item_num*item_len); return 0; }
1threat
Why are block level elements in this page displaying inline? : <p>I have met my wit's end. If anyone can tell me why the block level elements (h3 and p tags) are displaying inline in this page, you will be my hero: <a href="http://www.emc2017.emcss.org/committee-members" rel="nofollow">http://www.emc2017.emcss.org/committee-members</a></p>
0debug
import function from a file in the same folder : <p>I'm building a Flask app with Python 3.5 following a tutorial, based on different import rules. By looking for similar questions, I managed to solve an ImportError based on importing from a nested folder by adding the folder to the path, but I keep failing at importing a function from a script in the same folder (already in the path). The folder structure is this:</p> <pre><code>DoubleDibz β”œβ”€β”€ app β”‚ β”œβ”€β”€ __init__.py β”‚ β”œβ”€β”€ api β”‚ β”‚ β”œβ”€β”€ __init__.py β”‚ β”‚ └── helloworld.py β”‚ β”œβ”€β”€ app.py β”‚ β”œβ”€β”€ common β”‚ β”‚ β”œβ”€β”€ __init__.py β”‚ β”‚ └── constants.py β”‚ β”œβ”€β”€ config.py β”‚ β”œβ”€β”€ extensions.py β”‚ β”œβ”€β”€ static β”‚ └── templates └── run.py </code></pre> <p>In app.py I import a function from config.py by using this code:</p> <pre><code>import config as Config </code></pre> <p>but I get this error: </p> <pre><code>ImportError: No module named 'config' </code></pre> <p>I don't understand what's the problem, being the two files in the same folder. Thanks in advance </p>
0debug
Blade inline if and else if statement : <p>Is there a syntax to specify inline if and else if statement in Laravel blade template?</p> <p>Normally, the syntaxt for if and else statement would be :</p> <pre><code>{{ $var === "hello" ? "Hi" : "Goodbye" }} </code></pre> <p>I would now like to include else if statement, is this possible?</p> <pre><code> {{ $var === "hello" ? "Hi" : "Goodbye" else if $var ==="howdie ? "how" : "Goodbye""}} </code></pre>
0debug
how to capture dayclick events on non empty days fullcalendar : i'm working on a project and i need to know if there is a way to capture dayClick events specificly in days with already set events, in such a way that i can add more events using a popup, thanks
0debug
Any way to test EventEmitter in Angular2? : <p>I have a component that uses an EventEmitter and the EventEmitter is used when someone on the page is clicked. Is there any way that I can observe the EventEmitter during a unit test, and use TestComponentBuilder to click the element that triggers the EventEmitter.next() method and see what was sent?</p>
0debug
I'm not able to upload more 1 mb file in android : Pleae Help me, I have created a program in android for upload file. Everything is working perfectly but when i upload more than 1 mb file i got error from my server "Error while Uploading" Please Help me. It's my UploadFile() Method private void uploadFile() { dialog = ProgressDialog.show(getActivity(), "", "Uploading File...", true); // Map is used to multipart the file using okhttp3.RequestBody Map<String, RequestBody> map = new HashMap<>(); long maxLength = 10000000; File file = new File(selectedFilePath); if(file.length() > maxLength){ Toast.makeText(getActivity(), "can't upload file if size more than 10mb", Toast.LENGTH_LONG).show(); dialog.dismiss(); }else { String name = tv_name.getText().toString(); String email = tv_email.getText().toString(); // Parsing any Media type file RequestBody requestBody = RequestBody.create(MediaType.parse("*/*"), file); RequestBody requestBody1 = RequestBody.create(MediaType.parse("text/plain"), name); RequestBody requestBody2 = RequestBody.create(MediaType.parse("text/plain"), email); map.put("file\"; filename=\"" + selectedFilePath + "\"", requestBody); map.put("name\"; username=\"" + name + "\"", requestBody1); map.put("email\"; email=\"" + email + "\"", requestBody2); ApiConfig getResponse = AppConfig.getRetrofit().create(ApiConfig.class); Call<ServerResponse> call = getResponse.upload("token", map); call.enqueue(new Callback<ServerResponse>() { @Override public void onResponse(Call<ServerResponse> call, Response<ServerResponse> response) { if(dialog.isShowing()){ dialog.dismiss(); } ServerResponse serverResponse = response.body(); if (serverResponse != null) { if (serverResponse.getSuccess()) { Toast.makeText(getActivity(), serverResponse.getMessage(), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), serverResponse.getMessage(), Toast.LENGTH_SHORT).show(); } } else { // Log.v("Response", serverResponse.toString()); } // dialog.dismiss(); goToProfile(); } @Override public void onFailure(Call<ServerResponse> call, Throwable t) { t.printStackTrace(); dialog.dismiss(); Toast.makeText(getActivity(), "Failed, Please Try Again", Toast.LENGTH_SHORT).show(); } }); } } It's My PHP Code $target_dir = "uploads/"; $target_file_name = $target_dir .basename($_FILES["file"]["name"]); $response = array(); // Check if image file is a actual image or fake image if (isset($_FILES["file"])) { if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file_name)) { $success = true; $message = "Successfully Uploaded"; } else { $success = false; $message = "Error while uploading"; } } else { $success = false; $message = "Required Field Missing"; } $response["success"] = $success; $response["message"] = $message; echo json_encode($response); ?>
0debug
greedy algorithm for rod cuting : this is problem from civil engineering someone looks for a good solution for it assume u have a dict of bars you need to cut where the keys are the name of the bar and the values are list of numbers and length required of this bar and the standard length of the bar is 12 m how to make the most economic solution with the minimum lost dict{b1:(3,5),b2:(3,4),b3:(5,2.5)} notice 1- some times it's more economic to cut 3 pieces of 4 meters which makes a whole bar and this's considerd as optimal solution 2-the target is not to make 0 loss but trying to decrees it as possible
0debug
How to what program each logged in user is executing in linux? : <p>What command line would give me a list of programs each logged in user is executing for a Linux server using bash?</p>
0debug
void avfilter_free(AVFilterContext *filter) { int i; AVFilterLink *link; if (filter->filter->uninit) filter->filter->uninit(filter); for (i = 0; i < filter->input_count; i++) { if ((link = filter->inputs[i])) { if (link->src) link->src->outputs[link->srcpad - link->src->output_pads] = NULL; avfilter_formats_unref(&link->in_formats); avfilter_formats_unref(&link->out_formats); } av_freep(&link); } for (i = 0; i < filter->output_count; i++) { if ((link = filter->outputs[i])) { if (link->dst) link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL; avfilter_formats_unref(&link->in_formats); avfilter_formats_unref(&link->out_formats); } av_freep(&link); } av_freep(&filter->name); av_freep(&filter->input_pads); av_freep(&filter->output_pads); av_freep(&filter->inputs); av_freep(&filter->outputs); av_freep(&filter->priv); av_free(filter); }
1threat