problem
stringlengths
26
131k
labels
class label
2 classes
Unable to View the output of a python Script in Poweshell : > `with open('names.txt', 'r') as f: myNames = f.readlines()[The Print statement doesn't produce any output][1]` [1]: https://i.stack.imgur.com/tEdem.png So when i type these lines in my Powershell, i get no syntax error. But the Print statement show any output.Am i missing something? Also attached the Screenshot for reference
0debug
static void sdhci_set_inserted(DeviceState *dev, bool level) { SDHCIState *s = (SDHCIState *)dev; DPRINT_L1("Card state changed: %s!\n", level ? "insert" : "eject"); if ((s->norintsts & SDHC_NIS_REMOVE) && level) { timer_mod(s->insert_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + SDHC_INSERTION_DELAY); } else { if (level) { s->prnsts = 0x1ff0000; if (s->norintstsen & SDHC_NISEN_INSERT) { s->norintsts |= SDHC_NIS_INSERT; } } else { s->prnsts = 0x1fa0000; s->pwrcon &= ~SDHC_POWER_ON; s->clkcon &= ~SDHC_CLOCK_SDCLK_EN; if (s->norintstsen & SDHC_NISEN_REMOVE) { s->norintsts |= SDHC_NIS_REMOVE; } } sdhci_update_irq(s); } }
1threat
inline static void RENAME(hcscale)(uint16_t *dst, int dstWidth, uint8_t *src1, uint8_t *src2, int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, int32_t *mmx2FilterPos) { if(srcFormat==IMGFMT_YUY2) { RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(srcFormat==IMGFMT_UYVY) { RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(srcFormat==IMGFMT_BGR32) { RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(srcFormat==IMGFMT_BGR24) { RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(srcFormat==IMGFMT_BGR16) { RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(srcFormat==IMGFMT_BGR15) { RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(srcFormat==IMGFMT_RGB32) { RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(srcFormat==IMGFMT_RGB24) { RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+2048; } else if(isGray(srcFormat)) { return; } #ifdef HAVE_MMX if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) #else if(!(flags&SWS_FAST_BILINEAR)) #endif { RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); } else { #if defined(ARCH_X86) || defined(ARCH_X86_64) #ifdef HAVE_MMX2 int i; if(canMMX2BeUsed) { asm volatile( "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" #ifdef ARCH_X86_64 #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\ "add %%"REG_S", %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #else #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #endif FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE "xor %%"REG_a", %%"REG_a" \n\t" "mov %5, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "add $4096, %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), "m" (funnyUVCode), "m" (src2) : "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D ); for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { dst[i] = src1[srcW-1]*128; dst[i+2048] = src2[srcW-1]*128; } } else { #endif long xInc_shr16 = (long) (xInc >> 16); int xInc_mask = xInc & 0xffff; asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" "xor %%"REG_b", %%"REG_b" \n\t" "xorl %%ecx, %%ecx \n\t" ".balign 16 \n\t" "1: \n\t" "mov %0, %%"REG_S" \n\t" "movzbl (%%"REG_S", %%"REG_b"), %%edi \n\t" "movzbl 1(%%"REG_S", %%"REG_b"), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t" "movzbl (%5, %%"REG_b"), %%edi \n\t" "movzbl 1(%5, %%"REG_b"), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, 4096(%%"REG_D", %%"REG_a", 2)\n\t" "addw %4, %%cx \n\t" "adc %3, %%"REG_b" \n\t" "add $1, %%"REG_a" \n\t" "cmp %2, %%"REG_a" \n\t" " jb 1b \n\t" #if defined(ARCH_X86_64) && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4)) :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #else :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #endif "r" (src2) : "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi" ); #ifdef HAVE_MMX2 } #endif #else int i; unsigned int xpos=0; for(i=0;i<dstWidth;i++) { register unsigned int xx=xpos>>16; register unsigned int xalpha=(xpos&0xFFFF)>>9; dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); xpos+=xInc; } #endif } }
1threat
Wamp on Raspberry Pi : <p>For a school project, I need to install a server with Wamp but I need to have access everywhere so maybe is it possible to install it on my Raspberry. So is it possible and if is it how ? Thanks you so much for your help</p>
0debug
How to display IP address of devices which are connected to android hotspot programmatically? : <p>I need to display ip address of devices which are connected to android hotspot in a app.</p> <p>Please help me</p>
0debug
Simple bulls and cows java game : <p>I try to create a verry simple Bulls and Cows game (<a href="https://en.wikipedia.org/wiki/Bulls_and_Cows" rel="nofollow">https://en.wikipedia.org/wiki/Bulls_and_Cows</a>). The game is for my school project. My knowledge is limited, so I need to make the game using only loops, IF-else constructions and other simple functions.</p> <p>The written code works somewhat - generate code and understands that number is hited, but did not indicate how many cows and bulls have in the wrong assumptions.</p> <p>I would be glad if someone point me in the right direction :) Thanks in advance</p> <pre><code>import java.util.Random; import java.util.Scanner; public class BCgame{ public static void main(String[] args){ Random r= new Random(); int number= 0; int trynum = 0; while(uniq(number= (r.nextInt(9000) + 1000))); String targetStr = number +""; boolean game = true; Scanner input = new Scanner(System.in); do{ System.out.println(number); int bulls = 0; int cows = 0; System.out.print("Guess a number: "); int guess; guess = input.nextInt(); if (uniq(guess) || guess &lt; 1000) continue; trynum++; String guessStr = guess + ""; for(int i= 0;i &lt; 4;i++){ if(guessStr.charAt(i) == targetStr.charAt(i)){ bulls++; }else if(targetStr.contains(guessStr.charAt(i)+"")){ cows++; } } if(bulls == 4){ game = false; }else{ System.out.println(cows+" Cows and "+bulls+" Bulls."); } }while(game); System.out.println("You won after "+trynum+" guesses!"); } public static boolean uniq(int num){ String checknum = num+""; if(checknum.charAt(0) == checknum.charAt(1)) return false; else if(checknum.charAt(1) == checknum.charAt(2)) return false; else if(checknum.charAt(2) == checknum.charAt(3)) return false; return true; }; } </code></pre>
0debug
static bool memory_region_access_valid(MemoryRegion *mr, target_phys_addr_t addr, unsigned size) { if (!mr->ops->valid.unaligned && (addr & (size - 1))) { return false; } if (!mr->ops->valid.max_access_size) { return true; } if (size > mr->ops->valid.max_access_size || size < mr->ops->valid.min_access_size) { return false; } return true; }
1threat
Angular2 Resolve before CanActivate : <p>I have an Authentication service that implements the Resolve interface to return an observable that is resolved once a user's authentication state is retrieved from the server. </p> <p>This same authentication service implements the CanActivate interface to block users from accessing a component if they are not logged in.</p> <p>Currently, the canActivate function is triggered before the resolve function is resolved, meaning it checks the user's login state before the login state has been retrieved from the server.</p> <p>My question is, how can I prevent the canActivate function being called until resolve is resolved, or otherwise is there another way I can achieve what I want?</p> <p>Thanks Max.</p>
0debug
C++ I want to do something like Class1.Class2.Fct() : <p>I am new to C++ programming and I need your help:</p> <p>Let's say I have a class - Class1. Is it possible to have another class (Class2) with (at least) one function that returns (for example) an integer? Here is an example with I want to achive:</p> <pre><code>std::cout &lt;&lt; "I did it: " &lt;&lt; Class1.Class2.ReturnINTEGER() &lt;&lt; std::endl; </code></pre> <p>I need the code to be compatible with GNU G++ compiler. Thanks :).</p>
0debug
I need to store data from html table to mysql database using php : I am new to stackoverflow. I am doing a project with html, css, php and mysql. The project is online vegetable shop which is nearly an ecommerce site. I need to store data from html table(my cart) to mysql database using php. The table looks like this: http://i.imgur.com/OngFBuP.png the code for "cart" is: '<?php include("session.php"); include_once("config.php"); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>View shopping cart</title> <link href="style/style.css" rel="stylesheet" type="text/css"></head> <body> <h1 align="center">View Cart</h1> <div class="cart-view-table-back"> <form method="post" action="buy.php"> <table id="myTable" width="100%" cellpadding="6" cellspacing="0"> <thead><tr><th>Sl_no</th><th>Username</th><th>Quantity</th><th>Name</th> <th>Price</th><th>Total</th><th>Remove</th></tr></thead> <tbody> <?php if(isset($_SESSION["cart_products"])) { $total = 0; $fl=1; $b = 0; foreach ($_SESSION["cart_products"] as $cart_itm) { $product_name = $cart_itm["product_name"]; $product_qty = $cart_itm["product_qty"]; $product_price = $cart_itm["product_price"]; $product_code = $cart_itm["product_code"]; $subtotal = ($product_price * $product_qty); $bg_color = ($b++%2==1) ? 'odd' : 'even'; echo '<tr class="'.$bg_color.'">'; echo '<td>'.$fl.'</td>'; echo '<td>'.$user.'</td>'; echo '<td><input type="text" size="2" maxlength="2" name="product_qty['.$product_code.']" value="'.$product_qty.'" /></td>'; echo '<td>'.$product_name.'</td>'; echo '<td>'.$product_price.'</td>'; echo '<td>'.$subtotal.'</td>'; echo '<td><input type="checkbox" name="remove_code[]" value="'.$product_code.'" /></td>'; echo '</tr>'; $fl++; $total = ($total + $subtotal); } echo$fl; $grand_total = $total; } ?> </tbody> </table> <button name="btn1" type="submit">buy</button> <input type="hidden" name="return_url" value="<?php $current_url = urlencode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); echo $current_url; ?>" /> </form> </div> </body> </html>' And I am using a php page(buy.php) to store all the data to database. The code for "buy.php" is: '<?php include('session.php'); $con=new mysqli("localhost","root","","test"); $total=0; foreach ($_SESSION["cart_products"] as $cart_itm) { $product_name = $cart_itm["product_name"]; $product_qty = $cart_itm["product_qty"]; $product_price = $cart_itm["product_price"]; $product_code = $cart_itm["product_code"]; $subtotal = ($product_price * $product_qty); $total = ($total + $subtotal); } $sql="INSERT INTO cart (Uname,TotalCost,veg_id,quantity) VALUES('$user','$total','$product_code','$product_qty')"; if($con->query($sql)==true){ echo"data inserted successfully"; } echo"<br><br><a href='index_2.php'> Return to Your Dashboard</a> <a href='buy_veg.php'> Buy More Items</a>"; ?>' The problem is this "buy.php" page is actually storing the last record to the database. Image link: http://i.imgur.com/ZaCnvjI.png I want to store all the cart items to the database. I need to submit my project tomorrow. Please help me as fast as possible. Thank You .
0debug
How to plot time series data with different categories in ggplot 2 R : This is the data-set group <- c(1,2,3,1,2,3) species <- c("rabbit","rabbit","rabbit","plant","plant","plant") t1 <- c(66,77,80,4,3,1) t2 <- c(4,5,22,1,2,6) t100 <- c(56,78,22,1,6,7) df <- data.frame(group, species,t1,t2,t100) where ti represents time for the ith time-frame. In my original dataset I have 100 such columns I need to plot time series for the data such that rows with the same group number have the same colour lines, but different symbols (pch). Ideally I need one symbol for "rabbits" category, and another for "plants. Here is my attempt time <- c(1,2,100) library(ggplot2) ggplot(df, aes(x = time, y=df[,3:5], colour = group)) #I don't know how to take it from here
0debug
datepicker not working when its https : <p>I was creating a portal where it shows all the records of the company sales and services. I have used datatable to show the reports and datepicker to filter date range. but after installing the SSL Certificates the datepicker doesn't work but when I search with http:// then it works very nicely. What could be the problem ?</p> <p>It will be very kind if you guide me with it. I am really stuck. </p> <p>Thank You</p>
0debug
Program not in work : Segmentation fault is occur : <p>FACE faculty told us that sacnf, get() , etc like function don't work in TCS campus commune portal so instead of scanf() should used atoi() ,atof(), function which is in "stdlib" library, so I tried to run simple addition program on gcc compiler so there is Segmentation fault whereas there is no error in program. What is this Segmentation fault?</p>
0debug
static void virtio_blk_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOBlock *s = VIRTIO_BLK(dev); VirtIOBlkConf *conf = &s->conf; Error *err = NULL; static int virtio_blk_id; if (!conf->conf.bs) { error_setg(errp, "drive property not set"); return; } if (!bdrv_is_inserted(conf->conf.bs)) { error_setg(errp, "Device needs media, but drive is empty"); return; } blkconf_serial(&conf->conf, &conf->serial); s->original_wce = bdrv_enable_write_cache(conf->conf.bs); blkconf_geometry(&conf->conf, NULL, 65535, 255, 255, &err); if (err) { error_propagate(errp, err); return; } virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); s->bs = conf->conf.bs; s->rq = NULL; s->sector_mask = (s->conf.conf.logical_block_size / BDRV_SECTOR_SIZE) - 1; s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output); s->complete_request = virtio_blk_complete_request; virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err); if (err != NULL) { error_propagate(errp, err); virtio_cleanup(vdev); return; } s->migration_state_notifier.notify = virtio_blk_migration_state_changed; add_migration_state_change_notifier(&s->migration_state_notifier); s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_dev_ops(s->bs, &virtio_block_ops, s); bdrv_set_guest_block_size(s->bs, s->conf.conf.logical_block_size); bdrv_iostatus_enable(s->bs); }
1threat
void arm_v7m_cpu_do_interrupt(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; uint32_t lr; arm_log_exception(cs->exception_index); switch (cs->exception_index) { case EXCP_UDEF: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK; break; case EXCP_NOCP: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; break; case EXCP_INVSTATE: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK; break; case EXCP_SWI: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC); break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: switch (env->exception.fsr & 0xf) { case 0x8: switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.IBUSERR\n"); break; case EXCP_DATA_ABORT: env->v7m.cfsr[M_REG_NS] |= (R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK); env->v7m.bfar = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with CFSR.PRECISERR and BFAR 0x%x\n", env->v7m.bfar); break; } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS); break; default: switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n"); break; case EXCP_DATA_ABORT: env->v7m.cfsr[env->v7m.secure] |= (R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK); env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with CFSR.DACCVIOL and MMFAR 0x%x\n", env->v7m.mmfar[env->v7m.secure]); break; } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM); break; } break; case EXCP_BKPT: if (semihosting_enabled()) { int nr; nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff; if (nr == 0xab) { env->regs[15] += 2; qemu_log_mask(CPU_LOG_INT, "...handling as semihosting call 0x%x\n", env->regs[0]); env->regs[0] = do_arm_semihosting(env); return; } } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG); break; case EXCP_IRQ: break; case EXCP_EXCEPTION_EXIT: do_v7m_exception_exit(cpu); return; default: cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); return; } lr = 0xfffffff1; if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) { lr |= 4; } if (!arm_v7m_is_handler_mode(env)) { lr |= 8; } v7m_push_stack(cpu); v7m_exception_taken(cpu, lr); qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception); }
1threat
Iterating over unordered_map C++ : <p>Is it true that keys inserted in a particular order in an unordered_map, will come in the <strong>same order</strong> while iterating over the map using iterator?</p> <p>Like for example: if we insert (4,3), (2, 5), (6, 7) in B. And iterate like:</p> <pre><code>for(auto it=B.begin();it!=B.end();it++) { cout&lt;&lt;(it-&gt;first); } </code></pre> <p>will it give us 4, 2, 6 or keys may come in any order?</p>
0debug
Why compare don`t work : <p>How is this possible, what is wrong with all the four checks? And what is the correct way to check this?</p> <pre><code>&lt;?php $url = 'domain.dev'; var_dump(strpos($url, 'admin')); if(strpos($url, 'admin') === false); { var_dump($url); } if(strpos($url, 'admin') !== false); { var_dump($url); } if(strpos($url, 'admin') === true); { var_dump($url); } if(strpos($url, 'admin') == true); { var_dump($url); } </code></pre> <p>The output of this is:</p> <pre><code>bool(false) string(10) "domain.dev" string(10) "domain.dev" string(10) "domain.dev" string(10) "domain.dev" </code></pre>
0debug
static void phys_map_node_reserve(unsigned nodes) { if (next_map.nodes_nb + nodes > next_map.nodes_nb_alloc) { next_map.nodes_nb_alloc = MAX(next_map.nodes_nb_alloc * 2, 16); next_map.nodes_nb_alloc = MAX(next_map.nodes_nb_alloc, next_map.nodes_nb + nodes); next_map.nodes = g_renew(Node, next_map.nodes, next_map.nodes_nb_alloc); } }
1threat
static int write_console_data(SCLPEvent *event, const uint8_t *buf, int len) { int ret = 0; const uint8_t *buf_offset; SCLPConsoleLM *scon = SCLPLM_CONSOLE(event); if (!scon->chr) { return len; } buf_offset = buf; while (len > 0) { ret = qemu_chr_fe_write(scon->chr, buf, len); if (ret == 0) { len = 0; } else if (ret == -EAGAIN || (ret > 0 && ret < len)) { len -= ret; buf_offset += ret; } else { len = 0; } } return ret; }
1threat
How Immutability is Implemented : <p>I am trying to grasp how the <a href="https://hackernoon.com/how-immutable-data-structures-e-g-immutable-js-are-optimized-using-structural-sharing-e4424a866d56" rel="noreferrer">trie</a> and such in immutability is implemented, as relates to immutability in JS. I understand how there is supposed to be significant structural sharing.</p> <p>My question is say you have a graph sort of structure like this:</p> <pre><code>a -- b | c | d -- h | e -- i -- l | f -- j -- m | g -- k -- n </code></pre> <p>So then you add an <code>x</code> to the system. I'll try it two different ways:</p> <pre><code>a -- b | c | d -- h -- x | e -- i -- l | f -- j -- m | g -- k -- n </code></pre> <p>That one is just added as a leaf node.</p> <pre><code>a -- b | c | d -- h | x | e -- i -- l | f -- j -- m | g -- k -- n </code></pre> <p>That one is added in the middle of a path.</p> <p>I am wondering what the immutable data structure would be to handle these 2 situations. So essentially we have a function <code>f : graph -&gt; graph'</code> that changes the graph into a "new graph", when under the hood it should only be making a small adjustment to the data structure. Not sure how this would look or how it works. My first attempt at an explanation would be something like this...</p> <p>It starts of in a wrapper object which is like ImmutableJS's API layer on top of the JS objects.</p> <pre><code> -------------------------- | | | a -- b | | | | | c | | | | | d -- h | | | | | e -- i -- l | | | | | f -- j -- m | | | | | g -- k -- n | | | -------------------------- </code></pre> <p>Then you make the change and it creates a <em>new</em> wrapper object.</p> <pre><code> -------------------------- -------------------------- | | | | | a -- b | | | | | | | | | c | | | | | | | | | d -- h --------------------------------- x | | | | | | | e -- i -- l | | | | | | | | | f -- j -- m | | | | | | | | | g -- k -- n | | | | | | | -------------------------- -------------------------- </code></pre> <p>Then likewise for the second example:</p> <pre><code> -------------------------- -------------------------- | | | | | a -- b | | | | | | | | | c | | | | | | | | | d -- h | | | | | | | | | o --------------------------------- x | | | | | | | e -- i -- l | | | | | | | | | f -- j -- m | | | | | | | | | g -- k -- n | | | | | | | -------------------------- -------------------------- </code></pre> <p>The boxes are the API objects you use, and the graphs inside are the plain JS data objects.</p> <p>But in these examples the original graph structure is modified (placing a link to <code>h</code> in the first example, and placing an <code>o</code> placeholder in the second one). So I'm wondering how specifically you would make these things <em>immutable</em>. Every change I make to the graph I would like to "return a new object", but under the hood there is optimal structural sharing.</p> <p>Thank you for your help.</p>
0debug
av_cold void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int bit_exact) { #if HAVE_ALTIVEC if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; fdsp->vector_fmul = ff_vector_fmul_altivec; fdsp->vector_fmul_add = ff_vector_fmul_add_altivec; fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_altivec; if (!bit_exact) { fdsp->vector_fmul_window = ff_vector_fmul_window_altivec; } #endif }
1threat
WHAT IS WRONG IN THIS PL/SQL PROGRAM : declare p number:=371; x number; t number; sum number; begin x:=p; while x>0 loop t:=x mod 10; sum:=sum+ t**3; x:=x/10; end loop; if (sum=p) then dbms_output.put_line(p||+' '||'an armstrong number'); end if; end; /
0debug
WordPress theme not use after uploading m'y website on server : I uploaded my WordPress project on my 1&1 server and i'm very disapointed because all my modification have disapear. My theme is like Virgin. Si what can be wrong? Is there something to save before upload my files ? Thank you
0debug
Make Selenium wait 10 seconds : <p>Yes I know the question has been asked quite often but I still don't get it. I want to make Selenium wait, no matter what. I tried these methods </p> <pre><code>driver.set_page_load_timeout(30) driver.implicitly_wait(90) WebDriverWait(driver, 10) driver.set_script_timeout(30) </code></pre> <p>and other things but it does not work. I need selenium to wait 10 seconds. <strong>NO</strong> not until some element is loaded or whatever, just wait 10 seconds. I know there is this </p> <pre><code>try: element_present = EC.presence_of_element_located((By.ID, 'whatever')) WebDriverWait(driver, timeout).until(element_present) except TimeoutException: print "Timed out waiting for page to load" </code></pre> <p><strong>I do not want that</strong>.</p> <p>If waiting for some seconds is to much (not achievable) for selenium, what other (python) library's/programs would be capable to achieve this task? With Javas Selenium it does not seem to be a problem...</p>
0debug
static uint64_t subpage_read(void *opaque, target_phys_addr_t addr, unsigned len) { subpage_t *mmio = opaque; unsigned int idx = SUBPAGE_IDX(addr); MemoryRegionSection *section; #if defined(DEBUG_SUBPAGE) printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__, mmio, len, addr, idx); #endif section = &phys_sections[mmio->sub_section[idx]]; addr += mmio->base; addr -= section->offset_within_address_space; addr += section->offset_within_region; return io_mem_read(section->mr, addr, len); }
1threat
int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int (*commit_bs_si)(AVCodecContext *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice)) { AVDXVAContext *ctx = DXVA_CONTEXT(avctx); unsigned buffer_count = 0; #if CONFIG_D3D11VA D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4]; #endif #if CONFIG_DXVA2 DXVA2_DecodeBufferDesc buffer2[4]; #endif DECODER_BUFFER_DESC *buffer = NULL, *buffer_slice = NULL; int result, runs = 0; HRESULT hr; unsigned type; do { ff_dxva2_lock(avctx); #if CONFIG_D3D11VA if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, get_surface(frame), 0, NULL); #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->decoder, get_surface(frame), NULL); #endif if (hr != E_PENDING || ++runs > 50) break; ff_dxva2_unlock(avctx); av_usleep(2000); } while(1); if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); ff_dxva2_unlock(avctx); return -1; } #if CONFIG_D3D11VA if (ff_dxva2_is_d3d11(avctx)) { buffer = &buffer11[buffer_count]; type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS; } #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { buffer = &buffer2[buffer_count]; type = DXVA2_PictureParametersBufferType; } #endif result = ff_dxva2_commit_buffer(avctx, ctx, buffer, type, pp, pp_size, 0); if (result) { av_log(avctx, AV_LOG_ERROR, "Failed to add picture parameter buffer\n"); goto end; } buffer_count++; if (qm_size > 0) { #if CONFIG_D3D11VA if (ff_dxva2_is_d3d11(avctx)) { buffer = &buffer11[buffer_count]; type = D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX; } #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { buffer = &buffer2[buffer_count]; type = DXVA2_InverseQuantizationMatrixBufferType; } #endif result = ff_dxva2_commit_buffer(avctx, ctx, buffer, type, qm, qm_size, 0); if (result) { av_log(avctx, AV_LOG_ERROR, "Failed to add inverse quantization matrix buffer\n"); goto end; } buffer_count++; } #if CONFIG_D3D11VA if (ff_dxva2_is_d3d11(avctx)) { buffer = &buffer11[buffer_count + 0]; buffer_slice = &buffer11[buffer_count + 1]; } #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { buffer = &buffer2[buffer_count + 0]; buffer_slice = &buffer2[buffer_count + 1]; } #endif result = commit_bs_si(avctx, buffer, buffer_slice); if (result) { av_log(avctx, AV_LOG_ERROR, "Failed to add bitstream or slice control buffer\n"); goto end; } buffer_count += 2; assert(buffer_count == 1 + (qm_size > 0) + 2); #if CONFIG_D3D11VA if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_SubmitDecoderBuffers(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, buffer_count, buffer11); #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { DXVA2_DecodeExecuteParams exec = { .NumCompBuffers = buffer_count, .pCompressedBuffers = buffer2, .pExtensionData = NULL, }; hr = IDirectXVideoDecoder_Execute(DXVA2_CONTEXT(ctx)->decoder, &exec); } #endif if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", hr); result = -1; } end: #if CONFIG_D3D11VA if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder); #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) hr = IDirectXVideoDecoder_EndFrame(DXVA2_CONTEXT(ctx)->decoder, NULL); #endif ff_dxva2_unlock(avctx); if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", hr); result = -1; } return result; }
1threat
why this code didn't work corectly? : I have a following probleb to resolve, i don't understand why my code didnt work corectly. Here is the problem to resolve: Write a JavaScript function that takes as input an array of two numbers (start and end) and prints at the console a HTML table of 3 columns. The first column should hold a number num, changing from start to end. The second column should hold num*num. The third column should hold "yes" if num is Fibonacci number or "no" otherwise. The table should have header cells titled "Num", "Square" and "Fib". See the below examples. Input The input data comes as array of two numbers: start and end. The input data will always be valid and in the format described. There is no need to check it explicitly. Output Print at the console the above described table in the same format like the examples below. Don't add additional spaces. Whitespace and character casing are important, so please use the same as in the below examples. Constraints • The input is passed to the first JavaScript function found in your code as array of 2 elements. • The numbers start and end are positive integers in the range [1…1 000 000] and start ≤ end. • Allowed working time for your program: 0.2 seconds. • Allowed memory: 16 MB. This code is not the same by the requirement of problem, but the idea is the same I guess. Here is my code: <!-- begin snippet: js hide: false --> <!-- language: lang-js --> var fib = []; var a, b, result; a = 0; b = 1; result = b; for (var i = 1; i < 31; i++) { result = a + b; a = b; b = result; fib.push(result); } console.log("<table>"); console.log("<tr><th>Num</th><th>Square</th><th>Fib</th></tr>"); var start = 2; var end = 6; function isFib(start, end) { for (i = start; i < end; i++) { fib.forEach(function (element) { if (i === element) { return "yes"; } else { return "no"; } }); } } function buildTable() { for(var j = start; j < end; j++) { console.log("<tr><td>" + j + "</td><td>" + j * j + "</td><td>" + isFib(start, end) + "</td></tr>"); } } buildTable(start, end); <!-- end snippet --> This code is not the same by the requirement of problem, but the idea is same i guess.
0debug
Are there potential performance penalties for `auto o = SomeType(args)` instead of `SomeType o(args)`? : <p>I'm a great fan of <code>auto</code> and prefer writing <code>auto o = SomeType(args)</code>.</p> <p>It almost always results in calling a constructor only.</p> <p>@NathanOliver <a href="http://wandbox.org/permlink/KVmWnL9NJ72rJ2fn" rel="nofollow noreferrer">showed</a> that <code>-fno-elide-constructors</code> is capable of turning off copy elision and resulting in a call to a constructor and an assignment operator.</p> <p>Are there real-world cons of writing <code>auto o = SomeType(args)</code>?</p>
0debug
int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) { struct kvm_msi msi; KVMMSIRoute *route; if (s->direct_msi) { msi.address_lo = (uint32_t)msg.address; msi.address_hi = msg.address >> 32; msi.data = msg.data; msi.flags = 0; memset(msi.pad, 0, sizeof(msi.pad)); return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi); } route = kvm_lookup_msi_route(s, msg); if (!route) { int virq; virq = kvm_irqchip_get_virq(s); if (virq < 0) { return virq; } route = g_malloc(sizeof(KVMMSIRoute)); route->kroute.gsi = virq; route->kroute.type = KVM_IRQ_ROUTING_MSI; route->kroute.flags = 0; route->kroute.u.msi.address_lo = (uint32_t)msg.address; route->kroute.u.msi.address_hi = msg.address >> 32; route->kroute.u.msi.data = msg.data; kvm_add_routing_entry(s, &route->kroute); QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(msg.data)], route, entry); } assert(route->kroute.type == KVM_IRQ_ROUTING_MSI); return kvm_set_irq(s, route->kroute.gsi, 1); }
1threat
Replacing string character in python : <p>I am making a program where the user inputs some text, and I wan't all the characters in that text that is not in the variable "alfabet" to be changed to "?". How can I do this? I also want a to do it in two functions, main and clean_text. My code looks like this now:</p> <pre><code>def clean_text(): for char in text: if char in alfabeth: continue elif char not in alfabeth: #don't know what to do here #text[] = "?" def main(): userInput = input("type in text: ") text = list(userInput) if__name__ == "__main__": main() clean_text(text) </code></pre>
0debug
QmpOutputVisitor *qmp_output_visitor_new(void) { QmpOutputVisitor *v; v = g_malloc0(sizeof(*v)); v->visitor.type = VISITOR_OUTPUT; v->visitor.start_struct = qmp_output_start_struct; v->visitor.end_struct = qmp_output_end_struct; v->visitor.start_list = qmp_output_start_list; v->visitor.next_list = qmp_output_next_list; v->visitor.end_list = qmp_output_end_list; v->visitor.type_int64 = qmp_output_type_int64; v->visitor.type_uint64 = qmp_output_type_uint64; v->visitor.type_bool = qmp_output_type_bool; v->visitor.type_str = qmp_output_type_str; v->visitor.type_number = qmp_output_type_number; v->visitor.type_any = qmp_output_type_any; v->visitor.type_null = qmp_output_type_null; v->visitor.free = qmp_output_free; QTAILQ_INIT(&v->stack); return v; }
1threat
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return (result)
0debug
How do I run Javascript on Document Ready in Google Optimize? : <p>How do I run javascript on window load or document ready in Google Optimize campaigns? It seems like it allows me to select DOM elements all the way up to Body, but I need to run js on document ready.</p>
0debug
Could not find gradle wrapper within Android SDK. Might need to update your Android SDK : <p>I am trying to take build in an ionic2 application. I got this error while running <code>ionic build android</code>. The error log is </p> <pre><code>ANDROID_HOME=/home/varun/Android/Sdk JAVA_HOME=/usr/lib/jvm/java-8-oracle Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK. Looked here: /home/varun/Android/Sdk/tools/templates/gradle/wrapper </code></pre> <p>I tried updating the sdk but it was found that the sdk version is latest. </p> <p>When i looked at the <code>Android/Sdk/tools</code> folder there is no <code>templates</code> directory. I am running on ubuntu 16.04, with cordova version <code>6.5.0</code> </p>
0debug
How to Android SQLite DB restore? : <p>I have done an android application using SQLiteOpenHelper, database name is "database_backup".</p> <p><strong>My doubt is mentioned below:</strong></p> <ul> <li>If the user uninstall my application, and reinstall again. </li> <li>Is any way to get my Database again, with all data?</li> </ul>
0debug
please can someone help it shows only assignment,cal : <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; public class movingplayer1 : MonoBehaviour { private Rigidbody2D reg; public float speed = 10f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update(){ var Newx = 0f; var Newy = 0f; reg = GetComponent&lt;Rigidbody2D&gt; (); if(Input.GetKey("right")){ Newx+speed; } else if(Input.GetKey("left")){ Newx-speed; } reg.AddForce (new vector2 (Newx,Newy)); } } </code></pre> <p>im new in oop and i need some help guys it shows only assignment call increment decrement await and new object expressions can be used as a statement. </p>
0debug
Is it possible to add border to image in GitHub markdown? : <p>I need to add border to the image in GitHub README.md file. This is how image should be embeded:</p> <pre><code>![GitHub Logo](/images/logo.png) </code></pre> <p>I have tried to wrap image with the table:</p> <pre><code>|--------------------------------| |![GitHub Logo](/images/logo.png)| </code></pre> <p>but it is not possible to create table without header.</p> <p>I have also tried to include image as html tag:</p> <pre><code>&lt;img src="/images/logo.png" style="border: 1px solid black" /&gt; </code></pre> <p>but without success. Is there any way how to do this?</p>
0debug
Highlight Circumference of a circle using D3.js : <p>How to highlight the circumference of a circle in d3.js when the user hovers overs it? I wish to bolden the width of the circumference of a circle when the user hovers over the same</p> <p><a href="https://i.stack.imgur.com/qUsPB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qUsPB.png" alt="As shown in the example here"></a></p>
0debug
Importing BMP file in Turboc++ issue:BMP file is not being displayed in the output screen : I am trying to import Rama.BMP file in the graphics window of TurboC++, for this its source code is as follows(NOTE: I have not mentioned the header files in the source code): struct A { char type[2]; unsigned long size; unsigned short int reserved1,reserved2; unsigned long offset; unsigned long width,height; unsigned short int planes; unsigned short int bits; unsigned long compression; unsigned long imagesize; unsigned long xresolution,yresolution; unsigned long ncolors; unsigned long importantcolors; }HEADER; huge DetectSvga() { return 2; } void show() { fstream File; File.open("C:\\TURBOC3\\BIN\\Rama.BMP",ios::in); char ch; File.read((char*)&HEADER,sizeof(HEADER)); unsigned int i; char ColorBytes[4]; char *PaletteData; PaletteData=new char[256*3]; if(PaletteData) { for(i=0;i<256;i++) { File.read(ColorBytes,4); PaletteData[(int)(i*3+2)]=ColorBytes[0]>>2; PaletteData[(int)(i*3+0)]=ColorBytes[2]>>2; } outp(0x03c8,0); for(i=0;i<256*3;i++) outp(0x03c9,PaletteData[i]); delete[]PaletteData; } for(i=0;i<HEADER.height;i++) { for(int j=0;j<HEADER.width;) { File.read(&ch,1); putpixel(0+(j++),0+HEADER.height-i-1,ch); } } File.close(); } void main() { clrscr(); int gd=DETECT,gm,a; initgraph(&gd,&gm,"C:\\TURBOC3\\BGI"); installuserdriver("svga256",&DetectSvga); show(); getch(); closegraph(); } Now, i am not getting the BMP file in the graphics window, i.e, Graphics Window is not displaying Rama.bmp so how to fix it? Any help...
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
static int v4l2_set_parameters(AVFormatContext *s1) { struct video_data *s = s1->priv_data; struct v4l2_standard standard = { 0 }; struct v4l2_streamparm streamparm = { 0 }; struct v4l2_fract *tpf; AVRational framerate_q = { 0 }; int i, ret; if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); return ret; } if (s->standard) { if (s->std_id) { ret = 0; av_log(s1, AV_LOG_DEBUG, "Setting standard: %s\n", s->standard); for (i = 0; ; i++) { standard.index = i; if (v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) { ret = AVERROR(errno); break; } if (!av_strcasecmp(standard.name, s->standard)) break; } if (ret < 0) { av_log(s1, AV_LOG_ERROR, "Unknown or unsupported standard '%s'\n", s->standard); return ret; } if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { ret = AVERROR(errno); av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_STD): %s\n", av_err2str(ret)); return ret; } } else { av_log(s1, AV_LOG_WARNING, "This device does not support any standard\n"); } } if (v4l2_ioctl(s->fd, VIDIOC_G_STD, &s->std_id) == 0) { tpf = &standard.frameperiod; for (i = 0; ; i++) { standard.index = i; if (v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) { ret = AVERROR(errno); if (ret == AVERROR(EINVAL)) { tpf = &streamparm.parm.capture.timeperframe; break; } av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", av_err2str(ret)); return ret; } if (standard.id == s->std_id) { av_log(s1, AV_LOG_DEBUG, "Current standard: %s, id: %"PRIx64", frameperiod: %d/%d\n", standard.name, (uint64_t)standard.id, tpf->numerator, tpf->denominator); break; } } } else { tpf = &streamparm.parm.capture.timeperframe; } streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) < 0) { ret = AVERROR(errno); av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", av_err2str(ret)); return ret; } if (framerate_q.num && framerate_q.den) { if (streamparm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) { tpf = &streamparm.parm.capture.timeperframe; av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", framerate_q.den, framerate_q.num); tpf->numerator = framerate_q.den; tpf->denominator = framerate_q.num; if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) < 0) { ret = AVERROR(errno); av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_PARM): %s\n", av_err2str(ret)); return ret; } if (framerate_q.num != tpf->denominator || framerate_q.den != tpf->numerator) { av_log(s1, AV_LOG_INFO, "The driver changed the time per frame from " "%d/%d to %d/%d\n", framerate_q.den, framerate_q.num, tpf->numerator, tpf->denominator); } } else { av_log(s1, AV_LOG_WARNING, "The driver does not allow to change time per frame\n"); } } if (tpf->denominator > 0 && tpf->numerator > 0) { s1->streams[0]->avg_frame_rate.num = tpf->denominator; s1->streams[0]->avg_frame_rate.den = tpf->numerator; s1->streams[0]->r_frame_rate = s1->streams[0]->avg_frame_rate; } else av_log(s1, AV_LOG_WARNING, "Time per frame unknown\n"); return 0; }
1threat
Web API optional parameters : <p>I have a controller with the following signature:</p> <pre><code>[Route("products/filter/{apc=apc}/{xpc=xpc}/{sku=sku}")] public IHttpActionResult Get(string apc, string xpc, int? sku) { ... } </code></pre> <p>I call this method with following URIs:</p> <ul> <li>~/api/products/filter?apc=AA&amp;xpc=BB</li> <li>~/api/products/filter?sku=7199123</li> </ul> <p>The first URI works without issue. The second one has a strange side effect. Even though the default values for apc and xpc should be null when not provided, the parameters are actually their names. I can overcome this by adding the additional logic:</p> <pre><code>apc = (apc == "apc") ? null : apc; xpc = (xpc == "xpc") ? null : xpc; </code></pre> <p>This seems like a hack, and would be problematic if value passed was ever equal to the parameter name. </p> <p>Is there a way to define the Route without this side effect? </p>
0debug
static void qmp_output_start_list(Visitor *v, const char *name, GenericList **listp, size_t size, Error **errp) { QmpOutputVisitor *qov = to_qov(v); QList *list = qlist_new(); qmp_output_add(qov, name, list); qmp_output_push(qov, list, listp); }
1threat
Align a group of views containing a chain in a ConstraintLayout : <p>I have three views in a ConstraintLayout and want to align then like this:</p> <p><a href="https://i.stack.imgur.com/3az1I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3az1I.png" alt="enter image description here"></a></p> <p>Right now views <strong>B</strong> and <strong>C</strong> form a vertical chain, and <strong>A</strong> is centered relative to the chain. But how do I align the entire group centered in the parent? Note that View <strong>C</strong> may be <code>GONE</code>.</p>
0debug
Trying to download and install with apt-get with specified directory : <p>I am trying to do <code>sudo apt-get --download-only &lt;package_name&gt; ??target_directory??</code> but i want to specify the download location so that, in future i want to install my pre-downloaded package without internet connection with <code>sudo apt-get --no-download &lt;package_name&gt; ??target_directory??</code>. The problem here is, I want to choose the target directories as '/user/desktop/blabla' but don't know how to specify it with apt-get.</p> <p>If you can help me, I will be grateful :) Have a nice day.</p>
0debug
Composer Autoloading classes not found : <p>I have folder structure like:</p> <pre><code>includes/ libraries/ Classes/ Contact/ Contact.php ContactController.php admin/ controllers/ contact/ edit.php </code></pre> <p>Contact.php is my class that file that I'm trying to use. The file contains.</p> <pre><code>&lt;?php namespace Classes; class Contact { function __construct() { die('here'); } } </code></pre> <p>I have my composer.json file like:</p> <pre><code>{ "autoload": { "psr-4": { "Classes\\": "includes/libraries/Classes/" } }, } </code></pre> <p>The file I'm trying to use the Contact class in is <code>edit.php</code> within the <code>admin/controllers/contact/</code> folder. My <code>edit.php</code> file is like:</p> <pre><code>&lt;?php use Classes\Contact; $contact = new Contact(); var_dump($contact); </code></pre> <p>This file has the <code>vendor/autoload.php</code> file included, yet I can't seem to get it to use the class?</p>
0debug
Spring Async ThreadPoolTaskScheduler not initialized : <p>I'm trying to use Async annotation in Spring but I'm getting </p> <pre><code>java.lang.IllegalStateException: ThreadPoolTaskScheduler not initialized </code></pre> <p>error, when I try to run the method marked as Async. The following is the configuration for Async:</p> <pre><code>@EnableScheduling @EnableAsync @Configuration public class SchedulingConfiguration implements AsyncConfigurer{ @Override public Executor getAsyncExecutor() { ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); scheduler.setPoolSize(10); return scheduler; } } </code></pre> <p>and the following is the declaration of async method.</p> <pre><code>@Async @Transactional(value = "baseTransactionManager", isolation = Isolation.READ_COMMITTED) public void foo(Bar bar) {// some code here} </code></pre> <p>What am I missing in here?</p> <p>Thanks in advance.</p>
0debug
const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt) { if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB) return NULL; else return av_pix_fmt_descriptors[pix_fmt].name; }
1threat
jQuery On 1+ ul li href click ajax not displaying results in correct Div : I have a href link for my unordered html list. When the page loads for the first time, only the welcome page is visible as expected. When I click on the list for the first time after the page loads, I get the desired results on the desired div after clicking on the href link on the ul li. However, if i subsequently click on the other tab the results are displayed on the one i had clicked before. For example if i click on href #tab2a the results will be displayed on #tab2b nad vice versa. Ajax will direct results to the div I clicked on previously. I'm at a loss here! What could i be missing on my jQuery that will force the results to be displayed in the div that's referenced by the href id tag on unstructured list. I'm using an if else if condition. Is this the right approach? Thank you all in advance.
0debug
Custom Serchbar in ios : Hello i am using `UISerchbar` in `tableview` but is there any easy way to create custom `searchbar` in `tableview headerview`?
0debug
int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt) { AVCodecInternal *avci = avctx->internal; int ret; AVPacket tmp = *avpkt; if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) { av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n"); } *got_picture_ptr = 0; if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx)) avcodec_get_frame_defaults(picture); if (!avctx->refcounted_frames) av_frame_unref(&avci->to_free); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { int did_split = av_packet_split_side_data(&tmp); apply_param_change(avctx, &tmp); avctx->pkt = &tmp; if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr, &tmp); else { ret = avctx->codec->decode(avctx, picture, got_picture_ptr, &tmp); picture->pkt_dts = avpkt->dts; if(!avctx->has_b_frames){ av_frame_set_pkt_pos(picture, avpkt->pos); } if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) { if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio; if (!picture->width) picture->width = avctx->width; if (!picture->height) picture->height = avctx->height; if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt; } } add_metadata_from_side_data(avctx, picture); emms_c(); avctx->pkt = NULL; if (did_split) { ff_packet_free_side_data(&tmp); if(ret == tmp.size) ret = avpkt->size; } if (ret < 0 && picture->data[0]) av_frame_unref(picture); if (*got_picture_ptr) { if (!avctx->refcounted_frames) { avci->to_free = *picture; avci->to_free.extended_data = avci->to_free.data; memset(picture->buf, 0, sizeof(picture->buf)); } avctx->frame_number++; av_frame_set_best_effort_timestamp(picture, guess_correct_pts(avctx, picture->pkt_pts, picture->pkt_dts)); } } else ret = 0; picture->extended_data = picture->data; return ret; }
1threat
static inline void tcg_out_ldst(TCGContext *s, int ret, int addr, int offset, int op) { if (check_fit_tl(offset, 13)) { tcg_out32(s, op | INSN_RD(ret) | INSN_RS1(addr) | INSN_IMM13(offset)); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T1, offset); tcg_out_ldst_rr(s, ret, addr, TCG_REG_T1, op); } }
1threat
Pass array to varargs function in php : <p>I've got a varargs type method defined in PHP 7</p> <pre class="lang-php prettyprint-override"><code>function selectAll(string $sql, ...$params) { } </code></pre> <p>The problem I'm running into is that sometimes I want to call this method when I already have an array, and I can't just directly pass an array variable to this method.</p>
0debug
How to get starting creating a WordPress plugin? : <p>I would like to start writing a WordPress plugin that will allow the user to play a scratch the card game (like the lottery). I would like to ask what programming language I should learn and how to get started. Is anyone with similar experiences and what are the recommendations you can offer ? Thanks in advance for your responses</p>
0debug
How do make a H1 move down page whilst page scrolls? : <p>Hi Im looking to make a heading keep its position at the top of the page whilst the user scrolls down or up. How do I go about doing this. </p> <p>Many Thanks</p> <p>:)</p>
0debug
displaying a table from mssql server with php : i have written a code to connect to my sql server which is successful but it only displays the column name with no corresponding value from the database. What am i doing wrong? <?php $serverName = "VM4FE8D04"; $databaseName = "NNPC-ChevronScholarship"; $connectionInfo = array("Database"=>$databaseName); /* Connect using SQL Server Authentication. */ $conn = sqlsrv_connect( $serverName, $connectionInfo); $tsql = "SELECT * FROM ExamSlip"; /* Execute the query. */ $stmt = sqlsrv_query( $conn, $tsql); if ( $stmt ) { echo "Statement executed.<br>\n"; } else { echo "Error in statement execution.\n"; die( print_r( sqlsrv_errors(), true)); } /* Iterate through the result set printing a row of data upon each iteration.*/ while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) { echo "Name: ".$row[Names]."\n"; echo "Application No: ".$row[ApplicationNo]."\n"; echo "Serial No: ".$row[SerialNo]."<br>\n"; echo "-----------------<br>\n"; } /* Free statement and connection resources. */ sqlsrv_free_stmt( $stmt); sqlsrv_close( $conn); ?>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
why the map activity is terminate in android studio? : i don't know why the app is terminated ?! [enter image description here][1] [enter image description here][2] [enter image description here][3] [1]: https://i.stack.imgur.com/3GpKZ.png [2]: https://i.stack.imgur.com/RKN2N.png [3]: https://i.stack.imgur.com/SQKHE.png
0debug
void ff_float_init_arm_vfp(DSPContext* c, AVCodecContext *avctx) { c->vector_fmul = vector_fmul_vfp; c->vector_fmul_reverse = vector_fmul_reverse_vfp; #ifdef HAVE_ARMV6 c->float_to_int16 = float_to_int16_vfp; #endif }
1threat
SwsVector *sws_getGaussianVec(double variance, double quality) { const int length = (int)(variance * quality + 0.5) | 1; int i; double middle = (length - 1) * 0.5; SwsVector *vec = sws_allocVec(length); if (!vec) return NULL; for (i = 0; i < length; i++) { double dist = i - middle; vec->coeff[i] = exp(-dist * dist / (2 * variance * variance)) / sqrt(2 * variance * M_PI); } sws_normalizeVec(vec, 1.0); return vec; }
1threat
Mac os on VirtualBox does not recognize Iphone : <p>I have been trying to connect an iPhone to Mac OS High Sierra, I've installed on VirtualBox for testing swift app I am trying to develop. However, even I connect the phone to the USB, I can't select the phone from the devices.The message in the device section says that No device connected to the mac.</p> <p>So I have following questions, 1)Is it even possible to deploy and test iPhone app from mac os hosted on VirtualBox? and how to do it? 2)Are there any alternatives VMs to VirtualBox that allows me to connect my iPhone to virtual mac os for development purposes?</p> <p>Thank you.</p>
0debug
c++ std::map deleting pointers : <p>I will link the classes and output from execution below.</p> <p>The problem is, the <code>std::map</code> is iterating through and the pointer stored in the second which is of type <code>void*</code> is not deleting from the heap and freeing. The <code>std::map</code> iterated through in the <code>void ShutDown(void);</code> method of the <code>class Engine</code> which is called in the <code>destructor</code> for that class.</p> <p>I will post the code and output from execution.</p> <p>Engine header file:</p> <pre><code>#ifndef _TEST_ENGINE_H_ #define _TEST_ENGINE_H_ #include "test_graphics_system.h" #include &lt;iostream&gt; #include &lt;map&gt; namespace Core { enum class EngineStatus { Invalid, Constructing, Setup, Running, ShutDown, Destroying }; class Engine { public: Engine(void); ~Engine(void); template&lt;class T&gt; T * GetSystem(SystemType systemType) { if (mSystems[systemType]) { return (T*)mSystems[systemType]; } else { std::wcout &lt;&lt; "System doe not exist" &lt;&lt; std::endl; } return nullptr; } int Run(void); private: template&lt;class T&gt; void AddSystem(T * system) { size_t count = mSystems.size(); auto pair = std::make_pair(system-&gt;GetType(), (T*)system); mSystems.insert(pair); if (count == mSystems.size()) std::wcout &lt;&lt; "System failed to be added" &lt;&lt; std::endl; else std::wcout &lt;&lt; "System added" &lt;&lt; std::endl; } void Setup(void); void ShutDown(void); void SetupGraphicsSystem(void); static EngineStatus mEngineStatus; std::map&lt;SystemType, void*&gt; mSystems; bool mRunning; }; } #endif _TEST_ENGINE_H_ </code></pre> <p>Engine source file:</p> <pre><code>#include "test_engine.h" using namespace std; using namespace Core; EngineStatus Engine::mEngineStatus = EngineStatus::Invalid; Engine::Engine(void) { mEngineStatus = EngineStatus::Constructing; Setup(); } Engine::~Engine(void) { mEngineStatus = EngineStatus::Destroying; ShutDown(); } int Engine::Run(void) { mEngineStatus = EngineStatus::Running; return 0; } void Engine::Setup(void) { mEngineStatus = EngineStatus::Setup; SetupGraphicsSystem(); } void Engine::ShutDown(void) { mEngineStatus = EngineStatus::ShutDown; wcout &lt;&lt; endl; int count = 0; size_t total = mSystems.size(); for (auto obj : mSystems) { safe_delete(obj.second); wcout &lt;&lt; "\rSystem(s) deleted: " &lt;&lt; ++count &lt;&lt; " of " &lt;&lt; total; } } void Engine::SetupGraphicsSystem(void) { GraphicsSystem * gs = new GraphicsSystem(mSystems.size(), L"GraphicsSystem01", SystemType::Graphics); AddSystem(gs); } </code></pre> <p>Main source file:</p> <pre><code>#include "safe_del_rel.h" #include "strings.h" #include "test_engine.h" using namespace std; using namespace Core; void _DebugMemLeakDetection(void) { #if defined(_DEBUG) || defined(DEBUG) int flag = _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit _CrtSetDbgFlag(flag); _CrtSetBreakAlloc(0); #endif } int main(int argv, char argc[]) { _DebugMemLeakDetection(); Engine * eng = new Engine(); eng-&gt;Run(); system("pause"); safe_delete(eng); return 0; } </code></pre> <p>Output from last runtime:</p> <pre><code>'test_engine_console.exe' (Win32): Loaded 'C:\vs_projects\test_engine\x64\Debug\test_engine_console.exe'. Symbols loaded. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Unloaded 'C:\Windows\System32\vcruntime140d.dll' 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file. 'test_engine_console.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file. The thread 0x4134 has exited with code 0 (0x0). The thread 0x46ac has exited with code 0 (0x0). The thread 0x307c has exited with code 0 (0x0). Detected memory leaks! Dumping objects -&gt; {161} normal block at 0x00000293DD5E2680, 48 bytes long. Data: &lt;G r a p h i c s &gt; 47 00 72 00 61 00 70 00 68 00 69 00 63 00 73 00 {160} normal block at 0x00000293DD5E1820, 16 bytes long. Data: &lt; R] &gt; A0 52 5D DD 93 02 00 00 00 00 00 00 00 00 00 00 Object dump complete. The program '[12764] test_engine_console.exe' has exited with code 0 (0x0). </code></pre> <p>If someone can help plesae do.</p>
0debug
JavaCS wont crashes : First thing: I'm not a native english speaker so i try to do my best. Im trying to use JavaCV but it doesn't work i get a error: <!-- begin snippet --> OpenJDK 64-Bit Server VM warning: You have loaded library /usr/lib/libtbb.so which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'. Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) Caused by: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711) at com.googlecode.javacpp.Loader.load(Loader.java:586) at com.googlecode.javacpp.Loader.load(Loader.java:540) at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:134) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at com.googlecode.javacpp.Loader.load(Loader.java:561) at com.googlecode.javacpp.Loader.load(Loader.java:540) at com.googlecode.javacv.cpp.opencv_core$CvArr.<clinit>(opencv_core.java:156) at Main.main(Main.java:18) ... 5 more Caused by: java.lang.UnsatisfiedLinkError: /tmp/javacpp22248052399215/libjniopencv_core.so: libopencv_core.so.2.4: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:700) ... 14 more <!-- end snippet --> i installed OpenCV with this tutorial: https://udallascs.wordpress.com/2014/03/30/adding-opencv-and-configuring-to-work-with-eclipse-and-java/ and here is the source code: <!-- begin snippet --> import com.googlecode.javacv.cpp.opencv_core.IplImage; //import static com.googlecode.javacv.cpp.opencv_core.*; //import static com.googlecode.javacv.cpp.opencv_imgproc.*; //import static com.googlecode.javacv.cpp.opencv_highgui.*; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public class Main { public static void main(String s[]) { try { BufferedImage bi = ImageIO.read(new File("/home/arjan/Desktop/HelloWorld.jpg")); IplImage img = IplImage.createFrom(bi); // cvShowImage("Hello-World",img); // cvSmooth(img, img, CV_GAUSSIAN, 13); // cvShowImage("Blur-Image",img); // cvWaitKey(); // cvReleaseImage(img); }catch (Exception ex) {ex.printStackTrace();} } } <!-- end snippet --> I'm using arch linux and also installed OpenCV with pacman here is a image of the jars I use [picture of jar files][1] [1]: https://i.stack.imgur.com/M6pqj.png
0debug
void helper_ldq_kernel(uint64_t t0, uint64_t t1) { ldq_kernel(t1, t0); }
1threat
static void curses_setup(void) { int i, colour_default[8] = { COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, }; initscr(); noecho(); intrflush(stdscr, FALSE); nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE); start_color(); raw(); scrollok(stdscr, FALSE); for (i = 0; i < 64; i++) { init_pair(i, colour_default[i & 7], colour_default[i >> 3]); } for (i = 64; i < COLOR_PAIRS; i++) { init_pair(i, COLOR_WHITE, COLOR_BLACK); } #if 0 ACS_S1; ACS_S3; ACS_S7; ACS_S9; #endif vga_to_curses['\0'] = ' '; vga_to_curses[0x04] = ACS_DIAMOND; vga_to_curses[0x0a] = ACS_RARROW; vga_to_curses[0x0b] = ACS_LARROW; vga_to_curses[0x18] = ACS_UARROW; vga_to_curses[0x19] = ACS_DARROW; vga_to_curses[0x9c] = ACS_STERLING; vga_to_curses[0xb0] = ACS_BOARD; vga_to_curses[0xb1] = ACS_CKBOARD; vga_to_curses[0xb3] = ACS_VLINE; vga_to_curses[0xb4] = ACS_RTEE; vga_to_curses[0xbf] = ACS_URCORNER; vga_to_curses[0xc0] = ACS_LLCORNER; vga_to_curses[0xc1] = ACS_BTEE; vga_to_curses[0xc2] = ACS_TTEE; vga_to_curses[0xc3] = ACS_LTEE; vga_to_curses[0xc4] = ACS_HLINE; vga_to_curses[0xc5] = ACS_PLUS; vga_to_curses[0xce] = ACS_LANTERN; vga_to_curses[0xd8] = ACS_NEQUAL; vga_to_curses[0xd9] = ACS_LRCORNER; vga_to_curses[0xda] = ACS_ULCORNER; vga_to_curses[0xdb] = ACS_BLOCK; vga_to_curses[0xe3] = ACS_PI; vga_to_curses[0xf1] = ACS_PLMINUS; vga_to_curses[0xf2] = ACS_GEQUAL; vga_to_curses[0xf3] = ACS_LEQUAL; vga_to_curses[0xf8] = ACS_DEGREE; vga_to_curses[0xfe] = ACS_BULLET; }
1threat
Random number in time period : <p>How to solve a problem with Kotlin when I want to generate random numbers in time period (eg. 1 sec) and than than that numbers collect somehow and make Sum of that numbers. Thanks</p>
0debug
static int fill_note_info(struct elf_note_info *info, long signr, const CPUArchState *env) { #define NUMNOTES 3 CPUState *cpu = ENV_GET_CPU((CPUArchState *)env); TaskState *ts = (TaskState *)cpu->opaque; int i; info->notes = g_malloc0(NUMNOTES * sizeof (struct memelfnote)); if (info->notes == NULL) return (-ENOMEM); info->prstatus = g_malloc0(sizeof (*info->prstatus)); if (info->prstatus == NULL) return (-ENOMEM); info->psinfo = g_malloc0(sizeof (*info->psinfo)); if (info->prstatus == NULL) return (-ENOMEM); fill_prstatus(info->prstatus, ts, signr); elf_core_copy_regs(&info->prstatus->pr_reg, env); fill_note(&info->notes[0], "CORE", NT_PRSTATUS, sizeof (*info->prstatus), info->prstatus); fill_psinfo(info->psinfo, ts); fill_note(&info->notes[1], "CORE", NT_PRPSINFO, sizeof (*info->psinfo), info->psinfo); fill_auxv_note(&info->notes[2], ts); info->numnote = 3; info->notes_size = 0; for (i = 0; i < info->numnote; i++) info->notes_size += note_size(&info->notes[i]); cpu_list_lock(); CPU_FOREACH(cpu) { if (cpu == thread_cpu) { continue; } fill_thread_info(info, (CPUArchState *)cpu->env_ptr); } cpu_list_unlock(); return (0); }
1threat
Swift dispatch to overridden methods in subclass extensions : <p>overriding method signatures in extensions seems to produce unpredictable results in certain cases. The following example demonstrates two different results with a similar pattern.</p> <pre><code>class A: UIViewController { func doThing() { print("dothing super class") } override func viewDidLoad() { print("viewdidload superclass") super.viewDidLoad() } } class B: A { } extension B { override func doThing() { print("dothing sub class") super.doThing() } override func viewDidLoad() { print("viewdidload subclass") super.viewDidLoad() } } let a: A = B() a.doThing() let vc: UIViewController = B() vc.viewDidLoad() </code></pre> <p>This prints :</p> <pre><code>dothing super class viewdidload subclass viewdidload superclass </code></pre> <p>You can see this skips the <code>B</code>'s implementation of <code>doThing</code> when it is cast as <code>A</code>, however includes both implementations of <code>viewDidLoad</code> when cast as <code>UIViewController</code>. Is this the expected behavior? If so, what is the reason for this?</p> <p>ENV: Xcode 7.3, Playground</p>
0debug
Compare time in perl using subroutine : <p>I found the script to compare the time and get the return value. But that script not validating the following scenario properly. Please help me on this.</p> <p>Script Path : <a href="http://perlprogramming.language-tutorial.com/2012/10/perl-function-to-compare-two-dates.html#recent" rel="nofollow">http://perlprogramming.language-tutorial.com/2012/10/perl-function-to-compare-two-dates.html#recent</a></p> <pre><code>Input : 2015-07-01 00:50:00,2015-07-01 00:00:00, returns : 0 </code></pre>
0debug
udp_input(register struct mbuf *m, int iphlen) { Slirp *slirp = m->slirp; register struct ip *ip; register struct udphdr *uh; int len; struct ip save_ip; struct socket *so; DEBUG_CALL("udp_input"); DEBUG_ARG("m = %lx", (long)m); DEBUG_ARG("iphlen = %d", iphlen); if(iphlen > sizeof(struct ip)) { ip_stripoptions(m, (struct mbuf *)0); iphlen = sizeof(struct ip); } ip = mtod(m, struct ip *); uh = (struct udphdr *)((caddr_t)ip + iphlen); len = ntohs((uint16_t)uh->uh_ulen); if (ip->ip_len != len) { if (len > ip->ip_len) { goto bad; } m_adj(m, len - ip->ip_len); ip->ip_len = len; } save_ip = *ip; save_ip.ip_len+= iphlen; if (uh->uh_sum) { memset(&((struct ipovly *)ip)->ih_mbuf, 0, sizeof(struct mbuf_ptr)); ((struct ipovly *)ip)->ih_x1 = 0; ((struct ipovly *)ip)->ih_len = uh->uh_ulen; if(cksum(m, len + sizeof(struct ip))) { goto bad; } } if (ntohs(uh->uh_dport) == BOOTP_SERVER && (ip->ip_dst.s_addr == slirp->vhost_addr.s_addr || ip->ip_dst.s_addr == 0xffffffff)) { bootp_input(m); goto bad; } if (ntohs(uh->uh_dport) == TFTP_SERVER && ip->ip_dst.s_addr == slirp->vhost_addr.s_addr) { tftp_input(m); goto bad; } if (slirp->restricted) { goto bad; } so = slirp->udp_last_so; if (so->so_lport != uh->uh_sport || so->so_laddr.s_addr != ip->ip_src.s_addr) { struct socket *tmp; for (tmp = slirp->udb.so_next; tmp != &slirp->udb; tmp = tmp->so_next) { if (tmp->so_lport == uh->uh_sport && tmp->so_laddr.s_addr == ip->ip_src.s_addr) { so = tmp; break; } } if (tmp == &slirp->udb) { so = NULL; } else { slirp->udp_last_so = so; } } if (so == NULL) { so = socreate(slirp); if (!so) { goto bad; } if(udp_attach(so) == -1) { DEBUG_MISC((dfd," udp_attach errno = %d-%s\n", errno,strerror(errno))); sofree(so); goto bad; } so->so_laddr = ip->ip_src; so->so_lport = uh->uh_sport; if ((so->so_iptos = udp_tos(so)) == 0) so->so_iptos = ip->ip_tos; } so->so_faddr = ip->ip_dst; so->so_fport = uh->uh_dport; iphlen += sizeof(struct udphdr); m->m_len -= iphlen; m->m_data += iphlen; if(sosendto(so,m) == -1) { m->m_len += iphlen; m->m_data -= iphlen; *ip=save_ip; DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno))); icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno)); } m_free(so->so_m); m->m_len += iphlen; m->m_data -= iphlen; *ip=save_ip; so->so_m=m; return; bad: m_free(m); }
1threat
void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst, const ptrdiff_t dst_pitch) { int x, y, indx; int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2; int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6; int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9; ptrdiff_t pitch, back_pitch; const short *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr; const int num_bands = 4; pitch = plane->bands[0].pitch; back_pitch = 0; b0_ptr = plane->bands[0].buf; b1_ptr = plane->bands[1].buf; b2_ptr = plane->bands[2].buf; b3_ptr = plane->bands[3].buf; for (y = 0; y < plane->height; y += 2) { if (y+2 >= plane->height) pitch= 0; if (num_bands > 0) { b0_1 = b0_ptr[0]; b0_2 = b0_ptr[pitch]; } if (num_bands > 1) { b1_1 = b1_ptr[back_pitch]; b1_2 = b1_ptr[0]; b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch]; } if (num_bands > 2) { b2_2 = b2_ptr[0]; b2_3 = b2_2; b2_5 = b2_ptr[pitch]; b2_6 = b2_5; } if (num_bands > 3) { b3_2 = b3_ptr[back_pitch]; b3_3 = b3_2; b3_5 = b3_ptr[0]; b3_6 = b3_5; b3_8 = b3_2 - b3_5*6 + b3_ptr[pitch]; b3_9 = b3_8; } for (x = 0, indx = 0; x < plane->width; x+=2, indx++) { if (x+2 >= plane->width) { b0_ptr --; b1_ptr --; b2_ptr --; b3_ptr --; } b2_1 = b2_2; b2_2 = b2_3; b2_4 = b2_5; b2_5 = b2_6; = b2[x+1,y+1] b3_1 = b3_2; b3_2 = b3_3; = b3[x+1,y-1] b3_4 = b3_5; b3_5 = b3_6; = b3[x+1,y ] b3_7 = b3_8; b3_8 = b3_9; p0 = p1 = p2 = p3 = 0; if (num_bands > 0) { tmp0 = b0_1; tmp2 = b0_2; b0_1 = b0_ptr[indx+1]; b0_2 = b0_ptr[pitch+indx+1]; tmp1 = tmp0 + b0_1; p0 = tmp0 << 4; p1 = tmp1 << 3; p2 = (tmp0 + tmp2) << 3; p3 = (tmp1 + tmp2 + b0_2) << 2; } if (num_bands > 1) { tmp0 = b1_2; tmp1 = b1_1; b1_2 = b1_ptr[indx+1]; b1_1 = b1_ptr[back_pitch+indx+1]; tmp2 = tmp1 - tmp0*6 + b1_3; b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch+indx+1]; p0 += (tmp0 + tmp1) << 3; p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2; p2 += tmp2 << 2; p3 += (tmp2 + b1_3) << 1; } if (num_bands > 2) { b2_3 = b2_ptr[indx+1]; b2_6 = b2_ptr[pitch+indx+1]; tmp0 = b2_1 + b2_2; tmp1 = b2_1 - b2_2*6 + b2_3; p0 += tmp0 << 3; p1 += tmp1 << 2; p2 += (tmp0 + b2_4 + b2_5) << 2; p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1; } if (num_bands > 3) { b3_6 = b3_ptr[indx+1]; b3_3 = b3_ptr[back_pitch+indx+1]; tmp0 = b3_1 + b3_4; tmp1 = b3_2 + b3_5; tmp2 = b3_3 + b3_6; b3_9 = b3_3 - b3_6*6 + b3_ptr[pitch+indx+1]; p0 += (tmp0 + tmp1) << 2; p1 += (tmp0 - tmp1*6 + tmp2) << 1; p2 += (b3_7 + b3_8) << 1; p3 += b3_7 - b3_8*6 + b3_9; } dst[x] = av_clip_uint8((p0 >> 6) + 128); dst[x+1] = av_clip_uint8((p1 >> 6) + 128); dst[dst_pitch+x] = av_clip_uint8((p2 >> 6) + 128); dst[dst_pitch+x+1] = av_clip_uint8((p3 >> 6) + 128); } dst += dst_pitch << 1; back_pitch = -pitch; b0_ptr += pitch + 1; b1_ptr += pitch + 1; b2_ptr += pitch + 1; b3_ptr += pitch + 1; } }
1threat
from itertools import groupby def extract_elements(numbers, n): result = [i for i, j in groupby(numbers) if len(list(j)) == n] return result
0debug
Difference between Context Managers and Decorators in Python : <p>What is the main difference between the two? I have been studying Python and came across them. A decorator is essentially a function that wraps another function and you can do anything before and after a particular function executes.</p> <pre><code>def my_decorator(some_function): def wrapper(*args, **kwargs): print("Do something before the function is called") some_function(*args, **kwargs) print("Do something after the function is called") return wrapper @my_decorator def addition(a, b): result = a+b print("Addition of {} and {} is {}".format(a,b,result)) </code></pre> <p>But after studying Context Manager, I couldn't help but notice that it too has a <strong>enter</strong> and <strong>exit</strong> where you could do most similar operations. </p> <pre><code>from contextlib import contextmanager @contextmanager def open_file(path, mode): the_file = open(path, mode) yield the_file the_file.close() files = [] for x in range(100000): with open_file('foo.txt', 'w') as infile: files.append(infile) for f in files: if not f.closed: print('not closed') </code></pre> <p>Everything before yield is taken as part of the "enter" and everything after a part of "exit". </p> <p>Although both Context Managers and Decorators are syntactically different, their behaviors can be looked upon as similar. So what is the difference? What are the different scenarios when one should use either of them?</p>
0debug
Returning the update value of variable initialized in a method (Android Studio) : I'm new to programming so please bare with me. I have three methods. Method 1, Method 2 and Method 3. Each of these methods contain a String variable which is initailized within the method. Note: These methods are called when a user clicks on a button, so in other words theres a click listener. Now in the main method, what i want to do, is create a 4th String variable, which is initialized as such: public class Main{ String Variable4 = variable1 + variable2 + variable 3 System.out.println(Variable4); } The problem however is, variable 4 is null. And this is because the variables in the 3 methods are null in the main method. But they are initialized locally in the methods. So how would I return the initialized variable in the main method? Apologies for the long question
0debug
Inserting dynamic table values from PHP array to mysql table : Need help in inserting dynamic fields and values into mysql db table in PHP. sampe data $data[]=array('client'=>$clientname, 'amount' => 12000,'balance'=>6000, 'term'=>6,'maturitydate'=>'2016-05-31') parameters passed to get the above data : branch = branchid, date =cutoffdate Here's the table structure where I need to insert the above data. Fields : branch date account_no field value the first two fields values came from the parameters passed, account_no comes from the data after the querying the db using the passed param, for the field value should come from the array index and value is the index value. Been looking around the web for some possible solutions but I cannot find one. Any help will be highly appreciated. thank you
0debug
Searching and Extracting substring recursively with RegEx : <p>I'm wondering if there is a RegEx pattern to solve my problem.</p> <p>I'm getting strings like: "Running script A23jddie392.sql", "Skipped script ew223.sql", "Script 2234ffss321.sql has an error" and so on.</p> <p>Is it possible to extract the scriptname with RegEx? Maybe searching for the .sql and then going recursively to the first blank before the scriptname?</p> <p>Thank you! </p>
0debug
INLINE JAVASCRIPT ENABLE/DISABLE SELECT AND TEXT BOX ON CLICK RADIO BUTTON : > Hello i am trying inline script to enable disable with radio button > but it is not working how to do that? <form> <select id="mySelect"> <option>Apple</option> <option>Pear</option> <option>Banana</option> <option>Orange</option> </select> <br><br> <input type="radio" name="ph" onclick=" document.getElementById("mySelect").disabled=true;" value="Disable list">DISABLE <input type="radio" name="ph" onclick="enable()" value="Enable list">ENABLE </form>
0debug
static av_cold int encode_init(AVCodecContext* avc_context) { th_info t_info; th_comment t_comment; ogg_packet o_packet; unsigned int offset; TheoraContext *h = avc_context->priv_data; uint32_t gop_size = avc_context->gop_size; th_info_init(&t_info); t_info.frame_width = FFALIGN(avc_context->width, 16); t_info.frame_height = FFALIGN(avc_context->height, 16); t_info.pic_width = avc_context->width; t_info.pic_height = avc_context->height; t_info.pic_x = 0; t_info.pic_y = 0; t_info.fps_numerator = avc_context->time_base.den; t_info.fps_denominator = avc_context->time_base.num; if (avc_context->sample_aspect_ratio.num) { t_info.aspect_numerator = avc_context->sample_aspect_ratio.num; t_info.aspect_denominator = avc_context->sample_aspect_ratio.den; } else { t_info.aspect_numerator = 1; t_info.aspect_denominator = 1; } if (avc_context->color_primaries == AVCOL_PRI_BT470M) t_info.colorspace = TH_CS_ITU_REC_470M; else if (avc_context->color_primaries == AVCOL_PRI_BT470BG) t_info.colorspace = TH_CS_ITU_REC_470BG; else t_info.colorspace = TH_CS_UNSPECIFIED; if (avc_context->pix_fmt == AV_PIX_FMT_YUV420P) t_info.pixel_fmt = TH_PF_420; else if (avc_context->pix_fmt == AV_PIX_FMT_YUV422P) t_info.pixel_fmt = TH_PF_422; else if (avc_context->pix_fmt == AV_PIX_FMT_YUV444P) t_info.pixel_fmt = TH_PF_444; else { av_log(avc_context, AV_LOG_ERROR, "Unsupported pix_fmt\n"); return -1; } av_pix_fmt_get_chroma_sub_sample(avc_context->pix_fmt, &h->uv_hshift, &h->uv_vshift); if (avc_context->flags & CODEC_FLAG_QSCALE) { t_info.quality = av_clipf(avc_context->global_quality / (float)FF_QP2LAMBDA, 0, 10) * 6.3; t_info.target_bitrate = 0; } else { t_info.target_bitrate = avc_context->bit_rate; t_info.quality = 0; } h->t_state = th_encode_alloc(&t_info); if (!h->t_state) { av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n"); return -1; } h->keyframe_mask = (1 << t_info.keyframe_granule_shift) - 1; th_info_clear(&t_info); if (th_encode_ctl(h->t_state, TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE, &gop_size, sizeof(gop_size))) { av_log(avc_context, AV_LOG_ERROR, "Error setting GOP size\n"); return -1; } if (avc_context->flags & CODEC_FLAG_PASS1) { if (get_stats(avc_context, 0)) return -1; } else if (avc_context->flags & CODEC_FLAG_PASS2) { if (submit_stats(avc_context)) return -1; } offset = 0; th_comment_init(&t_comment); while (th_encode_flushheader(h->t_state, &t_comment, &o_packet)) if (concatenate_packet(&offset, avc_context, &o_packet)) return -1; th_comment_clear(&t_comment); avc_context->coded_frame = av_frame_alloc(); if (!avc_context->coded_frame) return AVERROR(ENOMEM); return 0; }
1threat
React - how to pass state to another component : <p>I'm trying to figure out how to notify another component about a state change. Let's say I have 3 components - App.jsx,Header.jsx,and SidebarPush.jsx and all I'm simply trying to do is toggle a class with an onClick.</p> <p>So the Header.jsx file will have 2 buttons when clicked will toggle the states to true or false. The other 2 components App.jsx and Header.jsx will need to know about these state changes so they can toggle a class whenever those states change.</p> <h2>App.jsx</h2> <pre><code>import React from 'react'; import Header from 'Header'; import classNames from "classnames"; import SidebarPush from 'SidebarPush'; import PageWrapper from 'PageWrapper'; var MainWrapper = React.createClass({ render: function() { return ( &lt;div className={classNames({ 'wrapper': false, 'SidebarPush-collapsed': !this.state.sidbarPushCollapsed })}&gt; &lt;Header/&gt; &lt;SidebarPush/&gt; &lt;PageWrapper&gt; {this.props.children} &lt;/PageWrapper&gt; &lt;/div&gt; ); } }); module.exports = MainWrapper; </code></pre> <h2>Header.jsx</h2> <pre><code>import React from 'react'; import ReactDom from 'react-dom'; class Header extends React.Component { constructor() { super(); this.state = { sidbarPushCollapsed: false, profileCollapsed: false }; this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState({ sidbarPushCollapsed: !this.state.sidbarPushCollapsed, profileCollapsed: !this.state.profileCollapsed }); } render() { return ( &lt;header id="header"&gt; &lt;ul&gt; &lt;li&gt; &lt;button type="button" id="sidbarPush" onClick={this.handleClick} profile={this.state.profileCollapsed}&gt; &lt;i className="fa fa-bars"&gt;&lt;/i&gt; &lt;/button&gt; &lt;/li&gt; &lt;li&gt; &lt;button type="button" id="profile" onClick={this.handleClick}&gt; &lt;i className="icon-user"&gt;&lt;/i&gt; &lt;/button&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt; &lt;button id="sidbarOverlay" onClick={this.handleClick}&gt; &lt;i className="fa fa-indent"&gt;&lt;/i&gt; &lt;/button&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/header&gt; ); } }; module.exports = Header; </code></pre> <h2>SidebarPush.jsx</h2> <pre><code>import React from 'react'; import ReactDom from 'react-dom'; import classNames from "classnames"; class SidebarPush extends React.Component { render() { return ( &lt;aside className="sidebarPush"&gt; &lt;div className={classNames({ 'sidebar-profile': true, 'hidden': !this.state.pagesCollapsed })}&gt; .... &lt;/div&gt; &lt;nav className="sidebarNav"&gt; .... &lt;/nav&gt; &lt;/aside&gt; ); } } export default SidebarPush; </code></pre>
0debug
Terraform azurerm 2.x Error: "features": required field is not set : <p>So azurerm updated to 2.0 a few hours ago....</p> <p>My main code is version locked for safety, but I'm doing some testing to see what's changed from the public beta of 1.44 and now I'm getting the following error on any TF command apart from terraform init.</p> <p>has anybody else come upon this?</p>
0debug
static void check_external_clock_sync(VideoState *is, double pts) { if (fabs(get_external_clock(is) - pts) > AV_NOSYNC_THRESHOLD) { update_external_clock_pts(is, pts); } }
1threat
static void coroutine_fn bdrv_aio_discard_co_entry(void *opaque) { BlockDriverAIOCBCoroutine *acb = opaque; BlockDriverState *bs = acb->common.bs; acb->req.error = bdrv_co_discard(bs, acb->req.sector, acb->req.nb_sectors); acb->bh = qemu_bh_new(bdrv_co_em_bh, acb); qemu_bh_schedule(acb->bh); }
1threat
int has_altivec(void) { #ifdef __AMIGAOS4__ ULONG result = 0; extern struct ExecIFace *IExec; IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); if (result == VECTORTYPE_ALTIVEC) return 1; #elif __APPLE__ int sels[2] = {CTL_HW, HW_VECTORUNIT}; int has_vu = 0; size_t len = sizeof(has_vu); int err; err = sysctl(sels, 2, &has_vu, &len, NULL, 0); if (err == 0) return (has_vu != 0); #else #endif }
1threat
GET form will not echo : <p>I'm starting to learn PHP and keep getting stuck at this point after copying word for word on each guide I'm following. When I complete the form below it updates the query string but dose not echo out the paragraph, same for print. Other answers I've seen for this say to reinstall the server but I have it on Host Gator.</p> <pre><code>&lt;form methon="get" action="index.php"&gt; &lt;input type="text" name="name"&gt; &lt;input type="text" name="age"&gt; &lt;input type="submit" name="name" value="submit"&gt; &lt;/form&gt; &lt;?php $name = $GET_['name']; $age = $GET_['age']; echo '&lt;p&gt;' . $name '&lt;/p&gt;'; echo '&lt;p&gt;' . $age . '&lt;/p&gt;'; ?&gt; </code></pre>
0debug
calculate the distance between two cities : <p>I have a bit of what I think is an odd request. What I need to do is calculate the distance between the two cities, given their city/state/zip input data. This would be as the crow flies, rather than mileage via highways and such. And I would need miles output, i.e. x mile radius, in USA miles. </p> <p>Again, I have city/state/zip input. Most solutions I have located are via latitude/longitude instead. Absent a city/state/zip solution, might there be a utility of some sort to convert city/state/zip input data to latitude/longitude and calculate based off of that? </p> <p>Looking to incorporate this functionality into a .NET C#, MS SQL Server application.</p> <p>Thanks in advance for any insight.</p>
0debug
void *qemu_blockalign0(BlockDriverState *bs, size_t size) { return memset(qemu_blockalign(bs, size), 0, size); }
1threat
static void init_proc_e500 (CPUPPCState *env, int version) { uint32_t tlbncfg[2]; uint64_t ivor_mask = 0x0000000F0000FFFFULL; uint32_t l1cfg0 = 0x3800 | 0x0020; #if !defined(CONFIG_USER_ONLY) int i; #endif gen_tbl(env); if (version == fsl_e500mc) { ivor_mask = 0x000003FE0000FFFFULL; } gen_spr_BookE(env, ivor_mask); spr_register(env, SPR_BOOKE_PIR, "PIR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_pir, 0x00000000); spr_register(env, SPR_BOOKE_SPEFSCR, "SPEFSCR", &spr_read_spefscr, &spr_write_spefscr, &spr_read_spefscr, &spr_write_spefscr, 0x00000000); #if defined(CONFIG_USER_ONLY) env->dcache_line_size = 32; env->icache_line_size = 32; #else env->nb_pids = 3; env->nb_ways = 2; env->id_tlbs = 0; switch (version) { case fsl_e500v1: tlbncfg[0] = gen_tlbncfg(2, 1, 1, 0, 256); tlbncfg[1] = gen_tlbncfg(16, 1, 9, TLBnCFG_AVAIL | TLBnCFG_IPROT, 16); env->dcache_line_size = 32; env->icache_line_size = 32; break; case fsl_e500v2: tlbncfg[0] = gen_tlbncfg(4, 1, 1, 0, 512); tlbncfg[1] = gen_tlbncfg(16, 1, 12, TLBnCFG_AVAIL | TLBnCFG_IPROT, 16); env->dcache_line_size = 32; env->icache_line_size = 32; break; case fsl_e500mc: tlbncfg[0] = gen_tlbncfg(4, 1, 1, 0, 512); tlbncfg[1] = gen_tlbncfg(64, 1, 12, TLBnCFG_AVAIL | TLBnCFG_IPROT, 64); env->dcache_line_size = 64; env->icache_line_size = 64; l1cfg0 |= 0x1000000; break; default: cpu_abort(env, "Unknown CPU: " TARGET_FMT_lx "\n", env->spr[SPR_PVR]); } #endif gen_spr_BookE206(env, 0x000000DF, tlbncfg); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_Exxx_BBEAR, "BBEAR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_Exxx_BBTAR, "BBTAR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_Exxx_MCAR, "MCAR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_MCSR, "MCSR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_Exxx_NPIDR, "NPIDR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_Exxx_BUCSR, "BUCSR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_Exxx_L1CFG0, "L1CFG0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, l1cfg0); spr_register(env, SPR_Exxx_L1CSR0, "L1CSR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_e500_l1csr0, 0x00000000); spr_register(env, SPR_Exxx_L1CSR1, "L1CSR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_MMUCSR0, "MMUCSR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_booke206_mmucsr0, 0x00000000); #if !defined(CONFIG_USER_ONLY) env->nb_tlb = 0; env->tlb_type = TLB_MAS; for (i = 0; i < BOOKE206_MAX_TLBN; i++) { env->nb_tlb += booke206_tlb_size(env, i); } #endif init_excp_e200(env); ppce500_irq_init(env); }
1threat
How to integrate Ninject into ASP.NET Core 2.0 Web applications? : <p>I have found out that Ninject has recently <a href="https://www.nuget.org/packages/Ninject/3.3.0" rel="noreferrer">introduced support for .NET Standard 2.0 / .NET Core 2.0</a>.</p> <p>However, I cannot find any extension to actually integrate it in the Web application (e.g similar to <a href="https://www.nuget.org/packages/Ninject.Web.Common/" rel="noreferrer">Ninject.Web.Common</a>)</p> <p>Looking on the code from an old ASP.NET MVC solution, I realized that the whole mechanism is different as the classic one relied on <code>WebActivatorEx.PreApplicationStartMethod</code> and <code>WebActivatorEx.ApplicationShutdownMethodAttribute</code> which are no longer available in ASP.NET Core.</p> <p>Also, the old <code>Ninject.Web.Common</code> assembly provided several useful classes used for initialization - Bootstrapper, OnePerRequestHttpModule, NinjectHttpModule:</p> <pre><code>public static void Start() { DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule)); DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule)); Bootstrapper.Initialize(CreateKernel); } </code></pre> <p><strong>Question:</strong> is there any example of how to integrate Ninject into an ASP.NET Core 2.0 Web application?</p>
0debug
Paginate Javascript array : <p>I am trying to write a Javascript function that takes an <code>array</code>, <code>page_size</code> and <code>page_number</code> as parameters and returns an array that mimics paginated results:</p> <pre><code>paginate: function (array, page_size, page_number) { return result; } </code></pre> <p>so for example when:</p> <pre><code>array = [1, 2, 3, 4, 5], page size = 2, page_number = 2, </code></pre> <p>the function should return: <code>[3, 4]</code>.</p> <p>Any ideas would be appreciated.</p>
0debug
KDoc: Insert code snippet : <p>How do I insert a code snippet in KDoc, Kotlin's default documentation tool?</p> <p>In Java, I can use the following:</p> <pre><code>/** * Example usage: * * &lt;pre&gt; * &lt;code&gt;&amp;#64;JavaAnnotation * public void foo() { * // Code * } * &lt;/code&gt; * &lt;/pre&gt; */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface JavaAnnotation {} </code></pre> <p>There seems to be no equivalent in Kotlin. I tried using Markdown, but inserting 2 spaces after line end does not line-break.</p>
0debug
static int parse_uint32(DeviceState *dev, Property *prop, const char *str) { uint32_t *ptr = qdev_get_prop_ptr(dev, prop); const char *fmt; fmt = strncasecmp(str, "0x",2) == 0 ? "%" PRIx32 : "%" PRIu32; if (sscanf(str, fmt, ptr) != 1) return -EINVAL; return 0; }
1threat
batch if, for, do sentences : I discovered while I tried to add a function with if command that I probably don't understand the real function of theese commands. what I tried to achieve: I tried to tell the script that "if" (variable) equals to (this) then it will "SET" (this variable) to 0 how I tried to acomplish this: i tried to acomplish this by writing: `IF %Q%==/decrypt_Delhi-Inter-Cafe-Guest set decrypt_Delhi-Inter-Cafe-Guest=0` and as you can see... I aparently don't understand quite what I'm doing here haha why would i want to do something like this? well I'm mostly playing around with some few things and in order for whatever I do to work. I need to write something that can do this (sort of same waY) heres the script itself (i removed any unneccecary lines. between those codes theres an menu and a lot of other stuff I removed. this is the only part that needs fixing.) (sorry for my incompetence. I'm here to learn) :P I tried to google a bit and read a lot but I had no luck sadly set encryption_Delhi-Inter_Cafe-Guest=1 set /P Q=Console: IF %Q%==/decrypt_Delhi-Inter-Cafe-Guest set decrypt_Delhi-Inter-Cafe-Guest=0 if encryption_Delhi-Inter_Cafe-Guest=0 goto decryptedsuccess :decryptedsuccess echo you successfully decrypted dheli guest network echo encryption value: %encryption_Delhi-Inter_Cafe-Guest%
0debug
How to calculate count of string in array-- TypeScript angular 4 : [ { "assetNo":"51GQA21AP001" }, { "assetNo":"51GQA22AP001" }, { "assetNo":"51GQA24AP001" }, { "assetNo":"51GQA22AP001" }, { "assetNo":"51GQA21AP001" }, { "assetNo":"51GQA23AP001" }, { "assetNo":"51GQA24AP001" } ] I need the output following format: { "assetNo": "51GQA21AP001", "count": 2 }, { "assetNo": "51GQA22AP001", "count": 2 }, , { "assetNo": "51GQA23AP001", "count": 2 },{ "assetNo": "51GQA24AP001", "count": 1 }
0debug
Could not initialize class com.ibm.ws.ffdc.FFDCFilter : <p>Starting IBM Websphere in Eclipse Mars, always gives this error:</p> <pre><code>An internal error occurred during: "Publishing to FrontServer...". Could not initialize class com.ibm.ws.ffdc.FFDCFilter </code></pre> <p>I'm using Websphere Version 7.0</p> <p>Any idea how to resolve this?</p> <p>Thanks!</p>
0debug
Select Subset of Columns based on Vector R : <p>I have a data frame with 300 columns of data. I created a vector with 126 elements that are the column names of 126 of the 300. I want to subset the 300 based on not being in my 126. They are NOT in order, so I can't simply remove by specifying -1:-126.</p> <p>I tried various things with grep and matrix operations, but they did not work. Such as the following which did not work. x has 300 columns. f contains vector of 126 column names I want to exclude from x1.</p> <pre><code>x1&lt;-x[,-which(names(x), %in% f)] </code></pre> <p>If I definitively use a variable name or several, I can get it to work, but I don't want to type out the 126 elements in f. </p>
0debug
static int mpegts_read_header(AVFormatContext *s, AVFormatParameters *ap) { MpegTSContext *ts = s->priv_data; AVIOContext *pb = s->pb; uint8_t buf[5*1024]; int len; int64_t pos; #if FF_API_FORMAT_PARAMETERS if (ap) { if (ap->mpeg2ts_compute_pcr) ts->mpeg2ts_compute_pcr = ap->mpeg2ts_compute_pcr; if(ap->mpeg2ts_raw){ av_log(s, AV_LOG_ERROR, "use mpegtsraw_demuxer!\n"); return -1; } } #endif pos = avio_tell(pb); len = avio_read(pb, buf, sizeof(buf)); if (len != sizeof(buf)) goto fail; ts->raw_packet_size = get_packet_size(buf, sizeof(buf)); if (ts->raw_packet_size <= 0) goto fail; ts->stream = s; ts->auto_guess = 0; if (s->iformat == &ff_mpegts_demuxer) { if (avio_seek(pb, pos, SEEK_SET) < 0) av_log(s, AV_LOG_ERROR, "Unable to seek back to the start\n"); mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); handle_packets(ts, s->probesize / ts->raw_packet_size); ts->auto_guess = 1; av_dlog(ts->stream, "tuning done\n"); s->ctx_flags |= AVFMTCTX_NOHEADER; } else { AVStream *st; int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l; int64_t pcrs[2], pcr_h; int packet_count[2]; uint8_t packet[TS_PACKET_SIZE]; st = av_new_stream(s, 0); if (!st) goto fail; av_set_pts_info(st, 60, 1, 27000000); st->codec->codec_type = AVMEDIA_TYPE_DATA; st->codec->codec_id = CODEC_ID_MPEG2TS; pcr_pid = -1; nb_pcrs = 0; nb_packets = 0; for(;;) { ret = read_packet(s, packet, ts->raw_packet_size); if (ret < 0) return -1; pid = AV_RB16(packet + 1) & 0x1fff; if ((pcr_pid == -1 || pcr_pid == pid) && parse_pcr(&pcr_h, &pcr_l, packet) == 0) { pcr_pid = pid; packet_count[nb_pcrs] = nb_packets; pcrs[nb_pcrs] = pcr_h * 300 + pcr_l; nb_pcrs++; if (nb_pcrs >= 2) break; } nb_packets++; } ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr; st->codec->bit_rate = s->bit_rate; st->start_time = ts->cur_pcr; av_dlog(ts->stream, "start=%0.3f pcr=%0.3f incr=%d\n", st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); } avio_seek(pb, pos, SEEK_SET); return 0; fail: return -1; }
1threat
static unsigned int dec_movem_mr(DisasContext *dc) { TCGv tmp[16]; TCGv addr; int i; int nr = dc->op2 + 1; DIS(fprintf (logfile, "movem [$r%u%s, $r%u\n", dc->op1, dc->postinc ? "+]" : "]", dc->op2)); addr = tcg_temp_new(TCG_TYPE_TL); cris_flush_cc_state(dc); for (i = 0; i < (nr >> 1); i++) { tmp[i] = tcg_temp_new(TCG_TYPE_I64); tcg_gen_addi_tl(addr, cpu_R[dc->op1], i * 8); gen_load(dc, tmp[i], addr, 8, 0); } if (nr & 1) { tmp[i] = tcg_temp_new(TCG_TYPE_I32); tcg_gen_addi_tl(addr, cpu_R[dc->op1], i * 8); gen_load(dc, tmp[i], addr, 4, 0); } tcg_temp_free(addr); for (i = 0; i < (nr >> 1); i++) { tcg_gen_trunc_i64_i32(cpu_R[i * 2], tmp[i]); tcg_gen_shri_i64(tmp[i], tmp[i], 32); tcg_gen_trunc_i64_i32(cpu_R[i * 2 + 1], tmp[i]); tcg_temp_free(tmp[i]); } if (nr & 1) { tcg_gen_mov_tl(cpu_R[dc->op2], tmp[i]); tcg_temp_free(tmp[i]); } if (dc->postinc) tcg_gen_addi_tl(cpu_R[dc->op1], cpu_R[dc->op1], nr * 4); cris_cc_mask(dc, 0); return 2; }
1threat
Finding merge commits from tag across branches in git : <p>My product is a plugin for IntelliJ. I support several versions of the underlying IntelliJ platform, and release builds of my plugin for each one since their APIs often change between versions. It's just me working on it, so I develop in master and then maintain a branch for each of the other versions. So my repo looks like this:</p> <pre><code> 1.6.0 1.6.1-eap1 .... a---b---c--- master \ \ d-------e--- idea-2017.1 \ \ f-------g--- idea-2016.3 \ \ ... ... etc etc </code></pre> <p><code>a</code> is a stable release, and has been tagged with <code>1.6.0</code>. <code>c</code> is an EAP (beta) release, and has been tagged with <code>1.6.1-eap1</code>. This scheme works fine for these two cases.</p> <p>Occasionally I'd like to create a dev build which doesn't go into a release channel, but that users can download manually and test out if they like. I'd like to produce a dev build for each platform, since dev users could be using any IntelliJ version. The best way I can think of would be to create a branch for the dev build from, say, tag <code>1.6.0</code> (commit <code>a</code>), and then corresponding branches from commits <code>d</code>, <code>f</code> and so on which I can merge the dev branch into and create dev builds from. </p> <p>Assuming I want to write a script to create and maintain these branches, how can I find commits <code>d</code>, <code>f</code> and so on from the tag <code>1.6.0</code> to create the dev build branches from?</p>
0debug
hi there, i m trying to generate a random number generator in viusal C++, and everything seems to working except the reset button : i m trying to generate a random number generator in viusal C++, and everything seems to working except the reset button #pragma endregion private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) { // Reset button System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) ; { // clear label fields this->label1->Text = "0"; this->label2->Text = "0"; this->label3->Text = "0"; this->label4->Text = "0"; this->label5->Text = "0"; this->label6->Text = "0"; this->label7->Text = "0"; // set button state this->button1->Enabled = false; this->button2->Enabled = true; } this is the code i placed into the reset button.
0debug
Golang: json Unmarshal fails to unpack simple example : <p>I cannot get my head around this problem. I have a simple struct, and another struct that uses it twice:</p> <pre><code>type Range struct { Position int `json:"position"` Length int `json:"length"` } type TwoRanges struct { From Range `json:"from"` To Range `json:"to"` } </code></pre> <p>and the following json sample in file "ranges.json":</p> <pre><code>{ "from:": { "position": 348, "length": 15 }, "to": { "position": 737, "length" : 10 } } </code></pre> <p>I try unmarshalling the sample in the following code:</p> <pre><code>func main() { buffer, err := ioutil.ReadFile("ranges.json") if err != nil { log.Fatal(err) } var sample TwoRanges if err = json.Unmarshal(buffer, &amp;sample); err != nil { log.Fatal(err) } fmt.Printf("%v\n", sample) } </code></pre> <p>The output is</p> <pre><code>{{0 0} {737 10}} </code></pre> <p>Somehow, only the half of the struct is unpacked.</p> <ol> <li>Is it a bug, or am I doing something wrong?</li> <li>Is there a "verbose mode" for the encoding/json package which would tell me what went wrong with the unmarshaller? It's not the first time that I've had mysterious problems with that package. </li> </ol>
0debug