problem
stringlengths
26
131k
labels
class label
2 classes
static void pc_q35_2_4_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); pc_q35_2_5_machine_options(m); m->alias = NULL; pcmc->broken_reserved_end = true; pcmc->inter_dimm_gap = false; SET_MACHINE_COMPAT(m, PC_COMPAT_2_4); }
1threat
static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track) { int pos = url_ftell(pb); char compressor_name[32]; int tag; put_be32(pb, 0); tag = track->enc->codec_tag; if (!tag) tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id); if (!tag) tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id); put_le32(pb, tag); put_be32(pb, 0); put_be16(pb, 0); put_be16(pb, 1); put_be16(pb, 0); put_be16(pb, 0); put_tag(pb, "FFMP"); if(track->enc->codec_id == CODEC_ID_RAWVIDEO) { put_be32(pb, 0); put_be32(pb, 0x400); } else { put_be32(pb, 0x200); put_be32(pb, 0x200); } put_be16(pb, track->enc->width); put_be16(pb, track->enc->height); put_be32(pb, 0x00480000); put_be32(pb, 0x00480000); put_be32(pb, 0); put_be16(pb, 1); memset(compressor_name,0,32); if (track->enc->codec->name) strncpy(compressor_name,track->enc->codec->name,31); put_byte(pb, FFMAX(strlen(compressor_name),32) ); put_buffer(pb, compressor_name, 31); put_be16(pb, 0x18); put_be16(pb, 0xffff); if(track->enc->codec_id == CODEC_ID_MPEG4) mov_write_esds_tag(pb, track); else if(track->enc->codec_id == CODEC_ID_H263) mov_write_d263_tag(pb); else if(track->enc->codec_id == CODEC_ID_SVQ3) mov_write_svq3_tag(pb); return updateSize (pb, pos); }
1threat
static AHCIQState *ahci_boot(void) { AHCIQState *s; const char *cli; s = g_malloc0(sizeof(AHCIQState)); cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s" ",format=raw" " -M q35 " "-device ide-hd,drive=drive0 " "-global ide-hd.ver=%s"; s->parent = qtest_pc_boot(cli, tmp_path, "testdisk", "version"); s->dev = get_ahci_device(&s->fingerprint); return s; }
1threat
def upper_ctr(str): upper_ctr = 0 for i in range(len(str)): if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1 return upper_ctr
0debug
Converting Text Files : <p>I have a text file containing these. I will load it in created form.</p> <pre><code>5JB01141570J4450901 1000 1051 2000 01161501B10G610M0350M200 0000006 </code></pre> <p>to produce this.</p> <pre><code>106262,5,JB,2015-01-14,70J4450901 ,1000 ,1051 ,2000 ,2015-01-16,0,1,B10G610M0350M200 ,6,, ,0,1/14/2015 3:06:16 PM </code></pre> <p>how can it converted to it?</p> <p>the first column is the row counts and the last column indicates datetime when generated..</p>
0debug
converting from Date format to another in R : <p>I want to convert my date format from 1/10/2017 to 2017-10-1 format using R. I tried using different methods as writhing a function or using Chron. I'm a beginner so any help would be appreciated.</p> <p>note: if date is 1/8/2017 it should be converted to 2017-08-01</p> <p>thanks in advance </p>
0debug
static uint32_t e1000e_macreg_read(e1000e_device *d, uint32_t reg) { return qpci_io_readl(d->pci_dev, d->mac_regs + reg); }
1threat
static void check_breakpoint(CPUState *env, DisasContext *dc) { CPUBreakpoint *bp; if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { TAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == dc->pc) { t_gen_raise_exception(dc, EXCP_DEBUG); dc->is_jmp = DISAS_UPDATE; } } } }
1threat
How to get the value of every incrementation in the list combined? : Given the list of `[0, 10, 20, 5, 10, 30, 20, 35]`, how do I get the list of `[20, 25, 15]` for every incrementation of the values in the initial list? `[0, 10, 20]` turns into `[20]`, `[5, 10, 30]` turns into `[25]`, and `[20, 35]` turns into `[15]`.
0debug
connot impert flask into test file : i have running following code for test purpose my file name is app.py my code is from flask import flask app = flask (_name_) @app.route("/") def main(): return "Welcome!" if __name__ == "__main__": app.run() when i run this code . it gives error Traceback (most recent call last): File "C:\Users\Ravi\AppData\Local\Programs\Python\Python36\app.py", line 1, in <module> from flask import flask ImportError: cannot import name 'flask Any thoughts as to why this is not working?
0debug
JavaScript === vs == for type checking : <p>Which of the following lines is correct?...</p> <pre><code>if (typeof value == 'boolean') { return value; } </code></pre> <p>... or ...</p> <pre><code>if (typeof value === 'boolean') { return value; } </code></pre> <p>I thought the double equal sign was a type of "soft compare" so the <code>value</code> variable could either be a <code>string</code> or formal type. Is this not so? I wonder because JSHint complained about the first version. I've changed it but now I'm worried that <code>typeof</code> won't return a string.</p>
0debug
whenever i start my node server and type localhost:3000 it is giving me this error Any Help would Be Appreciable : i am new beginner in angular .i am using Visual Studio code tool and i am trying to create a server using nodejs i am trying to load my index.html file when a user sends requests to the server my js code is var http=require('http'); var fs = require('fs'); http.createServer(function(req,res){ fs.read("./public/index.html","UTF-8", function(err,html){ res.writeHead(200,{'Content-type':'text/html'}); res.end(html); } ); }).listen(3000); TypeError: fd must be a file descriptor at Object.fs.read (fs.js:686:11) at Server.<anonymous> (E:\NodejsWork\server.js:7:7) at Server.emit (events.js:180:13) at parserOnIncoming (_http_server.js:642:12) at HTTPParser.parserOnHeadersComplete (_http_common.js:117:17)
0debug
Pass a value to another screen : <p>I have a screen where the user can select an option (not a browse gallery as it does not do what is required).</p> <p>I want to pass the item the user has selected to the pre-made "DetailScreen1" which is used by the browse gallery. </p> <p>I looked at the browse screen but did not see how it does it as the navigate onselect event is just normal navigation.</p> <p>Code:</p> <pre><code>Navigate(DetailScreen1, ScreenTransition.Fade) </code></pre> <p>I want to do something like </p> <pre><code>Navigate(DetailScreen1, ScreenTransition.None {Last(listOfStuff)}) </code></pre> <p>Thanks</p>
0debug
Firebase Performance: How many children per node? : <p>If a node has 100 million children, will there be a performance impact if I:</p> <p>a) Query, but limit to 10 results</p> <p>b) Watch one of the children only</p> <p>I could split the data up into multiple parents, but in my case I will have a reference to the child so can directly look it up (which reduces the complexity). If there is an impact, what is the maximum number for each scenario before performance is degraded?</p>
0debug
How to install latest version of openssl Mac OS X El Capitan : <p>I have used <code>brew install openssl</code> to download and install openssl v1.0.2f, however, it comes back saying:</p> <pre><code>A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash This formula is keg-only, which means it was not symlinked into /usr/local. Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include </code></pre> <p>And when I do <code>openssl version -a</code> it always gives me:</p> <pre><code>OpenSSL 0.9.8zg 14 July 2015 built on: Jul 31 2015 platform: darwin64-x86_64-llvm options: bn(64,64) md2(int) rc4(ptr,char) des(idx,cisc,16,int) blowfish(idx) compiler: -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O3 -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DMD32_REG_T=int -DOPENSSL_NO_IDEA -DOPENSSL_PIC -DOPENSSL_THREADS -DZLIB -mmacosx-version-min=10.6 OPENSSLDIR: "/System/Library/OpenSSL" </code></pre> <p>How can I replace the old version with the new one? I've searched a lot on how to do this, but the solutions online don't seem to work for me...</p>
0debug
static void RENAME(yuv2rgb555_1)(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *bguf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y) { const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; const int16_t *buf1= buf0; if (uvalpha < 2048) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB15(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB15(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } }
1threat
C Simple RingBuffer - Multithreading - Finding Critical Sections : <p>so I wrote a simple C Ring Buffer that I'm now testing using multiple threads and I'm having a hard time trying to get the code to fail so that I can identify critical sections.</p> <p>Note: The code is in C, but i'm testing it in C++ files because its easier to create threads mutexes etc.</p> <p>Header File:</p> <pre><code>#ifndef _C_TEST_H_ #define _C_TEST_H_ #include &lt;stdio.h&gt; #include &lt;mutex&gt; /////////////////////////////////////////////////////////////////////////////// // Defines and macros /////////////////////////////////////////////////////////////////////////////// #ifndef __cplusplus typedef enum { false, true } bool; #endif #define RING_BUFFER_SIZE 2000 /////////////////////////////////////////////////////////////////////////////// // Structures, Enumerations, Typedefs /////////////////////////////////////////////////////////////////////////////// typedef struct Node { int val; struct Node *next; struct Node *previous; } Node_T; typedef enum RB_ERC { RB_ERC_NO_ERROR, RB_ERC_NULL_PTR, RB_ERC_UNDERFLOW, RB_ERC_OVERFLOW } RB_ERC_T; typedef enum RB_HANDLE_OVERFLOW { RB_DECIMATE, RB_IGNORE_AND_RETURN_ERROR } RB_HANDLE_OVERFLOW_T; typedef enum RB_READ_MODE { RB_FIFO, RB_LIFO } RB_READ_MODE_T; typedef struct RingBuffer { int curSize; RB_HANDLE_OVERFLOW_T handleOverflow; struct Node *Write; struct Node *Read; Node_T buffer[RING_BUFFER_SIZE]; } RING_BUFFER_T; /////////////////////////////////////////////////////////////////////////////// // Prototypes /////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus extern "C" { #endif RB_ERC_T RB_InitRingBuffer(RING_BUFFER_T *rb_, RB_HANDLE_OVERFLOW_T ifOverflow_); //Return true if the queue has no elements; false if there are elements on the queue bool RB_IsEmpty(RING_BUFFER_T *rb_); //Return true if the queue is full; false if there are seats available bool RB_IsFull(RING_BUFFER_T *rb_); //Write N elements (length of the array) to the queue //Note: array values will be read from element 0 to array length RB_ERC_T RB_WriteArray(RING_BUFFER_T *rb_, int values_[], int length_); //Write 1 element RB_ERC_T RB_Write(RING_BUFFER_T *rb_, int val_); //Dequeue and read N elements (length of the array) into an array RB_ERC_T RB_ReadArray(RING_BUFFER_T *rb_, int values_[], int length_, RB_READ_MODE_T readMode_); //Dequeue and read 1 element RB_ERC_T RB_Read(RING_BUFFER_T *rb_, int *readVal_, RB_READ_MODE_T readMode_); #ifdef __cplusplus } #endif #endif //_C_TEST_H_ </code></pre> <p>Source:</p> <pre><code>#include "CTest.h" static std::mutex m; RB_ERC_T RB_InitRingBuffer(RING_BUFFER_T *rb_, RB_HANDLE_OVERFLOW_T handleOverflow_) { //m.lock(); RB_ERC_T erc = RB_ERC_NO_ERROR; int i; if(rb_ == 0) { return RB_ERC_NULL_PTR; } //Initialize this instance of the ring buffer //Both the read/write pointers should start at the same location rb_-&gt;curSize = 0; rb_-&gt;Read = &amp;rb_-&gt;buffer[0]; rb_-&gt;Write = &amp;rb_-&gt;buffer[0]; rb_-&gt;handleOverflow = handleOverflow_; //Build the circular doubly-linked list for(i = 0; i &lt; RING_BUFFER_SIZE; i++) { rb_-&gt;buffer[i].val = 0; if(i == 0) { //Sentinal Node found. Point the first node to the last element of the array rb_-&gt;buffer[i].previous = &amp;rb_-&gt;buffer[(RING_BUFFER_SIZE - 1)]; rb_-&gt;buffer[i].next = &amp;rb_-&gt;buffer[i + 1]; } else if(i &lt; (RING_BUFFER_SIZE - 1) ) { rb_-&gt;buffer[i].next = &amp;rb_-&gt;buffer[i + 1]; rb_-&gt;buffer[i].previous = &amp;rb_-&gt;buffer[i - 1]; } else { //Sentinal node found. Reached the last element in the array; Point the sentinal //node to the first element in the array to create a circular linked list. rb_-&gt;buffer[i].next = &amp;rb_-&gt;buffer[0]; rb_-&gt;buffer[i].previous = &amp;rb_-&gt;buffer[i - 1]; } } //m.unlock(); return erc; } bool RB_IsEmpty(RING_BUFFER_T *rb_) { //m.lock(); //Note: assume rb is valid. if(rb_-&gt;curSize == 0) { return true; } else { return false; } //m.unlock(); } bool RB_IsFull(RING_BUFFER_T *rb_) { //m.lock(); //Note: assume rb is valid. if(rb_-&gt;curSize == RING_BUFFER_SIZE) { return true; } else { return false; } //m.unlock(); } RB_ERC_T RB_WriteArray(RING_BUFFER_T *rb_, int values_[], int length_) { //m.lock(); RB_ERC_T erc = RB_ERC_NO_ERROR; int i; if(rb_ == 0 || values_ == 0 || length_ == 0) { return RB_ERC_NULL_PTR; } switch(rb_-&gt;handleOverflow) { //Increment through the array and enqueue //If attempting to write more elements than are available on the queue //Decimate - overwrite old data //Ignore and return error - Don't write any data and throw an error case RB_DECIMATE: for(i = 0; i &lt; length_; i++) { RB_Write(rb_, values_[i] ); } break; default: case RB_IGNORE_AND_RETURN_ERROR: { int numSeatsAvailable = (RING_BUFFER_SIZE - rb_-&gt;curSize); if( length_ &lt;= numSeatsAvailable ) { //Increment through the array and enqueue for(i = 0; i &lt; length_; i++) { RB_Write(rb_, values_[i] ); } } else { //Attempted to write more elements than are avaialable on the queue erc = RB_ERC_OVERFLOW; } } break; } //m.unlock(); return erc; } RB_ERC_T RB_Write(RING_BUFFER_T *rb_, int val_) { //m.lock(); RB_ERC_T erc = RB_ERC_NO_ERROR; if(rb_ == 0) { return RB_ERC_NULL_PTR; } if( !RB_IsFull(rb_) ) { //Write the value to the current location, then increment the write pointer //so that the write pointer is always pointing 1 element ahead of the queue rb_-&gt;Write-&gt;val = val_; rb_-&gt;Write = rb_-&gt;Write-&gt;next; rb_-&gt;curSize++; } else { //Overflow switch(rb_-&gt;handleOverflow) { case RB_DECIMATE: //Set the value and increment both the read/write pointers rb_-&gt;Write-&gt;val = val_; rb_-&gt;Write = rb_-&gt;Write-&gt;next; rb_-&gt;Read = rb_-&gt;Read-&gt;next; break; default: case RB_IGNORE_AND_RETURN_ERROR: erc = RB_ERC_OVERFLOW; break; } } //m.unlock(); return erc; } RB_ERC_T RB_ReadArray(RING_BUFFER_T *rb_, int values_[], int length_, RB_READ_MODE_T readMode_) { //m.lock(); RB_ERC_T erc = RB_ERC_NO_ERROR; if(values_ == 0) { return RB_ERC_NULL_PTR; } //Verify that the amount of data to be read is actually available on the queue if( length_ &lt;= rb_-&gt;curSize ) { //Increment through the array and dequeue int i; for(i = 0; i &lt; length_; i++) { //Note: Error conditions have already been checked. Skip the ERC check (void) RB_Read(rb_, &amp;values_[i], readMode_); } } else { //Attempted to read more data than is available on the queue erc = RB_ERC_UNDERFLOW; } //m.unlock(); return erc; } RB_ERC_T RB_Read(RING_BUFFER_T *rb_, int *readVal_, RB_READ_MODE_T readMode_) { //m.lock(); RB_ERC_T erc = RB_ERC_NO_ERROR; if(rb_ == 0 || readVal_ == 0) { return RB_ERC_NULL_PTR; } if( !RB_IsEmpty(rb_) ) { switch(readMode_) { case RB_LIFO: //Use the head (Write) to read the most recently written value (newest data) //Note: The write pointer is always pointing 1 position ahead of the current queue. rb_-&gt;Write = rb_-&gt;Write-&gt;previous; //Decrement write pointer //Read the data *readVal_ = rb_-&gt;Write-&gt;val; rb_-&gt;Write-&gt;val = 0; //Reset read values to 0 break; default: case RB_FIFO: *readVal_ = rb_-&gt;Read-&gt;val; rb_-&gt;Read-&gt;val = 0; //Reset read values to 0 rb_-&gt;Read = rb_-&gt;Read-&gt;next; //Increment read pointer break; } rb_-&gt;curSize--; } else { //Attempted to read more data but there is no data available on the queue erc = RB_ERC_UNDERFLOW; } //m.unlock(); return erc; } </code></pre> <p>Main CPP using for tests:</p> <pre><code>#include "CTest.h" #include &lt;iostream&gt; #include "windows.h" #include &lt;thread&gt; using namespace std; static RING_BUFFER_T test1; const int dataSize = 300; const int dataSizeout = 1000; int sharedValue = 0; static std::mutex m; void function1() { int data[dataSize]; RB_ERC_T erc = RB_ERC_NO_ERROR; for (int i = 0; i &lt; dataSizeout; i++) { erc = RB_Write(&amp;test1, i); if (erc != RB_ERC_NO_ERROR) { printf("Count down errrror %d\n", erc); } } //RB_WriteArray(&amp;test1, data, dataSize); } void function2() { RB_ERC_T erc = RB_ERC_NO_ERROR; for (int i = 0; i &gt; -dataSizeout; i--) { erc = RB_Write(&amp;test1, i); if (erc != RB_ERC_NO_ERROR) { printf("Count down errrror %d\n", erc); } } } int main() { RB_InitRingBuffer(&amp;test1, RB_DECIMATE); thread p1(function1); //Sleep(1000); thread p2(function2); p1.join(); p2.join(); //Read out 5 at a time int out; int cnt = 0; while(cnt &lt; (2 * dataSizeout) ) { if (RB_Read(&amp;test1, &amp;out, RB_LIFO) == RB_ERC_NO_ERROR) { printf("out[%d] = %d\n", cnt, out); cnt += 1; } } system("Pause"); return 0; } </code></pre> <p>I'm thinking that everything in the main RING_BUFFER_T instance would be shared variables, so everywhere they are used, which is pretty much everywhere, they would have to be enclosed in mutexes.</p> <pre><code>typedef struct RingBuffer { int curSize; RB_HANDLE_OVERFLOW_T handleOverflow; struct Node *Write; struct Node *Read; Node_T buffer[RING_BUFFER_SIZE]; } RING_BUFFER_T; </code></pre> <p>I suppose NODE_T would be as well, but only for initialization. Am I wrong or shouldn't the elements being stuffed in the ring buffer be placed out of order, since there is no mutex being used right now?</p>
0debug
is there a way to make a custom window? not box like but custom shape [python] : <p><a href="http://i.stack.imgur.com/HrfwH.jpg" rel="nofollow">like this</a></p> <p>the green lady on the screen. that's how i want to make my program look like. how do i make that happen in python? just so you know i am new to python and i know only the basics of it.and i would love an explaining of how i make text appear next to her and stuff like that. would appreciate step by step + explaining.i have looked a bit on the internet but i couldn't find nothing like this question before. thanks</p>
0debug
void virt_acpi_setup(VirtGuestInfo *guest_info) { AcpiBuildTables tables; AcpiBuildState *build_state; if (!guest_info->fw_cfg) { trace_virt_acpi_setup(); return; } if (!acpi_enabled) { trace_virt_acpi_setup(); return; } build_state = g_malloc0(sizeof *build_state); build_state->guest_info = guest_info; acpi_build_tables_init(&tables); virt_acpi_build(build_state->guest_info, &tables); build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_MAX_SIZE); assert(build_state->table_mr != NULL); build_state->linker_mr = acpi_add_rom_blob(build_state, tables.linker, "etc/table-loader", 0); fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data, acpi_data_len(tables.tcpalog)); build_state->rsdp_mr = acpi_add_rom_blob(build_state, tables.rsdp, ACPI_BUILD_RSDP_FILE, 0); qemu_register_reset(virt_acpi_build_reset, build_state); virt_acpi_build_reset(build_state); vmstate_register(NULL, 0, &vmstate_virt_acpi_build, build_state); acpi_build_tables_cleanup(&tables, false); }
1threat
static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool *rebuild, void **refcount_table, int64_t *nb_clusters) { BDRVQcow2State *s = bs->opaque; int64_t i; QCowSnapshot *sn; int ret; if (!*refcount_table) { int64_t old_size = 0; ret = realloc_refcount_array(s, refcount_table, &old_size, *nb_clusters); res->check_errors++; 0, s->cluster_size); ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters, s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO); for (i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters, sn->l1_table_offset, sn->l1_size, 0); s->snapshots_offset, s->snapshots_size); s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t)); return check_refblocks(bs, res, fix, rebuild, refcount_table, nb_clusters);
1threat
How to create struct which is composed of another : <p>I have a struct like so:</p> <pre><code>type Docs struct { Methods []string Route string } </code></pre> <p>and then I import that from another file like:</p> <pre><code>import tc "huru/type-creator" </code></pre> <p>and use it like so:</p> <pre><code>type DocsLocal struct { tc.Docs } </code></pre> <p>I am pretty certain that tc.Docs is just a field in DocsLocal, so this would be a case of composition, right?</p> <p>if I want to create new instance of DocsLocal, I try this:</p> <pre><code>d:= DocsLocal{} </code></pre> <p>but how do I pass in the Methods and Route parameters? If I do this:</p> <pre><code>methods:= []string{"foo"} r:="biscuit" d:= DocsLocal{methods, r} </code></pre> <p>I get an error:</p> <blockquote> <p>Cannot use methods (type []string) as type tc.Docs more</p> </blockquote> <p>So what is the right syntax to use here?</p>
0debug
What is Kubernetes' Users for? : I'm studying Kubernetes now, and have a question about Kubernetes' Users. I learned how to create Users and how to limit access by Role, but when should I use it? I mean, if malicious user(not k8s user, but operating user) penetrate k8s server, they can switch administrator easily (if they can see .kube/config). In addition to, if user switch his user account and he forgot switch back, the another person who enters next can also use first user's account. I doubt if I misunderstand usage of k8s Users, but it seems to be no documents about why k8s prepared it. I slightly assume that Users only use for doing something from inner pods, but if so, what the difference between Users and Service Accounts?
0debug
Macbook won't stay as using Python3 : When I change the alias for python using ***alias python='python3'*** in terminal, the python version will be changed to python3. But, when I close Atom and come back to the app later, it has gone back to python2. Can someone explain this please?
0debug
How to convert string to date format in java? : <p>How to convert string "Monday, 10 January 2017 | 04:58 PM" to a java.sql.Date 2017-01-10?</p>
0debug
Storybook JS Interaction Testing with Enzyme - State Changes being Overidden : <p>I am using storybook to visualize changes to React components after simulating user interaction with enzyme. As a small example, I want a story displaying a component after one of its button has been clicked.</p> <p>The issue I'm having is the component's constructor gets called twice: once when the component is mounted by enzyme and then after when storybook displays the component. This puts the component back to its default state so any changes following the simulated user interactions are lost.</p> <p>Here's some code showing the issue. After the story loads, the button component is in the "unclicked" state, even though a click was simulated with enzyme:</p> <pre><code>import React from 'react'; class SampleComponent extends React.Component { constructor(props){ super(props); console.log('constructor'); this.state = {isClicked: false}; this.onClick = this.onClick.bind(this); } onClick(){ console.log('onClick'); this.setState({isClicked: true}); } render(){ const text = (this.state.isClicked)? 'Clicked!' : 'Not Clicked'; return ( &lt;div&gt; &lt;input type='button' value='Click' onClick={this.onClick} /&gt; &lt;p&gt;{text}&lt;/p&gt; &lt;/div&gt; ); } } export default SampleComponent; </code></pre> <p>The story file:</p> <pre><code>import React from 'react'; import { storiesOf } from '@storybook/react'; import { mount } from 'enzyme'; import { specs, describe, it } from 'storybook-addon-specifications'; import SampleComponent from '../src/SampleComponent'; storiesOf('SampleComponent', module) .add('clicked', () =&gt; { const comp = &lt;SampleComponent/&gt;; specs(() =&gt; describe('clicked', function () { it('Should display clicked state message', function () { const output = mount(comp); output.find('input').simulate('click'); }); })); return comp; }); </code></pre> <p>The output to console would be:</p> <pre><code>constructor onClick constructor </code></pre>
0debug
500 Internal Server Error when I do a Include : <p>I'm trying to do an include in php, but when I execute the form submit Internal Server Error appears. If I delete the include this error does not appears. </p> <p>I've tryed to change permissions and the owner of the forlders and files to www-data: but it doesn't work. </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; registro. &lt;/title&gt; &lt;meta charset="utf-8"&gt; &lt;script src="jquery.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="#" method="post"&gt; &lt;label for="user"&gt;Nombre de usuario:&lt;/label&gt;&lt;input name="usuario" id="user" type="text"&gt;&lt;br&gt; &lt;label for="pass1"&gt;Contraseña:&lt;/label&gt;&lt;input name="pass1" id="pass1" type="text"&gt;&lt;br&gt; &lt;label for="pass2"&gt;Repita Contraseña&lt;/label&gt; &lt;input name="pass2" id="pass2" type="text"&gt;&lt;br&gt; &lt;input type="submit" value="enviar"&gt; &lt;/form&gt; &lt;?php if($_POST){ $user=$_POST['usuario']; $pass1=$_POST['pass1']; $pass2=$_POST['pass2']; echo $pass1; if(is_null($user)|| is_null($pass1)||is_null($pass2)){ echo 'Error, alguno de los datos no es válido'; }else{ if($pass1==$pass2){ include 'conexion.php'; $mysqli -&gt; query("INSERT INTO USERS VALUES ('2','2')"); echo 'Realizado correctamente, Redirigiendo a pagina principal...'; header ("refresh :2,url=login.php"); }else{ echo 'Error, las contraseñas no coinciden'; } } } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>this is the mensage: Internal Server Error</p> <p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p> <p>Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.</p> <p>More information about this error may be available in the server error log. Apache/2.4.25 (Debian) Server at localhost Port 80</p>
0debug
Cannot figure out "Unexpected token" in React : <p>I cannot figure out what the error means on line 42:18 Could someone explain, please.</p> <p><strong>Error Message:</strong></p> <blockquote> <p>Line 42:18: Parsing error: Unexpected token</p> </blockquote> <pre><code>render() { return ( &lt;div className="FlexContainer NavbarContainer"&gt; &lt;ul className="NavBar"&gt; &lt;div className="mobilecontainer LeftNav"&gt; &lt;h2 className="BrandName LeftNav mobileboxmenu inline"&gt;Kommonplaces&lt;/h2&gt; &lt;div className="hamburger inline" onClick={this.showDropdownMenu}&gt;&lt;img alt="menubtn" src={hamburger}&gt;&lt;/img&gt;&lt;/div&gt; { this.state.displayMenu ? ( &lt;/div&gt; This line is 42 &lt;Dropdown/&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;Host Your Space&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;About Us&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav FarRight"&gt;&lt;Link to="/"&gt;Contact Us&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;Sign Up&lt;/Link&gt;&lt;/li&gt; &lt;li className="RightNav"&gt;&lt;Link to="/"&gt;Login&lt;/Link&gt;&lt;/li&gt; &lt;/ul&gt; ): ( null ) } &lt;/div&gt; ); } } export default MobileDropdown; </code></pre>
0debug
MySQL Select records for each date in month even if records does not exist for specific date : <p>I have a table with records having created_date field. I want to select records for each date in current month, even if there is not record for any specific date.</p> <p>I want records as :</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>created_on | name ----------------------- 2018-01-01 | ABC 2018-01-02 | XYZ 2018-01-03 | MNO ... ... 2018-01-30 | FAQ 2018-01-31 | PQR</code></pre> </div> </div> </p>
0debug
MS access to sql migration issue : I have a sql query below select LTRIM(RTRIM(Sub string([Short Description],9,Len([Short Description])-8))) AS PolicyNumber from x table its giving error as this Msg 537, Level 16, State 3, Line 10 Invalid length parameter passed to the LEFT or SUBSTRING function.
0debug
Selecting sharepoint site language using powershell script : Is there a way or a script to get a list of the available languages for a sharepoint site in powershell?
0debug
Why Chrome on Linux shows "External protocol request" dialog for unknown protocol? : <p>I am creating a custom protocol handler for Google Chrome on Linux. My link looks like this:</p> <pre><code>&lt;a href="myprotocol:someargument"&gt;Trigger my app with param&lt;/a&gt; </code></pre> <p>I have noticed that if 'myprotocol:' is not registered (my app not installed), Google Chrome on Linux displays "External Protocol Request" dialog and tries to use xdg-open:</p> <p><a href="https://i.stack.imgur.com/difTw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/difTw.png" alt="enter image description here"></a></p> <p>While on other OS, such as Windows 10 and OS X El Capitan nothing is displayed if protocol is not registered. </p> <p>I have also verified that Firefox works consistently for unknown protocols on Windows, OS X and Linux - nothing is displayed.</p> <p>Chrome behavior on Linux is quite confusing for users. </p> <p>Any idea why Chrome on Linux (I was testing on Ubuntu 14.04) acts differently from any other OS and web browsers?</p>
0debug
Docker - Bash: IP: command not found : <p>I'm currently trying to set up a hyperledger fabric network using docker toolbox, based on the guide <a href="http://hyperledger-fabric.readthedocs.io/en/latest/Setup/Network-setup.html?cm_mc_uid=81974749078914879942140&amp;cm_mc_sid_50200000=1488939665#starting-up-validating-peers" rel="noreferrer">HERE</a></p> <p>When it comes to "Starting up validating peers" step, I followed and entered <code>ip add</code> into the terminal, but it returns <code>bash: ip: command not found</code>. Any solution? I've tried <code>ifconfig</code> as well and it's the same issue, command not found.</p> <p>Using Docker Toolbox on Windows 10 Home</p> <p>Thanks</p>
0debug
how to include js file with no error? : i want to separate my route file in nodejs i use restify framework and this is part of my code app.routes((app)=>{ require(__dirname + '/../routes/web.js') }) routes/web.js app.get('/', function (req, res, next) { console.log("object"); }) when run the program i get this error > app is not a defined who can i fix that?? in web.js "app" is undefined while i sended it to function
0debug
void ff_weight_h264_pixels16_8_msa(uint8_t *src, int stride, int height, int log2_denom, int weight_src, int offset) { avc_wgt_16width_msa(src, stride, height, log2_denom, weight_src, offset); }
1threat
How to properly create package python : Say i have a folder named foo. Inside that folder is __init__.py, a folder called test, and a another python file called t1.py. Inside folder test is a python file called bar.py, and in that file I am trying to do something like: from foo import t1. And it gives me this error: ModuleNotFoundError: No module named 'gmuwork'. Do i need to add something to environment variables, or sys.path?
0debug
static bool less_than_7(void *opaque, int version_id) { return version_id < 7; }
1threat
Django insert default data after migrations : <p>I want my application to have default data such as user types. Whats the most efficient way to manage default data after migrations.</p> <p>it needs to handle situations such as after i add a new table it adds the default data for it. </p>
0debug
What's going wrong with my code for Euler Project #1? : <p>Can anyone tell me where it is my program is going wrong here? I just don't see it...</p> <pre><code>x_3 = [] i=0 while 3*i &lt; 1000: sum_3 = 3*i x_3.extend([sum_3]) i += 1 x_5 = [] j = 0 while 5*j &lt; 1000: sum_5 = 5*j j += 1 x_5.extend([sum_5]) answer = sum(x_5) + sum(x_3) print(answer) 266333 </code></pre> <p>Which is not correct. </p>
0debug
Why does this variable change in the code? : <p>I wrote a mergesort function in c++. In which a pass wrong value(array out of bound) of upper limit in function.</p> <pre><code>int a[]={6,5,2,4,6,78,88,76,33,44,54,212,344,56,677}; int n=sizeof(a)/sizeof(a[0]); printf("n=%d\n",n); merges(a,0,n); // if should be 'merges(a,0,n-1)' printf("n=%d\n",n); </code></pre> <p>I think in argument only copy of a variable is passed. Original value does not change. but Checking before and after merges() function I got two different values. I can't figure out why? output:</p> <pre><code>n=15 n=677 </code></pre> <p>Here is complete code:</p> <pre><code>#include&lt;bits/stdc++.h&gt; using namespace std; void mergeit(int a[],int l,int mid,int r) { int n1=mid-l+1; int n2=r-mid; int ll[n1+1];ll[n1]=INT_MAX; for(int h=0;h&lt;n1;h++)ll[h]=a[l+h]; int rr[n2+1];rr[n2]=INT_MAX; for(int h=0;h&lt;n2;h++)rr[h]=a[mid+1+h]; int i=0,j=0; for(int k=l;k&lt;=r;k++) { if(ll[i]&lt;rr[j]) { a[k]=ll[i];i++; } else{a[k]=rr[j];j++;} } } void merges(int a[],int l,int r) { if(l&lt;r) { int mid=(l+r)/2; merges(a,l,mid); merges(a,mid+1,r); mergeit(a,l,mid,r); } } int main() { int a[]={6,5,2,4,6,78,88,76,33,44,54,212,344,56,677}; int n=sizeof(a)/sizeof(a[0]); printf("n=%d\n",n); merges(a,0,n); //array out of bound- it should be 'merges(a,0,n-1)' printf("n=%d\n",n); } </code></pre>
0debug
static void bdrv_raw_init(void) { bdrv_register(&bdrv_raw); bdrv_register(&bdrv_host_device); }
1threat
java bean drop game ball only going to right : The Ball only goes of to right Dependencies Std.java a marble picture and a background arena image thank you for the help I believe the issue to be in the transition from The LR method to the main game loop method i created a variable and it takes the LR method and runs it it is inside the loop that refreshes and clears the canvas as a frame every second The question maker requires more explanination so im going to fill the rest with random lorem ipsum jfkadhfkjhfljkashfjkdhsfjdhsfljkdhsafjlhdjkfhdsjkfhdjaskfhkjahfljhdkfjhdaslfjkhdfkjdhsfkjdsflh package cats; public class BeanDrop { public static void main(String[] args) throws InterruptedException { mainGameLoop(); } public static void mainGameLoop() throws InterruptedException{ double x = .5; double y = .9; while (true){ int choice = LR(); arena(); ball(x , y); if (choice == 1){ // right outcome x = x + .1; } else if(choice == 2){ //left outcome x = x -.1; } y = y - .1; Thread.sleep(1000); StdDraw.clear(); } } public static void arena(){ StdDraw.picture(.5, .5, "balldrop.jpeg"); } private static int LR(){ int choice = ((int) Math.random() * 2 + 1); return choice; } public static void ball(double x , double y){ StdDraw.picture(x, y, "ball.jpeg",.05,.05); } }
0debug
static void test_visitor_in_native_list_uint16(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U16); }
1threat
C - while operator in for loop initializer : <p>Why I cannot write smthng like this?</p> <pre><code>int i, size; int *arr; ... for(i = size - 1, while(arr[i] == 0) i--; i &gt;= 0; i--) { ... } </code></pre>
0debug
How to retrieve PHAsset from UIImagePickerController : <p>I'm trying to retrieve a PHAsset however PHAsset.fetchAssets(withALAssetURLs:options:) is deprecated from iOS 8 so how can I properly retrieve a PHAsset?</p>
0debug
How to add new row in dataframe : I have two dataframe that look like df1 V1 V2 V3 V4 rs200140498 chr1 861315 GG rs371217242 chr1 861329 AA rs200686669 chr1 861349 CC rs370046315 chr1 861357 CC rs374110379 chr1 861521 GG rs74045401 chr1 861530 GG rs377418023 chr1 865394 CC rs79027658 chr1 865438 CC rs202189913 chr1 865488 AA rs370992396 chr1 865543 GG and df2 V1 V2 V3 V4 rs200140498 chr1 861315 GG rs200686669 chr1 861349 CC rs370046315 chr1 861357 CC rs74045401 chr1 861530 GG rs377418023 chr1 865394 CC rs202189913 chr1 865488 AA rs370992396 chr1 865543 GG And i want to compare its and get new data frame V1 V2 V3 V4 rs200140498 chr1 861315 GG rs371217242 chr1 861329 -- rs200686669 chr1 861349 CC rs370046315 chr1 861357 CC rs374110379 chr1 861521 -- rs74045401 chr1 861530 GG rs377418023 chr1 865394 CC rs79027658 chr1 865438 -- rs202189913 chr1 865488 AA rs370992396 chr1 865543 GG Can anyone help me with this? Thanks in advance.
0debug
What is reflect-metadata in typescript : <p>what are reflect-metadata and its purpose?</p> <p>What is syntax and purpose of using reflect-metadata?</p> <p>Can some one provide the example for better understanding of the same?</p> <p>How can be the reflect metadata helpful in implementing decorators in typescript.</p>
0debug
Encrypt String in .NET Core : <p>I would like to encrypt a string in .NET Core using a key. I have a client / server scenario and would like to encrypt a string on the client, send it to the server and decrypt it. </p> <p>As .NET Core is still in a early stage (e.g. Rijndael is not yet available), what are my options? </p>
0debug
Airflow DAG Run triggered, but never executed? : <p>I've found myself in a situation where I manually trigger a DAG Run (via <code>airflow trigger_dag datablocks_dag</code>) run, and the Dag Run shows up in the interface, but it then stays "Running" forever without actually doing anything.</p> <p>When I inspect this DAG Run in the UI, I see the following:</p> <p><a href="https://i.stack.imgur.com/32PG2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/32PG2.png" alt="enter image description here"></a></p> <p>I've got <code>start_date</code> set to <code>datetime(2016, 1, 1)</code>, and <code>schedule_interval</code> set to <code>@once</code>. <em>My</em> understanding from reading the docs is that since <code>start_date</code> &lt; now, the DAG will be triggered. The <code>@once</code> makes sure it only happens a single time.</p> <p>My log file says:</p> <pre><code>[2017-07-11 21:32:05,359] {jobs.py:343} DagFileProcessor0 INFO - Started process (PID=21217) to work on /home/alex/Desktop/datablocks/tests/.airflow/dags/datablocks_dag.py [2017-07-11 21:32:05,359] {jobs.py:534} DagFileProcessor0 ERROR - Cannot use more than 1 thread when using sqlite. Setting max_threads to 1 [2017-07-11 21:32:05,365] {jobs.py:1525} DagFileProcessor0 INFO - Processing file /home/alex/Desktop/datablocks/tests/.airflow/dags/datablocks_dag.py for tasks to queue [2017-07-11 21:32:05,365] {models.py:176} DagFileProcessor0 INFO - Filling up the DagBag from /home/alex/Desktop/datablocks/tests/.airflow/dags/datablocks_dag.py [2017-07-11 21:32:05,703] {models.py:2048} DagFileProcessor0 WARNING - schedule_interval is used for &lt;Task(BashOperator): foo&gt;, though it has been deprecated as a task parameter, you need to specify it as a DAG parameter instead [2017-07-11 21:32:05,703] {models.py:2048} DagFileProcessor0 WARNING - schedule_interval is used for &lt;Task(BashOperator): foo2&gt;, though it has been deprecated as a task parameter, you need to specify it as a DAG parameter instead [2017-07-11 21:32:05,704] {jobs.py:1539} DagFileProcessor0 INFO - DAG(s) dict_keys(['example_branch_dop_operator_v3', 'latest_only', 'tutorial', 'example_http_operator', 'example_python_operator', 'example_bash_operator', 'example_branch_operator', 'example_trigger_target_dag', 'example_short_circuit_operator', 'example_passing_params_via_test_command', 'test_utils', 'example_subdag_operator', 'example_subdag_operator.section-1', 'example_subdag_operator.section-2', 'example_skip_dag', 'example_xcom', 'example_trigger_controller_dag', 'latest_only_with_trigger', 'datablocks_dag']) retrieved from /home/alex/Desktop/datablocks/tests/.airflow/dags/datablocks_dag.py [2017-07-11 21:32:07,083] {models.py:3529} DagFileProcessor0 INFO - Creating ORM DAG for datablocks_dag [2017-07-11 21:32:07,234] {models.py:331} DagFileProcessor0 INFO - Finding 'running' jobs without a recent heartbeat [2017-07-11 21:32:07,234] {models.py:337} DagFileProcessor0 INFO - Failing jobs without heartbeat after 2017-07-11 21:27:07.234388 [2017-07-11 21:32:07,240] {jobs.py:351} DagFileProcessor0 INFO - Processing /home/alex/Desktop/datablocks/tests/.airflow/dags/datablocks_dag.py took 1.881 seconds </code></pre> <p>What could be causing the issue?</p> <p>Am I misunderstanding how <code>start_date</code> operates?</p> <p>Or are the worrisome-seeming <code>schedule_interval</code> <code>WARNING</code> lines in the log file possibly the source of the problem?</p>
0debug
static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv b) { TCGv_i64 tmp64 = tcg_temp_new_i64(); tcg_gen_extu_i32_i64(tmp64, b); dead_tmp(b); tcg_gen_shli_i64(tmp64, tmp64, 32); tcg_gen_sub_i64(a, tmp64, a); tcg_temp_free_i64(tmp64); return a; }
1threat
React-Bootstrap add pull-right to Button : <p>I have the following JSX using React-Bootstrap:</p> <pre><code>&lt;Button bsStyle="danger pull-right" bsSize="small" onClick={() =&gt; {alert('do stuff')}}&gt; &lt;Glyphicon glyph="trash" /&gt; &lt;/Button&gt; </code></pre> <p>However this will show a warning in the console:</p> <pre><code>Warning: Failed prop type: Invalid prop `bsStyle` of value `danger pull-right` supplied to `Button`, expected one of ["success","warning","danger","info","default","primary","link"]. </code></pre> <p>What is the best way to add <code>pull-right</code> to the list of styles?</p> <p>The above code does work, but I'd prefer not to have any warnings in my console.</p>
0debug
static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c, GetByteContext *gb) { int i, j, k; uint8_t *dst; uint32_t bits; uint32_t cur_size, cursor_w, cursor_h, cursor_stride; uint32_t cursor_hot_x, cursor_hot_y; int cursor_fmt; uint8_t *tmp; cur_size = bytestream2_get_be32(gb); cursor_w = bytestream2_get_byte(gb); cursor_h = bytestream2_get_byte(gb); cursor_hot_x = bytestream2_get_byte(gb); cursor_hot_y = bytestream2_get_byte(gb); cursor_fmt = bytestream2_get_byte(gb); cursor_stride = FFALIGN(cursor_w, c->cursor_fmt==1 ? 32 : 1) * 4; if (cursor_w < 1 || cursor_w > 256 || cursor_h < 1 || cursor_h > 256) { av_log(avctx, AV_LOG_ERROR, "Invalid cursor dimensions %dx%d\n", cursor_w, cursor_h); return AVERROR_INVALIDDATA; } if (cursor_hot_x > cursor_w || cursor_hot_y > cursor_h) { av_log(avctx, AV_LOG_WARNING, "Invalid hotspot position %d,%d\n", cursor_hot_x, cursor_hot_y); cursor_hot_x = FFMIN(cursor_hot_x, cursor_w - 1); cursor_hot_y = FFMIN(cursor_hot_y, cursor_h - 1); } if (cur_size - 9 > bytestream2_get_bytes_left(gb) || c->cursor_w * c->cursor_h / 4 > cur_size) { av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %d/%d\n", cur_size, bytestream2_get_bytes_left(gb)); return AVERROR_INVALIDDATA; } if (cursor_fmt != 1 && cursor_fmt != 32) { avpriv_report_missing_feature(avctx, "Cursor format %d", cursor_fmt); return AVERROR_PATCHWELCOME; } tmp = av_realloc(c->cursor, cursor_stride * cursor_h); if (!tmp) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate cursor buffer\n"); return AVERROR(ENOMEM); } c->cursor = tmp; c->cursor_w = cursor_w; c->cursor_h = cursor_h; c->cursor_hot_x = cursor_hot_x; c->cursor_hot_y = cursor_hot_y; c->cursor_fmt = cursor_fmt; c->cursor_stride = cursor_stride; dst = c->cursor; switch (c->cursor_fmt) { case 1: for (j = 0; j < c->cursor_h; j++) { for (i = 0; i < c->cursor_w; i += 32) { bits = bytestream2_get_be32(gb); for (k = 0; k < 32; k++) { dst[0] = !!(bits & 0x80000000); dst += 4; bits <<= 1; } } } dst = c->cursor; for (j = 0; j < c->cursor_h; j++) { for (i = 0; i < c->cursor_w; i += 32) { bits = bytestream2_get_be32(gb); for (k = 0; k < 32; k++) { int mask_bit = !!(bits & 0x80000000); switch (dst[0] * 2 + mask_bit) { case 0: dst[0] = 0xFF; dst[1] = 0x00; dst[2] = 0x00; dst[3] = 0x00; break; case 1: dst[0] = 0xFF; dst[1] = 0xFF; dst[2] = 0xFF; dst[3] = 0xFF; break; default: dst[0] = 0x00; dst[1] = 0x00; dst[2] = 0x00; dst[3] = 0x00; } dst += 4; bits <<= 1; } } } break; case 32: bytestream2_skip(gb, c->cursor_h * (FFALIGN(c->cursor_w, 32) >> 3)); for (j = 0; j < c->cursor_h; j++) { for (i = 0; i < c->cursor_w; i++) { int val = bytestream2_get_be32(gb); *dst++ = val >> 0; *dst++ = val >> 8; *dst++ = val >> 16; *dst++ = val >> 24; } } break; default: return AVERROR_PATCHWELCOME; } return 0; }
1threat
Command to genarate result in xls/csv? : Below is the command to run the Soap UI project,after run I will be getting xml file results,that i needed in xls/csv Kindly some one help me. "/home/user/SmartBear/SoapUI-5.2.1/bin/testrunner.sh" -e$endpoint -rjf $resultfile $projectnew
0debug
void HELPER(cksm)(uint32_t r1, uint32_t r2) { uint64_t src = get_address_31fix(r2); uint64_t src_len = env->regs[(r2 + 1) & 15]; uint64_t cksm = 0; while (src_len >= 4) { cksm += ldl(src); cksm = cksm_overflow(cksm); src_len -= 4; src += 4; } switch (src_len) { case 0: break; case 1: cksm += ldub(src); cksm = cksm_overflow(cksm); break; case 2: cksm += lduw(src); cksm = cksm_overflow(cksm); break; case 3: cksm += lduw(src) << 8; cksm += ldub(src + 2); cksm = cksm_overflow(cksm); break; } env->regs[(r2 + 1) & 15] = 0; env->regs[r1] = (env->regs[r1] & 0xffffffff00000000ULL) | (uint32_t)cksm; }
1threat
static int str_read_packet(AVFormatContext *s, AVPacket *ret_pkt) { AVIOContext *pb = s->pb; StrDemuxContext *str = s->priv_data; unsigned char sector[RAW_CD_SECTOR_SIZE]; int channel; AVPacket *pkt; AVStream *st; while (1) { if (avio_read(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE) return AVERROR(EIO); channel = sector[0x11]; if (channel >= 32) return AVERROR_INVALIDDATA; switch (sector[0x12] & CDXA_TYPE_MASK) { case CDXA_TYPE_DATA: case CDXA_TYPE_VIDEO: { int current_sector = AV_RL16(&sector[0x1C]); int sector_count = AV_RL16(&sector[0x1E]); int frame_size = AV_RL32(&sector[0x24]); if(!( frame_size>=0 && current_sector < sector_count && sector_count*VIDEO_DATA_CHUNK_SIZE >=frame_size)){ av_log(s, AV_LOG_ERROR, "Invalid parameters %d %d %d\n", current_sector, sector_count, frame_size); break; } if(str->channels[channel].video_stream_index < 0){ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 64, 1, 15); str->channels[channel].video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_MDEC; st->codec->codec_tag = 0; st->codec->width = AV_RL16(&sector[0x28]); st->codec->height = AV_RL16(&sector[0x2A]); } pkt = &str->channels[channel].tmp_pkt; if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){ if(pkt->data) av_log(s, AV_LOG_ERROR, "missmatching sector_count\n"); av_free_packet(pkt); if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE)) return AVERROR(EIO); pkt->pos= avio_tell(pb) - RAW_CD_SECTOR_SIZE; pkt->stream_index = str->channels[channel].video_stream_index; } memcpy(pkt->data + current_sector*VIDEO_DATA_CHUNK_SIZE, sector + VIDEO_DATA_HEADER_SIZE, VIDEO_DATA_CHUNK_SIZE); if (current_sector == sector_count-1) { pkt->size= frame_size; *ret_pkt = *pkt; pkt->data= NULL; pkt->size= -1; pkt->buf = NULL; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS pkt->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif return 0; } } break; case CDXA_TYPE_AUDIO: if(str->channels[channel].audio_stream_index < 0){ int fmt = sector[0x13]; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); str->channels[channel].audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_ADPCM_XA; st->codec->codec_tag = 0; if (fmt & 1) { st->codec->channels = 2; st->codec->channel_layout = AV_CH_LAYOUT_STEREO; } else { st->codec->channels = 1; st->codec->channel_layout = AV_CH_LAYOUT_MONO; } st->codec->sample_rate = (fmt&4)?18900:37800; st->codec->block_align = 128; avpriv_set_pts_info(st, 64, 18 * 224 / st->codec->channels, st->codec->sample_rate); st->start_time = 0; } pkt = ret_pkt; if (av_new_packet(pkt, 2304)) return AVERROR(EIO); memcpy(pkt->data,sector+24,2304); pkt->stream_index = str->channels[channel].audio_stream_index; pkt->duration = 1; return 0; default: av_log(s, AV_LOG_WARNING, "Unknown sector type %02X\n", sector[0x12]); break; } if (url_feof(pb)) return AVERROR(EIO); } }
1threat
How to access vector class array methods in c++ : <pre><code>class Bird{ public: void init(); Bird();//constructor void foo();//its defined somewhere }; int _tmain(int argc, _TCHAR* argv[]) { std::vector &lt;Bird&gt; B[51]; for (int i = 0; i &lt; 51; i++) B[i].foo(); } </code></pre> <p>it seems vector is a safe and modern way to generate 51 object safely.</p> <p>assume Im creating an Object Array from class Bird. and want to use each objects method. (I cant use static object array because I have to swap the array members later.)</p> <p><br/><br/></p> <p>(and I didnt use C++ since 2000. Now I have to)</p>
0debug
Writing to a spreadsheet with Python 2.65 : <p>I am trying to make some Python 3.6 code work in a Python 2.65 environment. I've made most of the corrections but I cannot import module <code>xlwt</code>. It imports <code>xlrd</code> just fine. I tried <code>openpyxl</code> but that was not available either. Does Python 2.65 come with any standard module that will write to a spreadsheet?</p>
0debug
Angular 4 - Route query params cause path match failure : <p>After searching multiple threads/questions on the various types of routing within Angular 4, I cannot resolve an issue linked to passing queryParams to an Angular 4 route.</p> <p>When passing either into the url </p> <pre><code>http://localhost/search;x=y </code></pre> <p>through the template [queryParams]={x: 'y'}</p> <pre><code>&lt;a [routerLink]="/search" [queryParams]="{x: 'y'}"&gt;Navigate&lt;/a&gt; </code></pre> <p>or in the component class</p> <pre><code>this._router.navigate(['/search'], { queryParams: {x: 'y'} }); </code></pre> <p>the result is the router throwing a match error:</p> <pre><code>Error: Cannot match any routes. URL Segment: 'search%3Fparam1%3Dtest1%26param2%3Dtest2' </code></pre> <p>When setting enableTracing to true, I can see the navigation encodes the suspect characters, which most likely is the reason it's failing to match.</p> <p>I have a requirement to handle urls that contain queryParams and parse them for api calls, so the query param route must be used over required or optional params.</p> <p>Has anyone had a similar issue and if so, is the encoding the root (ahem.) cause of the issue?</p>
0debug
Deepcopy in React : <p>In reducers,we always use <code>Object.assign({},state,newState)</code> to save a state. But <code>assign()</code> doesn't support deepcopy,because this method only copy a reference of multi-level object. This is my code in program.</p> <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>const menuListState={ menuList: {}, menuListLoading:false } function getMenuList(state=menuListState,action=defaultAction){ switch(action.type){ //menuList begin case actions.GET_MENULIST_SUCCESS: return Object.assign({},state,{ menuList:action.data, menuListLoading:false }); default: return state; } }</code></pre> </div> </div> </p> <p>The property <code>menuList</code> is a multi-level Object. And when <code>action.data</code> changes, will <code>state.menuList</code> be changed immediately before the method <code>assign()</code> work?</p>
0debug
SimpleDateFormat and Date object : <p>In my android app I retrieve from an api the current day as.</p> <pre><code> long dateTime = innerJSON.getLong("dt"); Date weekDay = new Date(dateTime * 1000L); SimpleDateFormat outFormat = new SimpleDateFormat("EEEE"); String day = outFormat.format(weekDay); </code></pre> <p>And I get the current day ie Monday. </p> <p>For the date I use the same Date object but with a different SimpleDateFormat object. </p> <pre><code> SimpleDateFormat outFormat1 = new SimpleDateFormat("dd-M-yyyy"); String date = outFormat1.format(weekDay); </code></pre> <p>And that gives me,</p> <pre><code> 28-5-2016 </code></pre> <p>which is fine. However, I want the date to have a format of</p> <pre><code> 28 May </code></pre> <p>Any ideas on that? I checked the official orarcle's <a href="https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html" rel="nofollow">site</a>,but I can't find a solution.</p> <p>Thanks,</p> <p>Theo.</p>
0debug
static int v9fs_synth_readdir_r(FsContext *ctx, V9fsFidOpenState *fs, struct dirent *entry, struct dirent **result) { int ret; V9fsSynthOpenState *synth_open = fs->private; V9fsSynthNode *node = synth_open->node; ret = v9fs_synth_get_dentry(node, entry, result, synth_open->offset); if (!ret && *result != NULL) { synth_open->offset++; } return ret; }
1threat
static void audio_init (void) { size_t i; int done = 0; const char *drvname; VMChangeStateEntry *e; AudioState *s = &glob_audio_state; if (s->drv) { return; } QLIST_INIT (&s->hw_head_out); QLIST_INIT (&s->hw_head_in); QLIST_INIT (&s->cap_head); atexit (audio_atexit); s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); if (!s->ts) { hw_error("Could not create audio timer\n"); } audio_process_options ("AUDIO", audio_options); s->nb_hw_voices_out = conf.fixed_out.nb_voices; s->nb_hw_voices_in = conf.fixed_in.nb_voices; if (s->nb_hw_voices_out <= 0) { dolog ("Bogus number of playback voices %d, setting to 1\n", s->nb_hw_voices_out); s->nb_hw_voices_out = 1; } if (s->nb_hw_voices_in <= 0) { dolog ("Bogus number of capture voices %d, setting to 0\n", s->nb_hw_voices_in); s->nb_hw_voices_in = 0; } { int def; drvname = audio_get_conf_str ("QEMU_AUDIO_DRV", NULL, &def); } if (drvname) { int found = 0; for (i = 0; i < ARRAY_SIZE (drvtab); i++) { if (!strcmp (drvname, drvtab[i]->name)) { done = !audio_driver_init (s, drvtab[i]); found = 1; break; } } if (!found) { dolog ("Unknown audio driver `%s'\n", drvname); dolog ("Run with -audio-help to list available drivers\n"); } } if (!done) { for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) { if (drvtab[i]->can_be_default) { done = !audio_driver_init (s, drvtab[i]); } } } if (!done) { done = !audio_driver_init (s, &no_audio_driver); if (!done) { hw_error("Could not initialize audio subsystem\n"); } else { dolog ("warning: Using timer based audio emulation\n"); } } if (conf.period.hertz <= 0) { if (conf.period.hertz < 0) { dolog ("warning: Timer period is negative - %d " "treating as zero\n", conf.period.hertz); } conf.period.ticks = 1; } else { conf.period.ticks = muldiv64 (1, get_ticks_per_sec (), conf.period.hertz); } e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); if (!e) { dolog ("warning: Could not register change state handler\n" "(Audio can continue looping even after stopping the VM)\n"); } QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); }
1threat
2 place in the page with the same xpath : I want to insert a text to a filed. This filed xpath = "//*[@id='email']". This xpath is moved to 2 places in the web page. The first is not visible and the second is ok. I want to insert text to the second. I do it like this: String xpathOfElement = "//*[@id='email']"; List<WebElement> a = driver.findElements(By.xpath(xpathOfElement)); a.get(1).sendKeys("hhh"); I received this error msg: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
0debug
void ide_flush_cache(IDEState *s) { if (s->bs == NULL) { ide_flush_cb(s, 0); return; } s->status |= BUSY_STAT; block_acct_start(bdrv_get_stats(s->bs), &s->acct, 0, BLOCK_ACCT_FLUSH); s->pio_aiocb = bdrv_aio_flush(s->bs, ide_flush_cb, s); }
1threat
Keras Binary Classification - Sigmoid activation function : <p>I've implemented a basic MLP in Keras with tensorflow and I'm trying to solve a binary classification problem. For binary classification, it seems that sigmoid is the recommended activation function and I'm not quite understanding why, and how Keras deals with this.</p> <p>I understand the sigmoid function will produce values in a range between 0 and 1. My understanding is that for classification problems using sigmoid, there will be a certain threshold used to determine the class of an input (typically 0.5). In Keras, I'm not seeing any way to specify this threshold, so I assume it's done implicitly in the back-end? If this is the case, how is Keras distinguishing between the use of sigmoid in a binary classification problem, or a regression problem? With binary classification, we want a binary value, but with regression a nominal value is needed. All I can see that could be indicating this is the loss function. Is that informing Keras on how to handle the data?</p> <p>Additionally, assuming Keras is implicitly applying a threshold, why does it output nominal values when I use my model to predict on new data?</p> <p>For example:</p> <pre><code>y_pred = model.predict(x_test) print(y_pred) </code></pre> <p>gives:</p> <blockquote> <p>[7.4706882e-02] [8.3481872e-01] [2.9314638e-04] [5.2297767e-03] [2.1608515e-01] ... [4.4894204e-03] [5.1120580e-05] [7.0263929e-04]</p> </blockquote> <p>I can apply a threshold myself when predicting to get a binary output, however surely Keras must be doing that anyway in order to correctly classify? Perhaps Keras is applying a threshold when training the model, but when I use it to predict new values, the threshold isn't used as the loss function isn't used in predicting? Or is not applying a threshold at all, and the nominal values outputted happen to be working well with my model? I've checked this is happening on the Keras example for binary classification, so I don't think I've made any errors with my code, especially as it's predicting accurately.</p> <p>If anyone could explain how this is working, I would greatly appreciate it.</p> <p>Here's my model as a point of reference:</p> <pre><code>model = Sequential() model.add(Dense(124, activation='relu', input_shape = (2,))) model.add(Dropout(0.5)) model.add(Dense(124, activation='relu')) model.add(Dropout(0.1)) model.add(Dense(1, activation='sigmoid')) model.summary() model.compile(loss='binary_crossentropy', optimizer=SGD(lr = 0.1, momentum = 0.003), metrics=['acc']) history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1, validation_data=(x_test, y_test)) score = model.evaluate(x_test, y_test, verbose=0) </code></pre>
0debug
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc, int flags, const int16_t *hChrFilter, const int16_t *hChrFilterPos, int hChrFilterSize, enum PixelFormat srcFormat, uint8_t *formatConvBuffer, uint32_t *pal) { int32_t av_unused *mmx2FilterPos = c->chrMmx2FilterPos; int16_t av_unused *mmx2Filter = c->chrMmx2Filter; int av_unused canMMX2BeUsed = c->canMMX2BeUsed; void av_unused *mmx2FilterCode= c->chrMmx2FilterCode; if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE) return; src1 += c->chrSrcOffset; src2 += c->chrSrcOffset; if (c->hcscale_internal) { c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } if (!c->hcscale_fast) { c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); } else { #if ARCH_X86 && CONFIG_GPL #if COMPILE_TEMPLATE_MMX2 int i; #if defined(PIC) DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif if (canMMX2BeUsed) { __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %6 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE "xor %%"REG_a", %%"REG_a" \n\t" "mov %5, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %6, %%"REG_b" \n\t" #endif :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), "m" (mmx2FilterCode), "m" (src2) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { dst[i] = src1[srcW-1]*128; dst[i+VOFW] = src2[srcW-1]*128; } } else { #endif x86_reg xInc_shr16 = (x86_reg) (xInc >> 16); uint16_t xInc_mask = xInc & 0xffff; __asm__ volatile( "xor %%"REG_a", %%"REG_a" \n\t" "xor %%"REG_d", %%"REG_d" \n\t" "xorl %%ecx, %%ecx \n\t" ASMALIGN(4) "1: \n\t" "mov %0, %%"REG_S" \n\t" "movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" "movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" FAST_BILINEAR_X86 "movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t" "movzbl (%5, %%"REG_d"), %%edi \n\t" "movzbl 1(%5, %%"REG_d"), %%esi \n\t" FAST_BILINEAR_X86 "movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t" "addw %4, %%cx \n\t" "adc %3, %%"REG_d" \n\t" "add $1, %%"REG_a" \n\t" "cmp %2, %%"REG_a" \n\t" " jb 1b \n\t" #if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4) :: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #else :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #endif "r" (src2) : "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi" ); #if COMPILE_TEMPLATE_MMX2 } #endif #else c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc); #endif } if (c->chrConvertRange) c->chrConvertRange(dst, dstWidth); }
1threat
Angular2 Observables -- Replay : <p>I am trying to set up an Angular2 Observable that will replay the latest value.</p> <pre><code>import {Injectable} from 'angular2/core'; import {Observable} from 'rxjs/Observable'; @Injectable() export class RefinementService { refining: any; private r: any; constructor() { this.refining = new Observable(observer =&gt; this.r = observer).replay(1); } } </code></pre> <p><br/> I continually get errors stating:</p> <blockquote> <p>Property 'replay' does not exist on type Observable&lt;{}>.</p> </blockquote> <p>and</p> <blockquote> <p>this.refining.replay is not a function</p> </blockquote> <p><br/> Has anyone successfully implemented an observable that will re-emit it's latest value to new subscribers?</p>
0debug
Fast algorithm for checking if binary arrays can be rotated to not have an elementwise sum over 1 : <p>Let's say I have a set of constant-length arrays containing only zeroes and ones. My goal is to find out whether, after any rotation of any of the arrays, the element-wise sums of the arrays will not exceed 1.</p> <p>For instance, let's say I have the following three arrays: <code>[1, 0, 0, 0], [1, 0, 1, 0]</code>, and <code>[1, 0, 0, 0]</code>. I can rotate the second array by one element and the third array by two elements to obtain the arrays <code>[1, 0, 0, 0], [0, 1, 0, 1], [0, 0, 1, 0]</code>, the element-wise sum of which is <code>[1, 1, 1, 1]</code>. However, had I not applied the rotations, I would have gotten a sum of <code>[3, 0, 1, 0]</code>, which does not fit my requirements as one of the elements (the 3) is greater than 1.</p> <p>Now, my question is, what is a fast way to determine if this is possible for an arbitrary number of arrays? For instance, there is no way to rotate <code>[1, 0, 0, 0], [1, 0, 1, 0], [1, 0, 1, 0]</code> so that the elements of the sum do not exceed 1.</p> <p><strong>Current heuristics</strong></p> <p>Obviously, if the total sum of the arrays, which are, say, length <code>n</code>, exceeds <code>n</code>, then this is trivially impossible.<br> The best idea for an approach I can think of so far is taking two arrays, finding a way to merge them together, and inverting the result. Then, we take this result and the next array, and repeat this process. However, this method does not guarantee to find a solution if one exists.</p> <p>My question is, short of trying every possible rotation, what would be a good algorithm for this problem?</p>
0debug
module is not defined and process is not defined in eslint in visual studio code : <p>I have installed eslint in my machine and i have used visual studio code i have certain modules and process to be exported When i try to use "module" or "process" it shows it was working fine before.</p> <pre><code>[eslint] 'module' is not defined. (no-undef) [eslint] 'process' is not defined. (no-undef) </code></pre> <p>and here is my .eslintrc.json</p> <pre><code>{ "env": { "browser": true, "amd": true }, "parserOptions": { "ecmaVersion": 6 }, "extends": "eslint:recommended", "rules": { "no-console": "off", "indent": [ "error", "tab" ], "linebreak-style": [ "error", "windows" ], "quotes": [ "error", "single" ], "semi": [ "error", "always" ] } </code></pre> <p>}</p> <p>I want to remove this error </p>
0debug
SVG dominant-baseline not working in Safari : <p>I'm trying to position SVG text so that it site entirely above the y-location at which it is located. A dominant baseline of <code>text-after-edge</code> appears to be the appropriate setting for this.</p> <p>This works just fine in Chrome, but with Safari <code>text-after-edge</code> renders with the text centred around the y-location.</p> <p>I explored further, as seen in this codepen:</p> <p><a href="https://codepen.io/anon/pen/obrreb?editors=1010" rel="noreferrer">https://codepen.io/anon/pen/obrreb?editors=1010</a></p> <p>Here is the output in Chrome:</p> <p><a href="https://i.stack.imgur.com/SdsGk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SdsGk.png" alt="enter image description here"></a></p> <p>And in Safari:</p> <p><a href="https://i.stack.imgur.com/ZSiLM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZSiLM.png" alt="enter image description here"></a></p> <p>As you can see a number of the dominant baseline renderings differ.</p>
0debug
how to get an object (font style, font size, color, borders, lines, cell size) from excel using C#? : how to get an object (font style, font size, color, borders, lines, cell size) from excel using C#? PLEASE HELP! I don't where to start or how to start.
0debug
Changing the page title using the Angular 2 new router : <p>What's the right way to change the app page title in browser when using the <strong>new router</strong>?</p> <p>*Using Angular 2 CLI</p>
0debug
Following Java Tutorial - Need hep with errors : I've been following a java tutorials who has began learning via Sam's teach yourself java and although I have copied this to ensure I can run it before I begin to change and make it my own, it will not run and I am not sure why. I would appreciate if one of you guys/girls could help. I've put my java classes in the correct packages, but it doesn't run. Thanks. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> package com.jackson.ecommerce; import java.util.*; public class Item implements Comparable { private String id; private String name; private double retail; private int quantity; private double price; Item(String idIn, String nameIn, String retailIn, String quanIn) { id = idIn; name = nameIn; retail = Double.parseDouble(retailIn); if (quantity > 400) price = retail * 5D; else if (quantity > 200) price = retail * .6D; else price = retail * .7D; price = Math.floor( price * 100 + .5) / 100; } public int compareTo(Object obj) { Item temp = (Item)obj; if (this.price < temp.price) return 1; return 0; } public String getId(){ return id; } public String getName(){ return name; } public double GetRetail(){ return retail; } public int getQuantity(){ return quantity; } public double getPrice(){ return price; } } <!-- end snippet --> <!-- begin snippet: js hide: false --> <!-- language: lang-html --> package com.jackson.ecommerce; import java.util.*; public class Storefront { private LinkedList catalog = new LinkedList(); public void addItem(String id, String name, String price, String quant){ Item it = new Item(id, name, price, quant); catalog.add(it); } public Item getItem(int i){ return (Item)catalog.get(i); } public int getSize(){ return catalog.size(); } public void sort() { Collections.sort(catalog); } <!-- end snippet --> <!-- begin snippet: js hide: false --> <!-- language: lang-html --> package Package1; import com.jackson.ecommerce.*; public class Giftshop { public static void main(String[] arguments){ Storefront store = new Storefront(); store.addItem("C01", "MUG, "9.99", "150"); store.addItem("C02", "LG MUG", "12.99", "82"); store.addItem(“C03”, “MOUSEPAD”, “10.49”, “800”); store.addItem(“D01”, “T SHIRT”, “16.99”, “90”); store.sort()); for (int i = 0; i < store.getSize(); i++) { Item show = (Item)store.getItem(i); System.out.println( show.getId() + show.getName() + show.getRetail() + show.getPrice() + show.getQuantity()); } } } <!-- end snippet -->
0debug
Python print module says the file name is not defined : <p>Working on a Head First Python book, 2010, I've encountered an exercise where I had to print a list into a specific file, and another list into another one. Did all the code, everything works, except for the print module which says the name of the file is not defined, which is pretty weird since the solution of the exercise it's the exact same code of mine.</p> <pre><code>import os man = [] other = [] try: data = open('ketchup.txt') for each_line in data: try: (role, line_spoken) = each_line.split(":", 1) line_spoken = line_spoken.strip() if role == 'Man': man.append(line_spoken) elif role == 'Other Man': other.append(line_spoken) except ValueError: pass data.close() except IOError: print("The data file is missing!") print(man) print(other) try: out = open("man_speech.txt", "w") out = open("other_speech.txt", "w") print(man, file=man_speech) #HERE COMES THE ERROR print(other, file=other_speech) man_speech.close() other_speech.close() except IOError: print("File error") </code></pre> <p>Here is the error from the IDLE:</p> <blockquote> <p>Traceback (most recent call last): File "C:\Users\Monok\Desktop\HeadFirstPython\chapter3\sketch2.py", line 34, in print(man, file=man_speech) NameError: name 'man_speech' is not defined</p> </blockquote> <p>Am I doing something wrong about the syntax, or maybe I didn't get how the print module works? The book doesn't give me any clue about it. I've also checked for lot of questions here and in some other forums, but nothing seems wrong with my code, and I'm actually tilted.</p>
0debug
What do with Async in node js : I have problem with async. Result of this code from pic should be: First:0 Second:2 Item ADD! First:1 Second:2 Item ADD! First:2 Second:2 Item ADD! And here script should stop. I know that code is to long but I can't put less. connection.query('SELECT `keys`.*,`transaction`.*,`keys`.`id` as kid, `transaction`.`id` as tid FROM `transaction` JOIN `keys` ON `keys`.`id` = `transaction`.`keys_id` WHERE `transaction`.`status_pay`= 1 and `transaction`.`status` = 1').then(function(rows){ rows.forEach(function(record) { var offer = manager.createOffer('76512333220'); inventory.forEach(function(item) { connection.query('SELECT amount_two FROM transaction where id = \'' + record.tid + '\'').then(function(w){ console.log("First: " + w[0].amount_two); console.log("Second: " + record.amount); if(w[0].amount_two <= record.amount) { if(item.market_hash_name == record.real_name) { var asid = item.assetid; connection.query('SELECT count(id) as wynik FROM used where asset_id = \'' + asid + '\'').then(function(wiersze){ if (wiersze[0].wynik == 0) { var employee = { asset_id: asid, trans_id: record.tid }; connection.query('INSERT INTO used SET ?', employee).then(function(rows){ offer.addMyItem(item); console.log('Item ADD!'); connection.query('UPDATE `transaction` SET `amount_two`= `amount_two` + 1 WHERE `id`=\''+record.tid+'\'').then(function(rows){ }); }); } }); } } }); }); }); }); [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/WcilH.png
0debug
static inline void gen_intermediate_code_internal(X86CPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPUX86State *env = &cpu->env; DisasContext dc1, *dc = &dc1; target_ulong pc_ptr; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj; uint64_t flags; target_ulong pc_start; target_ulong cs_base; int num_insns; int max_insns; pc_start = tb->pc; cs_base = tb->cs_base; flags = tb->flags; dc->pe = (flags >> HF_PE_SHIFT) & 1; dc->code32 = (flags >> HF_CS32_SHIFT) & 1; dc->ss32 = (flags >> HF_SS32_SHIFT) & 1; dc->addseg = (flags >> HF_ADDSEG_SHIFT) & 1; dc->f_st = 0; dc->vm86 = (flags >> VM_SHIFT) & 1; dc->cpl = (flags >> HF_CPL_SHIFT) & 3; dc->iopl = (flags >> IOPL_SHIFT) & 3; dc->tf = (flags >> TF_SHIFT) & 1; dc->singlestep_enabled = cs->singlestep_enabled; dc->cc_op = CC_OP_DYNAMIC; dc->cc_op_dirty = false; dc->cs_base = cs_base; dc->tb = tb; dc->popl_esp_hack = 0; dc->mem_index = 0; if (flags & HF_SOFTMMU_MASK) { dc->mem_index = cpu_mmu_index(env); } dc->cpuid_features = env->features[FEAT_1_EDX]; dc->cpuid_ext_features = env->features[FEAT_1_ECX]; dc->cpuid_ext2_features = env->features[FEAT_8000_0001_EDX]; dc->cpuid_ext3_features = env->features[FEAT_8000_0001_ECX]; dc->cpuid_7_0_ebx_features = env->features[FEAT_7_0_EBX]; #ifdef TARGET_X86_64 dc->lma = (flags >> HF_LMA_SHIFT) & 1; dc->code64 = (flags >> HF_CS64_SHIFT) & 1; #endif dc->flags = flags; dc->jmp_opt = !(dc->tf || cs->singlestep_enabled || (flags & HF_INHIBIT_IRQ_MASK) #ifndef CONFIG_SOFTMMU || (flags & HF_SOFTMMU_MASK) #endif ); dc->repz_opt = !dc->jmp_opt && !(tb->cflags & CF_USE_ICOUNT); #if 0 if (!dc->addseg && (dc->vm86 || !dc->pe || !dc->code32)) printf("ERROR addseg\n"); #endif cpu_T[0] = tcg_temp_new(); cpu_T[1] = tcg_temp_new(); cpu_A0 = tcg_temp_new(); cpu_tmp0 = tcg_temp_new(); cpu_tmp1_i64 = tcg_temp_new_i64(); cpu_tmp2_i32 = tcg_temp_new_i32(); cpu_tmp3_i32 = tcg_temp_new_i32(); cpu_tmp4 = tcg_temp_new(); cpu_ptr0 = tcg_temp_new_ptr(); cpu_ptr1 = tcg_temp_new_ptr(); cpu_cc_srcT = tcg_temp_local_new(); gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; pc_ptr = pc_start; lj = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; gen_tb_start(); for(;;) { if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == pc_ptr && !((bp->flags & BP_CPU) && (tb->flags & HF_RF_MASK))) { gen_debug(dc, pc_ptr - dc->cs_base); goto done_generating; } } } if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } tcg_ctx.gen_opc_pc[lj] = pc_ptr; gen_opc_cc_op[lj] = dc->cc_op; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); pc_ptr = disas_insn(env, dc, pc_ptr); num_insns++; if (dc->is_jmp) break; if (dc->tf || dc->singlestep_enabled || (flags & HF_INHIBIT_IRQ_MASK)) { gen_jmp_im(pc_ptr - dc->cs_base); gen_eob(dc); break; } if ((tb->cflags & CF_USE_ICOUNT) && ((pc_ptr & TARGET_PAGE_MASK) != ((pc_ptr + TARGET_MAX_INSN_SIZE - 1) & TARGET_PAGE_MASK) || (pc_ptr & ~TARGET_PAGE_MASK) == 0)) { gen_jmp_im(pc_ptr - dc->cs_base); gen_eob(dc); break; } if (tcg_ctx.gen_opc_ptr >= gen_opc_end || (pc_ptr - pc_start) >= (TARGET_PAGE_SIZE - 32) || num_insns >= max_insns) { gen_jmp_im(pc_ptr - dc->cs_base); gen_eob(dc); break; } if (singlestep) { gen_jmp_im(pc_ptr - dc->cs_base); gen_eob(dc); break; } } if (tb->cflags & CF_LAST_IO) gen_io_end(); done_generating: gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { int disas_flags; qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); #ifdef TARGET_X86_64 if (dc->code64) disas_flags = 2; else #endif disas_flags = !dc->code32; log_target_disas(env, pc_start, pc_ptr - pc_start, disas_flags); qemu_log("\n"); } #endif if (!search_pc) { tb->size = pc_ptr - pc_start; tb->icount = num_insns; } }
1threat
How to open the current directory on Bash on Windows? : <p>I know that in the Mac OS10, people use the <code>open .</code> command to open the current directory.</p> <p>Does anybody please know the appropriate command to do the same task under Bash on Windows?</p> <p>Cheers!</p>
0debug
How do I import a mod with traits into rust? this function takes 1 parameter but 0 parameters were supplied : <p>How do I import a mod into rust? </p> <p>1) I have a file with these contents:</p> <pre><code>this_is_stupid.rs pub mod fix_me { use crate::InputData; pub trait Wow { fn findMe(&amp;self); } //impl InputData { impl Wow for InputData { fn findMe(&amp;self) { print!("Really dudes we are working?"); } } //end impl } // mod </code></pre> <p>In my main I have this:</p> <pre><code> pub mod this_is_stupid; use crate::this_is_stupid::fix_me; pub struct InputData {} fn main() { let input_data: InputData{}; fix_me::Wow::findMe(); } </code></pre> <p>Here is my error:</p> <pre><code>error[E0061]: this function takes 1 parameter but 0 parameters were supplied --&gt; src/main.rs:85:9 | 85 | fix_me::Wow::findMe(); | ^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter | ::: src/this_is_stupid.rs:12:9 | 12 | fn findMe(&amp;self); | ----------------- defined here </code></pre>
0debug
How do I auto-indent Python code in Visual Studio Code? : <p>I'm using Visual Studio Code (<em>not Visual Studio</em>) on Linux and I can't seem to find out how to turn on auto-indentation for Python. I've looked all over preferences, spent some time on Google, and can't find anything.</p> <p>Does anyone know how to do this?</p>
0debug
Practice project ideas for blockchain : <p>I have some knowledge on blockchain technologies like Ethereum, Hyperledger Fabric but I would like to have more dev experience apart from the tutorials that are provided on their websites.</p> <p>Are there any resources where there are some blockchain ideas to develop some small blockchain projects for practice?</p>
0debug
TeamCity fails to build projects using C# 7 : <p>TeamCity is throwing errors when I added new the output variable syntax in our latest code update:</p> <pre><code>if (Enum.TryParse(input, out MyProject.ClassificationType classification)) { result.Classification = classification; } </code></pre> <p>TeamCity threw this error:</p> <p><code>[Csc] MyProject\MyCode.cs(125, 111): error CS1003: Syntax error, ',' expected</code></p> <p>The code builds and runs fine in Visual Studio.</p>
0debug
Merge from A to B directory updating b directory using system.IO c# : <p>I would like to compare two equal directories A and B with subdirectories. If I change, delete, or include directories or files in A, I need to reflect on B. Is there is any C # routine that does this? I have this routine but I can't move on. I would like to update only what I changed in A to B and not all. If I delete a directory in A it does not delete in B</p>
0debug
void vhost_dev_cleanup(struct vhost_dev *hdev) { int i; for (i = 0; i < hdev->nvqs; ++i) { vhost_virtqueue_cleanup(hdev->vqs + i); } memory_listener_unregister(&hdev->memory_listener); if (hdev->migration_blocker) { migrate_del_blocker(hdev->migration_blocker); error_free(hdev->migration_blocker); } g_free(hdev->mem); g_free(hdev->mem_sections); hdev->vhost_ops->vhost_backend_cleanup(hdev); }
1threat
Reading Input from file : <p>How would I read in input from a file and save it to an array? For example the file contains:</p> <p>2</p> <p>1 1 2 3</p> <p>2 4 5</p> <p>Where the first number (2) represents the number of arrays need. The first number in the second line is the array ID followed by whatever should be in the array (1 2 3). Same for third line, so array 2 should contain 4 and 5.</p> <p>So the two arrays should be:</p> <p>array1: [1][2][3] array2: [4][5]</p> <p>Java please! thanks!</p>
0debug
static int ffm_read_data(AVFormatContext *s, uint8_t *buf, int size, int header) { FFMContext *ffm = s->priv_data; AVIOContext *pb = s->pb; int len, fill_size, size1, frame_offset, id; int64_t last_pos = -1; size1 = size; while (size > 0) { redo: len = ffm->packet_end - ffm->packet_ptr; if (len < 0) return -1; if (len > size) len = size; if (len == 0) { if (avio_tell(pb) == ffm->file_size) avio_seek(pb, ffm->packet_size, SEEK_SET); retry_read: if (pb->buffer_size != ffm->packet_size) { int64_t tell = avio_tell(pb); ffio_set_buf_size(pb, ffm->packet_size); avio_seek(pb, tell, SEEK_SET); } id = avio_rb16(pb); if (id != PACKET_ID) { if (ffm_resync(s, id) < 0) return -1; last_pos = avio_tell(pb); } fill_size = avio_rb16(pb); ffm->dts = avio_rb64(pb); frame_offset = avio_rb16(pb); avio_read(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE); ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size); if (ffm->packet_end < ffm->packet || frame_offset < 0) return -1; if (ffm->first_packet || (frame_offset & 0x8000)) { if (!frame_offset) { if (avio_tell(pb) >= ffm->packet_size * 3LL) { int64_t seekback = FFMIN(ffm->packet_size * 2LL, avio_tell(pb) - last_pos); seekback = FFMAX(seekback, 0); avio_seek(pb, -seekback, SEEK_CUR); goto retry_read; } return 0; } ffm->first_packet = 0; if ((frame_offset & 0x7fff) < FFM_HEADER_SIZE) return -1; ffm->packet_ptr = ffm->packet + (frame_offset & 0x7fff) - FFM_HEADER_SIZE; if (!header) break; } else { ffm->packet_ptr = ffm->packet; } goto redo; } memcpy(buf, ffm->packet_ptr, len); buf += len; ffm->packet_ptr += len; size -= len; header = 0; } return size1 - size; }
1threat
static void omap_mpu_timer_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque; if (size != 4) { return omap_badwidth_write32(opaque, addr, value); } switch (addr) { case 0x00: omap_timer_sync(s); s->enable = (value >> 5) & 1; s->ptv = (value >> 2) & 7; s->ar = (value >> 1) & 1; s->st = value & 1; omap_timer_update(s); return; case 0x04: s->reset_val = value; return; case 0x08: OMAP_RO_REG(addr); break; default: OMAP_BAD_REG(addr); } }
1threat
android - ListView.setAdapter error: java.lang.NullPointerException : <p>I am getting error "java.lang.NullPointerException" by setting my adapter in ListFragment activity.</p> <p>Here is my code:</p> <pre><code>private List&lt;Music&gt; musicList; public View inflate; ListView searchList; public class SearchFragment extends ListFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getActivity().getApplicationContext(); inflate = inflater.inflate(R.layout.search, container, false); musicList = new ArrayList&lt;Music&gt;(); adapter = new CustomListAdapter(musicList, context); searchList.setAdapter(adapter); } </code></pre> <p>I have a NullPointerException in the following code:</p> <p>The error is at <code>searchList.setAdapter(adapter);</code> so i also try to change to adapter value from <code>new ArrayList&lt;Music&gt;()</code> to <code>new &lt;Music&gt;ArrayList()</code> but no luck.</p> <p>My Music class looks like this:</p> <pre><code>public class Music { private String title, thumbnail, duration, uri, waveform; private int likes, playbackCount; public Music() { } public Music(String name, String thumbnailUrl, int likes, String rating, int playbackCount) { this.title = name; this.thumbnail = thumbnail; this.likes = likes; this.duration = rating; this.playbackCount = playbackCount; } public String getTitle() { return title; } public void setTitle(String name) { this.title = name; } public String getThumbnail() { return thumbnail; } public void setThumbnail(String thumbnail) { this.thumbnail = thumbnail; } public int getLikes() { return likes; } public void setLikes(int likes) { this.likes = likes; } public String getDuration() { return duration; } public void setDuration(String duration) { this.duration = duration; } public int getPlayBackCount() { return playbackCount; } public void setPlayBackCount(int playbackCount) { this.playbackCount = playbackCount; } public String getUri() { return uri; } public void setUri(String uri) { this.uri = uri; } public String getWaveform() { return waveform; } public void setWaveform(String waveform) { this.waveform = waveform; } } </code></pre>
0debug
static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int type, int length) { int buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1; char *buf = av_malloc(buf_size); if (!buf) return; if (type == 0 && length == 4) { snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb)); } else if (type == 1) { avio_get_str16le(pb, length, buf, buf_size); if (!strlen(buf)) { av_free(buf); return; } } else if (type == 3 && length == 4) { strcpy(buf, avio_rl32(pb) ? "true" : "false"); } else if (type == 4 && length == 8) { int64_t num = avio_rl64(pb); if (!strcmp(key, "WM/EncodingTime") || !strcmp(key, "WM/MediaOriginalBroadcastDateTime")) filetime_to_iso8601(buf, buf_size, num); else if (!strcmp(key, "WM/WMRVEncodeTime") || !strcmp(key, "WM/WMRVEndTime")) crazytime_to_iso8601(buf, buf_size, num); else if (!strcmp(key, "WM/WMRVExpirationDate")) oledate_to_iso8601(buf, buf_size, num); else if (!strcmp(key, "WM/WMRVBitrate")) snprintf(buf, buf_size, "%f", av_int2dbl(num)); else snprintf(buf, buf_size, "%"PRIi64, num); } else if (type == 5 && length == 2) { snprintf(buf, buf_size, "%"PRIi16, avio_rl16(pb)); } else if (type == 6 && length == 16) { ff_asf_guid guid; avio_read(pb, guid, 16); snprintf(buf, buf_size, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid)); } else if (type == 2 && !strcmp(key, "WM/Picture")) { get_attachment(s, pb, length); av_freep(&buf); return; } else { av_freep(&buf); av_log(s, AV_LOG_WARNING, "unsupported metadata entry; key:%s, type:%d, length:0x%x\n", key, type, length); avio_skip(pb, length); return; } av_metadata_set2(&s->metadata, key, buf, 0); av_freep(&buf); }
1threat
How to remove div in cross site div? : <p>I have an iframe youtube video, where i want to remove an div element. I can do it in in the console as long I manually folded out the div which I am looking for, but otherwise i am not able to find it using <code>document.getElementByClassName()</code>..</p> <p>Is it possible via js to somehow remove an div which resides inside #document?</p>
0debug
static void paio_cancel(BlockDriverAIOCB *blockacb) { struct qemu_paiocb *acb = (struct qemu_paiocb *)blockacb; int active = 0; mutex_lock(&lock); if (!acb->active) { TAILQ_REMOVE(&request_list, acb, node); acb->ret = -ECANCELED; } else if (acb->ret == -EINPROGRESS) { active = 1; } mutex_unlock(&lock); if (active) { while (qemu_paio_error(acb) == EINPROGRESS) ; } paio_remove(acb); }
1threat
How to use echo with PHP's array_reverse() Function : <p>I'm not a big fan of using print_r and I prefer to use echo all the time when I can so how can I use echo with PHPs array_reverse() function </p> <p>This how the docs look like most of the time online they use print_r all the time for example</p> <pre><code>&lt;?php $a=array("a"=&gt;"Volvo","b"=&gt;"BMW","c"=&gt;"Toyota"); print_r(array_reverse($a)); ?&gt; </code></pre> <p>I tried to use echo with this example but it does not work with echo.</p> <pre><code>&lt;?php $a=array("a"=&gt;"Volvo","b"=&gt;"BMW","c"=&gt;"Toyota"); echo array_reverse($a); ?&gt; </code></pre> <p>So how can I get it to work with echo?</p>
0debug
Does we need to change anything in usual webpage loader for loading an AMP (accelerate mobile page) webpage in Android? : This is my code. import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class Main extends Activity { private WebView mWebview; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mWebview = new WebView(this); mWebview.loadUrl("https://ampbyexample.com/"); setContentView(mWebview); } } But, it doesn't load an AMP webpage as fast as it usually did. It's load like an usual webpage. Is there need any change in this code.
0debug
static void avc_biwgt_16width_msa(uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height, int32_t log2_denom, int32_t src_weight, int32_t dst_weight, int32_t offset_in) { uint8_t cnt; v16i8 src_wgt, dst_wgt, wgt; v16i8 src0, src1, src2, src3; v16i8 dst0, dst1, dst2, dst3; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v8i16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; v8i16 denom, offset, add_val; int32_t val = 128 * (src_weight + dst_weight); offset_in = ((offset_in + 1) | 1) << log2_denom; src_wgt = __msa_fill_b(src_weight); dst_wgt = __msa_fill_b(dst_weight); offset = __msa_fill_h(offset_in); denom = __msa_fill_h(log2_denom + 1); add_val = __msa_fill_h(val); offset += add_val; wgt = __msa_ilvev_b(dst_wgt, src_wgt); for (cnt = height / 4; cnt--;) { LOAD_4VECS_SB(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); LOAD_4VECS_SB(dst, dst_stride, dst0, dst1, dst2, dst3); XORI_B_4VECS_SB(src0, src1, src2, src3, src0, src1, src2, src3, 128); XORI_B_4VECS_SB(dst0, dst1, dst2, dst3, dst0, dst1, dst2, dst3, 128); ILV_B_LRLR_SB(src0, dst0, src1, dst1, vec1, vec0, vec3, vec2); ILV_B_LRLR_SB(src2, dst2, src3, dst3, vec5, vec4, vec7, vec6); temp0 = __msa_dpadd_s_h(offset, wgt, vec0); temp1 = __msa_dpadd_s_h(offset, wgt, vec1); temp2 = __msa_dpadd_s_h(offset, wgt, vec2); temp3 = __msa_dpadd_s_h(offset, wgt, vec3); temp4 = __msa_dpadd_s_h(offset, wgt, vec4); temp5 = __msa_dpadd_s_h(offset, wgt, vec5); temp6 = __msa_dpadd_s_h(offset, wgt, vec6); temp7 = __msa_dpadd_s_h(offset, wgt, vec7); SRA_4VECS(temp0, temp1, temp2, temp3, temp0, temp1, temp2, temp3, denom); SRA_4VECS(temp4, temp5, temp6, temp7, temp4, temp5, temp6, temp7, denom); temp0 = CLIP_UNSIGNED_CHAR_H(temp0); temp1 = CLIP_UNSIGNED_CHAR_H(temp1); temp2 = CLIP_UNSIGNED_CHAR_H(temp2); temp3 = CLIP_UNSIGNED_CHAR_H(temp3); temp4 = CLIP_UNSIGNED_CHAR_H(temp4); temp5 = CLIP_UNSIGNED_CHAR_H(temp5); temp6 = CLIP_UNSIGNED_CHAR_H(temp6); temp7 = CLIP_UNSIGNED_CHAR_H(temp7); PCKEV_B_4VECS_SB(temp1, temp3, temp5, temp7, temp0, temp2, temp4, temp6, dst0, dst1, dst2, dst3); STORE_4VECS_SB(dst, dst_stride, dst0, dst1, dst2, dst3); dst += 4 * dst_stride; } }
1threat
alert('Hello ' + user_input);
1threat
static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write) { AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); IDEState *s = &ad->port.ifs[0]; ahci_populate_sglist(ad, &s->sg); s->io_buffer_size = s->sg.size; DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size); return s->io_buffer_size != 0; }
1threat
static void rtas_get_xive(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { struct ics_state *ics = spapr->icp->ics; uint32_t nr; if ((nargs != 1) || (nret != 3)) { rtas_st(rets, 0, -3); return; } nr = rtas_ld(args, 0); if (!ics_valid_irq(ics, nr)) { rtas_st(rets, 0, -3); return; } rtas_st(rets, 0, 0); rtas_st(rets, 1, ics->irqs[nr - ics->offset].server); rtas_st(rets, 2, ics->irqs[nr - ics->offset].priority); }
1threat
Why does it show value 5150 and not 155? : <p>So im quite new to javascript and i tried making something simple as entering a value and add 150 to it but it wont show number + 150? Pictures below</p> <p><a href="https://i.stack.imgur.com/XjPJr.png" rel="nofollow noreferrer">Code</a></p> <p><a href="https://i.stack.imgur.com/IcxER.png" rel="nofollow noreferrer">Output</a></p>
0debug
static void init_ppc_proc (CPUPPCState *env, ppc_def_t *def) { env->reserve = -1; env->nb_BATs = -1; env->nb_tlb = 0; env->nb_ways = 0; spr_register(env, SPR_PVR, "PVR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, def->pvr); printf("%s: PVR %08x mask %08x => %08x\n", __func__, def->pvr, def->pvr_mask, def->pvr & def->pvr_mask); switch (def->pvr) { case CPU_PPC_401A1: case CPU_PPC_401B2: case CPU_PPC_401C2: case CPU_PPC_401D2: case CPU_PPC_401E2: case CPU_PPC_401F2: case CPU_PPC_401G2: case CPU_PPC_IOP480: case CPU_PPC_COBRA: gen_spr_generic(env); gen_spr_40x(env); gen_spr_401_403(env); #if defined (TODO) gen_spr_compress(env); #endif env->nb_BATs = 0; env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; break; case CPU_PPC_403GA: case CPU_PPC_403GB: case CPU_PPC_403GC: case CPU_PPC_403GCX: gen_spr_generic(env); gen_spr_40x(env); gen_spr_401_403(env); gen_spr_403(env); env->nb_BATs = 0; env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; break; case CPU_PPC_405CR: case CPU_PPC_405EP: case CPU_PPC_405GPR: case CPU_PPC_405D2: case CPU_PPC_405D4: gen_spr_generic(env); gen_tbl(env); gen_spr_40x(env); gen_spr_405(env); env->nb_BATs = 0; env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; ppc405_irq_init(env); break; case CPU_PPC_NPE405H: case CPU_PPC_NPE405H2: case CPU_PPC_NPE405L: gen_spr_generic(env); gen_tbl(env); gen_spr_40x(env); gen_spr_405(env); env->nb_BATs = 0; env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; ppc405_irq_init(env); break; #if defined (TODO) case CPU_PPC_STB01000: #endif #if defined (TODO) case CPU_PPC_STB01010: #endif #if defined (TODO) case CPU_PPC_STB0210: #endif case CPU_PPC_STB03: #if defined (TODO) case CPU_PPC_STB043: #endif #if defined (TODO) case CPU_PPC_STB045: #endif case CPU_PPC_STB25: #if defined (TODO) case CPU_PPC_STB130: #endif gen_spr_generic(env); gen_tbl(env); gen_spr_40x(env); gen_spr_405(env); env->nb_BATs = 0; env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; ppc405_irq_init(env); break; case CPU_PPC_440EP: case CPU_PPC_440GP: case CPU_PPC_440GX: case CPU_PPC_440GXc: case CPU_PPC_440GXf: case CPU_PPC_440SP: case CPU_PPC_440SP2: case CPU_PPC_440SPE: gen_spr_generic(env); gen_tbl(env); gen_spr_BookE(env); gen_spr_440(env); env->nb_BATs = 0; env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; break; #if defined (TODO) case CPU_PPC_5xx: break; #endif #if defined (TODO) case CPU_PPC_8xx: break; #endif #if defined (TODO) case CPU_PPC_82xx_HIP3: case CPU_PPC_82xx_HIP4: break; #endif #if defined (TODO) case CPU_PPC_827x: break; #endif case CPU_PPC_e500v110: case CPU_PPC_e500v120: case CPU_PPC_e500v210: case CPU_PPC_e500v220: gen_spr_generic(env); gen_tbl(env); gen_spr_BookE(env); gen_spr_BookE_FSL(env); env->nb_BATs = 0; env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; break; #if defined (TODO) case CPU_PPC_e600: break; #endif case CPU_PPC_601: gen_spr_generic(env); gen_spr_ne_601(env); gen_spr_601(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_601_HID2, "HID2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_601_HID5, "HID5", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); #if 0 spr_register(env, SPR_601_HID15, "HID15", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); #endif env->nb_tlb = 64; env->nb_ways = 2; env->id_tlbs = 0; env->id_tlbs = 0; break; case CPU_PPC_602: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_tbl(env); gen_6xx_7xx_soft_tlb(env, 64, 2); gen_spr_602(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc6xx_irq_init(env); break; case CPU_PPC_603: case CPU_PPC_603E: case CPU_PPC_603E7v: case CPU_PPC_603E7v2: case CPU_PPC_603P: case CPU_PPC_603R: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_tbl(env); gen_6xx_7xx_soft_tlb(env, 64, 2); gen_spr_603(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc6xx_irq_init(env); break; case CPU_PPC_G2: case CPU_PPC_G2H4: case CPU_PPC_G2gp: case CPU_PPC_G2ls: case CPU_PPC_G2LE: case CPU_PPC_G2LEgp: case CPU_PPC_G2LEls: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_tbl(env); gen_high_BATs(env); gen_6xx_7xx_soft_tlb(env, 64, 2); gen_spr_G2_755(env); gen_spr_G2(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID2, "HID2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc6xx_irq_init(env); break; case CPU_PPC_604: case CPU_PPC_604E: case CPU_PPC_604R: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_tbl(env); gen_spr_604(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc6xx_irq_init(env); break; case CPU_PPC_74x: case CPU_PPC_740E: case CPU_PPC_750E: case CPU_PPC_74xP: case CPU_PPC_750CXE21: case CPU_PPC_750CXE22: case CPU_PPC_750CXE23: case CPU_PPC_750CXE24: case CPU_PPC_750CXE24b: case CPU_PPC_750CXE31: case CPU_PPC_750CXE31b: case CPU_PPC_750CXR: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_tbl(env); gen_spr_7xx(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc6xx_irq_init(env); break; case CPU_PPC_750FX10: case CPU_PPC_750FX20: case CPU_PPC_750FX21: case CPU_PPC_750FX22: case CPU_PPC_750FX23: case CPU_PPC_750GX10: case CPU_PPC_750GX11: case CPU_PPC_750GX12: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_high_BATs(env); gen_tbl(env); gen_spr_7xx(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_750_HID2, "HID2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc6xx_irq_init(env); break; case CPU_PPC_755_10: case CPU_PPC_755_11: case CPU_PPC_755_20: case CPU_PPC_755D: case CPU_PPC_755E: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_tbl(env); gen_high_BATs(env); gen_6xx_7xx_soft_tlb(env, 64, 2); gen_spr_G2_755(env); spr_register(env, SPR_ICTC, "ICTC", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_L2PM, "L2PM", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID2, "HID2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc6xx_irq_init(env); break; #if defined (TODO) case CPU_PPC_7400: case CPU_PPC_7410C: case CPU_PPC_7410D: case CPU_PPC_7410E: case CPU_PPC_7441: case CPU_PPC_7445: case CPU_PPC_7447: case CPU_PPC_7447A: case CPU_PPC_7448: case CPU_PPC_7450: case CPU_PPC_7450b: case CPU_PPC_7451: case CPU_PPC_7451G: case CPU_PPC_7455: case CPU_PPC_7455F: case CPU_PPC_7455G: case CPU_PPC_7457: case CPU_PPC_7457C: case CPU_PPC_7457A: break; #endif #if defined (TARGET_PPC64) #if defined (TODO) case CPU_PPC_620: case CPU_PPC_630: case CPU_PPC_631: case CPU_PPC_POWER4: case CPU_PPC_POWER4P: case CPU_PPC_POWER5: case CPU_PPC_POWER5P: #endif break; case CPU_PPC_970: case CPU_PPC_970FX10: case CPU_PPC_970FX20: case CPU_PPC_970FX21: case CPU_PPC_970FX30: case CPU_PPC_970FX31: case CPU_PPC_970MP10: case CPU_PPC_970MP11: gen_spr_generic(env); gen_spr_ne_601(env); gen_low_BATs(env); gen_tbl(env); gen_spr_7xx(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_750_HID2, "HID2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); ppc970_irq_init(env); break; #if defined (TODO) case CPU_PPC_CELL10: case CPU_PPC_CELL20: case CPU_PPC_CELL30: case CPU_PPC_CELL31: #endif break; #if defined (TODO) case CPU_PPC_RS64: case CPU_PPC_RS64II: case CPU_PPC_RS64III: case CPU_PPC_RS64IV: #endif break; #endif #if defined (TODO) case CPU_POWER: case CPU_POWER2: break; #endif default: gen_spr_generic(env); break; } if (env->nb_BATs == -1) env->nb_BATs = 4; if (env->nb_tlb != 0) { int nb_tlb = env->nb_tlb; if (env->id_tlbs != 0) nb_tlb *= 2; env->tlb = qemu_mallocz(nb_tlb * sizeof(ppc_tlb_t)); env->tlb_per_way = env->nb_tlb / env->nb_ways; } }
1threat
int av_grab(AVFormatContext *s) { UINT8 audio_buf[AUDIO_FIFO_SIZE]; UINT8 audio_buf1[AUDIO_FIFO_SIZE]; UINT8 audio_out[AUDIO_FIFO_SIZE]; UINT8 video_buffer[1024*1024]; char buf[256]; short *samples; URLContext *audio_handle = NULL, *video_handle = NULL; int ret; AVCodecContext *enc, *first_video_enc = NULL; int frame_size, frame_bytes; int use_audio, use_video; int frame_rate, sample_rate, channels; int width, height, frame_number, i, pix_fmt = 0; AVOutputStream *ost_table[s->nb_streams], *ost; UINT8 *picture_in_buf = NULL, *picture_420p = NULL; int audio_fifo_size = 0, picture_size = 0; INT64 time_start; for(i=0;i<s->nb_streams;i++) ost_table[i] = NULL; for(i=0;i<s->nb_streams;i++) { ost = av_mallocz(sizeof(AVOutputStream)); if (!ost) goto fail; ost->index = i; ost->st = s->streams[i]; ost_table[i] = ost; } use_audio = 0; use_video = 0; frame_rate = 0; sample_rate = 0; frame_size = 0; channels = 1; width = 0; height = 0; frame_number = 0; for(i=0;i<s->nb_streams;i++) { AVCodec *codec; ost = ost_table[i]; enc = &ost->st->codec; codec = avcodec_find_encoder(enc->codec_id); if (!codec) { fprintf(stderr, "Unknown codec\n"); return -1; } if (avcodec_open(enc, codec) < 0) { fprintf(stderr, "Incorrect encode parameters\n"); return -1; } switch(enc->codec_type) { case CODEC_TYPE_AUDIO: use_audio = 1; if (enc->sample_rate > sample_rate) sample_rate = enc->sample_rate; if (enc->frame_size > frame_size) frame_size = enc->frame_size; if (enc->channels > channels) channels = enc->channels; break; case CODEC_TYPE_VIDEO: if (!first_video_enc) first_video_enc = enc; use_video = 1; if (enc->frame_rate > frame_rate) frame_rate = enc->frame_rate; if (enc->width > width) width = enc->width; if (enc->height > height) height = enc->height; break; } } samples = NULL; if (use_audio) { snprintf(buf, sizeof(buf), "audio:%d,%d", sample_rate, channels); ret = url_open(&audio_handle, buf, URL_RDONLY); if (ret < 0) { fprintf(stderr, "Could not open audio device: disabling audio capture\n"); use_audio = 0; } else { URLFormat f; if (url_getformat(audio_handle, &f) < 0) { fprintf(stderr, "could not read back video grab parameters\n"); goto fail; } sample_rate = f.sample_rate; channels = f.channels; audio_fifo_size = ((AUDIO_FIFO_SIZE / 2) / audio_handle->packet_size) * audio_handle->packet_size; fprintf(stderr, "Audio sampling: %d Hz, %s\n", sample_rate, channels == 2 ? "stereo" : "mono"); } } if (use_video) { snprintf(buf, sizeof(buf), "video:%d,%d,%f", width, height, (float)frame_rate / FRAME_RATE_BASE); ret = url_open(&video_handle, buf, URL_RDONLY); if (ret < 0) { fprintf(stderr,"Could not init video 4 linux capture: disabling video capture\n"); use_video = 0; } else { URLFormat f; const char *pix_fmt_str; if (url_getformat(video_handle, &f) < 0) { fprintf(stderr, "could not read back video grab parameters\n"); goto fail; } width = f.width; height = f.height; pix_fmt = f.pix_fmt; switch(pix_fmt) { case PIX_FMT_YUV420P: pix_fmt_str = "420P"; break; case PIX_FMT_YUV422: pix_fmt_str = "422"; break; case PIX_FMT_RGB24: pix_fmt_str = "RGB24"; break; case PIX_FMT_BGR24: pix_fmt_str = "BGR24"; break; default: pix_fmt_str = "???"; break; } picture_size = video_handle->packet_size; picture_in_buf = malloc(picture_size); if (!picture_in_buf) goto fail; if (pix_fmt != PIX_FMT_YUV420P) { picture_420p = malloc((width * height * 3) / 2); } fprintf(stderr, "Video sampling: %dx%d, %s format, %0.2f fps\n", width, height, pix_fmt_str, (float)frame_rate / FRAME_RATE_BASE); } } if (!use_video && !use_audio) { fprintf(stderr,"Could not open grab devices : exiting\n"); exit(1); } for(i=0;i<s->nb_streams;i++) { ost = ost_table[i]; enc = &ost->st->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: ost->audio_resample = 0; if ((enc->channels != channels || enc->sample_rate != sample_rate)) { ost->audio_resample = 1; ost->resample = audio_resample_init(enc->channels, channels, enc->sample_rate, sample_rate); } if (fifo_init(&ost->fifo, (2 * audio_fifo_size * enc->sample_rate * enc->channels) / sample_rate)) goto fail; break; case CODEC_TYPE_VIDEO: ost->video_resample = 0; if (enc->width != width || enc->height != height) { UINT8 *buf; ost->video_resample = 1; buf = malloc((enc->width * enc->height * 3) / 2); if (!buf) goto fail; ost->pict_tmp.data[0] = buf; ost->pict_tmp.data[1] = buf + enc->width * height; ost->pict_tmp.data[2] = ost->pict_tmp.data[1] + (enc->width * height) / 4; ost->pict_tmp.linesize[0] = enc->width; ost->pict_tmp.linesize[1] = enc->width / 2; ost->pict_tmp.linesize[2] = enc->width / 2; ost->img_resample_ctx = img_resample_init( ost->st->codec.width, ost->st->codec.height, width, height); } } } fprintf(stderr, "Press [q] to stop encoding\n"); s->format->write_header(s); time_start = gettime(); term_init(); for(;;) { if (read_key() == 'q') break; if (use_audio) { int ret, nb_samples, nb_samples_out; UINT8 *buftmp; for(;;) { ret = url_read(audio_handle, audio_buf, audio_fifo_size); if (ret <= 0) break; nb_samples = ret / (channels * 2); for(i=0;i<s->nb_streams;i++) { ost = ost_table[i]; enc = &ost->st->codec; if (enc->codec_type == CODEC_TYPE_AUDIO) { if (!ost->audio_resample) { buftmp = audio_buf; nb_samples_out = nb_samples; } else { buftmp = audio_buf1; nb_samples_out = audio_resample(ost->resample, (short *)buftmp, (short *)audio_buf, nb_samples); } fifo_write(&ost->fifo, buftmp, nb_samples_out * enc->channels * 2, &ost->fifo.wptr); } } for(i=0;i<s->nb_streams;i++) { ost = ost_table[i]; enc = &ost->st->codec; if (enc->codec_type == CODEC_TYPE_AUDIO) { frame_bytes = enc->frame_size * 2 * enc->channels; while (fifo_read(&ost->fifo, audio_buf, frame_bytes, &ost->fifo.rptr) == 0) { ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out), (short *)audio_buf); s->format->write_packet(s, ost->index, audio_out, ret); } } } } } if (use_video) { AVPicture *picture1, *picture2, *picture; AVPicture picture_tmp0, picture_tmp1; ret = url_read(video_handle, picture_in_buf, picture_size); if (ret < 0) break; picture2 = &picture_tmp0; avpicture_fill(picture2, picture_in_buf, pix_fmt, width, height); if (pix_fmt != PIX_FMT_YUV420P) { picture = &picture_tmp1; avpicture_fill(picture, picture_420p, PIX_FMT_YUV420P, width, height); img_convert(picture, PIX_FMT_YUV420P, picture2, pix_fmt, width, height); } else { picture = picture2; } for(i=0;i<s->nb_streams;i++) { ost = ost_table[i]; enc = &ost->st->codec; if (enc->codec_type == CODEC_TYPE_VIDEO) { int n1, n2, nb; n1 = ((INT64)frame_number * enc->frame_rate) / frame_rate; n2 = (((INT64)frame_number + 1) * enc->frame_rate) / frame_rate; nb = n2 - n1; if (nb > 0) { if (ost->video_resample) { picture1 = &ost->pict_tmp; img_resample(ost->img_resample_ctx, picture1, picture); } else { picture1 = picture; } ret = avcodec_encode_video(enc, video_buffer, sizeof(video_buffer), picture1); s->format->write_packet(s, ost->index, video_buffer, ret); } } } frame_number++; } { char buf[1024]; INT64 total_size; float ti, bitrate; static float last_ti; INT64 ti1; total_size = url_ftell(&s->pb); ti1 = gettime() - time_start; if (recording_time && ti1 >= recording_time) break; ti = ti1 / 1000000.0; if (ti < 0.1) ti = 0.1; if ((ti - last_ti) >= 0.5) { last_ti = ti; bitrate = (int)((total_size * 8) / ti / 1000.0); buf[0] = '\0'; if (use_video) { sprintf(buf + strlen(buf), "frame=%5d fps=%4.1f q=%2d ", frame_number, (float)frame_number / ti, first_video_enc->quality); } sprintf(buf + strlen(buf), "size=%8LdkB time=%0.1f bitrate=%6.1fkbits/s", total_size / 1024, ti, bitrate); fprintf(stderr, "%s \r", buf); fflush(stderr); } } } term_exit(); for(i=0;i<s->nb_streams;i++) { ost = ost_table[i]; enc = &ost->st->codec; avcodec_close(enc); } s->format->write_trailer(s); if (audio_handle) url_close(audio_handle); if (video_handle) url_close(video_handle); { float ti, bitrate; INT64 total_size; total_size = url_ftell(&s->pb); ti = (gettime() - time_start) / 1000000.0; if (ti < 0.1) ti = 0.1; bitrate = (int)((total_size * 8) / ti / 1000.0); fprintf(stderr, "\033[K\nTotal time = %0.1f s, %Ld KBytes, %0.1f kbits/s\n", ti, total_size / 1024, bitrate); if (use_video) { fprintf(stderr, "Total frames = %d\n", frame_number); } } ret = 0; fail1: if (picture_in_buf) free(picture_in_buf); if (picture_420p) free(picture_420p); for(i=0;i<s->nb_streams;i++) { ost = ost_table[i]; if (ost) { if (ost->fifo.buffer) fifo_free(&ost->fifo); if (ost->pict_tmp.data[0]) free(ost->pict_tmp.data[0]); if (ost->video_resample) img_resample_close(ost->img_resample_ctx); if (ost->audio_resample) audio_resample_close(ost->resample); free(ost); } } return ret; fail: ret = -ENOMEM; goto fail1; }
1threat
i got this error plz help Program type already present: android.support.v4.app.LoaderManager : When i am running my android app on my app the compiler gives this all error i got this error plz help Program type already present: android.support.v4.app.LoaderManager java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\xxx\xxx\app\build\intermediates\transforms\dexBuilder\debug\1.jar, com.android.tools.r8.CompilationFailedException: Compilation failed to complete com.android.tools.r8.utils.AbortException
0debug
python build-in method next act strange : [enter image description here][1] [1]: https://i.stack.imgur.com/0YdGV.png When I use a imported package, I use an object that it give to me. I found it have next method so I just try use next() build-in function to generate next item of it,but something is wrong. And i wonder what is the built-in method of an Object, I never see it before. And i am using python 2.7.12 Thank you!
0debug