problem
stringlengths
26
131k
labels
class label
2 classes
void s390x_tod_timer(void *opaque) { S390CPU *cpu = opaque; CPUS390XState *env = &cpu->env; env->pending_int |= INTERRUPT_TOD; cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); }
1threat
Can I rely to ISE Eiffel as a programming language to offer web services through a DB connection : <p>I'm actually working for a little company of 10 people on the area of solar panels solutions in Chile. Am working on linux since 20 years now. When I studied programing I studied a lot with Eiffel which I found really a great language. Since, I'm frustrated from a language to another missing a lot of great concepts it offers like </p> <ul> <li>real object (no string != String; ...)</li> <li>multi-inheritance</li> <li>polymorphism</li> <li>genericity</li> <li>contract. </li> </ul> <p>Working now with Java because </p> <ul> <li>its mostly free</li> <li>the community for tutorials and helps is huge</li> <li>its multi-platform </li> </ul> <p>I'm looking for the pros &amp; cons to convince the instances of my hierarchy (basically talking about justifying the price of the licences which are 1500$=>1y and 2000$=>2y) and to be a bit secured that I don't pretend I'll go with a solution I'll regret at term because it will be hard to get the support I need to get my solutions working. Is ISE Eiffel reliable for production use? Will I have to get hours of pain making work a solution?</p> <h2>What are the pros &amp; cons?</h2> <h2>Pros</h2> <ul> <li>Concepts helping me to write real good quality code (multi-inheritance, polymorphism, genericity, contract)</li> <li>Pleasure to develop with such good tools</li> <li>Quality and reliability of produced code</li> <li>...</li> </ul> <h2>Cons</h2> <ul> <li>Poor community, meaning few tutorials</li> <li>I'm not good in C so digging into the implementation of C libraries is something which will cost me (and to the company)</li> <li>Price is high and has to be justified</li> <li>My Curriculum will not be as well as if I have years of experience in Java</li> <li>Formation of other programmers won't be easy if as most of them dont know these concepts</li> <li>...</li> </ul>
0debug
Logging from ASP.NET 5 application hosted as Azure Web App : <p>I have an ASP.NET 5 Web API that I host in Azure as a Web App. I want to log messages from my code using Azure Diagnostics. There are multiple article including <a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-troubleshoot-visual-studio/#apptracelogs" rel="noreferrer">Azure docs</a> that suggest that it should be as easy as <code>System.Diagnostics.Trace.WriteLine</code> once enabled. The logs should show up under <code>LogsFiles/Application</code> and in log stream in Azure.</p> <p>I enabled application logging for the web app:</p> <p><a href="https://i.stack.imgur.com/P0cjl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/P0cjl.png" alt="enter image description here"></a></p> <p>But the following calls produces no logs:</p> <pre><code>System.Diagnostics.Trace.TraceError("TEST"); System.Diagnostics.Trace.TraceInformation("TEST"); System.Diagnostics.Trace.TraceWarning("TEST"); System.Diagnostics.Trace.WriteLine("TEST"); </code></pre> <p>I tried to manually define <code>TRACE</code> symbol, but with no luck:</p> <p><a href="https://i.stack.imgur.com/lp1N8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lp1N8.png" alt="enter image description here"></a></p> <p>I also tried to use the new <code>Microsoft.Extensions.Logging</code> framework and use <code>ILogger.Log</code> API, but without any results again:</p> <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Debug; var sourceSwitch = new SourceSwitch("Sandbox.AspNet5.ApiApp-Demo"); sourceSwitch.Level = SourceLevels.All; loggerFactory.AddTraceSource(sourceSwitch, new ConsoleTraceListener(false)); loggerFactory.AddTraceSource(sourceSwitch, new EventLogTraceListener("Application")); } </code></pre> <p>Any ideas on what am I doing wrong?</p>
0debug
addition of elements within an array in python while loop : I have a numpy array full of numbers which I want to add to each other. For example if the list is [2,3,4,5,6]. I want to add 3 to 2 (index 1 to 0) and the 4 to 3 (index 2 to 1) and so on. I've been stressing out trying to figure out a while statement which goes through the array doing the additions and then adding these to a new array. Any help or ideas for this would be great as I'm quite new to python and coding and am rather stuck.
0debug
how to solve the error_syntax error near '< ' : Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '<'. I get the above error message everytime I try to execute the query below. Please help!! UPDATE [dbo].[FM1] SET [Datum] = <Datum, smalldatetime,> ,[Gesamtzeit] = <Gesamtzeit, nvarchar(5),>
0debug
Storing value in memory node js : <p>I use a request to return a value in node js. I would like to store the value return in memory in node js. Besides, the value should be initialize on app start. How could it be achieved?</p>
0debug
Can't figure out whats the cause of seg fault : <p>Total C noob here. Having difficulty location the cause of this seg fault. I have tried running a debugger the <code>GBD</code> debugger but I can't figure out how to get it working. The function I'm trying to test removes the contents of an array, puts it in a linked list and then puts the values of the linked list into the second array given to the function. Heres my test and function code. </p> <h3>Test</h3> <pre><code>int test_transfer(void) { #define ARRAY_LENGTH 10 void *arr1[ARRAY_LENGTH]; for (int i = 0; i &lt; ARRAY_LENGTH; i++) { arr1[i] = &amp;i; } void *ptr; void *arr2[ARRAY_LENGTH]; for (int i = 0; i &lt; ARRAY_LENGTH; i++) { arr2[i] = ptr; } transfer(arr1, arr2, ARRAY_LENGTH, sizeof(int), add_to_front, remove_from_front); for (int i=0; i &lt; ARRAY_LENGTH; i++) { printf("%d\n", *((int *)arr2[i])); } return 0; } </code></pre> <h3>Transfer Function</h3> <pre><code>void transfer(void **arr1, void **arr2, int length, int size, void (*insert)(List *, void *), void* (*remove)(List *)) { List *list = List_create(); for (int i=0; i &lt; length; i++) { (*insert)(list, &amp;arr1[i]); } for (int i=0; i &lt; length; i++) { void *indexPtr = arr2 + i*size; indexPtr = (*remove)(list); } } </code></pre>
0debug
Sort by JSON field values : <p>I have a table with json values like this:</p> <p><strong>-Table 1</strong></p> <pre><code>id | name | data ------+----------+--------------- 1 | Test | {"city_id": 3, "email":"test@test.com", "city_name":"something"} 2 | Test 2 | {"city_id": 1, "email":"test2@test2.com", "city_name":"another"} 3 | Test 3 | {"city_id": 6, "email":"test3@test3.com", "city_name":"blahblah"} </code></pre> <p>Now I want <code>SELECT</code> records with <code>order by</code> <code>data.city_name</code>, so I use this code:</p> <pre><code>SELECT id, name, JSON_EXTRACT(data, 'city_name') AS cityName FROM table1 ORDER BY cityName ASC </code></pre> <p>but this query cannot sort my records correctly !</p> <p>P.S: <code>city_name</code> have UTF-8 characters.</p>
0debug
void usb_test_hotplug(const char *hcd_id, const int port, void (*port_check)(void)) { QDict *response; char *cmd; cmd = g_strdup_printf("{'execute': 'device_add'," " 'arguments': {" " 'driver': 'usb-tablet'," " 'port': '%d'," " 'bus': '%s.0'," " 'id': 'usbdev%d'" "}}", port, hcd_id, port); response = qmp(cmd); g_free(cmd); g_assert(response); g_assert(!qdict_haskey(response, "error")); if (port_check) { port_check(); } cmd = g_strdup_printf("{'execute': 'device_del'," " 'arguments': {" " 'id': 'usbdev%d'" "}}", port); response = qmp(cmd); g_free(cmd); g_assert(response); g_assert(qdict_haskey(response, "event")); g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); }
1threat
static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, uint32_t node, Error **errp) { Error *local_err = NULL; sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); uint64_t align = memory_region_get_alignment(mr); uint64_t size = memory_region_size(mr); uint64_t addr; if (size % SPAPR_MEMORY_BLOCK_SIZE) { error_setg(&local_err, "Hotplugged memory size must be a multiple of " "%lld MB", SPAPR_MEMORY_BLOCK_SIZE/M_BYTE); goto out; } pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err); if (local_err) { goto out; } addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr); goto out; } spapr_add_lmbs(dev, addr, size, node, &error_abort); out: error_propagate(errp, local_err); }
1threat
Palindrome check in python : <p>Hello to everyone on stack.</p> <p>I am trying to make a python program capable of searching for palindromes.</p> <p>If my inputs were simply words to evaluate, I would have had no problem writing the code </p> <pre><code>def ispalindrome(word): return word == word[::-1] </code></pre> <p>but I am trying to do more than this.</p> <p>I would like to check if a string 'contains' a palindrome</p> <p>for example,</p> <pre><code>&gt;&gt;&gt;ispalindrome('rapparee') rappar </code></pre> <p>How should I approach this problem?</p>
0debug
How to fetch second row from the CSV file using ruby : <p>The CSV file will be downloaded after clicking on the button present on the application and contains the same data as the table. Scenario-: I have to test the whether the data in the csv file contains the same data as the table contains on the application.</p>
0debug
Angular 2: NgFor without HTML Tag? : <p>i want to create a ngFor Loop without a div tag.</p> <p>Is this somehow possible? </p> <p>My Problem is, that when i use a div *ngFor the slider is broken.</p> <pre><code>&lt;ion-slides #secondSlider [options]="secondSlideOptions" (ionDidChange)="onSecondSlideChanged()"&gt; &lt;!-- This div should not be there --&gt; &lt;div *ngFor="let set of exercise.sets; let setNumber = index;"&gt; &lt;ion-slide&gt; ... &lt;/ion-slide&gt; &lt;ion-slide&gt; ... &lt;/ion-slide&gt; &lt;/div&gt; &lt;/ion-slides&gt; </code></pre> <p>Is there another way to use ngFor without that div container?</p> <p>Thanks a lot!</p>
0debug
Comparison of data types without using comparisons : <p>I would like to know how l can overload a function named void maximum to find the maximum of two integer or two double numbers. When passing one integer and one double number function it should print that double vs int or int vs double. And in this case comparisons are not allowed and user should not be asked for input.?</p>
0debug
double av_int2dbl(int64_t v){ if(v+v > 0xFFEULL<<52) return NAN; return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075); }
1threat
How to find linecount in Perl? : <p>How do I find out linecount in perl similar to what wc -l gives me. A method preferably that doesn't require reading the whole file.</p>
0debug
Read in a certain line only? : <p>I'm making a program to read in a configuration file and I only want to read certain lines. Example:</p> <p>config.txt:</p> <pre><code>This is a test configuration text file It isn't supposed to read this line or the line above it Read this line, but not the white space above or below it Don't read this line or the white space above or below it Read this line, but not the white space above or below it </code></pre> <p>I'm using your basic I/O:</p> <pre><code>FILE *File; File = fopen("config.txt", "r"); </code></pre>
0debug
static void target_setup_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { struct target_rt_sigframe *frame; abi_ulong frame_addr, return_addr; frame_addr = get_sigframe(ka, env); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { goto give_sigsegv; } __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); __put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp); __put_user(sas_ss_flags(env->xregs[31]), &frame->uc.tuc_stack.ss_flags); __put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size); target_setup_sigframe(frame, env, set); if (ka->sa_flags & TARGET_SA_RESTORER) { return_addr = ka->sa_restorer; } else { __put_user(0xd2801168, &frame->tramp[0]); __put_user(0xd4000001, &frame->tramp[1]); return_addr = frame_addr + offsetof(struct target_rt_sigframe, tramp); } env->xregs[0] = usig; env->xregs[31] = frame_addr; env->xregs[29] = env->xregs[31] + offsetof(struct target_rt_sigframe, fp); env->pc = ka->_sa_handler; env->xregs[30] = return_addr; if (info) { if (copy_siginfo_to_user(&frame->info, info)) { goto give_sigsegv; } env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info); env->xregs[2] = frame_addr + offsetof(struct target_rt_sigframe, uc); } unlock_user_struct(frame, frame_addr, 1); return; give_sigsegv: unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); }
1threat
What is Robust in java : <p>I know that <strong>Robust</strong> is a Feature of java programming language. But I don't know what is the exact meaning of it and how to any programmer benefited by it.</p>
0debug
Decode the string with the number of letter repeation : <p>I have a string "<strong>3A4B2GEF</strong>", need to decode it to "<strong>AAABBBBGGEF</strong>". If there is no number before letter, <strong>it means that repeat = 1</strong>. But in the output the maximum letters of string is 30, example "29A3B" output is:</p> <pre><code>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAB BB </code></pre>
0debug
static ssize_t nic_receive(NetClientState *nc, const uint8_t * buf, size_t size) { EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque; uint16_t rfd_status = 0xa000; #if defined(CONFIG_PAD_RECEIVED_FRAMES) uint8_t min_buf[60]; #endif static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; #if defined(CONFIG_PAD_RECEIVED_FRAMES) if (size < sizeof(min_buf)) { memcpy(min_buf, buf, size); memset(&min_buf[size], 0, sizeof(min_buf) - size); buf = min_buf; size = sizeof(min_buf); } #endif if (s->configuration[8] & 0x80) { logout("%p received while CSMA is disabled\n", s); return -1; #if !defined(CONFIG_PAD_RECEIVED_FRAMES) } else if (size < 64 && (s->configuration[7] & BIT(0))) { logout("%p received short frame (%zu byte)\n", s, size); s->statistics.rx_short_frame_errors++; return -1; #endif } else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & BIT(3))) { logout("%p received long frame (%zu byte), ignored\n", s, size); return -1; } else if (memcmp(buf, s->conf.macaddr.a, 6) == 0) { TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size)); } else if (memcmp(buf, broadcast_macaddr, 6) == 0) { TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size)); rfd_status |= 0x0002; } else if (buf[0] & 0x01) { TRACE(RXTX, logout("%p received multicast, len=%zu,%s\n", s, size, nic_dump(buf, size))); if (s->configuration[21] & BIT(3)) { } else { unsigned mcast_idx = e100_compute_mcast_idx(buf); assert(mcast_idx < 64); if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) { } else if (s->configuration[15] & BIT(0)) { rfd_status |= 0x0004; } else { TRACE(RXTX, logout("%p multicast ignored\n", s)); return -1; } } rfd_status |= 0x0002; } else if (s->configuration[15] & BIT(0)) { TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size)); rfd_status |= 0x0004; } else if (s->configuration[20] & BIT(6)) { unsigned mcast_idx = compute_mcast_idx(buf); assert(mcast_idx < 64); if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) { TRACE(RXTX, logout("%p accepted, multiple IA bit set\n", s)); } else { TRACE(RXTX, logout("%p frame ignored, multiple IA bit set\n", s)); return -1; } } else { TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size, nic_dump(buf, size))); return size; } if (get_ru_state(s) != ru_ready) { logout("no resources, state=%u\n", get_ru_state(s)); eepro100_rnr_interrupt(s); s->statistics.rx_resource_errors++; #if 0 assert(!"no resources"); #endif return -1; } eepro100_rx_t rx; pci_dma_read(&s->dev, s->ru_base + s->ru_offset, &rx, sizeof(eepro100_rx_t)); uint16_t rfd_command = le16_to_cpu(rx.command); uint16_t rfd_size = le16_to_cpu(rx.size); if (size > rfd_size) { logout("Receive buffer (%" PRId16 " bytes) too small for data " "(%zu bytes); data truncated\n", rfd_size, size); size = rfd_size; } #if !defined(CONFIG_PAD_RECEIVED_FRAMES) if (size < 64) { rfd_status |= 0x0080; } #endif TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n", rfd_command, rx.link, rx.rx_buf_addr, rfd_size)); stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status), rfd_status); stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size); #if 0 eepro100_er_interrupt(s); #endif if (s->configuration[18] & BIT(2)) { missing("Receive CRC Transfer"); return -1; } #if 0 assert(!(s->configuration[17] & BIT(0))); #endif pci_dma_write(&s->dev, s->ru_base + s->ru_offset + sizeof(eepro100_rx_t), buf, size); s->statistics.rx_good_frames++; eepro100_fr_interrupt(s); s->ru_offset = le32_to_cpu(rx.link); if (rfd_command & COMMAND_EL) { logout("receive: Running out of frames\n"); set_ru_state(s, ru_suspended); } if (rfd_command & COMMAND_S) { set_ru_state(s, ru_suspended); } return size; }
1threat
forms of same id in while loop - how to post formdata of user submitted form to php with jquery ajax : I have a while loop wich creates forms like: <?php $i = 1; while($i<10){ ?> <form id="update"> <tr> <th scope="row"><?php echo $i;?></th> <td></td> <td></td> <td></td> <td><input type="text" maxlength="5" class ="input-xs valid" name="plus" value=""></td> <td><input type="submit" name="submit" class="btn btn-info btn-sm" value="Update"></td> <td><input class="input-sm slip" name="slip" value="" disabled/></td> <td></td> </tr> </form> <?php $i++; } ?> I want to post the formdata of user submitted form with jquery ajax.
0debug
Changing font size on javaScript : Im currently trying to change the FontSize of the Letters "Se Habla Espanol" So Im relative New to Javascript .... And well during the process of the me playing with the website i got into the following problem. This is what i currently have... <body> <font color="yellow"> <script> function blinker() { $('.blinking').fadeOut(500); $('.blinking').fadeIn(500); } setInterval(blinker, 1000); </script> <center> <p class="blinking">se habla Espanol</p> </center> </font> </body> I was thinking of using the following code but it seem that is only responsive to HTML and not javascript <font size="+2">This is bigger text.</font> This is what i had in mind so my work is not really accurate everything is taken from the internet --This is what i attempted to do but didn't work : <center> <font size="+2"> <p class="blinking">se habla Espanol</p> </font> </center>
0debug
bool qemu_clock_has_timers(QEMUClockType type) { return timerlist_has_timers( main_loop_tlg.tl[type]); }
1threat
static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) { int k, e; int ch; if (id_aac == TYPE_CPE && sbr->bs_coupling) { float alpha = sbr->data[0].bs_amp_res ? 1.0f : 0.5f; float pan_offset = sbr->data[0].bs_amp_res ? 12.0f : 24.0f; for (e = 1; e <= sbr->data[0].bs_num_env; e++) { for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { float temp1 = exp2f(sbr->data[0].env_facs[e][k] * alpha + 7.0f); float temp2 = exp2f((pan_offset - sbr->data[1].env_facs[e][k]) * alpha); float fac = temp1 / (1.0f + temp2); sbr->data[0].env_facs[e][k] = fac; sbr->data[1].env_facs[e][k] = fac * temp2; } } for (e = 1; e <= sbr->data[0].bs_num_noise; e++) { for (k = 0; k < sbr->n_q; k++) { float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k] + 1); float temp2 = exp2f(12 - sbr->data[1].noise_facs[e][k]); float fac = temp1 / (1.0f + temp2); sbr->data[0].noise_facs[e][k] = fac; sbr->data[1].noise_facs[e][k] = fac * temp2; } } } else { for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) { float alpha = sbr->data[ch].bs_amp_res ? 1.0f : 0.5f; for (e = 1; e <= sbr->data[ch].bs_num_env; e++) for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++) sbr->data[ch].env_facs[e][k] = exp2f(alpha * sbr->data[ch].env_facs[e][k] + 6.0f); for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) for (k = 0; k < sbr->n_q; k++) sbr->data[ch].noise_facs[e][k] = exp2f(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs[e][k]); } } }
1threat
why only one filename is written in using ls > in shell script : I'm stacked in coding shell script in my RedHatOS. I tried to output filename using Regular expression as below。 #!/bin/bash ls -1r rrr* > /tmp/memo.txt and the result is this /tmp/memo.txt /tmp/rrr1.txt I want to descript all files on txt file like I did same thing in console $ls -1r rrr* > /tmp/memo.txt $cat /tmp/memo.txt and the result of cat command is this /tmp/rrr1.txt /tmp/rrr2.txt I don't understand what is happening,so please tell me why this occur and how to write all result of ls command. thanks.
0debug
static int load_refcount_block(BlockDriverState *bs, int64_t refcount_block_offset, void **refcount_block) { BDRVQcow2State *s = bs->opaque; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD); ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset, refcount_block); return ret; }
1threat
static void update_irq(struct HPETTimer *timer) { qemu_irq irq; int route; if (timer->tn <= 1 && hpet_in_legacy_mode()) { if (timer->tn == 0) { irq=timer->state->irqs[0]; } else irq=timer->state->irqs[8]; } else { route=timer_int_route(timer); irq=timer->state->irqs[route]; } if (timer_enabled(timer) && hpet_enabled()) { qemu_irq_pulse(irq); } }
1threat
DOS command to copy only files and not folders in a folder tree : Let's assume the following folder structure, c:\tab\file1.txt c:\tab\insidetab1\file2.txt c:\tab\insidetab2\file3.txt c:\tab\insidetab3\insidetab4\file4.txt I want to copy only files file1.txt,file2.txt,file3.txt,file4.txt to some destination. Basically i want to remove all folders and keep only files is my requirment. Is it even possible ?
0debug
void ff_check_pixfmt_descriptors(void){ int i, j; for (i=0; i<FF_ARRAY_ELEMS(av_pix_fmt_descriptors); i++) { const AVPixFmtDescriptor *d = &av_pix_fmt_descriptors[i]; if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags) continue; av_assert0(d->log2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); av_assert0(d->name && d->name[0]); av_assert0((d->nb_components==4 || d->nb_components==2) == !!(d->flags & PIX_FMT_ALPHA)); av_assert2(av_get_pix_fmt(d->name) == i); for (j=0; j<FF_ARRAY_ELEMS(d->comp); j++) { const AVComponentDescriptor *c = &d->comp[j]; if(j>=d->nb_components) av_assert0(!c->plane && !c->step_minus1 && !c->offset_plus1 && !c->shift && !c->depth_minus1); } } }
1threat
void ff_put_h264_qpel16_mc00_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { copy_width16_msa(src, stride, dst, stride, 16); }
1threat
Apache camel conditional routing didn't work : I am trying to transfer file by using apache camel conditional routing. The condition is if filename starts with "041PACS".It created a .camel diretory on source folder.But don't know why file didn't transfered to destination folder.There is no error in console. I am using camel 2.17.3 and jdk 1.7. I don't know how to solve it. If you have any kind of thoughts please share or if there is another way to do it please tell me.Its urgent. Thanks in advance. applicationContext.xml ======================= <?xml version="1.0" encoding="UTF-8"?> <beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.17.3.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> <import resource="actionRoutes.xml" /> <camelContext streamCache="true" xmlns="http://camel.apache.org/schema/spring"> <package>in.client.camelbean</package> <routeContextRef ref="actionRoutes" /> </camelContext> </beans> actionRoutes.xml ================== <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.17.3.xsd "> <!-- Only the routeContext is here --> <routeContext id="actionRoutes" xmlns="http://camel.apache.org/schema/spring"> <route id="route36"> <from uri="file:\\home\41\CAMEL\reports" /> <choice> <when> <simple>${header.CamelFileName.startsWith("041PACS")} == 'true'</simple> <to uri="file:\\home\41\CAMEL\result?noop=true" /> </when> </choice> </route> </routeContext> </beans>
0debug
Looking for a CMS with a Template and Content Element-System like Typo3 and Concrete5 : <p>Community!</p> <p>I know, these questions shouldn't be opinion-based and I'm certainly not asking "What's the best CMS???". I'm just at a point of having tried out so many different CMS that I want to know if there does exist one which meets the following criteria:</p> <h2>Very flexible template system, content elements, content columns</h2> <p><strong>I don't really like the complexity of designing with Fluid in TYPO3</strong>. I'm not a complete newbie in this area but it strikes me as being pretty complex, you have to know all these functions and knowledge in TypoScript doesn't have much use outside of TYPO3.</p> <p><strong>On the other hand, I feel the templating is with Fluid is done pretty well</strong>. You have your backend layouts where you define your content columns (name and number), where in your fluid layouts you specify which content column (here, the number is used) is rendered where. Inside the backend you apply your backend layout to your root page (it is inherited which I love because it makes changes easier than having to change the template of every single page!) and you can add your content to the column defined in this backend layout. I love this idea!</p> <p><strong>The point I like</strong> is that content can exist outside this structure - you can create a content element and have it just not being rendered because it has no layout column specified. Also if you ever want to change your layout, you can do so by provoding the same column numbers in a new backend layout. The name of the columns can be changed without problems - that's the problem with Concrete5.</p> <p><strong>In Concrete5</strong>, all content resided inside of the "areas" (quasi content columns) on the individual pages. But because Concrete5 has only inline-editing, you can't just change your area names (and they're visible for your editors so maybe you want to change them to a better name, even though there are some standards like 'main' this doesn't fit for Non-English speaking people who just edit content in their language). If you do, you can't access your content inside these areas anymore because it is coupled with the area names (I wonder why there's no ID-system and just a public visibly area name).</p> <p><strong>Another point is crappy code</strong> - I really don't like the output of some CMS very much, even if you can control it somehow, sometimes there are things like many lines of whitespace - really weird. Concrete5's inline-editing-feature is pretty cool, especially the ability to work with Bootstrap and visually layout your blocks to have two thirds to one third width or something like that. But on the other hand you have to have these header- and footer-includes to use Concrete5, so you HAVE to change the output on your site and have to use the div-wrapper to use inline-editing. I don't really have anything against it as long as it doesn't clutter the final output too much (and I think, Concrete5 is pretty ok in this regard).</p> <p><strong>I LOVE ModX in this regard</strong> because after experimenting just a little bit I actually got ONLY my html and the things I put in the page editor in the final source code. <strong>The problem with ModX is</strong>: there are no content elements/blocks, there are no content columns/areas - all you have is one big editor field. I know, you can adjust that pretty heavily, but in the end as far as I think it's not really meant to offer you the ability to define multiple areas where you can put different kind of elements inside, is it? Like "Header", "Text &amp; Media" or "Slider" in TYPO3/Concrete5, which you can hide (at least in TYPO3) and move on their own.</p> <p>(And if there is some good kind of version control, that would be great as well, but that's just a thing I like in TYPO3 and I don't like that much in Concrete5 because you can't really roll back changes to individual elements, just to the whole site - and you can't hide part of your content (hide some blocks like you hide content elements in TYPO3) to "save" an alternative version of, say, a header or a normal text element.)</p> <hr> <p><strong>Long story short</strong>, I'm looking for a <em>very flexible template system</em> which let's me design the way I want. It should have <em>individual content elements</em> (elements of different types, which I can create on my own as well) and <em>content areas</em> (/columns), so that I can place my content in different places which I can style individually. It should output only my code if possible (like ModX) and be open to changes (like renaming content columns/areas).</p> <p>Just to recap my problems I have with the named CMS:</p> <ul> <li>TYPO3: too complex to enjoy layouting with Fluid in my regard</li> <li>Concrete5: too tightly coupled (content is gone when you rename the areas in your layout, you can't access it anymore at all)</li> <li>ModX: Not really built for multiple content elements which reside in multiple content columns</li> </ul> <p>To not counteract the purpose of stackoverflow, I want to clarify that I'm not looking for every CMS in which the named things are POSSIBLE. Someone might say "You can totally do that in Drupal, just install these 200 modules and you're good to go!") but are actually intended (like content columns and content elements in TYPO3/Concrete5, especially in Concrete5 it feels very natural to work that way, you don't get a sense of having to hack the system for days just to have a good base for developing your site.</p> <p>I'm asking if there's a CMS available (it should be open-source/free) that actually supports these developing principles by it's nature. I hope you can help me and everyone looking for a CMS which supports this style of working! Thank you! :)</p>
0debug
int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate) { MPADecodeContext s1, *s = &s1; s1.avctx = avctx; if (ff_mpa_check_header(head) != 0) return -1; if (ff_mpegaudio_decode_header(s, head) != 0) { return -1; } switch(s->layer) { case 1: avctx->frame_size = 384; break; case 2: avctx->frame_size = 1152; break; default: case 3: if (s->lsf) avctx->frame_size = 576; else avctx->frame_size = 1152; break; } *sample_rate = s->sample_rate; avctx->channels = s->nb_channels; avctx->bit_rate = s->bit_rate; avctx->sub_id = s->layer; return s->frame_size; }
1threat
How can I remove a file from Git within IntelliJ VCS? : <p>VCS has an <code>Add</code> option (Git Add) but seems to lack Git Remove.</p> <p>What's the idiomatic way to Git Remove with VCS?</p>
0debug
Twitch API login authorization : I'm trying to make a login trough Twitch API, but I have a few problems with a code. The code was written by BarryCarlyon, and copied from this forum https://discuss.dev.twitch.tv/t/authorization-code-flow/5148/12 . I'm not that familiar with the Twitch API, and my PHP knowledge only goes so far. I belive the problem occur at `if ($i['http_code'] == 200)`, or somewhere in this region: if ($i['http_code'] == 200) { $result = json_decode($result, true); // get $curl = curl_init('https://api.twitch.tv/kraken/user'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Accept: application/vnd.twitchtv.v3+json', 'Client-ID: ' . $client_id, 'Authorization: OAuth ' . $result['access_token'] )); $user = curl_exec($curl); $i = curl_getinfo($curl); curl_close($curl); if ($i['http_code'] == 200) { $user = json_decode($user); echo '<p>Thanks ' . $user->display_name . ' <3</p>'; // THE USER IS LOGGED IN } else { echo '<p>An error occured, please <a href="/">click here and try again</a></p>'; } The full code: $client_id = 'YourID'; $client_secret = 'YourSecret'; $redirect_uri = 'http://someplace/'; if ($_GET['code']) { $token_url = 'https://api.twitch.tv/kraken/oauth2/token'; $data = array( 'client_id' => $client_id, 'client_secret' => $client_secret, 'grant_type' => 'authorization_code', 'redirect_uri' => $redirect_uri, 'code' => $_GET['code'] ); $curl = curl_init($token_url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); $i = curl_getinfo($curl); curl_close($curl); if ($i['http_code'] == 200) { $result = json_decode($result, true); // get $curl = curl_init('https://api.twitch.tv/kraken/user'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Accept: application/vnd.twitchtv.v3+json', 'Client-ID: ' . $client_id, 'Authorization: OAuth ' . $result['access_token'] )); $user = curl_exec($curl); $i = curl_getinfo($curl); curl_close($curl); if ($i['http_code'] == 200) { $user = json_decode($user); echo '<p>Thanks ' . $user->display_name . ' <3</p>'; // THE USER IS LOGGED IN } else { echo '<p>An error occured, please <a href="/">click here and try again</a></p>'; } } else { echo '<p>An error occured, please <a href="/">click here and try again</a></p>'; } } else { $scopes = array( 'user_read' => 1, ); $req_scope = ''; foreach ($scopes as $scope => $allow) { if ($allow) { $req_scope .= $scope . '+'; } } $req_scope = substr($req_scope, 0, -1); $auth_url = 'https://api.twitch.tv/kraken/oauth2/authorize?response_type=code'; $auth_url .= '&client_id=' . $client_id; $auth_url .= '&redirect_uri=' . $redirect_uri; $auth_url .= '&scope=' . $req_scope; $auth_url .= '&force_verify=true'; echo '<a href="' . $auth_url . '">Please Click this Link to Authenticate with Twitch</a>'; }
0debug
void qdict_put_obj(QDict *qdict, const char *key, QObject *value) { unsigned int hash; QDictEntry *entry; hash = tdb_hash(key) % QDICT_HASH_SIZE; entry = qdict_find(qdict, key, hash); if (entry) { qobject_decref(entry->value); entry->value = value; } else { entry = alloc_entry(key, value); LIST_INSERT_HEAD(&qdict->table[hash], entry, next); } qdict->size++; }
1threat
Flatmapping in Java : Given the following two dimensional array int[][] arr = {{1, 2}, {3, 4}, {5, 6}}; What is the most elegant way in java to flatmap this to the following form int[] arr = {1, 3, 5, 2, 4, 6}; It can be assumed that all the nested arrays are of same length.
0debug
def extract_min_max(test_tup, K): res = [] test_tup = list(test_tup) temp = sorted(test_tup) for idx, val in enumerate(temp): if idx < K or idx >= len(temp) - K: res.append(val) res = tuple(res) return (res)
0debug
static inline void tcg_out_ext8u(TCGContext *s, int dest, int src) { assert(src < 4 || TCG_TARGET_REG_BITS == 64); tcg_out_modrm(s, OPC_MOVZBL + P_REXB_RM, dest, src); }
1threat
static void audio_reset_timer (AudioState *s) { if (audio_is_timer_needed ()) { timer_mod (s->ts, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks); } else { timer_del (s->ts); } }
1threat
How to variable in Object.keys : i'm trying to use use Object.keys in a map function but i'm getting keys based on map value variable but it's giving me error [my data object][1] as you can see i'm trying to get the keys of Display and coin value from map variable and the coin value is in the array at the end but it's giving me error in short i'm want to get the keys of every object in display child object and display child key will be from my coin name array so i don't have to hardcode it [1]: https://i.stack.imgur.com/s86ri.png {this.props.crypto_head_coins.map(coin => { return ( <div key={coin} className="crypto_head"> <span>{coin} </span> {console.log(Object.keys(this.props.crypto_head_data.DISPLAY.coin))} <p>{this.props.crypto_head_data.DISPLAY.BTC.USD.PRICE}</p> </div> ); })}
0debug
What are atomic operations for newbies? : <p>I am a newbie to operating systems and every answer I've found on Stackoverflow is so complicated that I am unable to understand. Can someone provide an explanation for what is an </p> <blockquote> <p>atomic operation</p> </blockquote> <p>For a newbie?</p> <p><strong>My understanding:</strong> My understanding is that <code>atomic operation</code> means it executes fully with <strong>no interruption</strong>? Ie, it is a <strong>blocking</strong> operation with no scope of interruption?</p>
0debug
Is there a way to use --esModuleInterop in tsconfig as opposed to it being a flag? : <p>Typescript v 2.7 released really neat flag called <code>--esModuleInterop</code> <a href="https://www.typescriptlang.org/docs/handbook/compiler-options.html" rel="noreferrer">https://www.typescriptlang.org/docs/handbook/compiler-options.html</a>, I am trying to figure out if there is a way to use it with <code>tsconfig.json</code> as currently it doesn't seem to be documented : <a href="http://www.typescriptlang.org/docs/handbook/tsconfig-json.html" rel="noreferrer">http://www.typescriptlang.org/docs/handbook/tsconfig-json.html</a></p> <p>Unless it somehow works with <code>module?</code></p> <p>Main use case I want to achieve is to be able to import things like this</p> <p><code>import React from "react"</code></p> <p>as opposed to </p> <p><code>import * as React from "react"</code></p> <p>And do so from my tsconfig if possible</p>
0debug
Override .dockerignore file when using ADD : <p>I have one Rockerfile that builds 4 images; I also have one central <code>.dockerignore</code> file. For one of the images I require assets that are blocked by the <code>.dockerignore</code> file -- is there a way when doing <code>ADD</code> or <code>COPY</code> to force add / ignore this list?</p> <p>It'll be a lot easier to do this in one file as opposed to three separate...!</p>
0debug
How to convert a string (describing arrays) into an array in python : <p>I have this string:</p> <pre><code>'[[57.7322273254, -58.8288497925, -54.460193634, 28.4842605591, -45.9620323181, -13.6266260147, -17.2981243134, -15.1332969666, -15.1287126541, -2.44765377045, -0.488036692142, -9.05566310883, -4.70651531219], [72.5999526978, -83.4902877808, -16.4493045807, 40.4356307983, -33.9553756714, -10.7394323349, -17.31067276, -15.6521835327, -25.1421508789, -13.1496963501, -4.11457395554, -14.9144859314, -5.76139545441]]' </code></pre> <p>I would like to convert this string into a numpy array of arrays</p>
0debug
static inline int decode_hrd_parameters(H264Context *h, SPS *sps) { int cpb_count, i; cpb_count = get_ue_golomb_31(&h->gb) + 1; if (cpb_count > 32U) { av_log(h->avctx, AV_LOG_ERROR, "cpb_count %d invalid\n", cpb_count); return AVERROR_INVALIDDATA; } get_bits(&h->gb, 4); get_bits(&h->gb, 4); for (i = 0; i < cpb_count; i++) { get_ue_golomb_long(&h->gb); get_ue_golomb_long(&h->gb); get_bits1(&h->gb); } sps->initial_cpb_removal_delay_length = get_bits(&h->gb, 5) + 1; sps->cpb_removal_delay_length = get_bits(&h->gb, 5) + 1; sps->dpb_output_delay_length = get_bits(&h->gb, 5) + 1; sps->time_offset_length = get_bits(&h->gb, 5); sps->cpb_cnt = cpb_count; return 0; }
1threat
How to convert timestamp from a String in Swift 3? : consider the string like "2017-08-30T06:40:00.000+00:00" 1 - How to convert this string into timestamp 2 - How to group this input into time slots (for eg, if the input is time = 2:30 PM, it will be grouped into the slot of 2pm to 3pm)
0debug
How to reset keys after unsetting values in an array? : <p>Take the following array:</p> <pre><code>$fruits = [ 'apple', 'banana', 'grapefruit', 'orange', 'melon' ]; </code></pre> <p>Grapefruits are just disgusting, so I would like to unset it.</p> <pre><code>$key = array_search('grapefruit', $fruit); unset($fruit[$key]); </code></pre> <p>The grapefruit is out of my <code>$fruit</code> array but my keys are no longer numbered correctly.</p> <pre><code>array(4) { [0] =&gt; 'apple' [1] =&gt; 'banana' [3] =&gt; 'orange' [4] =&gt; 'melon' } </code></pre> <p>I Could loop through the array and create a new one but I was wondering if there's a simpler method to reset the keys.</p>
0debug
static int img_amend(int argc, char **argv) { Error *err = NULL; int c, ret = 0; char *options = NULL; QemuOptsList *create_opts = NULL; QemuOpts *opts = NULL; const char *fmt = NULL, *filename, *cache; int flags; bool quiet = false, progress = false; BlockBackend *blk = NULL; BlockDriverState *bs = NULL; cache = BDRV_DEFAULT_CACHE; for (;;) { c = getopt(argc, argv, "ho:f:t:pq"); if (c == -1) { break; } switch (c) { case 'h': case '?': help(); break; case 'o': if (!is_valid_option_list(optarg)) { error_report("Invalid option list: %s", optarg); ret = -1; goto out; } if (!options) { options = g_strdup(optarg); } else { char *old_options = options; options = g_strdup_printf("%s,%s", options, optarg); g_free(old_options); } break; case 'f': fmt = optarg; break; case 't': cache = optarg; break; case 'p': progress = true; break; case 'q': quiet = true; break; } } if (!options) { error_exit("Must specify options (-o)"); } if (quiet) { progress = false; } qemu_progress_init(progress, 1.0); filename = (optind == argc - 1) ? argv[argc - 1] : NULL; if (fmt && has_help_option(options)) { ret = print_block_option_help(filename, fmt); goto out; } if (optind != argc - 1) { error_report("Expecting one image file name"); ret = -1; goto out; } flags = BDRV_O_FLAGS | BDRV_O_RDWR; ret = bdrv_parse_cache_flags(cache, &flags); if (ret < 0) { error_report("Invalid cache option: %s", cache); goto out; } blk = img_open("image", filename, fmt, flags, true, quiet); if (!blk) { ret = -1; goto out; } bs = blk_bs(blk); fmt = bs->drv->format_name; if (has_help_option(options)) { ret = print_block_option_help(filename, fmt); goto out; } if (!bs->drv->create_opts) { error_report("Format driver '%s' does not support any options to amend", fmt); ret = -1; goto out; } create_opts = qemu_opts_append(create_opts, bs->drv->create_opts); opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); if (options) { qemu_opts_do_parse(opts, options, NULL, &err); if (err) { error_report_err(err); ret = -1; goto out; } } qemu_progress_print(0.f, 0); ret = bdrv_amend_options(bs, opts, &amend_status_cb); qemu_progress_print(100.f, 0); if (ret < 0) { error_report("Error while amending options: %s", strerror(-ret)); goto out; } out: qemu_progress_end(); blk_unref(blk); qemu_opts_del(opts); qemu_opts_free(create_opts); g_free(options); if (ret) { return 1; } return 0; }
1threat
static void gen_addc(DisasContext *dc, TCGv dest, TCGv srca, TCGv srcb) { TCGv t0 = tcg_const_tl(0); TCGv res = tcg_temp_new(); TCGv sr_cy = tcg_temp_new(); TCGv sr_ov = tcg_temp_new(); tcg_gen_shri_tl(sr_cy, cpu_sr, ctz32(SR_CY)); tcg_gen_andi_tl(sr_cy, sr_cy, 1); tcg_gen_add2_tl(res, sr_cy, srca, t0, sr_cy, t0); tcg_gen_add2_tl(res, sr_cy, res, sr_cy, srcb, t0); tcg_gen_xor_tl(sr_ov, srca, srcb); tcg_gen_xor_tl(t0, res, srcb); tcg_gen_andc_tl(sr_ov, t0, sr_ov); tcg_temp_free(t0); tcg_gen_mov_tl(dest, res); tcg_temp_free(res); tcg_gen_shri_tl(sr_ov, sr_ov, TARGET_LONG_BITS - 1); tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_cy, ctz32(SR_CY), 1); tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_ov, ctz32(SR_OV), 1); gen_ove_cyov(dc, sr_ov, sr_cy); tcg_temp_free(sr_ov); tcg_temp_free(sr_cy); }
1threat
What is difference between "git push" and "a pull request"? : <p>I already figured out the following part of workflow of git: you do git add and then git commit and then git push. The git push step basically publish your changes to the github. So what is this next step commonly referred to as "pull request"? Suppose that I'm not "forking" or anything advanced. And suppose that I work on a new branch I created (named "dev") other than the master branch. And I did the add, commit, push all under this new branch and did not do any "merge". How do I do a "pull request" and what is that step supposed to accomplish beyond git add, commit, push. Does that just mean I merge "dev" to "master"?</p>
0debug
Code to reverse a string: "Undefined symbols for architecture x86_64" : <p>I'm writing a function to reverse a string, but I keep on getting the error "Undefined symbols for architecture x86_64" when compiling (clang). Here is my code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; char* reverse(string input); int main() { char* output; output = reverse("abcd"); cout &lt;&lt; *output; } char* reverse(char* input) { char* reversed; reversed = new char(sizeof(input) - 1); for(int i = 0; i != '\0'; i++) { char* j = reversed + sizeof(input - 1); input[i] = *j; j++; } return reversed; } </code></pre> <p>Specifically, this is what the compiler prints:</p> <pre><code>Undefined symbols for architecture x86_64: "reverse(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;)", referenced from: _main in test-c5860d.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [test] Error 1 </code></pre> <p>I'm sure that there are also logic errors in my code, but I'd like to have it compile and run at least before I debug those. Thanks!</p>
0debug
Sorting array with "linear" order : I need to sort an array in "linear" order like this example: var a = [510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 402, 402, 510, 510, 510, 510, 64, 510, 73, 510, 510, 510, 73, 510, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 64, 73, 73, 73, 73, 73, 73, 73, 64, 73, 73, 73, 73, 73, 64, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73]; output -> [510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 402, 402, 64, 64, 64, 64, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73]
0debug
static void rom_reset(void *unused) { Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; } if (rom->data == NULL) continue; cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize); if (rom->isrom) { qemu_free(rom->data); rom->data = NULL; } } }
1threat
Change td cell colour based on a number typed into an input field : <p>I have a form. In the form I have number input fields. The minimum number is 1 and the maximum is 5. All good so far. The use puts in a number (between 1-5) based on a risk assessment. 1 being low risk and 5 being high risk. If the user puts in a 1 I want the cell that the input field is in to turn green. If they input 5 I want it to turn red. The colour can start as green when the form first appears (though I am happy for it to be no colour until the field is first populated) numbers 1 and 2 are both green. 3 changes to yellow 4 to orange then 5 to red. Sounds simple enough but Im a little lost. Can someone take me by the hand and lead me through it. I have researched it but I have not found anything that gets me any closer. </p>
0debug
static void RENAME(resample_one)(DELEM *dst, const DELEM *src, int dst_size, int64_t index2, int64_t incr) { int dst_index; for (dst_index = 0; dst_index < dst_size; dst_index++) { dst[dst_index] = src[index2 >> 32]; index2 += incr; } }
1threat
static struct mm_struct *vma_init(void) { struct mm_struct *mm; if ((mm = qemu_malloc(sizeof (*mm))) == NULL) return (NULL); mm->mm_count = 0; TAILQ_INIT(&mm->mm_mmap); return (mm); }
1threat
MSSQL Simple query to include all columns based upon the MAX of one. I feel dumb : I've read through a lot of other articles and at this point I think I'm just beating my head against a wall. If any of you could explain how I would replace this statement SELECT * FROM EmployeeInformation I want to see all columns in table EmployeeInformation with ONLY the most recent RateChangeDate. I've tried MAX(RateChangeDate) and I'm just having no luck. An acceptable output with be as follows; Walters, Rob Senior Tool Designer 29.8462 2011-12-15 00:00:00.000 rob0@adventure-works.com [MSSQL Query][1] [1]: https://i.stack.imgur.com/Mdz07.png
0debug
Looping through certain files in a folder and running command on them while and also change the file name : <p>beginner here. I want to write a simple script for use in the bash terminal, but I don't know how to make it. The gist is that I have a folder filled with different files, some .foo, some .bar, etc. I want to create a script that takes all the .foo files and perform a command on them, but in the same line rename them so that the output file is named file.baz. </p> <p>For example: command -i file.foo -o file.baz for all .foo files in a directory.</p>
0debug
Select rows with duplicate values on 1 column SQL : Using SQL Server, I have : DATE Cookie ======================= 1 10/04/2018 123 2 10/05/2018 123 3 10/06/2018 321 4 10/07/2018 123 What i want : DATE Cookie ======================= 3 10/06/2018 321 i really need some help, thanks guys.
0debug
static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, const char *language, kbd_layout_t *k) { FILE *f; char * filename; char line[1024]; int len; filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language); f = filename ? fopen(filename, "r") : NULL; g_free(filename); if (!f) { fprintf(stderr, "Could not read keymap file: '%s'\n", language); return NULL; } if (!k) { k = g_malloc0(sizeof(kbd_layout_t)); } for(;;) { if (fgets(line, 1024, f) == NULL) { break; } len = strlen(line); if (len > 0 && line[len - 1] == '\n') { line[len - 1] = '\0'; } if (line[0] == '#') { continue; } if (!strncmp(line, "map ", 4)) { continue; } if (!strncmp(line, "include ", 8)) { parse_keyboard_layout(table, line + 8, k); } else { char *end_of_keysym = line; while (*end_of_keysym != 0 && *end_of_keysym != ' ') { end_of_keysym++; } if (*end_of_keysym) { int keysym; *end_of_keysym = 0; keysym = get_keysym(table, line); if (keysym == 0) { } else { const char *rest = end_of_keysym + 1; int keycode = strtol(rest, NULL, 0); if (strstr(rest, "numlock")) { add_to_key_range(&k->keypad_range, keycode); add_to_key_range(&k->numlock_range, keysym); } if (strstr(rest, "shift")) { keycode |= SCANCODE_SHIFT; } if (strstr(rest, "altgr")) { keycode |= SCANCODE_ALTGR; } if (strstr(rest, "ctrl")) { keycode |= SCANCODE_CTRL; } add_keysym(line, keysym, keycode, k); if (strstr(rest, "addupper")) { char *c; for (c = line; *c; c++) { *c = qemu_toupper(*c); } keysym = get_keysym(table, line); if (keysym) { add_keysym(line, keysym, keycode | SCANCODE_SHIFT, k); } } } } } } fclose(f); return k; }
1threat
Calculating leap years : <p>I have an assignment that is supposed to calculate whether a year that the user inputs is in fact a leap year. I cannot figure out the formula for this. Can anyone help? I can figure out the rest of the code but here is what is needed:</p> <p><strong>The month of February normally has 28 days. But if it is a leap year, February has 29 days. Write a program that asks the user to enter a year. The program should then display the number of days in February that year. Use the following criteria to identify leap years: 1. Determine whether the year is divisible by 100. If it is, then it is a leap year if and only if it is also divisible by 400. For example, 2000 is a leap year, but 2100 is not. 2. If the year is not divisible by 100, then it is a leap year if and only if it is divisible by 4. For example, 2008 is a leap year, but 2009 is not.</strong></p>
0debug
How does Lombok.val actually work? : <p><a href="https://projectlombok.org/features/val.html" rel="noreferrer">Lombok.val</a> allows you to </p> <blockquote> <p>use val as the type of a local variable declaration instead of actually writing the type. When you do this, the type will be inferred from the initializer expression. The local variable will also be made final.</p> </blockquote> <p>So instead of </p> <pre><code>final ArrayList&lt;String&gt; example = new ArrayList&lt;String&gt;(); </code></pre> <p>You can write</p> <pre><code>val example = new ArrayList&lt;String&gt;(); </code></pre> <hr> <p>I've tried to do some research into how this actually works but there doesn't seem to be a huge amount of information. Looking at <a href="https://github.com/rzwitserloot/lombok/blob/master/src/core/lombok/val.java" rel="noreferrer">the github page</a>, I can see that <code>val</code> is an annotation type. The annotation <em>type</em> is then used, rather than an actual annotation.</p> <p>I wasn't even aware you could even use annotation types in this manner but upon testing it the following code is indeed valid. However, I'm still not sure why you would ever want to use the type in this way.</p> <pre><code>public class Main { public @interface Foo { } public static void main(String... args) { Foo bar; System.out.println("End"); } } </code></pre> <p>How does Lombok process these usages if they are not annotations, but annotation <em>types</em>? To my (obviously incorrect) understanding, the syntax should look more like:</p> <pre><code>@Val foo = new ArrayList&lt;String&gt;(); </code></pre> <p>(I'm aware constraints of annotations mean the above is not valid syntax)</p>
0debug
Flutter layout without AppBar : <p>I need a layout without an appbar, so the most obvious approach is to just leave out the <code>appbar</code> tag on the <code>Scaffold</code> but if I do that the content goes underneath the status bar like this:</p> <p><a href="https://i.stack.imgur.com/j1AzG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/j1AzG.png" alt="enter image description here"></a></p> <p>As you can see my container which is colored in blue starts right from underneath the status bar which shouldn't be the case, so I had to manually set the margin of the container which is not so nice, this is the results:</p> <p><a href="https://i.stack.imgur.com/keN2R.png" rel="noreferrer"><img src="https://i.stack.imgur.com/keN2R.png" alt="enter image description here"></a></p> <p>I have this feeling that devices might have status bars with varying heights so setting my top margin to fixed size might not render properly on other devices. Is there a way for flutter to position my content automatically below the status like it positions the <code>AppBar</code> nicely below the status bar.</p> <p>Here is my scaffold code:</p> <pre><code>return new Scaffold( body: new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: &lt;Widget&gt;[ new HeaderLayout(), ], ), ); </code></pre> <p>This is my header container:</p> <pre><code>class HeaderLayout extends StatelessWidget{ @override Widget build(BuildContext context) { return new Container( color: Colors.blue, margin: const EdgeInsets.only(top: 30.0), child: new SizedBox( height: 80.0, child: new Center( child: new Text( "Recommended Courses", style: new TextStyle(color: Colors.white), ), ), ) ); } } </code></pre>
0debug
Multiprocessing : use tqdm to display a progress bar : <p>To make my code more "pythonic" and faster, I use "multiprocessing" and a map function to send it a) the function and b) the range of iterations.</p> <p>The implanted solution (i.e., call tqdm directly on the range tqdm.tqdm(range(0, 30)) does not work with multiprocessing (as formulated in the code below). </p> <p>The progress bar is displayed from 0 to 100% (when python reads the code?) but it does not indicate the actual progress of the map function.</p> <p><strong>How to display a progress bar that indicates at which step the 'map' function is ?</strong></p> <pre><code>from multiprocessing import Pool import tqdm import time def _foo(my_number): square = my_number * my_number time.sleep(1) return square if __name__ == '__main__': p = Pool(2) r = p.map(_foo, tqdm.tqdm(range(0, 30))) p.close() p.join() </code></pre> <p>Any help or suggestions are welcome...</p>
0debug
ESLint --fix not editing files : <p>I am trying to lint and fix my code using ESLint. When I run ESLint with my config file and without the fix flag, it runs fine, and this is what it outputs. </p> <p>eslint-c .eslintrc.json ./src/aura/SearchAvailableNumbers</p> <pre><code>/home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js 8:9 error Unexpected blank line after variable declarations newline-after-var 15:13 error 'hlp' is defined but never used no-unused-vars 50:30 error 'helper' is defined but never used no-unused-vars 55:32 error 'helper' is defined but never used no-unused-vars 59:42 error 'helper' is defined but never used no-unused-vars 69:7 error Expected { after 'if' condition curly 69:22 error Expected '===' and instead saw '==' eqeqeq 71:22 error Expected '===' and instead saw '==' eqeqeq 76:22 error Expected '===' and instead saw '==' eqeqeq 84:50 error Object properties must go on a new line object-property-newline 89:21 error Expected '===' and instead saw '==' eqeqeq 113:27 error 'appEvent' is already defined no-redeclare /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js 14:17 error Gratuitous parentheses around expression no-extra-parens 23:17 error 'appEvent' is defined but never used no-unused-vars 24:28 error Expected '===' and instead saw '==' eqeqeq 28:28 error Expected '===' and instead saw '==' eqeqeq 32:28 error Expected '===' and instead saw '==' eqeqeq </code></pre> <p>All of that information is correct, and are issues that must be fixed in the code. So I run it again, this time with </p> <p>eslint --fix --debug -c .eslintrc.json ./src/aura/SearchAvailableNumbers</p> <p>Now the output is</p> <pre><code>eslint:cli Running on files +0ms eslint:config Using command line config .eslintrc.json +70ms eslint:config-file Loading JSON config file: /home/jason/sfa/testproj/.eslintrc.json +5ms eslint:config-file Loading /usr/local/lib/node_modules/eslint/conf/eslint.json +292ms eslint:config-file Loading JSON config file: /usr/local/lib/node_modules/eslint/conf/eslint.json +0ms eslint:ignored-paths Looking for ignore file in /home/jason/sfa/testproj +40ms eslint:ignored-paths Could not find ignore file in cwd +0ms eslint:glob-util Creating list of files to process. +1ms eslint:cli-engine Processing /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js +6ms eslint:cli-engine Linting /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js +1ms eslint:config Constructing config for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js +0ms eslint:config Using .eslintrc and package.json files +0ms eslint:config Loading /home/jason/sfa/testproj/.eslintrc.yml +2ms eslint:config-file Loading YAML config file: /home/jason/sfa/testproj/.eslintrc.yml +1ms eslint:config-file Loading /usr/local/lib/node_modules/eslint/conf/eslint.json +63ms eslint:config-file Loading JSON config file: /usr/local/lib/node_modules/eslint/conf/eslint.json +0ms eslint:config Using /home/jason/sfa/testproj/.eslintrc.yml +5ms eslint:config Merging command line config file +0ms eslint:config Merging command line environment settings +0ms eslint:config-ops Apply environment settings to config +1ms eslint:config-ops Creating config for environment browser +0ms eslint:cli-engine Linting code for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js (pass 1) +3ms eslint:cli-engine Generating fixed text for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js (pass 1) +147ms eslint:text-fixer Applying fixes +0ms eslint:text-fixer No fixes to apply +0ms eslint:cli-engine Processing /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js +0ms eslint:cli-engine Linting /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js +1ms eslint:config Constructing config for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js +0ms eslint:config Using config from cache +0ms eslint:cli-engine Linting code for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js (pass 1) +0ms eslint:cli-engine Generating fixed text for /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js (pass 1) +56ms eslint:text-fixer Applying fixes +0ms eslint:text-fixer No fixes to apply +0ms eslint:cli-engine Linting complete in: 291ms +1ms eslint:cli Fix mode enabled - applying fixes +0ms /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js 8:9 error Unexpected blank line after variable declarations newline-after-var 15:13 error 'hlp' is defined but never used no-unused-vars 50:30 error 'helper' is defined but never used no-unused-vars 55:32 error 'helper' is defined but never used no-unused-vars 59:42 error 'helper' is defined but never used no-unused-vars 69:7 error Expected { after 'if' condition curly 69:22 error Expected '===' and instead saw '==' eqeqeq 71:22 error Expected '===' and instead saw '==' eqeqeq 76:22 error Expected '===' and instead saw '==' eqeqeq 84:50 error Object properties must go on a new line object-property-newline 89:21 error Expected '===' and instead saw '==' eqeqeq 113:27 error 'appEvent' is already defined no-redeclare /home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersHelper.js 14:17 error Gratuitous parentheses around expression no-extra-parens 23:17 error 'appEvent' is defined but never used no-unused-vars 24:28 error Expected '===' and instead saw '==' eqeqeq 28:28 error Expected '===' and instead saw '==' eqeqeq 32:28 error Expected '===' and instead saw '==' eqeqeq ✖ 17 problems (17 errors, 0 warnings) </code></pre> <p>When I open the actual code, nothing has been changed. When I run the linter again, it outputs the same thing.</p> <p>It clearly says "generating fixed text" but then it outputs "no fixes to apply". I can't find anything regarding how the fix flag functions online, so I turn to stackoverflow for help.. Thanks in advance.</p>
0debug
Android Change Button text randomly : <p>How to change button text every 5 secs ? i,e First the text will be "hello" and after 5 secs it should be "Hi" and then "hello" and then "hi" and so on until I click that button.</p>
0debug
Changing a variable outside of a for loop : <p>I am writing a program where I am accessing an object in a list using a for loop. I want to be able to change a variable outside of a for loop from within the loop. Code snippet below:</p> <pre><code>member_found = False # default value for member in self._members: if member_id == member.get_account_ID(): member_found = True </code></pre> <p>In PyCharm, I am getting a notification that says "Local variable 'member_found' value is not used." When I run this code, it doesn't seem to produce any errors, but I want to make sure the variable outside the for loop is actually being changed.</p> <p>I can always make the default value an empty list and append the list, but I would rather use booleans if possible.</p>
0debug
int ff_intrax8_decode_picture(IntraX8Context *const w, int dquant, int quant_offset) { MpegEncContext *const s = w->s; int mb_xy; assert(s); w->use_quant_matrix = get_bits1(&s->gb); w->dquant = dquant; w->quant = dquant >> 1; w->qsum = quant_offset; w->divide_quant_dc_luma = ((1 << 16) + (w->quant >> 1)) / w->quant; if (w->quant < 5) { w->quant_dc_chroma = w->quant; w->divide_quant_dc_chroma = w->divide_quant_dc_luma; } else { w->quant_dc_chroma = w->quant + ((w->quant + 3) >> 3); w->divide_quant_dc_chroma = ((1 << 16) + (w->quant_dc_chroma >> 1)) / w->quant_dc_chroma; } x8_reset_vlc_tables(w); for (s->mb_y = 0; s->mb_y < s->mb_height * 2; s->mb_y++) { x8_init_block_index(w, s->current_picture.f, s->mb_y); mb_xy = (s->mb_y >> 1) * s->mb_stride; for (s->mb_x = 0; s->mb_x < s->mb_width * 2; s->mb_x++) { x8_get_prediction(w); if (x8_setup_spatial_predictor(w, 0)) goto error; if (x8_decode_intra_mb(w, 0)) goto error; if (s->mb_x & s->mb_y & 1) { x8_get_prediction_chroma(w); x8_setup_spatial_predictor(w, 1); if (x8_decode_intra_mb(w, 1)) goto error; x8_setup_spatial_predictor(w, 2); if (x8_decode_intra_mb(w, 2)) goto error; w->dest[1] += 8; w->dest[2] += 8; s->mbskip_table[mb_xy] = 0; s->mbintra_table[mb_xy] = 1; s->current_picture.qscale_table[mb_xy] = w->quant; mb_xy++; } w->dest[0] += 8; } if (s->mb_y & 1) ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 8, 16); } error: return 0; }
1threat
In Python 3 Regexes, does dot-star (.*) match spaces? : Sorry this is a simple question but I couldn't find an answer anywhere. I'm going through Automate the Boring Stuff and I'm on Chapter 7 which is about Regexes. It says .* matches any character except a newline, does that include a space? Thanks in advance
0debug
Video Conferencing in Freeswitch : <p>I am working on Calling Solution which uses FreeSwitch for Audio/Video Calling. I am stuck with Video Conferencing system that will be run by iOS and Andriod client devices.</p> <ul> <li>When I create a Video Conference Call, every user can see Video of only one user.</li> <li>Then I added some canvas variables for Video Conferencing but all in vain.</li> <li>I have also enabled WebRTC port in FreeSwitch.</li> </ul> <p>I need an open source Video Conferencing Solution developed under Freeswitch and WebRTC and will be compatible to develop in Andriod and iOS platforms.</p> <p>Does OpenVCS or telepresence Server can do trick or not? Any other solution for this problem? </p>
0debug
Is it possible to apply css to only overflow:hidden elements? : Here i want to apply visibility:hidden only to those divs which are not visible <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <div style="height:100px;overflow:hidden;background:red;border:2px dashed #000;"> <div>Ganesh</div> <div>Om shankar</div> <div>Sai</div> <div>venkat</div> <div>Sireesha</div> <div>Sanjana</div> <div>Giri</div> <div>Santhosh</div> </div> </body> </html> <!-- end snippet -->
0debug
Angular-universal getting error: You must pass in a NgModule or NgModuleFactory to be bootstrapped : <p>I converted my existing angular-cli application to angular-universal by following <a href="https://github.com/angular/angular-cli/wiki/stories-universal-rendering" rel="noreferrer">this guide</a>.</p> <p>You can look at my complete source code <a href="https://github.com/SaurabhLpRocks/ng-performance-optimization" rel="noreferrer">here</a>.</p> <p>I am able to build both browser and client projects but I get following error when I view the app in the browser:</p> <blockquote> <p>Error: You must pass in a NgModule or NgModuleFactory to be bootstrapped at View.engine (D:\ng-ssr-demo\dist\server.js:359545:23)</p> </blockquote> <p>The issue is in my <strong>server.ts</strong> file where <strong>AppServerModuleNgFactory</strong> is being undefined and as this factory is used for bootstraping the app in the express backend, the bootstrapping is failing.</p> <p><strong>./server.ts:</strong></p> <pre><code>const MockBrowser = require('mock-browser').mocks.MockBrowser; const mock = new MockBrowser(); // Faster server renders w/ Prod mode (dev mode never needed) enableProdMode(); // Express server const app = express(); const PORT = process.env.PORT || 4000; const DIST_FOLDER = join(process.cwd(), 'dist'); // Fix for window error: const domino = require('domino'); const fs = require('fs'); const path = require('path'); const template = fs.readFileSync(path.resolve('./', 'dist', 'browser/', 'index.html')).toString(); const win = domino.createWindow(template); // workaround for leaflet global['window'] = win; global['document'] = win.document; // workaround for nex-charts win.screen = { deviceXDPI: 0, logicalXDPI: 0 }; global['MouseEvent'] = win.MouseEvent; global['navigator'] = mock.getNavigator(); // * NOTE :: leave this as require() since this file is built Dynamically from webpack const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main.bundle'); // AppServerModuleNgFactory is undefined console.log('AppServerModuleNgFactory', AppServerModuleNgFactory); // This is injected console.log('LAZY_MODULE_MAP', LAZY_MODULE_MAP); // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) app.engine('html', ngExpressEngine({ bootstrap: AppServerModuleNgFactory, providers: [ provideModuleMap(LAZY_MODULE_MAP) ] })); </code></pre> <p><strong>./webpack.server.config.js:</strong></p> <pre><code>module.exports = { entry: { // This is our Express server for Dynamic universal server: './server.ts', // This is an example of Static prerendering (generative) prerender: './prerender.ts' }, target: 'node', resolve: { extensions: ['.ts', '.js'] }, // Make sure we include all node_modules etc externals: [/node_modules/], output: { path: path.join(__dirname, 'dist'), filename: '[name].js' }, module: { rules: [{ test: /\.ts$/, loader: 'ts-loader'}] }, plugins: [ new webpack.ContextReplacementPlugin( // fixes WARNING Critical dependency: the request of a dependency is an expression /(.+)?angular(\\|\/)core(.+)?/, path.join(__dirname, 'src'), // location of your src {} // a map of your routes ), new webpack.ContextReplacementPlugin( // fixes WARNING Critical dependency: the request of a dependency is an expression /(.+)?express(\\|\/)(.+)?/, path.join(__dirname, 'src'), {} ) ] } </code></pre> <p><strong>./src/tsconfig.server.json:</strong></p> <pre><code>{ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "module": "commonjs", "baseUrl": "./", "types": ["node"], "typeRoots": ["../node_modules/@types"], "paths": { "@angular/*": [ "../node_modules/@angular/*" ], "@nebular/*": [ "../node_modules/@nebular/*" ] } }, "exclude": [ "test.ts", "**/*.spec.ts" ], "angularCompilerOptions": { "entryModule": "app/app.server.module#AppServerModule", "platform": 1 } } </code></pre> <p><strong>./src/main.server.ts:</strong></p> <pre><code>export { AppServerModule } from './app/app.server.module'; </code></pre> <p><strong>./src/app/app.module.ts:</strong></p> <pre><code>@NgModule({ declarations: [AppComponent], imports: [ BrowserModule.withServerTransition({appId: 'my-app'}), BrowserAnimationsModule, HttpModule, AppRoutingModule, NgbModule.forRoot(), ThemeModule.forRoot(), CoreModule.forRoot(), environment.production ? ServiceWorkerModule.register('./ngsw-worker.js') : [], ], bootstrap: [AppComponent], providers: [ { provide: APP_BASE_HREF, useValue: '/' }, WebWorkerService, ], }) export class AppModule { } </code></pre> <p><strong>./src/app/app.server.module.ts:</strong></p> <pre><code>@NgModule({ imports: [ AppModule, ServerModule, ModuleMapLoaderModule ], bootstrap: [AppComponent], }) export class AppServerModule {} </code></pre>
0debug
Automatic Logout Using Php : <p>If user 'A' is logged in some credentials into a Mobile App.for ex, username: user password: user and user 'B' tries to login using same credentials provided above.Then on successful login of user 'B',user 'A' session must be destroyed and should be automatically logged out from the Mobile App.</p>
0debug
Python functions in general : <p><a href="https://i.stack.imgur.com/WGYfR.png" rel="nofollow noreferrer">How do I fix this error?! I'm not sure what to change about it. I tried to remove using float but its not working? </a></p>
0debug
How to get the indices list of all NaN value in numpy array? : <p>Say now I have a numpy array which is defined as,</p> <pre><code>[[1,2,3,4], [2,3,NaN,5], [NaN,5,2,3]] </code></pre> <p>Now I want to have a list that contains all the indices of the missing values, which is <code>[(1,2),(2,0)]</code> at this case.</p> <p>Is there any way I can do that?</p>
0debug
int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, TAKStreamInfo *ti, int log_level_offset) { if (get_bits(gb, TAK_FRAME_HEADER_SYNC_ID_BITS) != TAK_FRAME_HEADER_SYNC_ID) { av_log(avctx, AV_LOG_ERROR + log_level_offset, "missing sync id\n"); return AVERROR_INVALIDDATA; } ti->flags = get_bits(gb, TAK_FRAME_HEADER_FLAGS_BITS); ti->frame_num = get_bits(gb, TAK_FRAME_HEADER_NO_BITS); if (ti->flags & TAK_FRAME_FLAG_IS_LAST) { ti->last_frame_samples = get_bits(gb, TAK_FRAME_HEADER_SAMPLE_COUNT_BITS) + 1; skip_bits(gb, 2); } else { ti->last_frame_samples = 0; } if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) { avpriv_tak_parse_streaminfo(gb, ti); if (get_bits(gb, 6)) skip_bits(gb, 25); align_get_bits(gb); } if (ti->flags & TAK_FRAME_FLAG_HAS_METADATA) return AVERROR_INVALIDDATA; skip_bits(gb, 24); return 0; }
1threat
SELECT ID THAT HAVE MULTIPLES ATTRIBUTS AND VALUES : i have table1 : +------+---------+ | id | name | +------+---------+ | 1 | name1 | | 2 | name2 | | 3 | name3 | | 4 | name4 | +------+---------+ i have table2 : +------+---------+----------+ | id | attribut| value | +------+---------+----------+ | 1 | 1 | 1 | | 1 | 3 | 3 | | 2 | 1 | 1 | | 2 | 3 | 4 | +------+---------+--------- + i want to select the distinct id(s) and name(s) in table1 that have ( attribut 1 and value 1) and (attribut 3 and value 3) in table 2 thanks for help !!
0debug
Will the following code removes a relationship by setting the foreign key to 0? : I have a question about entity framework. Will the following code removes a relationship by setting the foreign key to 0? entity.relationEntityID = 0;
0debug
How to make a texbox numeric only or text only VB.net : Dear Stackoverflow people, It's my first time asking a question here, but i also try to help other people as good as possible. But now lets get to the question. I've a form with 3 textboxes and 2 buttons. Button 1 is enabled if all 3 textboxes are filled in. Button 2 is a quit program button. Let's see my code for the textboxes Private Sub TextBoxes_TextChanged( ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles _ TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged Dim textBoxes = {TextBox1, TextBox2, TextBox3} Button1.Enabled = textBoxes.All(Function(tb) tb.Text <> "") End Sub So now i am wondering how can i change the value of textbox 2 to only numerics and of textbox 1 and 3 to only text. I hope you'll understand my questions. I hope you guys can help me out. Kindly regards, Slamnose
0debug
How to minify ES6 code using Webpack? : <p>I'm using webpack and want to deploy my site. If I minify and bundle my JavaScript code, I've got this error:</p> <blockquote> <p><strong>Parse error:</strong> Unexpected token: name (<code>Button</code>)</p> </blockquote> <p>Here is my not bundled code:</p> <pre><code>'use strict'; export class Button { // &lt;-- Error happens on this line constructor(translate, rotate, text, textscale = 1) { this.position = translate; this.rotation = rotate; this.text = text; this.textscale = textscale; } } </code></pre> <p>Note in bundled code the keyword <code>export</code> is removed. In development, there are no errors thrown. Here you could find my configuration file of WebPack:</p> <pre><code>var webpack = require('webpack'); var PROD = true; module.exports = { entry: "./js/entry.js", output: { path: __dirname, filename: PROD ? 'bundle.min.js' : 'bundle.js' }, module: { loaders: [ { test: /\.css$/, loader: "style-loader!css-loader" } ] }, plugins: PROD ? [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false }, output: { comments: false, }, }) ] : [] }; </code></pre> <p>If I change <code>PROD</code> to false, I've no error, if true I've got error from above. My question is can I enable ES6 in Webpack?</p>
0debug
int av_write_trailer(AVFormatContext *s) { int ret; while(s->packet_buffer){ int ret; AVPacketList *pktl= s->packet_buffer; truncate_ts(s->streams[pktl->pkt.stream_index], &pktl->pkt); ret= s->oformat->write_packet(s, &pktl->pkt); s->packet_buffer= pktl->next; av_free_packet(&pktl->pkt); av_freep(&pktl); if(ret<0) return ret; } ret = s->oformat->write_trailer(s); av_freep(&s->priv_data); return ret; }
1threat
static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base) { USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev); USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base); int rc; pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc); dev->info = info; dev->auto_attach = 1; QLIST_INIT(&dev->strings); rc = dev->info->init(dev); if (rc == 0 && dev->auto_attach) rc = usb_device_attach(dev); return rc; }
1threat
static const ppc_def_t *ppc_find_by_pvr (uint32_t pvr) { int i; for (i = 0; i < ARRAY_SIZE(ppc_defs); i++) { if (pvr == ppc_defs[i].pvr) { return &ppc_defs[i]; } } return NULL; }
1threat
document.write('<script src="evil.js"></script>');
1threat
import a function from another .ipynb file : <p>I defined a hello world function in a file called 'functions.ipynb'. Now, I would like to import functions in another file by using "import functions". I am sure that they are in the same folder. However, it still shows that "ImportError: No module named functions". By the way, I am using jupyter notebook. Thanks a lot!</p>
0debug
quotation marks in bash script around $@? : <p>I found the following snippet of bash script from <a href="https://stackoverflow.com/questions/8818119/how-can-i-run-a-function-from-a-script-in-command-line">How can I run a function from a script in command line?</a></p> <pre><code>$ cat test.sh testA() { echo "TEST A $1"; } testB() { echo "TEST B $2"; } "$@" </code></pre> <p>This works well. One of the response of this answer is <code>Use "$@" in most cases. $@ is not safe in some cases</code></p> <p>I'm wondering why <code>$@</code> needs quotation marks, <code>"$@"</code> , in the last line. What makes it difference with or without quotation marks around <code>$@</code> in the bash script?</p>
0debug
bash - shuffle a file that is too large to fit in memory : <p>I've got a file that's too large to fit in memory. <code>shuf</code> seems to run in RAM, and <code>sort -R</code> doesn't shuffle (identical lines end up next to each other; I need all of the lines to be shuffled). Are there any options other than rolling my own solution?</p>
0debug
Store html content into php vaiable? : I have some html in my php page that I fetched from database and will be used many times in my webpage, so I want to put it into a php variable for later use. My sample code is <div class="info"> Some content from database here... <div class="more"> Some more text... </div> </div> How to store this html into php variable? Please also tell me how to echo content of that variable?
0debug
git - error: addinfo_cache failed for path 'file' : <p>When I try to merge any branch in git into master I get <code>error: addinfo_cache failed for path 'file'</code>.</p> <p>What I do:</p> <pre><code>&gt;git checkout master &gt;git merge other-branch </code></pre> <p>Git gives me:</p> <pre><code>error: addinfo_cache failed for path 'file' file: unmerged (581c47f7d0e1a0bc825d528d9783ac18ee0cce27) file: unmerged (26a0c24dccd2bc2f74e20488ca01bba2fcd9cf56) file: unmerged (3be471ca5c689693339827a455f187814677642f) fatal: git write-tree failed to write a tree </code></pre> <p><code>&gt;git status</code> yields:</p> <pre><code>On branch master Your branch is up-to-date with 'origin/master'. Unmerged paths: (use "git reset HEAD &lt;file&gt;..." to unstage) (use "git add &lt;file&gt;..." to mark resolution) both modified: file no changes added to commit (use "git add" and/or "git commit -a") </code></pre> <p>I have no idea what to do and can't find anython on the problem.</p>
0debug
its possible update a page content use html and css without javascript? : <p>its possible update a page content use html and css without javascript</p> <p>I see this tutorial but i dont know if is possible update page on click without javascript </p> <p><a href="http://codepen.io/ejsado/pen/EaFsy?css-preprocessor=sass" rel="nofollow noreferrer">http://codepen.io/ejsado/pen/EaFsy?css-preprocessor=sass</a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>@keyframes hide1 { from { visibility: hidden; } to { visibility: visible; } } @keyframes hide2 { from { visibility: hidden; } to { visibility: visible; } } @mixin set-animation($name) { animation: $name 200ms steps(1); } h1, h3, h4, p { text-align: center; } h4 { width: 400px; margin: 1rem auto; } div { width: 140px; margin: 0 auto; } #click { position: absolute; left: -20px; } #single-click { position: absolute; cursor: pointer; @include set-animation(hide1); } #single-click, #double-click { user-select: none; width: 135px; height: 110px; } #double-click { border: none; background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/106891/folders.png"); background-size: 450px; background-position: 301px 0; } #click:checked ~ #single-click { @include set-animation(hide2); } #double-click:focus { outline: 0; } #click:focus ~ #double-click { background-position: 0 0; } #double-click:focus { background-position: 153px 0; } #double-click:focus ~ p { opacity: 1; } p { opacity: 0; } footer { position: fixed; bottom: 0; right: 0; font-size: 13px; background: #DDD; padding: 5px 10px; margin: 5px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1&gt;CSS Double Click&lt;/h1&gt; &lt;h3&gt;Double click detection without Javascript&lt;/h3&gt; &lt;div&gt; &lt;input type="checkbox" id="click"&gt; &lt;label id="single-click" for="click"&gt;&lt;/label&gt; &lt;button id="double-click"&gt;&lt;/button&gt; &lt;p&gt;You double clicked!&lt;/p&gt; &lt;/div&gt; &lt;h4&gt;The folder image is a button.&lt;/h4&gt; &lt;h4&gt;There is a transparent label on top of the button.&lt;/h4&gt; &lt;h4&gt;The label is attached to a checkbox.&lt;/h4&gt; &lt;h4&gt;When the label is clicked, it gains focus and the folder is opened and the checkbox is checked (or unchecked).&lt;/h4&gt; &lt;h4&gt;The checkbox triggers an animation which hides the transparent label for 200ms, which allows the button (folder image) to be clicked.&lt;/h4&gt; &lt;h4&gt;If the user is quick enough to click the button, the button is focussed and displays the full folder and shows the success message.&lt;/h4&gt; &lt;footer&gt; An original pen by &lt;a href="http://codepen.io/ejsado/"&gt;Eric&lt;/a&gt;. &lt;/footer&gt;</code></pre> </div> </div> </p> <p>Please help me</p>
0debug
How to verify React props in Jest and Enzyme? : <p>So I was trying to learn about testing in React and I have this: <code>Button.js</code> and <code>Button.test.js</code></p> <p>The question is commented along with the code below: </p> <pre class="lang-js prettyprint-override"><code>// Button.js import React from 'react'; import { string, bool, func } from 'prop-types'; import { StyledButton } from './styled' const Button = ({ size, text, }) =&gt; ( &lt;StyledButton size={size} // the test will alway fail with result: // Expected value to be: "Join us" // Received: undefined // Unless I add add this line below text={text} &gt; {text} // but the text props is here. That is my current practice of passing the props to the children, am I missing anything? &lt;/StyledButton&gt; ); Button.propTypes = { size: string, text: string, }; Button.defaultProps = { size: '', text: '', }; export default Button; // Button.test.js import React from 'react'; import { shallow } from 'enzyme'; import Button from '../../components/Button/Button'; describe('Component: Button', () =&gt; { const minProps = { text: '', size: '', }; it('renders a button in size of "small" with text in it', () =&gt; { const wrapper = shallow( &lt;Button {...minProps} size="small" text="Join us" /&gt; ); expect(wrapper.prop('size')).toBe('small'); expect(wrapper.prop('text')).toBe('Join us'); }); }); // StyledButton import Button from 'antd/lib/button'; const StyledButton = styled(Button)` &amp;.ant-btn { padding: 0 24px; ${({ size }) =&gt; { if (size === 'small') { return css` font-size: 14px; line-height: 32px; `; } return null; }}; `; export { StyledButton }; </code></pre> <p>Does anyone know why the test will not pass unless I pass the props to the <code>StyledButton</code>? </p>
0debug
static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,long src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 23; __asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory"); while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "punpckldq 3%1, %%mm0\n\t" "movd 6%1, %%mm1\n\t" "punpckldq 9%1, %%mm1\n\t" "movd 12%1, %%mm2\n\t" "punpckldq 15%1, %%mm2\n\t" "movd 18%1, %%mm3\n\t" "punpckldq 21%1, %%mm3\n\t" "pand %%mm7, %%mm0\n\t" "pand %%mm7, %%mm1\n\t" "pand %%mm7, %%mm2\n\t" "pand %%mm7, %%mm3\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm1, 8%0\n\t" MOVNTQ" %%mm2, 16%0\n\t" MOVNTQ" %%mm3, 24%0" :"=m"(*dest) :"m"(*s) :"memory"); dest += 32; s += 24; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { #ifdef WORDS_BIGENDIAN *dest++ = 0; *dest++ = s[2]; *dest++ = s[1]; *dest++ = s[0]; s+=3; #else *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; *dest++ = 0; #endif } }
1threat
static void dbdma_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { int channel = addr >> DBDMA_CHANNEL_SHIFT; DBDMAState *s = opaque; DBDMA_channel *ch = &s->channels[channel]; int reg = (addr - (channel << DBDMA_CHANNEL_SHIFT)) >> 2; DBDMA_DPRINTF("writel 0x" TARGET_FMT_plx " <= 0x%08x\n", addr, value); DBDMA_DPRINTF("channel 0x%x reg 0x%x\n", (uint32_t)addr >> DBDMA_CHANNEL_SHIFT, reg); if (reg == DBDMA_CMDPTR_LO && (ch->regs[DBDMA_STATUS] & (RUN | ACTIVE))) return; ch->regs[reg] = value; switch(reg) { case DBDMA_CONTROL: dbdma_control_write(ch); break; case DBDMA_CMDPTR_LO: ch->regs[DBDMA_CMDPTR_LO] &= ~0xf; dbdma_cmdptr_load(ch); break; case DBDMA_STATUS: case DBDMA_INTR_SEL: case DBDMA_BRANCH_SEL: case DBDMA_WAIT_SEL: break; case DBDMA_XFER_MODE: case DBDMA_CMDPTR_HI: case DBDMA_DATA2PTR_HI: case DBDMA_DATA2PTR_LO: case DBDMA_ADDRESS_HI: case DBDMA_BRANCH_ADDR_HI: case DBDMA_RES1: case DBDMA_RES2: case DBDMA_RES3: case DBDMA_RES4: break; } }
1threat
PHP int checking not working : <p>Well, I've tried making a rank system but it doesn't seem to work? I'm new but learning please take it easy on me. Here is where I check for users info</p> <p><strong>GetInfo.php</strong> <pre><code> # Check if user is valid session_start(); if(!isset($_SESSION['username'])) { header('location: login.php'); die(); } else { $my_username = $_SESSION['username']; } # Get User Information $db_get_user = mysqli_query($con, "SELECT * FROM users WHERE username='$my_username'"); # Get The User Information $row = mysqli_fetch_array($db_get_user); $my_email = $row['email']; if($my_rank = $row['rank'] = 0){ echo '000'; }else if($my_rank = $row['rank'] = 1){ echo '111'; }else if($my_rank = $row['rank'] = 2){ echo '222'; }else if($my_rank = $row['rank'] = 3){ echo '333'; }else if($my_rank = $row['rank'] = 4){ echo '444'; }else if($my_rank = $row['rank'] = 5){ echo '555'; } ?&gt; </code></pre>
0debug
I don't understand why backslash is used in extends class in php code : <p>class SwiftMailerTestCase extends \PHPUnit_Framework_TestCase</p> <p>why coder uses backslash in extends class in above php code</p>
0debug
I'm Creat android layout but after running on my real device i'm getting unique view of same layout please help me as soon as possible : I have an main activity in which I have creating layout in XML in android studio and setting width and height properly as per my need but after executing my code on my device I'm getting a different view of the same layout. and also i want to do scroll up my layout when my keyboard is active but after adding **android:windowSoftInputMode="adjustResize"** not help me please if any one have some perfect solution please let me know I have search a lot but not getting any kind of help on community <RelativeLayout android:id="@+id/lay_zcrt_img" android:layout_width="match_parent" android:layout_height="fill_parent" android:background="@drawable/splash1"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="45dp" android:background="@drawable/login_layout_border"> <ImageView android:layout_width="250dp" android:layout_height="120dp" android:layout_margin="4dp" android:src="@drawable/login_logo" /> </RelativeLayout> <android.support.v7.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginLeft="35dp" android:layout_marginTop="230dp" android:layout_marginRight="35dp" android:background="@drawable/lay_login_border" app:cardCornerRadius="14dp"> <RelativeLayout android:layout_width="350dp" android:layout_height="300dp" android:layout_gravity="center"> <TextView android:id="@+id/txt_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="15dp" android:gravity="center" android:text="Login" android:textColor="#000" android:textSize="25dp" /> <EditText android:id="@+id/edt_phone_number" android:layout_width="300dp" android:layout_height="65dp" android:layout_marginTop="55dp" android:layout_below="@+id/txt_title" android:layout_centerHorizontal="true" android:gravity="center_horizontal|center_vertical" android:hint="Mobile" android:inputType="number" android:maxLength="10" /> <Button android:id="@+id/btn_login" android:layout_width="300dp" android:layout_height="55dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginBottom="8dp" android:background="@drawable/btn_corner" android:gravity="center_horizontal|center_vertical" android:text="Submit" android:textAlignment="center" android:textColor="#fff" /> </RelativeLayout> </android.support.v7.widget.CardView> </RelativeLayout> here you can see from images I search a lot on a community but not getting any single article related to this please if anyone is here to solve then help [This is my android studio layout][1] [This is my real device view][2] [1]: https://i.stack.imgur.com/40etr.jpg [2]: https://i.stack.imgur.com/nntFO.jpg
0debug
static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; unsigned i, entries; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; sc = st->priv_data; avio_rb32(pb); entries = avio_rb32(pb); if (entries >= UINT_MAX / sizeof(*sc->stps_data)) return AVERROR_INVALIDDATA; sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data)); if (!sc->stps_data) return AVERROR(ENOMEM); sc->stps_count = entries; for (i = 0; i < entries; i++) { sc->stps_data[i] = avio_rb32(pb); } return 0; }
1threat
void *g_try_realloc(void *mem, size_t n_bytes) { __coverity_negative_sink__(n_bytes); return realloc(mem, n_bytes == 0 ? 1 : n_bytes); }
1threat