problem
stringlengths
26
131k
labels
class label
2 classes
how to set DI of service di in micro phalcon application.when setting DI with sevices its not working.How to handle that application? : use Phalcon\Mvc\Micro; use Phalcon\DI\FactoryDefault; use Commonapi\App\Library\ApiServices as ApiServices; class Bootstrap { public function run($opt){ $app = new Micro(); foreach ($loaders as $service) { $function = 'init' . ucfirst($service); $this->{$function}($app); } $services = new ApiServices($this->di); $app->setDI($services->di); return $app->handle(); } //have loaded config,routes,loader by seperate functions
0debug
Using redux-form I'm losing focus after typing the first character : <p>I'm using <code>redux-form</code> and on blur validation. After I type the first character into an input element, it loses focus and I have to click in it again to continue typing. It only does this with the first character. Subsequent characters types remains focuses. Here's my basic sign in form example:</p> <pre><code>import React, { Component } from 'react'; import { connect } from 'react-redux'; import { Field, reduxForm } from 'redux-form'; import * as actions from '../actions/authActions'; require('../../styles/signin.scss'); class SignIn extends Component { handleFormSubmit({ email, password }) { this.props.signinUser({ email, password }, this.props.location); } renderAlert() { if (this.props.errorMessage) { return ( &lt;div className="alert alert-danger"&gt; {this.props.errorMessage} &lt;/div&gt; ); } else if (this.props.location.query.error) { return ( &lt;div className="alert alert-danger"&gt; Authorization required! &lt;/div&gt; ); } } render() { const { message, handleSubmit, prestine, reset, submitting } = this.props; const renderField = ({ input, label, type, meta: { touched, invalid, error } }) =&gt; ( &lt;div class={`form-group ${touched &amp;&amp; invalid ? 'has-error' : ''}`}&gt; &lt;label for={label} className="sr-only"&gt;{label}&lt;/label&gt; &lt;input {...input} placeholder={label} type={type} className="form-control" /&gt; &lt;div class="text-danger"&gt; {touched ? error: ''} &lt;/div&gt; &lt;/div&gt; ); return ( &lt;div className="row"&gt; &lt;div className="col-md-4 col-md-offset-4"&gt; &lt;form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))} className="form-signin"&gt; &lt;h2 className="form-signin-heading"&gt; Please sign in &lt;/h2&gt; {this.renderAlert()} &lt;Field name="email" type="text" component={renderField} label="Email Address" /&gt; &lt;Field name="password" type="password" component={renderField} label="Password" /&gt; &lt;button action="submit" className="btn btn-lg btn-primary btn-block"&gt;Sign In&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; ); } } function validate(values) { const errors = {}; if (!values.email) { errors.email = 'Enter a username'; } if (!values.password) { errors.password = 'Enter a password' } return errors; } function mapStateToProps(state) { return { errorMessage: state.auth.error } } SignIn = reduxForm({ form: 'signin', validate: validate })(SignIn); export default connect(mapStateToProps, actions)(SignIn); </code></pre>
0debug
static int nut_read_packet(AVFormatContext * avf, AVPacket * pkt) { NUTContext * priv = avf->priv_data; nut_packet_t pd; int ret; while ((ret = nut_read_next_packet(priv->nut, &pd)) < 0) av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret)); if (ret || av_new_packet(pkt, pd.len) < 0) return -1; if (pd.flags & NUT_FLAG_KEY) pkt->flags |= PKT_FLAG_KEY; pkt->pts = pd.pts; pkt->stream_index = pd.stream; pkt->pos = url_ftell(&avf->pb); ret = nut_read_frame(priv->nut, &pd.len, pkt->data); return ret; }
1threat
tqdm show progress for a generator I know the length of : <p>I'm looping over a large file that I know the length of, but am processing lazily since it's too large to fit in memory. I'd like to be able to use tqdm to keep track of my progress through the file, but since it can't get the total number of examples out of the generator I'm using, the only thing it shows is the estimated iterations/second. Is there any way to tell tqdm how many elements it's going to be looping over total so I can get some of the other statistics?</p>
0debug
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info) { int handle = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) handle = 1; } else { for (n = 0; n < 4; n++) if (arch_info->dr6 & (1 << n)) switch ((arch_info->dr7 >> (16 + n*4)) & 0x3) { case 0x0: handle = 1; break; case 0x1: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) handle = 1; if (!handle) kvm_update_guest_debug(cpu_single_env, (arch_info->exception == 1) ? KVM_GUESTDBG_INJECT_DB : KVM_GUESTDBG_INJECT_BP); return handle; }
1threat
int ff_fft_init(FFTContext *s, int nbits, int inverse) { int i, j, m, n; float alpha, c1, s1, s2; int shuffle = 0; int av_unused has_vectors; s->nbits = nbits; n = 1 << nbits; s->exptab = av_malloc((n / 2) * sizeof(FFTComplex)); if (!s->exptab) goto fail; s->revtab = av_malloc(n * sizeof(uint16_t)); if (!s->revtab) goto fail; s->inverse = inverse; s2 = inverse ? 1.0 : -1.0; for(i=0;i<(n/2);i++) { alpha = 2 * M_PI * (float)i / (float)n; c1 = cos(alpha); s1 = sin(alpha) * s2; s->exptab[i].re = c1; s->exptab[i].im = s1; } s->fft_calc = ff_fft_calc_c; s->imdct_calc = ff_imdct_calc; s->imdct_half = ff_imdct_half; s->exptab1 = NULL; #ifdef HAVE_MMX has_vectors = mm_support(); shuffle = 1; if (has_vectors & MM_3DNOWEXT) { s->imdct_calc = ff_imdct_calc_3dn2; s->fft_calc = ff_fft_calc_3dn2; } else if (has_vectors & MM_3DNOW) { s->fft_calc = ff_fft_calc_3dn; } else if (has_vectors & MM_SSE) { s->imdct_calc = ff_imdct_calc_sse; s->imdct_half = ff_imdct_half_sse; s->fft_calc = ff_fft_calc_sse; } else { shuffle = 0; } #elif defined HAVE_ALTIVEC && !defined ALTIVEC_USE_REFERENCE_C_CODE has_vectors = mm_support(); if (has_vectors & MM_ALTIVEC) { s->fft_calc = ff_fft_calc_altivec; shuffle = 1; } #endif if (shuffle) { int np, nblocks, np2, l; FFTComplex *q; np = 1 << nbits; nblocks = np >> 3; np2 = np >> 1; s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex)); if (!s->exptab1) goto fail; q = s->exptab1; do { for(l = 0; l < np2; l += 2 * nblocks) { *q++ = s->exptab[l]; *q++ = s->exptab[l + nblocks]; q->re = -s->exptab[l].im; q->im = s->exptab[l].re; q++; q->re = -s->exptab[l + nblocks].im; q->im = s->exptab[l + nblocks].re; q++; } nblocks = nblocks >> 1; } while (nblocks != 0); av_freep(&s->exptab); } for(i=0;i<n;i++) { m=0; for(j=0;j<nbits;j++) { m |= ((i >> j) & 1) << (nbits-j-1); } s->revtab[i]=m; } return 0; fail: av_freep(&s->revtab); av_freep(&s->exptab); av_freep(&s->exptab1); return -1; }
1threat
static int tosa_dac_send(I2CSlave *i2c, uint8_t data) { TosaDACState *s = TOSA_DAC(i2c); s->buf[s->len] = data; if (s->len ++ > 2) { #ifdef VERBOSE fprintf(stderr, "%s: message too long (%i bytes)\n", __FUNCTION__, s->len); #endif return 1; } if (s->len == 2) { fprintf(stderr, "dac: channel %d value 0x%02x\n", s->buf[0], s->buf[1]); } return 0; }
1threat
How can I concat multiple dataframes in Python? : <p>I have multiple (more than 100) dataframes. How can I concat all of them?</p> <p>The problem is, that I have too many dataframes, that I can not write them manually in a list, like this: </p> <pre><code>&gt;&gt;&gt; cluster_1 = pd.DataFrame([['a', 1], ['b', 2]], ... columns=['letter ', 'number']) &gt;&gt;&gt; cluster_1 letter number 0 a 1 1 b 2 &gt;&gt;&gt; cluster_2 = pd.DataFrame([['c', 3], ['d', 4]], ... columns=['letter', 'number']) &gt;&gt;&gt; cluster_2 letter number 0 c 3 1 d 4 &gt;&gt;&gt; pd.concat([cluster_1, cluster_2]) letter number 0 a 1 1 b 2 0 c 3 1 d 4 </code></pre> <p>The names of my N dataframes are cluster_1, cluster_2, cluster_3,..., cluster_N. The number N can be very high.</p> <p>How can I concat N dataframes?</p>
0debug
static void spr_write_decr (DisasContext *ctx, int sprn, int gprn) { if (use_icount) { gen_io_start(); } gen_helper_store_decr(cpu_env, cpu_gpr[gprn]); if (use_icount) { gen_io_end(); gen_stop_exception(ctx); } }
1threat
Dataset for predicting gender : <p>Can anyone guide me towards any dataset which consists of questions/survey based on psychology which when answered in full extent can tell you the gender if the person taking the test?</p> <p>I need it to create a tool through which we can detect the patterns of fake profiles on the social platforms.</p> <p>I know a few groups which are gender-specific (e.g. for mothers, for women private talk) but the opposite gender tries to trash it getting into the group pretending to be female.</p> <p>I know it sounds silly for now, but anyone who wants to join these group can go through the questionnaire and the AI can detect it's gender.</p> <p>Thank you in advance.</p>
0debug
NFC RFID in Web Application : <p>How can I connect NFC in web application? Should i use a plugin or applet to read NFC in web apps using php or javascript.</p> <p>I tried this one but it doesn't work.</p> <p><a href="https://www.youtube.com/watch?v=F5XOr30fQJE" rel="nofollow noreferrer">https://www.youtube.com/watch?v=F5XOr30fQJE</a></p>
0debug
from collections import Counter def check_occurences(test_list): res = dict(Counter(tuple(ele) for ele in map(sorted, test_list))) return (res)
0debug
Postman: Is it possible to customize the sequence of test runs in the collection runner : <p>I have several tests in my postman collection but some of them are dependent on few others from within the collection as the latter set some envt variables that are used by other tests. I want these to run in a sequence. The tests in my collection are distributed across different folders. Is there a possibility to define such a sequence in a test suite like structure? </p>
0debug
static int elf_core_dump(int signr, const CPUState *env) { const TaskState *ts = (const TaskState *)env->opaque; struct vm_area_struct *vma = NULL; char corefile[PATH_MAX]; struct elf_note_info info; struct elfhdr elf; struct elf_phdr phdr; struct rlimit dumpsize; struct mm_struct *mm = NULL; off_t offset = 0, data_offset = 0; int segs = 0; int fd = -1; errno = 0; getrlimit(RLIMIT_CORE, &dumpsize); if (dumpsize.rlim_cur == 0) return 0; if (core_dump_filename(ts, corefile, sizeof (corefile)) < 0) return (-errno); if ((fd = open(corefile, O_WRONLY | O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) return (-errno); if ((mm = vma_init()) == NULL) goto out; walk_memory_regions(mm, vma_walker); segs = vma_get_mapping_count(mm); fill_elf_header(&elf, segs + 1, ELF_MACHINE, 0); if (dump_write(fd, &elf, sizeof (elf)) != 0) goto out; if (fill_note_info(&info, signr, env) < 0) goto out; offset += sizeof (elf); offset += (segs + 1) * sizeof (struct elf_phdr); fill_elf_note_phdr(&phdr, info.notes_size, offset); offset += info.notes_size; if (dump_write(fd, &phdr, sizeof (phdr)) != 0) goto out; offset = roundup(offset, ELF_EXEC_PAGESIZE); for (vma = vma_first(mm); vma != NULL; vma = vma_next(vma)) { (void) memset(&phdr, 0, sizeof (phdr)); phdr.p_type = PT_LOAD; phdr.p_offset = offset; phdr.p_vaddr = vma->vma_start; phdr.p_paddr = 0; phdr.p_filesz = vma_dump_size(vma); offset += phdr.p_filesz; phdr.p_memsz = vma->vma_end - vma->vma_start; phdr.p_flags = vma->vma_flags & PROT_READ ? PF_R : 0; if (vma->vma_flags & PROT_WRITE) phdr.p_flags |= PF_W; if (vma->vma_flags & PROT_EXEC) phdr.p_flags |= PF_X; phdr.p_align = ELF_EXEC_PAGESIZE; dump_write(fd, &phdr, sizeof (phdr)); } if (write_note_info(&info, fd) < 0) goto out; data_offset = lseek(fd, 0, SEEK_CUR); data_offset = TARGET_PAGE_ALIGN(data_offset); if (lseek(fd, data_offset, SEEK_SET) != data_offset) goto out; for (vma = vma_first(mm); vma != NULL; vma = vma_next(vma)) { abi_ulong addr; abi_ulong end; end = vma->vma_start + vma_dump_size(vma); for (addr = vma->vma_start; addr < end; addr += TARGET_PAGE_SIZE) { char page[TARGET_PAGE_SIZE]; int error; error = copy_from_user(page, addr, sizeof (page)); if (error != 0) { (void) fprintf(stderr, "unable to dump " TARGET_ABI_FMT_lx "\n", addr); errno = -error; goto out; } if (dump_write(fd, page, TARGET_PAGE_SIZE) < 0) goto out; } } out: free_note_info(&info); if (mm != NULL) vma_delete(mm); (void) close(fd); if (errno != 0) return (-errno); return (0); }
1threat
Can You explain how it works? : It would be awesome if someone could give me a proper explanation of the code :) Code is working and I like it, however as I am learning Java, need to understand every bit of it. Thanks! Checked StringBuilder() - seems fine, However part inside the loop is not quite clear. public class SquareDigit { public int squareDigits(int n) { StringBuilder builder = new StringBuilder(); while(n > 0) { int digit = n % 10; int square = digit * digit; builder.insert(0, square); n = Math.floorDiv(n, 10); } return Integer.valueOf(builder.toString()); } }
0debug
int load_elf_as(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, int big_endian, int elf_machine, int clear_lsb, int data_swab, AddressSpace *as) { int fd, data_order, target_data_order, must_swab, ret = ELF_LOAD_FAILED; uint8_t e_ident[EI_NIDENT]; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { perror(filename); return -1; } if (read(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident)) goto fail; if (e_ident[0] != ELFMAG0 || e_ident[1] != ELFMAG1 || e_ident[2] != ELFMAG2 || e_ident[3] != ELFMAG3) { ret = ELF_LOAD_NOT_ELF; goto fail; } #ifdef HOST_WORDS_BIGENDIAN data_order = ELFDATA2MSB; #else data_order = ELFDATA2LSB; #endif must_swab = data_order != e_ident[EI_DATA]; if (big_endian) { target_data_order = ELFDATA2MSB; } else { target_data_order = ELFDATA2LSB; } if (target_data_order != e_ident[EI_DATA]) { ret = ELF_LOAD_WRONG_ENDIAN; goto fail; } lseek(fd, 0, SEEK_SET); if (e_ident[EI_CLASS] == ELFCLASS64) { ret = load_elf64(filename, fd, translate_fn, translate_opaque, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb, data_swab, as); } else { ret = load_elf32(filename, fd, translate_fn, translate_opaque, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb, data_swab, as); } fail: close(fd); return ret; }
1threat
void qmp_drive_mirror(const char *device, const char *target, bool has_format, const char *format, enum MirrorSyncMode sync, bool has_mode, enum NewImageMode mode, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, Error **errp) { BlockDriverState *bs; BlockDriverState *source, *target_bs; BlockDriver *proto_drv; BlockDriver *drv = NULL; Error *local_err = NULL; int flags; uint64_t size; int ret; if (!has_speed) { speed = 0; } if (!has_on_source_error) { on_source_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_on_target_error) { on_target_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_mode) { mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; } if (!has_granularity) { granularity = 0; } if (!has_buf_size) { buf_size = DEFAULT_MIRROR_BUF_SIZE; } if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) { error_set(errp, QERR_INVALID_PARAMETER, device); return; } if (granularity & (granularity - 1)) { error_set(errp, QERR_INVALID_PARAMETER, device); return; } bs = bdrv_find(device); if (!bs) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } if (!bdrv_is_inserted(bs)) { error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); return; } if (!has_format) { format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; } if (format) { drv = bdrv_find_format(format); if (!drv) { error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); return; } } if (bdrv_in_use(bs)) { error_set(errp, QERR_DEVICE_IN_USE, device); return; } flags = bs->open_flags | BDRV_O_RDWR; source = bs->backing_hd; if (!source && sync == MIRROR_SYNC_MODE_TOP) { sync = MIRROR_SYNC_MODE_FULL; } proto_drv = bdrv_find_protocol(target); if (!proto_drv) { error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); return; } bdrv_get_geometry(bs, &size); size *= 512; if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) { assert(format && drv); bdrv_img_create(target, format, NULL, NULL, NULL, size, flags, &local_err, false); } else { switch (mode) { case NEW_IMAGE_MODE_EXISTING: ret = 0; break; case NEW_IMAGE_MODE_ABSOLUTE_PATHS: bdrv_img_create(target, format, source->filename, source->drv->format_name, NULL, size, flags, &local_err, false); break; default: abort(); } } if (error_is_set(&local_err)) { error_propagate(errp, local_err); return; } target_bs = bdrv_new(""); ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv); if (ret < 0) { bdrv_delete(target_bs); error_setg_file_open(errp, -ret, target); return; } mirror_start(bs, target_bs, speed, granularity, buf_size, sync, on_source_error, on_target_error, block_job_cb, bs, &local_err); if (local_err != NULL) { bdrv_delete(target_bs); error_propagate(errp, local_err); return; } drive_get_ref(drive_get_by_blockdev(bs)); }
1threat
Improve quality of programmatically captured image in the android app : <p>I integrated camera in my application and using that camera the captured image is blur. Any suggestions for improving captured image quality. I am using multipart for sending image on server.</p> <blockquote> <p>Code Snippet</p> </blockquote> <pre><code>@Override public void openCameraAction() { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, CAMERA_REQUEST); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == Constants.CAMERA_REQUEST &amp;&amp; resultCode == Activity.RESULT_OK) { photo = (Bitmap) data.getExtras().get("data"); imageBase64 = encodeToBase64(photo); imageUri = getImageUri(getApplicationContext(), photo); imageFile = new File(getRealPathFromURI(imageUri)); getImageView.setImageBitmap(photo); RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"),imageFile); MultipartBody.Part image = MultipartBody.Part.createFormData(imageQuestionId, imageFile.getName(),requestBody); parts.add(image); } } public static String encodeToBase64(Bitmap image) { Bitmap immagex=image; ByteArrayOutputStream baos = new ByteArrayOutputStream(); immagex.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] b = baos.toByteArray(); String imageEncoded = Base64.encodeToString(b, Base64.DEFAULT); return imageEncoded; } public Uri getImageUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); return Uri.parse(path); } public String getRealPathFromURI(Uri uri) { Cursor cursor = getContentResolver().query(uri, null, null, null, null); cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); return cursor.getString(idx); } </code></pre>
0debug
How to get client IP address in a Firebase cloud function? : <p>When saving data to Firebase database with a Firebase cloud function, I'd like to also write the IP address where the request comes from.</p> <p>However, <code>req.connection.remoteAddress</code> always returns <code>::ffff:0.0.0.0</code>. Is there a way to get the actual IP address of the client that makes the request?</p>
0debug
past a object from php to javascript : i have a little bit probleme , i need to give a object at JS when a click on a button , but i don t know how to do here is my code php echo '<script>'; echo 'var monObjet = "'.json_encode($product).'";'; echo '<script>'; <button type="button" onclick="ShowModal(monObjet)" class="btn btn-info btn-lg" data-toggle="modal" >Open Modal</button>'; and this is my code JS function ShowModal(monObjet){ var monObjet = monObjet; alert(monObjet); $('#myModal').appendTo("body").modal("show"); // $('#NomProduit').text(monObjet); }; </script> thanks in advance
0debug
static int compare_floats(const float *a, const float *b, int len, float max_diff) { int i; for (i = 0; i < len; i++) { if (fabsf(a[i] - b[i]) > max_diff) { av_log(NULL, AV_LOG_ERROR, "%d: %- .12f - %- .12f = % .12g\n", i, a[i], b[i], a[i] - b[i]); return -1; } } return 0; }
1threat
Is it possible to restrict number to a certain range : <p>Since typescript 2.0 RC (or even beta?) it is possible to use number literal types, as in <code>type t = 1 | 2;</code>. Is it possible to restrict a type to a number range, e.g. 0-255, without writing out 256 numbers in the type?</p> <p>In my case, a library accepts color values for a palette from 0-255, and I'd prefer to only name a few but restrict it to 0-255:</p> <pre><code>const enum paletteColor { someColor = 25, someOtherColor = 133 } declare function libraryFunc(color: paletteColor | 0-255); //would need to use 0|1|2|... </code></pre>
0debug
int DCT_common_init(MpegEncContext *s) { int i; ff_put_pixels_clamped = s->dsp.put_pixels_clamped; ff_add_pixels_clamped = s->dsp.add_pixels_clamped; s->dct_unquantize_h263 = dct_unquantize_h263_c; s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_c; s->dct_unquantize_mpeg2 = dct_unquantize_mpeg2_c; s->dct_quantize= dct_quantize_c; if(s->avctx->dct_algo==FF_DCT_FASTINT) s->fdct = fdct_ifast; else s->fdct = ff_jpeg_fdct_islow; if(s->avctx->idct_algo==FF_IDCT_INT){ s->idct_put= ff_jref_idct_put; s->idct_add= ff_jref_idct_add; s->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; }else{ s->idct_put= simple_idct_put; s->idct_add= simple_idct_add; s->idct_permutation_type= FF_NO_IDCT_PERM; } #ifdef HAVE_MMX MPV_common_init_mmx(s); #endif #ifdef ARCH_ALPHA MPV_common_init_axp(s); #endif #ifdef HAVE_MLIB MPV_common_init_mlib(s); #endif #ifdef HAVE_MMI MPV_common_init_mmi(s); #endif #ifdef ARCH_ARMV4L MPV_common_init_armv4l(); #endif #ifdef ARCH_POWERPC MPV_common_init_ppc(s); #endif switch(s->idct_permutation_type){ case FF_NO_IDCT_PERM: for(i=0; i<64; i++) s->idct_permutation[i]= i; break; case FF_LIBMPEG2_IDCT_PERM: for(i=0; i<64; i++) s->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); break; case FF_SIMPLE_IDCT_PERM: for(i=0; i<64; i++) s->idct_permutation[i]= simple_mmx_permutation[i]; break; case FF_TRANSPOSE_IDCT_PERM: for(i=0; i<64; i++) s->idct_permutation[i]= ((i&7)<<3) | (i>>3); break; default: fprintf(stderr, "Internal error, IDCT permutation not set\n"); return -1; } ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct); ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct); ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan); ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan); return 0; }
1threat
Do we have any possibility to stop request in OkHttp Interceptor? : <p>In our app we met with one special case - if our <code>App.specialFlag == true</code>, we need stop any request from our code. And we think, that the best approach in this situation is include special <code>Interceptor</code> which will stop any our requests, something like this:</p> <pre><code>if (App.specialFlag) { // Somehow stop request } else { return chain.proceed(chain.request()); } </code></pre> <p>Also, we should note, that we use <code>RxJavaCallAdapterFactory</code> for wrapping responses into <code>Observable</code>s.</p> <p>But we don't see any methods for stopping request in OkHttp Interceptors. </p> <p>We came up with two ways to solve our issue:</p> <p>a) Create special <code>ApiService.class</code> for wrapping every request in our API like this:</p> <pre><code>public Observable&lt;User&gt; getUserDetails() { if (App.specialFlag) { return Observable.just(null); } return api.getUserDetails(); } </code></pre> <p>But we think that it is ugly and cumbersome solution.</p> <p>b) Throw a <code>RuntimeException</code> in Interceptor, then catch it in every place we use our API. </p> <p>The second solution is also not good, because we need to include a lot of <code>onErrorResumeNext</code> operators in our chains.</p> <p>May be someone knows, how to handle our situation in more 'clever' way?..</p> <p>Thanks in advance!</p>
0debug
static void ppc_spapr_reset(void) { memset(spapr->htab, 0, spapr->htab_size); qemu_devices_reset(); spapr_finalize_fdt(spapr, spapr->fdt_addr, spapr->rtas_addr, spapr->rtas_size); first_cpu->gpr[3] = spapr->fdt_addr; first_cpu->gpr[5] = 0; first_cpu->halted = 0; first_cpu->nip = spapr->entry_point; }
1threat
hasMany vs belongsToMany in laravel 5.x : <p>I'm curious why the Eloquent relationship for <code>hasMany</code> has a different signature than for <code>belongsToMany</code>. Specifically the custom join table name-- for a system where a given <code>Comment</code> belongs to many <code>Role</code>s, and a given <code>Role</code> would have many <code>Comment</code>s, I want to store the relationship in a table called <code>my_custom_join_table</code> and have the keys set up as <code>comment_key</code> and <code>role_key</code>.</p> <pre><code>return $this-&gt;belongsToMany('App\Role', 'my_custom_join_table', 'comment_key', 'role_key'); // works </code></pre> <p>But on the inverse, I can't define that custom table (at least the docs don't mention it):</p> <pre><code>return $this-&gt;hasMany('App\Comment', 'comment_key', 'role_key'); </code></pre> <p>If I have a <code>Role</code> object that <code>hasMany</code> <code>Comments</code>, but I use a non-standard table name to store that relationship, why can I use this non-standard table going one way but not the other?</p>
0debug
Vue computed property not working as expected : <p>I have a vue component with a computed property i use to produce a list, it works on an array grouped by first letter.. see </p> <p><a href="https://jsfiddle.net/c6gtj1hw/" rel="nofollow noreferrer">https://jsfiddle.net/c6gtj1hw/</a></p> <pre><code>if (details.length &gt; 0) { accum.push[curr]; } </code></pre> <p>the push to accumulator isnt working as i would have expected. Is there something obvious im missing?</p>
0debug
static int ra144_decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; static const uint8_t sizes[LPC_ORDER] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; unsigned int refl_rms[NBLOCKS]; int16_t block_coefs[NBLOCKS][LPC_ORDER]; unsigned int lpc_refl[LPC_ORDER]; int i, j; int ret; int16_t *samples; unsigned int energy; RA144Context *ractx = avctx->priv_data; GetBitContext gb; if (buf_size < FRAME_SIZE) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); *got_frame_ptr = 0; return AVERROR_INVALIDDATA; } frame->nb_samples = NBLOCKS * BLOCKSIZE; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; samples = (int16_t *)frame->data[0]; init_get_bits8(&gb, buf, FRAME_SIZE); for (i = 0; i < LPC_ORDER; i++) lpc_refl[i] = ff_lpc_refl_cb[i][get_bits(&gb, sizes[i])]; ff_eval_coefs(ractx->lpc_coef[0], lpc_refl); ractx->lpc_refl_rms[0] = ff_rms(lpc_refl); energy = ff_energy_tab[get_bits(&gb, 5)]; refl_rms[0] = ff_interp(ractx, block_coefs[0], 1, 1, ractx->old_energy); refl_rms[1] = ff_interp(ractx, block_coefs[1], 2, energy <= ractx->old_energy, ff_t_sqrt(energy*ractx->old_energy) >> 12); refl_rms[2] = ff_interp(ractx, block_coefs[2], 3, 0, energy); refl_rms[3] = ff_rescale_rms(ractx->lpc_refl_rms[0], energy); ff_int_to_int16(block_coefs[3], ractx->lpc_coef[0]); for (i=0; i < NBLOCKS; i++) { do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); for (j=0; j < BLOCKSIZE; j++) *samples++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2); } ractx->old_energy = energy; ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0]; FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); *got_frame_ptr = 1; return FRAME_SIZE; }
1threat
Why is the move-constructor of std::optional not deleted when T is not move-constructible? : <p>According to the standard, the copy-constructor of <code>std::optional&lt;T&gt;</code>:</p> <blockquote> <p>...shall be defined as deleted unless <code>is_copy_constructible_v&lt;T&gt;</code> is <code>true</code>.</p> </blockquote> <p>But the move-constructor of <code>std::optional&lt;T&gt;</code>:</p> <blockquote> <p>...shall not participate in overload resolution unless <code>is_move_constructible_v&lt;T&gt;</code> is <code>true</code>.</p> </blockquote> <p>As I <a href="https://stackoverflow.com/questions/14085620/why-do-c11-deleted-functions-participate-in-overload-resolution">understand deleted constructors</a>, the purpose of not-deleting the move-constructor of <code>std::optional&lt;T&gt;</code> would be to allow code like this:</p> <pre><code>std::optional&lt;X&gt; o1; std::optional&lt;X&gt; o2(std::move(o1)); </code></pre> <p>...to work relying on some conversion sequence - <code>o2</code> would be constructed by an object of type <code>A</code> that has been constructed using a <code>std::optional&lt;X&gt;&amp;&amp;</code> (correct me if I am wrong).</p> <p>But regarding the possible constructors of <code>std::optional</code>, I have a hard time figuring out one that could match this use case...</p> <p><strong>Why is the move-constructor of <code>std::optional&lt;T&gt;</code> simply not <em>deleted</em> if <code>T</code> is not move-constructible?</strong></p>
0debug
int tap_win32_init(VLANState *vlan, const char *model, const char *name, const char *ifname) { TAPState *s; s = qemu_mallocz(sizeof(TAPState)); if (!s) return -1; if (tap_win32_open(&s->handle, ifname) < 0) { printf("tap: Could not open '%s'\n", ifname); return -1; } s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: ifname=%s", ifname); qemu_add_wait_object(s->handle->tap_semaphore, tap_win32_send, s); return 0; }
1threat
what is the correct way to write this mysql query?? "SELECT SUM(buyingPrice-(buyingPrice*10/100))" : <p>what is the correct way to write this mysql query?? "SELECT SUM(buyingPrice-(buyingPrice*10/100))" I wanna get the calculation done by the query?? Is this even possible?? </p>
0debug
int ff_h264_frame_start(H264Context *h) { Picture *pic; int i, ret; const int pixel_shift = h->pixel_shift; int c[4] = { 1<<(h->sps.bit_depth_luma-1), 1<<(h->sps.bit_depth_chroma-1), 1<<(h->sps.bit_depth_chroma-1), -1 }; if (!ff_thread_can_start_frame(h->avctx)) { av_log(h->avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n"); return -1; } release_unused_pictures(h, 1); h->cur_pic_ptr = NULL; i = find_unused_picture(h); if (i < 0) { av_log(h->avctx, AV_LOG_ERROR, "no frame buffer available\n"); return i; } pic = &h->DPB[i]; pic->f.reference = h->droppable ? 0 : h->picture_structure; pic->f.coded_picture_number = h->coded_picture_number++; pic->field_picture = h->picture_structure != PICT_FRAME; pic->f.key_frame = 0; pic->sync = 0; pic->mmco_reset = 0; if ((ret = alloc_picture(h, pic)) < 0) return ret; if(!h->sync && !h->avctx->hwaccel && !(h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) avpriv_color_frame(&pic->f, c); h->cur_pic_ptr = pic; h->cur_pic = *h->cur_pic_ptr; h->cur_pic.f.extended_data = h->cur_pic.f.data; ff_er_frame_start(&h->er); assert(h->linesize && h->uvlinesize); for (i = 0; i < 16; i++) { h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->linesize * ((scan8[i] - scan8[0]) >> 3); h->block_offset[48 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->linesize * ((scan8[i] - scan8[0]) >> 3); } for (i = 0; i < 16; i++) { h->block_offset[16 + i] = h->block_offset[32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3); h->block_offset[48 + 16 + i] = h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3); } for (i = 0; i < h->slice_context_count; i++) if (h->thread_context[i]) { ret = alloc_scratch_buffers(h->thread_context[i], h->linesize); if (ret < 0) return ret; } memset(h->slice_table, -1, (h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table)); if (h->avctx->codec_id != AV_CODEC_ID_SVQ3) h->cur_pic_ptr->f.reference = 0; h->cur_pic_ptr->field_poc[0] = h->cur_pic_ptr->field_poc[1] = INT_MAX; h->next_output_pic = NULL; assert(h->cur_pic_ptr->long_ref == 0); return 0; }
1threat
PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem, hwaddr base) { DeviceState *dev; PXA2xxPCMCIAState *s; dev = qdev_create(NULL, TYPE_PXA2XX_PCMCIA); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); s = PXA2XX_PCMCIA(dev); if (base == 0x30000000) { s->slot.slot_string = "PXA PC Card Socket 1"; } else { s->slot.slot_string = "PXA PC Card Socket 0"; } qdev_init_nofail(dev); return s; }
1threat
Object.entries() alternative for Internet Explorer and ReactJS : <p>Well, I've been building a web application for a couple weeks now, and everything good. I got to the part that I had to test in Internet Explorer, and of all of the things that came up (all fixed except for one), Object.entries() is not supported.</p> <p>I've been doing some research and try to come up with a simple alternative, but no luck at all.</p> <p>To be more specific, I'm bringing an object from an API, to fill options for <code>&lt;select&gt;&lt;/select&gt;</code> fields I have to filter some information, just like this:</p> <pre><code>Object.entries(this.state.filterInfo.sectorId).map(this.eachOption) // Function eachOption = ([key, val], i) =&gt; { return( &lt;option value={val} key={i}&gt;{val}&lt;/option&gt; ); } </code></pre> <p>So everything works correctly except for Internet Explorer. The thing is that in this particular component I'm rendering over 30 <code>&lt;select&gt;&lt;/select&gt;</code> fields. IF there is a solution that doesn't require me to rebuild everything, it would be amazing.</p> <p>Is there a simple solution? A way around this?</p> <p>Thanks in advance.</p>
0debug
static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) { int rd = extract32(insn, 0, 5); int rn = extract32(insn, 5, 5); int rm = extract32(insn, 16, 5); int size = extract32(insn, 22, 2); bool is_u = extract32(insn, 29, 1); bool is_q = extract32(insn, 30, 1); TCGv_i64 tcg_op1 = tcg_temp_new_i64(); TCGv_i64 tcg_op2 = tcg_temp_new_i64(); TCGv_i64 tcg_res[2]; int pass; tcg_res[0] = tcg_temp_new_i64(); tcg_res[1] = tcg_temp_new_i64(); for (pass = 0; pass < (is_q ? 2 : 1); pass++) { read_vec_element(s, tcg_op1, rn, pass, MO_64); read_vec_element(s, tcg_op2, rm, pass, MO_64); if (!is_u) { switch (size) { case 0: tcg_gen_and_i64(tcg_res[pass], tcg_op1, tcg_op2); break; case 1: tcg_gen_andc_i64(tcg_res[pass], tcg_op1, tcg_op2); break; case 2: tcg_gen_or_i64(tcg_res[pass], tcg_op1, tcg_op2); break; case 3: tcg_gen_orc_i64(tcg_res[pass], tcg_op1, tcg_op2); break; } } else { if (size != 0) { read_vec_element(s, tcg_res[pass], rd, pass, MO_64); } switch (size) { case 0: tcg_gen_xor_i64(tcg_res[pass], tcg_op1, tcg_op2); break; case 1: tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_op2); tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_res[pass]); tcg_gen_xor_i64(tcg_res[pass], tcg_op2, tcg_op1); break; case 2: tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]); tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_op2); tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); break; case 3: tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]); tcg_gen_andc_i64(tcg_op1, tcg_op1, tcg_op2); tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); break; } } } write_vec_element(s, tcg_res[0], rd, 0, MO_64); if (!is_q) { tcg_gen_movi_i64(tcg_res[1], 0); } write_vec_element(s, tcg_res[1], rd, 1, MO_64); tcg_temp_free_i64(tcg_op1); tcg_temp_free_i64(tcg_op2); tcg_temp_free_i64(tcg_res[0]); tcg_temp_free_i64(tcg_res[1]); }
1threat
Calling functions inside Vue.js template : <p>My template:</p> <pre><code>&lt;template id="players-template" inline-template&gt; &lt;div v-for="player in players"&gt; &lt;div v-bind:class="{ 'row': ($index + 1) % 3 == 0 }"&gt; &lt;div class="player col-md-4"&gt; &lt;div class="panel panel-default"&gt; &lt;div class="panel-heading"&gt; &lt;h3 class="panel-title"&gt; &lt;a href="#"&gt;{{ player.username }}&lt;/a&gt; &lt;span class="small pull-right"&gt;{{ player.createdAt }}&lt;/span&gt; &lt;/h3&gt; &lt;/div&gt; &lt;div class="panel-body"&gt; &lt;img v-bind:src="player.avatar" alt="{{ player.username }}" class="img-circle center-block"&gt; &lt;/div&gt; &lt;div class="panel-footer"&gt; &lt;div class="btn-group btn-group-justified" role="group" aria-label="..."&gt; &lt;a href="#" class="btn btn-primary btn-success send-message" data-toggle="tooltip" data-placement="bottom" title="Wyślij wiadomość" v-bind:id="player.id" @click="createConversation(player.id)"&gt;&lt;span class="glyphicon glyphicon-envelope"&gt;&lt;/span&gt;&amp;nbsp;&lt;/a&gt; &lt;a href="#" class="btn btn-primary btn-info" data-toggle="tooltip" data-placement="bottom" title="Pokaż profil"&gt;&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt;&amp;nbsp;&lt;/a&gt; &lt;a href="#" class="btn btn-primary btn-primary" data-toggle="tooltip" data-placement="bottom" title="Zobacz szczegółowe informacje o poście"&gt;&lt;span class="glyphicon glyphicon-option-horizontal"&gt;&lt;/span&gt;&amp;nbsp;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/template&gt; </code></pre> <p>My script:</p> <pre><code>new Vue({ el: 'body', methods: { createConversation: function(id) { console.log("createConversation()"); console.log(id); } } }); </code></pre> <p>When the template is rendering i gets an error <code>[Vue warn]: v-on:click="createConversation" expects a function value, got undefined</code>. I don't know how to use methods inside a component template. If someone could help me I would appreciate is.</p>
0debug
where are rails inbuilt inbuilt and default method written in rails app? : Can any one explain me Where is "NoMethodError" function written in rails app. Please let me know where can i get all the rails inbuilt method and function list.
0debug
static av_cold int libgsm_close(AVCodecContext *avctx) { gsm_destroy(avctx->priv_data); avctx->priv_data = NULL; return 0; }
1threat
How to unit test express Router routes : <p>I'm new to Node and Express and I'm trying to unit test my routes/controllers. I've separated my routes from my controllers. How do I go about testing my routes?</p> <p><strong>config/express.js</strong></p> <pre><code> var app = express(); // middleware, etc var router = require('../app/router')(app); </code></pre> <p><strong>app/router/index.js</strong></p> <pre><code> module.exports = function(app) { app.use('/api/books', require('./routes/books')); }; </code></pre> <p><strong>app/router/routes/books.js</strong></p> <pre><code> var controller = require('../../api/controllers/books'); var express = require('express'); var router = express.Router(); router.get('/', controller.index); module.exports = router; </code></pre> <p><strong>app/api/controllers/books.js</strong></p> <pre><code>// this is just an example controller exports.index = function(req, res) { return res.status(200).json('ok'); }; </code></pre> <p><strong>app/tests/api/routes/books.test.js</strong></p> <pre><code> var chai = require('chai'); var should = chai.should(); var sinon = require('sinon'); describe('BookRoute', function() { }); </code></pre>
0debug
Typescript 2.0 and Webpack importing of HTML as string : <p>I'm trying to import a HTML file as string with the help of webpack (Currently using webpack because TypeScript 2.0 doesn't support async/await on non ES6 targets).</p> <p>The problem I have is, even if the html-loader version from github supports a config flag 'exportAsEs6Default' i don't get it to set correctly. Is there any way to set a loader options globally? Because if I add the html-loader to the loaders section in the config file the loader is called twice causing the content to be nested.</p> <hr> <p>I have the following definition file to support importing of HTML (like in the example on <a href="https://www.typescriptlang.org/docs/handbook/modules.html" rel="noreferrer">the modules documentation</a>)</p> <pre><code>declare module "html!*" { const content: string; export default content; } </code></pre> <p>The corresponsing import statement:</p> <pre><code>import templateString from "html!./Hello.html"; </code></pre> <p>The versions of the packages I use:</p> <pre><code>"babel-core": "^6.17.0", "babel-loader": "^6.2.5", "babel-preset-es2015": "^6.16.0", "html-loader": "git://github.com/webpack/html-loader.git#4633a1c00c86b78d119b7862c71b17dbf68d49de", "ts-loader": "^0.9.5", "typescript": "2.0.3", "webpack": "^1.13.2" </code></pre> <p>And the webpack config file</p> <pre><code>"use strict"; module.exports = { entry: "./WebApp/Hello.ts", output: { path: "./wwwroot/compiled", filename: "app.bundle.js" }, resolve: { extensions: ["", ".webpack.js", ".web.js", ".js", ".ts"] }, module: { loaders: [ { test: /\.ts$/, exclude: /node_modules/, loader: "babel-loader!ts-loader" }, { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" } ] } }; </code></pre>
0debug
What other ways to initialize(allocate memory) data members of class in c++ other than constructors? : <p>Suppose i don't have constructors what are the other way to initialize data members of class?? _init() methods? considering we have to allocate memory for data members. </p>
0debug
Can I use excel logic function "if" in DataTable or dataGridView? : <p>I have a program in VB.NET with a table which would like to run the excel logic function "if" to complete the third column:</p> <p>My code for DT and DGV</p> <pre><code>Dim DGV As New DataGridView Dim DT As New DataTable If DGV.ColumnCount &gt; 0 Then Try DT.Columns.Remove("Nº") DT.Columns.Remove("Q") DT.Columns.Remove("k") DT.Clear() Catch g As DataException Console.WriteLine("Exception Of type {0} occurred.", g.GetType().ToString()) End Try End If DGV.SetBounds(12, 120, 865, 460) Controls.Add(DGV) DT.Columns.Add("Nº", GetType(Int32)) DT.Columns.Add("Q", GetType(Double)) DT.Columns.Add("k", GetType(String)) For I = 1 To 100 DT.Rows.Add(I, I * 3) Next (I) Me.DGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader DGV.ReadOnly = True DGV.DataSource = DT </code></pre> <p>It's possible? Examples in C# also are accepts.</p> <p>Thanks!</p>
0debug
static int blk_connect(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); int pers, index, qflags; bool readonly = true; if (blkdev->directiosafe) { qflags = BDRV_O_NOCACHE | BDRV_O_NATIVE_AIO; } else { qflags = BDRV_O_CACHE_WB; } if (strcmp(blkdev->mode, "w") == 0) { qflags |= BDRV_O_RDWR; readonly = false; } if (blkdev->feature_discard) { qflags |= BDRV_O_UNMAP; } index = (blkdev->xendev.dev - 202 * 256) / 16; blkdev->dinfo = drive_get(IF_XEN, 0, index); if (!blkdev->dinfo) { Error *local_err = NULL; xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n"); blkdev->bs = bdrv_new(blkdev->dev, &local_err); if (local_err) { blkdev->bs = NULL; } if (blkdev->bs) { BlockDriver *drv = bdrv_find_whitelisted_format(blkdev->fileproto, readonly); if (bdrv_open(&blkdev->bs, blkdev->filename, NULL, NULL, qflags, drv, &local_err) != 0) { xen_be_printf(&blkdev->xendev, 0, "error: %s\n", error_get_pretty(local_err)); error_free(local_err); bdrv_unref(blkdev->bs); blkdev->bs = NULL; } } if (!blkdev->bs) { return -1; } } else { xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n"); blkdev->bs = blkdev->dinfo->bdrv; if (bdrv_is_read_only(blkdev->bs) && !readonly) { xen_be_printf(&blkdev->xendev, 0, "Unexpected read-only drive"); blkdev->bs = NULL; return -1; } bdrv_ref(blkdev->bs); } bdrv_attach_dev_nofail(blkdev->bs, blkdev); blkdev->file_size = bdrv_getlength(blkdev->bs); if (blkdev->file_size < 0) { xen_be_printf(&blkdev->xendev, 1, "bdrv_getlength: %d (%s) | drv %s\n", (int)blkdev->file_size, strerror(-blkdev->file_size), bdrv_get_format_name(blkdev->bs) ?: "-"); blkdev->file_size = 0; } xen_be_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\"," " size %" PRId64 " (%" PRId64 " MB)\n", blkdev->type, blkdev->fileproto, blkdev->filename, blkdev->file_size, blkdev->file_size >> 20); xenstore_write_be_int(&blkdev->xendev, "sector-size", blkdev->file_blk); xenstore_write_be_int64(&blkdev->xendev, "sectors", blkdev->file_size / blkdev->file_blk); if (xenstore_read_fe_int(&blkdev->xendev, "ring-ref", &blkdev->ring_ref) == -1) { return -1; } if (xenstore_read_fe_int(&blkdev->xendev, "event-channel", &blkdev->xendev.remote_port) == -1) { return -1; } if (xenstore_read_fe_int(&blkdev->xendev, "feature-persistent", &pers)) { blkdev->feature_persistent = FALSE; } else { blkdev->feature_persistent = !!pers; } blkdev->protocol = BLKIF_PROTOCOL_NATIVE; if (blkdev->xendev.protocol) { if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) { blkdev->protocol = BLKIF_PROTOCOL_X86_32; } if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) { blkdev->protocol = BLKIF_PROTOCOL_X86_64; } } blkdev->sring = xc_gnttab_map_grant_ref(blkdev->xendev.gnttabdev, blkdev->xendev.dom, blkdev->ring_ref, PROT_READ | PROT_WRITE); if (!blkdev->sring) { return -1; } blkdev->cnt_map++; switch (blkdev->protocol) { case BLKIF_PROTOCOL_NATIVE: { blkif_sring_t *sring_native = blkdev->sring; BACK_RING_INIT(&blkdev->rings.native, sring_native, XC_PAGE_SIZE); break; } case BLKIF_PROTOCOL_X86_32: { blkif_x86_32_sring_t *sring_x86_32 = blkdev->sring; BACK_RING_INIT(&blkdev->rings.x86_32_part, sring_x86_32, XC_PAGE_SIZE); break; } case BLKIF_PROTOCOL_X86_64: { blkif_x86_64_sring_t *sring_x86_64 = blkdev->sring; BACK_RING_INIT(&blkdev->rings.x86_64_part, sring_x86_64, XC_PAGE_SIZE); break; } } if (blkdev->feature_persistent) { blkdev->max_grants = max_requests * BLKIF_MAX_SEGMENTS_PER_REQUEST; blkdev->persistent_gnts = g_tree_new_full((GCompareDataFunc)int_cmp, NULL, NULL, (GDestroyNotify)destroy_grant); blkdev->persistent_gnt_count = 0; } xen_be_bind_evtchn(&blkdev->xendev); xen_be_printf(&blkdev->xendev, 1, "ok: proto %s, ring-ref %d, " "remote port %d, local port %d\n", blkdev->xendev.protocol, blkdev->ring_ref, blkdev->xendev.remote_port, blkdev->xendev.local_port); return 0; }
1threat
Please help me SELECT FORM WHERE in SQL code : [I have place table and I get photo field][1] And ..... [I have trip_half_day table][2] I want to result [enter image description here][3] [1]: https://i.stack.imgur.com/gteNj.jpg [2]: https://i.stack.imgur.com/RhiaQ.png [3]: https://i.stack.imgur.com/JqGvj.png This is some code `<?php include("connect.php"); $strSQL = "SELECT trip_id, b.photo AS trip1, c.photo AS trip2, d.photo AS trip3, e.photo AS trip4 , a.type FROM trip_half_day a, place b, place c ,place d, place e WHERE a.trip1 = b.place_id AND a.trip2 = c.place_id AND a.trip3 = d.place_id AND a.trip4 = e.place_id "; $objQuery = mysqli_query($connection,$strSQL); $intNumField = mysqli_num_fields($objQuery); $resultArray = array(); while($obResult = mysqli_fetch_array($objQuery)) { $arrCol = array(); for($i=0;$i<$intNumField;$i++) { $arrCol[mysqli_fetch_field_direct($objQuery,$i)->name] = $obResult[$i]; } array_push($resultArray,$arrCol); } mysqli_close($connection); echo json_encode($resultArray); ?>` How I fix it.
0debug
def perimeter(diameter,height) : return 2*(diameter+height)
0debug
static inline void RENAME(rgb2rgb_init)(void) { rgb15to16 = RENAME(rgb15to16); rgb15tobgr24 = RENAME(rgb15tobgr24); rgb15to32 = RENAME(rgb15to32); rgb16tobgr24 = RENAME(rgb16tobgr24); rgb16to32 = RENAME(rgb16to32); rgb16to15 = RENAME(rgb16to15); rgb24tobgr16 = RENAME(rgb24tobgr16); rgb24tobgr15 = RENAME(rgb24tobgr15); rgb24tobgr32 = RENAME(rgb24tobgr32); rgb32to16 = RENAME(rgb32to16); rgb32to15 = RENAME(rgb32to15); rgb32tobgr24 = RENAME(rgb32tobgr24); rgb24to15 = RENAME(rgb24to15); rgb24to16 = RENAME(rgb24to16); rgb24tobgr24 = RENAME(rgb24tobgr24); shuffle_bytes_2103 = RENAME(shuffle_bytes_2103); rgb32tobgr16 = RENAME(rgb32tobgr16); rgb32tobgr15 = RENAME(rgb32tobgr15); yv12toyuy2 = RENAME(yv12toyuy2); yv12touyvy = RENAME(yv12touyvy); yuv422ptoyuy2 = RENAME(yuv422ptoyuy2); yuv422ptouyvy = RENAME(yuv422ptouyvy); yuy2toyv12 = RENAME(yuy2toyv12); planar2x = RENAME(planar2x); rgb24toyv12 = RENAME(rgb24toyv12); interleaveBytes = RENAME(interleaveBytes); vu9_to_vu12 = RENAME(vu9_to_vu12); yvu9_to_yuy2 = RENAME(yvu9_to_yuy2); uyvytoyuv420 = RENAME(uyvytoyuv420); uyvytoyuv422 = RENAME(uyvytoyuv422); yuyvtoyuv420 = RENAME(yuyvtoyuv420); yuyvtoyuv422 = RENAME(yuyvtoyuv422); }
1threat
static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs) { BdrvDirtyBitmap *bitmap; uint64_t size = bdrv_nb_sectors(bs); QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) { if (bdrv_dirty_bitmap_frozen(bitmap)) { continue; } hbitmap_truncate(bitmap->bitmap, size); bitmap->size = size; } }
1threat
how to mock ngrx selector in a component : <p>In a component, we use a ngrx selector to retrieve different parts of the state.</p> <pre><code>public isListLoading$ = this.store.select(fromStore.getLoading); public users$ = this.store.select(fromStore.getUsers); </code></pre> <p>the <code>fromStore.method</code> is created using ngrx <code>createSelector</code> method. For example:</p> <pre><code>export const getState = createFeatureSelector&lt;UsersState&gt;('users'); export const getLoading = createSelector( getState, (state: UsersState) =&gt; state.loading ); </code></pre> <p>I use these observables in the template:</p> <pre><code>&lt;div class="loader" *ngIf="isLoading$ | async"&gt;&lt;/div&gt; &lt;ul class="userList"&gt; &lt;li class="userItem" *ngFor="let user of $users | async"&gt;{{user.name}}&lt;/li&gt; &lt;/div&gt; </code></pre> <p>I would like to write a test where i could do something like:</p> <pre><code>store.select.and.returnValue(someSubject) </code></pre> <p>to be able to change subject value and test the template of the component agains these values.</p> <p>The fact is we struggle to find a proper way to test that. How to write my "andReturn" method since the <code>select</code> method is called two times in my component, with two different methods (MemoizedSelector) as arguments?</p> <p>We don't want to use real selector and so mocking a state then using real selector seems not to be a proper unit test way (tests wouldn't be isolated and would use real methods to test a component behavior).</p>
0debug
Strange MYSQL behavior on TABLE CREATE : <p>The command: </p> <pre><code>CREATE TABLE IRdata (ego int, altr VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); </code></pre> <p>works, but </p> <pre><code>CREATE TABLE IRdata (ego int, alter VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); </code></pre> <p>does not. The only difference is the "e" in "alter" for the second column.</p> <p>I have the latest MySQL install on the Ubuntu repos, running Ubuntu 18.04. </p> <p>Any help is appreciated. </p> <p>Thanks!</p>
0debug
static void *bamboo_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base, target_phys_addr_t initrd_size, const char *kernel_cmdline) { void *fdt = NULL; #ifdef CONFIG_FDT uint32_t mem_reg_property[] = { 0, 0, ramsize }; char *filename; int fdt_size; int ret; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE); if (!filename) { goto out; } fdt = load_device_tree(filename, &fdt_size); qemu_free(filename); if (fdt == NULL) { goto out; } ret = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, sizeof(mem_reg_property)); if (ret < 0) fprintf(stderr, "couldn't set /memory/reg\n"); ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", initrd_base); if (ret < 0) fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", (initrd_base + initrd_size)); if (ret < 0) fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", kernel_cmdline); if (ret < 0) fprintf(stderr, "couldn't set /chosen/bootargs\n"); if (kvm_enabled()) kvmppc_fdt_update(fdt); cpu_physical_memory_write (addr, (void *)fdt, fdt_size); out: #endif return fdt; }
1threat
def check(string): if len(set(string).intersection("AEIOUaeiou"))>=5: return ('accepted') else: return ("not accepted")
0debug
Badly working Intent in my app : Hello Stackoverflow community! Recently, a strange error occured to me. It is with a button in my app. When i press it there is nothing happening. No errors, or crashes but also Intent is not functioning. The transition to DeleteAccountActivity is not happening. I don't know why is this happening. The intent which I am using is very simple(passes nothing). Please help me AccountSettingsActivity.java public class AccountSettingsActivity extends AppCompatActivity { private static final String TAG = "AccountSettingsActivity"; private static final int ACTIVITY_NUM = 4; private String user_id; private Context mContext; public SectionsStatePagerAdapter pagerAdapter; private ViewPager mViewPager; private RelativeLayout mRelativeLayout; private Button mDelete; User mUser; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_accountsettings); mContext = AccountSettingsActivity.this; Log.d(TAG, "onCreate: started."); mViewPager = (ViewPager) findViewById(R.id.viewpager_container); mRelativeLayout = (RelativeLayout) findViewById(R.id.relLayout1); mDelete = (Button) findViewById(R.id.btnDelete); User mUser = new User(); setupSettingsList(); setupBottomNavigationView(); setupFragments(); getIncomingIntent(); //setup the backarrow for navigating back to "ProfileActivity" ImageView backArrow = (ImageView) findViewById(R.id.backArrow); backArrow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "onClick: navigating back to 'ProfileActivity'"); finish(); mDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(mContext, DeleteAccountActivity.class); startActivity(intent); } }); } }); } private void deleteAccounts(){ /* DatabaseReference deleteUser = FirebaseDatabase.getInstance().getReference("users").child(user_id); DatabaseReference deleteUserPhotos = FirebaseDatabase.getInstance().getReference("user_photos").child(user_id); DatabaseReference deleteUserPhotoComments = FirebaseDatabase.getInstance().getReference("comments").child(user_id); deleteUser.removeValue(); deleteUserPhotos.removeValue(); deleteUserPhotoComments.removeValue();*/ // getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out); FirebaseDatabase.getInstance().getReference() .child(getString(R.string.dbname_users)) // .child(FirebaseAuth.getInstance().getCurrentUser().getUid()) .child(mUser.getUser_id()) .removeValue(); /* FirebaseDatabase.getInstance().getReference() .child(getString(R.string.dbname_followers)) .child(mUser.getUser_id()) .child(FirebaseAuth.getInstance().getCurrentUser().getUid()) .removeValue(); */ } private void getIncomingIntent(){ Intent intent = getIntent(); if(intent.hasExtra(getString(R.string.selected_image)) || intent.hasExtra(getString(R.string.selected_bitmap))){ //if there is an imageUrl attached as an extra, then it was chosen from the gallery/photo fragment Log.d(TAG, "getIncomingIntent: New incoming imgUrl"); if(intent.getStringExtra(getString(R.string.return_to_fragment)).equals(getString(R.string.edit_profile_fragment))){ if(intent.hasExtra(getString(R.string.selected_image))){ //set the new profile picture FirebaseMethods firebaseMethods = new FirebaseMethods(AccountSettingsActivity.this); firebaseMethods.uploadNewPhoto(getString(R.string.profile_photo), null, 0, intent.getStringExtra(getString(R.string.selected_image)), null); } else if(intent.hasExtra(getString(R.string.selected_bitmap))){ //set the new profile picture FirebaseMethods firebaseMethods = new FirebaseMethods(AccountSettingsActivity.this); firebaseMethods.uploadNewPhoto(getString(R.string.profile_photo), null, 0, null,(Bitmap) intent.getParcelableExtra(getString(R.string.selected_bitmap))); } } } if(intent.hasExtra(getString(R.string.calling_activity))){ Log.d(TAG, "getIncomingIntent: received incoming intent from " + getString(R.string.profile_activity)); setViewPager(pagerAdapter.getFragmentNumber(getString(R.string.edit_profile_fragment))); } } private void setupFragments(){ pagerAdapter = new SectionsStatePagerAdapter(getSupportFragmentManager()); pagerAdapter.addFragment(new EditProfileFragment(), getString(R.string.edit_profile_fragment)); //fragment 0 pagerAdapter.addFragment(new SignOutFragment(), getString(R.string.sign_out_fragment)); //fragment 1 // pagerAdapter.addFragment(new DeleteAccountFragment(), "Delete Account"); } public void setViewPager(int fragmentNumber){ mRelativeLayout.setVisibility(View.GONE); Log.d(TAG, "setViewPager: navigating to fragment #: " + fragmentNumber); mViewPager.setAdapter(pagerAdapter); mViewPager.setCurrentItem(fragmentNumber); } private void setupSettingsList(){ Log.d(TAG, "setupSettingsList: initializing 'Account Settings' list."); ListView listView = (ListView) findViewById(R.id.lvAccountSettings); ArrayList<String> options = new ArrayList<>(); options.add(getString(R.string.edit_profile_fragment)); //fragment 0 options.add(getString(R.string.sign_out_fragment)); //fragement 1 // options.add("Delete Account"); ArrayAdapter adapter = new ArrayAdapter(mContext, android.R.layout.simple_list_item_1, options); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d(TAG, "onItemClick: navigating to fragment#: " + position); setViewPager(position); } }); } /** * BottomNavigationView setup */ private void setupBottomNavigationView(){ Log.d(TAG, "setupBottomNavigationView: setting up BottomNavigationView"); BottomNavigationViewEx bottomNavigationViewEx = (BottomNavigationViewEx) findViewById(R.id.bottomNavViewBar); BottomNavigationViewHelper.setupBottomNavigationView(bottomNavigationViewEx); BottomNavigationViewHelper.enableNavigation(mContext, this,bottomNavigationViewEx); Menu menu = bottomNavigationViewEx.getMenu(); MenuItem menuItem = menu.getItem(ACTIVITY_NUM); menuItem.setChecked(true); } } DeleteAccountActivity.java public class DeleteAccountActivity extends AppCompatActivity { Button yesButton; Button cancelButton; Context mContext; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); setContentView(R.layout.activity_delete_account); yesButton = (Button) findViewById(R.id.btnDelete2); cancelButton = (Button) findViewById(R.id.btnDelete3); yesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deleteAllData(); Intent intent = new Intent(mContext, RegisterActivity.class); startActivity(intent); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, AccountSettingsActivity.class); } }); } public void deleteAllData(){ DatabaseReference deleteUser = FirebaseDatabase.getInstance().getReference() .child("users") .child(FirebaseAuth.getInstance().getCurrentUser().getUid()); DatabaseReference deleteUserPhotos = FirebaseDatabase.getInstance().getReference() .child("user_photos") .child(FirebaseAuth.getInstance().getCurrentUser().getUid()); DatabaseReference deleteUserPhotoComments = FirebaseDatabase.getInstance().getReference() .child("user_account_settings") .child(FirebaseAuth.getInstance().getCurrentUser().getUid()); DatabaseReference deleteUserFollowing = FirebaseDatabase.getInstance().getReference() .child("following") .child(FirebaseAuth.getInstance().getCurrentUser().getUid()); DatabaseReference deleteUserFollowers = FirebaseDatabase.getInstance().getReference() .child("followers") .child(FirebaseAuth.getInstance().getCurrentUser().getUid()); deleteUser.removeValue(); deleteUserPhotos.removeValue(); deleteUserPhotoComments.removeValue(); deleteUserFollowing.removeValue(); deleteUserFollowers.removeValue(); } }
0debug
void palette8tobgr24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) { unsigned i; for(i=0; i<num_pixels; i++) { dst[0]= palette[ src[i]*4+0 ]; dst[1]= palette[ src[i]*4+1 ]; dst[2]= palette[ src[i]*4+2 ]; dst+= 3; } }
1threat
TensorFlow: questions regarding tf.argmax() and tf.equal() : <p>I am learning the TensorFlow, building a multilayer_perceptron model. I am looking into some examples like the one at: <a href="https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/multilayer_perceptron.ipynb" rel="noreferrer">https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/multilayer_perceptron.ipynb</a></p> <p>I then have some questions in the code below:</p> <pre><code>def multilayer_perceptron(x, weights, biases): : : pred = multilayer_perceptron(x, weights, biases) : : with tf.Session() as sess: sess.run(init) : correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) print ("Accuracy:", accuracy.eval({x: X_test, y: y_test_onehot})) </code></pre> <p>I am wondering what do <code>tf.argmax(prod,1)</code> and <code>tf.argmax(y,1)</code> mean and return (type and value) exactly? And is <code>correct_prediction</code> a variable instead of real values?</p> <p>Finally, how do we get the <code>y_test_prediction</code> array (the prediction result when the input data is <code>X_test</code>) from the tf session? Thanks a lot!</p>
0debug
PHP trim doesn't work in my case : <p>I have the next situation:</p> <pre><code>$a = ' 0226 '; </code></pre> <p>I'm trying to remove whitespaces from the beginning and end of the string:</p> <pre><code>print_r(trim($a)); </code></pre> <p>and expected output is:</p> <pre><code>'0226' </code></pre> <p>Here are results of <code>var_dump</code> and <code>urlencode</code> of above string:</p> <pre><code>print_r(urlencode($a)); // %C2%A0+0226+%C2%A0 var_dump($a) // &lt;pre class='xdebug-var-dump' dir='ltr'&gt;&lt;small&gt;string&lt;/small&gt; &lt;font color='#cc0000'&gt;'  0226  '&lt;/font&gt; &lt;i&gt;(length=10)&lt;/i&gt; &lt;/pre&gt; </code></pre>
0debug
Get month dates and name of days : <p>I want to get the name of the day and the dates of the current month. Can anyone help ?</p> <p>I want in respective format.</p> <pre><code>Date Day 2018-04-01 Sunday 2018-04-02 Monday 2018-04-03 Tuesday . . . . . . . 2018-04-30 Monday </code></pre>
0debug
Can anyone please help on this?I dont know why i am getting SQL Error: ORA-00001: unique constraint (RO_MARGE_TABLE_PK) violated : insert into RO_MARGE_TABLE ( PROMOTION_OFFER_ID, PROMOTION_CODE, SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, APPLICATION_ID, DL_SERVICE_CODE, DL_UPDATE_STAMP, SPEED, PREMIUM_TIERS, PACKAGE_TYPE, EFFECTIVE_DATE, EXPIRATION_DATE, PROMOTION_AMOUNT) select PROMOTION_OFFER_ID, DECODE(PROMOTION_CODE,NULL,NULL,NVL(RTRIM(PROMOTION_CODE),' ')), SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, DECODE(APPLICATION_ID,NULL,NULL,NVL(RTRIM(APPLICATION_ID),' ')), DECODE(DL_SERVICE_CODE,NULL,NULL,NVL(RTRIM(DL_SERVICE_CODE),' ')), DL_UPDATE_STAMP, DECODE(SPEED,NULL,NULL,NVL(RTRIM(SPEED),' ')), DECODE(PREMIUM_TIERS,NULL,NULL,NVL(RTRIM(PREMIUM_TIERS),' ')), DECODE(PACKAGE_TYPE,NULL,NULL,NVL(RTRIM(PACKAGE_TYPE),' ')), EFFECTIVE_DATE, EXPIRATION_DATE, PROMOTION_AMOUNT FROM SCHEMT098.MARGE_TABLE@DBLINK865;
0debug
static void handle_port_owner_write(EHCIState *s, int port, uint32_t owner) { USBDevice *dev = s->ports[port].dev; uint32_t *portsc = &s->portsc[port]; uint32_t orig; if (s->companion_ports[port] == NULL) return; owner = owner & PORTSC_POWNER; orig = *portsc & PORTSC_POWNER; if (!(owner ^ orig)) { return; } if (dev) { usb_attach(&s->ports[port], NULL); } *portsc &= ~PORTSC_POWNER; *portsc |= owner; if (dev) { usb_attach(&s->ports[port], dev); } }
1threat
whick keyword can be used to replace "FROM" in sql? : I am trying to bypass a waf ,and whick keyword can be used to replace "FROM" in sql ?
0debug
How to diable a link from a widget from another site : How do I disable the link associated with the widget I added to my website? I don't have access to anything other than the implement HTML code they provided. An example would be the Trustpilot widget at the bottom of the page in the link. If you click on the widget it takes you to Trustpilots website, but we don't want that to happen. https://goldsilver.com/
0debug
int64_t HELPER(nabs_i64)(int64_t val) { if (val < 0) { return val; } else { return -val; } }
1threat
void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) { if (backing_hd) { bdrv_ref(backing_hd); } if (bs->backing) { assert(bs->backing_blocker); bdrv_op_unblock_all(bs->backing->bs, bs->backing_blocker); bdrv_unref_child(bs, bs->backing); } else if (backing_hd) { error_setg(&bs->backing_blocker, "node is used as backing hd of '%s'", bdrv_get_device_or_node_name(bs)); } if (!backing_hd) { error_free(bs->backing_blocker); bs->backing_blocker = NULL; bs->backing = NULL; goto out; } bs->backing = bdrv_attach_child(bs, backing_hd, &child_backing); bs->open_flags &= ~BDRV_O_NO_BACKING; pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_hd->drv ? backing_hd->drv->format_name : ""); bdrv_op_block_all(backing_hd, bs->backing_blocker); bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET, bs->backing_blocker); out: bdrv_refresh_limits(bs, NULL); }
1threat
Server requirements for a database with 150,000 records : <p>I'm developing an application based on Laravel framework. Although the project is pretty simple, it'll contain a lot of data. I've never in my whole life managed a server with that amount.</p> <p>Perhaps for some of you 150,000 records is nothing, but for me it's a new thing.</p> <p>It'll probably never go higher than 150,000.</p> <p>So I have a few questions:</p> <ol> <li>Is 150,000 too much or servers can handle that amount of data?</li> <li>Should I worry about optimize everything or I am getting ahead of myself here?</li> <li>What's your guess on server requirements?</li> </ol> <p>Thank guys!</p>
0debug
start rule: <select from navigator or grammar> in antlr plugin in IntelliJ : <p>I have created simple grammar file in IntelliJ but failing to see any effect of Antlr plugin. When I open file in ANTLR preview, it says </p> <pre><code>start rule: &lt;select from navigator or grammar&gt; </code></pre> <p><a href="https://i.stack.imgur.com/3vMgl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3vMgl.png" alt="enter image description here"></a></p> <p>What is start rule? How to select it from navigator? How to select it from grammar?</p>
0debug
I can not access my sql server connection : [enter image description here][1] [1]: http://i.stack.imgur.com/AXcoe.jpg TITLE: Connect to Server ------------------------------ Cannot connect to DELL\SQLEXPRESS. ------------------------------ ADDITIONAL INFORMATION: A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=233&LinkId=20476 ------------------------------ No process is on the other end of the pipe ------------------------------ BUTTONS: OK ------------------------------
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
How to run multiple calculations at once using python? : <p>I have recently started using python and to try learn I have set a task of being able to run two chunks of code at once. I have 1 chunk of code to generate and append prime numbers into a list</p> <pre><code>primes=[] for num in range(1,999999999999 + 1): if num &gt; 1: for i in range(2,num): if (num % i) == 0: break else: primes.append(num) </code></pre> <p>And another chunk of code to use the prime numbers generates to find perfect numbers</p> <pre><code>limit = 25000000000000000000 for p in primes(): pp = 2**p perfect = (pp - 1) * (pp // 2) if perfect &gt; limit: break elif is_prime(pp - 1): print(perfect) </code></pre> <p>I have heard of something to do with importing thread or something along those lines but I am very confused by it, if anyone can help by giving me clear instructions on what to do that would be very appreciated. I have only been learning python for about a week now. </p> <p><em>Final note, I didn't code these calculations myself but I have modified them to what I need them for</em> </p>
0debug
In Django, how can I prevent a "Save with update_fields did not affect any rows." error? : <p>I'm using Django and Python 3.7. I have this code</p> <pre><code>article = get_article(id) ... article.label = label article.save(update_fields=["label"]) </code></pre> <p>Sometimes I get the following error on my "save" line ...</p> <pre><code> raise DatabaseError("Save with update_fields did not affect any rows.") django.db.utils.DatabaseError: Save with update_fields did not affect any rows. </code></pre> <p>Evidently, in the "..." another thread may be deleting my article. Is there another way to rewrite my "article.save(...)" statement such that if the object no longer exists I can ignore any error being thrown?</p>
0debug
how to tell if two dates are in the same day? : <p>I am using the moment npm module. I am comparing two dates and want to see if there in the same day.</p> <p>Is there a clean way of doing that using the moment package or using straight javascript or typescript?</p>
0debug
How do I check if the following items are in the a list? : <p>I need to check if list f is inside bolsa. Then, i should add f in carteira_acoes.</p> <pre><code>bolsa = {"ibm": 100.0, "google": 200.0, "microsoft": 100.0, "x": 40.0} carteira_acoes = [["ibm",10],["google",20]] f = ["x", 40] if (f[0]) in bolsa.items(): carteira_acoes.append(f) print (carteira_acoes) </code></pre>
0debug
void bdrv_drain_all_end(void) { BlockDriverState *bs; BdrvNextIterator it; BlockJob *job = NULL; for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); aio_enable_external(aio_context); bdrv_io_unplugged_end(bs); bdrv_parent_drained_end(bs); aio_context_release(aio_context); } while ((job = block_job_next(job))) { AioContext *aio_context = blk_get_aio_context(job->blk); aio_context_acquire(aio_context); block_job_resume(job); aio_context_release(aio_context); } }
1threat
static int init(AVFilterContext *ctx, const char *args) { EvalContext *eval = ctx->priv; char *args1 = av_strdup(eval->exprs); char *expr, *buf; int ret, i; if (!args1) { av_log(ctx, AV_LOG_ERROR, "Channels expressions list is empty\n"); ret = args ? AVERROR(ENOMEM) : AVERROR(EINVAL); goto end; } buf = args1; i = 0; while (i < FF_ARRAY_ELEMS(eval->expr) && (expr = av_strtok(buf, "|", &buf))) { ret = av_expr_parse(&eval->expr[i], expr, var_names, NULL, NULL, NULL, NULL, 0, ctx); if (ret < 0) goto end; i++; } eval->nb_channels = i; if (eval->chlayout_str) { int n; ret = ff_parse_channel_layout(&eval->chlayout, eval->chlayout_str, ctx); if (ret < 0) goto end; n = av_get_channel_layout_nb_channels(eval->chlayout); if (n != eval->nb_channels) { av_log(ctx, AV_LOG_ERROR, "Mismatch between the specified number of channels '%d' " "and the number of channels '%d' in the specified channel layout '%s'\n", eval->nb_channels, n, eval->chlayout_str); ret = AVERROR(EINVAL); goto end; } } else { eval->chlayout = av_get_default_channel_layout(eval->nb_channels); if (!eval->chlayout) { av_log(ctx, AV_LOG_ERROR, "Invalid number of channels '%d' provided\n", eval->nb_channels); ret = AVERROR(EINVAL); goto end; } } if ((ret = ff_parse_sample_rate(&eval->sample_rate, eval->sample_rate_str, ctx))) goto end; eval->duration = -1; if (eval->duration_str) { int64_t us = -1; if ((ret = av_parse_time(&us, eval->duration_str, 1)) < 0) { av_log(ctx, AV_LOG_ERROR, "Invalid duration: '%s'\n", eval->duration_str); goto end; } eval->duration = (double)us / 1000000; } eval->n = 0; end: av_free(args1); return ret; }
1threat
Coding algorithms that go back to certain steps if condition fails in R : <p>I'm a beginner to programming and I want to code an algorithm that goes back to certain places in the algorithm if a condition fails. So for instance, if I have an algorithm like:</p> <ol> <li>Do something here</li> <li>Check condition 1, else go back to 1.</li> <li>Do something here</li> <li>Check condition 2, else go back to 3.</li> </ol> <p>How do I go about coding a step 4 where if it fails I don't just completely start again but go back to a previous point of the function/algorithm?</p> <p>Many thanks for any help! Ryan</p>
0debug
Problema manipulando arrays no JSON e PHP : Tenho esses dados em um JSON: "sentences_tone": [ { "sentence_id": 0, "text": "I hate these new features On #ThisPhone after the update.", "tones": [ { "score": 0.637279, "tone_id": "anger", "tone_name": "Anger" } ] },... O problema que na hora de mostrar os resultado em PHP, aparece o erro: <br/> valor: 0.931034 <br/> sentimento: Raiva <br/> texto: It’s just inexcusable. <br/> Notice: Undefined offset: 2 in /Applications/XAMPP/xamppfiles/htdocs/toneAnalyzer/test.php on line 28 <br/><br/> O código é: > $result=curl_exec ($ch); > curl_close ($ch); >> $jsonObj = json_decode($result, true);<br/> >> $i = 0; <br/> foreach($jsonObj["sentences_tone"] as $value){<br/> echo 'valor: '.$value['tones'][$i]['score'];<br/> echo 'sentimento: '.$value['tones'][$i]['tone_name'];<br/> echo 'texto: '.$value['text'];<br/> $i++; };
0debug
Auto-merging package-lock.json : <pre><code>git merge --no-ff account-creation </code></pre> <p>Auto-merging package-lock.json CONFLICT (content): Merge conflict in package-lock.json Automatic merge failed; fix conflicts and then commit the result.</p> <p>Any idea regarding this issue ?</p>
0debug
void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { if (h&3) { ff_avg_dirac_pixels32_c(dst, src, stride, h); } else { ff_avg_pixels16_sse2(dst , src[0] , stride, h); ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h); } }
1threat
yuv2422_1_c_template(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y, enum PixelFormat target) { int i; if (uvalpha < 2048) { for (i = 0; i < (dstW >> 1); i++) { int Y1 = buf0[i * 2] >> 7; int Y2 = buf0[i * 2 + 1] >> 7; int U = ubuf1[i] >> 7; int V = vbuf1[i] >> 7; output_pixels(i * 4, Y1, U, Y2, V); } } else { for (i = 0; i < (dstW >> 1); i++) { int Y1 = buf0[i * 2] >> 7; int Y2 = buf0[i * 2 + 1] >> 7; int U = (ubuf0[i] + ubuf1[i]) >> 8; int V = (vbuf0[i] + vbuf1[i]) >> 8; output_pixels(i * 4, Y1, U, Y2, V); } } }
1threat
static void an5206_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; CPUM68KState *env; int kernel_size; uint64_t elf_entry; target_phys_addr_t entry; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); if (!cpu_model) cpu_model = "m5206"; env = cpu_init(cpu_model); if (!env) { hw_error("Unable to find m68k CPU definition\n"); } env->vbr = 0; env->mbar = AN5206_MBAR_ADDR | 1; env->rambar0 = AN5206_RAMBAR_ADDR | 1; memory_region_init_ram(ram, "an5206.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(address_space_mem, 0, ram); memory_region_init_ram(sram, "an5206.sram", 512); vmstate_register_ram_global(sram); memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram); mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, env); if (!kernel_filename) { fprintf(stderr, "Kernel image must be specified\n"); exit(1); } kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, NULL, NULL, 1, ELF_MACHINE, 0); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL); } if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, ram_size - KERNEL_LOAD_ADDR); entry = KERNEL_LOAD_ADDR; } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } env->pc = entry; }
1threat
ngx-bootstrap How to open a modal from another component? : <p>What I'm trying to do is open a modal from another component, however I keep getting this error <code>TypeError: Cannot create property 'validator' on string 'test1'</code> when <code>component1.html</code> loads because <code>childModal</code> is included. How can I get rid of these errors and implement this properly?</p> <p>component1.html</p> <pre><code>&lt;button type="button" class="btn btn-outline-primary btn-lg" (click)="modal.showModal()"&gt;Test ...... &lt;child-modal #childModal &gt;&lt;/child-modal&gt; </code></pre> <p>component1.ts</p> <pre><code> @ViewChild('childModal') childModal: ModalComponent; </code></pre> <p>modal.html</p> <pre><code>&lt;div bsModal #childModal="bs-modal" class="modal fade" tabindex="-1" role="dialog&gt; &lt;div class="modal-dialog modal-lg"&gt; &lt;div class="modal-content"&gt; &lt;input type="text" formControl="test1"&gt; &lt;input type="text" formControl="test2"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>modal.component.ts</p> <pre><code>constructor(private modalService: BsModalService) { this.form = new FormGroup({ 'test': new FormControl(), 'test2': new FormControl() }) } </code></pre>
0debug
void av_free(void *ptr) { #if CONFIG_MEMALIGN_HACK if (ptr) free((char *)ptr - ((char *)ptr)[-1]); #elif HAVE_ALIGNED_MALLOC _aligned_free(ptr); #else free(ptr); #endif }
1threat
What are the random non-hexadecimal characters in a sequence of hexadecimals? : <p>I have a sequence of characters from an rdf file I opened with python.</p> <pre><code>...\x00\x08\x00\x00\x80\xdc\xc0\x00\t{\x00\x00\xa3p\x00\xe2\xc00... </code></pre> <p>I understand that these are hexadecimals. However, there are some that do not compute as hexadecimals, such as xa3p. What are they and why are they here. And what is \t? Tab?</p>
0debug
Custom input pattern in textbox : >I am looking for a code that will validate custom values into the textbox for a window form such that the input entered follows a certain pattern as shown-|"DB1.DBX1.0"|"DB1000.DBB1000.0"|"DB18.DBD4.0"|"DB99.DBW999.0"| such that DB[1-1000].DB[X,B,D,W][1-1000.0-10] and if the values match the required pattern the valued would be accepted or else it will show an error. I have also attached textbox image for the reference. The textbox looks like such: https://i.stack.imgur.com/mAmAs.png
0debug
Plot confusion matrix in R using ggplot : <p>I have two confusion matrices with calculated values as true positive (tp), false positives (fp), true negatives(tn) and false negatives (fn), corresponding to two different methods. I want to represent them as <a href="https://i.stack.imgur.com/r3lu5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/r3lu5.png" alt="enter image description here"></a></p> <p>I believe facet grid or facet wrap can do this, but I find difficult to start. Here is the data of two confusion matrices corresponding to method1 and method2</p> <pre><code>dframe&lt;-structure(list(label = structure(c(4L, 2L, 1L, 3L, 4L, 2L, 1L, 3L), .Label = c("fn", "fp", "tn", "tp"), class = "factor"), value = c(9, 0, 3, 1716, 6, 3, 6, 1713), method = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("method1", "method2"), class = "factor")), .Names = c("label", "value", "method"), row.names = c(NA, -8L), class = "data.frame") </code></pre>
0debug
Python For loop repeats second loop : <p>I have 2 files (a.txt and shell.txt)</p> <p>in a.txt there are 59 lines and I've extracted their domains with the regex</p> <p>in shell.txt there are 5881 lines.</p> <p>The domains from a.txt exists in shell.txt and I want to extract the entire line of shell.txt if the domain of a.txt exists in shell.txt</p> <p>Unfortunately my loops are not working right so I would like to get some help from you guys.</p> <p>Thanks.</p> <pre><code>import re s1 = open('a.txt', 'r').read().splitlines() s2 = open('shell.txt', 'r').read().splitlines() for x in s1: c1 = re.findall("\/\/(.*)\/",x.split("|")[0])[0] for x2 in s2: c2 = re.findall("\/\/(.*)\/",x2.split("|")[2]) if c1 == c2: print x2 </code></pre>
0debug
BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm) { BlockBackend *blk; blk = g_new0(BlockBackend, 1); blk->refcnt = 1; blk->perm = perm; blk->shared_perm = shared_perm; blk_set_enable_write_cache(blk, true); qemu_co_mutex_init(&blk->public.throttle_group_member.throttled_reqs_lock); qemu_co_queue_init(&blk->public.throttle_group_member.throttled_reqs[0]); qemu_co_queue_init(&blk->public.throttle_group_member.throttled_reqs[1]); block_acct_init(&blk->stats); notifier_list_init(&blk->remove_bs_notifiers); notifier_list_init(&blk->insert_bs_notifiers); QTAILQ_INSERT_TAIL(&block_backends, blk, link); return blk; }
1threat
OAuth scopes and application roles & permissions : <p>Currently my application is verifying user's access based on the roles and permissions. For example, if a user is admin then he has all permissions. </p> <p>However, now I am implementing OAuth 2.0 and OpenIdConnect for single sign on and token based authentication for web applications and REST API's.</p> <p>OAuth 2.0 and Open id connect rely heavily on scopes for access control. Scopes such as account.write account.read account.delete are very similar to permissions "CanCreateAccount" "CanReadAccount" "CanDeleteAccounts" "CanAssignRolesToPermissions".</p> <p>I don't understand what is the difference between the two. This separation forces my application to check the client's scopes when access REST API's and separate check for user's permission. This i believe leads to code duplication. </p> <p>Am I right in thinking that OAuth 2.0 scopes and application permissions are same? If this is true, then instead of maintaining separate application permissions, should I just stick to scopes through out my application? </p> <p>For example, currently the user is assigned to a role and role has permissions. If I replace permissions with scopes then I wound't have to duplicate the client/user scope/permission checking functionality. </p> <p>You might be thinking why not replace scopes with permissions. That is because I want to stick to OAuth 2.0 spec and scopes are used throughout the spec.</p>
0debug
exists Redis java.lang.NullPointerException : I try to check a value in redis database with a bellow methode : redis.exists(searchuid) Error : Caused by: java.lang.NullPointerException
0debug
static int decode_segment(TAKDecContext *s, int8_t mode, int32_t *decoded, int len) { struct CParam code; GetBitContext *gb = &s->gb; int i; if (!mode) { memset(decoded, 0, len * sizeof(*decoded)); return 0; } if (mode > FF_ARRAY_ELEMS(xcodes)) return AVERROR_INVALIDDATA; code = xcodes[mode - 1]; for (i = 0; i < len; i++) { int x = get_bits_long(gb, code.init); if (x >= code.escape && get_bits1(gb)) { x |= 1 << code.init; if (x >= code.aescape) { int scale = get_unary(gb, 1, 9); if (scale == 9) { int scale_bits = get_bits(gb, 3); if (scale_bits > 0) { if (scale_bits == 7) { scale_bits += get_bits(gb, 5); if (scale_bits > 29) return AVERROR_INVALIDDATA; } scale = get_bits_long(gb, scale_bits) + 1; x += code.scale * scale; } x += code.bias; } else x += code.scale * scale - code.escape; } else x -= code.escape; } decoded[i] = (x >> 1) ^ -(x & 1); } return 0; }
1threat
static uint16_t qpci_pc_config_readw(QPCIBus *bus, int devfn, uint8_t offset) { outl(0xcf8, (1 << 31) | (devfn << 8) | offset); return inw(0xcfc); }
1threat
static int seg_write_header(AVFormatContext *s) { SegmentContext *seg = s->priv_data; AVFormatContext *oc = NULL; int ret, i; seg->segment_count = 0; if (!seg->write_header_trailer) seg->individual_header_trailer = 0; if (seg->time_str && seg->times_str) { av_log(s, AV_LOG_ERROR, "segment_time and segment_times options are mutually exclusive, select just one of them\n"); return AVERROR(EINVAL); } if ((seg->list_flags & SEGMENT_LIST_FLAG_LIVE) && seg->times_str) { av_log(s, AV_LOG_ERROR, "segment_flags +live and segment_times options are mutually exclusive:" "specify -segment_time if you want a live-friendly list\n"); return AVERROR(EINVAL); } if (seg->times_str) { if ((ret = parse_times(s, &seg->times, &seg->nb_times, seg->times_str)) < 0) return ret; } else { if (!seg->time_str) seg->time_str = av_strdup("2"); if ((ret = av_parse_time(&seg->time, seg->time_str, 1)) < 0) { av_log(s, AV_LOG_ERROR, "Invalid time duration specification '%s' for segment_time option\n", seg->time_str); return ret; } } if (seg->time_delta_str) { if ((ret = av_parse_time(&seg->time_delta, seg->time_delta_str, 1)) < 0) { av_log(s, AV_LOG_ERROR, "Invalid time duration specification '%s' for delta option\n", seg->time_delta_str); return ret; } } if (seg->list) { if (seg->list_type == LIST_TYPE_UNDEFINED) { if (av_match_ext(seg->list, "csv" )) seg->list_type = LIST_TYPE_CSV; else if (av_match_ext(seg->list, "ext" )) seg->list_type = LIST_TYPE_EXT; else if (av_match_ext(seg->list, "m3u8")) seg->list_type = LIST_TYPE_M3U8; else seg->list_type = LIST_TYPE_FLAT; } if ((ret = segment_list_open(s)) < 0) goto fail; } if (seg->list_type == LIST_TYPE_EXT) av_log(s, AV_LOG_WARNING, "'ext' list type option is deprecated in favor of 'csv'\n"); for (i = 0; i < s->nb_streams; i++) seg->has_video += (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO); if (seg->has_video > 1) av_log(s, AV_LOG_WARNING, "More than a single video stream present, " "expect issues decoding it.\n"); seg->oformat = av_guess_format(seg->format, s->filename, NULL); if (!seg->oformat) { ret = AVERROR_MUXER_NOT_FOUND; goto fail; } if (seg->oformat->flags & AVFMT_NOFILE) { av_log(s, AV_LOG_ERROR, "format %s not supported.\n", oc->oformat->name); ret = AVERROR(EINVAL); goto fail; } if ((ret = segment_mux_init(s)) < 0) goto fail; oc = seg->avf; if (av_get_frame_filename(oc->filename, sizeof(oc->filename), s->filename, seg->segment_idx++) < 0) { ret = AVERROR(EINVAL); goto fail; } seg->segment_count++; if (seg->write_header_trailer) { if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) goto fail; } else { if ((ret = open_null_ctx(&oc->pb)) < 0) goto fail; } if ((ret = avformat_write_header(oc, NULL)) < 0) { avio_close(oc->pb); goto fail; } if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0) s->avoid_negative_ts = 1; if (!seg->write_header_trailer) { close_null_ctx(oc->pb); if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) goto fail; } fail: if (ret) { if (seg->list) segment_list_close(s); if (seg->avf) avformat_free_context(seg->avf); } return ret; }
1threat
static void mirror_start_job(const char *job_id, BlockDriverState *bs, int creation_flags, BlockDriverState *target, const char *replaces, int64_t speed, uint32_t granularity, int64_t buf_size, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, BlockCompletionFunc *cb, void *opaque, const BlockJobDriver *driver, bool is_none_mode, BlockDriverState *base, bool auto_complete, const char *filter_node_name, bool is_mirror, Error **errp) { MirrorBlockJob *s; BlockDriverState *mirror_top_bs; bool target_graph_mod; bool target_is_backing; Error *local_err = NULL; int ret; if (granularity == 0) { granularity = bdrv_get_default_bitmap_granularity(target); } assert ((granularity & (granularity - 1)) == 0); assert(granularity >= BDRV_SECTOR_SIZE); if (buf_size < 0) { error_setg(errp, "Invalid parameter 'buf-size'"); return; } if (buf_size == 0) { buf_size = DEFAULT_MIRROR_BUF_SIZE; } mirror_top_bs = bdrv_new_open_driver(&bdrv_mirror_top, filter_node_name, BDRV_O_RDWR, errp); if (mirror_top_bs == NULL) { return; } if (!filter_node_name) { mirror_top_bs->implicit = true; } mirror_top_bs->total_sectors = bs->total_sectors; bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs)); bdrv_ref(mirror_top_bs); bdrv_drained_begin(bs); bdrv_append(mirror_top_bs, bs, &local_err); bdrv_drained_end(bs); if (local_err) { bdrv_unref(mirror_top_bs); error_propagate(errp, local_err); return; } s = block_job_create(job_id, driver, mirror_top_bs, BLK_PERM_CONSISTENT_READ, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed, creation_flags, cb, opaque, errp); if (!s) { goto fail; } bdrv_unref(mirror_top_bs); s->source = bs; s->mirror_top_bs = mirror_top_bs; target_is_backing = bdrv_chain_contains(bs, target); target_graph_mod = (backing_mode != MIRROR_LEAVE_BACKING_CHAIN); s->target = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE | (target_graph_mod ? BLK_PERM_GRAPH_MOD : 0), BLK_PERM_WRITE_UNCHANGED | (target_is_backing ? BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD : 0)); ret = blk_insert_bs(s->target, target, errp); if (ret < 0) { goto fail; } if (is_mirror) { blk_set_force_allow_inactivate(s->target); } s->replaces = g_strdup(replaces); s->on_source_error = on_source_error; s->on_target_error = on_target_error; s->is_none_mode = is_none_mode; s->backing_mode = backing_mode; s->base = base; s->granularity = granularity; s->buf_size = ROUND_UP(buf_size, granularity); s->unmap = unmap; if (auto_complete) { s->should_complete = true; } s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); if (!s->dirty_bitmap) { goto fail; } block_job_add_bdrv(&s->common, "target", target, 0, BLK_PERM_ALL, &error_abort); if (target_is_backing) { BlockDriverState *iter; for (iter = backing_bs(bs); iter != target; iter = backing_bs(iter)) { ret = block_job_add_bdrv(&s->common, "intermediate node", iter, 0, BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE, errp); if (ret < 0) { goto fail; } } } trace_mirror_start(bs, s, opaque); block_job_start(&s->common); return; fail: if (s) { bdrv_ref(mirror_top_bs); g_free(s->replaces); blk_unref(s->target); block_job_early_fail(&s->common); } bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL, &error_abort); bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abort); bdrv_unref(mirror_top_bs); }
1threat
PHP MVC update user data : Am still suck and it doesn't update the data it keep on giving me error Someone should help me>!! but if the email already exist is tell me email exist but it can not update user data that where am confuse please help me! Its give me this error Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in C:\xampp\htdocs\php.dev\classes\Model.php on line 37 **classed/Model.php** abstract class Model { protected $dbh; protected $stmt; public function __construct() { $this->dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASS); } public function query($query) { $this->stmt = $this->dbh->prepare($query); } // binds the prepare statement public function bind($param, $value, $type = null) { if (is_null($type)) { switch (true) { case is_int($value): $type = PDO::PARAM_INT; break; case is_bool($value): $type = PDO::PARAM_BOOL; break; case is_null($value): $type = PDO::PARAM_NULL; break; default: $type = PDO::PARAM_STR; } } $this->stmt->bindValue($param, $value, $type); } public function execute() { $this->stmt->execute(); } public function resultSet() { $this->execute(); return $this->stmt->fetchAll(PDO::FETCH_ASSOC); } public function lastInsertId() { return $this->dbh->lastInsertId(); } public function single(){ $this->execute(); return $this->stmt->fetch(PDO::FETCH_ASSOC); } public function emailExist() { $this->execute(); return $this->stmt->fetch(PDO::FETCH_ASSOC); } } **controllers/users.php** class Users extends Controller{ protected function profile(){ if (!isset($_SESSION['is_logged_in'])) {//if user do not login they can not profile page header('Location: '.ROOT_URL.'shares'); } $viewmodel = new UserModel(); $this->returnView($viewmodel->profile(), true); } protected function register(){ if (isset($_SESSION['is_logged_in'])) {//if user do not logout they can not access register page header('Location: '.ROOT_URL.'shares'); } $viewmodel = new UserModel(); $this->returnView($viewmodel->register(), true); } protected function login(){ if (isset($_SESSION['is_logged_in'])) {//if user do not logout they can not access login page header('Location: '.ROOT_URL.'shares'); } $viewmodel = new UserModel(); $this->returnView($viewmodel->login(), true); } protected function logout(){ unset($_SESSION['is_logged_in']); unset($_SESSION['user_data']); session_destroy(); // Redirect header('Location: '.ROOT_URL); } } **models/user.php** class UserModel extends Model { public function profile() { // Sanitize POST $post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); if($post['updateProfile']) { #$name = $post['name']; #$email = $post['email']; #$id = $post['id']; if (empty($post['name']) || empty($post['email'])) { Messages::setMsg('Please Fill All Form Fields', 'error'); return; } // check if email is already taken $this->query('SELECT * FROM users WHERE email = :email'); $this->bind(':email', $post['email']); $row = $this->emailExist(); if ($row) { Messages::setMsg('Email already Exist', 'error'); return; } else { # Update the MySQL $this->query("UPDATE users SET name =:name, email =:email WHERE id =:id"); $this->execute(); // Verify if($this->lastInsertId()){ Messages::setMsg('Successfull Updated', 'success'); return; } else { Messages::setMsg('Error while updating data', 'error'); return; } } } return; } } **view/users/profile.php** <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Update Data</h3> </div> <div class="panel-body"> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <div class="form-group"> <label>Name</label> <input type="text" name="name" class="form-control" value="<?php echo $_SESSION['user_data']['name'];?>" /> </div> <div class="form-group"> <label>Email</label> <input type="text" name="email" class="form-control" value="<?php echo $_SESSION['user_data']['email'];?>" /> <input type="hidden" name="id" class="form-control" value="" /> </div> <input class="btn btn-primary" name="updateProfile" type="submit" value="Submit" /> </form> </div> </div> someone should help me Please
0debug
i am developing small inventory model i trying to send mail if stock is less...please help me where to write and how : simple pdo mail function as on stock is column name, when stock is less than 10 then mail should go automatically in pdo please help me without SMTP include_once('database-config.php'); $email="abc@gmail.com"; $query = "SELECT slno, itemname FROM item WHERE as on stock = 10"; foreach ($dbh->query($query) as $row) { // Safe name for 70 char/line limit $itemname = (strlen($row['itemname']) > 40) ? (substr($row['itemname'], 0, 10) . '...') : $row['itemname']; // Prepare message data $subject = 'Out of stock - ' . $row['itemname']; $body = 'Product "' . $itemname . '" is out of stock.' . "\r\n"; $body .= 'Manage from http://localhost/oftest/login-system-in-php/guru-able/guru-able/default/adminhome.php?slno=' . $row['slno'] . "\r\n"; mail($email, $subject, $body);
0debug
Numpy 2 column n rows array- operation on elemts of two columsn in each row : I am very new to Python and Numpy. I have an array of n rows and two columns (array). I have another variable (a) which I am using as reference. for a between (1-10000) if column1 of ARRAY<= a <= column2 of the ARRAY save the tuple (a, YES) This resultant tuple I will use for further operation
0debug
Visual Studio Code Automatic Imports : <p>I'm in the process of making the move from Webstorm to Visual Studio Code. The Performance in Webstorm is abysmal.</p> <p>Visual studio code isn't being very helpful about finding the dependencies I need and importing them. I've been doing it manually so far, but to be honest I'd rather wait 15 seconds for webstorm to find and add my import that have to dig around manually for it.</p> <p><a href="https://i.stack.imgur.com/pjeiN.png"><img src="https://i.stack.imgur.com/pjeiN.png" alt="Screenshot: cannot find import"></a></p> <p>I'm using the angular2 seed from @minko-gechev <a href="https://github.com/mgechev/angular2-seed">https://github.com/mgechev/angular2-seed</a></p> <p>I have a tsconfig.json in my baseDir that looks like this:</p> <pre><code> { "compilerOptions": { "target": "es5", "module": "commonjs", "declaration": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "sourceMap": true, "pretty": true, "allowUnreachableCode": false, "allowUnusedLabels": false, "noImplicitAny": true, "noImplicitReturns": true, "noImplicitUseStrict": false, "noFallthroughCasesInSwitch": true }, "exclude": [ "node_modules", "dist", "typings/index.d.ts", "typings/modules", "src" ], "compileOnSave": false } </code></pre> <p>and I have another one in my src/client dir that looks like this:</p> <pre><code>{ "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "allowSyntheticDefaultImports": true } } </code></pre> <p>I don't know why there are two. The angualr seed project uses typescript gulp build tasks so I guess the compilation is different.</p> <p>What can I do get vscode to be more helpful??</p>
0debug
int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res) { if (bs->drv->bdrv_check == NULL) { return -ENOTSUP; } memset(res, 0, sizeof(*res)); return bs->drv->bdrv_check(bs, res); }
1threat
static int submit_packet(PerThreadContext *p, AVPacket *avpkt) { FrameThreadContext *fctx = p->parent; PerThreadContext *prev_thread = fctx->prev_thread; const AVCodec *codec = p->avctx->codec; if (!avpkt->size && !(codec->capabilities & AV_CODEC_CAP_DELAY)) return 0; pthread_mutex_lock(&p->mutex); release_delayed_buffers(p); if (prev_thread) { int err; if (prev_thread->state == STATE_SETTING_UP) { pthread_mutex_lock(&prev_thread->progress_mutex); while (prev_thread->state == STATE_SETTING_UP) pthread_cond_wait(&prev_thread->progress_cond, &prev_thread->progress_mutex); pthread_mutex_unlock(&prev_thread->progress_mutex); } err = update_context_from_thread(p->avctx, prev_thread->avctx, 0); if (err) { pthread_mutex_unlock(&p->mutex); return err; } } av_packet_unref(&p->avpkt); av_packet_ref(&p->avpkt, avpkt); p->state = STATE_SETTING_UP; pthread_cond_signal(&p->input_cond); pthread_mutex_unlock(&p->mutex); if (!p->avctx->thread_safe_callbacks && ( p->avctx->get_format != avcodec_default_get_format || p->avctx->get_buffer2 != avcodec_default_get_buffer2)) { while (p->state != STATE_SETUP_FINISHED && p->state != STATE_INPUT_READY) { int call_done = 1; pthread_mutex_lock(&p->progress_mutex); while (p->state == STATE_SETTING_UP) pthread_cond_wait(&p->progress_cond, &p->progress_mutex); switch (p->state) { case STATE_GET_BUFFER: p->result = ff_get_buffer(p->avctx, p->requested_frame, p->requested_flags); break; case STATE_GET_FORMAT: p->result_format = ff_get_format(p->avctx, p->available_formats); break; default: call_done = 0; break; } if (call_done) { p->state = STATE_SETTING_UP; pthread_cond_signal(&p->progress_cond); } pthread_mutex_unlock(&p->progress_mutex); } } fctx->prev_thread = p; fctx->next_decoding++; return 0; }
1threat
What means operator "slash" for C++ string? : <p>In a C++ code I found a line</p> <p><code>std::string fruit = "" / "apple";</code></p> <p>When stepping with Visual Studio 12 over this line, the <code>fruit</code> variable ends up containing <em>apple</em>. But <strong>what means this operator "/"</strong> for <code>std::string</code> ?</p>
0debug
Substrings and spliting : I have a lot of messages formatted like this "42[\"message\",\"base64:QWZ0ZXIgQnVuZGxlciBpbnN0YWxscyB0aGUgZ2VtcyBpbiB5b3VyIEdlbWZpbGUsIHlvdSBjYW4gcHJvY2VlZCB0byByZWZlcmVuY2UgdGhlbSBpbiA0eTQ0NG91ciBjb2RlIGp1c3QgYXMgaWYgeW914oCZZCBpbnN0YWxsZWQgdGhlbSB5b3Vyc2VsZi4=\"]" What I want to do is if the message contains base64: then extract the substring after the colon and before the next quote mark.
0debug
html5 autoplay video in Mobile device : <p>Auto play is not working without <strong>muted</strong> attribute, when I try to open url in mobile device. How to play video without using <strong>muted</strong> attribute ? I need to volume without click on muted button and one more important thing is that all thing will be working without <strong>JS and Jquery</strong>. <a href="https://i.stack.imgur.com/Inqfn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Inqfn.png" alt="enter image description here"></a></p>
0debug