problem
stringlengths
26
131k
labels
class label
2 classes
How to change Android talkback instructions for double tap and long press : <p>I have a view that has a long press action handler. I use the content description to set the message Talkback speaks when the view gets focus.</p> <p>Currently it says my content description right after getting a focus, and after a short pause says:</p> <blockquote> <p>Double tap to activate, double tap and hold for long press</p> </blockquote> <p>I want to change this message into something like</p> <blockquote> <p>Double tap to <strong>"action 1"</strong>, double tap and hold for <strong>"action 2"</strong></p> </blockquote> <p>Is there a way to do so?</p> <p>I looked into <code>onPopulateAccessibilityEvent()</code>, it gets <code>TYPE_VIEW_ACCESSIBILITY_FOCUSED</code> event, but I wasn't able to change the desired message. </p> <p>Am I missing something simple?</p>
0debug
static void put_int32(QEMUFile *f, void *pv, size_t size) { int32_t *v = pv; qemu_put_sbe32s(f, v); }
1threat
Ignore [JsonIgnore] Attribute on Serialization / Deserialization : <p>Is there a way I can ignore Json.NET's <code>[JsonIgnore]</code> attribute on a class that I don't have permission to modify/extend?</p> <pre><code>public sealed class CannotModify { public int Keep { get; set; } // I want to ignore this attribute (and acknowledge the property) [JsonIgnore] public int Ignore { get; set; } } </code></pre> <p>I need all properties in this class to be serialized/deserialized. I've tried subclassing Json.NET's <code>DefaultContractResolver</code> class and overriding what looks to be the relevant method:</p> <pre><code>public class JsonIgnoreAttributeIgnorerContractResolver : DefaultContractResolver { protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) { JsonProperty property = base.CreateProperty(member, memberSerialization); // Serialize all the properties property.ShouldSerialize = _ =&gt; true; return property; } } </code></pre> <p>but the attribute on the original class seems to always win:</p> <pre><code>public static void Serialize() { string serialized = JsonConvert.SerializeObject( new CannotModify { Keep = 1, Ignore = 2 }, new JsonSerializerSettings { ContractResolver = new JsonIgnoreAttributeIgnorerContractResolver() }); // Actual: {"Keep":1} // Desired: {"Keep":1,"Ignore":2} } </code></pre> <p>I dug deeper, and found an interface called <code>IAttributeProvider</code> that can be set (it had a value of "Ignore" for the <code>Ignore</code> property, so that was a clue this might be something that needs changing):</p> <pre><code>... property.ShouldSerialize = _ =&gt; true; property.AttributeProvider = new IgnoreAllAttributesProvider(); ... public class IgnoreAllAttributesProvider : IAttributeProvider { public IList&lt;Attribute&gt; GetAttributes(bool inherit) { throw new NotImplementedException(); } public IList&lt;Attribute&gt; GetAttributes(Type attributeType, bool inherit) { throw new NotImplementedException(); } } </code></pre> <p>But the code isn't ever hit.</p>
0debug
How to make a program to print the series : 1,12,123...12345678910,1234567891011...& so on to the nth term in java(Bluej)? : //I tried this one but output was wrong for tenth term import java.io.*; public class series { public static void main(String args[])throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n,i,i1=0,s=0,c=0; System.out.println("Enter the term of the series you want to get"); n=Integer.parseInt(in.readLine()); for (i=1;i<=n;i++) { i1=i; while (i1!=0) { c+=1; i1=i1/10; } s=(int)(s*(Math.pow(10,c))+i); c=0; System.out.print(s+" "); } } }
0debug
In perl why split is breaking at pipe(|) . : In perl why split is breaking at pipe(|) . I have string to be split at (")a my @temp1=split(/\"/,$line); but this will break at pipe(|) as well. like for input my_string|is"_ok the output is mystring , is, and _ok. Why ? Why its not mystring|, is and _ok.
0debug
Why am I getting a segmentation fault in c? : I am getting segmentation error when trying to do the CS50 Crack cryptography problem. I am a novice in C language. The code compiles Ok but when I run the debugger it seems to get the following error: Process received SIGSEGV: Segmentation fault ...at guess[0] = *alphabet1; I have looked at other stack overflow questions and suspect it could have something to do with string guess being a string literal but this has has muddied the waters for me. Can you please explain me why I am getting segmentation error or direct me to a good webpage to research this. The pertinant code is below. Thanks in advance for any help. string guess= " "; string hashed_word= " "; string letters= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; string letters1= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *alphabet; char *alphabet1; //check a-Z for (int j = 0; j < 52; j++) { alphabet1 = &letters1[j]; guess[0] = *alphabet1; hashed_word = guess; if (strcmp(hashed_word, s) == 0) { print(guess); } }
0debug
Why we cannot inherit a class with the private constructor in Java? : <p>Why we cannot inherit a class with the private constructor in Java? Can anyone explain with simple example?</p>
0debug
How to debug a g++ segmentation fault using gdb? : <p>I got a segfault when running my program. Then I googled my question and tried to follow steps from <a href="https://www.gnu.org/software/gcc/bugs/segfault.html" rel="nofollow noreferrer">https://www.gnu.org/software/gcc/bugs/segfault.html</a>.</p> <p>I did not configure GCC with <code>--enable-checking</code> then my first question is - </p> <p>1) is it necessary to configure it and compile with <code>-v -da -Q</code> ?</p> <p>But I always do compile with flags such as <code>-g -o0</code>. After running the program in GDB with arguments I get this:</p> <p><a href="https://i.stack.imgur.com/EMdFw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EMdFw.png" alt="gdb_screenshot"></a></p> <p>2) I can not print variables after segfault, is it okay ?</p> <p>3) How to figure out the line of my source code where segfault happens ?</p>
0debug
Elasticsearch: Return only nested inner_hits : <p>I have the following query:</p> <pre><code>GET /networkcollection/branch_routers/_search/ { "query": { "nested": { "path": "queries", "query": { "bool": { "must": [ { "match": { "queries.dateQuery": "20160101T200000.000Z" } } ] } }, "inner_hits" : {} } } } </code></pre> <p>This returns both the "hits" object (the entire document), as well as the "inner_hits" object (nested inside of hits).</p> <p>Is there a way to for me to only return the matched "queries" element(s) which appear in the "inner_hits" results, without getting the whole document?</p>
0debug
MATLAB: Replace a row/column in a cell array with NaN : <p>How am I supposed to replace a complete row/column within a cell array with NaNs?</p> <pre><code>test = cell(3,2); % These calls won't do it test{2,:} = nan; test(2,:) = nan; </code></pre>
0debug
Laravel - where less/greater than date syntax : <p>This is not showing the correct count. What is the correct syntax ?</p> <pre><code>$this-&gt;data['Tasks'] = \DB::table('tb_tasks')-&gt;where('Status', 'like', 'Open%')-&gt;whereDate('DeadLine', '&gt;', 'CURDATE()')-&gt;count(); </code></pre>
0debug
VBA drag down formula : Hi friend i have apply formula in S column (=concatenate(p1,q2,r3) this formula has to copy down till A column end ` ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-3],RC[-2],RC[-1])"` `Range("S1").Select` `Selection.copy` `Range("S:S").Select` `ActiveSheet.Paste` `Application.CutCopyMode = False`
0debug
Git reset single file in feature branch to be the same as in master : <p>I'm trying to revert my changes in a <strong>single file</strong> in my feature branch and I want this file to be the same as in master.</p> <p>I tried:</p> <pre><code>git checkout -- filename git checkout filename git checkout HEAD -- filename </code></pre> <p>It seems that none of these made any changes to my feature branch. Any suggestions? </p>
0debug
Begginer in Java - I can't print on the same line (I'm not using println) : This seems to be a common question but I couldn't find the solution to my problem. I started learning Java very recently so I barely know the basic. My professor gave an assignement where I have to write my name using asterisks. I did that using only one 'System.out.print' and it's very disorganized and confusing. So I tried this: public class teste2 { public static void main (String[] args) { String BR = "***** ***** \n* * * *\n* * * *\n***** ***** \n* * * *\n* * * *\n****** "; String U = "* *\n* *\n* *\n* *\n* *\n* *\n*******"; System.out.print (BR + U); } It works but they are in different lines, and I need it to be in just 1 line. What am I doing wrong?
0debug
Automatically run javascript function : <p>I have an html file on my desktop that looks like this:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; function sendCalls(){ //Network calls } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>(I replaced my network calls with //Network calls) I want the sendCalls function to automatically get called everday. This their a way to do this without deploying it to a server? Thanks.</p>
0debug
How I can give access for everyone around the world to my spring boot app that started on my computer? : <p>I started my spring boot app on my computer, and now I can easily make Http requests to <code>http://localhost:8080/</code>. How I can give access to everyone around the world to make Http requests to my app without deploying this app anywhere? </p>
0debug
static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags) { uint64_t reqid = request_id++; int ret = bdrv_co_pwrite_zeroes(bs->file, offset, count, flags); block_request_create(reqid, bs, qemu_coroutine_self()); qemu_coroutine_yield(); return ret; }
1threat
const char *error_get_pretty(Error *err) { return err->msg; }
1threat
I studied strucure is C good enough. But What type of strucuure it is? : How to read this structure and what it represents. First squire bracket [last_ds_type] showing array of structure. What about inner square bracket like [ds_1307]? What is dot (.) in .nvram_offset and .nvram_size? static struct chip_desc chips[last_ds_type] = { [ds_1307] = { .nvram_offset = 8, .nvram_size = 56, }, [ds_1308] = { .nvram_offset = 8, .nvram_size = 56, }, [ds_1337] = { .alarm = 1, .century_reg = DS1307_REG_MONTH, .century_bit = DS1337_BIT_CENTURY, }, [ds_1338] = { .nvram_offset = 8, .nvram_size = 56, }, [ds_1339] = { .alarm = 1, .century_reg = DS1307_REG_MONTH, .century_bit = DS1337_BIT_CENTURY, .trickle_charger_reg = 0x10, .do_trickle_setup = &do_trickle_setup_ds1339, }, [ds_1340] = { .century_reg = DS1307_REG_HOUR, .century_enable_bit = DS1340_BIT_CENTURY_EN, .century_bit = DS1340_BIT_CENTURY, .trickle_charger_reg = 0x08, }, [ds_1388] = { .trickle_charger_reg = 0x0a, }, [ds_3231] = { .alarm = 1, .century_reg = DS1307_REG_MONTH, .century_bit = DS1337_BIT_CENTURY, }, [rx_8130] = { .alarm = 1, /* this is battery backed SRAM */ .nvram_offset = 0x20, .nvram_size = 4, /* 32bit (4 word x 8 bit) */ }, [mcp794xx] = { .alarm = 1, /* this is battery backed SRAM */ .nvram_offset = 0x20, .nvram_size = 0x40, }, }; [1]: http://elixir.free-electrons.com/linux/latest/source/drivers/rtc/rtc-ds1307.c#L151
0debug
static void unix_process_msgfd(CharDriverState *chr, struct msghdr *msg) { TCPCharDriver *s = chr->opaque; struct cmsghdr *cmsg; for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { int fd; if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) continue; fd = *((int *)CMSG_DATA(cmsg)); if (fd < 0) continue; #ifndef MSG_CMSG_CLOEXEC qemu_set_cloexec(fd); #endif if (s->msgfd != -1) close(s->msgfd); s->msgfd = fd; } }
1threat
How to show distinct sender id from conversation PHP MYSQL : I was trying to print only unique/ distinct sender name in my conversation list. Here is my current code $sql = "SELECT a.name, b.id, b.byuid, b.unread, b.starred FROM all_users_table a INNER JOIN private_messages b ON a.id = b.byuid WHERE b.touid='".$myid."' AND starred='0' ORDER BY b.timesent DESC, b.unread LIMIT $limit_start, $items_per_page "; This currently printing user1 user1 user1 user2 user2 user3 What I wanted to print >user1 >user2 >user3 Is it possible? I tried with Group By buyuid but it returns random user NOT order by timesent / unread one first. How can I solve this ?!
0debug
Read json file and get output values using python : i want to fetch the output of below json file using python Json file <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> { "Name": [ { "name": "John", "Avg": "55.7" }, { "name": "Rose", "Avg": "71.23" }, { "name": "Lola", "Avg": "78.93" }, { "name": "Harry", "Avg": "95.5" } ] } <!-- end snippet --> I want to get the average marks of the person, when i look for harry i.e i need output in below or similar format Harry = 95.5
0debug
static uint64_t mv88w8618_wlan_read(void *opaque, target_phys_addr_t offset, unsigned size) { switch (offset) { case MP_WLAN_MAGIC1: return ~3; case MP_WLAN_MAGIC2: return -1; default: return 0; } }
1threat
static int ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data) { AC3EncodeContext *s = avctx->priv_data; const int16_t *samples = data; int16_t planar_samples[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE+AC3_FRAME_SIZE]; int32_t mdct_coef[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; uint8_t exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; uint8_t num_exp_groups[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; uint8_t grouped_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_EXP_GROUPS]; uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; int8_t exp_shift[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; uint16_t qmant[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; int frame_bits; if (s->bit_alloc.sr_code == 1) adjust_frame_size(s); deinterleave_input_samples(s, samples, planar_samples); apply_mdct(s, planar_samples, exp_shift, mdct_coef); frame_bits = process_exponents(s, mdct_coef, exp_shift, exp, exp_strategy, encoded_exp, num_exp_groups, grouped_exp); compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits); quantize_mantissas(s, mdct_coef, exp_shift, encoded_exp, bap, qmant); output_frame(s, frame, exp_strategy, num_exp_groups, grouped_exp, bap, qmant); return s->frame_size; }
1threat
int pp_check(int key, int pp, int nx) { int access; access = 0; if (key == 0) { switch (pp) { case 0x0: case 0x1: case 0x2: access |= PAGE_WRITE; case 0x3: case 0x6: access |= PAGE_READ; break; } } else { switch (pp) { case 0x0: case 0x6: access = 0; break; case 0x1: case 0x3: access = PAGE_READ; break; case 0x2: access = PAGE_READ | PAGE_WRITE; break; } } if (nx == 0) { access |= PAGE_EXEC; } return access; }
1threat
php: i want to trim "h;" from "w;h;" to get ''w;' but what I got is "w" : The below program is to right trim the string "w;h;" off string "h;" to get "w;". But unexpectedly what I got is "w", not "w;". <?php $string="w;h;"; $str="h;"; $nStr=rtrim($string,$str); echo $nStr.'</br>'; ?>
0debug
Invalid declaration of a python list : <p>I am trying to declare a simple list (myList) in python 3 and convert it to an array (myArray), but I get a syntax error. I tried several changes, but I cannot get it to work. Here is the code.</p> <pre><code>import numpy as np var myList = [1,2,3,4]; File "&lt;ipython-input-17-381fa36e2cfd&gt;", line 1 var myList = [1,2,3,4] ^ SyntaxError: invalid syntax var myArray = np.array(myList); File "&lt;ipython-input-18-15c82c3a3cf5&gt;", line 1 var myArray = np.array(myList); ^ SyntaxError: invalid syntax </code></pre>
0debug
Android studio preview window for xml files : <p>Is the preview of xml file is removed from Android studio 3.0.1 latest version if no then how to enable it</p> <p>.</p>
0debug
static inline void gen_neon_narrow_satu(int size, TCGv dest, TCGv src) { switch (size) { case 0: gen_helper_neon_narrow_sat_u8(dest, cpu_env, src); break; case 1: gen_helper_neon_narrow_sat_u16(dest, cpu_env, src); break; case 2: gen_helper_neon_narrow_sat_u32(dest, cpu_env, src); break; default: abort(); } }
1threat
Search for the most similar string python : Im doing a kind of a chatbot in python for a school project, its a simple one I ask a question and it searches a txt file with all the questions and answers that he has and then it gives and answer. What I want to do is know how it can search for the most similar question in the database.
0debug
com.apple.CoreData.SQLDebug not working : <p>I'm working with Xcode 8 with swift on MacOS Sierra in an iOS app. I realized a few months ago that the SQLDebug stops working... (It used to worked in my app)...</p> <p>I have created a new empty project with the coredata flag enabled..Then I created an entity with attributes and I executed this func in the ViewDidLoad and Xcode is NOT logging the sql</p> <pre><code>func fetchAllData(){ //1 delegate let appDelegate = UIApplication.shared.delegate as! AppDelegate let managedContext = appDelegate.persistentContainer.viewContext //2 prepare fetch request let fetchRequest: NSFetchRequest&lt;NSFetchRequestResult&gt; = NSFetchRequest(entityName:"Entrenamientos") //3 make fetch do{ let fetchedResults = try managedContext.fetch(fetchRequest) as! [NSManagedObject] } catch{ } } </code></pre>
0debug
How to escape "\" in exec.Command in Golang? : <p>I want to execute </p> <pre><code>cat database_dump_1.sql | docker exec -i my_postgres psql -U postgres </code></pre> <p>using exec.Command method of Golang.</p> <p>My code goes like this :</p> <pre><code>options := []string{"out.sql", "|", "docker", "exec", "-i", "my_postgres", "psql", "-U", "postgres"} cmd, err := exec.Command("cat", options...).Output() if err != nil { panic(err) } fmt.Println(string(cmd)) </code></pre> <p>but this fails. I guess I am not able to escape "|". I have tried "\|", but this also fails. What am I doing wrong??</p>
0debug
static int get_cluster_offset(BlockDriverState *bs, VmdkExtent *extent, VmdkMetaData *m_data, uint64_t offset, int allocate, uint64_t *cluster_offset) { unsigned int l1_index, l2_offset, l2_index; int min_index, i, j; uint32_t min_count, *l2_table; bool zeroed = false; if (m_data) { m_data->valid = 0; } if (extent->flat) { *cluster_offset = extent->flat_start_offset; return VMDK_OK; } offset -= (extent->end_sector - extent->sectors) * SECTOR_SIZE; l1_index = (offset >> 9) / extent->l1_entry_sectors; if (l1_index >= extent->l1_size) { return VMDK_ERROR; } l2_offset = extent->l1_table[l1_index]; if (!l2_offset) { return VMDK_UNALLOC; } for (i = 0; i < L2_CACHE_SIZE; i++) { if (l2_offset == extent->l2_cache_offsets[i]) { if (++extent->l2_cache_counts[i] == 0xffffffff) { for (j = 0; j < L2_CACHE_SIZE; j++) { extent->l2_cache_counts[j] >>= 1; } } l2_table = extent->l2_cache + (i * extent->l2_size); goto found; } } min_index = 0; min_count = 0xffffffff; for (i = 0; i < L2_CACHE_SIZE; i++) { if (extent->l2_cache_counts[i] < min_count) { min_count = extent->l2_cache_counts[i]; min_index = i; } } l2_table = extent->l2_cache + (min_index * extent->l2_size); if (bdrv_pread( extent->file, (int64_t)l2_offset * 512, l2_table, extent->l2_size * sizeof(uint32_t) ) != extent->l2_size * sizeof(uint32_t)) { return VMDK_ERROR; } extent->l2_cache_offsets[min_index] = l2_offset; extent->l2_cache_counts[min_index] = 1; found: l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size; *cluster_offset = le32_to_cpu(l2_table[l2_index]); if (extent->has_zero_grain && *cluster_offset == VMDK_GTE_ZEROED) { zeroed = true; } if (!*cluster_offset || zeroed) { if (!allocate) { return zeroed ? VMDK_ZEROED : VMDK_UNALLOC; } *cluster_offset = bdrv_getlength(extent->file); if (!extent->compressed) { bdrv_truncate( extent->file, *cluster_offset + (extent->cluster_sectors << 9) ); } *cluster_offset >>= 9; l2_table[l2_index] = cpu_to_le32(*cluster_offset); if (get_whole_cluster( bs, extent, *cluster_offset, offset, allocate) == -1) { return VMDK_ERROR; } if (m_data) { m_data->offset = *cluster_offset; m_data->l1_index = l1_index; m_data->l2_index = l2_index; m_data->l2_offset = l2_offset; m_data->valid = 1; } } *cluster_offset <<= 9; return VMDK_OK; }
1threat
React Native Android error in com.facebook.react.bridge.NoSuchKeyException : <p>I'm getting an error caught by Crashlytics and it's happening to almost 45% of the users but it doesn't seem to happen when the user is using the app but when it's in the background.</p> <p>The stacktrace shown on Crashlytics is:</p> <p><code>Fatal Exception: com.facebook.react.bridge.NoSuchKeyException ReadableNativeMap.java:124 lineNumber </code></p> <p>I have no clue what can be causing this issue, if it's a Javascript error or a native library error</p>
0debug
static int ogg_read_page(AVFormatContext *s, int *sid) { AVIOContext *bc = s->pb; struct ogg *ogg = s->priv_data; struct ogg_stream *os; int ret, i = 0; int flags, nsegs; uint64_t gp; uint32_t serial; int size, idx; uint8_t sync[4]; int sp = 0; ret = avio_read(bc, sync, 4); if (ret < 4) return ret < 0 ? ret : AVERROR_EOF; do { int c; if (sync[sp & 3] == 'O' && sync[(sp + 1) & 3] == 'g' && sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S') break; if(!i && bc->seekable && ogg->page_pos > 0) { memset(sync, 0, 4); avio_seek(bc, ogg->page_pos+4, SEEK_SET); ogg->page_pos = -1; } c = avio_r8(bc); if (avio_feof(bc)) return AVERROR_EOF; sync[sp++ & 3] = c; } while (i++ < MAX_PAGE_SIZE); if (i >= MAX_PAGE_SIZE) { av_log(s, AV_LOG_INFO, "cannot find sync word\n"); return AVERROR_INVALIDDATA; } if (avio_r8(bc) != 0) { av_log (s, AV_LOG_ERROR, "ogg page, unsupported version\n"); return AVERROR_INVALIDDATA; } flags = avio_r8(bc); gp = avio_rl64(bc); serial = avio_rl32(bc); avio_skip(bc, 8); nsegs = avio_r8(bc); idx = ogg_find_stream(ogg, serial); if (idx < 0) { if (data_packets_seen(ogg)) idx = ogg_replace_stream(s, serial, nsegs); else idx = ogg_new_stream(s, serial); if (idx < 0) { av_log(s, AV_LOG_ERROR, "failed to create or replace stream\n"); return idx; } } os = ogg->streams + idx; ogg->page_pos = os->page_pos = avio_tell(bc) - 27; if (os->psize > 0) ogg_new_buf(ogg, idx); ret = avio_read(bc, os->segments, nsegs); if (ret < nsegs) return ret < 0 ? ret : AVERROR_EOF; os->nsegs = nsegs; os->segp = 0; size = 0; for (i = 0; i < nsegs; i++) size += os->segments[i]; if (!(flags & OGG_FLAG_BOS)) os->got_data = 1; if (flags & OGG_FLAG_CONT || os->incomplete) { if (!os->psize) { while (os->segp < os->nsegs) { int seg = os->segments[os->segp++]; os->pstart += seg; if (seg < 255) break; } os->sync_pos = os->page_pos; } } else { os->psize = 0; os->sync_pos = os->page_pos; } if (os->bufsize - os->bufpos < size) { uint8_t *nb = av_malloc((os->bufsize *= 2) + FF_INPUT_BUFFER_PADDING_SIZE); if (!nb) return AVERROR(ENOMEM); memcpy(nb, os->buf, os->bufpos); av_free(os->buf); os->buf = nb; } ret = avio_read(bc, os->buf + os->bufpos, size); if (ret < size) return ret < 0 ? ret : AVERROR_EOF; os->bufpos += size; os->granule = gp; os->flags = flags; memset(os->buf + os->bufpos, 0, FF_INPUT_BUFFER_PADDING_SIZE); if (sid) *sid = idx; return 0; }
1threat
Letters to Numbers in an array : <p>Ok so basically I am working on a final grade calculator for believe it or not, finals. I was asked to use a picker view to select a letter (grade). I am trying to figure out how that when someone selects a letter grade it will use a number like 90 or 80 or so on so I can fit it into my math equation.</p>
0debug
static av_always_inline void h264_filter_mb_fast_internal(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int pixel_shift) { int chroma = !(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY)); int chroma444 = CHROMA444(h); int chroma422 = CHROMA422(h); int mb_xy = sl->mb_xy; int left_type = sl->left_type[LTOP]; int top_type = sl->top_type; int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int a = 52 + sl->slice_alpha_c0_offset - qp_bd_offset; int b = 52 + sl->slice_beta_offset - qp_bd_offset; int mb_type = h->cur_pic.mb_type[mb_xy]; int qp = h->cur_pic.qscale_table[mb_xy]; int qp0 = h->cur_pic.qscale_table[mb_xy - 1]; int qp1 = h->cur_pic.qscale_table[sl->top_mb_xy]; int qpc = get_chroma_qp( h, 0, qp ); int qpc0 = get_chroma_qp( h, 0, qp0 ); int qpc1 = get_chroma_qp( h, 0, qp1 ); qp0 = (qp + qp0 + 1) >> 1; qp1 = (qp + qp1 + 1) >> 1; qpc0 = (qpc + qpc0 + 1) >> 1; qpc1 = (qpc + qpc1 + 1) >> 1; if( IS_INTRA(mb_type) ) { static const int16_t bS4[4] = {4,4,4,4}; static const int16_t bS3[4] = {3,3,3,3}; const int16_t *bSH = FIELD_PICTURE(h) ? bS3 : bS4; if(left_type) filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1); if( IS_8x8DCT(mb_type) ) { filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0); if(top_type){ filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1); } filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0); } else { filter_mb_edgev( &img_y[4*1<<pixel_shift], linesize, bS3, qp, a, b, h, 0); filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0); filter_mb_edgev( &img_y[4*3<<pixel_shift], linesize, bS3, qp, a, b, h, 0); if(top_type){ filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1); } filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, a, b, h, 0); filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0); filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, a, b, h, 0); } if(chroma){ if(chroma444){ if(left_type){ filter_mb_edgev( &img_cb[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1); filter_mb_edgev( &img_cr[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1); } if( IS_8x8DCT(mb_type) ) { filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); if(top_type){ filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 ); filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 ); } filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); } else { filter_mb_edgev( &img_cb[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgev( &img_cr[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgev( &img_cb[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgev( &img_cr[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0); if(top_type){ filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1); filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1); } filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); } }else if(chroma422){ if(left_type){ filter_mb_edgecv(&img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); filter_mb_edgecv(&img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); } filter_mb_edgecv(&img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgecv(&img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0); if(top_type){ filter_mb_edgech(&img_cb[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); filter_mb_edgech(&img_cr[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); } filter_mb_edgech(&img_cb[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgech(&img_cr[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgech(&img_cb[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgech(&img_cr[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgech(&img_cb[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgech(&img_cr[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); }else{ if(left_type){ filter_mb_edgecv( &img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); filter_mb_edgecv( &img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); } filter_mb_edgecv( &img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgecv( &img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0); if(top_type){ filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); } filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); } } return; } else { LOCAL_ALIGNED_8(int16_t, bS, [2], [4][4]); int edges; if( IS_8x8DCT(mb_type) && (sl->cbp&7) == 7 && !chroma444 ) { edges = 4; AV_WN64A(bS[0][0], 0x0002000200020002ULL); AV_WN64A(bS[0][2], 0x0002000200020002ULL); AV_WN64A(bS[1][0], 0x0002000200020002ULL); AV_WN64A(bS[1][2], 0x0002000200020002ULL); } else { int mask_edge1 = (3*(((5*mb_type)>>5)&1)) | (mb_type>>4); int mask_edge0 = 3*((mask_edge1>>1) & ((5*left_type)>>5)&1); int step = 1+(mb_type>>24); edges = 4 - 3*((mb_type>>3) & !(sl->cbp & 15)); h->h264dsp.h264_loop_filter_strength(bS, sl->non_zero_count_cache, sl->ref_cache, sl->mv_cache, sl->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h)); } if( IS_INTRA(left_type) ) AV_WN64A(bS[0][0], 0x0004000400040004ULL); if( IS_INTRA(top_type) ) AV_WN64A(bS[1][0], FIELD_PICTURE(h) ? 0x0003000300030003ULL : 0x0004000400040004ULL); #define FILTER(hv,dir,edge,intra)\ if(AV_RN64A(bS[dir][edge])) { \ filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qp : qp##dir, a, b, h, intra );\ if(chroma){\ if(chroma444){\ filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ } else if(!(edge&1)) {\ filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ }\ }\ } if(left_type) FILTER(v,0,0,1); if( edges == 1 ) { if(top_type) FILTER(h,1,0,1); } else if( IS_8x8DCT(mb_type) ) { FILTER(v,0,2,0); if(top_type) FILTER(h,1,0,1); FILTER(h,1,2,0); } else { FILTER(v,0,1,0); FILTER(v,0,2,0); FILTER(v,0,3,0); if(top_type) FILTER(h,1,0,1); FILTER(h,1,1,0); FILTER(h,1,2,0); FILTER(h,1,3,0); } #undef FILTER } }
1threat
static int local_link(FsContext *ctx, V9fsPath *oldpath, V9fsPath *dirpath, const char *name) { int ret; V9fsString newpath; char *buffer, *buffer1; int serrno; v9fs_string_init(&newpath); v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name); buffer = rpath(ctx, oldpath->data); buffer1 = rpath(ctx, newpath.data); ret = link(buffer, buffer1); g_free(buffer); if (ret < 0) { goto out; } if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { char *vbuffer, *vbuffer1; ret = local_create_mapped_attr_dir(ctx, newpath.data); if (ret < 0) { goto err_out; } vbuffer = local_mapped_attr_path(ctx, oldpath->data); vbuffer1 = local_mapped_attr_path(ctx, newpath.data); ret = link(vbuffer, vbuffer1); g_free(vbuffer); g_free(vbuffer1); if (ret < 0 && errno != ENOENT) { goto err_out; } } goto out; err_out: serrno = errno; remove(buffer1); errno = serrno; out: g_free(buffer1); v9fs_string_free(&newpath); return ret; }
1threat
what does 'in' mean in javascript if statement : <p>Hi i'm following a tutorial learning to use javascript. </p> <pre><code>function move(keyclick) { if(40 in keyclick) {} playerMove.x++; render(); } </code></pre> <p>What does the 'in' word mean? I understand what the function is doing, but why not just use == ?</p> <p>Thanks </p>
0debug
static struct omap_lpg_s *omap_lpg_init(target_phys_addr_t base, omap_clk clk) { int iomemtype; struct omap_lpg_s *s = (struct omap_lpg_s *) qemu_mallocz(sizeof(struct omap_lpg_s)); s->tm = qemu_new_timer(rt_clock, omap_lpg_tick, s); omap_lpg_reset(s); iomemtype = cpu_register_io_memory(omap_lpg_readfn, omap_lpg_writefn, s, DEVICE_NATIVE_ENDIAN); cpu_register_physical_memory(base, 0x800, iomemtype); omap_clk_adduser(clk, qemu_allocate_irqs(omap_lpg_clk_update, s, 1)[0]); return s; }
1threat
static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVVHDXState *s = bs->opaque; int ret = 0; uint32_t i; uint64_t signature; uint32_t data_blocks_cnt, bitmap_blocks_cnt; s->bat = NULL; s->first_visible_write = true; qemu_co_mutex_init(&s->lock); ret = bdrv_pread(bs->file, 0, &signature, sizeof(uint64_t)); if (ret < 0) { goto fail; } if (memcmp(&signature, "vhdxfile", 8)) { ret = -EINVAL; goto fail; } vhdx_guid_generate(&s->session_guid); ret = vhdx_parse_header(bs, s); if (ret) { goto fail; } ret = vhdx_parse_log(bs, s); if (ret) { goto fail; } ret = vhdx_open_region_tables(bs, s); if (ret) { goto fail; } ret = vhdx_parse_metadata(bs, s); if (ret) { goto fail; } s->block_size = s->params.block_size; bs->total_sectors = s->virtual_disk_size >> s->logical_sector_size_bits; data_blocks_cnt = s->virtual_disk_size >> s->block_size_bits; if (s->virtual_disk_size - (data_blocks_cnt << s->block_size_bits)) { data_blocks_cnt++; } bitmap_blocks_cnt = data_blocks_cnt >> s->chunk_ratio_bits; if (data_blocks_cnt - (bitmap_blocks_cnt << s->chunk_ratio_bits)) { bitmap_blocks_cnt++; } if (s->parent_entries) { s->bat_entries = bitmap_blocks_cnt * (s->chunk_ratio + 1); } else { s->bat_entries = data_blocks_cnt + ((data_blocks_cnt - 1) >> s->chunk_ratio_bits); } s->bat_offset = s->bat_rt.file_offset; if (s->bat_entries > s->bat_rt.length / sizeof(VHDXBatEntry)) { ret = -EINVAL; goto fail; } s->bat = qemu_blockalign(bs, s->bat_rt.length); ret = bdrv_pread(bs->file, s->bat_offset, s->bat, s->bat_rt.length); if (ret < 0) { goto fail; } for (i = 0; i < s->bat_entries; i++) { le64_to_cpus(&s->bat[i]); } if (flags & BDRV_O_RDWR) { ret = vhdx_update_headers(bs, s, false, NULL); if (ret < 0) { goto fail; } } error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "vhdx", bs->device_name, "live migration"); migrate_add_blocker(s->migration_blocker); return 0; fail: qemu_vfree(s->headers[0]); qemu_vfree(s->headers[1]); qemu_vfree(s->bat); qemu_vfree(s->parent_entries); return ret; }
1threat
Uploaded image in codeigniter cannot be displayed : i have uploaded an image in codeigniter, the image has been uploaded in folder application/uploads, when i try to display the image in an <img> tag it is not shown while the path is correct and the image is existed
0debug
C++ : Similarities between Structure and Arrays? : <p>Are there any similarities between the structures and arrays in C++ ? </p> <p>I was wondering to see this kind of question as both are different as one is user defined data type and other is derived data type with contiguous memory location storage.</p>
0debug
How to show an element in front? : <p>I was setting some section and I want to show a section in front but it's not working. I tried <em>z-index</em> but it's not working</p> <p>I want that the listed product should come in front with their product content(Check link). and one more thing it should not push the footer below <a href="https://ibb.co/wKB0Zxj" rel="nofollow noreferrer">https://ibb.co/wKB0Zxj</a></p> <p>My site is this <a href="https://www.snatchu.com/product/toothpaste-squeezer-5-colors/" rel="nofollow noreferrer">https://www.snatchu.com/product/toothpaste-squeezer-5-colors/</a></p>
0debug
C# Recursion to get parent value and children value and all its children's children value : Need help with the following question. I was tested on this and failed and really want to know the answer so that I can study it.... Assume an list (C#) of objects in pyramid structure with the following properties: • id • name • value • parentid Example (C#): var b = new block();<br> b.id = 100;<br> b.name = "block 100"<br> b.value = 102.50;<br> b.parentid = 99; Write a recursive function that accepts an ID as the only parameter and will loop through an array or list of an undetermined size and number of levels. The recursive function will calculate ------------------------------ block block1 = new block(1, null, "block 1", 11.34M); block block11 = new block(11, 1, "block 11", 234.34M); block block111 = new block(111, 11, "block 111", 111); block block12 = new block(12, 1, "block 12", 564); block block13 = new block (13, 1, "block 13", 342.23M); block block131 = new block(131, 13, "block 131", 945); block block132 = new block(132, 13, "block 132", 10M); block block133 = new block(133, 13, "block 133", 88M); block block1331 = new block(1331, 133, "block 1331", 45); block block2 = new block(2, null, "block 2", 234); block block3 = new block(3, null, "block 3", 1249.34M); blocks = new List<block>(); blocks.Add(block1); blocks.Add(block11); blocks.Add(block111); blocks.Add(block12); blocks.Add(block13); blocks.Add(block131); blocks.Add(block132); blocks.Add(block133); blocks.Add(block2); blocks.Add(block3); decimal sum = SumAll(1); Console.WriteLine(sum); Console.ReadKey(); } --------------- I need a function that gives me a total "value" from the "value" property for the parent and all of its children and its children's children. Can anyone help?
0debug
how can I send the disconnect messages to subscriibed clients if one client is disconnected in MQTT? : Hello All I tried client 1 and client 2 program I can able to easily communicate with them.I can easily send the messages and receive the messages with them.but I don't know if one client is disconnected, how can I send the disconnected message to subscribed clients.can anyone help me.I need urgently.Thanks in advance.I am waiting for your reply. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> client 1: var mqtt=require("mqtt"); var express=require("express"); var app=express(); var options={ keepalive:100, port: 1883, clientId:'1', clientSession:false, host: "http://localhost:8000", will: { topic:'willMag', payload:"connection closed abnormallly r", qos:1, retain:true } }; var client=mqtt.connect("tcp://192.168.43.137:1883",options); client.on("connect",function() { setInterval(function() { client.publish("ranjith/princy","hello love you princy",function() { console.log("message published in client1"); }); },2000); client.subscribe("bv/nivi"); client.on("message",function(topic,message) { console.log("I recieved the topic:"+topic); console.log("I recieved the message:"+message); }); }); client.on("disconnect",function() { console.log("disconnected client1"); }); app.listen(8000,function() { console.log("server listen at port 8000"); }); client 2: var mqtt=require("mqtt"); var express=require("express"); var app=express(); var options={ keepalive:100, port: 1883, clientId:'2', clientSession:false, host: "http://localhost:8086", will: { topic:'willMag', payload:"connection closed abnormallly b", qos:1, retain:true } }; var client=mqtt.connect("tcp://192.168.43.137:1883",options); client.on("connect",function() { setInterval(function(){ client.publish("bv/nivi","hello love you nivi",function() { console.log("message published in client2"); }); },2000); client.subscribe("ranjith/princy"); client.on("message",function(topic,message) { console.log("I recieved the topic:"+topic); console.log("I recieved the message:"+message); }); }); client.on("disconnect",function() { console.log("disconnected client2"); }); app.listen(8086,function() { console.log("server listen at port 8000"); }); <!-- end snippet -->
0debug
I'm running ng test and getting below error. Could you please someone help me? : Failed: Template parse errors: 'app-navbar' is not a known element: 1. If 'app-navbar' is an Angular component, then verify that it is part of this module. 2. If 'app-navbar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<app-navbar></app-navbar> "): ng:///DynamicTestModule/AppComponent.html@0:0 Error: Template parse errors: 'app-navbar' is not a known element: 1. If 'app-navbar' is an Angular component, then verify that it is part of this module. 2. If 'app-navbar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<app-navbar></app-navbar>
0debug
Passing a parameter on click gives an error : <pre><code> $(".editorCancel").click({param1: kind}, closeMainMenu); function closeMainMenu(event){ console.log(event.data.param1); } </code></pre> <p>This will print the right value <code>param1</code>, <strong>but also print an error :</strong></p> <blockquote> <p>Cannot read property 'data' of undefined</p> </blockquote> <p>So if i get the right values, why is the error ?</p>
0debug
C++ - operator -= on a pointer : <p>Say I have pointer array:</p> <pre><code>char* buf = new char[256]; </code></pre> <p>what will happen to array pointer's value/size if i do</p> <pre><code>buf -= 100; </code></pre>
0debug
Run docker service on HTTPS : <p>Currently, I run a simple docker container by using the following files.</p> <p>DockerFile</p> <pre><code>FROM microsoft/aspnet:4.7.1 WORKDIR /inetpub/wwwroot EXPOSE 80 COPY index.html . </code></pre> <p>docker-compose.yml</p> <pre><code>version: '3.4' services: testapp: image: mytestapp:${TAG:-latest} build: context: . dockerfile: Dockerfile </code></pre> <p>docker-compose.override.yml</p> <pre><code>version: '3.4' services: testapp: ports: - "9091:80" </code></pre> <p>I use windows image to create my container by using the following command and I can access it by <a href="http://localhost:9091/" rel="noreferrer">http://localhost:9091/</a>.</p> <pre><code>docker-compose -f docker-compose.yml -f docker-compose.override.yml build </code></pre> <p>I want to access my app by using HTTPS instead of http. </p> <p>What are the steps that I need to follow ?</p>
0debug
Program producing corrupted data : <p>I'm not sure what I'm doing incorrectly here, but when I compile this program, the console output shows all of the data as strange corrupted characters and what seems to be hex numbers.</p> <p><strong>Here's the source:</strong></p> <pre><code>#include "stdafx.h" #include &lt;iostream&gt; using namespace std; int main() { int x[10] = { -5, 4, 3 }; char letters[] = { 'a', 'b', 'c' }; double z[4]; cout &lt;&lt; x; cout &lt;&lt; "\n"; cout &lt;&lt; letters; cout &lt;&lt; "\n"; cout &lt;&lt; z; cout &lt;&lt; "\n"; system("pause"); return 0; } </code></pre> <p>Here's how it compiles - <a href="https://gyazo.com/a622959f6b6e88846ce5d1d922c8c356" rel="nofollow noreferrer">https://gyazo.com/a622959f6b6e88846ce5d1d922c8c356</a></p> <p>Thanks in advance. </p>
0debug
Error while accessing dictionary in python : I have a dictionary named json_dict given below. I need to access the element ==> json_dict['OptionSettings'][3]['Value']. I need to access the element like print(json_dict[param]). When I giving param like param="['OptionSettings'][3]['Value']" OR param="'OptionSettings'][3]['Value'" I am getting below error KeyError: "['OptionSettings'][3]['Value']" OR KeyError: "'OptionSettings'][3]['Value'" I tried below thing also but it just print the string str1="json_dict" print(str1+param) { "ApplicationName": "Test", "EnvironmentName": "ABC-Nodejs", "CNAMEPrefix": "ABC-Neptune", "SolutionStackName": "64bit Amazon Linux 2016.03 v2.1.1 running Node.js", "OptionSettings": [ { "Namespace": "aws:ec2:vpc", "OptionName": "AssociatePublicIpAddress", "Value": "true" }, { "Namespace": "aws:elasticbeanstalk:environment", "OptionName": "EnvironmentType", "Value": "LoadBalanced" }, { "Namespace": "aws:ec2:vpc", "OptionName": "Subnets", "Value": "param1" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "SecurityGroups", "Value": "param2" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "MinSize", "Value": "1" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "MaxSize", "Value": "4" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "Availability Zones", "Value": "Any" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "Cooldown", "Value": "360" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "IamInstanceProfile", "Value": "NepRole" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "MonitoringInterval", "Value": "5 minutes" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "RootVolumeType", "Value": "gp2" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "RootVolumeSize", "Value": "10" }, { "Namespace": "aws:elasticbeanstalk:sns:topics", "OptionName": "Notification Endpoint", "Value": "sunil.kumar2@pb.com" }, { "Namespace": "aws:elasticbeanstalk:hostmanager", "OptionName": "LogPublicationControl", "Value": "false" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "DeploymentPolicy", "Value": "Rolling" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "BatchSizeType", "Value": "Percentage" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "BatchSize", "Value": "100" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "HealthCheckSuccessThreshold", "Value": "Ok" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "IgnoreHealthCheck", "Value": "false" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "Timeout", "Value": "600" }, { "Namespace": "aws:autoscaling:updatepolicy:rollingupdate", "OptionName": "RollingUpdateEnabled", "Value": "false" }, { "Namespace": "aws:ec2:vpc", "OptionName": "ELBSubnets", "Value": "param3" }, { "Namespace": "aws:elb:loadbalancer", "OptionName": "SecurityGroups", "Value": "param4" }, { "Namespace": "aws:elb:loadbalancer", "OptionName": "ManagedSecurityGroup", "Value": "param4" } ] }
0debug
int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs) { int j; fs->plane_count = f->plane_count; fs->transparency = f->transparency; for (j = 0; j < f->plane_count; j++) { PlaneContext *const p = &fs->plane[j]; if (fs->ac) { if (!p->state) p->state = av_malloc(CONTEXT_SIZE * p->context_count * sizeof(uint8_t)); if (!p->state) return AVERROR(ENOMEM); } else { if (!p->vlc_state) p->vlc_state = av_malloc(p->context_count * sizeof(VlcState)); if (!p->vlc_state) return AVERROR(ENOMEM); } } if (fs->ac > 1) { for (j = 1; j < 256; j++) { fs->c.one_state[j] = f->state_transition[j]; fs->c.zero_state[256 - j] = 256 - fs->c.one_state[j]; } } return 0; }
1threat
Destructor triggers a breakpoint : <p>I'm writing my version of string class and when I tried to overload + operator, destructor triggers a breakpoint while the program is performing</p> <p>function:</p> <pre><code>String operator+(const String &amp; s, const String &amp; st) { int k = s.len + st.len + 1; char* x = new char[k]; x = s.str; for (int i = 0, j = k - st.len - 1; j &lt; k; j++, i++) { x[j] = st.str[i]; } return String(x); } </code></pre> <p>destructor:</p> <pre><code>String::~String() { delete[] str; } </code></pre> <p>main:</p> <pre><code>int main() { String x("cos"); String y("cos"); String z = x + y; std::cout &lt;&lt; z; } </code></pre> <p>thanks for help</p>
0debug
How to size an array in c? 32 bit mcu : <p>The following line of c code creates an array to store a picture from a camera. The images are about 22kb. </p> <pre><code>uint8_t picturearray[32*1024]; </code></pre> <p>The mcu is 32 bit. I'm just wondering why it is <code>32*1024</code>? Is it 32 because it is 32 bit? Why would it be 1024?</p> <p>Thanks </p>
0debug
How do I know which stage of jenkins pipeline has failed : <p>In my Jenkins pipelines I generally use <code>post</code> declarative function to send me an email incase the pipeline has failed. </p> <p>A simple syntax of the <code>post</code> function is as under:</p> <pre><code>post { failure { mail to: 'team@example.com', subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", body: "Something is wrong with ${env.BUILD_URL}" } } </code></pre> <p>In the above email, I also want to mention which stage (lets say the pipeline has 5 to 6 stages) of the pipeline has failed. How can I do that? Any help is much appreciated.</p> <p>An extension to the above requirement will be to provide the user with the actual error log (of the stage that has failed) also as a part of the failure notification email.</p> <p>Idea is, when a user receives a failure notification from jenkins, he should know which stage of the pipeline has failed along with the error log.</p> <p>Thanks in advance.</p>
0debug
Ansible error on shell command returning zero : <p>Ansible doesn't seem to be able to handle the result '0' for shell commands. This</p> <pre><code>- name: Check if swap exists shell: "swapon -s | grep -ci dev" register: swap_exists </code></pre> <p>Returns an error </p> <blockquote> <p>"msg": "non-zero return code"</p> </blockquote> <p>But when I replace "dev" with "type", which actually always occurs and gives a count of at least 1, then the command is successful and no error is thrown.</p> <p>I also tried with <code>command:</code> instead of <code>shell:</code> - it doesn't give an error, but then the command is also not executed.</p>
0debug
Nested If Statement Not displaying Correctly : <p>I am creating Payroll systems for a side project. I am using the nested if statement to see what billing schedule the user selected (52 or 26) then calculate gross pay, taxes and other deductions. The 52 week pay schedule works correctly but the 26 week pay schedule does not display any values. </p> <pre><code>double hoursWorked = Double.parseDouble(txtHoursWorked.getText()); double hourlyRate = Double.parseDouble(txtHourlyPay.getText()); double overtimeHours = Double.parseDouble(txtOvertimeHours.getText()); double overtimeRate = Double.parseDouble(txtOvertimePay.getText()); // Declare variables double basicPay; double overtimePay; double grossPay; double taxes; double yearlyCompensation; double cpp; double ei; double deductions; double netPay; if (cmbPayPeriod.getSelectedItem().equals("52 Week Pay Period")) { grossPay = basicPay + overtimePay; txtGrossPay.setText(x.format(grossPay)); yearlyCompensation = grossPay * 52; if (yearlyCompensation &lt; 45282) { taxes = (yearlyCompensation * 0.15) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; netPay = grossPay - deductions; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); txtNetPay.setText(x.format(netPay)); } else if (yearlyCompensation &lt; 90536) { taxes = (yearlyCompensation * 0.205) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; netPay = grossPay - deductions; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); txtNetPay.setText(x.format(netPay)); } else if (yearlyCompensation &lt; 140388) { taxes = (yearlyCompensation * 0.265) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; netPay = grossPay - deductions; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); txtNetPay.setText(x.format(netPay)); } else if (yearlyCompensation &lt; 200000) { taxes = (yearlyCompensation * 0.29) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; netPay = grossPay - deductions; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); txtNetPay.setText(x.format(netPay)); } else { taxes = (yearlyCompensation * 0.33) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; netPay = grossPay - deductions; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); txtNetPay.setText(x.format(netPay)); } if (cmbPayPeriod.getSelectedItem().equals("n")) { grossPay = (basicPay + overtimePay) * 2; txtGrossPay.setText(x.format(grossPay)); yearlyCompensation = grossPay * 26; if (yearlyCompensation &lt; 45282) { taxes = (yearlyCompensation * 0.15) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); } else if (yearlyCompensation &lt; 90536) { taxes = (yearlyCompensation * 0.205) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); } else if (yearlyCompensation &lt; 140388) { taxes = (yearlyCompensation * 0.265) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); } else if (yearlyCompensation &lt; 200000) { taxes = (yearlyCompensation * 0.29) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); } else { taxes = (yearlyCompensation * 0.33) / 52; cpp = (yearlyCompensation * 0.0495) / 52; ei = (yearlyCompensation * 0.0163) / 52; deductions = taxes + cpp + ei; txtTaxP.setText(x.format(taxes)); txtCPP.setText(x.format(cpp)); txtEI.setText(x.format(ei)); txtDeductions.setText(x.format(deductions)); } } } </code></pre>
0debug
static int decode_cabac_mb_chroma_pre_mode( H264Context *h) { const int mba_xy = h->left_mb_xy[0]; const int mbb_xy = h->top_mb_xy; int ctx = 0; if( h->slice_table[mba_xy] == h->slice_num && h->chroma_pred_mode_table[mba_xy] != 0 ) ctx++; if( h->slice_table[mbb_xy] == h->slice_num && h->chroma_pred_mode_table[mbb_xy] != 0 ) ctx++; if( get_cabac( &h->cabac, &h->cabac_state[64+ctx] ) == 0 ) return 0; if( get_cabac( &h->cabac, &h->cabac_state[64+3] ) == 0 ) return 1; if( get_cabac( &h->cabac, &h->cabac_state[64+3] ) == 0 ) return 2; else return 3; }
1threat
static void gdb_accept(void) { GDBState *s; struct sockaddr_in sockaddr; socklen_t len; int val, fd; for(;;) { len = sizeof(sockaddr); fd = accept(gdbserver_fd, (struct sockaddr *)&sockaddr, &len); if (fd < 0 && errno != EINTR) { perror("accept"); return; } else if (fd >= 0) { break; } } val = 1; setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); s = qemu_mallocz(sizeof(GDBState)); s->c_cpu = first_cpu; s->g_cpu = first_cpu; s->fd = fd; gdb_has_xml = 0; gdbserver_state = s; fcntl(fd, F_SETFL, O_NONBLOCK); }
1threat
static inline void RENAME(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2, const uint8_t *src, long width) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "movq "MANGLE(bm01010101)", %%mm4 \n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "pand %%mm4, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "psrlw $8, %%mm2 \n\t" "psrlw $8, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "movq %%mm2, (%3, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst1+width), "r" (dst2+width) : "%"REG_a ); #else int i; for (i = 0; i < width; i++) { dst1[i] = src[2*i+0]; dst2[i] = src[2*i+1]; } #endif }
1threat
TypeError: attrib() got an unexpected keyword argument 'convert' : <p>This error occurred during automated testing of a python project on the CI server using <code>pytest</code>. I'm using <code>pytest==4.0.2</code>. This error only just started to occur, previous pipelines seem to work fine.</p> <p>The full error:</p> <pre><code>File "/usr/local/lib/python3.7/site-packages/_pytest/tmpdir.py", line 35, in TempPathFactory lambda p: Path(os.path.abspath(six.text_type(p))) TypeError: attrib() got an unexpected keyword argument 'convert' </code></pre>
0debug
static void rxfilter_notify(NetClientState *nc) { QObject *event_data; VirtIONet *n = qemu_get_nic_opaque(nc); if (nc->rxfilter_notify_enabled) { if (n->netclient_name) { event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }", n->netclient_name, object_get_canonical_path(OBJECT(n->qdev))); } else { event_data = qobject_from_jsonf("{ 'path': %s }", object_get_canonical_path(OBJECT(n->qdev))); } monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data); qobject_decref(event_data); nc->rxfilter_notify_enabled = 0; } }
1threat
Why does this for loop work : <p>I have this code:</p> <pre><code>int k; for (k=0; k&gt;-3; k=-2;); { System.out.println(k); } </code></pre> <p>The output is negative four. I don't understand why this code still runs even though there is a semi colon after the statements in the for loop. </p>
0debug
PHP GET error $ : <p>I want to collect information from <a href="http://mywebsite1.com/register.php?log=firstname=Yoga&amp;lastname=Galih" rel="nofollow">http://mywebsite1.com/register.php?log=firstname=Yoga&amp;lastname=Galih</a></p> <p>but i want to get that info to my 2nd website using PHP $_GET and save it to <code>reg.log</code></p> <pre><code>&lt;?php $txt = "reg.log"; if (isset($_GET["log"]) &amp;&amp; isset($_GET["firstname"]) &amp;&amp; isset($_GET["lastname"]) &amp;&amp; isset($_GET["address"]) &amp;&amp; isset($_GET["city"]) &amp;&amp; isset($_GET["state"]) &amp;&amp; isset($_GET["zip"]) &amp;&amp; isset($_GET["country"]) &amp;&amp; isset($_GET["phone"]) $$ isset($_GET["gender"]) &amp;&amp; isset($_GET["haircolor"]) &amp;&amp; isset($_GET["eyecolor"]) &amp;&amp; isset($_GET["high"]) isset($_GET["weight"])) { $firstname = $_GET["fname"]; $lastname = $_GET["lname"]; $address = $_GET["address"]; $city = $_GET["city"]; $state = $_GET["state"]; $zip = $_GET["zip"]; $country = $_GET["country"]; $gender = $_GET["gender"]; $haircolor = $_GET["hcolor"]; $eyecolor = $_GET["ecolor"]; $high = $_GET["high"]; $weight = $_GET["weight"]; $phone = $_GET["phone"]; echo $firstname .PHP_EOL. $lastname .PHP_EOL. $address .PHP_EOL. $city .PHP_EOL. $state .PHP_EOL. $zip .PHP_EOL. $country .PHP_EOL. $phone .PHP_EOL. $hcolor .PHP_EOL. $ecolor .PHP_EOL. $high .PHP_EOL. weigh .PHP_EOL. gender; $fh = fopen($txt, 'a'); fwrite($fh,$txt); // Write information to the file fclose($fh); // Close the fil } ?&gt; </code></pre> <p>but I get error [21-Mar-2016 15:17:09 America/New_York] PHP Parse error: syntax error, unexpected '$' in /home/my2ndweb/public_html/includes/register.php on line 3</p> <p>I need help</p> <p>Thanks</p>
0debug
SignalR Core 2.2 CORS AllowAnyOrigin() breaking change : <p>To connect via SignalR to an ASP.NET Core 2.1 server from any origin, we had to configure the pipeline as follows:</p> <pre><code>app.UseCors ( builder =&gt; builder .AllowAnyHeader () .AllowAnyMethod () .AllowAnyOrigin () .AllowCredentials () ) </code></pre> <p>According to <a href="https://docs.microsoft.com/pt-br/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&amp;tabs=visual-studio#update-cors-policy" rel="noreferrer">this</a> document, ASP.NET Core 2.2 no longer allows the combination of AllowAnyOrigin and AllowCredentials, so what would be the solution? Whereas the SignalR Core always sends withCredentials:true in the XMLHtppRequest.</p> <p>What I need is that from any origin and without credentials, our users can connect to the SignalR Hub.</p>
0debug
How to convert simple jQuery code to wordpress jQuery of the following code : <pre><code> &lt;b id="smsCount"&gt;&lt;/b&gt; SMS (&lt;b id="smsLength"&gt;&lt;/b&gt;) Characters left &lt;br /&gt;&lt;textarea id="smsText" style="width:400px;height:200px"&gt; &lt;/textarea&gt; //Plugin (function($){ jQuery.fn.smsArea = function(options){ var e = this, cutStrLength = 0, s = jQuery.extend({ cut: true, maxSmsNum: 3, interval: 400, counters: { message: jQuery('#smsCount'), character: jQuery('#smsLength') }, lengths: { ascii: [160, 306, 459], unicode: [70, 134, 201] } }, options); e.keyup(function(){ clearTimeout(this.timeout); this.timeout = setTimeout(function(){ var smsType, smsLength = 0, smsCount = -1, charsLeft = 0, text = e.val(), isUnicode = false; for(var charPos = 0; charPos &lt; text.length; charPos++){ switch(text[charPos]){ case "\n": case "[": case "]": case "\\": case "^": case "{": case "}": case "|": case "€": smsLength += 2; break; default: smsLength += 1; } //!isUnicode &amp;&amp; text.charCodeAt(charPos) &gt; 127 &amp;&amp; text[charPos] != "€" &amp;&amp; (isUnicode = true) if(text.charCodeAt(charPos) &gt; 127 &amp;&amp; text[charPos] != "€") isUnicode = true; } if(isUnicode) smsType = s.lengths.unicode; else smsType = s.lengths.ascii; for(var sCount = 0; sCount &lt; s.maxSmsNum; sCount++){ cutStrLength = smsType[sCount]; if(smsLength &lt;= smsType[sCount]){ smsCount = sCount + 1; charsLeft = smsType[sCount] - smsLength; break } } if(s.cut) e.val(text.substring(0, cutStrLength)); smsCount == -1 &amp;&amp; (smsCount = s.maxSmsNum, charsLeft = 0); s.counters.message.html(smsCount); s.counters.character.html(charsLeft); }, s.interval) }).keyup() }}(jQuery)); //Start jQuery(function(){ jQuery('#smsText').smsArea({maxSmsNum:3}); }); </code></pre> <p>I am working in Wordpress, M going to make some smscount system that counts ASCII and Unicode character.I saw somewhere that Wordpress take jQuery instead of $. But it is not working. Dnt knw whr I make mistake?</p> <p>Any help is appreciated. </p>
0debug
<script>document.cookie = "humans_21909=1"; document.location.reload(true)</script> : <p>web API build with wordpress is showing error of</p> <pre><code>&lt;script&gt;document.cookie = "humans_21909=1"; document.location.reload(true)&lt;/script&gt; </code></pre> <p>it works sometime on some network and sometime not working</p>
0debug
Where does the convention of using /healthz for application health checks come from? : <p>In the Kubernetes/Docker ecosystem there is a convention of using <code>/healthz</code> as a health-check endpoint for applications.</p> <p>Where does the name 'healthz' come from, and are there any particular semantics associated with that name?</p>
0debug
static void ac97_save (QEMUFile *f, void *opaque) { size_t i; uint8_t active[LAST_INDEX]; AC97LinkState *s = opaque; pci_device_save (s->pci_dev, f); qemu_put_be32s (f, &s->glob_cnt); qemu_put_be32s (f, &s->glob_sta); qemu_put_be32s (f, &s->cas); for (i = 0; i < ARRAY_SIZE (s->bm_regs); ++i) { AC97BusMasterRegs *r = &s->bm_regs[i]; qemu_put_be32s (f, &r->bdbar); qemu_put_8s (f, &r->civ); qemu_put_8s (f, &r->lvi); qemu_put_be16s (f, &r->sr); qemu_put_be16s (f, &r->picb); qemu_put_8s (f, &r->piv); qemu_put_8s (f, &r->cr); qemu_put_be32s (f, &r->bd_valid); qemu_put_be32s (f, &r->bd.addr); qemu_put_be32s (f, &r->bd.ctl_len); } qemu_put_buffer (f, s->mixer_data, sizeof (s->mixer_data)); active[PI_INDEX] = AUD_is_active_in (s->voice_pi) ? 1 : 0; active[PO_INDEX] = AUD_is_active_out (s->voice_po) ? 1 : 0; active[MC_INDEX] = AUD_is_active_in (s->voice_mc) ? 1 : 0; qemu_put_buffer (f, active, sizeof (active)); }
1threat
How to use another class method and the this context in a type method? : <p>I want to rewrite the JavaScript "method" further below in TypeScript. I am tempted to do it as class, like this: </p> <pre><code>// export default class export default class GroupItemMetadataProvider1 { protected m_instance; protected _grid; protected _defaults; protected m_options; constructor(options) { this.m_instance = this; this._defaults = { groupCssClass: "slick-group", groupTitleCssClass: "slick-group-title", totalsCssClass: "slick-group-totals", groupFocusable: true, totalsFocusable: false, toggleCssClass: "slick-group-toggle", toggleExpandedCssClass: "expanded", toggleCollapsedCssClass: "collapsed", enableExpandCollapse: true, groupFormatter: this.defaultGroupCellFormatter, totalsFormatter: this.defaultTotalsCellFormatter }; options = $.extend(true, {}, this._defaults, options); this.m_options = options; } protected defaultGroupCellFormatter(row, cell, value, columnDef, item) { if (!this.m_options.enableExpandCollapse) { return item.title; } let indentation = item.level * 15 + "px"; return "&lt;span class='" + this.m_options.toggleCssClass + " " + (item.collapsed ? this.m_options.toggleCollapsedCssClass : this.m_options.toggleExpandedCssClass) + "' style='margin-left:" + indentation + "'&gt;" + "&lt;/span&gt;" + "&lt;span class='" + this.m_options.groupTitleCssClass + "' level='" + item.level + "'&gt;" + item.title + "&lt;/span&gt;"; } protected defaultTotalsCellFormatter(row, cell, value, columnDef, item) { return (columnDef.groupTotalsFormatter &amp;&amp; columnDef.groupTotalsFormatter(item, columnDef)) || ""; } protected init(grid) { this._grid = grid; this._grid.onClick.subscribe(this.handleGridClick); this._grid.onKeyDown.subscribe(this.handleGridKeyDown); } protected destroy() { if (this._grid) { this._grid.onClick.unsubscribe(this.handleGridClick); this._grid.onKeyDown.unsubscribe(this.handleGridKeyDown); } } protected handleGridClick(e, args) { let context = (&lt;any&gt;this); let item = context.getDataItem(args.row); if (item &amp;&amp; item instanceof Slick.Group &amp;&amp; $(e.target).hasClass(this.m_options.toggleCssClass)) { let range = this._grid.getRenderedRange(); context.getData().setRefreshHints({ ignoreDiffsBefore: range.top, ignoreDiffsAfter: range.bottom + 1 }); if (item.collapsed) { context.getData().expandGroup(item.groupingKey); } else { context.getData().collapseGroup(item.groupingKey); } e.stopImmediatePropagation(); e.preventDefault(); } } // TODO: add -/+ handling protected handleGridKeyDown(e) { let context = (&lt;any&gt;this); if (this.m_options.enableExpandCollapse &amp;&amp; (e.which == Slick.keyCode.SPACE)) { let activeCell = context.getActiveCell(); if (activeCell) { let item = context.getDataItem(activeCell.row); if (item &amp;&amp; item instanceof Slick.Group) { let range = this._grid.getRenderedRange(); context.getData().setRefreshHints({ ignoreDiffsBefore: range.top, ignoreDiffsAfter: range.bottom + 1 }); if (item.collapsed) { context.getData().expandGroup(item.groupingKey); } else { context.getData().collapseGroup(item.groupingKey); } e.stopImmediatePropagation(); e.preventDefault(); } } } } public getGroupRowMetadata(item) { return { selectable: false, focusable: this.m_options.groupFocusable, cssClasses: this.m_options.groupCssClass, columns: { 0: { colspan: "*", formatter: this.m_options.groupFormatter, editor: null } } }; } public getTotalsRowMetadata(item) { return { selectable: false, focusable: this.m_options.totalsFocusable, cssClasses: this.m_options.totalsCssClass, formatter: this.m_options.totalsFormatter, editor: null }; } } </code></pre> <p>However, handleGridClick &amp; handleGridKeyDown both reference the 'this' "event-context", as well as the 'this' class-context to get the options. </p> <p>Problem is, I can't just bind the this in the constructor, because otherwise, the this-context of the object is wrong. How can I do this ? </p> <p>This is the plain JavaScript variant:</p> <pre><code>// import $ from '../../wwwroot/jQuery-3.3.js'; import Slick from './slick.core.js'; export default GroupItemMetadataProvider; /*** * Provides item metadata for group (Slick.Group) and totals (Slick.Totals) rows produced by the DataView. * This metadata overrides the default behavior and formatting of those rows so that they appear and function * correctly when processed by the grid. * * This class also acts as a grid plugin providing event handlers to expand &amp; collapse groups. * If "grid.registerPlugin(...)" is not called, expand &amp; collapse will not work. * * @class GroupItemMetadataProvider * @module Data * @namespace Slick.Data * @constructor * @param options */ function GroupItemMetadataProvider(options) { let _grid; let _defaults = { groupCssClass: "slick-group", groupTitleCssClass: "slick-group-title", totalsCssClass: "slick-group-totals", groupFocusable: true, totalsFocusable: false, toggleCssClass: "slick-group-toggle", toggleExpandedCssClass: "expanded", toggleCollapsedCssClass: "collapsed", enableExpandCollapse: true, groupFormatter: defaultGroupCellFormatter, totalsFormatter: defaultTotalsCellFormatter }; options = $.extend(true, {}, _defaults, options); function defaultGroupCellFormatter(row, cell, value, columnDef, item) { if (!options.enableExpandCollapse) { return item.title; } let indentation = item.level * 15 + "px"; return "&lt;span class='" + options.toggleCssClass + " " + (item.collapsed ? options.toggleCollapsedCssClass : options.toggleExpandedCssClass) + "' style='margin-left:" + indentation + "'&gt;" + "&lt;/span&gt;" + "&lt;span class='" + options.groupTitleCssClass + "' level='" + item.level + "'&gt;" + item.title + "&lt;/span&gt;"; } function defaultTotalsCellFormatter(row, cell, value, columnDef, item) { return (columnDef.groupTotalsFormatter &amp;&amp; columnDef.groupTotalsFormatter(item, columnDef)) || ""; } function init(grid) { _grid = grid; _grid.onClick.subscribe(handleGridClick); _grid.onKeyDown.subscribe(handleGridKeyDown); } function destroy() { if (_grid) { _grid.onClick.unsubscribe(handleGridClick); _grid.onKeyDown.unsubscribe(handleGridKeyDown); } } function handleGridClick(e, args) { let item = this.getDataItem(args.row); if (item &amp;&amp; item instanceof Slick.Group &amp;&amp; $(e.target).hasClass(options.toggleCssClass)) { let range = _grid.getRenderedRange(); this.getData().setRefreshHints({ ignoreDiffsBefore: range.top, ignoreDiffsAfter: range.bottom + 1 }); if (item.collapsed) { this.getData().expandGroup(item.groupingKey); } else { this.getData().collapseGroup(item.groupingKey); } e.stopImmediatePropagation(); e.preventDefault(); } } // TODO: add -/+ handling function handleGridKeyDown(e) { if (options.enableExpandCollapse &amp;&amp; (e.which == Slick.keyCode.SPACE)) { let activeCell = this.getActiveCell(); if (activeCell) { let item = this.getDataItem(activeCell.row); if (item &amp;&amp; item instanceof Slick.Group) { let range = _grid.getRenderedRange(); this.getData().setRefreshHints({ ignoreDiffsBefore: range.top, ignoreDiffsAfter: range.bottom + 1 }); if (item.collapsed) { this.getData().expandGroup(item.groupingKey); } else { this.getData().collapseGroup(item.groupingKey); } e.stopImmediatePropagation(); e.preventDefault(); } } } } function getGroupRowMetadata(item) { return { selectable: false, focusable: options.groupFocusable, cssClasses: options.groupCssClass, columns: { 0: { colspan: "*", formatter: options.groupFormatter, editor: null } } }; } function getTotalsRowMetadata(item) { return { selectable: false, focusable: options.totalsFocusable, cssClasses: options.totalsCssClass, formatter: options.totalsFormatter, editor: null }; } function getOptions() { return options; } return { init, destroy, getGroupRowMetadata, getTotalsRowMetadata, getOptions }; } </code></pre>
0debug
static void gen_partset_reg(int opsize, TCGv reg, TCGv val) { TCGv tmp; switch (opsize) { case OS_BYTE: tcg_gen_andi_i32(reg, reg, 0xffffff00); tmp = tcg_temp_new(); tcg_gen_ext8u_i32(tmp, val); tcg_gen_or_i32(reg, reg, tmp); break; case OS_WORD: tcg_gen_andi_i32(reg, reg, 0xffff0000); tmp = tcg_temp_new(); tcg_gen_ext16u_i32(tmp, val); tcg_gen_or_i32(reg, reg, tmp); break; case OS_LONG: case OS_SINGLE: tcg_gen_mov_i32(reg, val); break; default: qemu_assert(0, "Bad operand size"); break; } }
1threat
The Tomcat server is running properly but still error 404 is generated : <p><a href="http://i.stack.imgur.com/JNAOL.png" rel="nofollow">Server working fine but error landing on home page</a></p>
0debug
Header file for STL : <p>Is it a good and common practice to concentrate for example all STL includes within one header file? </p> <pre><code>// mystlheader.h //My STL Headerfile #pragma once #include &lt;vector&gt; #include &lt;list&gt; #include &lt;optional&gt; </code></pre> <p>And if I need a std::vector, std::list or any other STL stuff in my project I include only this file (#include "mystlheader.h"). </p> <p>Are there any drawbacks like header file pollution? </p>
0debug
Why we need --scripts-version : I am new to React and was learning how to properly create new project. Then I came across -scripts-version when we create new project with such command : "create-react-app new project -scripts version". Why do we need to use -scripts-version?
0debug
void qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id) { QXLCursor *cursor; fprintf(stderr, ": %s", qxl_name(qxl_cursor_cmd, cmd->type)); switch (cmd->type) { case QXL_CURSOR_SET: fprintf(stderr, " +%d+%d visible %s, shape @ 0x%" PRIx64, cmd->u.set.position.x, cmd->u.set.position.y, cmd->u.set.visible ? "yes" : "no", cmd->u.set.shape); cursor = qxl_phys2virt(qxl, cmd->u.set.shape, group_id); fprintf(stderr, " type %s size %dx%d hot-spot +%d+%d" " unique 0x%" PRIx64 " data-size %d", qxl_name(spice_cursor_type, cursor->header.type), cursor->header.width, cursor->header.height, cursor->header.hot_spot_x, cursor->header.hot_spot_y, cursor->header.unique, cursor->data_size); break; case QXL_CURSOR_MOVE: fprintf(stderr, " +%d+%d", cmd->u.position.x, cmd->u.position.y); break; } }
1threat
Struct method is setting field but they are not being "saved"? : <p>I know the title is confusing, and it is for me as well, as it says I have packets that decode binary data from byte buffers, each data value is set to a specific field of a struct. First I make a new struct of that type and call the "Decode" method: </p> <pre><code>text := packets.NewTextPacket() text.Buffer = bytes text.DecodeHeader() text.Decode() </code></pre> <p>The problem is that I specifically call the method called "Decode", here you can see what it does:</p> <pre><code>func (pk TextPacket) Decode() { pk.TextType = pk.GetByte() pk.Translation = pk.GetBool() switch pk.TextType { case Raw, Tip, System: pk.Message = pk.GetString() break case Chat, Whisper, Announcement: pk.Source = pk.GetString() pk.SourceThirdParty = pk.GetString() pk.SourcePlatform = pk.GetVarInt() pk.Message = pk.GetString() break case Translation, Popup, JukeboxPopup: pk.Message = pk.GetString() c := pk.GetUnsignedVarInt() for i := uint32(0); i &lt; c; i++ { pk.Params = append(pk.Params, pk.GetString()) } break } pk.Xuid = pk.GetString() pk.PlatformChatId = pk.GetString() } </code></pre> <p>When I print <code>pk.Message</code> inside <code>func (pk TextPacket) Decode()</code> it shows the correct string, but printing it after <code>text.Decode()</code> as <code>text.Message</code>, it shows the default value that is set when the struct is first made, which is an empty string, same goes for all the other fields such as <code>text.TextType</code>, etc.</p>
0debug
Is Python a suitable tool for automating data scraping? : <p>I am working on a project which involves working with a large amount of data. Essentially, there exists a large repository on some website of excel files that can be downloaded. The site has several different lists of filters and I have several different parameters I am filtering and then collecting data from. Overall, this process requires me to download upwards of 1,000+ excel files and copy and paste them together.</p> <p>Does Python have the functionality to automate this process? Essentially what I am doing is setting Filter 1 = A, Filter 2 = B, Filter 3 = C, download file, and then repeat with different parameters and copy and paste files together. If Python is suitable for this, can anyone point me in the direction of a good tutorial or starting point? If not, what language would be more suitable for this for someone with little background?</p> <p>Thanks!</p>
0debug
static void free_ahci_device(QPCIDevice *dev) { QPCIBus *pcibus = dev ? dev->bus : NULL; g_free(dev); qpci_free_pc(pcibus); }
1threat
c Making random number with a gap. i.e. 0-10, 30-40 : Im working on a school project where i have a road in the middle of the screen with offroad on each side. I need some obstacles to just appear offroad. To make it appear on both sides i need to generate a random number with a gap in the middle.
0debug
SQL Current_Timestamp Format : I'm learning MS SQL and have an update statement where the current date and time are inserted as follows: UPDATE data_table SET Date_Time_Cx=CURRENT_TIMESTAMP When it is populated in the DB, it appears "Feb 22 2018 5:07PM". How do I get to populate with the format "YYYY-MM-DD hh:mm:ss"? I looked through the SQL documents and lots of posts and it seems like it should be populating in the desired way. Where did I go wrong? Thanks!
0debug
Get uncommon elements from two list - KOTLIN : <p>I have two list of same model class (STUDENT), sample student object structure is given below, </p> <pre><code>{ "_id": "5a66d78690429a1d897a91ed", "division": "G", "standard": "X", "section": "Secondary", "lastName": "Sawant", "middleName": "Sandeep", "firstName": "Shraddha", "pin": 12345, "isEditable": true, "isTracked": false } </code></pre> <p>One list have 3 objects and other 2. lets say, List A has 1, 2, 3 students and List B has 1, 2</p> <p>So my question is there any inbuilt functions to get the uncommon element <strong>by comparing just the id</strong>? If not how can i solve this issue. </p> <p>FYI, following are the two approaches i have made to solve, but failed miserably. </p> <p>Approach 1.</p> <pre><code>internal fun getDistinctStudents(studentsList: List&lt;Students&gt;, prefStudents: List&lt;Students&gt;): List&lt;Students&gt; { val consolidated = prefStudents.filter { prefStudents.any { students: Students -&gt; it._id == students._id } } return prefStudents.minus(consolidated) } </code></pre> <p>Approach 2.</p> <pre><code>internal fun getDistinctStudents(studentsList: List&lt;Students&gt;, prefStudents: List&lt;Students&gt;): List&lt;Students&gt; { val consolidatedStudents = studentsList + prefStudents val distinctStudents = consolidatedStudents.distinctBy{ it._id } return prefStudents.minus(distinctStudents) } </code></pre> <p>Any kind of help will be greatly appreciated. </p> <p>Thanks </p>
0debug
My program crashes when i rotate my phone. : Im building a simple app, when the program starts the text blink and the song is played. when i rotate my phone it should change the landscape and restart the song. Im able to do the first part but it crashes when i change the landscape. It works if i remove the onPause method but when i do that music keeps on playing in the background and it also starts from the beginning. There is two songs playing at the same time import android.media.MediaPlayer; import android.os.Bundle; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity { MediaPlayer ourSong; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ourSong = MediaPlayer.create(this,R.raw.fixyou); ourSong.start(); blinkText(); } @Override protected void onPause(){ super.onPause(); ourSong.release(); finish(); } private void blinkText() { // TODO Auto-generated method stub final Handler handler = new Handler(); new Thread(new Runnable() { @Override public void run() { int timeToBlink = 500; //in ms try{ Thread.sleep(timeToBlink); }catch (Exception e) { } handler.post(new Runnable() { @Override public void run() { TextView txt = (TextView) findViewById(R.id.tv); if(txt.getVisibility() == View.VISIBLE){ txt.setVisibility(View.INVISIBLE); }else{ txt.setVisibility(View.VISIBLE); } blinkText(); } }); }}).start(); } }
0debug
ImgReSampleContext *img_resample_full_init(int owidth, int oheight, int iwidth, int iheight, int topBand, int bottomBand, int leftBand, int rightBand, int padtop, int padbottom, int padleft, int padright) { ImgReSampleContext *s; s = av_mallocz(sizeof(ImgReSampleContext)); if (!s) s->line_buf = av_mallocz(owidth * (LINE_BUF_HEIGHT + NB_TAPS)); if (!s->line_buf) goto fail; s->owidth = owidth; s->oheight = oheight; s->iwidth = iwidth; s->iheight = iheight; s->topBand = topBand; s->bottomBand = bottomBand; s->leftBand = leftBand; s->rightBand = rightBand; s->padtop = padtop; s->padbottom = padbottom; s->padleft = padleft; s->padright = padright; s->pad_owidth = owidth - (padleft + padright); s->pad_oheight = oheight - (padtop + padbottom); s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth; s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight; av_build_filter(&s->h_filters[0][0], (float) s->pad_owidth / (float) (iwidth - leftBand - rightBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0); av_build_filter(&s->v_filters[0][0], (float) s->pad_oheight / (float) (iheight - topBand - bottomBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0); return s; fail: av_free(s); }
1threat
Android Can't compress a recycled bitmap : I'm getting an image from a URL, I want to compress it and save it in the external memory device. I get this error java.lang.IllegalStateException: Can't compress a recycled bitmap at android.graphics.Bitmap.checkRecycled(Bitmap.java:400) at android.graphics.Bitmap.compress(Bitmap.java:1307) at this line mIcon11.compress(Bitmap.CompressFormat.JPEG, 40, bytes); --------------------------------------------------------------------- String foto = UT_drive_dropbox.AM.getfoto(); Bitmap mIcon11 = null; try { InputStream in = new java.net.URL(foto).openStream(); mIcon11 = BitmapFactory.decodeStream(in); } catch (Exception e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } final Bitmap output = Bitmap.createBitmap(mIcon11.getWidth(), mIcon11.getHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(output); final int color = Color.RED; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, mIcon11.getWidth(), mIcon11.getHeight()); final RectF rectF = new RectF(rect); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawOval(rectF, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(mIcon11, rect, rect, paint); mIcon11.recycle(); String fileName = "avatar.jpg"; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); mIcon11.compress(Bitmap.CompressFormat.JPEG, 40, bytes); File sd = new File(Environment.getExternalStorageDirectory(), getString(R.string.app_name) + File.separator + fileName); FileOutputStream fileOutputStream = null; try { sd.createNewFile(); fileOutputStream = new FileOutputStream(sd); fileOutputStream.write(bytes.toByteArray()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
0debug
static void pc_fw_add_pflash_drv(void) { QemuOpts *opts; QEMUMachine *machine; char *filename; if (bios_name == NULL) { bios_name = BIOS_FILENAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); opts = drive_add(IF_PFLASH, -1, filename, "readonly=on"); g_free(filename); if (opts == NULL) { return; } machine = find_default_machine(); if (machine == NULL) { return; } if (!drive_init(opts, machine->use_scsi)) { qemu_opts_del(opts); } }
1threat
packaging javascript based plug and play application : I am trying to build a plug and play web based application that I should be able to integrate with multiple other web applications (which are developed using AngalurJS\ ExtJS\ ReactJS etc). On click of a button, I should be able to launch a [sliding menu][1]. On this menu, I want to add Twitter like functionality. On the first half of the menu we will have a textbox (with features like autocomplete & hash tags). The second half with show a gird which will show already posted messages. The panel will be responsible to get and post data to server. The challenge is, I want to add this functionality to multiple other web applications with minimum configuration\changes. The consuming web applications should be able use this plugin with ease. Certain challenges I see is bootstrap does not play well with ExtJs framework & I may face similar issues with other JavaScript frameworks. **Questions:** 1. `How can I package this application?` It has a panel with third party plugins (for autocomplete & other features), CSS & JavaScript. I can use web pack or Browserify but I want to keep the solution clean & don't want to add unnecessary dependency. 2. The consumers should be able to consume the bundle\package with ease & just by adding some references (like my bundle, css file, jquery, bootstrap). I think, I can get the desired result with a simple ReactJs app, which I can bundle using web pack. But this will introduce other dependency. I want to keep the web application lite and simple. [1]: http://codepen.io/jasonhowmans/pen/dykhL
0debug
What is the quantifiable benefit of 64 bit for Visual Studio Code over 32 bit : <p>I'm not a hardware guy, but I know that Visual Studio in a 64 bit version issue request was declined by Microsoft stating that a 64 bit version would not have good performance.</p> <p>Two noticeable differences between the two that I feel are obvious is the code base. One began it's life in 1997, one would think that means more baggage on the Visual Studio side, less opportunities to have very modern application architecture and code and that may make it harder and possibly stuff may be built to perform on 32 bit and for some reason is not suitable for 64 bit? I don't know.</p> <p>Visual Studio Code on the other hand is an modern Electron app which means it pretty much just compiled HTML. CSS and JavaScript. I'm betting making a version of Visual Studio Code has little in the way of obstructions and although performance may not be something truly noticeable, why not?</p> <p><strong>P.S.</strong></p> <p><em>I still would like to understand what areas may be improved in performance and if that improvement is negligible to the a developer. Any additional info or fun facts you may know would be great I would like to have as much info as possible and I will update the question with any hard facts I uncover that are not mentioned.</em></p>
0debug
Unhandled event loop exception while m try to add second activity in android using eclipse : I m new in android app development..M using eclipse neon.2 for this..when m try to second activity in my project an error occur which says that Un handled event loopExceptio occur..another details of the error is as : [enter image description here][1] the details of the log file is as : [enter image description here][2] [1]: https://i.stack.imgur.com/Tc1b6.png [2]: https://i.stack.imgur.com/RlQMc.png plz help me to fix these errors..thnks
0debug
static void lx60_net_init(MemoryRegion *address_space, hwaddr base, hwaddr descriptors, hwaddr buffers, qemu_irq irq, NICInfo *nd) { DeviceState *dev; SysBusDevice *s; MemoryRegion *ram; dev = qdev_create(NULL, "open_eth"); qdev_set_nic_properties(dev, nd); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); sysbus_connect_irq(s, 0, irq); memory_region_add_subregion(address_space, base, sysbus_mmio_get_region(s, 0)); memory_region_add_subregion(address_space, descriptors, sysbus_mmio_get_region(s, 1)); ram = g_malloc(sizeof(*ram)); memory_region_init_ram(ram, OBJECT(s), "open_eth.ram", 16384, &error_abort); vmstate_register_ram_global(ram); memory_region_add_subregion(address_space, buffers, ram); }
1threat
How to load resource in cocoapods resource_bundle : <p>I have struggled a lot to how to load resource in cocoapods resource_bundle. </p> <p>The following is what i put in the <code>.podspecs</code> file.</p> <pre><code>s.source_files = 'XDCoreLib/Pod/Classes/**/*' s.resource_bundles = { 'XDCoreLib' =&gt; ['XDCoreLib/Pod/Resources/**/*.{png,storyboard}'] } </code></pre> <p>This is what I am trying to do from the main project.</p> <pre><code>let bundle = NSBundle(forClass: XDWebViewController.self) let image = UIImage(named: "ic_arrow_back", inBundle: bundle, compatibleWithTraitCollection: nil) print(image) </code></pre> <p>I did see the picture in the <code>XDCoreLib.bundle</code>, but it return a nil.</p>
0debug
How to retrieve the last row of a table and insert it into another table : <p>i want to retrieve a last row added in table A and insert all row into table B. The 2 table are in different database.My code:</p> <pre><code> $db=new PDO('mysql:host=localhost;dbname=service','root',''); $db1=new PDO('mysql:host=localhost;dbname=service1','root',''); $req = $db-&gt;query('SELECT * FROM `service`.`myusers` WHERE ID NOT IN (SELECT ID FROM `service1`.`myusers`)'); $reqt = $req-&gt;fetch(); $count = $req-&gt;rowCount(); if($count){ $db1-&gt;query('SET NAMES UTF8'); $reqa=$db1-&gt;prepare('insert into myusers values(?,?,?,?,?,?)'); $db1-&gt;query('SET NAMES UTF8'); $reqa-&gt;bindParam(1,$reqt['ID']); $reqa-&gt;bindParam(2,$reqt['Prénom']); $reqa-&gt;bindParam(3,$reqt['LastName']); $reqa-&gt;bindParam(4,$reqt['dateDebut']); $reqa-&gt;bindParam(5,$reqt['identifient']); $reqa-&gt;bindParam(6,$reqt['fid']); $reqa-&gt;execute(); return true; }else{ return false; } </code></pre> <p>But doesn't work.</p>
0debug
static void digic_load_rom(DigicBoardState *s, hwaddr addr, hwaddr max_size, const char *def_filename) { target_long rom_size; const char *filename; if (qtest_enabled()) { return; } if (bios_name) { filename = bios_name; } else { filename = def_filename; } if (filename) { char *fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, filename); if (!fn) { error_report("Couldn't find rom image '%s'.", filename); exit(1); } rom_size = load_image_targphys(fn, addr, max_size); if (rom_size < 0 || rom_size > max_size) { error_report("Couldn't load rom image '%s'.", filename); exit(1); } } }
1threat
Is this a good approach to random byte array genaration in C? : I know this kind of question has been already discussed here: http://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c But I wanted to share the way I implemented it just to know what people may think about it. #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <time.h> long int getNanoSecs(){ struct timespec unixtimespec; clock_gettime(CLOCK_REALTIME_COARSE, &unixtimespec); return unixtimespec.tv_nsec; } . . . unsigned char personal_final_token[PERSONAL_FINAL_TOKEN_SIZE_SIZE]; unsigned char pwd_ptr_ctr; srandom(getNanoSecs()*(getNanoSecs()&0xFF)); for(pwd_ptr_ctr=0;pwd_ptr_ctr<PERSONAL_FINAL_TOKEN_SIZE_SIZE;pwd_ptr_ctr++){ memset(personal_final_token+pwd_ptr_ctr,(random()^getNanoSecs())&0xFF,1); } just define PERSONAL_FINAL_TOKEN_SIZE_SIZE and you can generate a quite random token of the size you want.
0debug
static void load_symbols(struct elfhdr *hdr, int fd) { unsigned int i, nsyms; struct elf_shdr sechdr, symtab, strtab; char *strings; struct syminfo *s; struct elf_sym *syms; lseek(fd, hdr->e_shoff, SEEK_SET); for (i = 0; i < hdr->e_shnum; i++) { if (read(fd, &sechdr, sizeof(sechdr)) != sizeof(sechdr)) return; #ifdef BSWAP_NEEDED bswap_shdr(&sechdr); #endif if (sechdr.sh_type == SHT_SYMTAB) { symtab = sechdr; lseek(fd, hdr->e_shoff + sizeof(sechdr) * sechdr.sh_link, SEEK_SET); if (read(fd, &strtab, sizeof(strtab)) != sizeof(strtab)) return; #ifdef BSWAP_NEEDED bswap_shdr(&strtab); #endif goto found; } } return; found: s = malloc(sizeof(*s)); syms = malloc(symtab.sh_size); if (!syms) return; s->disas_strtab = strings = malloc(strtab.sh_size); if (!s->disas_strtab) return; lseek(fd, symtab.sh_offset, SEEK_SET); if (read(fd, syms, symtab.sh_size) != symtab.sh_size) return; nsyms = symtab.sh_size / sizeof(struct elf_sym); i = 0; while (i < nsyms) { #ifdef BSWAP_NEEDED bswap_sym(syms + i); #endif if (syms[i].st_shndx == SHN_UNDEF || syms[i].st_shndx >= SHN_LORESERVE || ELF_ST_TYPE(syms[i].st_info) != STT_FUNC) { nsyms--; if (i < nsyms) { syms[i] = syms[nsyms]; } continue; } #if defined(TARGET_ARM) || defined (TARGET_MIPS) syms[i].st_value &= ~(target_ulong)1; #endif i++; } syms = realloc(syms, nsyms * sizeof(*syms)); qsort(syms, nsyms, sizeof(*syms), symcmp); lseek(fd, strtab.sh_offset, SEEK_SET); if (read(fd, strings, strtab.sh_size) != strtab.sh_size) return; s->disas_num_syms = nsyms; #if ELF_CLASS == ELFCLASS32 s->disas_symtab.elf32 = syms; s->lookup_symbol = (lookup_symbol_t)lookup_symbolxx; #else s->disas_symtab.elf64 = syms; s->lookup_symbol = (lookup_symbol_t)lookup_symbolxx; #endif s->next = syminfos; syminfos = s; }
1threat
how to get date of the next sunday of the 24th day of the current month? [Excel VBA] : I need to get the date of the next Sunday of the month's 24th day. > For example, this October 2018 > > The Sunday following October 24, 2018 is October 28, 2018. > > Next example is November 2018 > > The Sunday following November 24, 2018 is November 25, 2018. Thank you!
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
Capturing Video with AVFoundation : <p>I've been looking around on Stack and I have found similar questions to this, but none have worked for me. I am a complete novice to Swift 3.0. Essentially what I'm trying to do is record a video using AVFoundation. So far I have managed to capture a still image, and this is the code I have so far</p> <pre><code>func beginSession() { do { let deviceInput = try AVCaptureDeviceInput(device: captureDevice) as AVCaptureDeviceInput if captureSession.inputs.isEmpty { self.captureSession.addInput(deviceInput) } stillImageOutput.outputSettings = [AVVideoCodecKey:AVVideoCodecJPEG] if captureSession.canAddOutput(stillImageOutput) { captureSession.addOutput(stillImageOutput) } } catch { print("error: \(error.localizedDescription)") } guard let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) else { print("no preview layer") return } self.view.layer.addSublayer(previewLayer) previewLayer.frame = self.view.layer.frame captureSession.startRunning() // Subviews self.view.addSubview(imgOverlay) self.view.addSubview(blur) self.view.addSubview(label) self.view.addSubview(Flip) self.view.addSubview(btnCapture) } </code></pre> <p>and </p> <pre><code> // SAVE PHOTO func saveToCamera() { if let videoConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) { stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (CMSampleBuffer, Error) in if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(CMSampleBuffer) { if let cameraImage = UIImage(data: imageData) { self.flippedImage = UIImage(cgImage: cameraImage.cgImage!, scale: cameraImage.scale, orientation: UIImageOrientation.rightMirrored) UIImageWriteToSavedPhotosAlbum(self.flippedImage, nil, nil, nil) } } }) } } </code></pre>
0debug
sed search for line and remove the first character of the following ten lines : <p>I have a file with links in it. the links are commented out. I would like to use sed or awk to search for a specific string and then remove the first character of the following ten lines. </p> <p>As far as I know, I can search with sed in the following way</p> <pre><code>sed -n '/StringToSearchFor/p' file </code></pre> <p>With awk I would write the following</p> <pre><code>awk '/pattern/ {print $1}' </code></pre> <p>But how could I delete the first character of the following ten lines?</p> <p>The manual page of sed and awk are a huge. So please do not point to them beside you have a search string for me.</p> <p>Thanks in advance.</p>
0debug
Get the value of <a> href using jQuery : <p>I have this <code>&lt;a&gt;</code> href attribute</p> <pre><code>&lt;a id="cancel" value="&lt;?php echo $subID;?&gt;" href="#"&gt;Cancel&lt;/a&gt; </code></pre> <p>and I need to get its value (<code>$subID</code>) and assign it to a JavaScript variable. How can I do that?</p>
0debug