problem
stringlengths
26
131k
labels
class label
2 classes
Ignore TS6133: "(import) is declared but never used"? : <p>While working on a TypeScript project, I commented out a line, and got the error:</p> <blockquote> <p>Failed to compile</p> <pre><code>./src/App.tsx (4,8): error TS6133: 'axios' is declared but never used. </code></pre> <p>This error occurred during the build time and cannot be dismissed.</p> </blockquote> <p>The error is right, I am importing axios, but I wanted to temporarily comment out the call to <code>axios.get</code>. I appreciate that error as it keeps my imports clean, but during early development is is pretty disruptive.</p> <p>Any way to disable or ignore that warning?</p>
0debug
int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value) { QObject *obj; obj = qdict_get(qdict, key); if (!obj || qobject_type(obj) != QTYPE_QINT) return def_value; return qint_get_int(qobject_to_qint(obj)); }
1threat
static CharDriverState *qemu_chr_open_mux(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { ChardevMux *mux = backend->mux; CharDriverState *chr, *drv; MuxDriver *d; drv = qemu_chr_find(mux->chardev); if (drv == NULL) { error_setg(errp, "mux: base chardev %s not found", mux->chardev); return NULL; } chr = qemu_chr_alloc(); d = g_new0(MuxDriver, 1); chr->opaque = d; d->drv = drv; d->focus = -1; chr->chr_write = mux_chr_write; chr->chr_update_read_handler = mux_chr_update_read_handler; chr->chr_accept_input = mux_chr_accept_input; chr->chr_set_fe_open = NULL; if (drv->chr_add_watch) { chr->chr_add_watch = mux_chr_add_watch; } chr->explicit_be_open = muxes_realized ? 0 : 1; chr->is_mux = 1; return chr; }
1threat
static void acquire_privilege(const char *name, Error **errp) { HANDLE token; TOKEN_PRIVILEGES priv; Error *local_err = NULL; if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token)) { if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) { error_set(&local_err, QERR_QGA_COMMAND_FAILED, "no luid for requested privilege"); goto out; } priv.PrivilegeCount = 1; priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) { error_set(&local_err, QERR_QGA_COMMAND_FAILED, "unable to acquire requested privilege"); goto out; } CloseHandle(token); } else { error_set(&local_err, QERR_QGA_COMMAND_FAILED, "failed to open privilege token"); } out: if (local_err) { error_propagate(errp, local_err); } }
1threat
C# delete files based on text file : <p>Hy,</p> <p>I have a FilesToDelete.txt file filled with file paths like:</p> <pre><code>C:\Users\Me\Pics\file01.png C:\Users\Me\Pics\file03.png C:\Users\Me\Pics\file15.png etc... </code></pre> <p>How can I delete these files with C#? Thanks!</p>
0debug
What does this syntax mean: const foo = () => {} : <p>I have recently come across this code with which I am unfamiliar:</p> <pre><code>const foo = () =&gt; { /*code block here*/ } </code></pre> <p>As far as I can tell, it means the same thing as:</p> <pre><code>const foo = function () { /*code block here*/ } </code></pre> <p>Is that a correct assumption, or are there differences? What is the correct name to refer to this bit of code? What exactly is the '=>' doing? I've never seen it in Javascript before.</p>
0debug
def lucky_num(n): List=range(-1,n*n+9,2) i=2 while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1 return List[1:n+1]
0debug
Dropping a level from a factor within a data frame : <p>I have a data frame 'qlfs' which contains a column 'qlfs$TravelMode'.</p> <p>The $TravelMode is a factor containing 10 levels:</p> <pre><code>levels(qlfs$TravelMode) [1] "Non-working adult" [2] "Car,van,minibus,works van" [3] "Motorbike,moped,scooter" [4] "Bicycle" [5] "Bus,coach,private bus" [6] "Taxi" [7] "Railway train" [8] "Underground train,light railway,tram" [9] "Walk" [10] "Other method" </code></pre> <p>The dataset contains 90k + rows.</p> <p>I would like to remove level 1 (Non-working adult) and any associated rows from the wider dataframe.</p> <p>I have tried the following:</p> <pre><code>for (i in 1:NROW(qlfs$TravelMode)) { if(qlfs$TravelMode[i]="Non-working adult") { qlfs$TravelMode[i] &lt;- "NA" } } </code></pre> <p>Where I would then remove the NAs at a later point, but this did not work.</p> <p>I have also looked at droplevels() function, but could not get this to work.</p> <p>Can anybody point out where I am going wrong or suggest a better way to achieve this?</p>
0debug
static void init_entropy_decoder(APEContext *ctx) { ctx->CRC = bytestream_get_be32(&ctx->ptr); ctx->frameflags = 0; if ((ctx->fileversion > 3820) && (ctx->CRC & 0x80000000)) { ctx->CRC &= ~0x80000000; ctx->frameflags = bytestream_get_be32(&ctx->ptr); } ctx->blocksdecoded = 0; ctx->riceX.k = 10; ctx->riceX.ksum = (1 << ctx->riceX.k) * 16; ctx->riceY.k = 10; ctx->riceY.ksum = (1 << ctx->riceY.k) * 16; ctx->ptr++; range_start_decoding(ctx); }
1threat
setting the time of datetime.now() : I am trying to get the current datetime and set the time to `00:00:00`. To do this, I call: current_date = dt.datetime.now() current_date.replace(hour=0, minute=0, second=0) print(current_date) The output is: > 2017-08-20 10:43:56.3243245 That is not what I expect. However, if I do: current_date = dt.datetime(dt.datetime.now().date().year,dt.datetime.now().date().month,dt.datetime.now().date().day,0,0,0) ... Everything is as I expect and I get the result: > 2017-08-20 00:00:00 Why is this? What is going on?? Why does `replace` not work?
0debug
Add value to first index of value 0 in Java array : <p>If I have an array of zeros [0,0,0] how do I insert a given value to the first index that is valued 0.</p> <p>So first off the value 3 will go into index 0 giving me [3,0,0]</p> <p>Then the second value 8 will go into index 1 giving me [3,8,0].</p> <p>How do I go about this?</p>
0debug
static int write_refcount_block(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; size_t size = s->cluster_size; if (s->refcount_block_cache_offset == 0) { return 0; } BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE); if (bdrv_pwrite(bs->file, s->refcount_block_cache_offset, s->refcount_block_cache, size) != size) { return -EIO; } return 0; }
1threat
static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data, unsigned size) { switch (offset) { case 0xc: n->bar.intms |= data & 0xffffffff; n->bar.intmc = n->bar.intms; break; case 0x10: n->bar.intms &= ~(data & 0xffffffff); n->bar.intmc = n->bar.intms; break; case 0x14: if (!NVME_CC_EN(data) && !NVME_CC_EN(n->bar.cc) && !NVME_CC_SHN(data) && !NVME_CC_SHN(n->bar.cc)) { n->bar.cc = data; } if (NVME_CC_EN(data) && !NVME_CC_EN(n->bar.cc)) { n->bar.cc = data; if (nvme_start_ctrl(n)) { n->bar.csts = NVME_CSTS_FAILED; } else { n->bar.csts = NVME_CSTS_READY; } } else if (!NVME_CC_EN(data) && NVME_CC_EN(n->bar.cc)) { nvme_clear_ctrl(n); n->bar.csts &= ~NVME_CSTS_READY; } if (NVME_CC_SHN(data) && !(NVME_CC_SHN(n->bar.cc))) { nvme_clear_ctrl(n); n->bar.cc = data; n->bar.csts |= NVME_CSTS_SHST_COMPLETE; } else if (!NVME_CC_SHN(data) && NVME_CC_SHN(n->bar.cc)) { n->bar.csts &= ~NVME_CSTS_SHST_COMPLETE; n->bar.cc = data; } break; case 0x24: n->bar.aqa = data & 0xffffffff; break; case 0x28: n->bar.asq = data; break; case 0x2c: n->bar.asq |= data << 32; break; case 0x30: n->bar.acq = data; break; case 0x34: n->bar.acq |= data << 32; break; default: break; } }
1threat
PHP: Aggregating arrays : <p>Assuming I have the following 3 PHP arrays:</p> <pre><code>$arr1 = [1,2,3,4] $arr2 = [5,2,4,1] $arr3 = [2,1,2,2] </code></pre> <p>What's the most efficient built-in way that PHP has to add these arrays to elements in the same index of each array. Meaning, the final output would be the following:</p> <pre><code>$final = [8,5,9,7] </code></pre> <p>There should be an easier way than doing <code>final = [$arr1[0]+$arr2[0]+$arr3[0]..]</code> etc. Also, I need to assume there's a variable amount of arrays, so hard coding the math like above isn't correct.</p>
0debug
Discharging java ArrayList : <p>I`ve two methods to discharge an ArrayList in java:</p> <p>1- re-assign the list object.</p> <pre><code>list = new ArrayList(); </code></pre> <p>2- using clear method.</p> <pre><code>list.clear(); </code></pre> <p>Which is better?</p>
0debug
Create thumbnail from selected video and store it in server : <p>I know this is not the right platform for asking this question and i will definitely get huge no. of down-votes for this, but i don't have any other choice. If anyone just give me a small solution that will be great.</p> <p>Till now in my android app, I am able to choose video from my gallery and successfully uploaded it to my server. Now i want that when i choose the video then its thumbnail should be generated and i should be able to upload that image along with the video in my server. This is the point where i am stucked currently, need any useful link or tutorial for the same, searched google but finally here with a hope.</p>
0debug
JavaScript POST to PHP - why does it return null without an If? : <p>This one has really been melting my brain because I'm just not sure why the PHP returns a null set to the front end when it's formatted like this:</p> <pre><code>&lt;?php require_once 'tempdbconfig.php'; $email=$_POST['email']; try { //if($email = "t*****@gmail.com"){ $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $sql="SELECT users_id FROM photow_users WHERE email_address = '$email'"; $result = $conn-&gt;prepare($sql); $result-&gt;execute(); $data = $result-&gt;fetchAll(); $catValues = array(); foreach($data as $row) { $users_id=$row['users_id']; $category_sql="SELECT * FROM photow_categories WHERE users_id = '$users_id'"; $category_result = $conn-&gt;prepare($category_sql); $category_result-&gt;execute(); $category_data = $category_result-&gt;fetchAll(); $catValues = array(); $i = 0; foreach($category_data as $category_row) { $categories = array(); $categoryid = $category_row['category_id']; $category = $category_row['name']; $categories["ID"] = $categoryid; $categories["Category"] = $category; $catValues[$i]=$categories; $i++; } } echo json_encode($catValues); //} //else //{ // echo 'no categories'; //} } catch (PDOException $pe) { die("Could not connect to the database $dbname :" . $pe-&gt;getMessage()); } ?&gt; </code></pre> <p>But if I uncomment the if else (the condition is the email that my currently logged in account on the front end is using, so it's akin to me asking if the sky is blue) I get the properly formatted JSON returned to the front end. Am I missing something about PHP or have I made a horrible mistake somewhere?</p> <p>This is the ajax call in case it's something there that's effecting it - localstorage does contain the correct email address by the way.</p> <pre><code>var email=localStorage.email; $.ajax({ type: "POST", url: "http://w****.azurewebsites.net/getCategoriesjson.php", data: 'email='+email, contentType: "application/json;charset=utf-8", dataType: "json", success: function(data){ var html = ''; $.each(data, function(index,value){ html+= '&lt;option value="'+value['ID']+'"&gt;'+value['Category']+'&lt;/option&gt;'; }); $('#categories').html(html); } }); </code></pre>
0debug
express: how to send html together with css using sendFile? : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = require('express')(); app.get('/', function(req, res) { res.sendFile(__dirname + "/" + "index.html"); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="style.css"&gt;</code></pre> </div> </div> </p> <p>I used the above node.js code to send a html file. To get the html file formatted I need to send another css file(style.css).<br/> My question is: how can I send both of these two files(index.html and style.css) using sendFile() and integrate them together in the client side? </p>
0debug
Error `window not defined` in Node.js : <p>I know <code>window</code> doesn't exist in Node.js, but I'm using React and the same code on both client and server. Any method I use to check if <code>window</code> exists nets me:</p> <blockquote> <p>Uncaught ReferenceError: window is not defined</p> </blockquote> <p>How do I get around the fact that I can't do <code>window &amp;&amp; window.scroll(0, 0)</code>?</p>
0debug
Use Variable insted of Get-Date : I am using `PowerShell "(Get-Date).AddDays(-7).ToString('ddMMyyyy')"` in batch script, I want to use variable in insted of Get-Date function. Is it possible? "ADate" is Variable name!
0debug
static int h261_decode_picture_header(H261Context *h) { MpegEncContext *const s = &h->s; int format, i; uint32_t startcode = 0; for (i = get_bits_left(&s->gb); i > 24; i -= 1) { startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF; if (startcode == 0x10) break; } if (startcode != 0x10) { av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } i = get_bits(&s->gb, 5); if (i < (s->picture_number & 31)) i += 32; s->picture_number = (s->picture_number & ~31) + i; s->avctx->time_base = (AVRational) { 1001, 30000 }; skip_bits1(&s->gb); skip_bits1(&s->gb); skip_bits1(&s->gb); format = get_bits1(&s->gb); if (format == 0) { s->width = 176; s->height = 144; s->mb_width = 11; s->mb_height = 9; } else { s->width = 352; s->height = 288; s->mb_width = 22; s->mb_height = 18; } s->mb_num = s->mb_width * s->mb_height; skip_bits1(&s->gb); skip_bits1(&s->gb); while (get_bits1(&s->gb) != 0) skip_bits(&s->gb, 8); s->pict_type = AV_PICTURE_TYPE_P; h->gob_number = 0; return 0; }
1threat
void portio_list_del(PortioList *piolist) { MemoryRegion *mr, *alias; unsigned i; for (i = 0; i < piolist->nr; ++i) { mr = piolist->regions[i]; alias = piolist->aliases[i]; memory_region_del_subregion(piolist->address_space, alias); memory_region_destroy(alias); memory_region_destroy(mr); g_free((MemoryRegionOps *)mr->ops); g_free(mr); g_free(alias); piolist->regions[i] = NULL; piolist->aliases[i] = NULL; } }
1threat
Passing props to Vue.js components instantiated by Vue-router : <p>Suppose I have a Vue.js component like this:</p> <pre><code>var Bar = Vue.extend({ props: ['my-props'], template: '&lt;p&gt;This is bar!&lt;/p&gt;' }); </code></pre> <p>And I want to use it when some route in vue-router is matched like this:</p> <pre><code>router.map({ '/bar': { component: Bar } }); </code></pre> <p>Normally in order to pass 'myProps' to the component I would do something like this:</p> <pre><code>Vue.component('my-bar', Bar); </code></pre> <p>and in the html:</p> <pre><code>&lt;my-bar my-props="hello!"&gt;&lt;/my-bar&gt; </code></pre> <p>In this case, the router is drawing automatically the component in the router-view element when the route is matched.</p> <p>My question is, in this case, how can I pass the the props to the component?</p>
0debug
static void spapr_machine_reset(void) { MachineState *machine = MACHINE(qdev_get_machine()); sPAPRMachineState *spapr = SPAPR_MACHINE(machine); PowerPCCPU *first_ppc_cpu; uint32_t rtas_limit; hwaddr rtas_addr, fdt_addr; void *fdt; int rc; foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL); spapr_caps_reset(spapr); first_ppc_cpu = POWERPC_CPU(first_cpu); if (kvm_enabled() && kvmppc_has_cap_mmu_radix() && ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0, spapr->max_compat_pvr)) { spapr->patb_entry = PATBE1_GR; } else { spapr_setup_hpt_and_vrma(spapr); } qemu_devices_reset(); object_child_foreach_recursive(object_get_root(), spapr_reset_drcs, NULL); spapr_clear_pending_events(spapr); rtas_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR); rtas_addr = rtas_limit - RTAS_MAX_SIZE; fdt_addr = rtas_addr - FDT_MAX_SIZE; if (!spapr->cas_reboot) { spapr_ovec_cleanup(spapr->ov5_cas); spapr->ov5_cas = spapr_ovec_new(); ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal); } fdt = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size); spapr_load_rtas(spapr, fdt, rtas_addr); rc = fdt_pack(fdt); assert(rc == 0); if (fdt_totalsize(fdt) > FDT_MAX_SIZE) { error_report("FDT too big ! 0x%x bytes (max is 0x%x)", fdt_totalsize(fdt), FDT_MAX_SIZE); exit(1); } qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt)); g_free(fdt); first_ppc_cpu->env.gpr[3] = fdt_addr; first_ppc_cpu->env.gpr[5] = 0; first_cpu->halted = 0; first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT; spapr->cas_reboot = false; }
1threat
How to create Wordpress theme like : <p>How to create WordPress theme like this websites one for govt jobs and another for show images slide </p> <p><a href="http://www.indiangovtjobs.in" rel="nofollow">www.indiangovtjobs.in</a></p> <p><a href="http://www.imgcluster.com" rel="nofollow">www.imgcluster.com</a></p>
0debug
Microsoft access form view : <p>I am creating a Microsoft access application, and I designed a login form, where the user inputs username and password. I want the form view of the form to be showing above the access window, as a pop-up... how do I achieve that? </p>
0debug
Android studio sync settings between different computers : <p>I use 3 different computers for programming in the android studio.</p> <p>What is the best way to sync android studio settings between computers?</p>
0debug
uint64_t ldq_le_phys(target_phys_addr_t addr) { return ldq_phys_internal(addr, DEVICE_LITTLE_ENDIAN); }
1threat
How to make condition if sim card is absent then show dialog if not do something in android? : <p>I have an app in which I have to check whether sim card is inserted in device or not and make some condition if sim is not inserted then show dialog else do something ,how can I do that</p>
0debug
Python to vb script conversion : I need to help in converting a Phyton script to VBS. I'm trying to load the .cal file as a binary value file and edit a particular value in the file but unfortunately, my environment only supports VBScript. import argparse parser = argparse.ArgumentParser(description='Sapix Cal File Sensitivity Adjustment') parser.add_argument("-calfile", default="test.cal", help="Enter the Calfile name (ex: 09781DK5081.cal") parser.add_argument("-vtest", default=125, help="New Vtest setting (85-205)") parser.add_argument("-vref", default=250, help="New Vref setting (250-120)") args = parser.parse_args() calfile = args.calfile vtest = args.vtest vref = args.vref print(calfile) print(vtest) print(vref) with open(calfile, "rb") as binary_file: # Read the whole file at once data = bytearray(binary_file.read()) # Find Line with VTEST setting ivteststart = data.find(bytearray('PARALLEL_VOLTAGE_TEST', 'utf-8')) ivtestend = data.find(b'\n',ivteststart) # Remove original VTEST line del data[ivteststart:ivtestend+1] # Insert New Line with new VTEST new_vtest = bytearray("PARALLEL_VOLTAGE_TEST %s\n" % (vtest),'utf-8') data[ivteststart:ivteststart] = new_vtest # Find Line with VREF setting ivrefstart = data.find(bytearray('PARALLEL_VOLTAGE_REF', 'utf-8')) ivrefend = data.find(b'\n',ivrefstart) # Remove original VREF line del data[ivrefstart:ivrefend+1] # Insert New Line with new VREF new_vref = bytearray("PARALLEL_VOLTAGE_REF %s\n" % (vref),'utf-8') data[ivrefstart:ivrefstart] = new_vref # Write new sensitivity settings to cal file with open(calfile, "wb") as binary_file: binary_file.write(data)
0debug
When to use React : <p>I've been learning part of the MEAN/MERN stack and feel somewhat comfortable using MongoDB, Express, and Node. I'm moving onto the A/R of the stacks and am having a bit of trouble understanding when these are applicable and when they're not.</p> <p>To try to put my thoughts into words, I would ask this:</p> <p>Is Angular and React applicable to nearly all web applications or were they built for a certain niche? For instance, one of my first projects will be creating a portal for employees to use for various tools to help them with their work as well as to transition from Excel based forms to web based forms. </p> <p>When creating a site like this, is Mongo/Express/Node enough?</p> <p>I'm kind of struggling to explain this as this React course I've been trying to complete is making my brain feel like its over flowing. I've learned HTML/CSS/JS + Mongo/Express/Node over the past few months including ES2015-2017 and such so immediately learning React on top of that feels a bit overwhelming. For some reason my head is having trouble 'Thinking in React'. Not necessarily breaking things down to components, but the props and states aspect of it all. </p> <p>For instance, I understand what pure functions are but I don't feel experienced enough to know how to refactor a non-pure function to a pure one and be confident.</p> <p>I hope this is making sense... Coding has been wonderful. Not only am I having fun but it's really given me motivation to better myself and my knowledge and as well as given me a goal to reach.</p> <p>Any direction on how to tackle React as a newbie would be extremely helpful.</p>
0debug
Simple PHP for most programers but im new to it : foreach( $users as $u ) { echo '<tr><td>' . $u->nome . '</td><td>' . $u->username . '</td><td>' . $u->email . '</td><td>' . ( $u->acesso == 1 ? '<b>Administrador</b>' : 'Aluno' ) . '</td><td><a href="/website/admineditar.php?id=' . $u->id . '">Alterar</a> <a href="/website/adminremover.php?id=' . $u->id . '" onclick="return confirm(\'Deseja mesmo remover este utilizador?\');">Remover</a></td></tr>'; } so my problem is on this part ( $u->acesso == 1 ? '<b>Administrador</b>' : 'Aluno' ) i would like it to be doing something like this ( $u->acesso == 1 ? '<b>Administrador</b>' : $u->acesso == 0 ? 'Aluno' : 'Enc. educação' ) but dont know how to do it :S tryed to use if and elseif but gives me an error :S
0debug
How to : Skip the Header record from one .csv and Copy the Records to another csv file using command prompt or batch : <p>I got a task that says skip the header part of a csv file and copy the rest to another file. I am unable to figure out any way that can do this. I require to do this using command prompt or by writing a batch file code. I tried using for loop but dint worked </p>
0debug
NetQueue *qemu_new_net_queue(void *opaque) { NetQueue *queue; queue = g_malloc0(sizeof(NetQueue)); queue->opaque = opaque; QTAILQ_INIT(&queue->packets); queue->delivering = 0; return queue; }
1threat
I don't know how to use android json parser : I'm new to android and i'm developing an Android App, i want to get JSON data I can't bring my json from server ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ This is the code am using to parse it: package com.centre.anapa; import android.os.Bundle; import android.os.StrictMode; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.widget.TextView; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectAll() .penaltyLog() .penaltyDialog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll() .penaltyLog() .build()); TextView dust = (TextView) findViewById(R.id.dust); TextView humid = (TextView) findViewById(R.id.humid); TextView temp = (TextView) findViewById(R.id.temp); TextView tim = (TextView) findViewById(R.id.tim); JSONObject json = null; String str = ""; HttpResponse response; HttpClient myClient = new DefaultHttpClient(); HttpPost myConnection = new HttpPost("http://mase.everypython.com/get_data"); try { response = myClient.execute(myConnection); str = EntityUtils.toString(response.getEntity(), "UTF-8"); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try{ JSONArray jArray = new JSONArray(str); json = jArray.getJSONObject(0); if (dust != null) { dust.setText(json.getString("dust")); } if (humid != null) { humid.setText(json.getString("humid")); } if (temp != null) { temp.setText(json.getString("temp")); } if (tim != null) { tim.setText(json.getString("time")); } } catch ( JSONException e) { e.printStackTrace(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ I don't know how to use Android son parse
0debug
static int asf_read_marker(AVFormatContext *s, int64_t size) { AVIOContext *pb = s->pb; ASFContext *asf = s->priv_data; int i, count, name_len, ret; char name[1024]; avio_rl64(pb); avio_rl64(pb); count = avio_rl32(pb); avio_rl16(pb); name_len = avio_rl16(pb); for (i = 0; i < name_len; i++) avio_r8(pb); for (i = 0; i < count; i++) { int64_t pres_time; int name_len; avio_rl64(pb); pres_time = avio_rl64(pb); pres_time -= asf->hdr.preroll * 10000; avio_rl16(pb); avio_rl32(pb); avio_rl32(pb); name_len = avio_rl32(pb); if ((ret = avio_get_str16le(pb, name_len * 2, name, sizeof(name))) < name_len) avio_skip(pb, name_len - ret); avpriv_new_chapter(s, i, (AVRational) { 1, 10000000 }, pres_time, AV_NOPTS_VALUE, name); } return 0; }
1threat
import re def remove_spaces(text): return (re.sub(' +',' ',text))
0debug
How can I execute script after entire webpage has loaded : <p>I have a simply script. For example:</p> <pre><code>var rowCount = $('tr').length; document.write(rowCount); </code></pre> <p>I want to load this after entire webpage has loaded. How can I do?</p>
0debug
What is the best way to create a simple slideshow into an Android project? : <p>I am absolutly new in <strong>Android</strong> development and I am developing my first app.</p> <p>I have to create something like a <strong>slideshow</strong> that show an image, when the user moove to the right (with the finger on the screen, what's the correct name in Android jargon?) show the next immage, when it moove to the left the previous one is shown.</p> <p>I have found this example, I have to implement something like the result shown in the attached video: <a href="http://androidopentutorials.com/android-image-slideshow-using-viewpager/" rel="nofollow">http://androidopentutorials.com/android-image-slideshow-using-viewpager/</a></p> <p>But my doutbs are:</p> <p>In the prvious tutorial it use 2 external library that have to be added to the project:</p> <ul> <li><strong>Universal Image Loader for Android:</strong> for asynchronous image loading.</li> <li><strong>ViewPagerIndicator:</strong> library to bring circle indicator with ViewPager.</li> </ul> <p>Is it a good solution? Or can I obtain the same behavior without using external library but only stuff provided by the <strong>Android SDK</strong>?</p> <p>I think that the result of the previous tutorial is what I need for my project but I prefer don't use external library and adhere as much as possible to the standard of Android development.</p> <p>Can you give me some suggestion about the right way to implement this feature?</p>
0debug
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration : <p>I followed few suggestions mentioned here, but it didn't work for me. Hence, putting the question here</p> <ol> <li><a href="https://stackoverflow.com/questions/21633555/how-to-inject-authenticationmanager-using-java-configuration-in-a-custom-filter/21639553#21639553">How To Inject AuthenticationManager using Java Configuration in a Custom Filter</a></li> <li><a href="https://stackoverflow.com/questions/49473634/spring-required-a-bean-of-type-authenticationmanager">Spring required a bean of type &#39;AuthenticationManager&#39;</a></li> </ol> <p>Could anyone please guide me what's the issue and how to fixed that ?</p> <p><strong>Error:</strong></p> <pre><code>*************************** APPLICATION FAILED TO START *************************** Description: Field authenticationManager in com.techprimers.security.springsecurityauthserver.config.AuthorizationServerConfig required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found. Action: Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration. </code></pre> <p><strong>AuthorizationServerConfig.java</strong></p> <pre><code>@Configuration @EnableAuthorizationServer public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter { @Autowired private AuthenticationManager authenticationManager; @Override public void configure(AuthorizationServerSecurityConfigurer security) throws Exception { security.tokenKeyAccess("permitAll()") .checkTokenAccess("isAuthenticated()"); } @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients .inMemory() .withClient("ClientId") .secret("secret") .authorizedGrantTypes("authorization_code") .scopes("user_info") .autoApprove(true); } @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.authenticationManager(authenticationManager); } } </code></pre> <p><strong>ResourceServerConfig.java</strong></p> <pre><code>@EnableResourceServer @Configuration public class ResourceServerConfig extends WebSecurityConfigurerAdapter { @Autowired @Qualifier("authenticationManagerBean") private AuthenticationManager authenticationManager; @Autowired private UserDetailsService customUserDetailsService; @Override protected void configure(HttpSecurity http) throws Exception { http.requestMatchers() .antMatchers("/login", "/oauth/authorize") .and() .authorizeRequests() .anyRequest() .authenticated() .and() .formLogin() .permitAll(); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.parentAuthenticationManager(authenticationManager) .userDetailsService(customUserDetailsService); } } </code></pre> <p>The code reference taken from <a href="https://github.com/TechPrimers/spring-security-oauth-mysql-example" rel="noreferrer">https://github.com/TechPrimers/spring-security-oauth-mysql-example</a>, only updated Spring Boot Parent Version to <code>2.0.4.RELEASE</code>, things started breaking.</p>
0debug
static int dvbsub_parse_page_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output) { DVBSubContext *ctx = avctx->priv_data; DVBSubRegionDisplay *display; DVBSubRegionDisplay *tmp_display_list, **tmp_ptr; const uint8_t *buf_end = buf + buf_size; int region_id; int page_state; int timeout; int version; if (buf_size < 1) return AVERROR_INVALIDDATA; timeout = *buf++; version = ((*buf)>>4) & 15; page_state = ((*buf++) >> 2) & 3; if (ctx->version == version) { return 0; ctx->time_out = timeout; ctx->version = version; ff_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state); if(ctx->compute_edt == 1) save_subtitle_set(avctx, sub, got_output); if (page_state == 1 || page_state == 2) { delete_regions(ctx); delete_objects(ctx); delete_cluts(ctx); tmp_display_list = ctx->display_list; ctx->display_list = NULL; while (buf + 5 < buf_end) { region_id = *buf++; buf += 1; display = tmp_display_list; tmp_ptr = &tmp_display_list; tmp_ptr = &display->next; if (!display) { display = av_mallocz(sizeof(DVBSubRegionDisplay)); if (!display) return AVERROR(ENOMEM); display->region_id = region_id; display->x_pos = AV_RB16(buf); buf += 2; display->y_pos = AV_RB16(buf); buf += 2; *tmp_ptr = display->next; display->next = ctx->display_list; ctx->display_list = display; ff_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos); while (tmp_display_list) { display = tmp_display_list; tmp_display_list = display->next; av_freep(&display); return 0;
1threat
i am getting 401 unauthorized response : getThingsApi() { let uri = 'https://testapiserver/api/things/'; let req = { method: "GET", headers: { Authorization: 'Basic cC5qYWltdXJ1Z2FuLm1jYUBnbWFpbC5jb206MTIzNDU2', } }; console.log('InputRequest::' + JSON.stringify(req)); fetch(uri, req) .then(response => response.json()) .then(responseJson => { console.log('ResponseAxis::' + JSON.stringify(responseJson)); }) .catch(error => { console.log("Error::" + JSON.stringify(error)); }); } when i run above code , its working fine codesandbox.io..but not working in react native app. Could you please suggest me..what i did wrong..
0debug
Java Selection Sort implementation not working output "[I@15db9742" : <p>Hey I'm trying to test my selection sort algorithm but all the output I get in the console is just "[I@15db9742" Could someone please explain to me why I'm getting junk output? It is really baffling me, could it possible be a problem with the IDE or is it something in the code? </p> <p>Thanks</p> <pre><code>import java.util.Arrays; public class SelectionSorterTest { // Factories // Queries /** * Sorts a copy of the input array. * @param input an array. * @return a sorted copy of input. */ public static int[] sort (int[] input) { int[] sorted = Arrays.copyOf(input, input.length); for(int i = 0; i &lt; sorted.length - 1; i++) { int minIndex = i; for(int j = i + 1; j &lt; sorted.length - 1; j++) { if(sorted[j] &lt; sorted[minIndex]) { minIndex = j; } } if(i != minIndex) { swap(sorted, minIndex, i); } } return sorted; } // Commands // Private // disabled constructor private SelectionSorterTest () { } private static void swap (int[] arr, int x, int y) { int temp = arr[x]; arr[x] = arr[y]; arr[y] = temp; } public static void main(String[] args) { int[] Array = {9,7,6,4,3,2,21,1}; System.out.println(sort(Array)); } } </code></pre>
0debug
int av_write_trailer(AVFormatContext *s) { int ret, i; for (;; ) { AVPacket pkt; ret = interleave_packet(s, &pkt, NULL, 1); if (ret < 0) goto fail; if (!ret) break; ret = s->oformat->write_packet(s, &pkt); if (ret >= 0) s->streams[pkt.stream_index]->nb_frames++; av_free_packet(&pkt); if (ret < 0) goto fail; } if (s->oformat->write_trailer) ret = s->oformat->write_trailer(s); if (!(s->oformat->flags & AVFMT_NOFILE)) avio_flush(s->pb); fail: for (i = 0; i < s->nb_streams; i++) { av_freep(&s->streams[i]->priv_data); av_freep(&s->streams[i]->index_entries); } if (s->oformat->priv_class) av_opt_free(s->priv_data); av_freep(&s->priv_data); return ret; }
1threat
Is it possible to tie the Graphic which I drawn with action listener : <p>I drawn some rectangle, using Graphic g. </p> <p>Is it possible that I use the rectangle I drawn and tie it with some code. So that when I click on that rectangle. Some action happen. </p>
0debug
static void gen_loop(DisasContext *ctx, int r1, int32_t offset) { int l1; l1 = gen_new_label(); tcg_gen_subi_tl(cpu_gpr_a[r1], cpu_gpr_a[r1], 1); tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr_a[r1], -1, l1); gen_goto_tb(ctx, 1, ctx->pc + offset); gen_set_label(l1); gen_goto_tb(ctx, 0, ctx->next_pc); }
1threat
static int cow_find_streak(const uint8_t *bitmap, int value, int start, int nb_sectors) { int streak_value = value ? 0xFF : 0; int last = MIN(start + nb_sectors, BITS_PER_BITMAP_SECTOR); int bitnum = start; while (bitnum < last) { if ((bitnum & 7) == 0 && bitmap[bitnum / 8] == streak_value) { bitnum += 8; continue; } if (cow_test_bit(bitnum, bitmap) == value) { bitnum++; continue; } break; } return MIN(bitnum, last) - start; }
1threat
Printing on only one line : <p>I have a program that has to only print data onto one line.</p> <p>What can I do to do this.</p> <pre><code>for i in range(10): print(i) </code></pre> <p>Is it possible to print all of this on one line so it prints 0, erases the line, print 2, erases, etc..?</p>
0debug
void do_interrupt(CPUState *env) { int ex_vec = -1; D(fprintf (stderr, "exception index=%d interrupt_req=%d\n", env->exception_index, env->interrupt_request)); switch (env->exception_index) { case EXCP_BREAK: ex_vec = env->trap_vector; env->pregs[PR_ERP] = env->pc + 2; break; case EXCP_MMU_FAULT: ex_vec = env->fault_vector; env->pregs[PR_ERP] = env->pc; break; default: if (!(env->pregs[PR_CCS] & I_FLAG)) return; ex_vec = env->interrupt_vector; env->pregs[PR_ERP] = env->pc; break; } if ((env->pregs[PR_CCS] & U_FLAG)) { D(fprintf(logfile, "excp isr=%x PC=%x ERP=%x pid=%x ccs=%x cc=%d %x\n", ex_vec, env->pc, env->pregs[PR_ERP], env->pregs[PR_PID], env->pregs[PR_CCS], env->cc_op, env->cc_mask)); } env->pc = ldl_code(env->pregs[PR_EBP] + ex_vec * 4); if (env->pregs[PR_CCS] & U_FLAG) { env->pregs[PR_USP] = env->regs[R_SP]; env->regs[R_SP] = env->ksp; } cris_shift_ccs(env); D(fprintf (logfile, "%s isr=%x vec=%x ccs=%x pid=%d erp=%x\n", __func__, env->pc, ex_vec, env->pregs[PR_CCS], env->pregs[PR_PID], env->pregs[PR_ERP])); }
1threat
static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum) { if (o->max*den < num*intnum || o->min*den > num*intnum) { av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range\n", num*intnum/den, o->name); return AVERROR(ERANGE); } switch (o->type) { case AV_OPT_TYPE_FLAGS: case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break; case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break; case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break; case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break; case AV_OPT_TYPE_RATIONAL: if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den}; else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24); break; default: return AVERROR(EINVAL); } return 0; }
1threat
Python 3.5 Extract Digits from Column into New Column : <p>I am trying to extract the last 5 digits of a number in a columun in a CSV and add it as an additional column. There are more columns in my actual data, and there are thousands of rows of numbers. For example:</p> <pre><code>Column 1, Column 2, Column 3, Column 4 3333333, 1234567, 4444444, 5555555 7777777, 7654321, 5555555, 6666666 </code></pre> <p>and I want it to be:</p> <pre><code> Column 1, Column 2, Column 3, Column 4, Column 5 33333333, 1234567, 44444444, 55555555, 34567 77777777, 7654321, 55555555, 66666666, 54321 </code></pre> <p>So far I have tried iterations of findall and think that regex is going to provide the best solution. I can extract the column, not exactly what I want to do, but so far that is as far as I have gotten.</p>
0debug
How to Find 2 second lowest number from integer without using any array or user defined functions in c#? : If i have `478523698` as an integer number, how to find 2nd lowest number only with if conditions wihout converting it to string, this question was asked in interview.
0debug
onitemclick listener not working in list view,i want toast msg at position where i clicked,but toast msg of each position is shown : /** * Created by Sonu on 09-Jun-16. */ public class EastContent extends AppCompatActivity implements AdapterView.OnItemClickListener{ public static ArrayList j; ListView listView; String s="sonu"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.east_content); Intent iin= getIntent(); Bundle b = iin.getExtras(); String[] array={"sonu","monu","ronu","sone"}; ArrayList<String> list=new ArrayList(); list.addAll(Arrays.asList(array)); j=b.getStringArrayList("name"); listView= (ListView) findViewById(R.id.listview); ArrayAdapter adapter=new ArrayAdapter(this,R.layout.customtextview,R.id.textViewcustom,array); listView.setAdapter(adapter); listView.setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position){ case 0: Toast.makeText(getApplication(),"good hai",Toast.LENGTH_SHORT).show(); case 1: Toast.makeText(getApplication(),"achha nahi hai",Toast.LENGTH_SHORT).show(); case 2: Toast.makeText(getApplication(),"achha cool hai",Toast.LENGTH_SHORT).show(); case 3: Toast.makeText(getApplication(),"sdvvgsgvrsg",Toast.LENGTH_SHORT).show(); } }} enter code here**strong text**
0debug
static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) { codebook_t * cb; floor_t * fc; residue_t * rc; mapping_t * mc; int i, book; venc->channels = avccontext->channels; venc->sample_rate = avccontext->sample_rate; venc->blocksize[0] = venc->blocksize[1] = 11; venc->ncodebooks = 29; venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks); int codebook0[] = { 2, 10, 8, 14, 7, 12, 11, 14, 1, 5, 3, 7, 4, 9, 7, 13, }; int codebook1[] = { 1, 4, 2, 6, 3, 7, 5, 7, }; int codebook2[] = { 1, 5, 7, 21, 5, 8, 9, 21, 10, 9, 12, 20, 20, 16, 20, 20, 4, 8, 9, 20, 6, 8, 9, 20, 11, 11, 13, 20, 20, 15, 17, 20, 9, 11, 14, 20, 8, 10, 15, 20, 11, 13, 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, 13, 20, 20, 20, 18, 18, 20, 20, 20, 20, 20, 20, 3, 6, 8, 20, 6, 7, 9, 20, 10, 9, 12, 20, 20, 20, 20, 20, 5, 7, 9, 20, 6, 6, 9, 20, 10, 9, 12, 20, 20, 20, 20, 20, 8, 10, 13, 20, 8, 9, 12, 20, 11, 10, 12, 20, 20, 20, 20, 20, 18, 20, 20, 20, 15, 17, 18, 20, 18, 17, 18, 20, 20, 20, 20, 20, 7, 10, 12, 20, 8, 9, 11, 20, 14, 13, 14, 20, 20, 20, 20, 20, 6, 9, 12, 20, 7, 8, 11, 20, 12, 11, 13, 20, 20, 20, 20, 20, 9, 11, 15, 20, 8, 10, 14, 20, 12, 11, 14, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 11, 16, 18, 20, 15, 15, 17, 20, 20, 17, 20, 20, 20, 20, 20, 20, 9, 14, 16, 20, 12, 12, 15, 20, 17, 15, 18, 20, 20, 20, 20, 20, 16, 19, 18, 20, 15, 16, 20, 20, 17, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, }; int codebook3[] = { 2, 3, 7, 13, 4, 4, 7, 15, 8, 6, 9, 17, 21, 16, 15, 21, 2, 5, 7, 11, 5, 5, 7, 14, 9, 7, 10, 16, 17, 15, 16, 21, 4, 7, 10, 17, 7, 7, 9, 15, 11, 9, 11, 16, 21, 18, 15, 21, 18, 21, 21, 21, 15, 17, 17, 19, 21, 19, 18, 20, 21, 21, 21, 20, }; int codebook4[] = { 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 7, 5, 7, 5, 7, 5, 7, 5, 8, 6, 8, 6, 8, 6, 9, 6, 9, 6, 10, 6, 10, 6, 11, 6, 11, 7, 11, 7, 12, 7, 12, 7, 12, 7, 12, 7, 12, 7, 12, 7, 12, 7, 12, 8, 13, 8, 12, 8, 12, 8, 13, 8, 13, 9, 13, 9, 13, 9, 13, 9, 12, 10, 12, 10, 13, 10, 14, 11, 14, 12, 14, 13, 14, 13, 14, 14, 15, 16, 15, 15, 15, 14, 15, 17, 21, 22, 22, 21, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, }; int codebook5[] = { 2, 5, 5, 4, 5, 4, 5, 4, 5, 4, 6, 5, 6, 5, 6, 5, 6, 5, 7, 5, 7, 6, 8, 6, 8, 6, 8, 6, 9, 6, 9, 6, }; int codebook6[] = { 8, 5, 8, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 8, 4, 8, 4, 9, 5, 9, 5, 9, 5, 9, 5, 9, 6, 10, 6, 10, 7, 10, 8, 11, 9, 11, 11, 12, 13, 12, 14, 13, 15, 13, 15, 14, 16, 14, 17, 15, 17, 15, 15, 16, 16, 15, 16, 16, 16, 15, 18, 16, 15, 17, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, }; int codebook7[] = { 1, 5, 5, 5, 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 6, 7, 7, 7, 7, 8, 7, 8, 8, 9, 8, 10, 9, 10, 9, }; int codebook8[] = { 4, 3, 4, 3, 4, 4, 5, 4, 5, 4, 5, 5, 6, 5, 6, 5, 7, 5, 7, 6, 7, 6, 8, 7, 8, 7, 8, 7, 9, 8, 9, 9, 9, 9, 10, 10, 10, 11, 9, 12, 9, 12, 9, 15, 10, 14, 9, 13, 10, 13, 10, 12, 10, 12, 10, 13, 10, 12, 11, 13, 11, 14, 12, 13, 13, 14, 14, 13, 14, 15, 14, 16, 13, 13, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, }; int codebook9[] = { 4, 5, 4, 5, 3, 5, 3, 5, 3, 5, 4, 4, 4, 4, 5, 5, 5, }; int codebook10[] = { 3, 3, 4, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 5, 7, 5, 8, 6, 8, 6, 9, 7, 10, 7, 10, 8, 10, 8, 11, 9, 11, }; int codebook11[] = { 3, 7, 3, 8, 3, 10, 3, 8, 3, 9, 3, 8, 4, 9, 4, 9, 5, 9, 6, 10, 6, 9, 7, 11, 7, 12, 9, 13, 10, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, }; int codebook12[] = { 4, 5, 4, 5, 4, 5, 4, 5, 3, 5, 3, 5, 3, 5, 4, 5, 4, }; int codebook13[] = { 4, 2, 4, 2, 5, 3, 5, 4, 6, 6, 6, 7, 7, 8, 7, 8, 7, 8, 7, 9, 8, 9, 8, 9, 8, 10, 8, 11, 9, 12, 9, 12, }; int codebook14[] = { 2, 5, 2, 6, 3, 6, 4, 7, 4, 7, 5, 9, 5, 11, 6, 11, 6, 11, 7, 11, 6, 11, 6, 11, 9, 11, 8, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, }; int codebook15[] = { 5, 6, 11, 11, 11, 11, 10, 10, 12, 11, 5, 2, 11, 5, 6, 6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, 8, 8, 8, 8, 10, 10, 0, 0, 0, 8, 8, 8, 8, 10, 10, 0, 0, 0, 9, 9, 9, 9, 10, 10, 0, 0, 0, 9, 9, 9, 9, 10, 10, 0, 0, 0, 10, 10, 10, 10, 11, 11, 0, 0, 0, 0, 0, 10, 10, 11, 11, }; int codebook21[] = { 2, 3, 3, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 10, 10, 11, 10, 0, 5, 5, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 0, 5, 5, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 0, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, 11, 11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, 11, 12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, 12, 12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, 12, 12, 0, 0, 0, 9, 9, 9, 9, 10, 10, 10, 10, 11, 10, 11, 11, 12, 12, 0, 0, 0, 0, 0, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 0, 0, 0, 0, 0, 9, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 0, 0, 0, 0, 0, 8, 8, 9, 9, 10, 10, 11, 11, 12, 11, 12, 12, 0, 0, 0, 0, 0, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 13, 13, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 0, 0, 0, 0, 0, 0, 0, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12, 13, 13, 13, 13, }; int codebook22[] = { 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7, 10, 9, 9, 11, 9, 9, 4, 7, 7, 10, 9, 9, 11, 9, 9, 7, 10, 10, 11, 11, 10, 12, 11, 11, 6, 9, 9, 11, 10, 10, 11, 10, 10, 6, 9, 9, 11, 10, 10, 11, 10, 10, 7, 11, 11, 11, 11, 11, 12, 11, 11, 6, 9, 9, 11, 10, 10, 11, 10, 10, 6, 9, 9, 11, 10, 10, 11, 10, 10, }; int codebook23[] = { 2, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 10, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 10, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 10, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 10, 10, 10, 7, 7, 8, 7, 8, 8, 8, 8, 10, 10, 10, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 7, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 9, 9, 8, 8, 9, 8, 10, 10, 10, 10, 10, 8, 8, 8, 8, 8, 8, }; int codebook24[] = { 1, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 6, 5, 5, 7, 7, 8, 8, 8, 8, 9, 9, 10, 10, 7, 5, 5, 7, 7, 8, 8, 8, 8, 9, 9, 11, 10, 0, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, 0, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, 0, 12, 12, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 0, 13, 13, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12, 0, 0, 0, 10, 10, 10, 10, 11, 11, 12, 12, 12, 12, 0, 0, 0, 10, 10, 10, 10, 11, 11, 12, 12, 12, 12, 0, 0, 0, 14, 14, 11, 11, 11, 11, 12, 12, 13, 13, 0, 0, 0, 14, 14, 11, 11, 11, 11, 12, 12, 13, 13, 0, 0, 0, 0, 0, 12, 12, 12, 12, 13, 13, 14, 13, 0, 0, 0, 0, 0, 13, 13, 12, 12, 13, 12, 14, 13, }; int codebook25[] = { 2, 4, 4, 5, 5, 6, 5, 5, 5, 5, 6, 4, 5, 5, 5, 6, 5, 5, 5, 5, 6, 6, 6, 5, 5, }; int codebook26[] = { 1, 4, 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 9, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 9, 7, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, }; int codebook27[] = { 1, 4, 4, 6, 6, 7, 7, 8, 7, 9, 9, 10, 10, 10, 10, 6, 5, 5, 7, 7, 8, 8, 10, 8, 11, 10, 12, 12, 13, 13, 6, 5, 5, 7, 7, 8, 8, 10, 9, 11, 11, 12, 12, 13, 12, 18, 8, 8, 8, 8, 9, 9, 10, 9, 11, 10, 12, 12, 13, 13, 18, 8, 8, 8, 8, 9, 9, 10, 10, 11, 11, 13, 12, 14, 13, 18, 11, 11, 9, 9, 10, 10, 11, 11, 11, 12, 13, 12, 13, 14, 18, 11, 11, 9, 8, 11, 10, 11, 11, 11, 11, 12, 12, 14, 13, 18, 18, 18, 10, 11, 10, 11, 12, 12, 12, 12, 13, 12, 14, 13, 18, 18, 18, 10, 11, 11, 9, 12, 11, 12, 12, 12, 13, 13, 13, 18, 18, 17, 14, 14, 11, 11, 12, 12, 13, 12, 14, 12, 14, 13, 18, 18, 18, 14, 14, 11, 10, 12, 9, 12, 13, 13, 13, 13, 13, 18, 18, 17, 16, 18, 13, 13, 12, 12, 13, 11, 14, 12, 14, 14, 17, 18, 18, 17, 18, 13, 12, 13, 10, 12, 11, 14, 14, 14, 14, 17, 18, 18, 18, 18, 15, 16, 12, 12, 13, 10, 14, 12, 14, 15, 18, 18, 18, 16, 17, 16, 14, 12, 11, 13, 10, 13, 13, 14, 15, }; int codebook28[] = { 2, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 10, 6, 6, 7, 7, 8, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 9, 10, 10, 10, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 10, 11, 11, 11, 9, 9, 9, 9, 9, 9, 10, 10, 9, 9, 10, 9, 11, 10, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 10, 10, 9, 9, 9, 9, 10, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 10, 9, 10, 10, 9, 10, 9, 9, 10, 9, 11, 10, 10, 11, 11, 11, 11, 9, 10, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 10, 10, 10, 9, 9, 10, 9, 10, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 10, 10, 10, }; int codebook_sizes[] = { 16, 8, 256, 64, 128, 32, 96, 32, 96, 17, 32, 78, 17, 32, 78, 100, 1641, 443, 105, 68, 81, 289, 81, 121, 169, 25, 169, 225, 289, }; int * codebook_lens[] = { codebook0, codebook1, codebook2, codebook3, codebook4, codebook5, codebook6, codebook7, codebook8, codebook9, codebook10, codebook11, codebook12, codebook13, codebook14, codebook15, codebook16, codebook17, codebook18, codebook19, codebook20, codebook21, codebook22, codebook23, codebook24, codebook25, codebook26, codebook27, codebook28, }; struct { int lookup; int dim; float min; float delta; int real_len; int * quant; } cvectors[] = { { 1, 8, -1.0, 1.0, 6561,(int[]){ 1, 0, 2, } }, { 1, 4, -2.0, 1.0, 625, (int[]){ 2, 1, 3, 0, 4, } }, { 1, 4, -2.0, 1.0, 625, (int[]){ 2, 1, 3, 0, 4, } }, { 1, 2, -4.0, 1.0, 81, (int[]){ 4, 3, 5, 2, 6, 1, 7, 0, 8, } }, { 1, 2, -4.0, 1.0, 81, (int[]){ 4, 3, 5, 2, 6, 1, 7, 0, 8, } }, { 1, 2, -8.0, 1.0, 289, (int[]){ 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15, 0, 16, } }, { 1, 4, -11.0, 11.0, 81, (int[]){ 1, 0, 2, } }, { 1, 2, -5.0, 1.0, 121, (int[]){ 5, 4, 6, 3, 7, 2, 8, 1, 9, 0, 10, } }, { 1, 2, -30.0, 5.0, 169, (int[]){ 6, 5, 7, 4, 8, 3, 9, 2, 10, 1, 11, 0, 12, } }, { 1, 2, -2.0, 1.0, 25, (int[]){ 2, 1, 3, 0, 4, } }, { 1, 2, -1530.0, 255.0, 169, (int[]){ 6, 5, 7, 4, 8, 3, 9, 2, 10, 1, 11, 0, 12, } }, { 1, 2, -119.0, 17.0, 225, (int[]){ 7, 6, 8, 5, 9, 4, 10, 3, 11, 2, 12, 1, 13, 0, 14, } }, { 1, 2, -8.0, 1.0, 289, (int[]){ 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15, 0, 16, } }, }; for (book = 0; book < venc->ncodebooks; book++) { cb = &venc->codebooks[book]; cb->nentries = codebook_sizes[book]; if (book < 16) { cb->ndimentions = 2; cb->min = 0.; cb->delta = 0.; cb->seq_p = 0; cb->lookup = 0; cb->quantlist = NULL; } else { int vals; cb->seq_p = 0; cb->nentries = cvectors[book - 16].real_len; cb->ndimentions = cvectors[book - 16].dim; cb->min = cvectors[book - 16].min; cb->delta = cvectors[book - 16].delta; cb->lookup = cvectors[book - 16].lookup; vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries); cb->quantlist = av_malloc(sizeof(int) * vals); for (i = 0; i < vals; i++) cb->quantlist[i] = cvectors[book - 16].quant[i]; } cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries); for (i = 0; i < cb->nentries; i++) { if (i < codebook_sizes[book]) cb->entries[i].len = codebook_lens[book][i]; else cb->entries[i].len = 0; } ready_codebook(cb); } venc->nfloors = 1; venc->floors = av_malloc(sizeof(floor_t) * venc->nfloors); fc = &venc->floors[0]; fc->partitions = 8; fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions); fc->nclasses = 0; for (i = 0; i < fc->partitions; i++) { int a[] = {0,1,2,2,3,3,4,4}; fc->partition_to_class[i] = a[i]; fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[i]); } fc->nclasses++; fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses); for (i = 0; i < fc->nclasses; i++) { floor_class_t * c = &fc->classes[i]; int j, books; int dim[] = {3,4,3,4,3}; int subclass[] = {0,1,1,2,2}; int masterbook[] = {0,0,1,2,3}; int * nbooks[] = { (int[]){ 4 }, (int[]){ 5, 6 }, (int[]){ 7, 8 }, (int[]){ -1, 9, 10, 11 }, (int[]){ -1, 12, 13, 14 }, }; c->dim = dim[i]; c->subclass = subclass[i]; c->masterbook = masterbook[i]; books = (1 << c->subclass); c->books = av_malloc(sizeof(int) * books); for (j = 0; j < books; j++) c->books[j] = nbooks[i][j]; } fc->multiplier = 2; fc->rangebits = venc->blocksize[0] - 1; fc->values = 2; for (i = 0; i < fc->partitions; i++) fc->values += fc->classes[fc->partition_to_class[i]].dim; fc->list = av_malloc(sizeof(floor_entry_t) * fc->values); fc->list[0].x = 0; fc->list[1].x = 1 << fc->rangebits; for (i = 2; i < fc->values; i++) { int a[] = {93,23,372,6,46,186,750,14,33,65,130,260,556,3,10,18,28,39,55,79,111,158,220,312,464,650,850}; fc->list[i].x = a[i - 2]; } ready_floor(fc); venc->nresidues = 1; venc->residues = av_malloc(sizeof(residue_t) * venc->nresidues); rc = &venc->residues[0]; rc->type = 2; rc->begin = 0; rc->end = 1600; rc->partition_size = 32; rc->classifications = 10; rc->classbook = 15; rc->books = av_malloc(sizeof(int[8]) * rc->classifications); for (i = 0; i < rc->classifications; i++) { int a[10][8] = { { -1, -1, -1, -1, -1, -1, -1, -1, }, { -1, -1, 16, -1, -1, -1, -1, -1, }, { -1, -1, 17, -1, -1, -1, -1, -1, }, { -1, -1, 18, -1, -1, -1, -1, -1, }, { -1, -1, 19, -1, -1, -1, -1, -1, }, { -1, -1, 20, -1, -1, -1, -1, -1, }, { -1, -1, 21, -1, -1, -1, -1, -1, }, { 22, 23, -1, -1, -1, -1, -1, -1, }, { 24, 25, -1, -1, -1, -1, -1, -1, }, { 26, 27, 28, -1, -1, -1, -1, -1, }, }; int j; for (j = 0; j < 8; j++) rc->books[i][j] = a[i][j]; } ready_residue(rc, venc); venc->nmappings = 1; venc->mappings = av_malloc(sizeof(mapping_t) * venc->nmappings); mc = &venc->mappings[0]; mc->submaps = 1; mc->mux = av_malloc(sizeof(int) * venc->channels); for (i = 0; i < venc->channels; i++) mc->mux[i] = 0; mc->floor = av_malloc(sizeof(int) * mc->submaps); mc->residue = av_malloc(sizeof(int) * mc->submaps); for (i = 0; i < mc->submaps; i++) { mc->floor[i] = 0; mc->residue[i] = 0; } mc->coupling_steps = venc->channels == 2 ? 1 : 0; mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps); mc->angle = av_malloc(sizeof(int) * mc->coupling_steps); if (mc->coupling_steps) { mc->magnitude[0] = 0; mc->angle[0] = 1; } venc->nmodes = 1; venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes); venc->modes[0].blockflag = 0; venc->modes[0].mapping = 0; venc->have_saved = 0; venc->saved = av_malloc(sizeof(float) * venc->channels * (1 << venc->blocksize[1]) / 2); venc->samples = av_malloc(sizeof(float) * venc->channels * (1 << venc->blocksize[1])); venc->floor = av_malloc(sizeof(float) * venc->channels * (1 << venc->blocksize[1]) / 2); venc->coeffs = av_malloc(sizeof(float) * venc->channels * (1 << venc->blocksize[1]) / 2); venc->win[0] = ff_vorbis_vwin[venc->blocksize[0] - 6]; venc->win[1] = ff_vorbis_vwin[venc->blocksize[1] - 6]; ff_mdct_init(&venc->mdct[0], venc->blocksize[0], 0); ff_mdct_init(&venc->mdct[1], venc->blocksize[1], 0); }
1threat
How to "grep" lines of a file by range of value : <p>I have a file with timestamps and I want to grep it so that I can see the lines matching 12:30:00 - 12:32:00 . I know that in bash there is the {0..2} for doing something similar but I dont know in grep how to do it? At the moment I am doing <code>grep 2015-01-12 12:3{0..2}</code> but it doesnt work?</p>
0debug
What does it mean to bind() a socket to any address other than localhost? : <p>I don't understand what it <em>means</em> to <code>bind</code> a socket to any address other than 127.0.0.1 (or ::1, etc.).<br> Am I not -- <em>by definition</em> -- binding the socket to a port on <strong>my own</strong> machine.. which is localhost?<br> What sense does it make to bind or listen to <em>another</em> machine or IP address's port?<br> Conceptually, it just doesn't make sense to me!</p> <p>(This has proven surprisingly hard to Google... possibly because I'm not Googling the right terms.)</p>
0debug
static USBDevice *usb_msd_init(USBBus *bus, const char *filename) { static int nr=0; char id[8]; QemuOpts *opts; DriveInfo *dinfo; USBDevice *dev; const char *p1; char fmt[32]; snprintf(id, sizeof(id), "usb%d", nr++); opts = qemu_opts_create(qemu_find_opts("drive"), id, 0); p1 = strchr(filename, ':'); if (p1++) { const char *p2; if (strstart(filename, "format=", &p2)) { int len = MIN(p1 - p2, sizeof(fmt)); pstrcpy(fmt, len, p2); qemu_opt_set(opts, "format", fmt); } else if (*filename != ':') { printf("unrecognized USB mass-storage option %s\n", filename); return NULL; } filename = p1; } if (!*filename) { printf("block device specification needed\n"); return NULL; } qemu_opt_set(opts, "file", filename); qemu_opt_set(opts, "if", "none"); dinfo = drive_init(opts, 0); if (!dinfo) { qemu_opts_del(opts); return NULL; } dev = usb_create(bus, "usb-storage"); if (!dev) { return NULL; } if (qdev_prop_set_drive(&dev->qdev, "drive", dinfo->bdrv) < 0) { qdev_free(&dev->qdev); return NULL; } if (qdev_init(&dev->qdev) < 0) return NULL; return dev; }
1threat
Mockito cannot mock this class : <p>I am attempting to mock a public class, however when doing so, Mockito throws an <code>Mockito cannot mock this class</code> exception.</p> <p>Class I wish to mock: <a href="https://github.com/scribejava/scribejava/blob/master/scribejava-core/src/main/java/com/github/scribejava/core/builder/ServiceBuilder.java" rel="noreferrer">https://github.com/scribejava/scribejava/blob/master/scribejava-core/src/main/java/com/github/scribejava/core/builder/ServiceBuilder.java</a></p> <p>Test code:</p> <pre><code>package xyz.jacobclark.adapter; import com.github.scribejava.apis.TwitterApi; import com.github.scribejava.core.builder.ServiceBuilder; import com.github.scribejava.core.model.OAuth1RequestToken; import com.github.scribejava.core.oauth.OAuth10aService; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import java.io.IOException; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsInstanceOf.any; @RunWith(MockitoJUnitRunner.class) public class TwitterOAuthAdapterTest { @Mock ServiceBuilder serviceBuilder; @Test public void getRequestTokenShouldReturnAValidRequestToken() throws IOException { class TwitterOAuthAdapter { private final OAuth10aService service; public TwitterOAuthAdapter(ServiceBuilder serviceBuilder){ this.service = serviceBuilder .apiKey("") .apiSecret("") .build(TwitterApi.instance()); } public OAuth1RequestToken getRequestToken() throws IOException { return this.service.getRequestToken(); } } TwitterOAuthAdapter oAuthAdapter = new TwitterOAuthAdapter(serviceBuilder); Assert.assertThat(oAuthAdapter.getRequestToken(), is(any(OAuth1RequestToken.class))); } } </code></pre> <p>Full stacktrace:</p> <pre><code>xyz.jacobclark.adapter.TwitterOAuthAdapterTest org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class: class com.github.scribejava.core.builder.ServiceBuilder. Mockito can only mock non-private &amp; non-final classes. If you're not sure why you're getting this error, please report to the mailing list. Java : 1.8 JVM vendor name : Oracle Corporation JVM vendor version : 25.0-b70 JVM name : Java HotSpot(TM) 64-Bit Server VM JVM version : 1.8.0-b132 JVM info : mixed mode OS name : Mac OS X OS version : 10.11.3 Underlying exception : java.lang.IllegalArgumentException: object is not an instance of declaring class at org.mockito.internal.runners.SilentJUnitRunner$1.withBefores(SilentJUnitRunner.java:29) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:276) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.mockito.internal.runners.SilentJUnitRunner.run(SilentJUnitRunner.java:39) at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39) at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:103) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$ForTypeArgument.resolve(TypeDescription.java:3843) at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Delegator$Chained.resolve(TypeDescription.java:3468) at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$ForTypeArgument.resolve(TypeDescription.java:3803) at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Delegator.asList(TypeDescription.java:3439) at net.bytebuddy.description.type.TypeDescription$Generic$OfWildcardType$ForLoadedType.getDeclaredAnnotations(TypeDescription.java:4748) at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$TypeVariableErasing.onWildcard(TypeDescription.java:680) at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$TypeVariableErasing.onWildcard(TypeDescription.java:663) at net.bytebuddy.description.type.TypeDescription$Generic$OfWildcardType.accept(TypeDescription.java:4656) at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$TypeVariableErasing.onParameterizedType(TypeDescription.java:691) at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$TypeVariableErasing.onParameterizedType(TypeDescription.java:663) at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:4998) at net.bytebuddy.description.type.TypeList$Generic$AbstractBase.accept(TypeList.java:249) at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$TypeVariableErasing$RetainedTypeVariable.getUpperBounds(TypeDescription.java:832) at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.asErasure(TypeDescription.java:5373) at net.bytebuddy.description.method.MethodDescription$AbstractBase.asTypeToken(MethodDescription.java:701) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$Default$Key$Harmonized.of(MethodGraph.java:881) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$Default$Key$Store.registerTopLevel(MethodGraph.java:1074) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$Default.doAnalyze(MethodGraph.java:588) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$Default.analyze(MethodGraph.java:548) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$Default.analyzeNullable(MethodGraph.java:567) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$Default.doAnalyze(MethodGraph.java:581) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$Default.compile(MethodGraph.java:521) at net.bytebuddy.dynamic.scaffold.MethodGraph$Compiler$AbstractBase.compile(MethodGraph.java:442) at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default.prepare(MethodRegistry.java:480) at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:160) at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:153) at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:2568) at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:2670) at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:84) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$CachedBytecodeGenerator.getOrGenerateMockClass(TypeCachingBytecodeGenerator.java:91) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:38) at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:67) at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:38) at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:26) at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35) at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63) at org.mockito.Mockito.mock(Mockito.java:1637) at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:33) at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16) at org.mockito.internal.configuration.DefaultAnnotationEngine.createMockFor(DefaultAnnotationEngine.java:39) at org.mockito.internal.configuration.DefaultAnnotationEngine.process(DefaultAnnotationEngine.java:63) at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:59) at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:43) at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:67) ... 23 more Test ignored. Process finished with exit code 255 </code></pre>
0debug
static int asf_read_replicated_data(AVFormatContext *s, ASFPacket *asf_pkt) { ASFContext *asf = s->priv_data; AVIOContext *pb = s->pb; int ret; if (!asf_pkt->data_size) { asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); if (asf_pkt->data_size <= 0) return AVERROR_INVALIDDATA; if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0) return ret; } else avio_skip(pb, 4); asf_pkt->dts = avio_rl32(pb); if (asf->rep_data_len && (asf->rep_data_len >= 8)) avio_skip(pb, asf->rep_data_len - 8); return 0; }
1threat
uint32_t lm4549_read(lm4549_state *s, target_phys_addr_t offset) { uint16_t *regfile = s->regfile; uint32_t value = 0; assert(offset < 128); value = regfile[offset]; DPRINTF("read [0x%02x] = 0x%04x\n", offset, value); return value; }
1threat
ypeError: book() takes 1 positional argument but 2 were given : when I run code my kivy window closes and show the error I have tried a lot of things but not able to solve the problem here I am having a windows application where there are 4 buttons when a user click on it he should jump on to next screen but when I click on it, kivy window closes `enter code here` class main_menu(Screen): def __init__(self, **kwargs): super().__init__(**kwargs) self.pic = self.ids["pic"] self.pic1 = self.ids["pic1"] self.ac=self.ids["ac"] self.sd=self.ids["sd"] print(phone) #self.ac.text=self.user_text.text #print(self.l.user_text.text,"jkckhjkfgh") self.lst = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"] self.sql="select * from snm" cursor.execute(self.sql) self.result = cursor.fetchall() self.pic.add_widget(Button(text = " {} ".format(self.result[0][0]) + '\n' + " {} , {} ".format(self.result[0][2],self.result[0][3]) + "\n\n Seating Capacity :" + " {}".format(self.result[0][1]) ,font_size=30 ,font_name="font1" ,background_normal=self.lst[0] ,on_press=self.book )) self.pic.add_widget(Button(text=" {} ".format(self.result[1][0]) + '\n' + " {} , {} ".format(self.result[1][2], self.result[1][3]) + "\n\n Seating Capacity :" + " {}".format(self.result[1][1]) ,font_size=30 ,font_name="font1" ,background_normal=self.lst[1] ,on_press=self.book )) self.pic.add_widget(Button(text=" {} ".format(self.result[2][0]) + '\n' + " {} , {} ".format(self.result[2][2], self.result[2][3]) + "\n\n Seating Capacity :" + " {}".format(self.result[2][1]) ,font_size=30 ,font_name="font1" ,background_normal=self.lst[2] ,on_press=self.book )) self.pic.add_widget(Button(text=" {} ".format(self.result[3][0]) + '\n' + " {} , {} ".format(self.result[3][2], self.result[3][3]) + "\n\n Seating Capacity :" + " {}".format(self.result[3][1]) ,font_size=30 ,font_name="font1" ,background_normal=self.lst[3] ,on_press=self.book )) self.h = 4 self.pic.size = (100, self.h *600) def book(self): sm.current="main_menu" class PopUp(Popup): def set(self): self.title = 'Wrong Login Details' self.content = Label(text = 'You have entered wrong Login Details',font_size=30) self.size_hint = (None,None) self.size = (600,250) class book_ticket(Screen): def __init__(self,**kwargs): super().__init__(**kwargs) t1=signin(name='signin') t2=details(name='details') t3=main_menu(name="main_menu") t4=book_ticket(name="book_ticket") print(phone) print(type(t1)) #print(t1.user_text.text,phone,23) #create local login applic def Start(self): sm = ScreenManager() sm.add_widget(t1) sm.add_widget(t2) sm.add_widget(t3) sm.add_widget(t4) class main(App): def build(self): return main_menu() main().run() I am not able to figure out what to do
0debug
Compare Lines on csv file : <p>I have this csv file which has an answer key in the top row and all of the students answers below it in a roll like so:</p> <pre><code>First Name,Last Name,Student ID,Version,Score,1,2,3,4,5,6,7,8,9,10 Answer Key,,,p,75,j,c,g,c,g,d,f,a,j,c Mark,Mueller,14697,p,35,j,c,f,c,d,f,a,j,c,j Andruw ,Wittles,15674,p,75,a,c,d,f,h,g,a,d,j,d Bob,Johnson,32423,p,36,d,a,j,i,d,a,b,c,j,d John,Smith,12343,p,67,a,c,b,g,h,j,a,d,c,b </code></pre> <p>The problem is that I cant find a good way to compare the answer key and the students answers. If you could help me also give the student's id the score. (The 5 digit number after the name)</p> <p>Thanks.</p>
0debug
Convert numpy array type and values from Float64 to Float32 : <p>I am trying to convert threshold array(pickle file of isolation forest from scikit learn) of type from Float64 to Float32 </p> <pre><code>for i in range(len(tree.tree_.threshold)): tree.tree_.threshold[i] = tree.tree_.threshold[i].astype(np.float32) </code></pre> <p>​ Then Printing it</p> <pre><code>for value in tree.tree_.threshold[:5]: print(type(value)) print(value) </code></pre> <p>the output i am getting is :</p> <pre><code>&lt;class 'numpy.float64'&gt; 526226.0 &lt;class 'numpy.float64'&gt; 91.9514312744 &lt;class 'numpy.float64'&gt; 3.60330319405 &lt;class 'numpy.float64'&gt; -2.0 &lt;class 'numpy.float64'&gt; -2.0 </code></pre> <p>I am not getting a proper conversion to Float32. I want to convert values and their type to Float32, Did anybody have any workaround this ?</p>
0debug
Add line to Boxplot in GGPLOT2 : <p>Is there a way to add a horizontal line to a boxplot in ggplot2, that doesn't cut through the existing plot, but only the spaces in between?</p> <p>Thanks for your help...</p>
0debug
How to configure custom domain name for Amazon ECR : <p>Amazon Elastic Container Repositories (ECR) have quite human-unfriendly URIs, like <code>99999999999.dkr.ecr.eu-west-1.amazonaws.com</code>. Is it at all possible to configure custom domain name for an ECR? </p> <p>Simplistic solution would be to create a CNAME record to point to the ECR URI, but this doesn't really work (SSL certificate doesn't match the domain name, passwords generated by <code>aws ecr get-login</code> don't pass, cannot push images tagged with custom domain name...).</p> <p>Are there other options?</p>
0debug
how to apply floating lable to edit text in android in java file instead of xml : I want to know is there any way we can apply floating lable for edit text using java instead of xml. If yes please tell me the way how to do the same.
0debug
static int ioreq_runio_qemu_aio(struct ioreq *ioreq) { struct XenBlkDev *blkdev = ioreq->blkdev; if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1) goto err; ioreq->aio_inflight++; if (ioreq->presync) bdrv_flush(blkdev->bs); switch (ioreq->req.operation) { case BLKIF_OP_READ: ioreq->aio_inflight++; bdrv_aio_readv(blkdev->bs, ioreq->start / BLOCK_SIZE, &ioreq->v, ioreq->v.size / BLOCK_SIZE, qemu_aio_complete, ioreq); break; case BLKIF_OP_WRITE: case BLKIF_OP_WRITE_BARRIER: ioreq->aio_inflight++; if (!ioreq->req.nr_segments) break; bdrv_aio_writev(blkdev->bs, ioreq->start / BLOCK_SIZE, &ioreq->v, ioreq->v.size / BLOCK_SIZE, qemu_aio_complete, ioreq); break; default: goto err; } if (ioreq->postsync) bdrv_flush(blkdev->bs); qemu_aio_complete(ioreq, 0); return 0; err: ioreq->status = BLKIF_RSP_ERROR; return -1; }
1threat
Simple algorithms that can be implemented on a FPGA : <p>I am new to FPGA programming and was planning on implementing several algorithms that may become useful in future to me when I am doing my projects. So, I wanted to ask for suggestions on things I could implement on FPGA (specially some interesting algorithms) ordered in difficulty level. Thank you!</p>
0debug
void qemu_chr_add_handlers(CharDriverState *s, IOCanReadHandler *fd_can_read, IOReadHandler *fd_read, IOEventHandler *fd_event, void *opaque) { if (!opaque) { ++s->avail_connections; } s->chr_can_read = fd_can_read; s->chr_read = fd_read; s->chr_event = fd_event; s->handler_opaque = opaque; if (s->chr_update_read_handler) s->chr_update_read_handler(s); if (s->opened) { qemu_chr_generic_open(s); } }
1threat
void qpci_io_writeq(QPCIDevice *dev, void *data, uint64_t value) { uintptr_t addr = (uintptr_t)data; if (addr < QPCI_PIO_LIMIT) { dev->bus->pio_writeq(dev->bus, addr, value); } else { value = cpu_to_le64(value); dev->bus->memwrite(dev->bus, addr, &value, sizeof(value)); } }
1threat
how to put getting rows from excel in an arrayllist in java? : The following code for reading the existing excel file in java. I want to get likely [[a, b], [b, c, d], [a, c, d, e], [a, d, e], [a, b, c], [a, b, c, d], [a], [a, b, c], [a, b, d], [b, c, e]]... where [a,b] referred to one row in excel file.Please help me.. public class Excel { public static void main(String[] args) throws FileNotFoundException { List<Set<String>> itemsetList = new ArrayList<>(); Scanner scanner = new Scanner(new File("bc_dataset.csv")); scanner.next(); while(scanner.hasNext()){ String str=scanner.next(); itemsetList.add(new HashSet<>(Arrays.asList(str.split(",")))); System.out.println(itemsetList); } scanner.close(); } }
0debug
What are the different ways of including libraries in a C++ project? : <p>Allow me to preface this question by letting you know that I have no formal CS education and have been self-learning C++.</p> <p>I would like to understand what the different ways of including third party libraries in a project are.</p> <p>How to identify how a project is to be included if there is an interesting library on github?</p> <p>I've read about concepts of dynamic and static linking in a windows context however I am still somewhat not clear about them.</p>
0debug
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) { UnsharpContext *unsharp = ctx->priv; int lmsize_x = 5, cmsize_x = 0; int lmsize_y = 5, cmsize_y = 0; double lamount = 1.0f, camount = 0.0f; if (args) sscanf(args, "%d:%d:%lf:%d:%d:%lf", &lmsize_x, &lmsize_y, &lamount, &cmsize_x, &cmsize_y, &camount); if ((lamount && (lmsize_x < 2 || lmsize_y < 2)) || (camount && (cmsize_x < 2 || cmsize_y < 2))) { av_log(ctx, AV_LOG_ERROR, "Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d\n", lmsize_x, lmsize_y, cmsize_x, cmsize_y); return AVERROR(EINVAL); } set_filter_param(&unsharp->luma, lmsize_x, lmsize_y, lamount); set_filter_param(&unsharp->chroma, cmsize_x, cmsize_y, camount); return 0; }
1threat
int s390_virtio_hypercall(CPUS390XState *env) { s390_virtio_fn fn = s390_diag500_table[env->regs[1]]; if (!fn) { return -EINVAL; } return fn(&env->regs[2]); }
1threat
i got this error in androidStudio : java.lang.NumberFormatException: For input string: " " : for example i want to create contacts that only has two fields name and age, but only name is important for me. public class Contact { public String name; public int age; public Contact(String name) { this.name = name; } public Contact() { } public Contact(String name,int age) { this.name = name; this.age=age } } in the part of code for some reason i need user add new Contact and its not important to insert age. after user submit i expect get new Contact. EditText editName=findviewByid(r.id.edit_name); EditText editAge=findviewByid(r.id.edit_age); . . . when user click the submit button : String name = editName.getText().toString().trim(); String age = editAge.getText().toString().trim(); Contact contact =new (name,Integer.parseInt(age)); if user didn't input age we got this error java.lang.NumberFormatException: For input string: ""
0debug
Looping over expect script not working : New at scripting, beware... I'm attempting to use this code that i put together from reading a couple blogs. The idea is for this script to read the IPs that i have saved on ips.txt and then run the code to ssh to the read IP using the credentials given, perform a couple send commands as described below, exit the ssh session, and repeat with the second line in the ips.txt file, which is a different IP, until it finishes the IPs list. Note: the ips.txt file is a simple list of IP addresses as follows (no spaces between the IPs): 192.168.0.2 192.168.0.3 192.168.0.4 ... The spawn, expect, and send commands work fine. It also loops fine back up to the beginning of the code but it will NOT read the second IP in the ips.txt file; it will just read the first one again and perform the same steps over and over. Please assist... #!/usr/bin/expect set timeout 180 set username admin set password Changeme1 set fildes [open "ips.txt" r] set ip [gets $fildes] while {[string length $ip] != 1} { spawn ssh $username@$ip expect "password:" send "$password\r" expect ".mi" send "show sw\r" expect ".mi" send "exit\r" set ip [gets $fildes] } close $fildes
0debug
void visit_start_list(Visitor *v, const char *name, Error **errp) { v->start_list(v, name, errp); }
1threat
Which kubernetes version is supported in docker version 18.09 : <p>I am using <code>Raspberry pi</code> for <code>kubernetes</code> cluster setup. I was using below docker version:</p> <pre><code>Client: Version: 18.06.1-ce API version: 1.38 Go version: go1.10.3 Git commit: e68fc7a Built: Tue Aug 21 17:30:52 2018 OS/Arch: linux/arm Experimental: false Server: Engine: Version: 18.06.1-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: e68fc7a Built: Tue Aug 21 17:26:37 2018 OS/Arch: linux/arm Experimental: false </code></pre> <p>Looks like now the docker version latest is <code>18.09.0</code> and the latest <code>kubernetes</code> version is not supporting this docker version. I have even tried installing some older version of kube like <code>1.9.7</code> or <code>1.9.6</code> but while initiating the <code>kubeadm init</code>, I am getting the below error:</p> <pre><code>[ERROR SystemVerification]: unsupported docker version: 18.09.0 [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...` </code></pre> <p>Which version should I specify for <code>kubernetes</code> and <code>docker</code> to run properly. Also how can we specify version while insatlling docker. I normally use below command to install docker:</p> <pre><code>curl -sSL get.docker.com | sh </code></pre>
0debug
static bool vmxnet3_peer_has_vnet_hdr(VMXNET3State *s) { NetClientState *nc = qemu_get_queue(s->nic); if (qemu_peer_has_vnet_hdr(nc)) { return true; } VMW_WRPRN("Peer has no virtio extension. Task offloads will be emulated."); return false; }
1threat
Dynamically creating table in javascript : I'm asking you for help with DOM table in JS. When I click buttons table will be creating automagically with example texts. I want to write a few functions for create table tag, thead, border and align center, caption, data (rows and cells with text), tfoot, deleting row, adding row. I don't know how to do it, so... thanks for the help guys ^^
0debug
calculating average and variance in c++ : <p>I need help with my code... I have no idea whats wrong or how to fix it. I think it has something with declaring my variables and referencing but I am not entirely sure how to fix the bugs. Please help! </p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;cmath&gt; using namespace std; double calculate_average(int test_values[], int&amp; size, int&amp; sum, double&amp; average) { int i; for (i = 0; i &lt; size; i++) { sum += test_values[i]; }; return average = sum / i; }; double var(int test_values[], int size, double average, double&amp; variance) { for (int j = 0; j &lt; size; j++) { variance += pow((test_values[j] - average), 2); }; return variance; }; int main() { int test_values[] = { 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 53 }; int size = sizeof(test_values); int sum; double average, variance; int calculate_average(int test_values[], int size, int sum, double average); int var(int test_values[], int size, double average, double variance); cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2); cout &lt;&lt; test_values &lt;&lt; endl; cout &lt;&lt; average &lt;&lt; endl; cout &lt;&lt; variance &lt;&lt; endl; return 0; } </code></pre>
0debug
void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, uint32_t io_int_word) { uint32_t type; if (io_int_word & IO_INT_WORD_AI) { type = KVM_S390_INT_IO(1, 0, 0, 0); } else { type = ((subchannel_id & 0xff00) << 24) | ((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16); } kvm_s390_interrupt_internal(cpu, type, ((uint32_t)subchannel_id << 16) | subchannel_nr, ((uint64_t)io_int_parm << 32) | io_int_word, 1); }
1threat
How to get code completion for Tensorflow in PyCharm? : <p>I have installed the tensorflow module and it works in PyCharm. However, I want it to have code completion. Currently I do this:</p> <pre><code>import tensorflow as tf hello = tf.constant("Hello, Tensorflow!") </code></pre> <p>However, PyCharm doesn't suggest or autocomplete functions when I type 'tf'<br> Is this possible to be done automatically or am I missing something?</p> <p>I am using Windows 10. Tensorflow is installed natively.</p>
0debug
Can i convert MP3 to MIDI in C# ? or is there any library to convert MP3 to MIDI in C# ? Thanks : I'm working on a program (C#) to convert a MP3 file to MIDI, but I have a problem to converting it. How should i do ? Is there any library to convert MIDI from MP3 file Thank You
0debug
static int scsi_hot_add(Monitor *mon, DeviceState *adapter, DriveInfo *dinfo, int printinfo) { SCSIBus *scsibus; SCSIDevice *scsidev; scsibus = DO_UPCAST(SCSIBus, qbus, QLIST_FIRST(&adapter->child_bus)); if (!scsibus || strcmp(scsibus->qbus.info->name, "SCSI") != 0) { error_report("Device is not a SCSI adapter"); return -1; } dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1); scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo, dinfo->unit); if (!scsidev) { return -1; } dinfo->unit = scsidev->id; if (printinfo) monitor_printf(mon, "OK bus %d, unit %d\n", scsibus->busnr, scsidev->id); return 0; }
1threat
Hashmap individual value retrieval in java : I have created a hashmap listed below: Map<String, List<Double>> hm1 = new HashMap<String, List<Double>>(); List<Double> hmValues1 = new ArrayList<Double>(); and using this below function to add values from a file, where the specified values of the file are: line1 0.418 0.24968 -0.41242 0.1217 0.34527 -0.044457 -0.49688 -0.17862 0.00066023 -0.6566 line2 0.013441 0.23682 -0.16899 0.40951 0.63812 0.47709 -0.42852 -0.55641 -0.364 -0.23938 line3 -0.418 -0.24968 0.41242 -0.1217 -0.34527 -0.16899 -0.40951 -0.63812 -0.47709 0.42852 I am able to print all the values of Key: line1. but I want to retrieve individual values of the list, to process them separately. Please give a guidance. public static void conceptHashMap() { int len,i=0; double dVal=0.0; String strLine; String conceptSearch = "line1"; // will be a key in hashmap try (BufferedReader br = new BufferedReader(new FileReader(fileName))) { while ((strLine = br.readLine()) != null) { String[] dims = strLine.split(" "); len=dims.length; if(dims[i++].equals(conceptSearch)){ while(--len>0) { dVal=Double.parseDouble(dims[i++]); hmValues1.add(dVal); } hm1.put(conceptSearch, hmValues1); for (Map.Entry<String, List<Double>> entry : hm1.entrySet()) { String key = entry.getKey(); List<Double> hmvalues1 = entry.getValue(); System.out.println("key value pair"); System.out.println("Key = " + key); System.out.println("Values = " + hmvalues1); } break; } i=0; } } catch (IOException e) { e.printStackTrace(); } }
0debug
What permission is required to create a Service Hook in Visual Studio Team Services? : <p>In Visual Studio Team Services on the tab for "Service Hooks", some of our project team members get an message that says "You do not have sufficient permissions to view or configure subscriptions." </p> <p>What permission or group do they need to be assigned in order to create a Service Hook for a given project?</p>
0debug
I have 16 in database I need to change into 4PM : I have time in format of 16, 18 like this. I need to convert into AM PM format please help me
0debug
\n doesn't work in Python 3.6 : <p>It might be very basic thing, and i don't see what I'm i doing wrong. </p> <p>I do have a dictionary: </p> <pre><code>elSPH = { '%SiO2': 52.79, '%MgO': 0.10, '%Na2O': 4.33, '%Al2O3': 29.50 } </code></pre> <p>And i want to make a new string line for each element to look like this:</p> <pre><code>%SiO2: 52.79 %MgO: 0.10 %Na2O: 4.33 %Al2O3: 29.50 </code></pre> <p>So I've tried </p> <pre><code>''.join('{}{}\n'.format(key, val) for key, val in elSPH.items()) </code></pre> <p>And got output: </p> <pre><code>'%SiO252.79\n%MgO0.1\n%Na2O4.33\n%Al2O329.5\n' </code></pre> <p>Is there a way how i could make this \n new line break working? For some reason it's even not working on a simple things like:</p> <pre><code>In: d = 'Hello\nworld' In: d Out: 'Hello\nworld' </code></pre>
0debug
static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req) { NvmeRwCmd *rw = (NvmeRwCmd *)cmd; uint32_t nlb = le32_to_cpu(rw->nlb) + 1; uint64_t slba = le64_to_cpu(rw->slba); uint64_t prp1 = le64_to_cpu(rw->prp1); uint64_t prp2 = le64_to_cpu(rw->prp2); uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas); uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds; uint64_t data_size = (uint64_t)nlb << data_shift; uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS); int is_write = rw->opcode == NVME_CMD_WRITE ? 1 : 0; if ((slba + nlb) > ns->id_ns.nsze) { return NVME_LBA_RANGE | NVME_DNR; } if (nvme_map_prp(&req->qsg, prp1, prp2, data_size, n)) { return NVME_INVALID_FIELD | NVME_DNR; } assert((nlb << data_shift) == req->qsg.size); req->has_sg = true; dma_acct_start(n->conf.blk, &req->acct, &req->qsg, is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_READ); req->aiocb = is_write ? dma_blk_write(n->conf.blk, &req->qsg, aio_slba, nvme_rw_cb, req) : dma_blk_read(n->conf.blk, &req->qsg, aio_slba, nvme_rw_cb, req); return NVME_NO_COMPLETE; }
1threat
Is there a way to make randint() less pseudo and more random? : <p>I'm working on a lottery simulator and I'm not quiet happy with the draws generated by randint.</p> <p>Are there any tricks to make it more random?</p>
0debug
int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong address, int rw, int access_type) { ppcemb_tlb_t *tlb; target_phys_addr_t raddr; int i, ret, zsel, zpr; ret = -1; raddr = -1; for (i = 0; i < env->nb_tlb; i++) { tlb = &env->tlb[i].tlbe; if (ppcemb_tlb_check(env, tlb, &raddr, address, env->spr[SPR_40x_PID], 0, i) < 0) continue; zsel = (tlb->attr >> 4) & 0xF; zpr = (env->spr[SPR_40x_ZPR] >> (28 - (2 * zsel))) & 0x3; #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: TLB %d zsel %d zpr %d rw %d attr %08x\n", __func__, i, zsel, zpr, rw, tlb->attr); } #endif if (access_type == ACCESS_CODE) { switch (zpr) { case 0x2: if (msr_pr) goto check_exec_perm; goto exec_granted; case 0x0: if (msr_pr) { ctx->prot = 0; ret = -3; break; } case 0x1: check_exec_perm: if (!(tlb->prot & PAGE_EXEC)) { ret = -3; } else { if (tlb->prot & PAGE_WRITE) { ctx->prot = PAGE_READ | PAGE_WRITE; } else { ctx->prot = PAGE_READ; } ret = 0; } break; case 0x3: exec_granted: ctx->prot = PAGE_READ | PAGE_WRITE; ret = 0; break; } } else { switch (zpr) { case 0x2: if (msr_pr) goto check_rw_perm; goto rw_granted; case 0x0: if (msr_pr) { ctx->prot = 0; ret = -2; break; } case 0x1: check_rw_perm: if (tlb->prot & PAGE_WRITE) { ctx->prot = PAGE_READ | PAGE_WRITE; ret = 0; } else { ctx->prot = PAGE_READ; if (rw) ret = -2; else ret = 0; } break; case 0x3: rw_granted: ctx->prot = PAGE_READ | PAGE_WRITE; ret = 0; break; } } if (ret >= 0) { ctx->raddr = raddr; #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: access granted " ADDRX " => " REGX " %d %d\n", __func__, address, ctx->raddr, ctx->prot, ret); } #endif return 0; } } #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: access refused " ADDRX " => " REGX " %d %d\n", __func__, address, raddr, ctx->prot, ret); } #endif return ret; }
1threat
how to create static list over session in asp mvc : i should create buy basket in my website and i like to use list<int> static of id's of products that user selected but when i create this static list i public static list<int> Ordered_products; and add item to this list buy Ordered_products.add(item.id); and show the product name buy id's in Ordered_products when multi user insert to the list users can see the product hat another user insert it to the list . how can i have static list over session?
0debug
List with the alphabetical scrolling : Helllo. How to make the simplest list using the recyclerview and add there alphabetical scrolling (as in contacts)? Tell me please, or give me an example of how to do it. P.S I'm new in Android development and I've never worked with the RecyclerView before.
0debug
A way to reject digits that are all the same? : I have an input which the user fill in and send it over. I would like to create a validation in javascript to prevent the user typing something like: **1111111111** **2222222222** **3333333333** etc <input type="text" class="form-control" id="inputID" placeholder="Company nummer" name="CompanyNumber" onchanged="checkInputDigits()" maxlength="13" pattern=".{13,}" required title="most be 13 digits"/> <script> function checkInputDigits() { //What to do? } </script>
0debug
static inline void t_gen_swapb(TCGv d, TCGv s) { TCGv t, org_s; t = tcg_temp_new(TCG_TYPE_TL); org_s = tcg_temp_new(TCG_TYPE_TL); tcg_gen_mov_tl(org_s, s); tcg_gen_shli_tl(t, org_s, 8); tcg_gen_andi_tl(d, t, 0xff00ff00); tcg_gen_shri_tl(t, org_s, 8); tcg_gen_andi_tl(t, t, 0x00ff00ff); tcg_gen_or_tl(d, d, t); tcg_temp_free(t); tcg_temp_free(org_s); }
1threat
void pxa27x_timer_init(target_phys_addr_t base, qemu_irq *irqs, qemu_irq irq4) { pxa2xx_timer_info *s = pxa2xx_timer_init(base, irqs); int i; s->freq = PXA27X_FREQ; s->tm4 = (PXA2xxTimer4 *) qemu_mallocz(8 * sizeof(PXA2xxTimer4)); for (i = 0; i < 8; i ++) { s->tm4[i].tm.value = 0; s->tm4[i].tm.irq = irq4; s->tm4[i].tm.info = s; s->tm4[i].tm.num = i + 4; s->tm4[i].tm.level = 0; s->tm4[i].freq = 0; s->tm4[i].control = 0x0; s->tm4[i].tm.qtimer = qemu_new_timer(vm_clock, pxa2xx_timer_tick4, &s->tm4[i]); } }
1threat
static void format_line(void *ptr, int level, const char *fmt, va_list vl, char part[3][512], int part_size, int *print_prefix, int type[2]) { AVClass* avc = ptr ? *(AVClass **) ptr : NULL; part[0][0] = part[1][0] = part[2][0] = 0; if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; if (*print_prefix && avc) { if (avc->parent_log_context_offset) { AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) + avc->parent_log_context_offset); if (parent && *parent) { snprintf(part[0], part_size, "[%s @ %p] ", (*parent)->item_name(parent), parent); if(type) type[0] = get_category(((uint8_t *) ptr) + avc->parent_log_context_offset); } } snprintf(part[1], part_size, "[%s @ %p] ", avc->item_name(ptr), ptr); if(type) type[1] = get_category(ptr); } vsnprintf(part[2], part_size, fmt, vl); *print_prefix = strlen(part[2]) && part[2][strlen(part[2]) - 1] == '\n'; }
1threat
String variable with limited number of characters in Golang : Can I create a variable of the type string with a limited number of characters/ "Runes"? Something similar to byte array that only accepts n entries? myByteArray := make([]byte, 20) Can I even create a custom data type that will only accepts n entries?
0debug
Why Firexfox and IE cannot open a link (anchor) inside a <button></button> tag. : <p>Why IE and Firefox cannot open a link inside the button tag, In chrome it opens the link in same window.</p> <p>Example:</p> <pre><code>&lt;button type="button"&gt;&lt;a href="http://stackoverflow.com"&gt;stackoverflow&lt;/a&gt;&lt;/button&gt; </code></pre>
0debug