problem
stringlengths
26
131k
labels
class label
2 classes
making database with php : I'm trying to get my script needed information from user by php and make a database. so I thought I could **make** a database and make a table in it by this code: <?php //ini_set('display_errors', 'Off'); if(isset($_POST['siteName'])){ $DBS=htmlspecialchars($_POST['databaseServer']); $DBN=htmlspecialchars($_POST['databaseName']); $DBU=htmlspecialchars($_POST['databaseUser']); $DBP=htmlspecialchars($_POST['databasePass']); $SN=htmlspecialchars($_POST['siteName']); $AU=htmlspecialchars($_POST['adminUser']); $AP=htmlspecialchars($_POST['adminPass']); $con=new Mysqli($DBS,$DBU,$DBP,$DBN); if($con->connect_error) echo "Error : ".$con->connect_error; else{ $sql="CREAT DATABASE '$DBN'"; $sql.="CREATE TABLE options (sitename VARCHAR(30),adminUser VARCHAR(30),adminPass VARCHAR(30),reg_date TIMESTAMP);"; $sql.="CREATE TABLE users (ID int(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, userName VARCHAR(30),password VARCHAR(30),reg_date TIMESTAMP);"; $sql.="INSERT INTO '$DBN' (sitename,adminUser,adminPass) VALUES ($SN,$AU,$AP);"; if($con->multi_query($sql)===true) echo " Enjoy .. ! "; else echo "Error : ".$sql." : ".$con->error; } } ?> but when I type a sample name for database,get this error: Error : Unknown database 'name' and when creat a database manually and type the name of it in my form , get this error: Error : CREAT DATABASE 'ex'CREATE TABLE options (sitename VARCHAR(30),adminUser VARCHAR(30),adminPass VARCHAR(30),reg_date TIMESTAMP);CREATE TABLE users (ID int(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, userName VARCHAR(30),password VARCHAR(30),reg_date TIMESTAMP);INSERT INTO 'ex' (sitename,adminUser,adminPass) VALUES (My Phone Book,admin,102030); : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREAT DATABASE 'ex'CREATE TABLE options (sitename VARCHAR(30),adminUser VARCHAR(' at line 1 So,whats wrong?
0debug
static uint32_t cc_calc_abs_32(int32_t dst) { if ((uint32_t)dst == 0x80000000UL) { return 3; } else if (dst) { return 1; } else { return 0; } }
1threat
Request payload limit with AWS API Gateway : <p>What is the request-payload limit with AWS API-Gateway? </p> <p>I need to send a JSON payload with <code>base64</code> encoded files and some other parameters to API Gateway, that will then pass on the payload to AWS Lambda. </p> <p>I could not find AWS documentation regarding this. </p>
0debug
How do i watch python source code files and restart when i save? : <p>When I save a python source code file, I want to re-run the script. Is there a command that works like this (sort of like nodemon for node)?</p>
0debug
Enable CORS for /health endpoint in Spring Boot Actuator : <p>We want to enable Cors for all GET requests to the <code>/health</code> endpoint provided by spring boot actuator.</p> <p>We tried adding the following bean without success</p> <pre><code>@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/health").allowedMethods("GET"); } }; } </code></pre>
0debug
reverse string sentence c : i tried to find somthing mach to my needs but i dident. somone could help me fix my code to sucsses reverse a sentence (from: "my name is" to "is name my" for example). please without function and pointers. #include <stdio.h> #include <string.h> void main() { int i = 0, j = 0, end, count=0, sumletters=0; char str[1000], strrev[1000]; fgets(str, sizeof(str), stdin);//get string from user sumletters = strchr(str, '\0') - str - 1;//find the last characters in string while (sumletters) { end = sumletters= strchr(str, '\0') - str - 1; while (str[sumletters] != ' '){ //find the number letters of the last word and enter to counter sumletters--; } for (i = 0; sumletters!=end; i++, sumletters++) {//enter every leters from the last word to new string strrev[i] = str[sumletters + 1]; str[sumletters + 1] = '\0';//dros the leters that already copy } } puts(str); puts(strrev); }
0debug
copy date from one excel workbook to another excel workbook with pushing macro button : >hi all >I want to copy date from one excel workbook to another excel workbook(master work book) with pushing macro button. >pls assist.
0debug
static void read_table(AVFormatContext *avctx, AVStream *st, int (*parse)(AVFormatContext *avctx, AVStream *st, const char *name, int size)) { int count, i; AVIOContext *pb = avctx->pb; avio_skip(pb, 4); count = avio_rb32(pb); avio_skip(pb, 4); for (i = 0; i < count; i++) { char name[17]; int size; avio_read(pb, name, 16); name[sizeof(name) - 1] = 0; size = avio_rb32(pb); if (parse(avctx, st, name, size) < 0) { avpriv_request_sample(avctx, "Variable %s", name); avio_skip(pb, size); } } }
1threat
static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; int part1_size, hscale, vscale, i, j, ret; int width = s->avctx->width; int height = s->avctx->height; s->profile = (buf[0]>>1) & 7; if (s->profile > 1) { avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile); s->keyframe = !(buf[0] & 1); s->invisible = 0; part1_size = AV_RL24(buf) >> 4; buf += 4 - s->profile; buf_size -= 4 - s->profile; memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab)); ff_vp56_init_range_decoder(c, buf, part1_size); buf += part1_size; buf_size -= part1_size; if (s->keyframe) { width = vp8_rac_get_uint(c, 12); height = vp8_rac_get_uint(c, 12); hscale = vp8_rac_get_uint(c, 2); vscale = vp8_rac_get_uint(c, 2); if (hscale || vscale) avpriv_request_sample(s->avctx, "Upscaling"); s->update_golden = s->update_altref = VP56_FRAME_CURRENT; vp78_reset_probability_tables(s); memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); memcpy(s->prob->pred8x8c , vp8_pred8x8c_prob_inter , sizeof(s->prob->pred8x8c)); for (i = 0; i < 2; i++) memcpy(s->prob->mvc[i], vp7_mv_default_prob[i], sizeof(vp7_mv_default_prob[i])); memset(&s->segmentation, 0, sizeof(s->segmentation)); memset(&s->lf_delta, 0, sizeof(s->lf_delta)); memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan)); if (s->keyframe || s->profile > 0) memset(s->inter_dc_pred, 0 , sizeof(s->inter_dc_pred)); for (i = 0; i < 4; i++) { s->feature_enabled[i] = vp8_rac_get(c); if (s->feature_enabled[i]) { s->feature_present_prob[i] = vp8_rac_get_uint(c, 8); for (j = 0; j < 3; j++) s->feature_index_prob[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255; if (vp7_feature_value_size[i]) for (j = 0; j < 4; j++) s->feature_value[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[s->profile][i]) : 0; s->segmentation.enabled = 0; s->segmentation.update_map = 0; s->lf_delta.enabled = 0; s->num_coeff_partitions = 1; ff_vp56_init_range_decoder(&s->coeff_partition[0], buf, buf_size); if (!s->macroblocks_base || width != s->avctx->width || height != s->avctx->height || (width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height) { if ((ret = update_dimensions(s, width, height)) < 0) return ret; vp7_get_quants(s); if (!s->keyframe) { s->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE; s->sign_bias[VP56_FRAME_GOLDEN] = 0; s->update_last = 1; s->update_probabilities = 1; s->fade_present = 1; if (s->profile > 0) { s->update_probabilities = vp8_rac_get(c); if (!s->update_probabilities) s->prob[1] = s->prob[0]; if (!s->keyframe) s->fade_present = vp8_rac_get(c); if (s->fade_present && vp8_rac_get(c)) { int alpha = (int8_t)vp8_rac_get_uint(c, 8); int beta = (int8_t)vp8_rac_get_uint(c, 8); if (!s->keyframe && (alpha || beta)) { if (s->framep[VP56_FRAME_GOLDEN] == s->framep[VP56_FRAME_PREVIOUS]) { AVFrame *gold = s->framep[VP56_FRAME_GOLDEN]->tf.f; AVFrame *prev; int i, j; s->framep[VP56_FRAME_PREVIOUS] = vp8_find_free_buffer(s); if ((ret = vp8_alloc_frame(s, s->framep[VP56_FRAME_PREVIOUS], 1)) < 0) return ret; prev = s->framep[VP56_FRAME_PREVIOUS]->tf.f; fade(prev->data[0], prev->linesize[0], gold->data[0], gold->linesize[0], s->mb_width * 16, s->mb_height * 16, alpha, beta); for (j = 1; j < 3; j++) for (i = 0; i < s->mb_height * 8; i++) memcpy(prev->data[j] + i * prev->linesize[j], gold->data[j] + i * gold->linesize[j], s->mb_width * 8); } else { AVFrame *prev = s->framep[VP56_FRAME_PREVIOUS]->tf.f; fade(prev->data[0], prev->linesize[0], prev->data[0], prev->linesize[0], s->mb_width * 16, s->mb_height * 16, alpha, beta); if (!s->profile) s->filter.simple = vp8_rac_get(c); if (vp8_rac_get(c)) for (i = 1; i < 16; i++) s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)]; if (s->profile > 0) s->filter.simple = vp8_rac_get(c); s->filter.level = vp8_rac_get_uint(c, 6); s->filter.sharpness = vp8_rac_get_uint(c, 3); vp78_update_probability_tables(s); s->mbskip_enabled = 0; if (!s->keyframe) { s->prob->intra = vp8_rac_get_uint(c, 8); s->prob->last = vp8_rac_get_uint(c, 8); vp78_update_pred16x16_pred8x8_mvc_probabilities(s); return 0;
1threat
Angular2 Router error: cannot find primary outlet to load 'HomePage' : <p>I just started using the new routing library (@angular/router v3.0.0-alpha.7) but following the official <a href="https://angular.io/docs/ts/latest/guide/router.html">docs</a> leads to error below:</p> <pre><code>browser_adapter.ts:74: EXCEPTION: Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'HomePage' </code></pre> <p><strong>Question is - how do I get rid of the error and make the router behave as expected? Have I missed a setting?</strong></p> <p>(Same error appears when using the alpha.6 version.)</p> <p><em>app.component.ts</em></p> <pre><code>import { Component } from '@angular/core'; import { ROUTER_DIRECTIVES } from '@angular/router'; @Component({ selector: 'app', template: ` &lt;p&gt;Angular 2 is running...&lt;/p&gt; &lt;!-- Routed views go here --&gt; &lt;router-outlet&gt;&lt;/router-outlet&gt; `, providers: [ROUTER_DIRECTIVES] }) export class AppComponent { } </code></pre> <p><em>app.routes.ts</em></p> <pre><code>import { provideRouter, RouterConfig } from '@angular/router'; import { HomePage } from './pages/home/home'; export const routes: RouterConfig = [ { path: '', component: HomePage } ]; export const APP_ROUTER_PROVIDERS = [ provideRouter(routes) ]; </code></pre> <p><em>home.ts</em></p> <pre><code>import { Component } from '@angular/core'; @Component({ template: '&lt;h1&gt;Home Page&lt;/h1&gt;' }) export class HomePage { } </code></pre> <p><em>main.ts</em></p> <pre><code>/* Avoid: 'error TS2304: Cannot find name &lt;type&gt;' during compilation */ ///&lt;reference path="../../typings/index.d.ts" /&gt; import { bootstrap } from "@angular/platform-browser-dynamic"; import { APP_ROUTER_PROVIDERS } from './app.routes'; import { AppComponent } from "./app.component"; bootstrap(AppComponent, [ APP_ROUTER_PROVIDERS, ]).catch(err =&gt; console.error(err)); </code></pre>
0debug
static void tcg_temp_free_internal(int idx) { TCGContext *s = &tcg_ctx; TCGTemp *ts; int k; #if defined(CONFIG_DEBUG_TCG) s->temps_in_use--; if (s->temps_in_use < 0) { fprintf(stderr, "More temporaries freed than allocated!\n"); } #endif assert(idx >= s->nb_globals && idx < s->nb_temps); ts = &s->temps[idx]; assert(ts->temp_allocated != 0); ts->temp_allocated = 0; k = ts->base_type + (ts->temp_local ? TCG_TYPE_COUNT : 0); set_bit(idx, s->free_temps[k].l); }
1threat
vnc_display_setup_auth(VncDisplay *vs, bool password, bool sasl, bool tls, bool x509) { if (password) { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { VNC_DEBUG("Initializing VNC server with password auth\n"); vs->auth = VNC_AUTH_VNC; vs->subauth = VNC_AUTH_INVALID; } } else if (sasl) { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } } else { VNC_DEBUG("Initializing VNC server with SASL auth\n"); vs->auth = VNC_AUTH_SASL; vs->subauth = VNC_AUTH_INVALID; } } else { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } } }
1threat
Why does i get this magige : i get this error when i try to do mysqli_num_rows() Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\php\search.php on line 13 There are no results matching your search $search = mysqli_real_escape_string($conn, $_POST['search']); $sql = "SELECT * FROM posts WHERE a_title LIKE '%$search%' OR a_text LIKE '%$search%' OR a_author LIKE '%$search%' OR a_date LIKE '%$search%"; $result = mysqli_query($conn, $sql); $queryResult = mysqli_num_rows($result);
0debug
static inline void downmix_2f_2r_to_stereo(float *samples) { int i; for (i = 0; i < 256; i++) { samples[i] += samples[i + 512]; samples[i + 256] = samples[i + 768]; samples[i + 512] = samples[i + 768] = 0; } }
1threat
Is there a way to tell GCC not to reorder any instructions, not just load/stores? : <p>I'm working on the irq_lock() / irq_unlock() implementation for an RTOS and found an issue. We want to absolutely minimize how much time the CPU spends with interrupts locked. Right now, our irq_lock() inline function for x86 uses "memory" clobber:</p> <pre><code>static ALWAYS_INLINE unsigned int _do_irq_lock(void) { unsigned int key; __asm__ volatile ( "pushfl;\n\t" "cli;\n\t" "popl %0;\n\t" : "=g" (key) : : "memory" ); return key; } </code></pre> <p>The problem is that the compiler will still reorder potentially expensive operations into the critical section if they just touch registers and not memory. A specific example is here in our kernel's sleep function:</p> <pre><code>void k_sleep(int32_t duration) { __ASSERT(!_is_in_isr(), ""); __ASSERT(duration != K_FOREVER, ""); K_DEBUG("thread %p for %d ns\n", _current, duration); /* wait of 0 ns is treated as a 'yield' */ if (duration == 0) { k_yield(); return; } int32_t ticks = _TICK_ALIGN + _ms_to_ticks(duration); int key = irq_lock(); _remove_thread_from_ready_q(_current); _add_thread_timeout(_current, NULL, ticks); _Swap(key); } </code></pre> <p>The 'ticks' calculation, which does expensive math, gets reordered inside where we lock interrupts, so we are calling __divdi3 with interrupts locked which is <em>not</em> what we want:</p> <pre><code>Dump of assembler code for function k_sleep: 0x0010197a &lt;+0&gt;: push %ebp 0x0010197b &lt;+1&gt;: mov %esp,%ebp 0x0010197d &lt;+3&gt;: push %edi 0x0010197e &lt;+4&gt;: push %esi 0x0010197f &lt;+5&gt;: push %ebx 0x00101980 &lt;+6&gt;: mov 0x8(%ebp),%edi 0x00101983 &lt;+9&gt;: test %edi,%edi 0x00101985 &lt;+11&gt;: jne 0x101993 &lt;k_sleep+25&gt; 0x00101987 &lt;+13&gt;: lea -0xc(%ebp),%esp 0x0010198a &lt;+16&gt;: pop %ebx 0x0010198b &lt;+17&gt;: pop %esi 0x0010198c &lt;+18&gt;: pop %edi 0x0010198d &lt;+19&gt;: pop %ebp 0x0010198e &lt;+20&gt;: jmp 0x101944 &lt;k_yield&gt; 0x00101993 &lt;+25&gt;: pushf 0x00101994 &lt;+26&gt;: cli 0x00101995 &lt;+27&gt;: pop %esi 0x00101996 &lt;+28&gt;: pushl 0x104608 0x0010199c &lt;+34&gt;: call 0x101726 &lt;_remove_thread_from_ready_q&gt; 0x001019a1 &lt;+39&gt;: mov $0x64,%eax 0x001019a6 &lt;+44&gt;: imul %edi 0x001019a8 &lt;+46&gt;: mov 0x104608,%ebx 0x001019ae &lt;+52&gt;: add $0x3e7,%eax 0x001019b3 &lt;+57&gt;: adc $0x0,%edx 0x001019b6 &lt;+60&gt;: mov %ebx,0x20(%ebx) 0x001019b9 &lt;+63&gt;: movl $0x0,(%esp) 0x001019c0 &lt;+70&gt;: push $0x3e8 0x001019c5 &lt;+75&gt;: push %edx 0x001019c6 &lt;+76&gt;: push %eax 0x001019c7 &lt;+77&gt;: call 0x1000a0 &lt;__divdi3&gt; 0x001019cc &lt;+82&gt;: add $0x10,%esp 0x001019cf &lt;+85&gt;: inc %eax 0x001019d0 &lt;+86&gt;: mov %eax,0x28(%ebx) 0x001019d3 &lt;+89&gt;: movl $0x0,0x24(%ebx) 0x001019da &lt;+96&gt;: lea 0x18(%ebx),%edx 0x001019dd &lt;+99&gt;: mov $0x10460c,%eax 0x001019e2 &lt;+104&gt;: add $0x28,%ebx 0x001019e5 &lt;+107&gt;: mov $0x10162b,%ecx 0x001019ea &lt;+112&gt;: push %ebx 0x001019eb &lt;+113&gt;: call 0x101667 &lt;sys_dlist_insert_at&gt; 0x001019f0 &lt;+118&gt;: mov %esi,0x8(%ebp) 0x001019f3 &lt;+121&gt;: pop %eax 0x001019f4 &lt;+122&gt;: lea -0xc(%ebp),%esp 0x001019f7 &lt;+125&gt;: pop %ebx 0x001019f8 &lt;+126&gt;: pop %esi 0x001019f9 &lt;+127&gt;: pop %edi 0x001019fa &lt;+128&gt;: pop %ebp 0x001019fb &lt;+129&gt;: jmp 0x100f77 &lt;_Swap&gt; End of assembler dump. </code></pre> <p>We discovered that we can get the ordering we want by declaring 'ticks' volatile:</p> <pre><code>Dump of assembler code for function k_sleep: 0x0010197a &lt;+0&gt;: push %ebp 0x0010197b &lt;+1&gt;: mov %esp,%ebp 0x0010197d &lt;+3&gt;: push %ebx 0x0010197e &lt;+4&gt;: push %edx 0x0010197f &lt;+5&gt;: mov 0x8(%ebp),%edx 0x00101982 &lt;+8&gt;: test %edx,%edx 0x00101984 &lt;+10&gt;: jne 0x10198d &lt;k_sleep+19&gt; 0x00101986 &lt;+12&gt;: call 0x101944 &lt;k_yield&gt; 0x0010198b &lt;+17&gt;: jmp 0x1019f5 &lt;k_sleep+123&gt; 0x0010198d &lt;+19&gt;: mov $0x64,%eax 0x00101992 &lt;+24&gt;: push $0x0 0x00101994 &lt;+26&gt;: imul %edx 0x00101996 &lt;+28&gt;: add $0x3e7,%eax 0x0010199b &lt;+33&gt;: push $0x3e8 0x001019a0 &lt;+38&gt;: adc $0x0,%edx 0x001019a3 &lt;+41&gt;: push %edx 0x001019a4 &lt;+42&gt;: push %eax 0x001019a5 &lt;+43&gt;: call 0x1000a0 &lt;__divdi3&gt; 0x001019aa &lt;+48&gt;: add $0x10,%esp 0x001019ad &lt;+51&gt;: inc %eax 0x001019ae &lt;+52&gt;: mov %eax,-0x8(%ebp) 0x001019b1 &lt;+55&gt;: pushf 0x001019b2 &lt;+56&gt;: cli 0x001019b3 &lt;+57&gt;: pop %ebx 0x001019b4 &lt;+58&gt;: pushl 0x1045e8 0x001019ba &lt;+64&gt;: call 0x101726 &lt;_remove_thread_from_ready_q&gt; 0x001019bf &lt;+69&gt;: mov 0x1045e8,%eax 0x001019c4 &lt;+74&gt;: mov -0x8(%ebp),%edx 0x001019c7 &lt;+77&gt;: movl $0x0,0x24(%eax) 0x001019ce &lt;+84&gt;: mov %edx,0x28(%eax) 0x001019d1 &lt;+87&gt;: mov %eax,0x20(%eax) 0x001019d4 &lt;+90&gt;: lea 0x18(%eax),%edx 0x001019d7 &lt;+93&gt;: add $0x28,%eax 0x001019da &lt;+96&gt;: mov %eax,(%esp) 0x001019dd &lt;+99&gt;: mov $0x10162b,%ecx 0x001019e2 &lt;+104&gt;: mov $0x1045ec,%eax 0x001019e7 &lt;+109&gt;: call 0x101667 &lt;sys_dlist_insert_at&gt; 0x001019ec &lt;+114&gt;: mov %ebx,(%esp) 0x001019ef &lt;+117&gt;: call 0x100f77 &lt;_Swap&gt; 0x001019f4 &lt;+122&gt;: pop %eax 0x001019f5 &lt;+123&gt;: mov -0x4(%ebp),%ebx 0x001019f8 &lt;+126&gt;: leave 0x001019f9 &lt;+127&gt;: ret End of assembler dump. </code></pre> <p>However this just fixes it in one spot. We really need a way to modify the irq_lock() implementation such that it does the right thing everywhere, and right now the "memory" clobber is not sufficient.</p>
0debug
DB design for microservice architecture : <p>I am planning to use the Microservices architecture for the implementation of our website. I wanted to know if it is right to share databases between services or if it is preferable to have a separate database for each service. In this regard, can I consider having one common database for all services or does it violate the very essence of Microservice architecture ?</p>
0debug
How to get the data from JSON URL by JAVA SCRIPT? : Can someone show me how the syntax work to get the data from the JSON of URL by JAVASCRIPT? An example: JSON in the url ({"test":60,"homework":15,"quiz":0,"class_participation":10,"final_exam":15,"success":true}). The number represents the weight of the categories, after I get the data out from the URL I want it to automatically fill out all the input box with respectively values. Thank you!
0debug
WRONGTYPE Operation against a key holding the wrong kind of value php : <p>Hi I am using Laravel with Redis .When I am trying to access a key by get method then get following error "WRONGTYPE Operation against a key holding the wrong kind of value"</p> <p>I am using following code to access the key value -</p> <p>i use this code for get data from redis </p> <pre><code>$values = "l_messages"; $value = $redis-&gt;HGETALL($values); print($value); </code></pre>
0debug
context or workdir for docker-compose : <p>I'm learning docker</p> <p>I need to specify the working directory for a docker image, I think that'll be something like this:</p> <pre><code>version: '2' services: test: build: context: ./dir </code></pre> <p>Now I want to make the image <code>python:onbuild</code> to run on the <code>./dir</code>, but I dont want to create any <code>Dockerfile</code> inside the <code>./dir</code>.</p> <p>The <code>docker-compose</code> manual says nothing about that.</p> <p>Is it possible? How to do that?</p>
0debug
CSS: Why left border is taking extra space? : <p>Here is my website: <a href="http://www.reshapefinancial.com/" rel="nofollow noreferrer">http://www.reshapefinancial.com/</a> and when I apply left border it creates a space on right site. When you inspect and remove the left border <code>border-left: 1px solid white</code> you'll see that the space on the right disappears.</p> <p><a href="https://i.stack.imgur.com/PBx43.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PBx43.jpg" alt="enter image description here"></a></p>
0debug
static inline int is_yuv_planar(PixFmtInfo *ps) { return (ps->color_type == FF_COLOR_YUV || ps->color_type == FF_COLOR_YUV_JPEG) && !ps->is_packed; }
1threat
how to make input tag dynamic : I am designing a chat application just like web whatsapp. I have a class named as chat-body where the messages are displayed and i have another class named as chattext where the user can enter the message whatever he or she wants to send. Now, what my question is how to make it dynamic i.e if user enters some text in the chattext input tag and hits enter then the entered text should be displayed in the chat-body class. Any suggestions..?[this is the screenshot of my chat application which i am designing][1] [1]: https://i.stack.imgur.com/wXbP7.png
0debug
How do I keep a menubar at the top of the page? : <p>I'm trying to make my menu bar stay at the top of the page like on <a href="https://forbes.com" rel="nofollow noreferrer">https://forbes.com</a> for my bootcamp project &amp; team landing page.</p> <p>I'm not sure what to do: <a href="https://github.com/JonDevOps/W3Develops-new-landing-page" rel="nofollow noreferrer">https://github.com/JonDevOps/W3Develops-new-landing-page</a> </p> <p>I want it to stay at the top of the page , even when i scroll way down.</p>
0debug
uint64_t helper_mulldo(CPUPPCState *env, uint64_t arg1, uint64_t arg2) { int64_t th; uint64_t tl; muls64(&tl, (uint64_t *)&th, arg1, arg2); if (likely((uint64_t)(th + 1) <= 1)) { env->ov = 0; } else { env->so = env->ov = 1; } return (int64_t)tl; }
1threat
Get levels for the Reply system in php+sql : <pre><code> id user_id comment_id body parent level 94 4 28 first reply NULL NULL 95 4 28 second reply NULL NULL 96 4 28 reply to the first reply 94 1 97 4 28 reply to the second reply 95 1 98 4 28 third reply NULL NULL 99 4 35 Reply to the third comment NULL NULL 100 4 29 reply to the second comment NULL NULL </code></pre> <p>Name : replies</p> <p>Hey all, i am now working on a comment and reply system which contains infinity reply recursions and for that i need to get the levels of the reply . Above is my table and the values in the level column are wrong. i couldn't get the query to get the levels. So far my logic is this. the reply to a comment will be the parent reply which will be NULL in parent column and rest of the reply for that reply will be of the reply ID as the parent and it is working . i need the help to get the levels which are greater than one that is, get the value 2 for the reply to the reply to the reply of a comment </p>
0debug
static int idcin_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; IdcinDemuxContext *idcin = s->priv_data; AVStream *st; unsigned int width, height; unsigned int sample_rate, bytes_per_sample, channels; int ret; width = avio_rl32(pb); height = avio_rl32(pb); sample_rate = avio_rl32(pb); bytes_per_sample = avio_rl32(pb); channels = avio_rl32(pb); if (s->pb->eof_reached) { av_log(s, AV_LOG_ERROR, "incomplete header\n"); return s->pb->error ? s->pb->error : AVERROR_EOF; } if (av_image_check_size(width, height, 0, s) < 0) return AVERROR_INVALIDDATA; if (sample_rate > 0) { if (sample_rate < 14 || sample_rate > INT_MAX) { av_log(s, AV_LOG_ERROR, "invalid sample rate: %u\n", sample_rate); return AVERROR_INVALIDDATA; } if (bytes_per_sample < 1 || bytes_per_sample > 2) { av_log(s, AV_LOG_ERROR, "invalid bytes per sample: %u\n", bytes_per_sample); return AVERROR_INVALIDDATA; } if (channels < 1 || channels > 2) { av_log(s, AV_LOG_ERROR, "invalid channels: %u\n", channels); return AVERROR_INVALIDDATA; } idcin->audio_present = 1; } else { idcin->audio_present = 0; } st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 33, 1, IDCIN_FPS); st->start_time = 0; idcin->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_IDCIN; st->codec->codec_tag = 0; st->codec->width = width; st->codec->height = height; st->codec->extradata_size = HUFFMAN_TABLE_SIZE; st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE); ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE); if (ret < 0) { return ret; } else if (ret != HUFFMAN_TABLE_SIZE) { av_log(s, AV_LOG_ERROR, "incomplete header\n"); return AVERROR(EIO); } if (idcin->audio_present) { idcin->audio_present = 1; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 63, 1, sample_rate); st->start_time = 0; idcin->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_tag = 1; st->codec->channels = channels; st->codec->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; st->codec->sample_rate = sample_rate; st->codec->bits_per_coded_sample = bytes_per_sample * 8; st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels; st->codec->block_align = idcin->block_align = bytes_per_sample * channels; if (bytes_per_sample == 1) st->codec->codec_id = AV_CODEC_ID_PCM_U8; else st->codec->codec_id = AV_CODEC_ID_PCM_S16LE; if (sample_rate % 14 != 0) { idcin->audio_chunk_size1 = (sample_rate / 14) * bytes_per_sample * channels; idcin->audio_chunk_size2 = (sample_rate / 14 + 1) * bytes_per_sample * channels; } else { idcin->audio_chunk_size1 = idcin->audio_chunk_size2 = (sample_rate / 14) * bytes_per_sample * channels; } idcin->current_audio_chunk = 0; } idcin->next_chunk_is_video = 1; idcin->first_pkt_pos = avio_tell(s->pb); return 0; }
1threat
How solve error expected ; : <p>Given an integer,n , perform the following conditional actions:</p> <p>If n, is odd, print Weird If n, is even and in the inclusive range of 2 to 5, print Not Weird If n, is even and in the inclusive range of 6 to 20, print Weird If n is even and greater than 20, print Not Weird</p> <p>My Code is</p> <pre><code>import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String ans=""; if(n%2==1) { ans = "Weird"; } elseif(n%2==0 &amp;&amp; 2&lt;=n&lt;=5){ ans = "Not Weird"; } elseif(n%2==0 &amp;&amp; 6&lt;=n&lt;=20) { ans = "Weird"; } elseif(n&gt;=20) { ans = "Weird";`` } System.out.println(ans); } } </code></pre> <p>And there are error : Solution.java:18: error: ';' expected elseif(n%2==0 &amp;&amp; 2&lt;=n&lt;=5){ ^ Solution.java:22: error: ';' expected elseif(n%2==0 &amp;&amp; 6&lt;=n&lt;=20) { ^ Solution.java:26: error: ';' expected elseif(n>=20) ^ 3 errors I don't know how to solve those problem.</p>
0debug
SKLabelNode - how to center align when more than one line? : <p>With <code>SKLabelNode</code>, it would appear that when you break to more than one line,</p> <p>the results is always </p> <pre><code>abcde fg </code></pre> <p>rather than</p> <pre><code>abcde fg </code></pre> <p>Really it seems that SKLabelNode is just left-aligned, and that's it.</p> <p>Is there a solution - how to make multiline SKLabelNode center-align?</p> <hr> <p><strong><em>Note</em></strong> - horizontalAlignmentMode is totally unrelated. it simply allows you to choose whether the anchor of the overall label area is on the left, right or center of the position.</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Angular 2 - Checking for server errors from subscribe : <p>I feel like this scenario should be in the Angular 2 docs, but I can't find it anywhere. </p> <p>Here's the scenario</p> <ol> <li>submit a form (create object) that is invalid on the server</li> <li>server returns a 400 bad request with errors I display on the form</li> <li>after the subscribe comes back, I want to check an error variable or something (ie. if no errors > then route to newly created detail page)</li> </ol> <p>I imagine it working something like this:</p> <pre><code>this.projectService.create(project) .subscribe( result =&gt; console.log(result), error =&gt; { this.errors = error } ); } if (!this.errors) { //route to new page } </code></pre> <p>I'm very new to Angular 2 so this may come from my lack of understanding in how an Observable works. I have no issue with displaying that data on the form, but can't figure out how to see it within the ts component. I really just want to check the success/fail of the http create.</p>
0debug
Can,t insert data in database : I am try to insert data in database but not work. I want to insert color code in database which selected. Example, If i select cookware, then insert in database #A8CF45 this color code or If i select dinner, then insert in database #EDCA86 this color code. Please help me how can i insert data. Here is my frontend code: <select class="col-sm-9" id="cate" name="cate"> <option value="cookware">Cookware</option> <option value="dinner">Dinner Set</option> <option value="tiffin">Tiffin</option> <option value="storage">Storage</option> </select> Here is my backend code: <?php $cate=$_POST["cate"]; if('cookware' == $cate){ $bg_color= '#A8CF45'; } elseif('dinner' == $cate){ $bg_color= '#EDCA86'; } elseif('tiffin' == $cate){ $bg_color= '#FBB12F'; } elseif('storage' == $cate){ $bg_color= '#F26F35'; } else{ $result=mysqli_query($conn, "INSERT INTO table( bg_color) VALUES ('$bg_color')")or die("Could not retrieve image: " .mysqli_error($conn)); echo 1; } ?>
0debug
How to access a member of a pointer to object : <p>I need some clarification about this issue. I have a class called con. </p> <pre><code>class con { public: con(); int readIndex; } </code></pre> <p>in con.cpp:</p> <pre><code>con::con() { readIndex = 0; } </code></pre> <p>in main:</p> <pre><code>con = new con(); </code></pre> <p>now readIndex is not 0 as I wanted. Watch window shows that the value is <code>0xcdcdcdcd {???}</code> and the type is now <code>int*</code> and not <code>int</code> which means that a variable will become a pointer if it's class object is created using <code>new</code>? I then tried to change the code to <code>*readIndex = 0;</code> but I got a write access violation. So how should I set the value of readIndex to 0 after all? `</p>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
numpy random choice in Tensorflow : <p>Is there an equivalent function to numpy random choice in Tensorflow. In numpy we can get an item randomly from the given list with its weights. </p> <pre><code> np.random.choice([1,2,3,5], 1, p=[0.1, 0, 0.3, 0.6, 0]) </code></pre> <p>This code will select an item from the given list with p weights. </p>
0debug
static av_cold int cuvid_decode_init(AVCodecContext *avctx) { CuvidContext *ctx = avctx->priv_data; AVCUDADeviceContext *device_hwctx; AVHWDeviceContext *device_ctx; AVHWFramesContext *hwframe_ctx; CUVIDSOURCEDATAPACKET seq_pkt; CUcontext cuda_ctx = NULL; CUcontext dummy; const AVBitStreamFilter *bsf; int ret = 0; enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12, AV_PIX_FMT_NONE }; int probed_width = avctx->coded_width ? avctx->coded_width : 1280; int probed_height = avctx->coded_height ? avctx->coded_height : 720; ret = ff_get_format(avctx, pix_fmts); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "ff_get_format failed: %d\n", ret); return ret; } avctx->pix_fmt = ret; if (ctx->resize_expr && sscanf(ctx->resize_expr, "%dx%d", &ctx->resize.width, &ctx->resize.height) != 2) { av_log(avctx, AV_LOG_ERROR, "Invalid resize expressions\n"); ret = AVERROR(EINVAL); goto error; } if (ctx->crop_expr && sscanf(ctx->crop_expr, "%dx%dx%dx%d", &ctx->crop.top, &ctx->crop.bottom, &ctx->crop.left, &ctx->crop.right) != 4) { av_log(avctx, AV_LOG_ERROR, "Invalid cropping expressions\n"); ret = AVERROR(EINVAL); goto error; } ret = cuvid_load_functions(&ctx->cvdl); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Failed loading nvcuvid.\n"); goto error; } ctx->frame_queue = av_fifo_alloc(ctx->nb_surfaces * sizeof(CuvidParsedFrame)); if (!ctx->frame_queue) { ret = AVERROR(ENOMEM); goto error; } if (avctx->hw_frames_ctx) { ctx->hwframe = av_buffer_ref(avctx->hw_frames_ctx); if (!ctx->hwframe) { ret = AVERROR(ENOMEM); goto error; } hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; ctx->hwdevice = av_buffer_ref(hwframe_ctx->device_ref); if (!ctx->hwdevice) { ret = AVERROR(ENOMEM); goto error; } } else { if (avctx->hw_device_ctx) { ctx->hwdevice = av_buffer_ref(avctx->hw_device_ctx); if (!ctx->hwdevice) { ret = AVERROR(ENOMEM); goto error; } } else { ret = av_hwdevice_ctx_create(&ctx->hwdevice, AV_HWDEVICE_TYPE_CUDA, ctx->cu_gpu, NULL, 0); if (ret < 0) goto error; } ctx->hwframe = av_hwframe_ctx_alloc(ctx->hwdevice); if (!ctx->hwframe) { av_log(avctx, AV_LOG_ERROR, "av_hwframe_ctx_alloc failed\n"); ret = AVERROR(ENOMEM); goto error; } hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; } device_ctx = hwframe_ctx->device_ctx; device_hwctx = device_ctx->hwctx; cuda_ctx = device_hwctx->cuda_ctx; ctx->cudl = device_hwctx->internal->cuda_dl; memset(&ctx->cuparseinfo, 0, sizeof(ctx->cuparseinfo)); memset(&ctx->cuparse_ext, 0, sizeof(ctx->cuparse_ext)); memset(&seq_pkt, 0, sizeof(seq_pkt)); ctx->cuparseinfo.pExtVideoInfo = &ctx->cuparse_ext; switch (avctx->codec->id) { #if CONFIG_H264_CUVID_DECODER case AV_CODEC_ID_H264: ctx->cuparseinfo.CodecType = cudaVideoCodec_H264; break; #endif #if CONFIG_HEVC_CUVID_DECODER case AV_CODEC_ID_HEVC: ctx->cuparseinfo.CodecType = cudaVideoCodec_HEVC; break; #endif #if CONFIG_MJPEG_CUVID_DECODER case AV_CODEC_ID_MJPEG: ctx->cuparseinfo.CodecType = cudaVideoCodec_JPEG; break; #endif #if CONFIG_MPEG1_CUVID_DECODER case AV_CODEC_ID_MPEG1VIDEO: ctx->cuparseinfo.CodecType = cudaVideoCodec_MPEG1; break; #endif #if CONFIG_MPEG2_CUVID_DECODER case AV_CODEC_ID_MPEG2VIDEO: ctx->cuparseinfo.CodecType = cudaVideoCodec_MPEG2; break; #endif #if CONFIG_MPEG4_CUVID_DECODER case AV_CODEC_ID_MPEG4: ctx->cuparseinfo.CodecType = cudaVideoCodec_MPEG4; break; #endif #if CONFIG_VP8_CUVID_DECODER case AV_CODEC_ID_VP8: ctx->cuparseinfo.CodecType = cudaVideoCodec_VP8; break; #endif #if CONFIG_VP9_CUVID_DECODER case AV_CODEC_ID_VP9: ctx->cuparseinfo.CodecType = cudaVideoCodec_VP9; break; #endif #if CONFIG_VC1_CUVID_DECODER case AV_CODEC_ID_VC1: ctx->cuparseinfo.CodecType = cudaVideoCodec_VC1; break; #endif default: av_log(avctx, AV_LOG_ERROR, "Invalid CUVID codec!\n"); return AVERROR_BUG; } if (avctx->codec->id == AV_CODEC_ID_H264 || avctx->codec->id == AV_CODEC_ID_HEVC) { if (avctx->codec->id == AV_CODEC_ID_H264) bsf = av_bsf_get_by_name("h264_mp4toannexb"); else bsf = av_bsf_get_by_name("hevc_mp4toannexb"); if (!bsf) { ret = AVERROR_BSF_NOT_FOUND; goto error; } if (ret = av_bsf_alloc(bsf, &ctx->bsf)) { goto error; } if (((ret = avcodec_parameters_from_context(ctx->bsf->par_in, avctx)) < 0) || ((ret = av_bsf_init(ctx->bsf)) < 0)) { av_bsf_free(&ctx->bsf); goto error; } ctx->cuparse_ext.format.seqhdr_data_length = ctx->bsf->par_out->extradata_size; memcpy(ctx->cuparse_ext.raw_seqhdr_data, ctx->bsf->par_out->extradata, FFMIN(sizeof(ctx->cuparse_ext.raw_seqhdr_data), ctx->bsf->par_out->extradata_size)); } else if (avctx->extradata_size > 0) { ctx->cuparse_ext.format.seqhdr_data_length = avctx->extradata_size; memcpy(ctx->cuparse_ext.raw_seqhdr_data, avctx->extradata, FFMIN(sizeof(ctx->cuparse_ext.raw_seqhdr_data), avctx->extradata_size)); } ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces; ctx->cuparseinfo.ulMaxDisplayDelay = 4; ctx->cuparseinfo.pUserData = avctx; ctx->cuparseinfo.pfnSequenceCallback = cuvid_handle_video_sequence; ctx->cuparseinfo.pfnDecodePicture = cuvid_handle_picture_decode; ctx->cuparseinfo.pfnDisplayPicture = cuvid_handle_picture_display; ret = CHECK_CU(ctx->cudl->cuCtxPushCurrent(cuda_ctx)); if (ret < 0) goto error; ret = cuvid_test_dummy_decoder(avctx, &ctx->cuparseinfo, probed_width, probed_height); if (ret < 0) goto error; ret = CHECK_CU(ctx->cvdl->cuvidCreateVideoParser(&ctx->cuparser, &ctx->cuparseinfo)); if (ret < 0) goto error; seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data; seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length; if (seq_pkt.payload && seq_pkt.payload_size) { ret = CHECK_CU(ctx->cvdl->cuvidParseVideoData(ctx->cuparser, &seq_pkt)); if (ret < 0) goto error; } ret = CHECK_CU(ctx->cudl->cuCtxPopCurrent(&dummy)); if (ret < 0) goto error; ctx->prev_pts = INT64_MIN; if (!avctx->pkt_timebase.num || !avctx->pkt_timebase.den) av_log(avctx, AV_LOG_WARNING, "Invalid pkt_timebase, passing timestamps as-is.\n"); return 0; error: cuvid_decode_end(avctx); return ret; }
1threat
static void test_visitor_out_any(TestOutputVisitorData *data, const void *unused) { QObject *qobj; QInt *qint; QBool *qbool; QString *qstring; QDict *qdict; QObject *obj; qobj = QOBJECT(qint_from_int(-42)); visit_type_any(data->ov, NULL, &qobj, &error_abort); obj = visitor_get(data); g_assert(qobject_type(obj) == QTYPE_QINT); g_assert_cmpint(qint_get_int(qobject_to_qint(obj)), ==, -42); qobject_decref(qobj); visitor_reset(data); qdict = qdict_new(); qdict_put(qdict, "integer", qint_from_int(-42)); qdict_put(qdict, "boolean", qbool_from_bool(true)); qdict_put(qdict, "string", qstring_from_str("foo")); qobj = QOBJECT(qdict); visit_type_any(data->ov, NULL, &qobj, &error_abort); qobject_decref(qobj); qdict = qobject_to_qdict(visitor_get(data)); g_assert(qdict); qobj = qdict_get(qdict, "integer"); g_assert(qobj); qint = qobject_to_qint(qobj); g_assert(qint); g_assert_cmpint(qint_get_int(qint), ==, -42); qobj = qdict_get(qdict, "boolean"); g_assert(qobj); qbool = qobject_to_qbool(qobj); g_assert(qbool); g_assert(qbool_get_bool(qbool) == true); qstring = qobject_to_qstring(qdict_get(qdict, "string")); g_assert(qstring); g_assert_cmpstr(qstring_get_str(qstring), ==, "foo"); }
1threat
Using html themes in reacjs : First of all I want to express that i am quite new with reactjs and this question might be not very appropriate to the topic but i am just trying to enrich my knowledge about it. I have a html/css theme and I am trying to build a application using that theme but with reactjs. Is there any way to use that theme in react? I have used several ui libraries to create some application with react but from scratch. What would be the solution when I already have a html/css theme to use in my project with react? Thank you.
0debug
How do I pass integers in Android Studio? : I'm relatively new to Android Studio and wanted to practice using it. How do I pass integers in the app? I wanted to build a little combat game where I have a set skill point of 20 and wanted to pass these points to certain attributes. I don't think I can do it through a TextView since hard coding is a no no. So essentially my main question is, do I use it through EditText? If so, how? Below is a picture of what I'm trying to achieve. Thanks a lot for your time. https://i.stack.imgur.com/i7PNh.png
0debug
static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) { CPUArchState *env = cpu->env_ptr; unsigned long mmu_idx_bitmask = data.host_int; int mmu_idx; assert_cpu_is_self(cpu); tb_lock(); tlb_debug("start: mmu_idx:0x%04lx\n", mmu_idx_bitmask); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { if (test_bit(mmu_idx, &mmu_idx_bitmask)) { tlb_debug("%d\n", mmu_idx); memset(env->tlb_table[mmu_idx], -1, sizeof(env->tlb_table[0])); memset(env->tlb_v_table[mmu_idx], -1, sizeof(env->tlb_v_table[0])); } } memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache)); tlb_debug("done\n"); tb_unlock(); }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Importing a JSON object into MongoDB - java : while ((line = br.readLine()) != null) { Document document = Document.parse(String.format("{\"a\": %s}", line)); for(Document doc : document) { docs.add(new InsertOneModel<Document>(doc)); } I am getting the error in the for loop (for Document doc : document) as "can only iterate over an array or an instance of java.lang.Iterable. Can anyone please help
0debug
I want to count number of several cases that are either civil or criminal and sum of those cases in thier respective month : SUMMARY OF FILED SPECIAL CASES S/NO. MONTH CIVIL CRIMINAL TOTAL 1 JANUARY 2 FEBRUARY 3 MARCH 4 APRIL 5 MAY 6 JUNE 7 JULY 8 AUGUST 9 SEPTEMBER 10 OCTOBER 11 NOVEMBER 12 DECEMBER GRAND TOTAL
0debug
If statement issue enter : <p>I have this JS var, followed by this if statement : </p> <pre><code>if ($('custom_t4')) var contratType = $('custom_t4').value === 'Nouvelle_affaire' ? 'Nouvelle Affaire' : $('custom_t4').value === 'Avenant' ? 'Avenant' : ''; if (contratType &amp;&amp; (contratType !== 'Nouvelle Affaire' || contratType !== 'Avenant')){ } </code></pre> <p>The problem I have, is that when contratType is defined and his value is 'Nouvelle Affaire', is still enter that if. </p> <p>Did I miss something ?</p>
0debug
static void vc1_mc_4mv_chroma(VC1Context *v, int dir) { MpegEncContext *s = &v->s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcU, *srcV; int uvmx, uvmy, uvsrc_x, uvsrc_y; int k, tx = 0, ty = 0; int mvx[4], mvy[4], intra[4], mv_f[4]; int valid_count; int chroma_ref_type = v->cur_field_type, off = 0; int v_edge_pos = s->v_edge_pos >> v->field_mode; if (!v->field_mode && !v->s.last_picture.f.data[0]) return; if (s->flags & CODEC_FLAG_GRAY) return; for (k = 0; k < 4; k++) { mvx[k] = s->mv[dir][k][0]; mvy[k] = s->mv[dir][k][1]; intra[k] = v->mb_type[0][s->block_index[k]]; if (v->field_mode) mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off]; } if (!v->field_mode || (v->field_mode && !v->numref)) { valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty); chroma_ref_type = v->reffield; if (!valid_count) { s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0; s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0; v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; return; } } else { int dominant = 0; if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2) dominant = 1; valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty); if (dominant) chroma_ref_type = !v->cur_field_type; } if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0]) return; s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; uvmx = (tx + ((tx & 3) == 3)) >> 1; uvmy = (ty + ((ty & 3) == 3)) >> 1; v->luma_mv[s->mb_x][0] = uvmx; v->luma_mv[s->mb_x][1] = uvmy; if (v->fastuvmc) { uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1)); uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1)); } if (v->cur_field_type != chroma_ref_type) uvmy += 2 - 4 * chroma_ref_type; uvsrc_x = s->mb_x * 8 + (uvmx >> 2); uvsrc_y = s->mb_y * 8 + (uvmy >> 2); if (v->profile != PROFILE_ADVANCED) { uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); } else { uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); } if (!dir) { if (v->field_mode) { if ((v->cur_field_type != chroma_ref_type) && v->cur_field_type) { srcU = s->current_picture.f.data[1]; srcV = s->current_picture.f.data[2]; } else { srcU = s->last_picture.f.data[1]; srcV = s->last_picture.f.data[2]; } } else { srcU = s->last_picture.f.data[1]; srcV = s->last_picture.f.data[2]; } } else { srcU = s->next_picture.f.data[1]; srcV = s->next_picture.f.data[2]; } if(!srcU) return; srcU += uvsrc_y * s->uvlinesize + uvsrc_x; srcV += uvsrc_y * s->uvlinesize + uvsrc_x; if (v->field_mode) { if (chroma_ref_type) { srcU += s->current_picture_ptr->f.linesize[1]; srcV += s->current_picture_ptr->f.linesize[2]; } off = v->second_field ? s->current_picture_ptr->f.linesize[1] : 0; } if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) || s->h_edge_pos < 18 || v_edge_pos < 18 || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 || (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) { s->vdsp.emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8 + 1, 8 + 1, uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, 8 + 1, 8 + 1, uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); srcU = s->edge_emu_buffer; srcV = s->edge_emu_buffer + 16; if (v->rangeredfrm) { int i, j; uint8_t *src, *src2; src = srcU; src2 = srcV; for (j = 0; j < 9; j++) { for (i = 0; i < 9; i++) { src[i] = ((src[i] - 128) >> 1) + 128; src2[i] = ((src2[i] - 128) >> 1) + 128; } src += s->uvlinesize; src2 += s->uvlinesize; } } if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; uint8_t *src, *src2; src = srcU; src2 = srcV; for (j = 0; j < 9; j++) { for (i = 0; i < 9; i++) { src[i] = v->lutuv[src[i]]; src2[i] = v->lutuv[src2[i]]; } src += s->uvlinesize; src2 += s->uvlinesize; } } } uvmx = (uvmx & 3) << 1; uvmy = (uvmy & 3) << 1; if (!v->rnd) { h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy); h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy); } else { v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy); v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy); } }
1threat
Can I create an alias of a type in Golang? : <p>I'm struggling with my learning of Go.</p> <p>I found this neat implementation of a Set in go: <a href="https://github.com/fatih/set" rel="noreferrer">gopkg.in/fatih/set.v0</a>, but I'd prefer naming my sets with a more explicit name that <code>set.Set</code>, doing something like:</p> <pre><code>type View set.Set </code></pre> <p>In essence, I want my <code>View</code> type to inherit <code>set.Set</code>'s methods. Because, well, <code>View</code> <strong>is a</strong> <code>set.Set</code> of descriptors. But I know Go is pretty peaky on inheritance, and typing in general.</p> <p>For now I've been trying the following <em>kinda</em> inheritance, but it's causing loads of errors when trying to use some functions like <code>func Union(set1, set2 Interface, sets ...Interface) Interface</code> or <code>func (s *Set) Merge(t Interface)</code>:</p> <pre><code>type View struct { set.Set } </code></pre> <p>I'd like to know if there's a way to achieve what I want in a Go-like way, or if I'm just trying to apply my good-ol' OO practices to a language that discards them, please.</p>
0debug
Is it possible to show a console in a Jupyter notebook? : <p>I would like to be able to fiddle around in the environment using a console in a Jupyter notebook. Adding an additional cell means that I always have to scroll to the very bottom or create new cells wherever I want a 'console-like' text field. Is it possible to have a permanent console window, e.g. at the bottom of the window?</p> <p>Thanks!</p>
0debug
int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx){ int dst_index, i; int index= c->index; int frac= c->frac; int dst_incr_frac= c->dst_incr % c->src_incr; int dst_incr= c->dst_incr / c->src_incr; int compensation_distance= c->compensation_distance; if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ int64_t index2= ((int64_t)index)<<32; int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr; dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr); for(dst_index=0; dst_index < dst_size; dst_index++){ dst[dst_index] = src[index2>>32]; index2 += incr; } frac += dst_index * dst_incr_frac; index += dst_index * dst_incr; index += frac / c->src_incr; frac %= c->src_incr; }else{ for(dst_index=0; dst_index < dst_size; dst_index++){ FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); int sample_index= index >> c->phase_shift; FELEM2 val=0; if(sample_index < 0){ for(i=0; i<c->filter_length; i++) val += src[FFABS(sample_index + i) % src_size] * filter[i]; }else if(sample_index + c->filter_length > src_size){ break; }else if(c->linear){ FELEM2 v2=0; for(i=0; i<c->filter_length; i++){ val += src[sample_index + i] * (FELEM2)filter[i]; v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length]; } val+=(v2-val)*(FELEML)frac / c->src_incr; }else{ for(i=0; i<c->filter_length; i++){ val += src[sample_index + i] * (FELEM2)filter[i]; } } #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE dst[dst_index] = av_clip_int16(lrintf(val)); #else val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; #endif frac += dst_incr_frac; index += dst_incr; if(frac >= c->src_incr){ frac -= c->src_incr; index++; } if(dst_index + 1 == compensation_distance){ compensation_distance= 0; dst_incr_frac= c->ideal_dst_incr % c->src_incr; dst_incr= c->ideal_dst_incr / c->src_incr; } } } *consumed= FFMAX(index, 0) >> c->phase_shift; if(index>=0) index &= c->phase_mask; if(compensation_distance){ compensation_distance -= dst_index; assert(compensation_distance > 0); } if(update_ctx){ c->frac= frac; c->index= index; c->dst_incr= dst_incr_frac + c->src_incr*dst_incr; c->compensation_distance= compensation_distance; } #if 0 if(update_ctx && !c->compensation_distance){ #undef rand av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2); av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance); } #endif return dst_index; }
1threat
static int pxa2xx_pic_load(QEMUFile *f, void *opaque, int version_id) { PXA2xxPICState *s = (PXA2xxPICState *) opaque; int i; for (i = 0; i < 2; i ++) qemu_get_be32s(f, &s->int_enabled[i]); for (i = 0; i < 2; i ++) qemu_get_be32s(f, &s->int_pending[i]); for (i = 0; i < 2; i ++) qemu_get_be32s(f, &s->is_fiq[i]); qemu_get_be32s(f, &s->int_idle); for (i = 0; i < PXA2XX_PIC_SRCS; i ++) qemu_get_be32s(f, &s->priority[i]); pxa2xx_pic_update(opaque); return 0; }
1threat
static int smc_decode_init(AVCodecContext *avctx) { SmcContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; dsputil_init(&s->dsp, avctx); s->frame.data[0] = NULL; return 0; }
1threat
static void cris_alu(DisasContext *dc, int op, TCGv d, TCGv op_a, TCGv op_b, int size) { TCGv tmp; int writeback; writeback = 1; if (op == CC_OP_BOUND || op == CC_OP_BTST) tmp = tcg_temp_local_new(TCG_TYPE_TL); if (op == CC_OP_CMP) { tmp = tcg_temp_new(TCG_TYPE_TL); writeback = 0; } else if (size == 4) { tmp = d; writeback = 0; } else tmp = tcg_temp_new(TCG_TYPE_TL); cris_pre_alu_update_cc(dc, op, op_a, op_b, size); cris_alu_op_exec(dc, op, tmp, op_a, op_b, size); cris_update_result(dc, tmp); if (writeback) { if (size == 1) tcg_gen_andi_tl(d, d, ~0xff); else tcg_gen_andi_tl(d, d, ~0xffff); tcg_gen_or_tl(d, d, tmp); } if (GET_TCGV(tmp) != GET_TCGV(d)) tcg_temp_free(tmp); }
1threat
What is the underscore "_" in JavaScript? : <p>I'm doing a redux tutorial, and I saw a call like this:</p> <pre><code>this._render(); </code></pre> <p>and it's defined elsewhere as:</p> <pre><code>_render() { .... } </code></pre> <p>What is the underscore "_"? Why is it used?</p>
0debug
Stacked bar chart in R : <p>I have a data set that looks like this</p> <p><a href="https://i.stack.imgur.com/R7GOp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R7GOp.png" alt="enter image description here"></a></p> <p>I want to plot a stacked bar chart with X being Session and Y as Absent and Present stacked one above another. How to do this in <code>ggplot()</code> in <code>R</code></p>
0debug
i am developing java application, i have a panel inside a form : i want to get two parameters[a,b] in [setpoints] function from the form and use it in paintcomponent to draw with.but the problem is that two variables is no accessible by the whole panel.it is only accessible by [setpoints] function Here is the code of the panel: public class shape extends javax.swing.JPanel { public int a; public int b; public shape() { initComponents(); } public void setpoints(int x0,int y0) { this.a=x0; this.b=y0; } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.blue); g.drawLine(a, b, a,b); } }
0debug
How to separate the PartName and PartCost from the String in Java for Android App : I am getting this text as String from the Image dynamically "Part Name Part Cost Engine Oil and Oil Filter Replacement Rs 10K Alf Filter Rs 4500 Cabin AC Micro Filter Rs 4000 Pollen Filter Rs 1200 - 1500 AC Disinfectant Rs 3000 Fuel Filter Rs 6000 - 8000 Spark Plug Set Replacement (Applicable in TFSI / Petrol Car Range) Rs 10K Body Wash, Basic Clean 8. Engine Degrease Rs 3000 Body Wax Polish Detailed Rs 7000 - 8000 Car interior Dry Clean with Genn Clean Rs 8000 - 10000 Wheel Alignment \u0026 Balancing Rs 6000 - 7000 Brake Pads Replacernent (Pair) Rs 30K - 32K Brake Disc Replacernent (Pair) Rs 30K - 35K ". I need to separate the Part Name and Part Cost(2 columns each) get the values from it and should store it in SQLIte Database Android. Please Help me ASAP.Thanks in Advance.
0debug
static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, uint16_t **refcount_table, int64_t *nb_clusters) { BDRVQcowState *s = bs->opaque; int64_t i; QCowSnapshot *sn; int ret; *refcount_table = g_try_new0(uint16_t, *nb_clusters); if (*nb_clusters && *refcount_table == NULL) { res->check_errors++; return -ENOMEM; } ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, 0, s->cluster_size); if (ret < 0) { return ret; } ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO); if (ret < 0) { return ret; } for (i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, sn->l1_table_offset, sn->l1_size, 0); if (ret < 0) { return ret; } } ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, s->snapshots_offset, s->snapshots_size); if (ret < 0) { return ret; } ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t)); if (ret < 0) { return ret; } return check_refblocks(bs, res, fix, refcount_table, nb_clusters); }
1threat
Export multiple classes in ES6 modules : <p>I'm trying to create a module that exports multiple ES6 classes. Let's say I have the following directory structure:</p> <pre><code>my/ └── module/ ├── Foo.js ├── Bar.js └── index.js </code></pre> <p><code>Foo.js</code> and <code>Bar.js</code> each export a default ES6 class:</p> <pre><code>// Foo.js export default class Foo { // class definition } // Bar.js export default class Bar { // class definition } </code></pre> <p>I currently have my <code>index.js</code> set up like this:</p> <pre><code>import Foo from './Foo'; import Bar from './Bar'; export default { Foo, Bar, } </code></pre> <p>However, I am unable to import. I want to be able to do this, but the classes aren't found:</p> <pre><code>import {Foo, Bar} from 'my/module'; </code></pre> <p>What is the correct way to export multiple classes in an ES6 module?</p>
0debug
How to debug a java application when a value entered from UI is not persisted into the database? : <p>Can someone explain me how to debug a java application in eclipse,when a value entered from U.I is not persisted in the database?</p>
0debug
Google finance converter stopped working or changed its url? : <p><a href="https://finance.google.com/finance/converter" rel="noreferrer">https://finance.google.com/finance/converter</a> now redirects to <a href="https://www.google.com/search" rel="noreferrer">https://www.google.com/search</a> Have they changed the url ?</p>
0debug
static int advanced_decode_picture_secondary_header(VC9Context *v) { GetBitContext *gb = &v->s.gb; int index, status = 0; switch(v->s.pict_type) { case P_TYPE: status = decode_p_picture_secondary_header(v); break; case B_TYPE: status = decode_b_picture_secondary_header(v); break; case BI_TYPE: case I_TYPE: status = decode_i_picture_secondary_header(v); break; } if (status<0) return FRAME_SKIPED; v->ac_table_level = decode012(gb); if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) { v->ac2_table_level = decode012(gb); } index = decode012(gb); v->luma_dc_vlc = &ff_msmp4_dc_luma_vlc[index]; v->chroma_dc_vlc = &ff_msmp4_dc_chroma_vlc[index]; return 0; }
1threat
checking username and password PHP : <p>I'm trying to create a php username and password checker but can't get it to work, here is the code:</p> <pre><code>&lt;?php $servername = "iphere"; $user = "userhere"; $pass = "passwordhere"; $dbname = "databasehere"; try { $username = $_GET['username']; $password = $_GET['password']; $conn = new PDO("mysql:host=$servername;dbname=$dbname", $user, $pass); $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $conn-&gt;prepare("SELECT username FROM users WHERE username = :name AND password = :password"); $stmt-&gt;bindParam(':name', $username); $stmt-&gt;bindParam(':password', $password); $stmt-&gt;execute(); $result = $stmt-&gt;setFetchMode(PDO::FETCH_ASSOC); if($username == $result &amp;&amp; $password == $result) { echo "OK"; } else { echo "not OK"; } } catch(PDOException $e) { echo "Error"; } $conn = null; ?&gt; </code></pre> <p>It doesn't give any error or anything. It just echoes OK and thats it. By the way i use GET for my another project. So i will change it later.</p>
0debug
timer_write(void *opaque, hwaddr addr, uint64_t val64, unsigned int size) { struct timerblock *t = opaque; struct xlx_timer *xt; unsigned int timer; uint32_t value = val64; addr >>= 2; timer = timer_from_addr(addr); xt = &t->timers[timer]; D(fprintf(stderr, "%s addr=%x val=%x (timer=%d off=%d)\n", __func__, addr * 4, value, timer, addr & 3)); addr &= 3; switch (addr) { case R_TCSR: if (value & TCSR_TINT) value &= ~TCSR_TINT; xt->regs[addr] = value; if (value & TCSR_ENT) timer_enable(xt); break; default: if (addr < ARRAY_SIZE(xt->regs)) xt->regs[addr] = value; break; } timer_update_irq(t); }
1threat
C# - save image as stream : I try to create a screenshot and send it from C# to PHP where I store it. I create a screenshot like this: Bitmap screenshot = TakeScreenshot(); Now I try to [save it as a stream][1] so I can send it: Stream myStream; screenshot.Save(myStream, System.Drawing.Imaging.ImageFormat.Gif); However, I get `Use of unassigned local variable 'myStream'`. What am I doing wrong? ---------- **Functions:** private Bitmap TakeScreenshot() { //Create a new bitmap. var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Create a graphics object from the bitmap. using (var gfxScreenshot = Graphics.FromImage(bmpScreenshot)) { // Take the screenshot from the upper left corner to the right bottom corner. gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); } return bmpScreenshot; } [1]: https://msdn.microsoft.com/de-de/library/ms142147(v=vs.110).aspx
0debug
How to operate the reboot in Linux a bash shellscript : <p>In Linux bash, I want to write a .sh script, need to reboot twice in the script, How should I write this script?</p>
0debug
How to avoid downloading gradle dependencies each time react-native project is build? : <p>I am working on a react-native android project. For which I am using "react-native run-android" command to build and execute the android project.</p> <p>But each time I use above command, the react-native system downloads the gradle component while it's already installed in my system. Had cross checked that the installed version is same as that which is about to get install via react-native-cli.</p> <p>Would like to know is there a way by which the existing downloaded gradle can be used rather than downloading it?</p> <p>Thanks for reading.</p>
0debug
Want to emulate this type of table with HTML and CSS : <p><a href="https://i.stack.imgur.com/nDrxq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nDrxq.png" alt="Image of what I want to emualte"></a></p> <p>Would like to use something similar to this format for my own personal blog site. The source code isn't giving me many hints to how I can code up a format like this.</p> <p>I was thinking of somehow using divs within each row of a table to do this, but I know there's a cleaner way to do it. Any recommendations? </p>
0debug
Podio Integratioon : <p>I'm developing an app which uses the data from podio website. Here my need is that Integrate the Podio api into my app and Authenticate the app with user credentials.</p> <p>How this could be done?? please put some example codes. &lt;&lt;&lt;<strong>THANKS IN ADVANCE>>>>></strong></p>
0debug
getting cassandra to listen on 9042 properly : Wow..i must say that using cassandra is a disaster compared to other stacks. thanks datastax! OMG I simply want to get a single node running and connect from a remote server. lsof -i :9042 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 22089 cassandra 137u IPv4 80564 0t0 TCP cassansra.sucks.com:9042 (LISTEN) on the cassandra server: sudo nodetool status Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN xxx.xxx.xxx.xxx 202.28 KiB 256 100.0% 6e485a3c-7e0f-452c-8545-77380f21daa0 rack1 What I want iks 9042 to listen on an ip address. I have the below in the cassandra.yaml file: rpc_address: xxx.xxx.xxx.xxx I am using cassandra 3.x
0debug
how disable and get name for control in FlowLayoutPanel from ContextMenuStrip in VB.Net : **my program Contain buttens in FlowLayoutPanel I went to disable any butten when right click on it and click disable in ContextMenuStrip** **my code is** Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For i As Integer = 0 To 30 Dim btn As New Button btn.Name = i btn.Text = i btn.ContextMenuStrip = ContextMenuStrip1 FlowLayoutPanel1.Controls.Add(btn) Next End Sub End Class [enter image description here][1] [1]: https://i.stack.imgur.com/QAmGA.png
0debug
i want to run a command in Python which is working perfectly in cmd. tried import os and os.system to do so but with no use. : The command is for java installation :"jdk-7u51-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature" /L D:\Java\setup.log"
0debug
Cloud-build Trigger : <p><strong><em>1.I want to build trigger on Cloud build for only specific branches</em></strong></p> <p><strong><em>2.It should work with both branches as well as tags in same trigger</em></strong></p> <p>Any solution/suggestion</p> <p>Thanks in advance</p>
0debug
static void balloon_stats_get_all(Object *obj, struct Visitor *v, void *opaque, const char *name, Error **errp) { Error *err = NULL; VirtIOBalloon *s = opaque; int i; if (!s->stats_last_update) { error_setg(errp, "guest hasn't updated any stats yet"); return; } visit_start_struct(v, NULL, "guest-stats", name, 0, &err); if (err) { goto out; } visit_type_int(v, &s->stats_last_update, "last-update", &err); visit_start_struct(v, NULL, NULL, "stats", 0, &err); if (err) { goto out_end; } for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) { visit_type_int64(v, (int64_t *) &s->stats[i], balloon_stat_names[i], &err); } visit_end_struct(v, &err); out_end: visit_end_struct(v, &err); out: error_propagate(errp, err); }
1threat
how to write code for backspace and space in vb .net : i am programming virtual keyboard with images, when i press the key it will display image but am not able to code space and backspace... Dim myDir As String = "C:\Users\ASUBUSU\Desktop\keyboard\java pgm\" Dim img As Image = Image.FromFile(myDir & "sna.png") Dim orgData = Clipboard.GetDataObject Clipboard.SetImage(img) Me.RichTextBox1.Paste() Clipboard.SetDataObject(orgData) how to write code for space and backspace.
0debug
static void vmdk_free_last_extent(BlockDriverState *bs) { BDRVVmdkState *s = bs->opaque; if (s->num_extents == 0) { return; } s->num_extents--; s->extents = g_realloc(s->extents, s->num_extents * sizeof(VmdkExtent)); }
1threat
Internal Implementation of TreeMap : <p>how internal Implementation of TreeMap is done in Java? Does it use any tree (like : binary tree, red-black, B-tree) for arranging elements?</p>
0debug
Docker error when pulling Java 8 image - "failed to register layer" : <p>I am trying to pull the latest official Java docker image (java:8), but I keep getting a <code>failed to register layer</code> error. The Java 7 and 9 docker images download successfully. I am running OS X El Capitan version 10.11.1.</p> <pre><code>&gt; docker -v Docker version 1.10.0, build 590d5108 &gt; docker-machine -v docker-machine version 0.6.0, build e27fb87 &gt; docker pull java:8 8: Pulling from library/java 03e1855d4f31: Extracting [==================================================&gt;] 51.36 MB/51.36 MB a3ed95caeb02: Download complete 9269ba3950bb: Download complete 6ecee6444751: Download complete 5b865d39f77d: Download complete e7e5c0273866: Download complete 6a4effbc4451: Download complete 4b6cb08bb4bc: Download complete 7b07ad270e2c: Download complete failed to register layer: rename /mnt/sda1/var/lib/docker/image/aufs/layerdb/tmp/layer-273420626 /mnt/sda1/var/lib/docker/image/aufs/layerdb/sha256/78dbfa5b7cbc2bd94ccbdba52e71be39b359ed7eac43972891b136334f5ce181: directory not empty </code></pre> <p>Has anyone run across a similar error and successfully resolved it? Thanks</p>
0debug
What is the algorithm Who have the worst complexity O(2^2^n)? : <p>Their are many complexity type like O(1) ... But the worst complexity is O(2^2^n) Is There an algorithm Who have this complexity O(2^2^n)? Who is it?</p>
0debug
how to set values in mongodb array : <blockquote> <p>System.NullReferenceException occurred HResult=0x80004003<br> Message=Object reference not set to an instance of an object.<br> Source= StackTrace: at mongotest.Program.Main(String[] args) in C:\Users\kiit\source\repos\C#-code\mongotest\mongotest\Program.cs:line 20</p> </blockquote> <p>Please help me to solve this error. Why I get the null reference. Apart from this tell me how to get data in MongoDB for this schema </p> <pre><code>{ "_id" : ObjectId("5a78a7365a98c0a0d9118c1a"), "name" : "Amit", "contacts" : [ "userid1", "userid2" ], "logs" : { "status" : "online", "Available" : "False" } } </code></pre> <p>Code : how to set value for logs and contacts,I want to insert these value in database. What I will do with this solution: I will insert value in a database on click event in asp.net and take values from the user.</p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Driver; namespace mongotest { class Program { static void Main(string[] args) { /* Connection in MongoDb and insert data in database */ var client = new MongoClient("mongodb://localhost"); var database = client.GetDatabase("SIH"); var collection = database.GetCollection&lt;testing&gt;("testing"); testing newobject = new testing(); newobject.name = "Amit Mishra"; newobject.logs.Available = "true"; newobject.logs.status = "false"; collection.InsertOneAsync(newobject); Console.Write("Done"); Console.Read(); } } } public class testing { public string _id { get; set; } public string name { get; set; } public string[] contacts { get; set; } public Logs logs { get; set; } } public class Logs { public string status { get; set; } public string Available { get; set; } } </code></pre>
0debug
How to add dynamically created hyperlink to stack panel programmatically : i am creating hyperlinks and want to add it to stack panel. for (int i = 1; i <= links.Length; i++) { Hyperlink hyperlink = new Hyperlink() { NavigateUri = new Uri(links[i - 1]) }; } hyperlink.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(this.Hyperlink_RequestNavigate); mainControl.Children.Add(hyperlink); it gives me error - cannot convert to system.windows.documents.hyperlink to system.windows.uielement. i understand the namespace error but didn't find resolution because in uielement i dint find hyperlink. please provide the solution.
0debug
static inline void _cpu_ppc_store_hdecr(PowerPCCPU *cpu, uint32_t hdecr, uint32_t value, int is_excp) { ppc_tb_t *tb_env = cpu->env.tb_env; if (tb_env->hdecr_timer != NULL) { __cpu_ppc_store_decr(cpu, &tb_env->hdecr_next, tb_env->hdecr_timer, &cpu_ppc_hdecr_excp, hdecr, value, is_excp); } }
1threat
static int stream_set_speed(BlockJob *job, int64_t value) { StreamBlockJob *s = container_of(job, StreamBlockJob, common); if (value < 0) { return -EINVAL; } ratelimit_set_speed(&s->limit, value / BDRV_SECTOR_SIZE); return 0; }
1threat
static int vnc_refresh_lossy_rect(VncDisplay *vd, int x, int y) { VncState *vs; int sty = y / VNC_STAT_RECT; int stx = x / VNC_STAT_RECT; int has_dirty = 0; y = y / VNC_STAT_RECT * VNC_STAT_RECT; x = x / VNC_STAT_RECT * VNC_STAT_RECT; QTAILQ_FOREACH(vs, &vd->clients, next) { int j; if (vs->output.offset) { continue; } if (!vs->lossy_rect[sty][stx]) { continue; } vs->lossy_rect[sty][stx] = 0; for (j = 0; j < VNC_STAT_RECT; ++j) { vnc_set_bits(vs->dirty[y + j], x / 16, VNC_STAT_RECT / 16); } has_dirty++; } return has_dirty; }
1threat
static int curl_open(BlockDriverState *bs, QDict *options, int flags) { BDRVCURLState *s = bs->opaque; CURLState *state = NULL; QemuOpts *opts; Error *local_err = NULL; const char *file; double d; static int inited = 0; if (flags & BDRV_O_RDWR) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "curl block device does not support writes"); return -EROFS; } opts = qemu_opts_create_nofail(&runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); goto out_noclean; } s->readahead_size = qemu_opt_get_size(opts, "readahead", READ_AHEAD_SIZE); if ((s->readahead_size & 0x1ff) != 0) { fprintf(stderr, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512\n", s->readahead_size); goto out_noclean; } file = qemu_opt_get(opts, "url"); if (file == NULL) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "curl block driver requires " "an 'url' option"); goto out_noclean; } if (!inited) { curl_global_init(CURL_GLOBAL_ALL); inited = 1; } DPRINTF("CURL: Opening %s\n", file); s->url = g_strdup(file); state = curl_init_state(s); if (!state) goto out_noclean; curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1); curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_size_cb); if (curl_easy_perform(state->curl)) goto out; curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d); if (d) s->len = (size_t)d; else if(!s->len) goto out; DPRINTF("CURL: Size = %zd\n", s->len); curl_clean_state(state); curl_easy_cleanup(state->curl); state->curl = NULL; s->multi = curl_multi_init(); curl_multi_setopt(s->multi, CURLMOPT_SOCKETDATA, s); curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb); curl_multi_do(s); qemu_opts_del(opts); return 0; out: fprintf(stderr, "CURL: Error opening file: %s\n", state->errmsg); curl_easy_cleanup(state->curl); state->curl = NULL; out_noclean: g_free(s->url); qemu_opts_del(opts); return -EINVAL; }
1threat
Download Complete : Hello i have this C# code that does not do the job. This code should run a code when the download is complete. But it does not work. Code: private void DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { ZipFile.ExtractToDirectory("web/data/main/web.zip", "web/"); } private void flatToggle2_CheckedChanged(object sender) { if (flatToggle2.Checked) { //Create File Directory.CreateDirectory("web/data/main/"); timer2.Start(); bunifuProgressBar1.Show(); bunifuCustomLabel1.Show(); //Downloand using (var client = new WebClient()) { client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadFileCompleted); client.DownloadFile("https://www.apachelounge.com/download/VC15/binaries/httpd-2.4.29-Win64-VC15.zip", "web/data/main/web.zip"); } } else { } } This is the code that does not work private void DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { ZipFile.ExtractToDirectory("web/data/main/web.zip", "web/"); } I tried to run this code without the Unzip but it did not work so i need help with this code. Thank You. Btw i am new here at stackoverflow so please help me if i am wrong.
0debug
def is_upper(string): return (string.upper())
0debug
static void cpu_openrisc_load_kernel(ram_addr_t ram_size, const char *kernel_filename, OpenRISCCPU *cpu) { long kernel_size; uint64_t elf_entry; hwaddr entry; if (kernel_filename && !qtest_enabled()) { kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, NULL, NULL, 1, EM_OPENRISC, 1, 0); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL, NULL, NULL); } if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, ram_size - KERNEL_LOAD_ADDR); entry = KERNEL_LOAD_ADDR; } if (kernel_size < 0) { fprintf(stderr, "QEMU: couldn't load the kernel '%s'\n", kernel_filename); exit(1); } cpu->env.pc = entry; } }
1threat
DateTime formats used in InvariantCulture : <p>I have to pre-validate in Javascript a string that will be a DateTime in c#. The DateTime parse uses InvariantCulture.</p> <p>Does anyone know the DateTime formats defined for InvariantCulture?</p>
0debug
adding a tag when a button is clicked : <p>I need a script when the selected text is surrounded by tags after clicking on the button. For example, there was the text</p> <blockquote> <p>This is my text, I love read</p> </blockquote> <p>I selected "my text" and then clicked on the button, and this text becomes surrounded by tags, for example</p> <blockquote> <p>This is &lt; myTag >my text&lt; /myTag >, I love read</p> </blockquote> <p>The principle of operation is the same as that of text editors, when you can change fonts and style of the text, but I need to surround the text with my tag. How can I do it?</p>
0debug
SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose) { SwsFilter *filter = av_malloc(sizeof(SwsFilter)); if (!filter) return NULL; if (lumaGBlur != 0.0) { filter->lumH = sws_getGaussianVec(lumaGBlur, 3.0); filter->lumV = sws_getGaussianVec(lumaGBlur, 3.0); } else { filter->lumH = sws_getIdentityVec(); filter->lumV = sws_getIdentityVec(); } if (chromaGBlur != 0.0) { filter->chrH = sws_getGaussianVec(chromaGBlur, 3.0); filter->chrV = sws_getGaussianVec(chromaGBlur, 3.0); } else { filter->chrH = sws_getIdentityVec(); filter->chrV = sws_getIdentityVec(); } if (!filter->lumH || !filter->lumV || !filter->chrH || !filter->chrV) { sws_freeVec(filter->lumH); sws_freeVec(filter->lumV); sws_freeVec(filter->chrH); sws_freeVec(filter->chrV); av_freep(&filter); return NULL; } if (chromaSharpen != 0.0) { SwsVector *id = sws_getIdentityVec(); sws_scaleVec(filter->chrH, -chromaSharpen); sws_scaleVec(filter->chrV, -chromaSharpen); sws_addVec(filter->chrH, id); sws_addVec(filter->chrV, id); sws_freeVec(id); } if (lumaSharpen != 0.0) { SwsVector *id = sws_getIdentityVec(); sws_scaleVec(filter->lumH, -lumaSharpen); sws_scaleVec(filter->lumV, -lumaSharpen); sws_addVec(filter->lumH, id); sws_addVec(filter->lumV, id); sws_freeVec(id); } if (chromaHShift != 0.0) sws_shiftVec(filter->chrH, (int)(chromaHShift + 0.5)); if (chromaVShift != 0.0) sws_shiftVec(filter->chrV, (int)(chromaVShift + 0.5)); sws_normalizeVec(filter->chrH, 1.0); sws_normalizeVec(filter->chrV, 1.0); sws_normalizeVec(filter->lumH, 1.0); sws_normalizeVec(filter->lumV, 1.0); if (verbose) sws_printVec2(filter->chrH, NULL, AV_LOG_DEBUG); if (verbose) sws_printVec2(filter->lumH, NULL, AV_LOG_DEBUG); return filter; }
1threat
static int xan_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int ret, buf_size = avpkt->size; XanContext *s = avctx->priv_data; if (avctx->codec->id == CODEC_ID_XAN_WC3) { const uint8_t *buf_end = buf + buf_size; int tag = 0; while (buf_end - buf > 8 && tag != VGA__TAG) { unsigned *tmpptr; uint32_t new_pal; int size; int i; tag = bytestream_get_le32(&buf); size = bytestream_get_be32(&buf); size = FFMIN(size, buf_end - buf); switch (tag) { case PALT_TAG: if (size < PALETTE_SIZE) if (s->palettes_count >= PALETTES_MAX) tmpptr = av_realloc(s->palettes, (s->palettes_count + 1) * AVPALETTE_SIZE); if (!tmpptr) return AVERROR(ENOMEM); s->palettes = tmpptr; tmpptr += s->palettes_count * AVPALETTE_COUNT; for (i = 0; i < PALETTE_COUNT; i++) { #if RUNTIME_GAMMA int r = gamma_corr(*buf++); int g = gamma_corr(*buf++); int b = gamma_corr(*buf++); #else int r = gamma_lookup[*buf++]; int g = gamma_lookup[*buf++]; int b = gamma_lookup[*buf++]; #endif *tmpptr++ = (r << 16) | (g << 8) | b; } s->palettes_count++; break; case SHOT_TAG: if (size < 4) new_pal = bytestream_get_le32(&buf); if (new_pal < s->palettes_count) { s->cur_palette = new_pal; } else av_log(avctx, AV_LOG_ERROR, "Invalid palette selected\n"); break; case VGA__TAG: break; default: buf += size; break; } } buf_size = buf_end - buf; } if ((ret = avctx->get_buffer(avctx, &s->current_frame))) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } s->current_frame.reference = 3; if (!s->frame_size) s->frame_size = s->current_frame.linesize[0] * s->avctx->height; memcpy(s->current_frame.data[1], s->palettes + s->cur_palette * AVPALETTE_COUNT, AVPALETTE_SIZE); s->buf = buf; s->size = buf_size; if (xan_wc3_decode_frame(s) < 0) if (s->last_frame.data[0]) avctx->release_buffer(avctx, &s->last_frame); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->current_frame; FFSWAP(AVFrame, s->current_frame, s->last_frame); return buf_size; }
1threat
Which communication technology should I use for pushing data stream to the website users : <p>I'm building a website where I want to allow users to subscribe to various realtime data streams. They will subscribe to few streams and it will be pushing the data back as long as they are connected. The question is, which technology is more suitable for this: Server Send Evenets, Websockets, HTTP/2, Comet? What should I use for achieving the best results? I aim for quite big amount of users with this. Will appreciate for answers pointing me in the best direction here.</p>
0debug
Where can i find the CDN source for browser version of sanitize-html : <p>I am planning to use the sanitize-html at client side. And i searched but didn't find any CDN which is hosting it. Where can i find it/ is there any way i can add to some of the popular CDNs?</p>
0debug
How to get the git latest commit message and prevent the jenkins build if the commit message contains [ci skip]? : <p>I tried to get the git commit message in jenkinsfile and prevent the build based on commit message.</p> <p><strong>env.GIT_COMMIT</strong> doesn't return the commit details in jenkinsfile.</p> <p>How to get the git latest commit message and prevent the jenkins build if the commit message contains [ci skip] in it?</p>
0debug
Sending POST request in Golang with header : <p>I create my form like this:</p> <pre><code>form := url.Values{} form.Add("region", "San Francisco") if len(params) &gt; 0 { for i := 0; i &lt; len(params); i += 2 { form.Add(params[i], params[i+1]) } testLog.Infof("form %v", form) </code></pre> <p>Now if I use</p> <pre><code>resp, err = http.PostForm(address+r.Path, form) </code></pre> <p>then everything works fine, I get back a response with an expected cookie. </p> <p>However, I would like to to add a header in which case I can't use <code>PostForm</code> hence I created my <code>POST request</code> manually like:</p> <pre><code>req, err := http.NewRequest("POST", address+r.Path, strings.NewReader(form.Encode())) </code></pre> <p>Then I add stuff to the header and send the request</p> <pre><code>req.Header.Add("region", "San Francisco") resp, err = http.DefaultClient.Do(req) </code></pre> <p>But the form is not received and my response does not contain any cookie.</p> <p>When I print the <code>req</code>, it looks like the form is <code>nil</code>:</p> <pre><code>&amp;{POST http://localhost:8081/login HTTP/1.1 1 1 map[Region:[San Francisco]] {0xc420553600} 78 [] false localhost:8081 map[] map[] &lt;nil&gt; map[] &lt;nil&gt; &lt;nil&gt; &lt;nil&gt; &lt;nil&gt;} </code></pre>
0debug
static void predict_plane(SnowContext *s, DWTELEM *buf, int plane_index, int add){ Plane *p= &s->plane[plane_index]; const int mb_w= s->mb_band.width; const int mb_h= s->mb_band.height; const int mb_stride= s->mb_band.stride; int x, y, mb_x, mb_y; int scale = plane_index ? s->mv_scale : 2*s->mv_scale; int block_w = plane_index ? 8 : 16; uint8_t *obmc = plane_index ? obmc16 : obmc32; int obmc_stride= plane_index ? 16 : 32; int ref_stride= s->last_picture.linesize[plane_index]; uint8_t *ref = s->last_picture.data[plane_index]; int w= p->width; int h= p->height; if(s->avctx->debug&512){ for(y=0; y<h; y++){ for(x=0; x<w; x++){ if(add) buf[x + y*w]+= 128*256; else buf[x + y*w]-= 128*256; } } return; } for(mb_y=-1; mb_y<=mb_h; mb_y++){ for(mb_x=-1; mb_x<=mb_w; mb_x++){ int index= clip(mb_x, 0, mb_w-1) + clip(mb_y, 0, mb_h-1)*mb_stride; add_xblock(buf, ref, obmc, block_w*mb_x - block_w/2, block_w*mb_y - block_w/2, 2*block_w, 2*block_w, s->mv_band[0].buf[index]*scale, s->mv_band[1].buf[index]*scale, w, h, w, ref_stride, obmc_stride, s->mb_band.buf[index], add); } } }
1threat
select first div of mutliple div with same class name : <p>Anyone know how to select first div of mutliple div with same class name</p> <pre><code>&lt;div class="abc"&gt;&lt;a&gt;&lt;img src=""&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="abc"&gt;&lt;a&gt;&lt;img src=""&gt;&lt;/a&gt;&lt;/div&gt; </code></pre> <p>how can i select first img in css?</p>
0debug
Remove brakets from numpy array : I have an array which looks like this `['w_49c9417' 'w_b6ae946' 'w_1596a47' 'w_b68d04']`. This a numpy array, is there any way i can remove those brackets, I tried `'.'join(thearray)` but i get, Type Error: sequence item 0: expected instance, Numpy.ndarray found Any suggestions would be helpful! Thanks in advance.
0debug
document.write('<script src="evil.js"></script>');
1threat
React pseudo selector inline styling : <p>What do you think are good ways to handle styling pseudo selectors with React inline styling? What are the gains and drawbacks?</p> <p>Say you have a styles.js file for each React component. You style your component with that styles file. But then you want to do a hover effect on a button (or whatever). </p> <p>One way is to have a global CSS file and handle styling pseudo selectors that way. Here, the class 'label-hover' comes from a global CSS file and styles.label comes from the components style file.</p> <pre><code>&lt;ControlLabel style={styles.label} className='label-hover'&gt; Email &lt;/ControlLabel&gt; </code></pre> <p>Another way is to style the components based on certain conditions (that might be triggered by state or whatever). Here, if hovered state is true, use styles.button and styles.buttonHover otherwise just use styles.button.</p> <pre><code>&lt;section style={(hovered !== true) ? {styles.button} : {...styles.button, ...styles.buttonHover }&gt; &lt;/section&gt; </code></pre> <p>Both approaches feels kind of hacky. If anyone has a better approach, I'd love to know. Thanks!</p>
0debug
static av_cold int pcm_encode_init(AVCodecContext *avctx) { avctx->frame_size = 0; switch(avctx->codec->id) { case CODEC_ID_PCM_ALAW: pcm_alaw_tableinit(); break; case CODEC_ID_PCM_MULAW: pcm_ulaw_tableinit(); break; default: break; } avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id); avctx->block_align = avctx->channels * avctx->bits_per_coded_sample/8; avctx->coded_frame= avcodec_alloc_frame(); return 0; }
1threat
static void exynos4210_uart_write(void *opaque, target_phys_addr_t offset, uint64_t val, unsigned size) { Exynos4210UartState *s = (Exynos4210UartState *)opaque; uint8_t ch; PRINT_DEBUG_EXTEND("UART%d: <0x%04x> %s <- 0x%08llx\n", s->channel, offset, exynos4210_uart_regname(offset), (long long unsigned int)val); switch (offset) { case ULCON: case UBRDIV: case UFRACVAL: s->reg[I_(offset)] = val; exynos4210_uart_update_parameters(s); break; case UFCON: s->reg[I_(UFCON)] = val; if (val & UFCON_Rx_FIFO_RESET) { fifo_reset(&s->rx); s->reg[I_(UFCON)] &= ~UFCON_Rx_FIFO_RESET; PRINT_DEBUG("UART%d: Rx FIFO Reset\n", s->channel); } if (val & UFCON_Tx_FIFO_RESET) { fifo_reset(&s->tx); s->reg[I_(UFCON)] &= ~UFCON_Tx_FIFO_RESET; PRINT_DEBUG("UART%d: Tx FIFO Reset\n", s->channel); } break; case UTXH: if (s->chr) { s->reg[I_(UTRSTAT)] &= ~(UTRSTAT_TRANSMITTER_EMPTY | UTRSTAT_Tx_BUFFER_EMPTY); ch = (uint8_t)val; qemu_chr_fe_write(s->chr, &ch, 1); #if DEBUG_Tx_DATA fprintf(stderr, "%c", ch); #endif s->reg[I_(UTRSTAT)] |= UTRSTAT_TRANSMITTER_EMPTY | UTRSTAT_Tx_BUFFER_EMPTY; s->reg[I_(UINTSP)] |= UINTSP_TXD; exynos4210_uart_update_irq(s); } break; case UINTP: s->reg[I_(UINTP)] &= ~val; s->reg[I_(UINTSP)] &= ~val; PRINT_DEBUG("UART%d: UINTP [%04x] have been cleared: %08x\n", s->channel, offset, s->reg[I_(UINTP)]); exynos4210_uart_update_irq(s); break; case UTRSTAT: case UERSTAT: case UFSTAT: case UMSTAT: case URXH: PRINT_DEBUG("UART%d: Trying to write into RO register: %s [%04x]\n", s->channel, exynos4210_uart_regname(offset), offset); break; case UINTSP: s->reg[I_(UINTSP)] &= ~val; break; case UINTM: s->reg[I_(UINTM)] = val; exynos4210_uart_update_irq(s); break; case UCON: case UMCON: default: s->reg[I_(offset)] = val; break; } }
1threat