problem
stringlengths
26
131k
labels
class label
2 classes
Converting Boolean value to Integer value in swift 3 : <p>I was converting from swift 2 to swift 3. I noticed that I cannot convert a boolean value to integer value in swift 3 :\ .</p> <pre><code>let p1 = ("a" == "a") //true print(true) //"true\n" print(p1) //"true\n" Int(true) //1 Int(p1) //error </code></pre> <p>For example these syntaxes worked fine in swift 2. But in swift 3, <code>print(p1)</code> yields an error.</p> <p>The error is <code>error: cannot invoke initializer for type 'Int' with an argument list of type '((Bool))'</code></p> <p>I understand why the errors are happening. Can anyone explain what is the reason for this safety and how to convert from Bool to Int in swift 3?</p>
0debug
int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *id = qdict_get_str(qdict, "id"); BlockDriverState *bs; BlockDriverState **ptr; Property *prop; bs = bdrv_find(id); if (!bs) { qerror_report(QERR_DEVICE_NOT_FOUND, id); return -1; } if (bdrv_in_use(bs)) { qerror_report(QERR_DEVICE_IN_USE, id); return -1; } qemu_aio_flush(); bdrv_flush(bs); bdrv_close(bs); if (bs->peer) { for (prop = bs->peer->info->props; prop && prop->name; prop++) { if (prop->info->type == PROP_TYPE_DRIVE) { ptr = qdev_get_prop_ptr(bs->peer, prop); if (*ptr == bs) { bdrv_detach(bs, bs->peer); *ptr = NULL; break; } } } } drive_uninit(drive_get_by_blockdev(bs)); return 0; }
1threat
Linux:i can not understand a m4 command : My work is converting Linux command into CMake execute_process(COMMAND ...), and there are some differences between them, so i need to understand each Linux command. But this m4 command really beat me. The m4 command as below: <!-- language: lang-html --> m4 -Isource/analyzer/ -P < source/analyzer/aParser.m4y > source/analyzer/aParser.by What does this command mean?
0debug
static void test_qemu_strtoll_max(void) { const char *str = g_strdup_printf("%lld", LLONG_MAX); char f = 'X'; const char *endptr = &f; int64_t res = 999; int err; err = qemu_strtoll(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LLONG_MAX); g_assert(endptr == str + strlen(str)); }
1threat
static void parse_str(StringInputVisitor *siv, Error **errp) { char *str = (char *) siv->string; long long start, end; Range *cur; char *endptr; if (siv->ranges) { return; } do { errno = 0; start = strtoll(str, &endptr, 0); if (errno == 0 && endptr > str) { if (*endptr == '\0') { cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = start + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; str = NULL; } else if (*endptr == '-') { str = endptr + 1; errno = 0; end = strtoll(str, &endptr, 0); if (errno == 0 && endptr > str && start <= end && (start > INT64_MAX - 65536 || end < start + 65536)) { if (*endptr == '\0') { cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = end + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; str = NULL; } else if (*endptr == ',') { str = endptr + 1; cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = end + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; } else { goto error; } } else { goto error; } } else if (*endptr == ',') { str = endptr + 1; cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = start + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; } else { goto error; } } else { goto error; } } while (str); return; error: g_list_foreach(siv->ranges, free_range, NULL); g_list_free(siv->ranges); siv->ranges = NULL; }
1threat
Image is not showing up for tab bar item : <p>I uploaded an image to assets folder and assigned the image to 1x, 2x and 3x. selected the table view controller of the respective tab bar item -> selected the Attributes -> assigned the image to the image field in the Bar Items section. </p> <p>After running the application a Blue Square box is showing up on selection and Grayed out square box is showing up on selection of a different bar item. </p> <p>Where am I going wrong?</p>
0debug
how to avoid passing same parameter through multiple function : def function1(a) #some computation function2(a, b) end def function2(a,b) #some computation function3(a, b, c) end def function3(a, b ,c) print a end How to avoid passing same parameter (a) to all function. One way is to make parameter 'a' as instance variable. what is the right way to do this.
0debug
static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src_size, int w, int h) { BitBuf bb; int res, val; int i, j; int bx, by; int l0x, l1x, l0y, l1y; int mx, my; const uint8_t *src_end = src + src_size; kmvc_init_getbits(bb, src); for (by = 0; by < h; by += 8) for (bx = 0; bx < w; bx += 8) { kmvc_getbit(bb, src, src_end, res); if (!res) { if (src >= src_end) { av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); return AVERROR_INVALIDDATA; } val = *src++; for (i = 0; i < 64; i++) BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val; } else { for (i = 0; i < 4; i++) { l0x = bx + (i & 1) * 4; l0y = by + (i & 2) * 2; kmvc_getbit(bb, src, src_end, res); if (!res) { kmvc_getbit(bb, src, src_end, res); if (!res) { if (src >= src_end) { av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); return AVERROR_INVALIDDATA; } val = *src++; for (j = 0; j < 16; j++) BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val; } else { if (src >= src_end) { av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); return AVERROR_INVALIDDATA; } val = *src++; mx = val & 0xF; my = val >> 4; for (j = 0; j < 16; j++) BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = BLK(ctx->cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my); } } else { for (j = 0; j < 4; j++) { l1x = l0x + (j & 1) * 2; l1y = l0y + (j & 2); kmvc_getbit(bb, src, src_end, res); if (!res) { kmvc_getbit(bb, src, src_end, res); if (!res) { if (src >= src_end) { av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); return AVERROR_INVALIDDATA; } val = *src++; BLK(ctx->cur, l1x, l1y) = val; BLK(ctx->cur, l1x + 1, l1y) = val; BLK(ctx->cur, l1x, l1y + 1) = val; BLK(ctx->cur, l1x + 1, l1y + 1) = val; } else { if (src >= src_end) { av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); return AVERROR_INVALIDDATA; } val = *src++; mx = val & 0xF; my = val >> 4; BLK(ctx->cur, l1x, l1y) = BLK(ctx->cur, l1x - mx, l1y - my); BLK(ctx->cur, l1x + 1, l1y) = BLK(ctx->cur, l1x + 1 - mx, l1y - my); BLK(ctx->cur, l1x, l1y + 1) = BLK(ctx->cur, l1x - mx, l1y + 1 - my); BLK(ctx->cur, l1x + 1, l1y + 1) = BLK(ctx->cur, l1x + 1 - mx, l1y + 1 - my); } } else { BLK(ctx->cur, l1x, l1y) = *src++; BLK(ctx->cur, l1x + 1, l1y) = *src++; BLK(ctx->cur, l1x, l1y + 1) = *src++; BLK(ctx->cur, l1x + 1, l1y + 1) = *src++; } } } } } } return 0; }
1threat
How would you make a !!say command for a discord bot in Java? : **This is how my commands are set up:** `public void onMessageReceived(MessageReceivedEvent evt) {` //Objects User objUser = evt.getAuthor(); MessageChannel objMsgCh = evt.getChannel(); Message objMsg = evt.getMessage(); //Commands if(objMsg.getContentRaw().equalsIgnoreCase(Ref.prefix+"ping")) { objMsgCh.sendMessage(objUser.getAsMention() + " Pong!").queue(); } } The API I use is JDA (Java Discord API).
0debug
static void fill_picture_parameters(AVCodecContext *avctx, struct dxva_context *ctx, const struct MpegEncContext *s, DXVA_PictureParameters *pp) { const Picture *current_picture = s->current_picture_ptr; int is_field = s->picture_structure != PICT_FRAME; memset(pp, 0, sizeof(*pp)); pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(ctx, &current_picture->f); pp->wDeblockedPictureIndex = 0; if (s->pict_type != AV_PICTURE_TYPE_I) pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture.f); else pp->wForwardRefPictureIndex = 0xffff; if (s->pict_type == AV_PICTURE_TYPE_B) pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f); else pp->wBackwardRefPictureIndex = 0xffff; pp->wPicWidthInMBminus1 = s->mb_width - 1; pp->wPicHeightInMBminus1 = (s->mb_height >> is_field) - 1; pp->bMacroblockWidthMinus1 = 15; pp->bMacroblockHeightMinus1 = 15; pp->bBlockWidthMinus1 = 7; pp->bBlockHeightMinus1 = 7; pp->bBPPminus1 = 7; pp->bPicStructure = s->picture_structure; pp->bSecondField = is_field && !s->first_field; pp->bPicIntra = s->pict_type == AV_PICTURE_TYPE_I; pp->bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B; pp->bBidirectionalAveragingMode = 0; pp->bMVprecisionAndChromaRelation= 0; pp->bChromaFormat = s->chroma_format; pp->bPicScanFixed = 1; pp->bPicScanMethod = s->alternate_scan ? 1 : 0; pp->bPicReadbackRequests = 0; pp->bRcontrol = 0; pp->bPicSpatialResid8 = 0; pp->bPicOverflowBlocks = 0; pp->bPicExtrapolation = 0; pp->bPicDeblocked = 0; pp->bPicDeblockConfined = 0; pp->bPic4MVallowed = 0; pp->bPicOBMC = 0; pp->bPicBinPB = 0; pp->bMV_RPS = 0; pp->bReservedBits = 0; pp->wBitstreamFcodes = (s->mpeg_f_code[0][0] << 12) | (s->mpeg_f_code[0][1] << 8) | (s->mpeg_f_code[1][0] << 4) | (s->mpeg_f_code[1][1] ); pp->wBitstreamPCEelements = (s->intra_dc_precision << 14) | (s->picture_structure << 12) | (s->top_field_first << 11) | (s->frame_pred_frame_dct << 10) | (s->concealment_motion_vectors << 9) | (s->q_scale_type << 8) | (s->intra_vlc_format << 7) | (s->alternate_scan << 6) | (s->repeat_first_field << 5) | (s->chroma_420_type << 4) | (s->progressive_frame << 3); pp->bBitstreamConcealmentNeed = 0; pp->bBitstreamConcealmentMethod = 0; }
1threat
How to move file or directories in linux : <p>HELP. I need help with moving directories and files in Linux because i don't understand how to it and how it works, i am a student in year 11 so if someone could explain in the most simplest way possible or in a step by step guide would be helpful Thanks.</p>
0debug
hey guys i want to make this photo more visible with python code i tried median filter and mean filter but nothing helped : [enter image description here][1] [1]: https://i.stack.imgur.com/mLLiZ.png import cv2 import numpy as np import argparse ap = argparse.ArgumentParser() args = vars(ap.parse_args()) image = cv2.imread(args['image']) kernel = np.ones((3,3),np.float32)/9 processed_image = cv2.filter2D(image,-1,kernel) cv2.imshow('Mean Filter Processing', processed_image) cv2.imwrite('processed_image.png', processed_image) cv2.waitKey(0)
0debug
Understanding this C Array syntax - 3[arr] : <p>I'm reading Head First C and going well so far but I'm having trouble with this example - </p> <pre><code>int doses[] = {1, 3, 2, 1000}; printf("Issue dose %i", 3[doses]); </code></pre> <p>Result = "Issue dose 1000"</p> <p>I know what this does, it accesses index 3 of the doses array. More technically my understanding is that it adds the size of three integers to the pointer address for the first element in the array ( the doses variable ) </p> <p>The book explains that it works because </p> <pre><code>doses[3] == *(doses + 3) == *(3 + doses) == 3[doses] </code></pre> <p>I'm with it up until that final jump between *(3 + doses) == 3[doses]. Given that doses[3] is easy for me to grasp maybe I'm not understanding the significance of the [] correctly?</p>
0debug
How do I select a single line within Visual Studio Code? : <p>Using Microsoft's Visual Studio Code, how do I select a single line of code? (equivalent to Atom's or other IDE's <kbd>Cmd</kbd>+<kbd>L</kbd> on Mac) </p> <p>And what would be the command I'm looking for? (e.g. <code>editor.action.copyLinesDownAction</code>)</p> <p>It's quite confusing, since other selection shortucts like <kbd>Cmd</kbd>+<kbd>A</kbd> and <kbd>Cmd</kbd>+<kbd>D</kbd> are the same as in my previous IDE's.</p>
0debug
static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slots) { BusChild *kid, *next; int slot = ffs(slots) - 1; PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); if (!bus) { return; } s->acpi_pcihp_pci_status[bsel].down &= ~(1U << slot); s->acpi_pcihp_pci_status[bsel].up &= ~(1U << slot); QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { DeviceState *qdev = kid->child; PCIDevice *dev = PCI_DEVICE(qdev); if (PCI_SLOT(dev->devfn) == slot) { if (!acpi_pcihp_pc_no_hotplug(s, dev)) { object_unparent(OBJECT(qdev)); } } } }
1threat
static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "movq "MANGLE(bm01010101)", %%mm4 \n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",4), %%mm0 \n\t" "movq 8(%1, %%"REG_a",4), %%mm1 \n\t" "pand %%mm4, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, %%mm1 \n\t" "psrlw $8, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "packuswb %%mm0, %%mm0 \n\t" "packuswb %%mm1, %%mm1 \n\t" "movd %%mm0, (%3, %%"REG_a") \n\t" "movd %%mm1, (%2, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width) : "%"REG_a ); #else int i; for (i=0; i<width; i++) { dstU[i]= src1[4*i + 0]; dstV[i]= src1[4*i + 2]; } #endif assert(src1 == src2); }
1threat
Part of Fragment items hides under Action bar : <p>I am learning android dev and my question might be very simple. I am stuck at the below part and requesting your help</p> <p><strong>Description</strong></p> <p>I am using the android's default "Navigation Drawer" activity to implement a small project. I have created a fragment and when user selects an option from Navigation drawer, the fragment opens. </p> <p><strong>Problem faced</strong></p> <p>When the fragment opens, part of the fragment &amp; action bar is clipped. Image below<a href="https://i.stack.imgur.com/1jTnA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1jTnA.png" alt="enter image description here"></a></p> <p><strong>Code</strong></p> <p><strong>fragment layout</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:clipToPadding="false" android:orientation="vertical" android:background="#ffffff" android:layout_weight="120" tools:context="test.navigationdrawcheck.RateCalculator"&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:ems="12" android:gravity="center" android:layout_weight="10" android:hint="text 1" android:textColorHint="@color/colorDivider" android:id="@+id/editText" android:layout_gravity="center_horizontal" /&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 2" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText1" android:layout_gravity="center_horizontal" /&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 3" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText3" android:layout_gravity="center_horizontal" /&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 4" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText4" android:layout_gravity="center_horizontal" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="15dp" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Total " android:textColor="@color/colorDivider" android:layout_weight="10" android:textStyle="bold" android:gravity="center_vertical" android:id="@+id/textView" android:layout_gravity="center_horizontal" /&gt; &lt;Button android:layout_width="match_parent" android:layout_height="10dp" android:inputType="number" android:ems="15" android:gravity="center" android:layout_weight="5" android:id="@+id/editText6" android:text="Submit" android:textSize="20sp" android:textColor="@color/colorWhite" android:background="@color/colorPrimary" android:layout_gravity="center_horizontal" /&gt; </code></pre> <p></p> <p><strong>App Bar Code</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="test.navigationdrawcheck.MainActivity"&gt; &lt;android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:theme="@style/AppTheme.AppBarOverlay"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:elevation="4dp" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:fitsSystemWindows="true" app:popupTheme="@style/AppTheme.PopupOverlay"/&gt; &lt;/android.support.design.widget.AppBarLayout&gt; &lt;FrameLayout android:id="@+id/framecheck" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;/FrameLayout&gt; &lt;android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_dialog_email" /&gt; &lt;/android.support.design.widget.CoordinatorLayout&gt; </code></pre> <p><strong>Actual output i am looking for</strong> </p> <p>Below is my actual fragment layout xml. <strong>When i merge it with Navigation drawer it should not be clipped</strong> and fragment items should be displayed correctly</p> <p><a href="https://i.stack.imgur.com/88DQw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/88DQw.png" alt="enter image description here"></a></p> <p><strong>What I have tried so far</strong></p> <p>I tried adding this <code>android:windowActionBarOverlay=false</code> in my styles.xml but no luck</p> <p>Requesting your suggestions</p>
0debug
Python Garbage Collection sometimes not working in Jupyter Notebook : <p>I'm constantly running out of RAM with some Jupyter Notebooks and I seem to be unable to release memory that is no longer needed. Here is an example:</p> <pre><code>import gc thing = Thing() result = thing.do_something(...) thing = None gc.collect() </code></pre> <p>As you can presume, <code>thing</code> uses a lot of memory to do something and then I don't need it anymore. I should be able to release the memory it uses. Even though it doesn't write to any variables that I can access from my notebook, garbage collector isn't freeing up space properly. The only workaround I've found is writing <code>result</code> into a pickle, restarting kernel, loading <code>result</code> from pickle, and continuing. This is really inconvenient when running long notebooks. How can I free up memory properly?</p>
0debug
static void tgen_ext16s(TCGContext *s, TCGType type, TCGReg dest, TCGReg src) { if (facilities & FACILITY_EXT_IMM) { tcg_out_insn(s, RRE, LGHR, dest, src); return; } if (type == TCG_TYPE_I32) { if (dest == src) { tcg_out_sh32(s, RS_SLL, dest, TCG_REG_NONE, 16); } else { tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 16); } tcg_out_sh32(s, RS_SRA, dest, TCG_REG_NONE, 16); } else { tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 48); tcg_out_sh64(s, RSY_SRAG, dest, dest, TCG_REG_NONE, 48); } }
1threat
Pushing value to stack on Assembly : Recently I faced to an snippet of Assembly function code that first of all saves registers value's in stack(sets $sp to -12) and doing it's job. but in pushing first value to stack it moves 8 units from base address and for second one 4 units and for the last one 0 unit. but I don't get that why It' pushes the first value by moving 8 units and not 4?! Leaf_example: addi $sp, $sp, -12 sw $t1, 8($sp) sw $t0, 4($sp) sw $s0, 0($sp) add $t0, $a0, $a1 add $t1, $a2, $a3 sub $s0, $t0, $t1 add $v0, $s0, $zero lw $s0, 0($sp) lw $t0, 4($sp) lw $t1, 8($sp) addi $sp, $sp, 12 jr $ra
0debug
static void ich9_lpc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); dc->reset = ich9_lpc_reset; k->init = ich9_lpc_initfn; dc->vmsd = &vmstate_ich9_lpc; dc->no_user = 1; k->config_write = ich9_lpc_config_write; dc->desc = "ICH9 LPC bridge"; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ICH9_8; k->revision = ICH9_A2_LPC_REVISION; k->class_id = PCI_CLASS_BRIDGE_ISA; }
1threat
void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd) { struct kvm_create_spapr_tce args = { .liobn = liobn, .window_size = window_size, }; long len; int fd; void *table; *pfd = -1; if (!cap_spapr_tce) { return NULL; } fd = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &args); if (fd < 0) { fprintf(stderr, "KVM: Failed to create TCE table for liobn 0x%x\n", liobn); return NULL; } len = (window_size / SPAPR_TCE_PAGE_SIZE) * sizeof(sPAPRTCE); table = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (table == MAP_FAILED) { fprintf(stderr, "KVM: Failed to map TCE table for liobn 0x%x\n", liobn); close(fd); return NULL; } *pfd = fd; return table; }
1threat
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) { int opaque_alloc = 0; int ret; q->param.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY; q->param.AsyncDepth = q->async_depth; q->async_fifo = av_fifo_alloc((1 + q->async_depth) * (sizeof(AVPacket) + sizeof(mfxSyncPoint) + sizeof(mfxBitstream*))); if (!q->async_fifo) return AVERROR(ENOMEM); if (avctx->hwaccel_context) { AVQSVContext *qsv = avctx->hwaccel_context; q->session = qsv->session; q->param.IOPattern = qsv->iopattern; opaque_alloc = qsv->opaque_alloc; } if (!q->session) { ret = ff_qsv_init_internal_session(avctx, &q->internal_session, q->load_plugins); if (ret < 0) return ret; q->session = q->internal_session; } ret = init_video_param(avctx, q); if (ret < 0) return ret; ret = MFXVideoENCODE_QueryIOSurf(q->session, &q->param, &q->req); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error querying the encoding parameters\n"); return ff_qsv_error(ret); } if (opaque_alloc) { ret = qsv_init_opaque_alloc(avctx, q); if (ret < 0) return ret; } if (avctx->hwaccel_context) { AVQSVContext *qsv = avctx->hwaccel_context; int i, j; q->extparam = av_mallocz_array(qsv->nb_ext_buffers + q->nb_extparam_internal, sizeof(*q->extparam)); if (!q->extparam) return AVERROR(ENOMEM); q->param.ExtParam = q->extparam; for (i = 0; i < qsv->nb_ext_buffers; i++) q->param.ExtParam[i] = qsv->ext_buffers[i]; q->param.NumExtParam = qsv->nb_ext_buffers; for (i = 0; i < q->nb_extparam_internal; i++) { for (j = 0; j < qsv->nb_ext_buffers; j++) { if (qsv->ext_buffers[j]->BufferId == q->extparam_internal[i]->BufferId) break; } if (j < qsv->nb_ext_buffers) continue; q->param.ExtParam[q->param.NumExtParam++] = q->extparam_internal[i]; } } else { q->param.ExtParam = q->extparam_internal; q->param.NumExtParam = q->nb_extparam_internal; } ret = MFXVideoENCODE_Init(q->session, &q->param); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing the encoder\n"); return ff_qsv_error(ret); } ret = qsv_retrieve_enc_params(avctx, q); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error retrieving encoding parameters.\n"); return ret; } q->avctx = avctx; return 0; }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Can C++17 be used together with CUDA using clang? : <p>As far as using <code>nvcc</code>, one needs to use the corresponding <code>gcc</code> (currently max. 5.4 I believe) in conjunction. This of course somewhat prevents one from using C++17 on the host side.</p> <p>Since C++17 can be compiled using <code>clang 5</code> and upwards (see <a href="http://clang.llvm.org/cxx_status.html" rel="noreferrer">here</a>), and one can compile cuda code as well (see <a href="http://llvm.org/docs/CompileCudaWithLLVM.html" rel="noreferrer">here</a>), <strong>is it possible to use both C++17 and CUDA at the same time</strong> (or can there be problems, e.g. with the CUDA runtime)?</p>
0debug
How to replace Swagger UI header logo in Swashbuckle : <p>I am using the Swashbuckle package for WebAPI and am attempting to customize the look and feel of the swagger ui default page. I would like to customize the default swagger logo/header. I have added the following to SwaggerConfig</p> <pre><code>.EnableSwaggerUi(c =&gt; { c.InjectJavaScript(thisAssembly, typeof(SwaggerConfig).Namespace + ".SwaggerExtensions.custom-js.js"); } </code></pre> <p>The contents of custom-js.js are as follows:</p> <pre><code>$("#logo").replaceWith("&lt;span id=\"test\"&gt;test&lt;/span&gt;"); </code></pre> <p>This works for the most part but the visual is a bit jarring, in that the default swagger header is visible while the page loads and after a brief delay the jquery below kicks and the content of the #logo element is updated</p> <p>Is there a way to avoid this so that the jquery kicks in as part of the initial load/render and it appears seamless?</p>
0debug
Issue with my website url : <p>obiventures.com is my website, when I open this site I found <a href="http://obiventures.com/OBI1.0/home.html" rel="nofollow noreferrer">http://obiventures.com/OBI1.0/home.html</a> this URL how to remove/hide this <strong>OBI1.0/home.html</strong> from website URL? please help me.</p>
0debug
Number formatting - Java : <p>I need to convert an integer so that a dash is inserted after two characters, for example 12-34-56. </p> <p>The integer will be a randomly generated six digit number.</p>
0debug
*ngFor on ng-template outputs nothing Angular2 : <p>Not sure why my *ngFor loop is printing nothing out. I have the following code in an html file:</p> <pre><code>&lt;table class="table table-hover"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Email&lt;/th&gt; &lt;th&gt;Company&lt;/th&gt; &lt;th&gt;Status&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;!-- NGFOR ATTEMPTED HERE -- no content printed --&gt; &lt;ng-template *ngFor="let xb of tempData"&gt; &lt;tr data-toggle="collapse" data-target="#demo1" class="accordion-toggle"&gt; &lt;td&gt;{{ xb.name }}&lt;/td&gt; &lt;td&gt;{{ xb.email }}&lt;/td&gt; &lt;td&gt;{{ xb.company }}&lt;/td&gt; &lt;td&gt;{{ xb.status }}&lt;/td&gt; &lt;/tr&gt; &lt;!-- other content --&gt; &lt;/ng-template&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Then, in my simple component I have the following:</p> <pre><code>import { Component } from '@angular/core'; @Component({ selector: 'my-profile-exhibitors', templateUrl: './profile-exhibitors.component.html', styleUrls: ['./profile-exhibitors.component.scss'] }) export class ProfileExhibitorsComponent { public tempData: any = [ { 'name': 'name1', 'email': 'email1@gmail', 'company': 'company', 'status': 'Complete' }, { 'name': 'name2', 'email': 'email2@gmail', 'company': 'company', 'status': 'Incomplete' } ]; constructor() {} } </code></pre> <p>When I run this code, I get zero output. Even weirder is that when I select the element using debug tools I see this:</p> <p><a href="https://i.stack.imgur.com/9Vlch.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9Vlch.png" alt="enter image description here"></a></p> <p>Looks like it correctly recognizes my object, but then outputs nothing.</p>
0debug
Slow Docker on Windows Run Step, Why? : <p>I'm trying to create a new docker image with the following <code>dockerfile</code>, but it's taking an awful long time to finish one of the steps:</p> <pre><code>FROM microsoft/dotnet-framework:4.7 SHELL ["powershell"] # Note: Get MSBuild 12. RUN Invoke-WebRequest "https://download.microsoft.com/download/9/B/B/9BB1309E-1A8F-4A47-A6C5-ECF76672A3B3/BuildTools_Full.exe" -OutFile "$env:TEMP\BuildTools_Full.exe" -UseBasicParsing RUN &amp; "$env:TEMP\BuildTools_Full.exe" /Silent /Full # Todo: delete the BuildTools_Full.exe file in this layer # Note: Add .NET ## RUN Install-WindowsFeature NET-Framework-45-Features ; \ # Note: Add NuGet RUN Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "C:\windows\nuget.exe" -UseBasicParsing WORKDIR "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0" # Note: Add Msbuild to path RUN setx PATH '%PATH%;C:\\Program Files (x86)\\MSBuild\\12.0\\Bin\\msbuild.exe' CMD ["C:\\Program Files (x86)\\MSBuild\\12.0\\Bin\\msbuild.exe"] </code></pre> <p>Here is the output so far:</p> <pre><code>PS C:\MyWorkspace\images\msbuild&gt; docker build -t msbuild . Sending build context to Docker daemon 2.56kB Step 1/9 : FROM microsoft/dotnet-framework:4.7 ---&gt; 91abbfdc50cb Step 2/9 : MAINTAINER mohamed.elkammar@gmail.com ---&gt; Using cache ---&gt; fbf720101007 Step 3/9 : SHELL powershell ---&gt; Using cache ---&gt; 642cf0e08730 Step 4/9 : RUN Invoke-WebRequest "https://download.microsoft.com/download/9/B/B/9BB1309E-1A8F-4A47-A6C5-ECF76672A3B3/BuildTools_Full.exe" -OutFile "$env:TEMP\BuildTools_Full.exe" -UseBasicParsing ---&gt; Using cache ---&gt; a722c88fee0f Step 5/9 : RUN &amp; "$env:TEMP\BuildTools_Full.exe" /Silent /Full ---&gt; Using cache ---&gt; 4fda7448f2e4 Step 6/9 : RUN Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "C:\windows\nuget.exe" -UseBasicParsing ---&gt; Running in eec036874574 </code></pre> <p>Additionally, here is the output of <code>docker info</code>:</p> <pre><code>C:\Windows\system32&gt;docker info Containers: 2 Running: 1 Paused: 0 Stopped: 1 Images: 5 Server Version: 17.06.1-ee-2 Storage Driver: windowsfilter Windows: Logging Driver: json-file Plugins: Volume: local Network: l2bridge l2tunnel nat null overlay transparent Log: awslogs etwlogs fluentd json-file logentries splunk syslog Swarm: inactive Default Isolation: process Kernel Version: 10.0 14393 (14393.1715.amd64fre.rs1_release_inmarket.170906-1810) Operating System: Windows Server 2016 Datacenter OSType: windows Architecture: x86_64 CPUs: 1 Total Memory: 4.75GiB Name: instance-1 ID: B2BG:6AW5:Y32S:YLIO:FE25:WWDO:ZAGQ:CZ3M:S5XM:LSHB:U5GM:VYEM Docker Root Dir: C:\ProgramData\docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false </code></pre> <p>What would cause a simple download step to take forever?</p>
0debug
static int vaapi_decode_make_config(AVCodecContext *avctx) { VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data; AVVAAPIHWConfig *hwconfig = NULL; AVHWFramesConstraints *constraints = NULL; VAStatus vas; int err, i, j; const AVCodecDescriptor *codec_desc; VAProfile profile, *profile_list = NULL; int profile_count, exact_match, alt_profile; const AVPixFmtDescriptor *sw_desc, *desc; codec_desc = avcodec_descriptor_get(avctx->codec_id); if (!codec_desc) { err = AVERROR(EINVAL); goto fail; } profile_count = vaMaxNumProfiles(ctx->hwctx->display); profile_list = av_malloc_array(profile_count, sizeof(VAProfile)); if (!profile_list) { err = AVERROR(ENOMEM); goto fail; } vas = vaQueryConfigProfiles(ctx->hwctx->display, profile_list, &profile_count); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to query profiles: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(ENOSYS); goto fail; } profile = VAProfileNone; exact_match = 0; for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) { int profile_match = 0; if (avctx->codec_id != vaapi_profile_map[i].codec_id) continue; if (avctx->profile == vaapi_profile_map[i].codec_profile || vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN) profile_match = 1; profile = vaapi_profile_map[i].va_profile; for (j = 0; j < profile_count; j++) { if (profile == profile_list[j]) { exact_match = profile_match; break; } } if (j < profile_count) { if (exact_match) break; alt_profile = vaapi_profile_map[i].codec_profile; } } av_freep(&profile_list); if (profile == VAProfileNone) { av_log(avctx, AV_LOG_ERROR, "No support for codec %s " "profile %d.\n", codec_desc->name, avctx->profile); err = AVERROR(ENOSYS); goto fail; } if (!exact_match) { if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) { av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not " "supported for hardware decode.\n", codec_desc->name, avctx->profile); av_log(avctx, AV_LOG_WARNING, "Using possibly-" "incompatible profile %d instead.\n", alt_profile); } else { av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not " "supported for hardware decode.\n", codec_desc->name, avctx->profile); err = AVERROR(EINVAL); goto fail; } } ctx->va_profile = profile; ctx->va_entrypoint = VAEntrypointVLD; vas = vaCreateConfig(ctx->hwctx->display, ctx->va_profile, ctx->va_entrypoint, NULL, 0, &ctx->va_config); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to create decode " "configuration: %d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail; } hwconfig = av_hwdevice_hwconfig_alloc(avctx->hw_device_ctx ? avctx->hw_device_ctx : ctx->frames->device_ref); if (!hwconfig) { err = AVERROR(ENOMEM); goto fail; } hwconfig->config_id = ctx->va_config; constraints = av_hwdevice_get_hwframe_constraints(avctx->hw_device_ctx ? avctx->hw_device_ctx : ctx->frames->device_ref, hwconfig); if (!constraints) { err = AVERROR(ENOMEM); goto fail; } if (avctx->coded_width < constraints->min_width || avctx->coded_height < constraints->min_height || avctx->coded_width > constraints->max_width || avctx->coded_height > constraints->max_height) { av_log(avctx, AV_LOG_ERROR, "Hardware does not support image " "size %dx%d (constraints: width %d-%d height %d-%d).\n", avctx->coded_width, avctx->coded_height, constraints->min_width, constraints->max_width, constraints->min_height, constraints->max_height); err = AVERROR(EINVAL); goto fail; } if (!constraints->valid_sw_formats || constraints->valid_sw_formats[0] == AV_PIX_FMT_NONE) { av_log(avctx, AV_LOG_ERROR, "Hardware does not offer any " "usable surface formats.\n"); err = AVERROR(EINVAL); goto fail; } ctx->surface_format = constraints->valid_sw_formats[0]; sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); for (i = 0; constraints->valid_sw_formats[i] != AV_PIX_FMT_NONE; i++) { desc = av_pix_fmt_desc_get(constraints->valid_sw_formats[i]); if (desc->nb_components != sw_desc->nb_components || desc->log2_chroma_w != sw_desc->log2_chroma_w || desc->log2_chroma_h != sw_desc->log2_chroma_h) continue; for (j = 0; j < desc->nb_components; j++) { if (desc->comp[j].depth != sw_desc->comp[j].depth) break; } if (j < desc->nb_components) continue; ctx->surface_format = constraints->valid_sw_formats[i]; break; } ctx->surface_count = 4; switch (avctx->codec_id) { case AV_CODEC_ID_H264: case AV_CODEC_ID_HEVC: ctx->surface_count += 16; break; case AV_CODEC_ID_VP9: ctx->surface_count += 8; break; case AV_CODEC_ID_VP8: ctx->surface_count += 3; break; default: ctx->surface_count += 2; } if (avctx->active_thread_type & FF_THREAD_FRAME) ctx->surface_count += avctx->thread_count; av_hwframe_constraints_free(&constraints); av_freep(&hwconfig); return 0; fail: av_hwframe_constraints_free(&constraints); av_freep(&hwconfig); if (ctx->va_config != VA_INVALID_ID) { vaDestroyConfig(ctx->hwctx->display, ctx->va_config); ctx->va_config = VA_INVALID_ID; } av_freep(&profile_list); return err; }
1threat
int64_t bdrv_getlength(BlockDriverState *bs) { int64_t ret = bdrv_nb_sectors(bs); return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE; }
1threat
C++ ifstream data type? : The variable "read" in this program needs to be passed through a function and i don't know what data type it is. I have used http://www.cplusplus.com/reference/fstream/ifstream/ifstream/ and http://www.cplusplus.com/reference/fstream/ifstream/ but I'm struggling to find anything, is this just not possible? ifstream read(ans.c_str());
0debug
iOS table view don't start with first row : <p>I do everything in tutorial but row don't start in first row</p> <p><a href="http://i.stack.imgur.com/52Oat.png" rel="nofollow">Table View in Storyboard</a></p> <p><a href="http://i.stack.imgur.com/gtDeq.png" rel="nofollow">Code for table view</a></p>
0debug
Merging data based on matching first column in Python : <p>I currently have two sets of data files that look like this:</p> <p>File 1:</p> <pre><code>test1 ba ab cd dh gf test2 fa ab cd dh gf test3 rt ty er wq ee test4 er rt sf sd sa </code></pre> <p>and in file 2:</p> <pre><code>test1 123 344 123 test1 234 567 787 test1 221 344 566 test3 456 121 677 </code></pre> <p>I would like to combine the files based on mathching rows in the first column (so that "tests" match up)</p> <p>like so:</p> <pre><code>test1 ba ab cd dh gf 123 344 123 test1 ba ab cd dh gf 234 567 787 test1 ba ab cd dh gf 221 344 566 test3 rt ty er wq ee 456 121 677 </code></pre> <p>I have this Code</p> <pre><code>def combineFiles(file1,file2,outfile): def read_file(file): data = {} for line in csv.reader(file): data[line[0]] = line[1:] return data with open(file1, 'r') as f1, open(file2, 'r') as f2: data1 = read_file(f1) data2 = read_file(f2) with open(outfile, 'w') as out: wtr= csv.writer(out) for key in data1.keys(): try: wtr.writerow(((key), ','.join(data1[key]), ','.join(data2[key]))) except KeyError: pass </code></pre> <p>However the output ends up looking like this:</p> <pre><code>test1 ba ab cd dh gf 123 344 123 test3 er rt sf sd sa 456 121 677 </code></pre> <p>Can anyone help me with how to make the output so that test1 can be printed all three times?</p> <p>Much Appreciated</p>
0debug
static void error_mem_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { abort(); }
1threat
static void decode(GetByteContext *gb, RangeCoder *rc, unsigned cumFreq, unsigned freq, unsigned total_freq) { rc->code -= cumFreq * rc->range; rc->range *= freq; while (rc->range < TOP && bytestream2_get_bytes_left(gb) > 0) { unsigned byte = bytestream2_get_byte(gb); rc->code = (rc->code << 8) | byte; rc->range <<= 8; } }
1threat
Java Eclipse Debug and Deploy Issues : <p>I'm working on a big project and the test component is consumed me the most part of the time. Why ? When I made some changes in a project during the debug, to suffer effect I have to stop the debug, deply and debug again. And I know if I change the configurations, I can do some changes during the debug. Anyone know what I need to do?</p> <p>Another problem: To do the deploy of some changes, how can I do without deploy all of the project ? This consume more than 7 minutes.</p> <p>Thanks in advance</p>
0debug
Java external command : not found, createProcess errno=2 : <p>I try</p> <pre><code>ProcessBuilder().command("C:\\Windows\\System32\\sc.exe query power"); </code></pre> <p>or</p> <pre><code>ProcessBuilder().command("c:/windows/system32/sc.exe query power"); </code></pre> <p>or</p> <pre><code>ProcessBuilder().command("c:/windows/system32/sc query power"); </code></pre> <p>I always get the same error ...</p>
0debug
static bool msix_is_masked(PCIDevice *dev, int vector) { return msix_vector_masked(dev, vector, dev->msix_function_masked); }
1threat
static int svq3_decode_mb(H264Context *h, unsigned int mb_type) { int i, j, k, m, dir, mode; int cbp = 0; uint32_t vlc; int8_t *top, *left; MpegEncContext *const s = (MpegEncContext *) h; const int mb_xy = h->mb_xy; const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF; h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF; h->topright_samples_available = 0xFFFF; if (mb_type == 0) { if (s->pict_type == FF_P_TYPE || s->next_picture.mb_type[mb_xy] == -1) { svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0); if (s->pict_type == FF_B_TYPE) { svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 1, 1); } mb_type = MB_TYPE_SKIP; } else { mb_type = FFMIN(s->next_picture.mb_type[mb_xy], 6); if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0) return -1; if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0) return -1; mb_type = MB_TYPE_16x16; } } else if (mb_type < 8) { if (h->thirdpel_flag && h->halfpel_flag == !get_bits1 (&s->gb)) { mode = THIRDPEL_MODE; } else if (h->halfpel_flag && h->thirdpel_flag == !get_bits1 (&s->gb)) { mode = HALFPEL_MODE; } else { mode = FULLPEL_MODE; } for (m = 0; m < 2; m++) { if (s->mb_x > 0 && h->intra4x4_pred_mode[mb_xy - 1][0] != -1) { for (i = 0; i < 4; i++) { *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride]; } } else { for (i = 0; i < 4; i++) { *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0; } } if (s->mb_y > 0) { memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t)); memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[mb_xy - s->mb_stride][4] == -1) ? PART_NOT_AVAILABLE : 1, 4); if (s->mb_x < (s->mb_width - 1)) { *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4]; h->ref_cache[m][scan8[0] + 4 - 1*8] = (h->intra4x4_pred_mode[mb_xy - s->mb_stride + 1][0] == -1 || h->intra4x4_pred_mode[mb_xy - s->mb_stride ][4] == -1) ? PART_NOT_AVAILABLE : 1; }else h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE; if (s->mb_x > 0) { *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1]; h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[mb_xy - s->mb_stride - 1][3] == -1) ? PART_NOT_AVAILABLE : 1; }else h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE; }else memset(&h->ref_cache[m][scan8[0] - 1*8 - 1], PART_NOT_AVAILABLE, 8); if (s->pict_type != FF_B_TYPE) break; } if (s->pict_type == FF_P_TYPE) { if (svq3_mc_dir(h, (mb_type - 1), mode, 0, 0) < 0) return -1; } else { if (mb_type != 2) { if (svq3_mc_dir(h, 0, mode, 0, 0) < 0) return -1; } else { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } if (mb_type != 1) { if (svq3_mc_dir(h, 0, mode, 1, (mb_type == 3)) < 0) return -1; } else { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } } mb_type = MB_TYPE_16x16; } else if (mb_type == 8 || mb_type == 33) { memset(h->intra4x4_pred_mode_cache, -1, 8*5*sizeof(int8_t)); if (mb_type == 8) { if (s->mb_x > 0) { for (i = 0; i < 4; i++) { h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[mb_xy - 1][i]; } if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) { h->left_samples_available = 0x5F5F; } } if (s->mb_y > 0) { h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][4]; h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][5]; h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][6]; h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][3]; if (h->intra4x4_pred_mode_cache[4+8*0] == -1) { h->top_samples_available = 0x33FF; } } for (i = 0; i < 16; i+=2) { vlc = svq3_get_ue_golomb(&s->gb); if (vlc >= 25){ av_log(h->s.avctx, AV_LOG_ERROR, "luma prediction:%d\n", vlc); return -1; } left = &h->intra4x4_pred_mode_cache[scan8[i] - 1]; top = &h->intra4x4_pred_mode_cache[scan8[i] - 8]; left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]]; left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]]; if (left[1] == -1 || left[2] == -1){ av_log(h->s.avctx, AV_LOG_ERROR, "weird prediction\n"); return -1; } } } else { for (i = 0; i < 4; i++) { memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_PRED, 4); } } ff_h264_write_back_intra_pred_mode(h); if (mb_type == 8) { ff_h264_check_intra4x4_pred_mode(h); h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF; h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF; } else { for (i = 0; i < 4; i++) { memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_128_PRED, 4); } h->top_samples_available = 0x33FF; h->left_samples_available = 0x5F5F; } mb_type = MB_TYPE_INTRA4x4; } else { dir = i_mb_type_info[mb_type - 8].pred_mode; dir = (dir >> 1) ^ 3*(dir & 1) ^ 1; if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir)) == -1){ av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n"); return -1; } cbp = i_mb_type_info[mb_type - 8].cbp; mb_type = MB_TYPE_INTRA16x16; } if (!IS_INTER(mb_type) && s->pict_type != FF_I_TYPE) { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } if (s->pict_type == FF_B_TYPE) { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } } if (!IS_INTRA4x4(mb_type)) { memset(h->intra4x4_pred_mode[mb_xy], DC_PRED, 8); } if (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE) { memset(h->non_zero_count_cache + 8, 0, 4*9*sizeof(uint8_t)); s->dsp.clear_blocks(h->mb); } if (!IS_INTRA16x16(mb_type) && (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE)) { if ((vlc = svq3_get_ue_golomb(&s->gb)) >= 48){ av_log(h->s.avctx, AV_LOG_ERROR, "cbp_vlc=%d\n", vlc); return -1; } cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc] : golomb_to_inter_cbp[vlc]; } if (IS_INTRA16x16(mb_type) || (s->pict_type != FF_I_TYPE && s->adaptive_quant && cbp)) { s->qscale += svq3_get_se_golomb(&s->gb); if (s->qscale > 31){ av_log(h->s.avctx, AV_LOG_ERROR, "qscale:%d\n", s->qscale); return -1; } } if (IS_INTRA16x16(mb_type)) { if (svq3_decode_block(&s->gb, h->mb, 0, 0)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\n"); return -1; } } if (cbp) { const int index = IS_INTRA16x16(mb_type) ? 1 : 0; const int type = ((s->qscale < 24 && IS_INTRA4x4(mb_type)) ? 2 : 1); for (i = 0; i < 4; i++) { if ((cbp & (1 << i))) { for (j = 0; j < 4; j++) { k = index ? ((j&1) + 2*(i&1) + 2*(j&2) + 4*(i&2)) : (4*i + j); h->non_zero_count_cache[ scan8[k] ] = 1; if (svq3_decode_block(&s->gb, &h->mb[16*k], index, type)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding block\n"); return -1; } } } } if ((cbp & 0x30)) { for (i = 0; i < 2; ++i) { if (svq3_decode_block(&s->gb, &h->mb[16*(16 + 4*i)], 0, 3)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma dc block\n"); return -1; } } if ((cbp & 0x20)) { for (i = 0; i < 8; i++) { h->non_zero_count_cache[ scan8[16+i] ] = 1; if (svq3_decode_block(&s->gb, &h->mb[16*(16 + i)], 1, 1)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma ac block\n"); return -1; } } } } } h->cbp= cbp; s->current_picture.mb_type[mb_xy] = mb_type; if (IS_INTRA(mb_type)) { h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8); } return 0; }
1threat
Handling refresh tokens using rxjs : <p>Since i've started with angular2 i have setup my services to return Observable of T. In the service i would have the map() call, and components using these services would just use subscribe() to wait for the response. For these simple scenarios i didnt really need to dig in to rxjs so all was ok. </p> <p>I now want to achieve the following: i am using Oauth2 authentication with refresh tokens. I want to build an api service that all other services will use, and that will transparently handle the refresh token when a 401 error is returned. So, in the case of a 401, i first fetch a new token from the OAuth2 endpoint, and then retry my request with the new token. Below is the code that works fine, with promises:</p> <pre><code>request(url: string, request: RequestOptionsArgs): Promise&lt;Response&gt; { var me = this; request.headers = request.headers || new Headers(); var isSecureCall: boolean = true; //url.toLowerCase().startsWith('https://'); if (isSecureCall === true) { me.authService.setAuthorizationHeader(request.headers); } request.headers.append('Content-Type', 'application/json'); request.headers.append('Accept', 'application/json'); return this.http.request(url, request).toPromise() .catch(initialError =&gt; { if (initialError &amp;&amp; initialError.status === 401 &amp;&amp; isSecureCall === true) { // token might be expired, try to refresh token. return me.authService.refreshAuthentication().then((authenticationResult:AuthenticationResult) =&gt; { if (authenticationResult.IsAuthenticated == true) { // retry with new token me.authService.setAuthorizationHeader(request.headers); return this.http.request(url, request).toPromise(); } return &lt;any&gt;Promise.reject(initialError); }); } else { return &lt;any&gt;Promise.reject(initialError); } }); } </code></pre> <p>In the code above, authService.refreshAuthentication() will fetch the new token and store it in localStorage. authService.setAuthorizationHeader will set the 'Authorization' header to previously updated token. If you look at the catch method, you'll see that it returns a promise (for the refresh token) that in its turns will eventually return another promise (for the actual 2nd try of the request).</p> <p>I have attempted to do this without resorting to promises:</p> <pre><code>request(url: string, request: RequestOptionsArgs): Observable&lt;Response&gt; { var me = this; request.headers = request.headers || new Headers(); var isSecureCall: boolean = true; //url.toLowerCase().startsWith('https://'); if (isSecureCall === true) { me.authService.setAuthorizationHeader(request.headers); } request.headers.append('Content-Type', 'application/json'); request.headers.append('Accept', 'application/json'); return this.http.request(url, request) .catch(initialError =&gt; { if (initialError &amp;&amp; initialError.status === 401 &amp;&amp; isSecureCall === true) { // token might be expired, try to refresh token return me.authService.refreshAuthenticationObservable().map((authenticationResult:AuthenticationResult) =&gt; { if (authenticationResult.IsAuthenticated == true) { // retry with new token me.authService.setAuthorizationHeader(request.headers); return this.http.request(url, request); } return Observable.throw(initialError); }); } else { return Observable.throw(initialError); } }); } </code></pre> <p>The code above does not do what i expect: in the case of a 200 response, it properly returns the response. However, if it catches the 401, it will successfully retrieve the new token, but the subscribe wil eventually retrieve an observable instead of the response. Im guessing this is the unexecuted Observable that should do the retry.</p> <p>I realize that translating the promise way of working onto the rxjs library is probably not the best way to go, but i havent been able to grasp the "everything is a stream" thing. I have tried a few other solutions involving flatmap, retryWhen etc ... but didnt get far, so some help is appreciated.</p>
0debug
Selector not work for button : [This is my selector code][1] [This is my xml][2] [1]: https://i.stack.imgur.com/Vhrf2.png [2]: https://i.stack.imgur.com/CeaZM.png Anyone smarter than I am have a solution to this? Thanks!
0debug
iterate over a list to change variable in python : I have a list of words and I want to iterate over it to pull groups of 5 and assign them to a variable as strings which I then run some code and then change the variable so that my output looks something like this words = ['word1', 'word2', 'word3', 'word4', 'word5', 'word6', 'word7', 'word8'] var = 'word1', 'word2', 'word3', 'word4', 'word5' print(var) var = 'word6', 'word7', 'word8' print(var)
0debug
how to find parent node of a row using jquery : i have a html like this <tbody> <tr id="article0"> <td id="CheckboxDiv0"> <div class="checkbox"> <label> <input type="checkbox" id="CheckboxArticle0" value="helo"> </label> </div> </td> </tr> </tbody> i have the following code to get the parent id $ParentId=$("#checkboxArticle0").parentNode.parentNode.parentNode.parentNode.id; but this code is not working fine can someone suggest me how to grab the id of the parent div which is "article0"
0debug
I need to skip lines in a text file : I'm very new to Python and we are using pandas to read a text file and retrieve data from specific lines. There are 44 lines listed in my text file but I only need from line 35 -44. And I need to exclude everything but "President", "Took office", "Left Office", "Party". I have this function but its not reading my df1 that will be my dataframe. def party_list(): df1 = pd.read_table("presidents.txt", delimiter=",",usecols=["President ", "Took office ","Left office ", "Party "]) location1=r' /users/Paula/PycharmProjects/Spring 2018_Paula/ ' f = open("presidents.txt",'r') while True: line = f.readline() if line == "": break print(line)
0debug
static int qcow_write_snapshots(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; QCowSnapshotHeader h; int i, name_size, id_str_size, snapshots_size; uint64_t data64; uint32_t data32; int64_t offset, snapshots_offset; offset = 0; for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; offset = align_offset(offset, 8); offset += sizeof(h); offset += strlen(sn->id_str); offset += strlen(sn->name); } snapshots_size = offset; snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); offset = snapshots_offset; if (offset < 0) { return offset; } for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; memset(&h, 0, sizeof(h)); h.l1_table_offset = cpu_to_be64(sn->l1_table_offset); h.l1_size = cpu_to_be32(sn->l1_size); h.vm_state_size = cpu_to_be32(sn->vm_state_size); h.date_sec = cpu_to_be32(sn->date_sec); h.date_nsec = cpu_to_be32(sn->date_nsec); h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec); id_str_size = strlen(sn->id_str); name_size = strlen(sn->name); h.id_str_size = cpu_to_be16(id_str_size); h.name_size = cpu_to_be16(name_size); offset = align_offset(offset, 8); if (bdrv_pwrite(bs->file, offset, &h, sizeof(h)) != sizeof(h)) goto fail; offset += sizeof(h); if (bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size) != id_str_size) goto fail; offset += id_str_size; if (bdrv_pwrite(bs->file, offset, sn->name, name_size) != name_size) goto fail; offset += name_size; } data64 = cpu_to_be64(snapshots_offset); if (bdrv_pwrite(bs->file, offsetof(QCowHeader, snapshots_offset), &data64, sizeof(data64)) != sizeof(data64)) goto fail; data32 = cpu_to_be32(s->nb_snapshots); if (bdrv_pwrite(bs->file, offsetof(QCowHeader, nb_snapshots), &data32, sizeof(data32)) != sizeof(data32)) goto fail; qcow2_free_clusters(bs, s->snapshots_offset, s->snapshots_size); s->snapshots_offset = snapshots_offset; s->snapshots_size = snapshots_size; return 0; fail: return -1; }
1threat
Need Help in JAVA LIST .. Urgent //Thanks in advance : class Solution { public List<List<Integer>> largeGroupPositions(String S) { //int k=0; List<Integer> l1 = new ArrayList<Integer>(); List<List<Integer>> l2 = new ArrayList<List<Integer>>(); int n = S.length(); int count =1, i1=0, i2=0; for(int i=1; i<n; i++){ if(S.charAt(i)==S.charAt(i-1)){ count++; }else{ i2 = i-1; if(count>=3){ l1.add(i1); l1.add(i2); l2.add(l1); } count =1; i1=i; } } return l2; } }**I need this output [[3,5],[6,9],[12,14]], But i am getting [[3,5,6,9,12,14],[3,5,6,9,12,14],[3,5,6,9,12,14]], If i uses l1.clear() in else part then the changes is occuring in l2 also**
0debug
static inline uint64_t tcg_opc_movi_a(int qp, TCGReg dst, int64_t src) { assert(src == sextract64(src, 0, 22)); return tcg_opc_a5(qp, OPC_ADDL_A5, dst, src, TCG_REG_R0); }
1threat
Show placeholder page when browser receives 302 request : <p>When a browser is receiving redirect request from server, for a fraction of second, browser shows an error page that says "Page not found", and then redirects to appropriate url.</p> <p>I am looking for solution where browser, instead of displaying "Page not found" page, shows a dummy page. </p> <p>I assume this is what payment gateways are doing by displaying a page that says "Do not press back/refresh button".</p>
0debug
void OPPROTO op_subfme (void) { T0 = ~T0 + xer_ca - 1; if (likely((uint32_t)T0 != (uint32_t)-1)) xer_ca = 1; RETURN(); }
1threat
Get access to all installed Apps on Iphone : I want to display all apps there was installed on the iPhone in a UITableView in my App and then I would like to display the internet usage of each apps there are installed. Is that Possible ? Thanks for your answer and a good day :)
0debug
int main(int argc, char *argv[]) { int fd_in, fd_out, comp_len, uncomp_len, i, last_out; char buf_in[1024], buf_out[65536]; z_stream zstream; struct stat statbuf; if (argc < 3) { printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]); return 1; } fd_in = open(argv[1], O_RDONLY); if (fd_in < 0) { perror("Error opening input file"); return 1; } fd_out = open(argv[2], O_WRONLY | O_CREAT, 00644); if (fd_out < 0) { perror("Error opening output file"); close(fd_in); return 1; } if (read(fd_in, &buf_in, 8) != 8) { printf("Header error\n"); close(fd_in); close(fd_out); return 1; } if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') { printf("Not a compressed flash file\n"); return 1; } fstat(fd_in, &statbuf); comp_len = statbuf.st_size; uncomp_len = buf_in[4] | (buf_in[5] << 8) | (buf_in[6] << 16) | (buf_in[7] << 24); printf("Compressed size: %d Uncompressed size: %d\n", comp_len - 4, uncomp_len - 4); buf_in[0] = 'F'; if (write(fd_out, &buf_in, 8) < 8) { perror("Error writing output file"); return 1; } zstream.zalloc = NULL; zstream.zfree = NULL; zstream.opaque = NULL; if (inflateInit(&zstream) != Z_OK) { fprintf(stderr, "inflateInit failed\n"); return 1; } for (i = 0; i < comp_len - 8;) { int ret, len = read(fd_in, &buf_in, 1024); dbgprintf("read %d bytes\n", len); last_out = zstream.total_out; zstream.next_in = &buf_in[0]; zstream.avail_in = len; zstream.next_out = &buf_out[0]; zstream.avail_out = 65536; ret = inflate(&zstream, Z_SYNC_FLUSH); if (ret != Z_STREAM_END && ret != Z_OK) { printf("Error while decompressing: %d\n", ret); inflateEnd(&zstream); return 1; } dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n", zstream.avail_in, zstream.total_in, zstream.avail_out, zstream.total_out, zstream.total_out - last_out); if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) { perror("Error writing output file"); return 1; } i += len; if (ret == Z_STREAM_END || ret == Z_BUF_ERROR) break; } if (zstream.total_out != uncomp_len - 8) { printf("Size mismatch (%lu != %d), updating header...\n", zstream.total_out, uncomp_len - 8); buf_in[0] = (zstream.total_out + 8) & 0xff; buf_in[1] = ((zstream.total_out + 8) >> 8) & 0xff; buf_in[2] = ((zstream.total_out + 8) >> 16) & 0xff; buf_in[3] = ((zstream.total_out + 8) >> 24) & 0xff; if ( lseek(fd_out, 4, SEEK_SET) < 0 || write(fd_out, &buf_in, 4) < 4) { perror("Error writing output file"); return 1; } } inflateEnd(&zstream); close(fd_in); close(fd_out); return 0; }
1threat
ES6 destructuring within a return statement : <p>Is it possible to destructure an object while returning it at the same time. For example, to change this code:</p> <pre><code>const mapStateToProps = ({ newItem }) =&gt;{ const { id, name, price } = newItem; return { id, name, price }; } </code></pre> <p>To something like this:</p> <pre><code>const mapStateToProps = ({ newItem }) =&gt;{ return { id, name, price } = newItem; } </code></pre>
0debug
Flutter - how to get Text widget on widget test : <p>I'm trying to create a simple widget test in Flutter. I have a custom widget that receives some values, composes a string and shows a Text with that string. I got to create the widget and it works, but I'm having trouble reading the value of the Text component to assert that the generated text is correct.</p> <p>I created a simple test that illustrates the issue. I want to get the text value, which is "text". I tried several ways, if I get the finder asString() I could interpret the string to get the value, but I don't consider that a good solution. I wanted to read the component as a Text so that I have access to all the properties.</p> <p>So, how would I read the Text widget so that I can access the data property?</p> <pre><code>import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('my first widget test', (WidgetTester tester) async { await tester .pumpWidget(MaterialApp(home: Text("text", key: Key('unit_text')))); // This works and prints: (Text-[&lt;'unit_text'&gt;]("text")) var finder = find.byKey(Key("unit_text")); print(finder.evaluate().first); // This also works and prints: (Text-[&lt;'unit_text'&gt;]("text")) var finderByType = find.byType(Text); print(finderByType.evaluate().first); // This returns empty print(finder.first.evaluate().whereType&lt;Text&gt;()); // This throws: type 'StatelessElement' is not a subtype of type 'Text' in type cast print(finder.first.evaluate().cast&lt;Text&gt;().first); }); } </code></pre>
0debug
In Java, what is the difference between a monitor and a lock : <p>Using the synchronized keyword method, using the javap command to view the bytecode, it is found that monitor is used, and if it is possible to call the monitor when the synchronized is implemented, is that my understanding, right? Please correct it if you do not. What is the relationship between them? What is the relationship between the lock and the monitor?</p>
0debug
How to globally set the preserveWhitespaces option in Angular to false? : <p>Since one of the beta releases of version 5, Angular has a new compiler option, <code>preserveWhitespaces</code>. The property is mentioned in <a href="https://angular.io/api/core/CompilerOptions" rel="noreferrer"><code>CompilerOptions</code> type alias</a> in the docs. The docs for the <code>Component</code> decorator describe <a href="https://angular.io/api/core/Component#preserveWhitespaces" rel="noreferrer"><strong>its usage</strong></a>, and mention that the default in version 5 is <code>true</code> (no whitespace removal).</p> <p>I've seen <a href="https://github.com/angular/angular/pull/18401/files" rel="noreferrer">the PR</a>, but from what I can tell from some tests is that the only way to use it is to supply <code>preserveWhitespace</code> to every <code>@Component</code> metadata. How can I set it to <code>false</code> globally, for <em>all</em> components, and then set it to <code>true</code> only for some components?</p>
0debug
How to check connected user on psql : <p>In my PostgreSQL database I have 2 users: postgres and myuser.</p> <p>The default user is postgres, but this user has no permission to query my foreign tables and myuser does. How can I check if I'm connected with the right user?</p> <p>If I'm using the wrong user, how do I change to the right one?</p>
0debug
Wrote the code for sorting. Getting timeout error. Any ideas how to get it working (PS:started coding a week ago) : <p>The following code is supposed to do sorting by assigning indexes based on greater or less than. eg for 5,17,13,21,6 5 is greater than 0 numbers, 17 is greater than 3 numbers 13 is greater than 2 number 21 is greater than 4 numbers and 6 is greater than 1 number. so we use these indexes and then place the numbers in new array accordingly. </p> <pre><code>#include&lt;stdio.h&gt; int main() { int i,j,w[4],z[4],x[4]; x[0]=0;x[1]=0;x[2]=0;x[3]=0; w[0]=1; w[1]=3; w[2]=7; w[3]=15; for(i=0; i&lt;4; i++) { for(j=0; j&lt;4; i++) { if (w[j] &lt; w[i]) { x[i] = x[i] + 1;} ;} ;} for(i=0; i&lt;4; i++) {z[x[i]]=w[i];} for(i=0; i&lt;4; i++) {printf("%d",z[i]);} } </code></pre>
0debug
Spark Framework: Match with or without trailing slash : <p>I have noticed something in the Spark Framework. It does not match trailing slashes with a mapped route. So it considers /api/test and /api/test/ as different URIs.</p> <p>That's fine if there is a way to wildcard them together, but there doesn't seem to be. Am I missing anything?</p> <p>I want this route:</p> <pre><code>Spark.get("/api/test", (req, res) -&gt; { return "TEST OK"; }); </code></pre> <p>To match /api/test OR /api/test/. As it stands, it only matches /api/test, and if I switch it to:</p> <pre><code>Spark.get("/api/test/", (req, res) -&gt; { return "TEST OK"; }); </code></pre> <p>It only matches <code>/api/test/</code></p>
0debug
def find_missing(ar,N): l = 0 r = N - 1 while (l <= r): mid = (l + r) / 2 mid= int (mid) if (ar[mid] != mid + 1 and ar[mid - 1] == mid): return (mid + 1) elif (ar[mid] != mid + 1): r = mid - 1 else: l = mid + 1 return (-1)
0debug
Run a java application on linux : <p>I have created a java application run by main. My development is done by Eclipse on PC and I would like to run it on linux scheduled by cronjob. The application has dependencies. Some classes are self-created. Some are external jars. What is the most convenient way to compile it to include all dependencies and put it on the linux?</p> <p>Thanks</p>
0debug
How to properly return Optional<> of a method? : <p>I have read a lot of Java 8 Optional and I do understand the concept, but still get difficulties when trying to implement it myself in my code.</p> <p>Although I have serached the web for good examples, I didn't found one with good explanation.</p> <p>I have the next method:</p> <pre><code>public static String getFileMd5(String filePath) throws NoSuchAlgorithmException, IOException { AutomationLogger.getLog().info("Trying getting MD5 hash from file: " + filePath); MessageDigest md = MessageDigest.getInstance("MD5"); InputStream inputStream; try { inputStream = Files.newInputStream(Paths.get(filePath)); } catch (NoSuchFileException e) { AutomationLogger.getLog().error("No such file path: " + filePath, e); return null; } DigestInputStream dis = new DigestInputStream(inputStream, md); byte[] buffer = new byte[8 * 1024]; while (dis.read(buffer) != -1); dis.close(); inputStream.close(); byte[] output = md.digest(); BigInteger bi = new BigInteger(1, output); String hashText = bi.toString(16); return hashText; } </code></pre> <p>This simple method returns the md5 of a file, by passing it the file path. As you can notice, if the file path doesn't exists (or wrong typed) a <strong>NoSuchFileException</strong> get thrown and the method return <strong>Null</strong>.</p> <p>Instead of returning null, I want to use Optional, so my method should return <code>Optional &lt;String&gt;</code>, right?</p> <ol> <li>What is the proper way of doing it right?</li> <li>If the returned String is null - can I use here <code>orElse()</code>, or this kind of method should be used by the client side?</li> </ol>
0debug
static void jazz_led_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned int size) { LedState *s = opaque; uint8_t new_val = val & 0xff; trace_jazz_led_write(addr, new_val); s->segments = new_val; s->state |= REDRAW_SEGMENTS; }
1threat
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver, QIOTask *task, size_t *naddrs, SocketAddressLegacy ***addrs) { struct QIODNSResolverLookupData *data = qio_task_get_result_pointer(task); size_t i; *naddrs = 0; *addrs = NULL; if (!data) { return; } *naddrs = data->naddrs; *addrs = g_new0(SocketAddressLegacy *, data->naddrs); for (i = 0; i < data->naddrs; i++) { (*addrs)[i] = QAPI_CLONE(SocketAddressLegacy, data->addrs[i]); } }
1threat
Order by most matched records first : <p>Given the following query:</p> <pre><code>select * from users where first_name ilike '%foo%' OR last_name ilike '%bar%' OR nickname ilike '%foobar%' </code></pre> <p>Returns:</p> <pre><code> first_name| last_name | nickname ---------------------------------------- Foo | ABC | abcd Foo | DEF | efgh Foo | BAR | ijkl AMD | Bar | foobar Foo | Bar | foobar2 </code></pre> <p><strong>Question:</strong></p> <p>How to sort most relevant (matched) values first? I mean by most matched that matches more than one pattern inside <code>Where .. OR</code> </p> <p><strong>Expected Result:</strong></p> <pre><code> first_name| last_name | nickname ---------------------------------------- Foo | Bar | foobar2 Foo | BAR | ijkl AMD | Bar | foobar Foo | ABC | abcd Foo | DEF | efgh </code></pre>
0debug
Is there a text file that translates app names like "com.google.android.youtube" to names that people understand like "YouTube"? : <p>I have a text file with app names like "com.android.chrome", "com.whatsapp", and "com.google.android.youtube" and I want to convert them to names like "Chrome", "WhatsApp", and "YouTube".</p>
0debug
How to ONLY trigger parent click event when a child is clicked : <p>Both child and parent are clickable (child could be a link or div with jQuery click events). When I click on child, how do I only trigger parent click event but not the child event?</p>
0debug
How can I specifically convert this php code to html? : <p>how can I specifically convert this php below code to html? I want to do this as I want to be able to run this code on my website. </p> <p>From reading other forum posts I understand about people saying them link the PHP file externally using something like this <code>&lt;ahref="hello.php"&gt;php&lt;/a&gt;</code>. However, from my understanding my PHP code is slightly different in terms of the output and I'm just not sure. </p> <p>Below is my php code I want to run externally on my site from the html file. </p> <pre><code>&lt;?php echo $_SERVER['HTTP_USER_AGENT']; $browser = get_browser(); print_r($browser); ?&gt; </code></pre>
0debug
static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1) { uint32_t insn, imm, shift, offset; uint32_t rd, rn, rm, rs; TCGv tmp; TCGv tmp2; TCGv tmp3; TCGv addr; TCGv_i64 tmp64; int op; int shiftop; int conds; int logic_cc; if (!(arm_feature(env, ARM_FEATURE_THUMB2) || arm_feature (env, ARM_FEATURE_M))) { insn = insn_hw1; if ((insn & (1 << 12)) == 0) { offset = ((insn & 0x7ff) << 1); tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); tmp2 = new_tmp(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if (insn & (1 << 11)) { offset = ((insn & 0x7ff) << 1) | 1; tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tmp2 = new_tmp(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if ((s->pc & ~TARGET_PAGE_MASK) == 0) { offset = ((int32_t)insn << 21) >> 9; tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + offset); return 0; } } insn = lduw_code(s->pc); s->pc += 2; insn |= (uint32_t)insn_hw1 << 16; if ((insn & 0xf800e800) != 0xf000e800) { ARCH(6T2); } rn = (insn >> 16) & 0xf; rs = (insn >> 12) & 0xf; rd = (insn >> 8) & 0xf; rm = insn & 0xf; switch ((insn >> 25) & 0xf) { case 0: case 1: case 2: case 3: abort(); case 4: if (insn & (1 << 22)) { if (insn & 0x01200000) { if (rn == 15) { addr = new_tmp(); tcg_gen_movi_i32(addr, s->pc & ~3); } else { addr = load_reg(s, rn); } offset = (insn & 0xff) * 4; if ((insn & (1 << 23)) == 0) offset = -offset; if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, offset); offset = 0; } if (insn & (1 << 20)) { tmp = gen_ld32(addr, IS_USER(s)); store_reg(s, rs, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = gen_ld32(addr, IS_USER(s)); store_reg(s, rd, tmp); } else { tmp = load_reg(s, rs); gen_st32(tmp, addr, IS_USER(s)); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rd); gen_st32(tmp, addr, IS_USER(s)); } if (insn & (1 << 21)) { if (rn == 15) goto illegal_op; tcg_gen_addi_i32(addr, addr, offset - 4); store_reg(s, rn, addr); } else { dead_tmp(addr); } } else if ((insn & (1 << 23)) == 0) { addr = tcg_temp_local_new(); load_reg_var(s, addr, rn); tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2); if (insn & (1 << 20)) { gen_load_exclusive(s, rs, 15, addr, 2); } else { gen_store_exclusive(s, rd, rs, 15, addr, 2); } tcg_temp_free(addr); } else if ((insn & (1 << 6)) == 0) { if (rn == 15) { addr = new_tmp(); tcg_gen_movi_i32(addr, s->pc); } else { addr = load_reg(s, rn); } tmp = load_reg(s, rm); tcg_gen_add_i32(addr, addr, tmp); if (insn & (1 << 4)) { tcg_gen_add_i32(addr, addr, tmp); dead_tmp(tmp); tmp = gen_ld16u(addr, IS_USER(s)); } else { dead_tmp(tmp); tmp = gen_ld8u(addr, IS_USER(s)); } dead_tmp(addr); tcg_gen_shli_i32(tmp, tmp, 1); tcg_gen_addi_i32(tmp, tmp, s->pc); store_reg(s, 15, tmp); } else { ARCH(7); op = (insn >> 4) & 0x3; if (op == 2) { goto illegal_op; } addr = tcg_temp_local_new(); load_reg_var(s, addr, rn); if (insn & (1 << 20)) { gen_load_exclusive(s, rs, rd, addr, op); } else { gen_store_exclusive(s, rm, rs, rd, addr, op); } tcg_temp_free(addr); } } else { if (((insn >> 23) & 1) == ((insn >> 24) & 1)) { if (IS_USER(s)) goto illegal_op; if (insn & (1 << 20)) { addr = load_reg(s, rn); if ((insn & (1 << 24)) == 0) tcg_gen_addi_i32(addr, addr, -8); tmp = gen_ld32(addr, 0); tcg_gen_addi_i32(addr, addr, 4); tmp2 = gen_ld32(addr, 0); if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { tcg_gen_addi_i32(addr, addr, -4); } store_reg(s, rn, addr); } else { dead_tmp(addr); } gen_rfe(s, tmp, tmp2); } else { op = (insn & 0x1f); if (op == (env->uncached_cpsr & CPSR_M)) { addr = load_reg(s, 13); } else { addr = new_tmp(); tmp = tcg_const_i32(op); gen_helper_get_r13_banked(addr, cpu_env, tmp); tcg_temp_free_i32(tmp); } if ((insn & (1 << 24)) == 0) { tcg_gen_addi_i32(addr, addr, -8); } tmp = load_reg(s, 14); gen_st32(tmp, addr, 0); tcg_gen_addi_i32(addr, addr, 4); tmp = new_tmp(); gen_helper_cpsr_read(tmp); gen_st32(tmp, addr, 0); if (insn & (1 << 21)) { if ((insn & (1 << 24)) == 0) { tcg_gen_addi_i32(addr, addr, -4); } else { tcg_gen_addi_i32(addr, addr, 4); } if (op == (env->uncached_cpsr & CPSR_M)) { store_reg(s, 13, addr); } else { tmp = tcg_const_i32(op); gen_helper_set_r13_banked(cpu_env, tmp, addr); tcg_temp_free_i32(tmp); } } else { dead_tmp(addr); } } } else { int i; addr = load_reg(s, rn); offset = 0; for (i = 0; i < 16; i++) { if (insn & (1 << i)) offset += 4; } if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } for (i = 0; i < 16; i++) { if ((insn & (1 << i)) == 0) continue; if (insn & (1 << 20)) { tmp = gen_ld32(addr, IS_USER(s)); if (i == 15) { gen_bx(s, tmp); } else { store_reg(s, i, tmp); } } else { tmp = load_reg(s, i); gen_st32(tmp, addr, IS_USER(s)); } tcg_gen_addi_i32(addr, addr, 4); } if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } if (insn & (1 << rn)) goto illegal_op; store_reg(s, rn, addr); } else { dead_tmp(addr); } } } break; case 5: op = (insn >> 21) & 0xf; if (op == 6) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); if (insn & (1 << 5)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); dead_tmp(tmp2); store_reg(s, rd, tmp); } else { if (rn == 15) { tmp = new_tmp(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } tmp2 = load_reg(s, rm); shiftop = (insn >> 4) & 3; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); conds = (insn & (1 << 20)) != 0; logic_cc = (conds && thumb2_logic_op(op)); gen_arm_shift_im(tmp2, shiftop, shift, logic_cc); if (gen_thumb2_data_op(s, op, conds, 0, tmp, tmp2)) goto illegal_op; dead_tmp(tmp2); if (rd != 15) { store_reg(s, rd, tmp); } else { dead_tmp(tmp); } } break; case 13: op = ((insn >> 22) & 6) | ((insn >> 7) & 1); if (op < 4 && (insn & 0xf000) != 0xf000) goto illegal_op; switch (op) { case 0: tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((insn & 0x70) != 0) goto illegal_op; op = (insn >> 21) & 3; logic_cc = (insn & (1 << 20)) != 0; gen_arm_shift_reg(tmp, op, tmp2, logic_cc); if (logic_cc) gen_logic_CC(tmp); store_reg_bx(env, s, rd, tmp); break; case 1: tmp = load_reg(s, rm); shift = (insn >> 4) & 3; if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); op = (insn >> 20) & 7; switch (op) { case 0: gen_sxth(tmp); break; case 1: gen_uxth(tmp); break; case 2: gen_sxtb16(tmp); break; case 3: gen_uxtb16(tmp); break; case 4: gen_sxtb(tmp); break; case 5: gen_uxtb(tmp); break; default: goto illegal_op; } if (rn != 15) { tmp2 = load_reg(s, rn); if ((op >> 1) == 1) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); dead_tmp(tmp2); } } store_reg(s, rd, tmp); break; case 2: op = (insn >> 20) & 7; shift = (insn >> 4) & 7; if ((op & 3) == 3 || (shift & 3) == 3) goto illegal_op; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); gen_thumb2_parallel_addsub(op, shift, tmp, tmp2); dead_tmp(tmp2); store_reg(s, rd, tmp); break; case 3: op = ((insn >> 17) & 0x38) | ((insn >> 4) & 7); if (op < 4) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if (op & 1) gen_helper_double_saturate(tmp, tmp); if (op & 2) gen_helper_sub_saturate(tmp, tmp2, tmp); else gen_helper_add_saturate(tmp, tmp, tmp2); dead_tmp(tmp2); } else { tmp = load_reg(s, rn); switch (op) { case 0x0a: gen_helper_rbit(tmp, tmp); break; case 0x08: tcg_gen_bswap32_i32(tmp, tmp); break; case 0x09: gen_rev16(tmp); break; case 0x0b: gen_revsh(tmp); break; case 0x10: tmp2 = load_reg(s, rm); tmp3 = new_tmp(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); dead_tmp(tmp3); dead_tmp(tmp2); break; case 0x18: gen_helper_clz(tmp, tmp); break; default: goto illegal_op; } } store_reg(s, rd, tmp); break; case 4: case 5: op = (insn >> 4) & 0xf; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); switch ((insn >> 20) & 7) { case 0: tcg_gen_mul_i32(tmp, tmp, tmp2); dead_tmp(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); if (op) tcg_gen_sub_i32(tmp, tmp2, tmp); else tcg_gen_add_i32(tmp, tmp, tmp2); dead_tmp(tmp2); } break; case 1: gen_mulxy(tmp, tmp2, op & 2, op & 1); dead_tmp(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, tmp, tmp2); dead_tmp(tmp2); } break; case 2: case 4: if (op) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 22)) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } dead_tmp(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, tmp, tmp2); dead_tmp(tmp2); } break; case 3: if (op) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = new_tmp(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, tmp, tmp2); dead_tmp(tmp2); } break; case 5: case 6: tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rs != 15) { tmp = load_reg(s, rs); if (insn & (1 << 20)) { tmp64 = gen_addq_msw(tmp64, tmp); } else { tmp64 = gen_subq_msw(tmp64, tmp); } } if (insn & (1 << 4)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = new_tmp(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); break; case 7: gen_helper_usad8(tmp, tmp, tmp2); dead_tmp(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); tcg_gen_add_i32(tmp, tmp, tmp2); dead_tmp(tmp2); } break; } store_reg(s, rd, tmp); break; case 6: case 7: op = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70); tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((op & 0x50) == 0x10) { if (!arm_feature(env, ARM_FEATURE_DIV)) goto illegal_op; if (op & 0x20) gen_helper_udiv(tmp, tmp, tmp2); else gen_helper_sdiv(tmp, tmp, tmp2); dead_tmp(tmp2); store_reg(s, rd, tmp); } else if ((op & 0xe) == 0xc) { if (op & 1) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (op & 0x10) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } dead_tmp(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); dead_tmp(tmp); gen_addq(s, tmp64, rs, rd); gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (op & 0x20) { tmp64 = gen_mulu_i64_i32(tmp, tmp2); } else { if (op & 8) { gen_mulxy(tmp, tmp2, op & 2, op & 1); dead_tmp(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); dead_tmp(tmp); } else { tmp64 = gen_muls_i64_i32(tmp, tmp2); } } if (op & 4) { gen_addq_lo(s, tmp64, rs); gen_addq_lo(s, tmp64, rd); } else if (op & 0x40) { gen_addq(s, tmp64, rs, rd); } gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } break; } break; case 6: case 7: case 14: case 15: if (((insn >> 24) & 3) == 3) { insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4); if (disas_neon_data_insn(env, s, insn)) goto illegal_op; } else { if (insn & (1 << 28)) goto illegal_op; if (disas_coproc_insn (env, s, insn)) goto illegal_op; } break; case 8: case 9: case 10: case 11: if (insn & (1 << 15)) { if (insn & 0x5000) { offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff; offset |= (insn & 0x7ff) << 1; offset ^= ((~insn) & (1 << 13)) << 10; offset ^= ((~insn) & (1 << 11)) << 11; if (insn & (1 << 14)) { tcg_gen_movi_i32(cpu_R[14], s->pc | 1); } offset += s->pc; if (insn & (1 << 12)) { gen_jmp(s, offset); } else { offset &= ~(uint32_t)2; gen_bx_im(s, offset); } } else if (((insn >> 23) & 7) == 7) { if (insn & (1 << 13)) goto illegal_op; if (insn & (1 << 26)) { goto illegal_op; } else { op = (insn >> 20) & 7; switch (op) { case 0: if (IS_M(env)) { tmp = load_reg(s, rn); addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_msr(cpu_env, addr, tmp); tcg_temp_free_i32(addr); dead_tmp(tmp); gen_lookup_tb(s); break; } case 1: if (IS_M(env)) goto illegal_op; tmp = load_reg(s, rn); if (gen_set_psr(s, msr_mask(env, s, (insn >> 8) & 0xf, op == 1), op == 1, tmp)) goto illegal_op; break; case 2: if (((insn >> 8) & 7) == 0) { gen_nop_hint(s, insn & 0xff); } if (IS_USER(s)) break; offset = 0; imm = 0; if (insn & (1 << 10)) { if (insn & (1 << 7)) offset |= CPSR_A; if (insn & (1 << 6)) offset |= CPSR_I; if (insn & (1 << 5)) offset |= CPSR_F; if (insn & (1 << 9)) imm = CPSR_A | CPSR_I | CPSR_F; } if (insn & (1 << 8)) { offset |= 0x1f; imm |= (insn & 0x1f); } if (offset) { gen_set_psr_im(s, offset, 0, imm); } break; case 3: ARCH(7); op = (insn >> 4) & 0xf; switch (op) { case 2: gen_clrex(s); break; case 4: case 5: case 6: break; default: goto illegal_op; } break; case 4: tmp = load_reg(s, rn); gen_bx(s, tmp); break; case 5: if (IS_USER(s)) { goto illegal_op; } if (rn != 14 || rd != 15) { goto illegal_op; } tmp = load_reg(s, rn); tcg_gen_subi_i32(tmp, tmp, insn & 0xff); gen_exception_return(s, tmp); break; case 6: tmp = new_tmp(); if (IS_M(env)) { addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_mrs(tmp, cpu_env, addr); tcg_temp_free_i32(addr); } else { gen_helper_cpsr_read(tmp); } store_reg(s, rd, tmp); break; case 7: if (IS_USER(s) || IS_M(env)) goto illegal_op; tmp = load_cpu_field(spsr); store_reg(s, rd, tmp); break; } } } else { op = (insn >> 22) & 0xf; s->condlabel = gen_new_label(); gen_test_cc(op ^ 1, s->condlabel); s->condjmp = 1; offset = (insn & 0x7ff) << 1; offset |= (insn & 0x003f0000) >> 4; offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11; offset |= (insn & (1 << 13)) << 5; offset |= (insn & (1 << 11)) << 8; gen_jmp(s, s->pc + offset); } } else { if (insn & (1 << 25)) { if (insn & (1 << 24)) { if (insn & (1 << 20)) goto illegal_op; op = (insn >> 21) & 7; imm = insn & 0x1f; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); if (rn == 15) { tmp = new_tmp(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } switch (op) { case 2: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_sbfx(tmp, shift, imm); break; case 6: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_ubfx(tmp, shift, (1u << imm) - 1); break; case 3: if (imm < shift) goto illegal_op; imm = imm + 1 - shift; if (imm != 32) { tmp2 = load_reg(s, rd); gen_bfi(tmp, tmp2, tmp, shift, (1u << imm) - 1); dead_tmp(tmp2); } break; case 7: goto illegal_op; default: if (shift) { if (op & 1) tcg_gen_sari_i32(tmp, tmp, shift); else tcg_gen_shli_i32(tmp, tmp, shift); } tmp2 = tcg_const_i32(imm); if (op & 4) { if ((op & 1) && shift == 0) gen_helper_usat16(tmp, tmp, tmp2); else gen_helper_usat(tmp, tmp, tmp2); } else { if ((op & 1) && shift == 0) gen_helper_ssat16(tmp, tmp, tmp2); else gen_helper_ssat(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); break; } store_reg(s, rd, tmp); } else { imm = ((insn & 0x04000000) >> 15) | ((insn & 0x7000) >> 4) | (insn & 0xff); if (insn & (1 << 22)) { imm |= (insn >> 4) & 0xf000; if (insn & (1 << 23)) { tmp = load_reg(s, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, imm << 16); } else { tmp = new_tmp(); tcg_gen_movi_i32(tmp, imm); } } else { if (rn == 15) { offset = s->pc & ~(uint32_t)3; if (insn & (1 << 23)) offset -= imm; else offset += imm; tmp = new_tmp(); tcg_gen_movi_i32(tmp, offset); } else { tmp = load_reg(s, rn); if (insn & (1 << 23)) tcg_gen_subi_i32(tmp, tmp, imm); else tcg_gen_addi_i32(tmp, tmp, imm); } } store_reg(s, rd, tmp); } } else { int shifter_out = 0; shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12); imm = (insn & 0xff); switch (shift) { case 0: break; case 1: imm |= imm << 16; break; case 2: imm |= imm << 16; imm <<= 8; break; case 3: imm |= imm << 16; imm |= imm << 8; break; default: shift = (shift << 1) | (imm >> 7); imm |= 0x80; imm = imm << (32 - shift); shifter_out = 1; break; } tmp2 = new_tmp(); tcg_gen_movi_i32(tmp2, imm); rn = (insn >> 16) & 0xf; if (rn == 15) { tmp = new_tmp(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } op = (insn >> 21) & 0xf; if (gen_thumb2_data_op(s, op, (insn & (1 << 20)) != 0, shifter_out, tmp, tmp2)) goto illegal_op; dead_tmp(tmp2); rd = (insn >> 8) & 0xf; if (rd != 15) { store_reg(s, rd, tmp); } else { dead_tmp(tmp); } } } break; case 12: { int postinc = 0; int writeback = 0; int user; if ((insn & 0x01100000) == 0x01000000) { if (disas_neon_ls_insn(env, s, insn)) goto illegal_op; break; } user = IS_USER(s); if (rn == 15) { addr = new_tmp(); imm = s->pc & 0xfffffffc; if (insn & (1 << 23)) imm += insn & 0xfff; else imm -= insn & 0xfff; tcg_gen_movi_i32(addr, imm); } else { addr = load_reg(s, rn); if (insn & (1 << 23)) { imm = insn & 0xfff; tcg_gen_addi_i32(addr, addr, imm); } else { op = (insn >> 8) & 7; imm = insn & 0xff; switch (op) { case 0: case 8: shift = (insn >> 4) & 0xf; if (shift > 3) goto illegal_op; tmp = load_reg(s, rm); if (shift) tcg_gen_shli_i32(tmp, tmp, shift); tcg_gen_add_i32(addr, addr, tmp); dead_tmp(tmp); break; case 4: tcg_gen_addi_i32(addr, addr, -imm); break; case 6: tcg_gen_addi_i32(addr, addr, imm); user = 1; break; case 1: imm = -imm; case 3: postinc = 1; writeback = 1; break; case 5: imm = -imm; case 7: tcg_gen_addi_i32(addr, addr, imm); writeback = 1; break; default: goto illegal_op; } } } op = ((insn >> 21) & 3) | ((insn >> 22) & 4); if (insn & (1 << 20)) { if (rs == 15 && op != 2) { if (op & 2) goto illegal_op; } else { switch (op) { case 0: tmp = gen_ld8u(addr, user); break; case 4: tmp = gen_ld8s(addr, user); break; case 1: tmp = gen_ld16u(addr, user); break; case 5: tmp = gen_ld16s(addr, user); break; case 2: tmp = gen_ld32(addr, user); break; default: goto illegal_op; } if (rs == 15) { gen_bx(s, tmp); } else { store_reg(s, rs, tmp); } } } else { if (rs == 15) goto illegal_op; tmp = load_reg(s, rs); switch (op) { case 0: gen_st8(tmp, addr, user); break; case 1: gen_st16(tmp, addr, user); break; case 2: gen_st32(tmp, addr, user); break; default: goto illegal_op; } } if (postinc) tcg_gen_addi_i32(addr, addr, imm); if (writeback) { store_reg(s, rn, addr); } else { dead_tmp(addr); } } break; default: goto illegal_op; } return 0; illegal_op: return 1; }
1threat
justify-content isn't workin - flexbox problem : I am working on the following code: html: <div class="positiones"> <div class="mainheading"> <h1>The biggest startup event of the year!</h1><br> </div><br> </div> <div class="linebreak"></div><br> <div class="Button"> <button type="button" class="btn btn-primary btn-lg">Get more info</button><br> </div> </div> css: .positiones { display: flex; height: 100vh; align-items: center; justify-content: center; } as you can see, the justify-content property isn't working. well, I need some help, thank you:)
0debug
how to get attribute values from children (HTML) in XPath php : first i had looked for all the elements i need, now i am trying to get attributed values from the children- title, url and image- but getting errors all the time- please help , what am i doing wrong? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> function getContent($value) { $homepage = file_get_contents('https://www.youtube.com/results?search_query=' . $value); $doc = new DOMDocument(); libxml_use_internal_errors(TRUE); //disable libxml errors //check if any html is actually returned if (!empty($homepage)) { //load $doc->loadHTML($homepage); //remove errors for yucky HTML libxml_clear_errors(); //get DOMxPath $scriptXpath = new DOMXPath($doc); //get all the ytd-video-renderer's $scriptRows = $scriptXpath->query('//*[@class="item-section"]/li[position()>1]'); //get all the ytd-channel-renderer's // $scriptRow = $scriptXpath->query('//ytd-channel-renderer');//dont forget channels $videos = array(); foreach ($scriptRows as $scriptRow) { $VideoTitle = $scriptRow->{'/div/div/div/h3/a/@title'}; $VideoUrl = 'https://youtube.com' .$scriptRow->{'/div/div/div[2]/h3/a/@href'}; $VideoImg = $scriptRow->{'/div/div/div[1]/a/div/span/img/@src'}; // add to the end of a array of videos $videos[] = [ 'title' => $VideoTitle, 'url' => $VideoUrl, 'image' => $VideoImg, ]; } } <!-- end snippet -->
0debug
static bool ufd_version_check(int ufd) { struct uffdio_api api_struct; uint64_t ioctl_mask; api_struct.api = UFFD_API; api_struct.features = 0; if (ioctl(ufd, UFFDIO_API, &api_struct)) { error_report("postcopy_ram_supported_by_host: UFFDIO_API failed: %s", strerror(errno)); return false; } ioctl_mask = (__u64)1 << _UFFDIO_REGISTER | (__u64)1 << _UFFDIO_UNREGISTER; if ((api_struct.ioctls & ioctl_mask) != ioctl_mask) { error_report("Missing userfault features: %" PRIx64, (uint64_t)(~api_struct.ioctls & ioctl_mask)); return false; } if (getpagesize() != ram_pagesize_summary()) { bool have_hp = false; #ifdef UFFD_FEATURE_MISSING_HUGETLBFS have_hp = api_struct.features & UFFD_FEATURE_MISSING_HUGETLBFS; #endif if (!have_hp) { error_report("Userfault on this host does not support huge pages"); return false; } } return true; }
1threat
Replace string that contains dynamically numbers : <p>i have a variable that contains the string: attribute_value[XXX][] where XXX every time that page loads is a 3-digit number that changes every time.</p> <p>How can i use .replace function in javascript to replace attribute_value[XXX][] with something specific regardless the XXX value?</p> <p>Thank you in advance</p>
0debug
import re def text_match_two_three(text): patterns = 'ab{2,3}' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
0debug
static int encode_frame(AVCodecContext* avc_context, uint8_t *outbuf, int buf_size, void *data) { th_ycbcr_buffer t_yuv_buffer; TheoraContext *h = avc_context->priv_data; AVFrame *frame = data; ogg_packet o_packet; int result, i; if (!frame) { th_encode_packetout(h->t_state, 1, &o_packet); if (avc_context->flags & CODEC_FLAG_PASS1) if (get_stats(avc_context, 1)) return -1; return 0; } for (i = 0; i < 3; i++) { t_yuv_buffer[i].width = FFALIGN(avc_context->width, 16) >> (i && h->uv_hshift); t_yuv_buffer[i].height = FFALIGN(avc_context->height, 16) >> (i && h->uv_vshift); t_yuv_buffer[i].stride = frame->linesize[i]; t_yuv_buffer[i].data = frame->data[i]; } if (avc_context->flags & CODEC_FLAG_PASS2) if (submit_stats(avc_context)) return -1; result = th_encode_ycbcr_in(h->t_state, t_yuv_buffer); if (result) { const char* message; switch (result) { case -1: message = "differing frame sizes"; break; case TH_EINVAL: message = "encoder is not ready or is finished"; break; default: message = "unknown reason"; break; } av_log(avc_context, AV_LOG_ERROR, "theora_encode_YUVin failed (%s) [%d]\n", message, result); return -1; } if (avc_context->flags & CODEC_FLAG_PASS1) if (get_stats(avc_context, 0)) return -1; result = th_encode_packetout(h->t_state, 0, &o_packet); switch (result) { case 0: return 0; case 1: break; default: av_log(avc_context, AV_LOG_ERROR, "theora_encode_packetout failed [%d]\n", result); return -1; } if (buf_size < o_packet.bytes) { av_log(avc_context, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } memcpy(outbuf, o_packet.packet, o_packet.bytes); avc_context->coded_frame->pts = frame->pts; avc_context->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask); return o_packet.bytes; }
1threat
int kvm_arch_insert_hw_breakpoint(target_ulong addr, target_ulong len, int type) { switch (type) { case GDB_BREAKPOINT_HW: len = 1; break; case GDB_WATCHPOINT_WRITE: case GDB_WATCHPOINT_ACCESS: switch (len) { case 1: break; case 2: case 4: case 8: if (addr & (len - 1)) return -EINVAL; break; default: return -EINVAL; } break; default: return -ENOSYS; } if (nb_hw_breakpoint == 4) return -ENOBUFS; if (find_hw_breakpoint(addr, len, type) >= 0) return -EEXIST; hw_breakpoint[nb_hw_breakpoint].addr = addr; hw_breakpoint[nb_hw_breakpoint].len = len; hw_breakpoint[nb_hw_breakpoint].type = type; nb_hw_breakpoint++; return 0; }
1threat
static void virtex_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; hwaddr initrd_base = 0; int initrd_size = 0; MemoryRegion *address_space_mem = get_system_memory(); DeviceState *dev; PowerPCCPU *cpu; CPUPPCState *env; hwaddr ram_base = 0; DriveInfo *dinfo; MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32], *cpu_irq; int kernel_size; int i; if (cpu_model == NULL) { cpu_model = "440-Xilinx"; } cpu = ppc440_init_xilinx(&ram_size, 1, cpu_model, 400000000); env = &cpu->env; qemu_register_reset(main_cpu_reset, cpu); memory_region_allocate_system_memory(phys_ram, NULL, "ram", ram_size); memory_region_add_subregion(address_space_mem, ram_base, phys_ram); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi01_register(PFLASH_BASEADDR, NULL, "virtex.flash", FLASH_SIZE, dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL, (64 * 1024), FLASH_SIZE >> 16, 1, 0x89, 0x18, 0x0000, 0x0, 1); cpu_irq = (qemu_irq *) &env->irq_inputs[PPC40x_INPUT_INT]; dev = qdev_create(NULL, "xlnx.xps-intc"); qdev_prop_set_uint32(dev, "kind-of-intr", 0); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]); for (i = 0; i < 32; i++) { irq[i] = qdev_get_gpio_in(dev, i); } serial_mm_init(address_space_mem, UART16550_BASEADDR, 2, irq[UART16550_IRQ], 115200, serial_hds[0], DEVICE_LITTLE_ENDIAN); dev = qdev_create(NULL, "xlnx.xps-timer"); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 62 * 1000000); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]); if (kernel_filename) { uint64_t entry, low, high; hwaddr boot_offset; kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, &low, &high, 1, ELF_MACHINE, 0); boot_info.bootstrap_pc = entry & 0x00ffffff; if (kernel_size < 0) { boot_offset = 0x1200000; kernel_size = load_image_targphys(kernel_filename, boot_offset, ram_size); boot_info.bootstrap_pc = boot_offset; high = boot_info.bootstrap_pc + kernel_size + 8192; } boot_info.ima_size = kernel_size; if (machine->initrd_filename) { initrd_base = high = ROUND_UP(high, 4); initrd_size = load_image_targphys(machine->initrd_filename, high, ram_size - high); if (initrd_size < 0) { error_report("couldn't load ram disk '%s'", machine->initrd_filename); exit(1); } high = ROUND_UP(high + initrd_size, 4); } boot_info.fdt = high + (8192 * 2); boot_info.fdt &= ~8191; xilinx_load_device_tree(boot_info.fdt, ram_size, initrd_base, initrd_size, kernel_cmdline); } env->load_info = &boot_info; }
1threat
softusb_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistSoftUsbState *s = opaque; trace_milkymist_softusb_memory_write(addr, value); addr >>= 2; switch (addr) { case R_CTRL: s->regs[addr] = value; break; default: error_report("milkymist_softusb: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } }
1threat
date in format of 20190328 rather than 2019-03-28 in python : The files I need to move,have a pattern of date as 20190328.My datetime module gives me the date as 2019-03-28.how can I get the date in form 20190328?
0debug
Styled-components organization : <p>I want to use styled-components in my app and I am wondering how to organize it.</p> <p>Basically styled-components are assigned to specific component for reusability.</p> <p>But what about styled-components which I would like to use many times in other components (for example animations components)? Should I create a file where I will keep these 'global' styled-components and import it to many components?</p> <p>Is it good practice?</p>
0debug
How to search for string in an array using grep? : I have an array which contains some file names ,I'm trying to grep the particular file name which matches the string .. @arr=qw(INS.INPUT01.S7779902 INS.INPUT01.S7779903 INS.INPUT01.S7779904); $str = "7779902"; if (grep{$_=~ /$str/} @arr){ print $_; }
0debug
static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr, unsigned size) { VirtIOPCIProxy *proxy = opaque; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); uint64_t val = 0; if (addr < config) { return virtio_ioport_read(proxy, addr); } addr -= config; switch (size) { case 1: val = virtio_config_readb(vdev, addr); break; case 2: val = virtio_config_readw(vdev, addr); if (virtio_is_big_endian()) { val = bswap16(val); } break; case 4: val = virtio_config_readl(vdev, addr); if (virtio_is_big_endian()) { val = bswap32(val); } break; } return val; }
1threat
Unable to import svg files in typescript : <p>In <code>typescript(*.tsx)</code> files I cannot import svg file with this statement:</p> <pre><code>import logo from './logo.svg'; </code></pre> <p>Transpiler says:<code>[ts] cannot find module './logo.svg'.</code> My svg file is just <code>&lt;svg&gt;...&lt;/svg&gt;</code>.</p> <p>But in <code>.js</code> file I'm able to import it without any issues with exact the same import statement. I suppose it has something to do with type of svg file which must be set somehow for ts transpiler. </p> <p>Could you please share how to make this work in ts files?</p>
0debug
Changing the project name : <p>Is it possible changing the project name of a Flutter project? With project name I mean the name you provide when creating a flutter project <code>flutter create name</code>. </p>
0debug
JS parse string always as string and no number evaluation : <p>Example:</p> <pre><code>var garbage = JSON.parse('12345E666'); </code></pre> <p>=> infinity while </p> <pre><code>var garbage = JSON.parse('1234E300'); </code></pre> <p>=> 1.234e+303</p> <p>As you can see, this is rather rotten and definitely not what I want. </p> <p>The task at hand is to receive a string ... and it should remain as such. I have looked at JSON.stringify already, but this is also not what I want:</p> <p>=> "\"1234E300\"". Additional clean-up is required and it is always a mess to do this afterwards. </p> <p>JSON.parse accepts an additional parameter, but from what I have seen, this is also not elegant.</p> <pre><code>var garbage1 = JSON.parse('1234E300', function(key, value){return value;}); var garbage2 = JSON.parse('1234E300', function(key, value){return value;}); </code></pre> <p>Well ... see for yourself. It is rotten. </p> <p>How do I prevent JS to be smart and interpret something out of a string that it should not do? </p> <p>Input (String) => Output (Value) ... and no messing around with the data that should not be there.</p>
0debug
const char *qemu_get_version(void) { return qemu_version; }
1threat
In selenium,If Element is not exists then its takes alot of time to Execute next line of code : Iam Ravi ,Working as Automation Engineer using selenium, I have found one problem with selenium,If Element is not exists in the HTML page or DOM its take a lot of time to find that element more than 5 min after 5 mins its executes next line of code I want if that element not exists in the page it immediately go to the next line of code but it takes more time.In Some cases element exists in page so I did if element exist then come this code otherwise go to else code I have a lot of cases like these so it takes a lot of take to execute complete code,I tried with all possible ways like list ,try and Catch but unable to reduce time,Can you please give any solution for this in selenium. please give solution for that above problem. Thanks, Ravikiran.
0debug
SQL-SERVER 2012 - Select querries leap year : Leap year! Arghhhhhhhh. I have a little issue with one my SELECT querries. The entire query is actually is a little long since it includes a UNION ALL. SELECT 'ITV' = CASE WHEN tblIntake.StaffID Is Null THEN '<Unknown>' ELSE (tblStaffMember.StaffLast + ', ' + tblStaffMember.StaffFirst + CASE WHEN tblStaffMember.StaffMI Is Null THEN '' ELSE ' ' + tblStaffMember.StaffMI END) END, tblMember.[LAST], tblMember.[FIRST], 'DueDate' = DATEADD(m, 6,CAST(CONVERT(Varchar(10), MONTH(tblIntake.EnrollDate)) + '/' + CONVERT(Varchar(10), DAY(tblIntake.EnrollDate)) + '/' + CONVERT(Varchar(10),YEAR(GETDATE()))As DateTime)), 'Type' = '6 Month Appt' From tblIntake LEFT JOIN tblStaffMember ON tblIntake.StaffID = tblStaffMember.StaffID LEFT JOIN tblMember ON tblIntake.KEY = tblMember.KEY Where tblIntake.UnEnrollDate Is Null AND DATEADD(m,6,CAST(CONVERT(Varchar(10),MONTH(tblIntake.EnrollDate)) + '/' + CONVERT(Varchar(10),DAY(tblIntake.EnrollDate)) + '/' + CONVERT(Varchar(10),YEAR(GETDATE()))As DateTime)) > GETDATE() AND DATEADD(m, 6,CAST(CONVERT(Varchar(10),MONTH(tblIntake.EnrollDate)) + '/' + CONVERT(Varchar(10),DAY(tblIntake.EnrollDate)) + '/' + CONVERT(Varchar(10),YEAR(GETDATE()))As DateTime)) <= DATEADD(d, 45, GETDATE()) SO i have this wonderful query. Everything was running Okay until a user entered a leap year date for ENROLLDATE in tblIntake. How would I go about fixing it? My other UNION do the same SELECT statements with the exception of for when it does CONVERT(VARCHAR(10),YEAR(GetDate()-1)) as DateTime > '4th line from the bottom CONVERT(VARCHAR(10),YEAR(GetDate()-1)) as DateTime > '2nd line from the bottom
0debug
Statement requires expression of integer type ('double' invalid) - C++ : I have #include <iostream> #include <iomanip> using namespace std; int main () { double score; cout << fixed << setprecision(2) << "Enter your grade score and I will give you a letter grade \n"; cin >> score; if (score < 0 || score > 100) cout << "Enter a number less than 100 and greater than 0" << endl; switch (score) { case score > 90 : cout << score << "Grade: A"; case score > 80 || case score < 90 : cout << score << "Grade: B"; case score > 70 || case score < 80 : cout << score << "Grade: C"; case score > 60 || case score < 70 : cout << score << "Grade: D"; case score < 60 : cout << score << "Grade: F"; } } I kept getting > Statement requires expression of integer type ('double' invalid) _____ #Questions **How would one go about and debug this further ?** _______________ I'm open to any suggestions at this moment. Any hints/suggestions / helps on this be will be much appreciated!
0debug
Searchbox to URL in Javascript html [PLEASE READ, Is Possible : Okay, so I have this code <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <center> <font color="blue"> <h1 style="font-family:Comic Sans Ms;text-align="center";font-size:20pt; color:#00FF00;> Admin Login </h1> <script type="text/javascript"> function CheckPassword() { var username=document.login.username.value; var password=document.login.password.value; location.href = username + password+'.htm'; } </script> <form method="post" action="ingen_javascript.htm" onsubmit="CheckPassword();return false;" name="login"> <pre> Username: <input type="text" name="username"> Password: <input type="password" name="password"> </pre> <input type="submit" value="login" onclick="CheckPassword();return false;"> </form> <script language="javascript" text="javascript"> Mousetrap.bind("ctrl+u", function() { alert("Hello, World!"); }); </script> <script type="text/javascript"> if (document.addEventListener) { document.addEventListener('contextmenu', function(e) { alert("No"); //here you draw your own menu e.preventDefault(); }, false); } else { document.attachEvent('oncontextmenu', function() { alert("NO"); window.event.returnValue = false; }); } </script> <!-- end snippet --> and you can see that if you type anything on and click enter, it will come up with that in the URL. But how do I get rid of the password and just use the username but instead of 'Username:' it says 'vite:' and instead of 'login' it says 'go!' Please help me out with this, I know it's possible. I'd give you money if I could!
0debug
Login with ASP Identity fails every time with "Not Allowed" (even when 'email' and 'username' have the same value)) : <p>Registering a user works fine, as it logs in via this line:</p> <pre><code>await _signInManager.SignInAsync(user, isPersistent: model.RememberMe); </code></pre> <p>But if I want to log in with the same user again does not work (the Task Result always returned "Not Allowed").</p> <pre><code>var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: true); </code></pre> <p>I do realise that PasswordSignInAsync expects a USERNAME, not an EMAIL - but they are one and the same for my application.</p> <p>I have tried every variation of the log in methods, including checking if the user and passwords are correct (which all succeed), passing in the user object, altering the ViewModel property name, etc. </p> <p>Any ideas what needs to change?</p> <p>Similar issue for context: <a href="https://stackoverflow.com/questions/26430094/asp-net-identity-provider-signinmanager-keeps-returning-failure">ASP.NET Identity Provider SignInManager Keeps Returning Failure</a></p> <p>Thank you.</p>
0debug
Linked lists: Assigning values to a node? : <p>I'm not sure if I am even asking the right question (in reference to the question's title), but I am having trouble writing a statement that assigns the default values (in default) to the object pointed to by pNode? Thanks for any help anyone! </p> <pre><code>#include &lt;stdio.h&gt; #define SIZE 50 struct book { char title[SIZE], author[SIZE], year[5]; }; typedef struct book Item; typedef struct node { Item item; struct node * next; } Node; typedef Node * List; int main(void){ Node Node1, Node2; List pNode = &amp;Node2; Item Default = { "title", "author", "1950" }; //pNode -&gt; Item = Default;??? pNode -&gt; next = NULL; return 0; } </code></pre> <p>The comment is my sad failure of a statement that I have come up with.</p>
0debug
static void test_ivshmem_pair(void) { IVState state1, state2, *s1, *s2; char *data; int i; setup_vm(&state1); s1 = &state1; setup_vm(&state2); s2 = &state2; data = g_malloc0(TMPSHMSIZE); memset(tmpshmem, 0x42, TMPSHMSIZE); qtest_memread(s1->qtest, (uintptr_t)s1->mem_base, data, TMPSHMSIZE); for (i = 0; i < TMPSHMSIZE; i++) { g_assert_cmpuint(data[i], ==, 0x42); } qtest_memread(s2->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE); for (i = 0; i < TMPSHMSIZE; i++) { g_assert_cmpuint(data[i], ==, 0x42); } memset(data, 0x43, TMPSHMSIZE); qtest_memwrite(s1->qtest, (uintptr_t)s1->mem_base, data, TMPSHMSIZE); memset(data, 0, TMPSHMSIZE); qtest_memread(s2->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE); for (i = 0; i < TMPSHMSIZE; i++) { g_assert_cmpuint(data[i], ==, 0x43); } memset(data, 0x44, TMPSHMSIZE); qtest_memwrite(s2->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE); memset(data, 0, TMPSHMSIZE); qtest_memread(s1->qtest, (uintptr_t)s2->mem_base, data, TMPSHMSIZE); for (i = 0; i < TMPSHMSIZE; i++) { g_assert_cmpuint(data[i], ==, 0x44); } qtest_quit(s1->qtest); qtest_quit(s2->qtest); g_free(data); }
1threat
Explanation of one part of code c# : <p>I got c# project from my prof.(no i can't ask him) I understand all except marked part in this class. Can someone give me short explanation or link to answer, what that part of code actually do?</p> <pre><code>class AccessConnection { private OleDbConnection conn; public AccessConnection() { conn = new OleDbConnection(); conn.ConnectionString= @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Bata\Desktop\Izvestaj\praksa\praksa\Studenti.accdb"; } public void otvoriKonekciju() { conn.Open(); } public void zatvoriKonekciju() { conn.Close(); } /* This is part of code i don't understand public OleDbConnection Conn { get { return this.conn; } } */ } </code></pre>
0debug
float32 HELPER(ucf64_adds)(float32 a, float32 b, CPUUniCore32State *env) { return float32_add(a, b, &env->ucf64.fp_status); }
1threat
what is default qemu arm enviroment in qemu-arm-static? : <p>I tried qemu-arm-static in Ubuntu.</p> <p>In QEMU system, I type below for execution.</p> <pre><code># qemu-system-arm -M versatilepb -cpu .... </code></pre> <p>It means that we give the configuration(like versatilepb) to QEMU.</p> <p>Now, I install qemu-user-static. Then I execute qemu-arm-static using chroot.</p> <p>In that case, we don't give any configuration..</p> <p>what is the default configuration in qemu-arm-staic??</p> <p>I mean something like board name, cpu name ... Please help me.</p>
0debug
static int interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy) { int work[10]; int b = NBLOCKS - a; int i; for (i=0; i<30; i++) out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2; if (eval_refl(work, out, ractx)) { int_to_int16(out, ractx->lpc_coef[copyold]); return rescale_rms(ractx->lpc_refl_rms[copyold], energy); } else { return rescale_rms(rms(work), energy); } }
1threat
Why i get a 500 (Internal Server Error) when i'm trying to get Modules list in Extensions? : After developing my website in my local server, i upload it to the web host. When i try to display Modules list in Extensions I get this error (form the web host logs) : GET http://bamatco.com/dental/prod/admin/index.php?route=extension/extension/module&user_token=XXXXXXXXX 500 (Internal Server Error) (jquery-2.1.1.min.js:4) I used the 3.0.2.0 opencart version. Everything is ok on the local server. I tried to disable all the extensions, i uninstall a modifications that i had already installed (Frensh language pack), i disabled all the Events (in Extensions submenu), always nothing. it’s very urgent. Thanks.
0debug
BlockAIOCB *bdrv_aio_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BlockCompletionFunc *cb, void *opaque) { Coroutine *co; BlockAIOCBCoroutine *acb; trace_bdrv_aio_discard(bs, sector_num, nb_sectors, opaque); acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque); acb->need_bh = true; acb->req.error = -EINPROGRESS; acb->req.sector = sector_num; acb->req.nb_sectors = nb_sectors; co = qemu_coroutine_create(bdrv_aio_discard_co_entry); qemu_coroutine_enter(co, acb); bdrv_co_maybe_schedule_bh(acb); return &acb->common; }
1threat