problem
stringlengths
26
131k
labels
class label
2 classes
I have data streaming over serial in bytes. What is the easiest way to read this data in? : <p>I have written an application that streams pixel information over serial to an arduino. </p> <p>I want to be able to stream 100 pixels at 24fps which should be possible if I run the serial connection at 115200 baud.</p> <p>(24fps * 100 pixels * 5 bytes * 8 bits) = 96,000 bps</p> <p>for each pixel of each frame I am sending a total of 5 bytes</p> <p>byte 1: Pixel index number 0-100 byte 2: Red value 0-254 byte 3: Green value 0-254 byte 4: Blue value 0-254 byte 5: Pixel delimiter byte = 255</p> <p>these are all being streamed as raw bytes over the serial connection to the arduino. </p> <p>What is going to be the easiest way to reliably get these bytes into ints so I can pass them to fastLED to display them on neopixels?</p>
0debug
static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *decoded, int stride, int level, int threshold, int lambda, int intra){ int count, y, x, i, j, split, best_mean, best_score, best_count; int best_vector[6]; int block_sum[7]= {0, 0, 0, 0, 0, 0}; int w= 2<<((level+2)>>1); int h= 2<<((level+1)>>1); int size=w*h; int16_t block[7][256]; const int8_t *codebook_sum, *codebook; const uint16_t (*mean_vlc)[2]; const uint8_t (*multistage_vlc)[2]; best_score=0; if(intra){ codebook_sum= svq1_intra_codebook_sum[level]; codebook= ff_svq1_intra_codebooks[level]; mean_vlc= ff_svq1_intra_mean_vlc; multistage_vlc= ff_svq1_intra_multistage_vlc[level]; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v= src[x + y*stride]; block[0][x + w*y]= v; best_score += v*v; block_sum[0] += v; } } }else{ codebook_sum= svq1_inter_codebook_sum[level]; codebook= ff_svq1_inter_codebooks[level]; mean_vlc= ff_svq1_inter_mean_vlc + 256; multistage_vlc= ff_svq1_inter_multistage_vlc[level]; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v= src[x + y*stride] - ref[x + y*stride]; block[0][x + w*y]= v; best_score += v*v; block_sum[0] += v; } } } best_count=0; best_score -= ((block_sum[0]*block_sum[0])>>(level+3)); best_mean= (block_sum[0] + (size>>1)) >> (level+3); if(level<4){ for(count=1; count<7; count++){ int best_vector_score= INT_MAX; int best_vector_sum=-999, best_vector_mean=-999; const int stage= count-1; const int8_t *vector; for(i=0; i<16; i++){ int sum= codebook_sum[stage*16 + i]; int sqr, diff, score; vector = codebook + stage*size*16 + i*size; sqr = s->dsp.ssd_int8_vs_int16(vector, block[stage], size); diff= block_sum[stage] - sum; score= sqr - ((diff*(int64_t)diff)>>(level+3)); if(score < best_vector_score){ int mean= (diff + (size>>1)) >> (level+3); assert(mean >-300 && mean<300); mean= av_clip(mean, intra?0:-256, 255); best_vector_score= score; best_vector[stage]= i; best_vector_sum= sum; best_vector_mean= mean; } } assert(best_vector_mean != -999); vector= codebook + stage*size*16 + best_vector[stage]*size; for(j=0; j<size; j++){ block[stage+1][j] = block[stage][j] - vector[j]; } block_sum[stage+1]= block_sum[stage] - best_vector_sum; best_vector_score += lambda*(+ 1 + 4*count + multistage_vlc[1+count][1] + mean_vlc[best_vector_mean][1]); if(best_vector_score < best_score){ best_score= best_vector_score; best_count= count; best_mean= best_vector_mean; } } } split=0; if(best_score > threshold && level){ int score=0; int offset= (level&1) ? stride*h/2 : w/2; PutBitContext backup[6]; for(i=level-1; i>=0; i--){ backup[i]= s->reorder_pb[i]; } score += encode_block(s, src , ref , decoded , stride, level-1, threshold>>1, lambda, intra); score += encode_block(s, src + offset, ref + offset, decoded + offset, stride, level-1, threshold>>1, lambda, intra); score += lambda; if(score < best_score){ best_score= score; split=1; }else{ for(i=level-1; i>=0; i--){ s->reorder_pb[i]= backup[i]; } } } if (level > 0) put_bits(&s->reorder_pb[level], 1, split); if(!split){ assert((best_mean >= 0 && best_mean<256) || !intra); assert(best_mean >= -256 && best_mean<256); assert(best_count >=0 && best_count<7); assert(level<4 || best_count==0); put_bits(&s->reorder_pb[level], multistage_vlc[1 + best_count][1], multistage_vlc[1 + best_count][0]); put_bits(&s->reorder_pb[level], mean_vlc[best_mean][1], mean_vlc[best_mean][0]); for (i = 0; i < best_count; i++){ assert(best_vector[i]>=0 && best_vector[i]<16); put_bits(&s->reorder_pb[level], 4, best_vector[i]); } for(y=0; y<h; y++){ for(x=0; x<w; x++){ decoded[x + y*stride]= src[x + y*stride] - block[best_count][x + w*y] + best_mean; } } } return best_score; }
1threat
static int xan_decode_init(AVCodecContext *avctx) { XanContext *s = avctx->priv_data; int i; s->avctx = avctx; if ((avctx->codec->id == CODEC_ID_XAN_WC3) && (s->avctx->palctrl == NULL)) { av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n"); } avctx->pix_fmt = PIX_FMT_PAL8; avctx->has_b_frames = 0; dsputil_init(&s->dsp, avctx); for (i = 0; i < 256; i++) { y_r_table[i] = Y_R * i; y_g_table[i] = Y_G * i; y_b_table[i] = Y_B * i; u_r_table[i] = U_R * i; u_g_table[i] = U_G * i; u_b_table[i] = U_B * i; v_r_table[i] = V_R * i; v_g_table[i] = V_G * i; v_b_table[i] = V_B * i; } s->buffer1 = av_malloc(avctx->width * avctx->height); s->buffer2 = av_malloc(avctx->width * avctx->height); if (!s->buffer1 || !s->buffer2) return 0; }
1threat
PHP Submit based on entry : <pre><code>&lt;form method="POST"&gt; &lt;?php if (isset($_GET['name'])){ $searchname = $_GET['name']; } ?&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;name:&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;input type='Text' name='name' Value='&lt;?=$searchname?&gt;'&gt;&lt;/td&gt; &lt;td colspan='3'&gt;&lt;input type='Submit' value='Search'&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>Above I have a basic variable passed in from another page via URL. This variable is passed into a text box. When I get to the page that this is on, I want to have it search automatically, instead of me pressing the submit button. How does one do this?</p>
0debug
Java Downcasting of extending class : <p>Why this code is not working? When i casting, I get ClassCastExeption Exception in thread "main" java.lang.ClassCastException: A cannot be cast to B at HelloWorld.main</p> <pre><code>public class HelloWorld { public static void main(String[] args) { B b1 = (B)new A(); b1.a(); } } public class A { public void a (){ System.out.println("A.a"); } public void b (){ System.out.println("A.b"); } } public class B extends A{ } </code></pre>
0debug
static void uc32_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); UniCore32CPU *cpu = UNICORE32_CPU(obj); CPUUniCore32State *env = &cpu->env; static bool inited; cs->env_ptr = env; cpu_exec_init(cs, &error_abort); #ifdef CONFIG_USER_ONLY env->uncached_asr = ASR_MODE_USER; env->regs[31] = 0; #else env->uncached_asr = ASR_MODE_PRIV; env->regs[31] = 0x03000000; #endif tlb_flush(cs, 1); if (tcg_enabled() && !inited) { inited = true; uc32_translate_init(); } }
1threat
static void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); memory_region_init(system_memory, "system", INT64_MAX); address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io)); memory_region_init(system_io, "io", 65536); address_space_init(&address_space_io, system_io, "I/O"); memory_listener_register(&core_memory_listener, &address_space_memory); memory_listener_register(&io_memory_listener, &address_space_io); memory_listener_register(&tcg_memory_listener, &address_space_memory); }
1threat
Difference between @Valid and @Validated in Spring : <p>Spring supports two different validation methods: Spring validation and JSR-303 bean validation. Both can be used by defining a Spring validator that delegates to other delegators including the bean validator. So far so good.</p> <p>But when annotating methods to actually request validation, it's another story. I can annotate like this</p> <pre><code>@RequestMapping(value = "/object", method = RequestMethod.POST) public @ResponseBody TestObject create(@Valid @RequestBody TestObject obj, BindingResult result) { </code></pre> <p>or like this</p> <pre><code>@RequestMapping(value = "/object", method = RequestMethod.POST) public @ResponseBody TestObject create(@Validated @RequestBody TestObject obj, BindingResult result) { </code></pre> <p>Here, @Valid is <a href="http://docs.oracle.com/javaee/7/api/javax/validation/Valid.html">javax.validation.Valid</a>, and @Validated is <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/validation/annotation/Validated.html">org.springframework.validation.annotation.Validated</a>. The docs for the latter say</p> <blockquote> <p>Variant of JSR-303's Valid, supporting the specification of validation groups. Designed for convenient use with Spring's JSR-303 support but not JSR-303 specific.</p> </blockquote> <p>which doesn't help much because it doesn't tell exactly how it's different. If at all. Both seem to be working pretty fine for me.</p>
0debug
How to get user input and output it onto the web page : <p>I am trying to create a program where I ask the user for two numeric inputs and then output to the web page the value of those two numbers when added together (show something like 1 + 2 = 3) and then display those two numbers multiplied together (1 * 2 = 2). Sample output should look something like the following but based on the input received from the website user:</p> <p>1 + 2 = 3</p> <p>1 * 2 = 2 </p>
0debug
void qemu_service_io(void) { qemu_notify_event(); }
1threat
R - Descriptive analytics summarize multiple column with dplyr : <p>I'm trying to join the mean, median, sd and var of a dataset but I'm failing to do so with dplyr.</p> <p>Here is a SS with the <a href="https://i.stack.imgur.com/vVd3X.png" rel="nofollow noreferrer">Data</a></p> <p>I'm just failing to obtain a table containing mean, median, sd and var for each header (Congruent and Incongruent)</p> <p>The header of the table would still be Congruent and Incongruent and the rows would be each function described above.</p> <p>This is probably a dupe but I have read a lot of similar questions and I just couldn't achieve what I'm trying, sorry for my rookieness. </p> <p>Many thanks</p>
0debug
How to copy a class instance in python? : <p>I would like to make a copy of a class instance in python. I tried <code>copy.deepcopy</code> but I get the error message:</p> <blockquote> <p>RuntimeError: Only Variables created explicitly by the user (graph leaves) support the deepcopy protocol at the moment</p> </blockquote> <p>So suppose I have something like:</p> <pre><code>class C(object): def __init__(self,a,b, **kwargs): self.a=a self.b=b for x, v in kwargs.items(): setattr(self, x, v) c = C(4,5,'r'=2) c.a = 11 del c.b </code></pre> <p>And now I want to make an identical deep copy of <code>c</code>, is there an easy way?</p>
0debug
static av_always_inline void FUNC(row_fdct)(int16_t *data) { int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; int tmp10, tmp11, tmp12, tmp13; int z1, z2, z3, z4, z5; int16_t *dataptr; int ctr; dataptr = data; for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { tmp0 = dataptr[0] + dataptr[7]; tmp7 = dataptr[0] - dataptr[7]; tmp1 = dataptr[1] + dataptr[6]; tmp6 = dataptr[1] - dataptr[6]; tmp2 = dataptr[2] + dataptr[5]; tmp5 = dataptr[2] - dataptr[5]; tmp3 = dataptr[3] + dataptr[4]; tmp4 = dataptr[3] - dataptr[4]; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; dataptr[0] = (int16_t) ((tmp10 + tmp11) << PASS1_BITS); dataptr[4] = (int16_t) ((tmp10 - tmp11) << PASS1_BITS); z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); dataptr[2] = (int16_t) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), CONST_BITS-PASS1_BITS); dataptr[6] = (int16_t) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), CONST_BITS-PASS1_BITS); z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; z3 = tmp4 + tmp6; z4 = tmp5 + tmp7; z5 = MULTIPLY(z3 + z4, FIX_1_175875602); tmp4 = MULTIPLY(tmp4, FIX_0_298631336); tmp5 = MULTIPLY(tmp5, FIX_2_053119869); tmp6 = MULTIPLY(tmp6, FIX_3_072711026); tmp7 = MULTIPLY(tmp7, FIX_1_501321110); z1 = MULTIPLY(z1, - FIX_0_899976223); z2 = MULTIPLY(z2, - FIX_2_562915447); z3 = MULTIPLY(z3, - FIX_1_961570560); z4 = MULTIPLY(z4, - FIX_0_390180644); z3 += z5; z4 += z5; dataptr[7] = (int16_t) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); dataptr[5] = (int16_t) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); dataptr[3] = (int16_t) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); dataptr[1] = (int16_t) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); dataptr += DCTSIZE; } }
1threat
Alamofire download issue : <p>I am trying to download <a href="https://slove.tulleb.com/uploads/6/6/0/2/66027561/2791411.jpg-1447979839.png">this picture</a> in my code using Alamofire 4.0.0 with Xcode 8.0 and Swift 3.0.</p> <p>Here is my request:</p> <pre><code> func download(_ path: String, _ completionHandler: @escaping (Any?) -&gt; ()) { let stringURL = "https://slove.tulleb.com/uploads/6/6/0/2/66027561/2791411.jpg-1447979839.png" print("Requesting \(stringURL)...") _ = Alamofire.download(stringURL) .responseData { response in print(response) if let data = response.result.value { completionHandler(UIImage(data: data)) } else { completionHandler(nil) } } } </code></pre> <p>I get the following answer from the server:</p> <blockquote> <p>FAILURE: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputFileReadFailed(file:///private/var/mobile/Containers/Data/Application/50400F41-47FD-4276-8903-F48D942D064A/tmp/CFNetworkDownload_D1Aqkh.tmp))</p> </blockquote> <p>I don't have any idea on how to fix this... Is Alamofire new version having some issues or is it me forgetting something somewhere?</p> <p>Thanks!</p>
0debug
Why it prints false : let optionalString:String?="" print(optionalString == nil) the optional string contains null value but I don't understand why it prints false, when I compile this program I have output false I don't know why and what is happening, so that my question so that my question so that my question
0debug
onRequestPermissionsResult never gets called in fragment : <p>Below code is working fine in Activity but I <strong>cannot make it work inside a Fragment.</strong></p> <p>The <code>onRequestPermissionsResult</code> is never gets called.</p> <p>There is a <code>requestPermissions</code> function in API level 23 (Android 6.0) but I need to make it work on lower levels like API level 21 (Android 5.0) so unfortunetely I cannot use that. <code>ActivityCompat.requestPermissions</code> just simply not calls <code>onRequestPermissionsResult</code>.</p> <p>Any suggestion?</p> <pre><code>public class MyFragment extends Fragment { final int REQUEST_CODE = 120; @Override public View onCreateView(LayoutInflater infl, ViewGroup cont, Bundle bundle) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { Log.i("LOG", "Asking for permission right now.."); ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_CODE); //This is working but needs API level 23 (Android 6.0) - How to make this work on Android 5.0? //requestPermissions( new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_CODE); } return super.onCreateView(infl, cont, bundle); } @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { Log.i("LOG", "onRequestPermissionsResult!"); if (requestCode == REQUEST_CODE) { if (grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) { Log.i("LOG", "GRANTED"); Toast.makeText(getActivity(), "GRANTED,", Toast.LENGTH_LONG).show(); } else { Log.i("LOG", "REFUSED"); Toast.makeText(getActivity(), "REFUSED,", Toast.LENGTH_LONG).show(); } } } } </code></pre>
0debug
def replace_char(str1,ch,newch): str2 = str1.replace(ch, newch) return str2
0debug
Java Program : Split an Array into two array via them types : How can I Write a program to input a string (consist of symbol and number) into an array, the program then should store number into array1, and symbol into array2. for example I want to split this Array [Im 18 years old & 22 days ] then our out put should be Array1[Im,years,old,days] Array2 [18,&,22] thanks for your helps in advance !!
0debug
Grouping WHERE and AND as one satement : <p>Im trying run this sql statement but its not working..<br></p> <p>the select statement is ok but its just the bottom part that's giving me trouble.</p> <pre><code>SELECT VRVDIL.INVOICE_DATE, VRVDIL.INVOICE_NO, VRVDIL.DEAL_NO, VRVDIL.COST, VVD.DEAL_DATE, VVD.SALESMAN_NAME, VVD.SIGNED_DATE, VVD.STOCK_NO, VVD.VEHICLE_ID, VVD.VEHICLE_SALES_GROUP_DESCRIPTION, VVD.INVOICE_TO_NAME, VRVS.DATE_SOLD, VRVS.DAYS_IN_STOCK_BEFORE_SOLD, VRVS.LOCATION_NAME, VRVS.STOCKED_DATE, VRVS.VEHICLE_CLASS_DESCRIPTION, VRVRD.BUYER_NAME, VRVRD.PURCHASING_PRICE, VRVRD.SELLING_PRICE, VRV.VIN, VRV.VEHICLE_TYPE, VRV.REGO_NO, VRV.REGISTRATION_EXPIRY_DATE, VRV.MODEL_ID, VRV.MAKE_ID, VRVDOL.QTY FROM VW_RG_VEHICLE_DEAL_INVOICE_LINE VRVDIL, VW_VEHICLE_DEAL VVD, VW_RG_VEHICLE_DEAL_ORDER_LINE VRVDOL, VW_RG_VEHICLE VRV, VW_RG_VEHICLE_STOCKCARD VRVS, VW_RG_VEHICLE_REGISTER_DETAIL VRVRD WHERE (VRVDIL.VEHICLE_DEAL_KEY = VVD.VEHICLE_DEAL_KEY AND VRVDOL.VEHICLE_DEAL_KEY = VVD.VEHICLE_DEAL_KEY AND VVD.VEHICLE_KEY = VRV.VEHICLE_KEY AND VRVS.VEHICLE_STOCKCARD_KEY = VVD.VEHICLE_STOCKCARD_KEY AND VRVS.VEHICLE_KEY = VRV.VEHICLE_KEY AND VRVS.VEHICLE_STOCKCARD_KEY = VRVRD.VEHICLE_STOCKCARD_KEY </code></pre> <p>what is the error?</p>
0debug
Insert byte in a byte Array? : <p>byte[] myFile = File.ReadAllBytes("d:\123.xml"); I want insert some character after each byte in myFile byte array. If the myFile byte array length is 5000, after insert, it will become 10000. How can I write by c# ?</p>
0debug
Whatsapp like CircularProgressBar : <p>Is there any library, which functions as <strong>WhatsApp</strong> like <strong>Circular ProgressBar</strong> for uploading or downloading image?</p>
0debug
I am using TabLaout in Activity , but it showing NULL pointer : <p>This is my code </p> <pre><code> package com.saverx.rushabh.saverx; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.view.ViewGroup; public class MainActivity extends AppCompatActivity { View view; private static final String ARG_SECTION_NUMBER = "section_number"; ViewPager viewPager; //TabLayout tabLayout; TabLayout tabLayout; LayoutInflater inflater; ViewGroup container; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.container=container; this.inflater=inflater; this.view= inflater.inflate(R.layout.activity_main, container, false); viewPager=(ViewPager)view.findViewById(R.id.viewPager); viewPager.setAdapter(new sliderAapter(getSupportFragmentManager())); tabLayout=(TabLayout)view.findViewById(R.id.sliding_tab); tabLayout.post(new Runnable() { @Override public void run() { tabLayout.setupWithViewPager(viewPager); } }); //return view; } private class sliderAapter extends FragmentPagerAdapter { public sliderAapter(FragmentManager supportFragmentManager) { super(supportFragmentManager); } @Override public Fragment getItem(int position) { Log.e("adapter", ""+position); // return new CalendarFragment(); NewLeadsFragment obj= new NewLeadsFragment(); /* Bundle bundle=new Bundle(); bundle.putInt("position",position); obj.setArguments(bundle); return obj;*/ return obj; } @Override public int getCount() { return 3;// 3 tabs } @Override public CharSequence getPageTitle(int position) { switch (position) { case 0: return "Leads"; case 1: return "Meetings"; case 2: return "Service"; } return null; } } } </code></pre> <p>Exception is </p> <pre><code> Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean)' on a null object reference at com.saverx.rushabh.saverx.MainActivity.onCreate(MainActivity.java:33) </code></pre> <p>This code is working perfectly fine when I am using fragment instad of activity</p> <p>I am using tablayout so that i can drag through signup and sign in using tablayout.</p> <p>The runtime error is :</p> <p>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.saverx.rushabh.saverx/com.saverx.rushabh.saverx.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean)' on a null object reference</p> <p>I summarise that the error may be due to I havent inserted <code>this.view=view</code> but it is throwing same exception </p>
0debug
static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) { int i; m->style_entries = AV_RB16(tsmb); tsmb += 2; if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size) return -1; m->box_flags |= STYL_BOX; for(i = 0; i < m->style_entries; i++) { m->s_temp = av_malloc(sizeof(*m->s_temp)); if (!m->s_temp) { mov_text_cleanup(m); return AVERROR(ENOMEM); } m->s_temp->style_start = AV_RB16(tsmb); tsmb += 2; m->s_temp->style_end = AV_RB16(tsmb); tsmb += 2; m->s_temp->style_fontID = AV_RB16(tsmb); tsmb += 2; m->s_temp->style_flag = AV_RB8(tsmb); tsmb++; m->s_temp->fontsize = AV_RB8(tsmb); av_dynarray_add(&m->s, &m->count_s, m->s_temp); if(!m->s) { mov_text_cleanup(m); return AVERROR(ENOMEM); } tsmb++; tsmb += 4; } return 0; }
1threat
static void gen_farith (DisasContext *ctx, uint32_t op1, int ft, int fs, int fd, int cc) { const char *opn = "farith"; const char *condnames[] = { "c.f", "c.un", "c.eq", "c.ueq", "c.olt", "c.ult", "c.ole", "c.ule", "c.sf", "c.ngle", "c.seq", "c.ngl", "c.lt", "c.nge", "c.le", "c.ngt", }; const char *condnames_abs[] = { "cabs.f", "cabs.un", "cabs.eq", "cabs.ueq", "cabs.olt", "cabs.ult", "cabs.ole", "cabs.ule", "cabs.sf", "cabs.ngle", "cabs.seq", "cabs.ngl", "cabs.lt", "cabs.nge", "cabs.le", "cabs.ngt", }; enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP; uint32_t func = ctx->opcode & 0x3f; switch (ctx->opcode & FOP(0x3f, 0x1f)) { case FOP(0, 16): GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); gen_op_float_add_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "add.s"; optype = BINOP; break; case FOP(1, 16): GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); gen_op_float_sub_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "sub.s"; optype = BINOP; break; case FOP(2, 16): GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); gen_op_float_mul_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "mul.s"; optype = BINOP; break; case FOP(3, 16): GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); gen_op_float_div_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "div.s"; optype = BINOP; break; case FOP(4, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_sqrt_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "sqrt.s"; break; case FOP(5, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_abs_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "abs.s"; break; case FOP(6, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_mov_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "mov.s"; break; case FOP(7, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_chs_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "neg.s"; break; case FOP(8, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_roundl_s(); GEN_STORE_FTN_FREG(fd, DT2); opn = "round.l.s"; break; case FOP(9, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_truncl_s(); GEN_STORE_FTN_FREG(fd, DT2); opn = "trunc.l.s"; break; case FOP(10, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_ceill_s(); GEN_STORE_FTN_FREG(fd, DT2); opn = "ceil.l.s"; break; case FOP(11, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_floorl_s(); GEN_STORE_FTN_FREG(fd, DT2); opn = "floor.l.s"; break; case FOP(12, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_roundw_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "round.w.s"; break; case FOP(13, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_truncw_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "trunc.w.s"; break; case FOP(14, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_ceilw_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "ceil.w.s"; break; case FOP(15, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_floorw_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "floor.w.s"; break; case FOP(17, 16): GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT2, fd); gen_movcf_s(ctx, (ft >> 2) & 0x7, ft & 0x1); GEN_STORE_FTN_FREG(fd, WT2); opn = "movcf.s"; break; case FOP(18, 16): GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT2, fd); gen_op_float_movz_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "movz.s"; break; case FOP(19, 16): GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT2, fd); gen_op_float_movn_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "movn.s"; break; case FOP(21, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_recip_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "recip.s"; break; case FOP(22, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_rsqrt_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "rsqrt.s"; break; case FOP(28, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT2, fd); gen_op_float_recip2_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "recip2.s"; break; case FOP(29, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_recip1_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "recip1.s"; break; case FOP(30, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_rsqrt1_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "rsqrt1.s"; break; case FOP(31, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT2, fd); gen_op_float_rsqrt2_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "rsqrt2.s"; break; case FOP(33, 16): gen_op_cp1_registers(fd); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_cvtd_s(); GEN_STORE_FTN_FREG(fd, DT2); opn = "cvt.d.s"; break; case FOP(36, 16): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_cvtw_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "cvt.w.s"; break; case FOP(37, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_cvtl_s(); GEN_STORE_FTN_FREG(fd, DT2); opn = "cvt.l.s"; break; case FOP(38, 16): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT1, fs); GEN_LOAD_FREG_FTN(WT0, ft); gen_op_float_cvtps_s(); GEN_STORE_FTN_FREG(fd, DT2); opn = "cvt.ps.s"; break; case FOP(48, 16): case FOP(49, 16): case FOP(50, 16): case FOP(51, 16): case FOP(52, 16): case FOP(53, 16): case FOP(54, 16): case FOP(55, 16): case FOP(56, 16): case FOP(57, 16): case FOP(58, 16): case FOP(59, 16): case FOP(60, 16): case FOP(61, 16): case FOP(62, 16): case FOP(63, 16): GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); if (ctx->opcode & (1 << 6)) { gen_op_cp1_64bitmode(); gen_cmpabs_s(func-48, cc); opn = condnames_abs[func-48]; } else { gen_cmp_s(func-48, cc); opn = condnames[func-48]; } break; case FOP(0, 17): gen_op_cp1_registers(fs | ft | fd); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); gen_op_float_add_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "add.d"; optype = BINOP; break; case FOP(1, 17): gen_op_cp1_registers(fs | ft | fd); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); gen_op_float_sub_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "sub.d"; optype = BINOP; break; case FOP(2, 17): gen_op_cp1_registers(fs | ft | fd); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); gen_op_float_mul_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "mul.d"; optype = BINOP; break; case FOP(3, 17): gen_op_cp1_registers(fs | ft | fd); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); gen_op_float_div_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "div.d"; optype = BINOP; break; case FOP(4, 17): gen_op_cp1_registers(fs | fd); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_sqrt_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "sqrt.d"; break; case FOP(5, 17): gen_op_cp1_registers(fs | fd); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_abs_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "abs.d"; break; case FOP(6, 17): gen_op_cp1_registers(fs | fd); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_mov_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "mov.d"; break; case FOP(7, 17): gen_op_cp1_registers(fs | fd); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_chs_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "neg.d"; break; case FOP(8, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_roundl_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "round.l.d"; break; case FOP(9, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_truncl_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "trunc.l.d"; break; case FOP(10, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_ceill_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "ceil.l.d"; break; case FOP(11, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_floorl_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "floor.l.d"; break; case FOP(12, 17): gen_op_cp1_registers(fs); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_roundw_d(); GEN_STORE_FTN_FREG(fd, WT2); opn = "round.w.d"; break; case FOP(13, 17): gen_op_cp1_registers(fs); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_truncw_d(); GEN_STORE_FTN_FREG(fd, WT2); opn = "trunc.w.d"; break; case FOP(14, 17): gen_op_cp1_registers(fs); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_ceilw_d(); GEN_STORE_FTN_FREG(fd, WT2); opn = "ceil.w.d"; break; case FOP(15, 17): gen_op_cp1_registers(fs); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_floorw_d(); GEN_STORE_FTN_FREG(fd, WT2); opn = "floor.w.d"; break; case FOP(17, 17): GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT2, fd); gen_movcf_d(ctx, (ft >> 2) & 0x7, ft & 0x1); GEN_STORE_FTN_FREG(fd, DT2); opn = "movcf.d"; break; case FOP(18, 17): GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT2, fd); gen_op_float_movz_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "movz.d"; break; case FOP(19, 17): GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT2, fd); gen_op_float_movn_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "movn.d"; break; case FOP(21, 17): gen_op_cp1_registers(fs | fd); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_recip_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "recip.d"; break; case FOP(22, 17): gen_op_cp1_registers(fs | fd); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_rsqrt_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "rsqrt.d"; break; case FOP(28, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT2, ft); gen_op_float_recip2_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "recip2.d"; break; case FOP(29, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_recip1_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "recip1.d"; break; case FOP(30, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_rsqrt1_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "rsqrt1.d"; break; case FOP(31, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT2, ft); gen_op_float_rsqrt2_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "rsqrt2.d"; break; case FOP(48, 17): case FOP(49, 17): case FOP(50, 17): case FOP(51, 17): case FOP(52, 17): case FOP(53, 17): case FOP(54, 17): case FOP(55, 17): case FOP(56, 17): case FOP(57, 17): case FOP(58, 17): case FOP(59, 17): case FOP(60, 17): case FOP(61, 17): case FOP(62, 17): case FOP(63, 17): GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); if (ctx->opcode & (1 << 6)) { gen_op_cp1_64bitmode(); gen_cmpabs_d(func-48, cc); opn = condnames_abs[func-48]; } else { gen_op_cp1_registers(fs | ft); gen_cmp_d(func-48, cc); opn = condnames[func-48]; } break; case FOP(32, 17): gen_op_cp1_registers(fs); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_cvts_d(); GEN_STORE_FTN_FREG(fd, WT2); opn = "cvt.s.d"; break; case FOP(36, 17): gen_op_cp1_registers(fs); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_cvtw_d(); GEN_STORE_FTN_FREG(fd, WT2); opn = "cvt.w.d"; break; case FOP(37, 17): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_cvtl_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "cvt.l.d"; break; case FOP(32, 20): GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_cvts_w(); GEN_STORE_FTN_FREG(fd, WT2); opn = "cvt.s.w"; break; case FOP(33, 20): gen_op_cp1_registers(fd); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_cvtd_w(); GEN_STORE_FTN_FREG(fd, DT2); opn = "cvt.d.w"; break; case FOP(32, 21): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_cvts_l(); GEN_STORE_FTN_FREG(fd, WT2); opn = "cvt.s.l"; break; case FOP(33, 21): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(DT0, fs); gen_op_float_cvtd_l(); GEN_STORE_FTN_FREG(fd, DT2); opn = "cvt.d.l"; break; case FOP(38, 20): case FOP(38, 21): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_cvtps_pw(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "cvt.ps.pw"; break; case FOP(0, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); gen_op_float_add_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "add.ps"; break; case FOP(1, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); gen_op_float_sub_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "sub.ps"; break; case FOP(2, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); gen_op_float_mul_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "mul.ps"; break; case FOP(5, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_abs_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "abs.ps"; break; case FOP(6, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_mov_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "mov.ps"; break; case FOP(7, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_chs_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "neg.ps"; break; case FOP(17, 22): gen_op_cp1_64bitmode(); GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT2, fd); GEN_LOAD_FREG_FTN(WTH2, fd); gen_movcf_ps(ctx, (ft >> 2) & 0x7, ft & 0x1); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "movcf.ps"; break; case FOP(18, 22): gen_op_cp1_64bitmode(); GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT2, fd); GEN_LOAD_FREG_FTN(WTH2, fd); gen_op_float_movz_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "movz.ps"; break; case FOP(19, 22): gen_op_cp1_64bitmode(); GEN_LOAD_REG_TN(T0, ft); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT2, fd); GEN_LOAD_FREG_FTN(WTH2, fd); gen_op_float_movn_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "movn.ps"; break; case FOP(24, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, ft); GEN_LOAD_FREG_FTN(WTH0, ft); GEN_LOAD_FREG_FTN(WT1, fs); GEN_LOAD_FREG_FTN(WTH1, fs); gen_op_float_addr_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "addr.ps"; break; case FOP(26, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, ft); GEN_LOAD_FREG_FTN(WTH0, ft); GEN_LOAD_FREG_FTN(WT1, fs); GEN_LOAD_FREG_FTN(WTH1, fs); gen_op_float_mulr_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "mulr.ps"; break; case FOP(28, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT2, fd); GEN_LOAD_FREG_FTN(WTH2, fd); gen_op_float_recip2_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "recip2.ps"; break; case FOP(29, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_recip1_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "recip1.ps"; break; case FOP(30, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_rsqrt1_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "rsqrt1.ps"; break; case FOP(31, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT2, fd); GEN_LOAD_FREG_FTN(WTH2, fd); gen_op_float_rsqrt2_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "rsqrt2.ps"; break; case FOP(32, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_cvts_pu(); GEN_STORE_FTN_FREG(fd, WT2); opn = "cvt.s.pu"; break; case FOP(36, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); gen_op_float_cvtpw_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "cvt.pw.ps"; break; case FOP(40, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); gen_op_float_cvts_pl(); GEN_STORE_FTN_FREG(fd, WT2); opn = "cvt.s.pl"; break; case FOP(44, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); gen_op_float_pll_ps(); GEN_STORE_FTN_FREG(fd, DT2); opn = "pll.ps"; break; case FOP(45, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH1, ft); gen_op_float_plu_ps(); GEN_STORE_FTN_FREG(fd, DT2); opn = "plu.ps"; break; case FOP(46, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); gen_op_float_pul_ps(); GEN_STORE_FTN_FREG(fd, DT2); opn = "pul.ps"; break; case FOP(47, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WTH1, ft); gen_op_float_puu_ps(); GEN_STORE_FTN_FREG(fd, DT2); opn = "puu.ps"; break; case FOP(48, 22): case FOP(49, 22): case FOP(50, 22): case FOP(51, 22): case FOP(52, 22): case FOP(53, 22): case FOP(54, 22): case FOP(55, 22): case FOP(56, 22): case FOP(57, 22): case FOP(58, 22): case FOP(59, 22): case FOP(60, 22): case FOP(61, 22): case FOP(62, 22): case FOP(63, 22): gen_op_cp1_64bitmode(); GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); if (ctx->opcode & (1 << 6)) { gen_cmpabs_ps(func-48, cc); opn = condnames_abs[func-48]; } else { gen_cmp_ps(func-48, cc); opn = condnames[func-48]; } break; default: MIPS_INVAL(opn); generate_exception (ctx, EXCP_RI); return; } switch (optype) { case BINOP: MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]); break; case CMPOP: MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]); break; default: MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]); break; } }
1threat
no results from $wpdb->get_row() Help please : hope someone could help with this... I'm trying to read data from my WP db where I've added a custom table. Hereunder the code: `add_shortcode('modifica','f_modifica'); function f_modifica() { $chimod = $_POST['chimod']; echo $chimod; // OK IT PRINTS THE CORRECT VALUE global $wpdb; $result = $wpdb->get_row("SELECT * FROM $wpdb->mg_nomi WHERE id_nome = %d",'$chimod'); echo $result->id_nome; // NO RESULTS }` Well, here is some additional info: 1- `mg_nomi` is the table name 2- `id_nome` is the primary key (integer 11) 3- `$_POST['chimod']` is the (integer) parameter I receive from another form with submit button and hidden field I need only one row because I have to put values into fields in order to update them. Already tried with: 1- `$wpdb->get_row("SELECT * FROM $wpdb->mg_nomi WHERE id_nome = '$chimod');` 2- `$wpdb->get_row("SELECT * FROM $wpdb->mg_nomi WHERE id_nome = '22');` 3- `$wpdb->get_row($wpdb->prepare(("SELECT * FROM $wpdb->mg_nomi WHERE id_nome = '22'));` 4- `$wpdb->get_row("SELECT * FROM $wpdb->mg_nomi WHERE id_nome = '$chimod',ARRAY_A");` this one with `echo $result['id_nome']` 5-perhaps all the other variations of the above...I think... Already did other query that works great, like ` $wpdb->get_results();` or `$wpdb->delete();` Does anyone have any ideas? Thank you in advance! Cheers. Matteo.
0debug
Display Submenus using botstrap : I am trying to create submenu using the following code : `html` <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul class="nav navbar-nav"> <li class="menu-item dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Drop Down<b class="caret"></b></a> <ul class="dropdown-menu"> <li class="menu-item dropdown dropdown-submenu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Level 1</a> <ul class="dropdown-menu"> <li class="menu-item "> <a href="#">Link 1</a> </li> <li class="menu-item dropdown dropdown-submenu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Level 2</a> <ul class="dropdown-menu"> <li> <a href="#">Link 3</a> </li> </ul> </li> </ul> </li> </ul> </li> </ul> </div> </div> </div> `css` .dropdown-submenu { position:relative; } .dropdown-submenu>.dropdown-menu { top:0; left:100%; margin-top:-6px; margin-left:-1px; -webkit-border-radius:0 6px 6px 6px; -moz-border-radius:0 6px 6px 6px; border-radius:0 6px 6px 6px; } .dropdown-submenu:hover>.dropdown-menu { display:block; } .dropdown-submenu>a:after { display:block; content:" "; float:right; width:0; height:0; border-color:transparent; border-style:solid; border-width:5px 0 5px 5px; border-left-color:#cccccc; margin-top:5px; margin-right:-10px; } .dropdown-submenu:hover>a:after { border-left-color:#ffffff; } .dropdown-submenu.pull-left { float:none; } .dropdown-submenu.pull-left>.dropdown-menu { left:-100%; margin-left:10px; -webkit-border-radius:6px 0 6px 6px; -moz-border-radius:6px 0 6px 6px; border-radius:6px 0 6px 6px; } But it is showing only menu not showing sub-menu. Please help me what I am missing
0debug
CSS target UL by LI class : <p>I am trying to target a UL that has no class, I have no control over the HTML that is output...</p> <pre><code>&lt;ul&gt; &lt;li class="item"&gt;Item 1&lt;/li&gt; &lt;li class="item"&gt;Item 2&lt;/li&gt; &lt;li class="item"&gt;Item 3&lt;/li&gt; &lt;li class="item"&gt;Item 4&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I am trying to apply an image bullet like this....</p> <pre><code>ul { list-style-image: url('sqpurple.gif'); } </code></pre> <p>There are many different UL tags on the page so is there a way I can just target this one?</p>
0debug
I can't access the website project in the folder www on wamp : <p>I am building a website using wordpress on local WAMP. Already running perfect when I go through the server computer. But, when trying to access from other device that are connected on the network LAN, it work. but, the browser brings up a text link without border, background, images etc on my project.</p> <p>What should I do?</p>
0debug
static av_cold void mdct_end(AC3MDCTContext *mdct) { mdct->nbits = 0; av_freep(&mdct->costab); av_freep(&mdct->sintab); av_freep(&mdct->xcos1); av_freep(&mdct->xsin1); av_freep(&mdct->rot_tmp); av_freep(&mdct->cplx_tmp); }
1threat
static int attribute_align_arg av_buffersrc_add_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags) { BufferSourceContext *s = ctx->priv; AVFrame *copy; int ret; if (!frame) { s->eof = 1; return 0; } else if (s->eof) return AVERROR(EINVAL); if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) { switch (ctx->outputs[0]->type) { case AVMEDIA_TYPE_VIDEO: CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height, frame->format); break; case AVMEDIA_TYPE_AUDIO: if (!frame->channel_layout) frame->channel_layout = s->channel_layout; CHECK_AUDIO_PARAM_CHANGE(ctx, s, frame->sample_rate, frame->channel_layout, frame->format); break; default: return AVERROR(EINVAL); } } if (!av_fifo_space(s->fifo) && (ret = av_fifo_realloc2(s->fifo, av_fifo_size(s->fifo) + sizeof(copy))) < 0) return ret; if (!(copy = av_frame_alloc())) return AVERROR(ENOMEM); av_frame_move_ref(copy, frame); if ((ret = av_fifo_generic_write(s->fifo, &copy, sizeof(copy), NULL)) < 0) { av_frame_move_ref(frame, copy); av_frame_free(&copy); return ret; } if ((flags & AV_BUFFERSRC_FLAG_PUSH)) if ((ret = ctx->output_pads[0].request_frame(ctx->outputs[0])) < 0) return ret; return 0; }
1threat
How to resize an image in navigation bar title : <p>I am trying to resize my image so it fits to navigation title. I give it height and weight but it still looks huge <a href="https://i.stack.imgur.com/dyPqb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dyPqb.png" alt="like this"></a></p> <p>and here is my code:</p> <pre><code> override func viewDidLoad() { super.viewDidLoad() let image = UIImage(named: "rollyiha copyi") let imageview = UIImageView(image: image) imageview.frame.size.width = 58 imageview.frame.size.height = 33 imageview.frame.origin = CGPoint(x: 2, y: 8) imageview.sizeToFit() navcik.titleView = imageview } </code></pre> <p>And when I edit the picture to smaller size manually, it loses resolution. How to make it size 58 : 33 with code ?</p>
0debug
how to save a Dataset[row] as text file in spark? : <p>I would like to save a Dataset[Row] as text file with a specific name in specific location. Can anybody help me?</p> <p>I have tried this, but this produce me a folder (LOCAL_FOLDER_TEMP/filename) with a parquet file inside of it: Dataset.write.save(LOCAL_FOLDER_TEMP+filename)</p> <p>Thanks</p>
0debug
static void grlib_apbuart_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { UART *uart = opaque; unsigned char c = 0; addr &= 0xff; switch (addr) { case DATA_OFFSET: case DATA_OFFSET + 3: c = value & 0xFF; qemu_chr_fe_write(uart->chr, &c, 1); return; case STATUS_OFFSET: return; case CONTROL_OFFSET: uart->control = value; return; case SCALER_OFFSET: return; default: break; } trace_grlib_apbuart_writel_unknown(addr, value); }
1threat
Android studio google maps activity error creating map markers on Create but works with button? : Im working on an android application in android studio, and the rest of the application is developed including the map activity. the map markers get their location from a web API that returns the lat and long in a JSON format. the code works perfectly doing everything i want when it is inside the onClickListener and the corresponding button is pressed, but i want the markers to load instantly in onCreate so that the user doesn't have to press a button to load the markers. however when i take the exact same code and put it in oncreate it doesn't work at all, the errorListener is called, but when i try print the error message it is blank??? here is the code (thanks in advance) `loadMachines.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { StringRequest st = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject jsonarray = new JSONObject(response); JSONArray machinesArray = jsonarray.getJSONArray("machines"); for (int i = 0; i < machinesArray.length();i++){ JSONObject machineProperties = machinesArray.getJSONObject(i); String addr1 = machineProperties.getString("address_1"); String addr2 = machineProperties.getString("address_2"); String lat = machineProperties.getString("lat"); String lng = machineProperties.getString("lng"); MarkerOptions options = new MarkerOptions().title(addr1 + " " + addr2).position(new LatLng(Double.parseDouble(lat),Double.parseDouble(lng))); mGoogleMap.addMarker(options); } Toast.makeText(MapActivity.this, "Success, we have updated the locations, zoom out to view!", Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { if (error.networkResponse.statusCode == 500) { Toast.makeText(MapActivity.this , "Internal Server Error", Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(MapActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show(); } } }) { protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> params = new HashMap<String, String>(); params.put("key", "****"); params.put("token", tokenString); params.put("user_lat", String.valueOf(getLatitude())); params.put("user_lng", String.valueOf(getLatitude())); return params; } }; MySingleton.getInstance(MapActivity.this).addToRequestQueue(st); } });`
0debug
yuv2gray16_2_c_template(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { int yalpha1 = 4095 - yalpha; \ int i; for (i = 0; i < (dstW >> 1); i++) { const int i2 = 2 * i; int Y1 = (buf0[i2 ] * yalpha1 + buf1[i2 ] * yalpha) >> 11; int Y2 = (buf0[i2+1] * yalpha1 + buf1[i2+1] * yalpha) >> 11; output_pixel(&dest[2 * i2 + 0], Y1); output_pixel(&dest[2 * i2 + 2], Y2); } }
1threat
counting the zero's in the the factorial number ,please the check the error : Compilation Errors Main.java:18: error: method mod in class BigInteger cannot be applied to given types; r=factorialans.mod(10); ^ required: BigInteger found: int reason: actual argument int cannot be converted to BigInteger by method invocation conversion Main.java:22: error: method divide in class BigInteger cannot be applied to given types; factorialans = factorialans.divide(10); ^ required: BigInteger found: int reason: actual argument int cannot be converted to BigInteger by method invocation conversion 2 errors -------------------------------------------------------------------------------- import java.util.Scanner; import java.math.BigInteger; class Main { public static void main(String args[]) { BigInteger r; BigInteger factorialans=new BigInteger("1"); int n,i,count=0; Scanner sc=new Scanner(System.in); n=sc.nextInt(); //factorial... for(i=n;i>0;i--){ factorialans=factorialans.multiply(BigInteger.valueOf(i)); } System.out.print(factorialans); while(!factorialans.equals(0)){ r=factorialans.mod(10); if(r.equals(0)){ count++; } factorialans = factorialans.divide(10); } System.out.print(count); } }
0debug
static av_cold int aac_encode_end(AVCodecContext *avctx) { AACEncContext *s = avctx->priv_data; ff_mdct_end(&s->mdct1024); ff_mdct_end(&s->mdct128); ff_psy_end(&s->psy); ff_psy_preprocess_end(s->psypp); av_freep(&s->samples); av_freep(&s->cpe); return 0; }
1threat
Assigned data to out of array allocation but program show output with a buffer overrun has occurred : <p>I wrote a sample program like below:<br> when program execution finish this error occur "A buffer overrun has occurred".<br> I assigned data to out of array allocation but output show i mentioned in code.<br> Program compile and run on VS2010 </p> <pre><code>void check(int arr[]) { arr[0]=100; arr[8]=103; arr[10]=102; cout&lt;&lt;arr[10]&lt;&lt;endl; // output show 102 } int main() { int arr[] = {2, 3, 4, 10, 40, 56, 69, 89, 99}; check(arr); arr[10]=102; cout&lt;&lt;arr[10]&lt;&lt;endl; // output show 102 return 0; } </code></pre>
0debug
TypeScript array with minimum length : <p>How can you create a type in TypeScript that only accepts arrays with two or more elements?</p> <pre><code>needsTwoOrMore(["onlyOne"]) // should have error needsTwoOrMore(["one", "two"]) // should be allowed needsTwoOrMore(["one", "two", "three"]) // should also be allowed </code></pre>
0debug
How to make table row group color(even - odd) with jquery : How to make table in jquey like [this pic :][1] I know this is simple, but i hope, someone can helpme. With the good logic. Thanks before [1]: https://i.stack.imgur.com/RvrvV.png
0debug
static void flush_packet(AVFormatContext *ctx, int stream_index, int64_t pts, int64_t dts, int64_t scr) { MpegMuxContext *s = ctx->priv_data; StreamInfo *stream = ctx->streams[stream_index]->priv_data; uint8_t *buf_ptr; int size, payload_size, startcode, id, stuffing_size, i, header_len; int packet_size; uint8_t buffer[128]; int zero_trail_bytes = 0; int pad_packet_bytes = 0; id = stream->id; #if 0 printf("packet ID=%2x PTS=%0.3f\n", id, pts / 90000.0); #endif buf_ptr = buffer; if (((s->packet_number % s->pack_header_freq) == 0)) { size = put_pack_header(ctx, buf_ptr, scr); buf_ptr += size; if (s->is_vcd) { if (stream->packet_number==0) { size = put_system_header(ctx, buf_ptr, id); buf_ptr += size; } } else { if ((s->packet_number % s->system_header_freq) == 0) { size = put_system_header(ctx, buf_ptr, 0); buf_ptr += size; } } } size = buf_ptr - buffer; put_buffer(&ctx->pb, buffer, size); packet_size = s->packet_size - size; if (s->is_vcd && id == AUDIO_ID) zero_trail_bytes += 20; if (s->is_vcd && stream->packet_number==0) { pad_packet_bytes = packet_size - zero_trail_bytes; } packet_size -= pad_packet_bytes + zero_trail_bytes; if (packet_size > 0) { packet_size -= 6; if (s->is_mpeg2) { header_len = 3; } else { header_len = 0; } if (pts != AV_NOPTS_VALUE) { if (dts != pts) header_len += 5 + 5; else header_len += 5; } else { if (!s->is_mpeg2) header_len++; } payload_size = packet_size - header_len; if (id < 0xc0) { startcode = PRIVATE_STREAM_1; payload_size -= 4; if (id >= 0xa0) payload_size -= 3; } else { startcode = 0x100 + id; } stuffing_size = payload_size - stream->buffer_ptr; if (stuffing_size < 0) stuffing_size = 0; put_be32(&ctx->pb, startcode); put_be16(&ctx->pb, packet_size); if (!s->is_mpeg2) for(i=0;i<stuffing_size;i++) put_byte(&ctx->pb, 0xff); if (s->is_mpeg2) { put_byte(&ctx->pb, 0x80); if (pts != AV_NOPTS_VALUE) { if (dts != pts) { put_byte(&ctx->pb, 0xc0); put_byte(&ctx->pb, header_len - 3 + stuffing_size); put_timestamp(&ctx->pb, 0x03, pts); put_timestamp(&ctx->pb, 0x01, dts); } else { put_byte(&ctx->pb, 0x80); put_byte(&ctx->pb, header_len - 3 + stuffing_size); put_timestamp(&ctx->pb, 0x02, pts); } } else { put_byte(&ctx->pb, 0x00); put_byte(&ctx->pb, header_len - 3 + stuffing_size); } } else { if (pts != AV_NOPTS_VALUE) { if (dts != pts) { put_timestamp(&ctx->pb, 0x03, pts); put_timestamp(&ctx->pb, 0x01, dts); } else { put_timestamp(&ctx->pb, 0x02, pts); } } else { put_byte(&ctx->pb, 0x0f); } } if (startcode == PRIVATE_STREAM_1) { put_byte(&ctx->pb, id); if (id >= 0xa0) { put_byte(&ctx->pb, 7); put_be16(&ctx->pb, 4); put_byte(&ctx->pb, stream->lpcm_header[0]); put_byte(&ctx->pb, stream->lpcm_header[1]); put_byte(&ctx->pb, stream->lpcm_header[2]); } else { put_byte(&ctx->pb, stream->nb_frames); put_be16(&ctx->pb, stream->frame_start_offset); } } if (s->is_mpeg2) for(i=0;i<stuffing_size;i++) put_byte(&ctx->pb, 0xff); put_buffer(&ctx->pb, stream->buffer, payload_size - stuffing_size); } if (pad_packet_bytes > 0) put_padding_packet(ctx,&ctx->pb, pad_packet_bytes); for(i=0;i<zero_trail_bytes;i++) put_byte(&ctx->pb, 0x00); put_flush_packet(&ctx->pb); s->packet_number++; stream->packet_number++; stream->nb_frames = 0; stream->frame_start_offset = 0; }
1threat
uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap, uint64_t start, uint64_t count) { return hbitmap_serialization_size(bitmap->bitmap, start, count); }
1threat
How do I write a function that writes falling distance, I need to write d = 1/2 gt^2 function inside loop that goes from 1-10 for 1sec 16 for 2sec 64? : def falling_distance( fallingTime ): distance = ( 1 / 2 ) * gravity * fallingTime ** 2 return distance def main(): print( "Time\tFalling Distance\n=========) for currentTime in range( 1,10 ): print( currentTime, "\t", format( falling Distance( currentTime ), ",2f" ) ) main(): ________________________________________________________________________________This is what I have so far, any help would be much appreciated. Thanks.
0debug
static void become_daemon(const char *pidfile) { #ifndef _WIN32 pid_t pid, sid; pid = fork(); if (pid < 0) { exit(EXIT_FAILURE); } if (pid > 0) { exit(EXIT_SUCCESS); } if (pidfile) { if (!ga_open_pidfile(pidfile)) { g_critical("failed to create pidfile"); exit(EXIT_FAILURE); } } umask(0); sid = setsid(); if (sid < 0) { goto fail; } if ((chdir("/")) < 0) { goto fail; } close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); return; fail: unlink(pidfile); g_critical("failed to daemonize"); exit(EXIT_FAILURE); #endif }
1threat
Is there a tool that let's you try big query for free : <p>If you are an individual in EU without a business you can't try it for free on google cloud platform. </p> <p>Is there another tool out there that let's you try big query for free? Even something that can run locally and you just play around with small datasets. </p>
0debug
sql insert varchr into image : I have tow table the first one contain ( image_path varchar , id uniqueidentifier) the second (image image , id unique identifier ) how can I insert the image_path in image when I use cast or convert to varbinary then to image it Mack all field the same value and when I use bulk I must insert the path manually do u have query to this problem
0debug
Need help creating script to take usernames and run it through AD, and output address : <p>I want to create a script to help me search 2000+ usernames on AD, and output their Address information. I have a list of usernames on a excel sheet. Any suggestions where to start? Thanks</p>
0debug
Understanding Gaussian Mixture Models : <p>I am trying to understand the results from the scikit-learn gaussian mixture model implementation. Take a look at the following example:</p> <pre><code>#!/opt/local/bin/python import numpy as np import matplotlib.pyplot as plt from sklearn.mixture import GaussianMixture # Define simple gaussian def gauss_function(x, amp, x0, sigma): return amp * np.exp(-(x - x0) ** 2. / (2. * sigma ** 2.)) # Generate sample from three gaussian distributions samples = np.random.normal(-0.5, 0.2, 2000) samples = np.append(samples, np.random.normal(-0.1, 0.07, 5000)) samples = np.append(samples, np.random.normal(0.2, 0.13, 10000)) # Fit GMM gmm = GaussianMixture(n_components=3, covariance_type="full", tol=0.001) gmm = gmm.fit(X=np.expand_dims(samples, 1)) # Evaluate GMM gmm_x = np.linspace(-2, 1.5, 5000) gmm_y = np.exp(gmm.score_samples(gmm_x.reshape(-1, 1))) # Construct function manually as sum of gaussians gmm_y_sum = np.full_like(gmm_x, fill_value=0, dtype=np.float32) for m, c, w in zip(gmm.means_.ravel(), gmm.covariances_.ravel(), gmm.weights_.ravel()): gmm_y_sum += gauss_function(x=gmm_x, amp=w, x0=m, sigma=np.sqrt(c)) # Normalize so that integral is 1 gmm_y_sum /= np.trapz(gmm_y_sum, gmm_x) # Make regular histogram fig, ax = plt.subplots(nrows=1, ncols=1, figsize=[8, 5]) ax.hist(samples, bins=50, normed=True, alpha=0.5, color="#0070FF") ax.plot(gmm_x, gmm_y, color="crimson", lw=4, label="GMM") ax.plot(gmm_x, gmm_y_sum, color="black", lw=4, label="Gauss_sum") # Annotate diagram ax.set_ylabel("Probability density") ax.set_xlabel("Arbitrary units") # Draw legend plt.legend() plt.show() </code></pre> <p><a href="https://i.stack.imgur.com/LPjll.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LPjll.png" alt="Resulting plot from the code above"></a></p> <p>Here I first generate a sample distribution constructed from gaussians, then fit a gaussian mixture model to these data. Next, I want to calculate the probability for some given input. Conveniently, the scikit implementation offer the <code>score_samples</code> method to do just that. Now I am trying to understand these results. I always thought, that I can just take the parameters of the gaussians from the GMM fit and construct the very same distribution by summing over them and then normalising the integral to 1. However, as you can see in the plot, the samples drawn from the <code>score_samples</code> method fit perfectly (red line) to the original data (blue histogram), the manually constructed distribution (black line) does not. I would like to understand where my thinking went wrong and why I can't construct the distribution myself by summing the gaussians as given by the GMM fit!?! Thanks a lot for any input!</p>
0debug
When appending new members to an existing array of hash in this manner, how can I check whether it's indeed a key -> value pair that I inserted? : I have one of the weirdest of problems, and I spent too much time trying to figure out where I am making an error. I am trying to debug an issue *(not my source entirely)*. I have a package I made which is a wrapper for `IO::Socket` to create socket. package mysock::my_sock; use strict; use warnings; use Scalar::Util 'refaddr'; use IO::Docket; use IO::Select; my %socket; my $flag = 0; sub new { my $class = shift; my $args = shift; my $sock = new IO::Socket::INET(%{args}); if (!$sock) { warn "Cannot create socket: $!/$@\n" if ($flag); return undef; } # Initialize some vars for class $socket{ refaddr $obj }->{_SOCKET_} = $sock; $socket{ refaddr $obj }->{_SELECT_} = $sel; $socket{ refaddr $obj }->{_EOL_} = $eol; $socket{ refaddr $obj }->{_BUFFER_} = {}; return $obj; } 1; } Now when I call/use my package in my script this way everything **works fine** : use warnings; use mysock::my_sock; sub new { my $var = mysock::my_sock->new({ ip => '10.109.157.249', # Hard coded IP addr port => '2002', # Hard coded port reuse => 1, eol =>'' }) or die "unable to connect $!\n"; return var; } # This sub will go to another package, putting it here for brevity. my $box = new(); The above code is straight forward. I have created a socket handle successfully. **No** problems so far. But when I modify my new function this way in my script so that i could pass the ip and port, i can't get it to work no matter what i do: sub new { my ($ip_, $port_) = @_; my @AoH = ( { reuse => 1, eol =>'' } ); $AoH[0]{ip} = $ip_ ; #insert key => value to my AoH $AoH[0]{port} = $port_ ; #insert key => value to my AoH my $var = mysock::my_sock->new($AoH[0]) or die "unable to connect- $!\n"; return $var; } my $box = new('10.150.180.245','2011'); # pass ip/port as args. I tried passing `my $var = mysock::my_sock->new($AoH)` or `my $var = mysock::my_sock->new($AoH)` and even `my $var = mysock::my_sock->new(\@AoH)`. None of these works. When I dump the `$args` that I get inside my package, for both cases it prints a hash: $VAR1 = { "reuse" => 1, "ip" => "10.63.122.49", "port" => 6002, "eol" => "" }; I am using perl debugger, and it shows the same hash above when i run my script either way, which is what confuses me. If they are the same, then why won't the second method work? Could the hash somehow gotten over written? I dunno what's gone wrong. `$sock` in my package doesn't get the socket, and I couldn't get `IO::Socket` to bless me w/ a socket call when i use my modified function where i pass the params so i return `undef`. Can you help?
0debug
av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, enum FFLPCType lpc_type) { s->blocksize = blocksize; s->max_order = max_order; s->lpc_type = lpc_type; if (lpc_type == FF_LPC_TYPE_LEVINSON) { s->windowed_samples = av_mallocz((blocksize + max_order + 2) * sizeof(*s->windowed_samples)); if (!s->windowed_samples) return AVERROR(ENOMEM); } else { s->windowed_samples = NULL; } s->lpc_apply_welch_window = lpc_apply_welch_window_c; s->lpc_compute_autocorr = lpc_compute_autocorr_c; if (HAVE_MMX) ff_lpc_init_x86(s); return 0; }
1threat
How to safely render html in react? : <p>I've got some user generated html markup from a text area and I'd like to render it on another part of the screen. The markup is saved as a string in the props of the component. </p> <p>I don't want to use dangerouslysethtml for obvious reasons. Is there a parser such as <a href="https://github.com/chjj/marked" rel="noreferrer">marked</a> but for html so that it strips out script tags and other invalid html. </p>
0debug
Kotlin, smart cast is impossible because of complex expression : <p>I have this code:</p> <pre><code>// allocate one mesh pScene.mNumMeshes = 1 pScene.mMeshes = mutableListOf(AiMesh()) val pMesh = pScene.mMeshes[0] </code></pre> <p>Where <code>mMeshes</code> is a parameter of type </p> <p><code>var mMeshes: MutableList&lt;AiMesh&gt;? = null,</code></p> <p>Compilers complains on the last row, where I try to declare <code>pMesh</code></p> <blockquote> <p>Smart cast to <code>MutableList&lt;AiMesh&gt;</code> is impossible because <code>pScene.mMeshes</code> is a complex expression</p> </blockquote> <p>What's the problem?</p>
0debug
Slicing a tensor by using indices in Tensorflow : <p>Basically I have a 2d array and I want to do this nice numpy-like thing</p> <pre><code>noise_spec[:rows,:cols] </code></pre> <p>in Tensorflow. Here rows and cols are just two integers.</p>
0debug
How to extract and display field in android : <p>Please fins Main.java code below</p> <pre><code>public class Main extends Activity implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); findViewById(R.id.my_button).setOnClickListener(this); } @Override public void onClick(View arg0) { Button b = (Button)findViewById(R.id.my_button); b.setClickable(false); new LongRunningGetIO().execute(); } private class LongRunningGetIO extends AsyncTask &lt;Void, Void, String&gt; { protected String getASCIIContentFromEntity(HttpEntity entity) throws IllegalStateException, IOException { InputStream in = entity.getContent(); StringBuffer out = new StringBuffer(); int n = 1; while (n&gt;0) { byte[] b = new byte[4096]; n = in.read(b); if (n&gt;0) out.append(new String(b, 0, n)); } return out.toString(); } @Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet("http://191.166.1.88:2000"); String text = null; try { HttpResponse response = httpClient.execute(httpGet, localContext); HttpEntity entity = response.getEntity(); text = getASCIIContentFromEntity(entity); } catch (Exception e) { return e.getLocalizedMessage(); } return text; } protected void onPostExecute(String results) { if (results!=null) { EditText et = (EditText)findViewById(R.id.my_edit); et.setText(results); } Button b = (Button)findViewById(R.id.my_button); b.setClickable(true); } } } </code></pre> <p>I am getting the JSON data from REST API, it is as shown below</p> <pre><code> {"Tm":{"Time": "Mon Nov 20 12:45:59 IST 2015"},"Name": {"Host": "u1", "IP": "190.166.169.137"},"Speed":{"cpu": 2494.259033203125}} </code></pre> <p>How to extract only Nama of Host that is "u1" and display in text box in android. I am new to it please help</p>
0debug
Organise web portal database : <p>I wanna build a web app which will store a lot of data for each user, so I've got a question, which solution is better:</p> <ul> <li>create a separate database for each user</li> <li>create one big database and in every table add a column with user id</li> <li>?another option?</li> </ul> <p>Thanks!</p>
0debug
av_cold int ff_dct_common_init(MpegEncContext *s) { ff_dsputil_init(&s->dsp, s->avctx); ff_videodsp_init(&s->vdsp, 8); s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c; s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c; s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; if (s->flags & CODEC_FLAG_BITEXACT) s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; #if ARCH_X86 ff_MPV_common_init_x86(s); #elif ARCH_ALPHA ff_MPV_common_init_axp(s); #elif ARCH_ARM ff_MPV_common_init_arm(s); #elif HAVE_ALTIVEC ff_MPV_common_init_altivec(s); #elif ARCH_BFIN ff_MPV_common_init_bfin(s); #endif if (s->alternate_scan) { ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan); } else { ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct); } ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); return 0; }
1threat
static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat, int dstFormat, int srcW, int srcH, int dstW, int dstH, int flags){ uint8_t *src[3]; uint8_t *dst[3]; uint8_t *out[3]; int srcStride[3], dstStride[3]; int i; uint64_t ssdY, ssdU, ssdV; struct SwsContext *srcContext, *dstContext, *outContext; int res; res = 0; for(i=0; i<3; i++){ if(srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24) srcStride[i]= srcW*3; else srcStride[i]= srcW*4; if(dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24) dstStride[i]= dstW*3; else dstStride[i]= dstW*4; src[i]= (uint8_t*) malloc(srcStride[i]*srcH); dst[i]= (uint8_t*) malloc(dstStride[i]*dstH); out[i]= (uint8_t*) malloc(refStride[i]*h); if ((src[i] == NULL) || (dst[i] == NULL) || (out[i] == NULL)) { perror("Malloc"); res = -1; goto end; } } dstContext = outContext = NULL; srcContext= sws_getContext(w, h, PIX_FMT_YUV420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL); if (srcContext == NULL) { fprintf(stderr, "Failed to get %s ---> %s\n", sws_format_name(PIX_FMT_YUV420P), sws_format_name(srcFormat)); res = -1; goto end; } dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL); if (dstContext == NULL) { fprintf(stderr, "Failed to get %s ---> %s\n", sws_format_name(srcFormat), sws_format_name(dstFormat)); res = -1; goto end; } outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUV420P, flags, NULL, NULL, NULL); if (outContext == NULL) { fprintf(stderr, "Failed to get %s ---> %s\n", sws_format_name(dstFormat), sws_format_name(PIX_FMT_YUV420P)); res = -1; goto end; } sws_scale(srcContext, ref, refStride, 0, h , src, srcStride); sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride); sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride); #if defined(ARCH_X86) asm volatile ("emms\n\t"); #endif ssdY= getSSD(ref[0], out[0], refStride[0], refStride[0], w, h); ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1); ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1); if(srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0; ssdY/= w*h; ssdU/= w*h/4; ssdV/= w*h/4; if(ssdY>100 || ssdU>100 || ssdV>100){ printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5lld,%5lld,%5lld\n", sws_format_name(srcFormat), srcW, srcH, sws_format_name(dstFormat), dstW, dstH, flags, ssdY, ssdU, ssdV); } end: sws_freeContext(srcContext); sws_freeContext(dstContext); sws_freeContext(outContext); for(i=0; i<3; i++){ free(src[i]); free(dst[i]); free(out[i]); } return res; }
1threat
.NET Core TestServer returning 404 when using Startup class defined in unit test project : <p>I've a basic .net core api web app and a unit test project that uses a TestServer to make http requests.</p> <p>I've a TestStartup class that subclassed the Startup class in the api project.</p> <p>If the Startup class is in the unit test project i get a 404 response. If the TestStartup class is moved to the api project i get a 200 reponse.</p> <p>Api Project</p> <p>Api.csproj</p> <pre><code>&lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt; </code></pre> <p>Program.cs</p> <pre><code>public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt; WebHost.CreateDefaultBuilder(args) .UseStartup&lt;Startup&gt;(); } </code></pre> <p>Startup.cs</p> <pre><code>public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseMvc(); } } </code></pre> <p>TestController.cs</p> <pre><code>public class TestController : ControllerBase { [HttpGet("test")] public ObjectResult Get() { return Ok("data"); } } </code></pre> <p>Unit Test Project</p> <p>Tests.csproj</p> <pre><code>&lt;PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" /&gt; &lt;PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.1.2" /&gt; &lt;PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" /&gt; &lt;PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" /&gt; &lt;PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" /&gt; &lt;PackageReference Include="NUnit" Version="3.10.1" /&gt; &lt;PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /&gt; </code></pre> <p>Tests.cs</p> <pre><code>[TestFixture] public class Tests { [Test] public async Task Test() { var server = new TestServer(WebHost.CreateDefaultBuilder() .UseStartup&lt;TestStartup&gt;() .UseEnvironment("Development")); var response = await server.CreateClient().GetAsync("test"); } } </code></pre> <p>Startup.cs</p> <pre><code>public class TestStartup : Startup { } </code></pre>
0debug
In c++, when accessing member variable in a class, any difference between using a.var and a.var() : Just for example Class A{ public: int a; }; int main(){ A test; int b = test.a; int c = test.a(); } My question is that when accessing the member variable of a class, is there any difference between using test.a and test.a()?
0debug
static int openfile(char *name, int flags, QDict *opts) { Error *local_err = NULL; if (qemuio_blk) { fprintf(stderr, "file open already, try 'help close'\n"); QDECREF(opts); return 1; } qemuio_blk = blk_new_open("hda", name, NULL, opts, flags, &local_err); if (!qemuio_blk) { fprintf(stderr, "%s: can't open%s%s: %s\n", progname, name ? " device " : "", name ?: "", error_get_pretty(local_err)); error_free(local_err); return 1; } bs = blk_bs(qemuio_blk); if (bdrv_is_encrypted(bs)) { char password[256]; printf("Disk image '%s' is encrypted.\n", name); if (qemu_read_password(password, sizeof(password)) < 0) { error_report("No password given"); goto error; } if (bdrv_set_key(bs, password) < 0) { error_report("invalid password"); goto error; } } return 0; error: blk_unref(qemuio_blk); qemuio_blk = NULL; return 1; }
1threat
void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, MemHotplugState *state) { MachineState *machine = MACHINE(qdev_get_machine()); state->dev_count = machine->ram_slots; if (!state->dev_count) { return; } state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count); memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state, "acpi-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN); memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io); }
1threat
Android Studio - CRLF vs LF for a Git-based multiplatform project : <p>I'm working on an Android project involving multiple developers, some of which are on Windows, others Linux/MacOS. Since I'm on Windows, I've been instructed to configure Git as follows to avoid issues:</p> <pre><code>autocrlf = true safecrlf = true </code></pre> <p>This works mostly fine. Any .java/XML/etc files I create in Android Studio are in CRLF, get converted to LF when I push them into the repo, then back into CRLF when I pull changes into my local copy. Problem is, some types of files, like vector drawable assets, get generated in LF instead, for some reason. So when I try to add them to Git, I get the "irreversible conversion" error:</p> <p><a href="https://i.stack.imgur.com/Ufo1A.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ufo1A.png" alt="enter image description here"></a> I know I could set <code>safecrlf = warn</code>, but from what I understand, this carries a risk of corrupting binary files if Git mistakes them for text files, so I'm looking for a safer solution. For now I'm manually editing vector assets into CRLF before I add them to Git, which avoids the above error message, but gets tedious having to repeat the process for every file. Any way to force Android Studio to generate all local files in CRLF?</p>
0debug
Use href then execute a PHP function : <p>As a disclaimer, I'm quite new to web development and even before I posted this, I have spent hours looking for answers but everything I have read did not help on what I want to do. </p> <p>I'm basically trying to redirect to a certain page and then execute a php function which also require a variable to be pass to it and is inside a class.</p> <p>I've read about ajax but people have said that theres no point using it if I want to redirect to another page anyway as its only good to use if you just want to reload a portion of the page.</p> <p>The most simplistic way I can explain on what I want to do is, when I click on an image, I would like for a new page to be open and then in that said page is all the things about that image. For example, description about it, a short vid and maybe a comment section regarding the image clicked.</p> <p>Please explain if what I'm trying to do is not possible and if so, please point me in the right direction as to what might be a better way of doing this.</p>
0debug
static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MpegEncContext *s = avctx->priv_data; int i; AVFrame *pict = data; int slice_count; const uint8_t *slices_hdr = NULL; av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size); if (buf_size == 0) { return 0; } if(!avctx->slice_count){ slice_count = (*buf++) + 1; buf_size--; slices_hdr = buf + 4; buf += 8 * slice_count; buf_size -= 8 * slice_count; if (buf_size <= 0) return AVERROR_INVALIDDATA; }else slice_count = avctx->slice_count; for(i=0; i<slice_count; i++){ unsigned offset = get_slice_offset(avctx, slices_hdr, i); int size, size2; if (offset >= buf_size) return AVERROR_INVALIDDATA; if(i+1 == slice_count) size= buf_size - offset; else size= get_slice_offset(avctx, slices_hdr, i+1) - offset; if(i+2 >= slice_count) size2= buf_size - offset; else size2= get_slice_offset(avctx, slices_hdr, i+2) - offset; if (size <= 0 || size2 <= 0 || offset + FFMAX(size, size2) > buf_size) return AVERROR_INVALIDDATA; if(rv10_decode_packet(avctx, buf+offset, size, size2) > 8*size) i++; } if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){ ff_er_frame_end(s); ff_MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict = s->current_picture_ptr->f; } else if (s->last_picture_ptr != NULL) { *pict = s->last_picture_ptr->f; } if(s->last_picture_ptr || s->low_delay){ *got_frame = 1; ff_print_debug_info(s, pict); } s->current_picture_ptr= NULL; } return avpkt->size; }
1threat
Why can IntelliJ detect missing semi-colons and Java compiler can't? : <p>I was wondering why that's the case. How and why IntelliJ is able to detect missing semi-colons and Java compiler can't? Is there a case where IntelliJ is wrong and there is no way to actually detect missing semicolon? I read similar question discussing C and C++, there are pointers which complicate things, but Java seems simpler in that matter. </p>
0debug
static int dvvideo_init(AVCodecContext *avctx) { DVVideoContext *s = avctx->priv_data; DSPContext dsp; static int done=0; int i, j; if (!done) { VLC dv_vlc; uint16_t new_dv_vlc_bits[NB_DV_VLC*2]; uint8_t new_dv_vlc_len[NB_DV_VLC*2]; uint8_t new_dv_vlc_run[NB_DV_VLC*2]; int16_t new_dv_vlc_level[NB_DV_VLC*2]; done = 1; dv_vlc_map = av_mallocz_static(DV_VLC_MAP_LEV_SIZE*DV_VLC_MAP_RUN_SIZE*sizeof(struct dv_vlc_pair)); if (!dv_vlc_map) return -ENOMEM; dv_anchor = av_malloc(12*27*sizeof(void*)); if (!dv_anchor) { return -ENOMEM; } for (i=0; i<12*27; i++) dv_anchor[i] = (void*)(size_t)i; for (i=0, j=0; i<NB_DV_VLC; i++, j++) { new_dv_vlc_bits[j] = dv_vlc_bits[i]; new_dv_vlc_len[j] = dv_vlc_len[i]; new_dv_vlc_run[j] = dv_vlc_run[i]; new_dv_vlc_level[j] = dv_vlc_level[i]; if (dv_vlc_level[i]) { new_dv_vlc_bits[j] <<= 1; new_dv_vlc_len[j]++; j++; new_dv_vlc_bits[j] = (dv_vlc_bits[i] << 1) | 1; new_dv_vlc_len[j] = dv_vlc_len[i] + 1; new_dv_vlc_run[j] = dv_vlc_run[i]; new_dv_vlc_level[j] = -dv_vlc_level[i]; } } init_vlc(&dv_vlc, TEX_VLC_BITS, j, new_dv_vlc_len, 1, 1, new_dv_vlc_bits, 2, 2, 0); dv_rl_vlc = av_malloc(dv_vlc.table_size * sizeof(RL_VLC_ELEM)); if (!dv_rl_vlc) { av_free(dv_anchor); return -ENOMEM; } for(i = 0; i < dv_vlc.table_size; i++){ int code= dv_vlc.table[i][0]; int len = dv_vlc.table[i][1]; int level, run; if(len<0){ run= 0; level= code; } else { run= new_dv_vlc_run[code] + 1; level= new_dv_vlc_level[code]; } dv_rl_vlc[i].len = len; dv_rl_vlc[i].level = level; dv_rl_vlc[i].run = run; } free_vlc(&dv_vlc); for (i = 0; i < NB_DV_VLC - 1; i++) { if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE) continue; #ifdef DV_CODEC_TINY_TARGET if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE) continue; #endif if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0) continue; dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc = dv_vlc_bits[i] << (!!dv_vlc_level[i]); dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size = dv_vlc_len[i] + (!!dv_vlc_level[i]); } for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) { #ifdef DV_CODEC_TINY_TARGET for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) { if (dv_vlc_map[i][j].size == 0) { dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + dv_vlc_map[0][j].size; } } #else for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) { if (dv_vlc_map[i][j].size == 0) { dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + dv_vlc_map[0][j].size; } dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc = dv_vlc_map[i][j].vlc | 1; dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size = dv_vlc_map[i][j].size; } #endif } } dsputil_init(&dsp, avctx); s->get_pixels = dsp.get_pixels; s->fdct[0] = dsp.fdct; s->idct_put[0] = dsp.idct_put; for (i=0; i<64; i++) s->dv_zigzag[0][i] = dsp.idct_permutation[ff_zigzag_direct[i]]; s->fdct[1] = dsp.fdct248; s->idct_put[1] = simple_idct248_put; if(avctx->lowres){ for (i=0; i<64; i++){ int j= ff_zigzag248_direct[i]; s->dv_zigzag[1][i] = dsp.idct_permutation[(j&7) + (j&8)*4 + (j&48)/2]; } }else memcpy(s->dv_zigzag[1], ff_zigzag248_direct, 64); dv_build_unquantize_tables(s, dsp.idct_permutation); if (dv_codec_profile(avctx)) avctx->pix_fmt = dv_codec_profile(avctx)->pix_fmt; avctx->coded_frame = &s->picture; s->avctx= avctx; return 0; }
1threat
Using regex to restrict user input : <p>There is a particular field in my application where a user will be asked to enter a time for a job to be run (like HH:MM) for the MM field, I want the user to enter a number in the range 0-59 ONLY. How should I pattern match this with regexp ?</p>
0debug
How do i display the output of a "while loop" in a table? : I don't even have an idea of where to start for this. I need to display 100 numbers in a table and would like to use a while loop to do so. is there a "shortcut" to doing this?
0debug
int ff_xvid_rate_control_init(MpegEncContext *s){ char *tmp_name; int fd, i; xvid_plg_create_t xvid_plg_create = { 0 }; xvid_plugin_2pass2_t xvid_2pass2 = { 0 }; fd=av_tempfile("xvidrc.", &tmp_name, 0, s->avctx); if (fd == -1) { av_log(NULL, AV_LOG_ERROR, "Can't create temporary pass2 file.\n"); return -1; } for(i=0; i<s->rc_context.num_entries; i++){ static const char frame_types[] = " ipbs"; char tmp[256]; RateControlEntry *rce; rce= &s->rc_context.entry[i]; snprintf(tmp, sizeof(tmp), "%c %d %d %d %d %d %d\n", frame_types[rce->pict_type], (int)lrintf(rce->qscale / FF_QP2LAMBDA), rce->i_count, s->mb_num - rce->i_count - rce->skip_count, rce->skip_count, (rce->i_tex_bits + rce->p_tex_bits + rce->misc_bits+7)/8, (rce->header_bits+rce->mv_bits+7)/8); if (write(fd, tmp, strlen(tmp)) < 0) { av_log(NULL, AV_LOG_ERROR, "Error %s writing 2pass logfile\n", strerror(errno)); return AVERROR(errno); } } xvid_2pass2.version= XVID_MAKE_VERSION(1,1,0); xvid_2pass2.filename= tmp_name; xvid_2pass2.bitrate= s->avctx->bit_rate; xvid_2pass2.vbv_size= s->avctx->rc_buffer_size; xvid_2pass2.vbv_maxrate= s->avctx->rc_max_rate; xvid_2pass2.vbv_initial= s->avctx->rc_initial_buffer_occupancy; xvid_plg_create.version= XVID_MAKE_VERSION(1,1,0); xvid_plg_create.fbase= s->avctx->time_base.den; xvid_plg_create.fincr= s->avctx->time_base.num; xvid_plg_create.param= &xvid_2pass2; if(xvid_plugin_2pass2(NULL, XVID_PLG_CREATE, &xvid_plg_create, &s->rc_context.non_lavc_opaque)<0){ av_log(NULL, AV_LOG_ERROR, "xvid_plugin_2pass2 failed\n"); return -1; } return 0; }
1threat
Return "raw" json in ASP.NET Core 2.0 Web Api : <p>The standard way AFAIK to return data in ASP.NET Core Web Api is by using <code>IActionResult</code> and providing e.g. an <code>OkObject</code> result. This works fine with objects, but what if I have obtained a JSON string somehow, and I just want to return that JSON back to the caller?</p> <p>e.g. </p> <pre><code>public IActionResult GetSomeJSON() { return Ok("{ \"name\":\"John\", \"age\":31, \"city\":\"New York\" }"); } </code></pre> <p>What ASP.NET Core does here is, it takes the JSON String, and wraps it into JSON again (e.g. it escapes the JSON)</p> <p>Returning plain text with <code>[Produces("text/plain")]</code> does work by providing the "RAW" content, but it also sets the content-type of the response to PLAIN instead of JSON. We use <code>[Produces("application/json")]</code> on our Controllers.</p> <p>How can I return the JSON that I have as a normal JSON content-type without it being escaped?</p> <p><em>Note: It doesn't matter how the JSON string was aquired, it could be from a 3rd party service, or there are some special serialization needs so that we want to do custom serialization instead of using the default JSON.NET serializer.</em></p>
0debug
void virtio_scsi_handle_cmd_req_submit(VirtIOSCSI *s, VirtIOSCSIReq *req) { if (scsi_req_enqueue(req->sreq)) { scsi_req_continue(req->sreq); } bdrv_io_unplug(req->sreq->dev->conf.bs); scsi_req_unref(req->sreq); }
1threat
Swift (4) - How to open/read a text file with an iOS App? : I build an iOS App with Swift 4 and would like to import text files (CSV) from the iOS files app (since iOS 11) into my app. Next step would be to parse the text into an a json, dictionary or array. It depends on the content. I just need read rights. Does someone has an idea how to do it? I haven’t found any tutorial yet. Bye Moe
0debug
static IOMMUTLBEntry typhoon_translate_iommu(MemoryRegion *iommu, hwaddr addr, bool is_write) { TyphoonPchip *pchip = container_of(iommu, TyphoonPchip, iommu); IOMMUTLBEntry ret; int i; if (addr <= 0xffffffffu) { if ((pchip->ctl & 0x20) && addr >= 0x80000 && addr <= 0xfffff) { goto failure; } for (i = 0; i < 3; ++i) { if (window_translate(&pchip->win[i], addr, &ret)) { goto success; } } if ((pchip->win[3].wba & 0x80000000000ull) == 0 && window_translate(&pchip->win[3], addr, &ret)) { goto success; } } else { if (addr >= 0x10000000000ull && addr < 0x20000000000ull) { if (pchip->ctl & 0x40) { make_iommu_tlbe(0, 0x007ffffffffull, &ret); goto success; } } if (addr >= 0x80000000000ull && addr <= 0xfffffffffffull) { if ((pchip->win[3].wba & 0x80000000001ull) == 0x80000000001ull) { uint64_t pte_addr; pte_addr = pchip->win[3].tba & 0x7ffc00000ull; pte_addr |= (addr & 0xffffe000u) >> 10; if (pte_translate(pte_addr, &ret)) { goto success; } } } } failure: ret = (IOMMUTLBEntry) { .perm = IOMMU_NONE }; success: return ret; }
1threat
Joining a list in python with different conditions and separator : <p>I have a list of integer</p> <p><code>a=[1,2,3,4,5,6,7,8,9]</code></p> <p>and i must create a string with the integers separated by spaces and every five number i must add a '\n'</p> <p><code>string='1 2 3 4 5\n6 7 8 9\n\n'</code></p> <hr> <p>I have tried with a join like that:</p> <p><code>string=' '.join(a)</code></p> <p>but i don't know how to add '\n' with a condition.</p>
0debug
Distance between two Points in pandas csv Data-frame in python : How to calculate the distance between two coordinates points for the below data frame i had tried with the below codes but it's always gives error in executoin ` `distance.vincenty(coords_1, coords_2).km ) #d.apply(lambda x: vincenty((x['lat1'],x['long1']), (x['lat2'], x['long2'])).miles, axis=1) #mat = d.spatial.distance.cdist(d[['lat1','long1']], d[['lat2','long2']], metric='euclidean') #dist = mpu.haversine_distance((d[['lat1','long1']]), (d[['lat2','long2']]))` [![enter image description here][1]][1], [1]: https://i.stack.imgur.com/Oy2Bz.jpg
0debug
static abi_long host_to_target_data_route(struct nlmsghdr *nlh) { uint32_t nlmsg_len; struct ifinfomsg *ifi; struct ifaddrmsg *ifa; struct rtmsg *rtm; nlmsg_len = nlh->nlmsg_len; switch (nlh->nlmsg_type) { case RTM_NEWLINK: case RTM_DELLINK: case RTM_GETLINK: ifi = NLMSG_DATA(nlh); ifi->ifi_type = tswap16(ifi->ifi_type); ifi->ifi_index = tswap32(ifi->ifi_index); ifi->ifi_flags = tswap32(ifi->ifi_flags); ifi->ifi_change = tswap32(ifi->ifi_change); host_to_target_link_rtattr(IFLA_RTA(ifi), nlmsg_len - NLMSG_LENGTH(sizeof(*ifi))); break; case RTM_NEWADDR: case RTM_DELADDR: case RTM_GETADDR: ifa = NLMSG_DATA(nlh); ifa->ifa_index = tswap32(ifa->ifa_index); host_to_target_addr_rtattr(IFA_RTA(ifa), nlmsg_len - NLMSG_LENGTH(sizeof(*ifa))); break; case RTM_NEWROUTE: case RTM_DELROUTE: case RTM_GETROUTE: rtm = NLMSG_DATA(nlh); rtm->rtm_flags = tswap32(rtm->rtm_flags); host_to_target_route_rtattr(RTM_RTA(rtm), nlmsg_len - NLMSG_LENGTH(sizeof(*rtm))); break; default: return -TARGET_EINVAL; } return 0; }
1threat
void qemu_aio_wait(void) { sigset_t set; int nb_sigs; #if !defined(QEMU_IMG) && !defined(QEMU_NBD) if (qemu_bh_poll()) return; #endif sigemptyset(&set); sigaddset(&set, aio_sig_num); sigwait(&set, &nb_sigs); qemu_aio_poll(); }
1threat
I have sentence . how can group this based on character length? : public class sortingtext { public static void main(String[] args) throws IOException { String readline="i have a sentence with words"; String[] words=readline.split(" "); Arrays.sort(words, (a, b)->Integer.compare(b.length(), a.length())); for (int i=0;i<words.length;i++) { int len = words[i].length(); int t=0; System.out.println(len +"-"+words[i]); } } input: i have a sentence with words when i tried i got it like 8- sentence 5- words 4- have 4-with 1-I 1-a Expected output: 8- sentence 5- words 4- have ,with 1-I a
0debug
Execute command in all immediate subdirectories : <p>I'm trying to add a shell function (zsh) <code>mexec</code> to execute the same command in all immediate subdirectories e.g. with the following structure</p> <pre><code>~ -- folder1 -- folder2 </code></pre> <p><code>mexec pwd</code> would show for example </p> <pre><code>/home/me/folder1 /home/me/folder2 </code></pre> <p>I'm using <code>find</code> to pull the immediate subdirectories. The problem is getting the passed in command to execute. Here's my first function defintion:</p> <pre><code>mexec() { find . -mindepth 1 -maxdepth 1 -type d | xargs -I'{}' \ /bin/zsh -c "cd {} &amp;&amp; $@;"; } </code></pre> <p>only executes the command itself but doesn't pass in the arguments i.e. <code>mexec ls -al</code> behaves exactly like <code>ls</code></p> <p>Changing the second line to <code>/bin/zsh -c "(cd {} &amp;&amp; $@);"</code>, <code>mexec</code> works for just <code>mexec ls</code> but shows this error for <code>mexec ls -al</code>:</p> <pre><code>zsh:1: parse error near `ls' </code></pre> <p>Going the exec route with find</p> <pre><code>find . -mindepth 1 -maxdepth 1 -type d -exec /bin/zsh -c "(cd {} &amp;&amp; $@)" \; </code></pre> <p>Gives me the same thing which leads me to believe there's a problem with how I'm passing the arguments to zsh. This also seems to be a problem if I use bash: the error shown is:</p> <pre><code>-a);: -c: line 1: syntax error: unexpected end of file </code></pre> <p>What would be a good way to achieve this?</p>
0debug
Andriod Error While Making an Activity : I recently Installed Android Studio 2.1 and start programming when I tried to make an activity it show me an error. So guys Help Me to resolve this error and thanks in advance ;)[enter image description here][1] [1]: http://i.stack.imgur.com/t6r2u.png
0debug
Combobox control in application designers maximo 7.6 : My clients requirement is to have a combobox on one of my custom application in maximo 76. How to bind a combobox in maximo application designer
0debug
Java: Repeat Task Every Random Seconds : <p>I'm already familiar with repeating tasks every n seconds by using Java.util.Timer and Java.util.TimerTask. But lets say I want to print "Hello World" to the console every random seconds from 1-5. Unfortunately I'm in a bit of a rush and don't have any code to show so far. Any help would be apriciated. </p>
0debug
Options in select option doesn't match elements width : As you can see - the once clicking the select menu - the options are overlapping.... [![enter image description here][1]][1] I wonder if anyone stumble upon this kind of behavior and what could to match the option width to the select width - i didn't added a fiddle because the problem occurs in my project which i can't share... so i need a more general approach Here is the CSS: .select { width: 100%; border-radius: 5px; border: 1px solid #dcdcdc; font-size: 12px; } [1]: https://i.stack.imgur.com/dptcy.jpg
0debug
insert a node at a specific position : I need to insert a note at position. I didn't get any error but my answer s wrong. Could you please help me to correct my code? Node InsertNth(Node head, int data, int position) { Node node = new Node(); node.data = data; if (head == null){ return node; } else { Node current = head; for (int i=0; i < position-1 ; i++){ current = current.next; } node.next = current.next; current.next = node; return head; } }
0debug
Converting UTC Time Field To Browser Time Using Momemnt.js : I'm receiving ONLY UTC time from my db like 02:10:12, I want to convert this time to users browser time. I tried below links https://stackoverflow.com/questions/32540667/moment-js-utc-to-local-time https://stackoverflow.com/questions/19401426/changing-the-utc-date-to-local-date-using-moment-js https://stackoverflow.com/questions/42596669/convert-utc-time-to-local-time-of-browser but none of them worked for me since most of them work with datetime field, mine is only time type in my database. What I want to do is this,if my db UTC time is 02:10:12 then using moment.js we detect users browser timezone and convert this UTC time to that time zone and show in UI.
0debug
Check all opened windows in vba : <p>Basically I want a code to check all of the opened windows in my desktop, using vba.</p> <p>That includes applications' windows as well.</p> <p>I also need to know the windows names.</p> <p>In general I want to know if the application Winrar is proceeding a specific operation, for example when I add files to an archive then the Winrar's desktop window is named as "Updating archive x", I want to get this text in my vba code.</p> <p>I need the exact same thing for more applications as well, so it'd be nice to get a function for that.</p> <p>Thanks in advance.</p>
0debug
Regular Experssion to exlude specific pattern in pattern : I want to select html attributes based on Regular expression Follwing is the strings it is matching based on follwoing regular expression for below HTML markup. colspan="2" bgcolor="#FFFFFF" height="28" psdtyle="font-stretch: normal; font-size: 12px; line-height: 1.5;" align="center" style="word-wrap: break-word; margin: 5px 0px;" size="2" ((\w+)="[a-zA-Z#-:0-9 ;]*") Now the real question is i want to exclude colspan, i.e colspan="2" shold not match.Please suggest.Thanks in advance <td colspan="2" bgcolor="#FFFFFF" height="28" psdtyle="font-stretch: normal; font-size: 12px; line-height: 1.5;"> <p align="center" style="word-wrap: break-word; margin: 5px 0px;"><font size="2">Shoulder</font></p> </td
0debug
Visual studio code - keyboard shortcuts - expand/collapse all : <p>Trying to find the equivalent to <strong>ctrl + shift + "-"</strong> in Intellij that collapses/expands all functions.</p>
0debug
Check if user has scrolled to the bottom in Angular 2 : <p>What is the best practice to check if user has scrolled to the bottom of the page in Angular2 without jQuery? Do I have access to the window in my app component? If not should i check for scrolling to the bottom of the footer component, and how would I do that? A directive on the footer component? Has anyone accomplished this?</p>
0debug
MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len, size_t max_len, hwaddr addr, const char *fw_file_name, FWCfgReadCallback fw_callback, void *callback_opaque) { MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); Rom *rom; MemoryRegion *mr = NULL; rom = g_malloc0(sizeof(*rom)); rom->name = g_strdup(name); rom->addr = addr; rom->romsize = max_len ? max_len : len; rom->datasize = len; rom->data = g_malloc0(rom->datasize); memcpy(rom->data, blob, len); rom_insert(rom); if (fw_file_name && fw_cfg) { char devpath[100]; void *data; snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name); if (mc->rom_file_has_mr) { data = rom_set_mr(rom, OBJECT(fw_cfg), devpath); mr = rom->mr; } else { data = rom->data; } fw_cfg_add_file_callback(fw_cfg, fw_file_name, fw_callback, callback_opaque, data, rom->datasize); } return mr; }
1threat
How check if Vue is in development mode? : <p>When I run my Vue app, the console shows:</p> <pre><code>You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html </code></pre> <p>So now I want to check if Vue is in development from inside my templates by using:</p> <pre><code>console.log("mode is " + process.env.NODE_ENV) </code></pre> <p>But that only logs <code>undefined</code> Is there a different way to find the NODE_ENV in Vue?</p> <p>My webpack config has this part:</p> <pre><code>if (process.env.NODE_ENV === 'production') { module.exports.devtool = '#source-map' // http://vue-loader.vuejs.org/en/workflow/production.html module.exports.plugins = (module.exports.plugins || []).concat([ new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"production"' } }), new webpack.optimize.UglifyJsPlugin({ sourceMap: true, compress: { warnings: false } }), new webpack.LoaderOptionsPlugin({ minimize: true }) ]) } </code></pre> <p>Perhaps relevant: I use typescript, so I included this type declaration:</p> <pre><code>declare var process: { env: { NODE_ENV: string } } </code></pre>
0debug
Flask-Migrate and Migrations in General : I'm relatively new to flask, python, and coding overall so please bear with me if you have the time. I'm trying to understand migrations and have some questions regarding the topic. I'm working on a web-based asset management app, and I've had some modest success thus far. I've implemented a page that iterates through all my assets (rows) and displays them in a form with their associated row values (horsepower, voltage etc.) I've implemented a page that takes form data and adds it to the database. I've implemented a page that lets you filter all your assets by some of their values (horsepower, voltage etc.) and displays the result, as well as a search by primary_key (Asset Tag) bar in the header. To be honest so far I'm quietly impressing myself :). Flask is great because when I was getting started and watching a few tutorial playlists I found it easier to learn than Django. There was much less overhead / pre-written code and I actually knew what each line of code was doing, and I felt I was really grasping the operation of my application in its entirety. Anyways this is all besides the point. What I'm looking to implement now is something I feel the need to get some opinions on as I have not found much of anything regarding it online. I'd like for my customers to be able to add / remove tables, and table columns and rows. From the reading I have done I know that making schema changes is going to require migrations, so adding in that functionality would require something along the lines of writing a view that takes form data and inserts it into a function that then invokes a method of Flask-Migrate, or maybe something directly into Flask-Migrate itself? The thing is, even if I manage to build something like this, don't migrations build the required separate scripts and everything that goes along with that each time something is added or removed? Is that a practical solution for something like this, where 10 or 20 new tables might be added from the default / shipped database? Also, if I'm building in a functionality that allows users to add columns to a table, it will have to modify that tables class. I'm unsure if that's even possible, or a safe idea? I may also be looking at solving this the wrong way entirely. In that case I'd really appreciate it if someone could help me out, and at least get me pointed in the right direction. TLDR; Can you take form data and change database schema? Is it a good idea? Is there a downside to many migrations from a 'default' database?
0debug
Get index in ForEach in SwiftUI : <p>I have an array and I want to iterate through it initialize views based on array value, and want to perform action based on array item index</p> <p>When I iterate through objects</p> <pre class="lang-swift prettyprint-override"><code>ForEach(array, id: \.self) { item in CustomView(item: item) .tapAction { self.doSomething(index) // Can't get index, so this won't work } } </code></pre> <p>So, I've tried another approach</p> <pre class="lang-swift prettyprint-override"><code>ForEach((0..&lt;array.count)) { index in CustomView(item: array[index]) .tapAction { self.doSomething(index) } } </code></pre> <p>But the issue with second approach is, that when I change array, for example, if <code>doSomething</code> does following</p> <pre><code>self.array = [1,2,3] </code></pre> <p>views in <code>ForEach</code> do not change, even if values are changed. I believe, that happens because <code>array.count</code> haven't changed. </p> <p>Is there a solution for this? Thanks in advance.</p>
0debug
How to run webpack-bundle-analyzer : <p>I installed webpack-bundle-analyzer and need to run it. How can I do it? I have several errors. One of the most common is</p> <pre><code>Could't analyze webpack bundle </code></pre>
0debug
static int swf_write_video(AVFormatContext *s, AVCodecContext *enc, const uint8_t *buf, int size) { ByteIOContext *pb = &s->pb; static int tag_id = 0; if (enc->frame_number > 1) { put_swf_tag(s, TAG_REMOVEOBJECT); put_le16(pb, SHAPE_ID); put_le16(pb, 1); put_swf_end_tag(s); put_swf_tag(s, TAG_FREECHARACTER); put_le16(pb, BITMAP_ID); put_swf_end_tag(s); } put_swf_tag(s, TAG_JPEG2 | TAG_LONG); put_le16(pb, tag_id); put_byte(pb, 0xff); put_byte(pb, 0xd8); put_byte(pb, 0xff); put_byte(pb, 0xd9); put_buffer(pb, buf, size); put_swf_end_tag(s); put_swf_tag(s, TAG_PLACEOBJECT); put_le16(pb, SHAPE_ID); put_le16(pb, 1); put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0); put_swf_end_tag(s); put_swf_tag(s, TAG_SHOWFRAME); put_swf_end_tag(s); put_flush_packet(&s->pb); return 0; }
1threat
Curl -u equivalent in HTTP request : <p>I've been trying to plug into the Toggl API for a project, and their examples are all using CURL. I'm trying to use the C# wrapper which causes a bad request when trying to create a report, so I thought I'd use Postman to try a simple HTTP request.</p> <p>I can't seem to get the HTTP request to accept my API Token though. Here's the example that they give (CURL):</p> <pre><code>curl -u my-secret-toggl-api-token:api_token -X GET "https://www.toggl.com/reports/api/v2/project/?page=1&amp;user_agent=devteam@example.com&amp;workspace_id=1&amp;project_id=2" </code></pre> <p>I've tried the following HTTP request with Postman with a header called api_token with my token as the value:</p> <pre><code>https://www.toggl.com/reports/api/v2/project/?user_agent=MYEMAIL@EMAIL.COM&amp;project_id=9001&amp;workspace_id=9001 </code></pre> <p>(changed ids and email of course).</p> <p>Any help on how to use the CURL -u in HTTP would be appreciated, thanks.</p>
0debug
%p formats to 8 hex digits for a 64-bit binary : <p>I have a 64-bit binary (modfied version of sqlite, but this shouldn't mattrr):</p> <pre><code>&gt; file /home/aromanov/IdeaProjects/sqlite/sqlite3 /home/aromanov/IdeaProjects/sqlite/sqlite3: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x39a2db352d3bc451ed621ad0588eec3008df034b, not stripped </code></pre> <p>produced with GCC 4.7.4. However, debugging code in it outputs just 8 hex digits (32 bits) for <code>%p</code> in format string, where I expected 16. Is this normal? </p>
0debug
Spring Security Configuration - HttpSecurity vs WebSecurity : <p>I just need to understand something in Spring Security Configuration. Using the example below...</p> <pre><code>@Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .httpBasic() .and() .authorizeRequests().antMatchers("/secret/**").authenticated() .and() .authorizeRequests().antMatchers("/**").permitAll(); } @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/resources/**"); } } </code></pre> <p>What is the purpose of <code>configure(WebSecurity web)</code> method? </p> <p>Can't I just add <code>/resources/**</code> in the <code>configure(HttpSecurity http)</code> method in this line <code>.authorizeRequests().antMatchers("/**", "/resources/**").permitAll();</code> Shouldn't it work the same i.e. permitting all requests to <code>/resources/**</code> without any authentication?</p>
0debug
static void ich9_lpc_config_write(PCIDevice *d, uint32_t addr, uint32_t val, int len) { ICH9LPCState *lpc = ICH9_LPC_DEVICE(d); uint32_t rcba_old = pci_get_long(d->config + ICH9_LPC_RCBA); pci_default_write_config(d, addr, val, len); if (ranges_overlap(addr, len, ICH9_LPC_PMBASE, 4) || ranges_overlap(addr, len, ICH9_LPC_ACPI_CTRL, 1)) { ich9_lpc_pmbase_sci_update(lpc); } if (ranges_overlap(addr, len, ICH9_LPC_RCBA, 4)) { ich9_lpc_rcba_update(lpc, rcba_old); } if (ranges_overlap(addr, len, ICH9_LPC_PIRQA_ROUT, 4)) { pci_bus_fire_intx_routing_notifier(lpc->d.bus); } if (ranges_overlap(addr, len, ICH9_LPC_PIRQE_ROUT, 4)) { pci_bus_fire_intx_routing_notifier(lpc->d.bus); } if (ranges_overlap(addr, len, ICH9_LPC_GEN_PMCON_1, 8)) { ich9_lpc_pmcon_update(lpc); } }
1threat
settimeout php sql : <p>I am using php,sql,javascript I am building a friend request system , if user-1 sends user-2 a friend request user-2 has 1 hour to accept that friend request or the friend request is automatically denied/removed . . . i can use settimeout to run that function but if the page is refreshed that function is no longer good , I need it to be able to run even if both users are not online anymore . . . so if user-1 and user-2 are both online at the time when the friend request is sent. . . user-2 and user-1 signs out , i need that friend request to be deleted within 1 hr of the time sent , i am pretty certain that function would need to be ran on the server or something just not sure what direction I would need to look it ! just confused maybe theres a function in php i can use? </p>
0debug