problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
MySQL query challenge :) : <p>I am trying to get the last <strong>ids</strong> if <strong>user_handle</strong> is distinct with only 1 SQL query. Anyone knows how to do this?. I need that the SQL returns the ids (16149,16154). Thanks a lot.</p>
<p><a href="https://i.stack.imgur.com/XSzB2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XSzB2.jpg" alt="enter image description here"></a></p>
| 0debug |
GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
int64_t count, Error **errp)
{
GuestFileRead *read_data = NULL;
guchar *buf;
HANDLE fh;
bool is_ok;
DWORD read_count;
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
if (!gfh) {
return NULL;
}
if (!has_count) {
count = QGA_READ_COUNT_DEFAULT;
} else if (count < 0) {
error_setg(errp, "value '%" PRId64
"' is invalid for argument count", count);
return NULL;
}
fh = gfh->fh;
buf = g_malloc0(count+1);
is_ok = ReadFile(fh, buf, count, &read_count, NULL);
if (!is_ok) {
error_setg_win32(errp, GetLastError(), "failed to read file");
slog("guest-file-read failed, handle %" PRId64, handle);
} else {
buf[read_count] = 0;
read_data = g_malloc0(sizeof(GuestFileRead));
read_data->count = (size_t)read_count;
read_data->eof = read_count == 0;
if (read_count != 0) {
read_data->buf_b64 = g_base64_encode(buf, read_count);
}
}
g_free(buf);
return read_data;
}
| 1threat |
static void nbd_trip(void *opaque)
{
NBDClient *client = opaque;
NBDExport *exp = client->exp;
NBDRequest *req;
struct nbd_request request;
struct nbd_reply reply;
ssize_t ret;
uint32_t command;
TRACE("Reading request.");
if (client->closing) {
return;
}
req = nbd_request_get(client);
ret = nbd_co_receive_request(req, &request);
if (ret == -EAGAIN) {
goto done;
}
if (ret == -EIO) {
goto out;
}
reply.handle = request.handle;
reply.error = 0;
if (ret < 0) {
reply.error = -ret;
goto error_reply;
}
command = request.type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_DISC && (request.from + request.len) > exp->size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
request.from, request.len,
(uint64_t)exp->size, (uint64_t)exp->dev_offset);
LOG("requested operation past EOF--bad client?");
goto invalid_request;
}
if (client->closing) {
goto done;
}
switch (command) {
case NBD_CMD_READ:
TRACE("Request type is READ");
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
ret = blk_read(exp->blk,
(request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("reading from file failed");
reply.error = -ret;
goto error_reply;
}
TRACE("Read %u byte(s)", request.len);
if (nbd_co_send_reply(req, &reply, request.len) < 0)
goto out;
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
if (exp->nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
reply.error = EROFS;
goto error_reply;
}
TRACE("Writing to device");
ret = blk_write(exp->blk,
(request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("writing to file failed");
reply.error = -ret;
goto error_reply;
}
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
goto out;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = blk_co_discard(exp->blk, (request.from + exp->dev_offset)
/ BDRV_SECTOR_SIZE,
request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("discard failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
default:
LOG("invalid request type (%u) received", request.type);
invalid_request:
reply.error = EINVAL;
error_reply:
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
}
TRACE("Request/Reply complete");
done:
nbd_request_put(req);
return;
out:
nbd_request_put(req);
client_close(client);
}
| 1threat |
Remove part from a string [SWIFT] : I am working on an iOS App using Swift 4. I am writing some data to a Firebase Database ("FB-DB"). When reading the data, the app generates the following:
let sharedDataReceivedWithBraces = "[\(each.1)]"
The respective console output is the following after `print(sharedDataReceivedWithBraces)`:
[{
id = "EEBEA75A-4DD0-4B30-84FB-1610A664276A";
key = "-Ku5VUHb5rbiy1ipFPL1";
code = 81358;
time = "14:06";
}]
I want to remove the braces {} from this to further process the info, but I struggle a lot with this. Can you help me how to make my console's output look like this?
[
id = "EEBEA75A-4DD0-4B30-84FB-1610A664276A";
key = "-Ku5VUHb5rbiy1ipFPL1";
code = 81358;
time = "14:06";
]
Thank you very much for your great and patient help!
Cheers,
*Janninho* | 0debug |
How to make a GUI in Julia? : <p>I'm new at programming in Julia and I need to create a GUI.
I've been looking for information and I can't find anything useful. I tried to search information in the Julia official web page, but it seems to be down. I wonder if any of you guys knows where I can find information about it.</p>
| 0debug |
Python - Convert string to array/rows : <p>I'm doing a test in Python3 trying to convert a string from <code>http.client</code> to a array/row format. </p>
<pre><code>val1 = "error"
val2 = "message"
array = (val1,val2)
value = "('error', 'message')"
print(value[1])
>> error
print(array[1])
>> '
</code></pre>
<p>I would like to get what I get when I run <code>print(value[1])</code> using a string.<br>
Thanks :)</p>
| 0debug |
Internal Server error 500 for .htaccess file creat : when i creat **.htaccess** file for urlrewrite .i got error Internal Server Error 500.i try to all the solution from net but itn't work.
please help me thanx..
| 0debug |
What is the difference between docker-machine and docker-compose? : <p>I think I don't get it. First, I created docker-machine:</p>
<pre><code>$ docker-machine create -d virtualbox dev
$ eval $(docker-machine env dev)
</code></pre>
<p>Then I wrote Dockerfile and docker-compose.yml:</p>
<pre><code>FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
version: '2'
services:
db:
image: postgres
web:
build: .
restart: always
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
links:
- db
</code></pre>
<p>Finally, I built and started the image:</p>
<pre><code>$ docker-compose build --no-cache
$ docker-compose start
</code></pre>
<p>I checked ip of my virtual machine</p>
<pre><code>$ docker-machine ip dev
</code></pre>
<p>and successfully opened the site in my browser. But when I made some changes in my code - nothing happened. So I logged to the "dev" machine:</p>
<pre><code>$ docker-machine ssh dev
</code></pre>
<p>and I didn't find my code! So I logged to the docker "web" image:</p>
<pre><code>$ docker exec -it project_web_1 bash
</code></pre>
<p>and there was a code, but unchanged.</p>
<p>What is the docker-machine for? What is the sense? Why docker doesn't syncing files after changes? It looks like docker + docker-machine + docker-compose are pain in the a...s for local development :-)</p>
<p>Thanks.</p>
| 0debug |
static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
void *data, int *got_frame_ptr,
const uint8_t *buf, int buf_size)
{
WavpackContext *wc = avctx->priv_data;
WavpackFrameContext *s;
void *samples = data;
int samplecount;
int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0, got_float = 0;
int got_hybrid = 0;
const uint8_t* orig_buf = buf;
const uint8_t* buf_end = buf + buf_size;
int i, j, id, size, ssize, weights, t;
int bpp, chan, chmask;
if (buf_size == 0){
*got_frame_ptr = 0;
return 0;
}
if(block_no >= wc->fdec_num && wv_alloc_frame_context(wc) < 0){
av_log(avctx, AV_LOG_ERROR, "Error creating frame decode context\n");
return -1;
}
s = wc->fdec[block_no];
if(!s){
av_log(avctx, AV_LOG_ERROR, "Context for block %d is not present\n", block_no);
return -1;
}
memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
memset(s->ch, 0, sizeof(s->ch));
s->extra_bits = 0;
s->and = s->or = s->shift = 0;
s->got_extra_bits = 0;
if(!wc->mkv_mode){
s->samples = AV_RL32(buf); buf += 4;
if(!s->samples){
*got_frame_ptr = 0;
return 0;
}
}else{
s->samples = wc->samples;
}
s->frame_flags = AV_RL32(buf); buf += 4;
if(s->frame_flags&0x80){
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
} else if((s->frame_flags&0x03) <= 1){
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
} else {
avctx->sample_fmt = AV_SAMPLE_FMT_S32;
}
bpp = av_get_bytes_per_sample(avctx->sample_fmt);
samples = (uint8_t*)samples + bpp * wc->ch_offset;
s->stereo = !(s->frame_flags & WV_MONO);
s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo;
s->joint = s->frame_flags & WV_JOINT_STEREO;
s->hybrid = s->frame_flags & WV_HYBRID_MODE;
s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE;
s->hybrid_maxclip = 1 << ((((s->frame_flags & 0x03) + 1) << 3) - 1);
s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f);
s->CRC = AV_RL32(buf); buf += 4;
if(wc->mkv_mode)
buf += 4;
wc->ch_offset += 1 + s->stereo;
while(buf < buf_end){
id = *buf++;
size = *buf++;
if(id & WP_IDF_LONG) {
size |= (*buf++) << 8;
size |= (*buf++) << 16;
}
size <<= 1;
ssize = size;
if(id & WP_IDF_ODD) size--;
if(size < 0){
av_log(avctx, AV_LOG_ERROR, "Got incorrect block %02X with size %i\n", id, size);
break;
}
if(buf + ssize > buf_end){
av_log(avctx, AV_LOG_ERROR, "Block size %i is out of bounds\n", size);
break;
}
if(id & WP_IDF_IGNORE){
buf += ssize;
continue;
}
switch(id & WP_IDF_MASK){
case WP_ID_DECTERMS:
if(size > MAX_TERMS){
av_log(avctx, AV_LOG_ERROR, "Too many decorrelation terms\n");
s->terms = 0;
buf += ssize;
continue;
}
s->terms = size;
for(i = 0; i < s->terms; i++) {
s->decorr[s->terms - i - 1].value = (*buf & 0x1F) - 5;
s->decorr[s->terms - i - 1].delta = *buf >> 5;
buf++;
}
got_terms = 1;
break;
case WP_ID_DECWEIGHTS:
if(!got_terms){
av_log(avctx, AV_LOG_ERROR, "No decorrelation terms met\n");
continue;
}
weights = size >> s->stereo_in;
if(weights > MAX_TERMS || weights > s->terms){
av_log(avctx, AV_LOG_ERROR, "Too many decorrelation weights\n");
buf += ssize;
continue;
}
for(i = 0; i < weights; i++) {
t = (int8_t)(*buf++);
s->decorr[s->terms - i - 1].weightA = t << 3;
if(s->decorr[s->terms - i - 1].weightA > 0)
s->decorr[s->terms - i - 1].weightA += (s->decorr[s->terms - i - 1].weightA + 64) >> 7;
if(s->stereo_in){
t = (int8_t)(*buf++);
s->decorr[s->terms - i - 1].weightB = t << 3;
if(s->decorr[s->terms - i - 1].weightB > 0)
s->decorr[s->terms - i - 1].weightB += (s->decorr[s->terms - i - 1].weightB + 64) >> 7;
}
}
got_weights = 1;
break;
case WP_ID_DECSAMPLES:
if(!got_terms){
av_log(avctx, AV_LOG_ERROR, "No decorrelation terms met\n");
continue;
}
t = 0;
for(i = s->terms - 1; (i >= 0) && (t < size); i--) {
if(s->decorr[i].value > 8){
s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
s->decorr[i].samplesA[1] = wp_exp2(AV_RL16(buf)); buf += 2;
if(s->stereo_in){
s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2;
s->decorr[i].samplesB[1] = wp_exp2(AV_RL16(buf)); buf += 2;
t += 4;
}
t += 4;
}else if(s->decorr[i].value < 0){
s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2;
t += 4;
}else{
for(j = 0; j < s->decorr[i].value; j++){
s->decorr[i].samplesA[j] = wp_exp2(AV_RL16(buf)); buf += 2;
if(s->stereo_in){
s->decorr[i].samplesB[j] = wp_exp2(AV_RL16(buf)); buf += 2;
}
}
t += s->decorr[i].value * 2 * (s->stereo_in + 1);
}
}
got_samples = 1;
break;
case WP_ID_ENTROPY:
if(size != 6 * (s->stereo_in + 1)){
av_log(avctx, AV_LOG_ERROR, "Entropy vars size should be %i, got %i", 6 * (s->stereo_in + 1), size);
buf += ssize;
continue;
}
for(j = 0; j <= s->stereo_in; j++){
for(i = 0; i < 3; i++){
s->ch[j].median[i] = wp_exp2(AV_RL16(buf));
buf += 2;
}
}
got_entropy = 1;
break;
case WP_ID_HYBRID:
if(s->hybrid_bitrate){
for(i = 0; i <= s->stereo_in; i++){
s->ch[i].slow_level = wp_exp2(AV_RL16(buf));
buf += 2;
size -= 2;
}
}
for(i = 0; i < (s->stereo_in + 1); i++){
s->ch[i].bitrate_acc = AV_RL16(buf) << 16;
buf += 2;
size -= 2;
}
if(size > 0){
for(i = 0; i < (s->stereo_in + 1); i++){
s->ch[i].bitrate_delta = wp_exp2((int16_t)AV_RL16(buf));
buf += 2;
}
}else{
for(i = 0; i < (s->stereo_in + 1); i++)
s->ch[i].bitrate_delta = 0;
}
got_hybrid = 1;
break;
case WP_ID_INT32INFO:
if(size != 4){
av_log(avctx, AV_LOG_ERROR, "Invalid INT32INFO, size = %i, sent_bits = %i\n", size, *buf);
buf += ssize;
continue;
}
if(buf[0])
s->extra_bits = buf[0];
else if(buf[1])
s->shift = buf[1];
else if(buf[2]){
s->and = s->or = 1;
s->shift = buf[2];
}else if(buf[3]){
s->and = 1;
s->shift = buf[3];
}
buf += 4;
break;
case WP_ID_FLOATINFO:
if(size != 4){
av_log(avctx, AV_LOG_ERROR, "Invalid FLOATINFO, size = %i\n", size);
buf += ssize;
continue;
}
s->float_flag = buf[0];
s->float_shift = buf[1];
s->float_max_exp = buf[2];
buf += 4;
got_float = 1;
break;
case WP_ID_DATA:
s->sc.offset = buf - orig_buf;
s->sc.size = size * 8;
init_get_bits(&s->gb, buf, size * 8);
s->data_size = size * 8;
buf += size;
got_bs = 1;
break;
case WP_ID_EXTRABITS:
if(size <= 4){
av_log(avctx, AV_LOG_ERROR, "Invalid EXTRABITS, size = %i\n", size);
buf += size;
continue;
}
s->extra_sc.offset = buf - orig_buf;
s->extra_sc.size = size * 8;
init_get_bits(&s->gb_extra_bits, buf, size * 8);
s->crc_extra_bits = get_bits_long(&s->gb_extra_bits, 32);
buf += size;
s->got_extra_bits = 1;
break;
case WP_ID_CHANINFO:
if(size <= 1){
av_log(avctx, AV_LOG_ERROR, "Insufficient channel information\n");
return -1;
}
chan = *buf++;
switch(size - 2){
case 0:
chmask = *buf;
break;
case 1:
chmask = AV_RL16(buf);
break;
case 2:
chmask = AV_RL24(buf);
break;
case 3:
chmask = AV_RL32(buf);
break;
case 5:
chan |= (buf[1] & 0xF) << 8;
chmask = AV_RL24(buf + 2);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Invalid channel info size %d\n", size);
chan = avctx->channels;
chmask = avctx->channel_layout;
}
if(chan != avctx->channels){
av_log(avctx, AV_LOG_ERROR, "Block reports total %d channels, decoder believes it's %d channels\n",
chan, avctx->channels);
return -1;
}
if(!avctx->channel_layout)
avctx->channel_layout = chmask;
buf += size - 1;
break;
default:
buf += size;
}
if(id & WP_IDF_ODD) buf++;
}
if(!got_terms){
av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n");
return -1;
}
if(!got_weights){
av_log(avctx, AV_LOG_ERROR, "No block with decorrelation weights\n");
return -1;
}
if(!got_samples){
av_log(avctx, AV_LOG_ERROR, "No block with decorrelation samples\n");
return -1;
}
if(!got_entropy){
av_log(avctx, AV_LOG_ERROR, "No block with entropy info\n");
return -1;
}
if(s->hybrid && !got_hybrid){
av_log(avctx, AV_LOG_ERROR, "Hybrid config not found\n");
return -1;
}
if(!got_bs){
av_log(avctx, AV_LOG_ERROR, "Packed samples not found\n");
return -1;
}
if(!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLT){
av_log(avctx, AV_LOG_ERROR, "Float information not found\n");
return -1;
}
if(s->got_extra_bits && avctx->sample_fmt != AV_SAMPLE_FMT_FLT){
const int size = get_bits_left(&s->gb_extra_bits);
const int wanted = s->samples * s->extra_bits << s->stereo_in;
if(size < wanted){
av_log(avctx, AV_LOG_ERROR, "Too small EXTRABITS\n");
s->got_extra_bits = 0;
}
}
if(s->stereo_in){
if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
else
samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
if (samplecount < 0)
return -1;
samplecount >>= 1;
}else{
const int channel_stride = avctx->channels;
if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
else
samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
if (samplecount < 0)
return -1;
if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){
int16_t *dst = (int16_t*)samples + 1;
int16_t *src = (int16_t*)samples;
int cnt = samplecount;
while(cnt--){
*dst = *src;
src += channel_stride;
dst += channel_stride;
}
}else if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S32){
int32_t *dst = (int32_t*)samples + 1;
int32_t *src = (int32_t*)samples;
int cnt = samplecount;
while(cnt--){
*dst = *src;
src += channel_stride;
dst += channel_stride;
}
}else if(s->stereo){
float *dst = (float*)samples + 1;
float *src = (float*)samples;
int cnt = samplecount;
while(cnt--){
*dst = *src;
src += channel_stride;
dst += channel_stride;
}
}
}
*got_frame_ptr = 1;
return samplecount * bpp;
}
| 1threat |
static int advanced_decode_i_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int mqdiff, mquant, current_mb = 0, over_flags_mb = 0;
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)
{
if (v->ac_pred_plane.is_raw)
s->ac_pred = get_bits(gb, 1);
else
s->ac_pred = v->ac_pred_plane.data[current_mb];
if (v->condover == 3 && v->over_flags_plane.is_raw)
over_flags_mb = get_bits(gb, 1);
GET_MQUANT();
}
current_mb++;
}
return 0;
}
| 1threat |
Application main has not been registered : <p>I have recently started to convert my react native app and running on Expo so i could test this on my actual android device. I am getting this error above. I have since then running my app using the Expo XDE. I am also running on a windows machine.</p>
<p>The full error message is:</p>
<p><img src="https://i.stack.imgur.com/AbxKr.png" alt="enter image description here">]<a href="https://i.stack.imgur.com/AbxKr.png" rel="noreferrer">1</a></p>
<p>I figured that this has something to do with my index.js, yet here it is</p>
<pre><code>import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('projectTARA', () => 'App');
</code></pre>
| 0debug |
How do you load a separate .html page with Javascript : <p>I am trying to figure out how to send a user to another page I design after they have input the correct password. I don't know how to load the page with a JavaScript Command. How could i use the code below to open a new page titled insideVault.html? </p>
<p>I have tried many google searches, but cant find any resources to help me out with this.</p>
<pre><code>// login code //
<div class = "container">
<div class = "passwordEnter">
<div class = "text-center">
<form id="login" onsubmit="return passCheck()" method="get">
<p> Enter Password </p>
<input type="password" name="password" id = "password">
<input type="submit">
</form>
</div>
</div>
</div>
<script src="script.js"></script>
</div>
<script>
function passCheck(){
var input = document.getElementById("password").value == 'test';
console.log(input);
if(!input){
alert('Password incorrect, please try again.');
return false;
}
return true;
}
</code></pre>
<p>I want the code to load a new page, but so far I have not been able to find any code that would allow me to do this.</p>
| 0debug |
How to use server side cursors with psycopg2 : <p>I have a table with 4million rows and I use psycopg2 to execture a:</p>
<pre><code> SELECT * FROM ..WHERE query
</code></pre>
<p>I haven't heard before of the server side cursor and I am reading its a good practice when you expect lots of results.</p>
<p>I find the documentation a bit limited and I have some basic questions. </p>
<p>First I declare the server-side cursor as:</p>
<pre><code>cur = conn.cursor('cursor-name')
</code></pre>
<p>then I execute the query as:</p>
<pre><code>cur.itersize = 10000
sqlstr = "SELECT clmn1, clmn2 FROM public.table WHERE clmn1 LIKE 'At%'"
cur.execute(sqlstr)
</code></pre>
<p>My question is: What do I do now? How do I get the results?</p>
<p>Do I iterate through the rows as:</p>
<pre><code>row = cur.fetchone()
while row:
row = cur.fetchone()
</code></pre>
<p>or I use fetchmany() and I do this:</p>
<pre><code>row = cur.fetchmany(10)
</code></pre>
<p>But in the second case how can I "scroll" the results?</p>
<p>Also what is the point of itersize? </p>
| 0debug |
static void set_cfg_value(bool is_max, int index, int value)
{
if (is_max) {
cfg.buckets[index].max = value;
} else {
cfg.buckets[index].avg = value;
}
} | 1threat |
Natural Languga Processing and keyword finding for Java : assume we have a forum where a user can create topics and discuss about things. It is in my interest that the forum is serious and does not contain exchange of illegal things or organization of illegal meetings e.g. drug trade or child pornography. My application is written in Java, is there a Framework or an WebApi that can find and identify words or semantic meanings of the things user wrote to check there are no illegal things going on? | 0debug |
cannot use nil as type model.Article in return argument : <p>I have this function which is supposed to query database and return an <code>article</code> if found, and nil if the article is not found:</p>
<pre><code>func GetArticleBySlug(slug string) (model.Article, error) {
var err error
var article model.Article
err = database.SQL.Get(&article, "SELECT * FROM article WHERE slug=? LIMIT 1", slug)
if err != nil {
log.Println(err)
return nil, err //<- Problem here
}
return article, nil
}
</code></pre>
<p>Where <code>Article</code> is a struct defined in <code>model</code> package. </p>
<p>But I get this error:</p>
<pre><code>cannot use nil as type model.Article in return argument
</code></pre>
<p>How can I fix this?</p>
| 0debug |
int dyngen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf,
const uint8_t *searched_pc)
{
return tcg_gen_code_common(s, gen_code_buf, 1, searched_pc);
}
| 1threat |
Best Website to record logs like progress, errors, bugs, requests : <p><br>
I am looking for a website, where I can invite all my developers <br> and they can create a log of the apps they are making . <br>
I will also be inviting tester for same project so that they can also create a bug log, or report error and request a developer to look and examine it. <br>
basically I want a website to record logs, errors related to apps and have a communication among developer and tester . </p>
| 0debug |
Read Json with php, some troubles : <p>I have tried, checked many previous topics, and i cant find the way.
<a href="https://stackoverflow.com/questions/6964403/parsing-json-with-php">Parsing JSON with PHP</a>
There is the answer, but im blind; actually, im a medimu PHP programmer, but im new with Json.</p>
<p>Here is my Json:</p>
<p>{"result":"true","disponible":{"aaa":"0.00001362",<strong>"bbb":"0.000392"</strong>,"ccc":"0.00788523","ddd":"0.00004443","eee":"0.0001755","fff":"0.1755",<strong>"ggg":"797.64618376"</strong>}}</p>
<p>My code:</p>
<pre><code>$balances = json_encode(get_balances(),true);
print_r($balances);
</code></pre>
<p>The screen show my Json, so everything is ok here. Now, i want take the bolded values from the json and assign it to PHP variables.</p>
<pre><code>$variable1 = $balances["disponible"]["bbb"];
$variable2 = $balances["disponible"]["ggg"];
echo "Valor 1: ".$variable1 ."<br>";
echo "Valor 2: ";$variable2 ;
</code></pre>
<p>But it dont work. I tried with many combinantions and nothing.
What im doing wrong?</p>
<p>Thanks a lot in advance. Im blocked with this.</p>
| 0debug |
How to make an Implicit Intent so that it opens a specific video in the youtube app? : <p>Basically I am making a simple app and I need to know that how when you click a button a video in the youtube app opens up and can be watched. I could not find any code that I could understand. Thank You your help it will be very much appreciated.</p>
| 0debug |
JS Higher Order functions Nesting : WHAT IS WRONG HERE?? IT WORKS WHEN FILTER METHOD IS ABOVE MAP.
```
const weekLogs = this.props.weeklyLogs
.map(weekLogs =>
<div >
<h3>{weekLogs.title}</h3>
</div>)
.filter(weekLogs => weekLogs.id<10)
``` | 0debug |
iOS 13 status bar style : <p>I want to change the status bar style on a per-ViewController level on iOS 13. So far I didn't have any luck.<br>
I define <code>UIUserInterfaceStyle</code> as <code>Light</code> in info.plist (as I do not want to support dark mode) and set <code>UIViewControllerBasedStatusBarAppearance</code> to <code>true</code>. <code>preferredStatusBarStyle</code> is called on my ViewController but completely ignored. The <code>UIUserInterfaceStyle</code> seems to always override the VC preferences.
How do I get per-ViewController status bar style working on iOS 13? Or is it not supported any more?</p>
| 0debug |
av_cold void ff_gradfun_init_x86(GradFunContext *gf)
{
int cpu_flags = av_get_cpu_flags();
if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2)
gf->filter_line = gradfun_filter_line_mmx2;
if (HAVE_SSSE3 && cpu_flags & AV_CPU_FLAG_SSSE3)
gf->filter_line = gradfun_filter_line_ssse3;
if (HAVE_SSE && cpu_flags & AV_CPU_FLAG_SSE2)
gf->blur_line = gradfun_blur_line_sse2;
}
| 1threat |
static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
{
int i;
writer_print_section_header(w, SECTION_ID_STREAMS);
for (i = 0; i < fmt_ctx->nb_streams; i++)
if (selected_streams[i])
show_stream(w, fmt_ctx, i, 0);
writer_print_section_footer(w);
}
| 1threat |
static bool fw_cfg_ctl_mem_valid(void *opaque, target_phys_addr_t addr,
unsigned size, bool is_write)
{
return is_write && size == 2;
}
| 1threat |
How to identify the storage space left in a persistent volume claim? : <p>I have a Kubernetes cluster on Google Cloud Platform. It has a persistent Volume Claim with a Capacity of 1GB. The persistent volume claim is bound to many deployments. </p>
<p>I would like to identify the space left in the persistent Volume Claim in order to know if 1GB is sufficient for my application. </p>
<p>I have used the command "kubectl get pv" but this does not show the storage space left.</p>
| 0debug |
static Visitor *validate_test_init_raw(TestInputVisitorData *data,
const char *json_string)
{
return validate_test_init_internal(data, json_string, NULL);
}
| 1threat |
static inline void RENAME(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
uint8_t *dst1, uint8_t *dst2,
long width, long height,
long srcStride1, long srcStride2,
long dstStride1, long dstStride2)
{
x86_reg y;
long x,w,h;
w=width/2; h=height/2;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
PREFETCH" %0 \n\t"
PREFETCH" %1 \n\t"
::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory");
#endif
for (y=0;y<h;y++) {
const uint8_t* s1=src1+srcStride1*(y>>1);
uint8_t* d=dst1+dstStride1*y;
x=0;
#if COMPILE_TEMPLATE_MMX
for (;x<w-31;x+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*x])
:"m"(s1[x])
:"memory");
}
#endif
for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x];
}
for (y=0;y<h;y++) {
const uint8_t* s2=src2+srcStride2*(y>>1);
uint8_t* d=dst2+dstStride2*y;
x=0;
#if COMPILE_TEMPLATE_MMX
for (;x<w-31;x+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*x])
:"m"(s2[x])
:"memory");
}
#endif
for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x];
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| 1threat |
I have to create a table with 96 columns . is it efficient or not ? but 96 columns must be in the table : <p>I have a table with 96 columns . the problem is i get confused for create this table with a large amount of columns.</p>
| 0debug |
My def functions are not being executed in Python : <pre><code>print("Welcome to the BMI Index Calculator.")
student_name = " "
while student_name != "0":
student_name = input("Please begin by entering the student's name, or 0 to quit:")
if student_name == "0":
print("Exiting program...")
exit()
def student_height():
input("Please enter student's height in inches:")
return
def student_weight():
input("Please enter student's weight in pounds:")
return
def bmi_profile():
print(student_name, "'s BMI profile:")
print("Height:", student_height, '"')
print("Weight:", student_weight, "lbs.")
def bmi_index(bmi):
bmi = (student_weight * 703 / student_height ** 2)
print("BMI Index:", bmi)
return bmi
</code></pre>
<p>The loop runs but the def functions are not being executed. Can someone tell me where is my mistake? I try to fix the indentation many times but apparently that's not the error...
Thank you in advance for the help.</p>
| 0debug |
Some documentation features not working in Xcode 8 : <p>I'm experimented with documentation comments for Swift in Xcode 8 and found that not every feature from <a href="https://developer.apple.com/library/content/documentation/Xcode/Reference/xcode_markup_formatting_ref/" rel="noreferrer">Markup Formatting Reference</a> works. In particular, I can't make <a href="https://developer.apple.com/library/content/documentation/Xcode/Reference/xcode_markup_formatting_ref/SeeAlso.html#//apple_ref/doc/uid/TP40016497-CH45-SW1" rel="noreferrer"><code>seealso:</code></a> callout working and can't <a href="https://developer.apple.com/library/content/documentation/Xcode/Reference/xcode_markup_formatting_ref/Images.html#//apple_ref/doc/uid/TP40016497-CH17-SW1" rel="noreferrer">insert image URL</a> to my documentation comments. </p>
<p>That's how my <code>seealso:</code> looked like: </p>
<p><a href="https://i.stack.imgur.com/g4ERf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g4ERf.png" alt="broken seealso"></a></p>
<p>I used exactly the same comments as described on these webpages. </p>
<p>Did anybody have the same problem? Does anybody know the solution?</p>
| 0debug |
Regex extract number from a string with a specific pattern in Alteryx : <p>I have string like this which looks like a url</p>
<pre><code>mainpath/path2/abc/PI 6/j
</code></pre>
<p>From the string I need to get the number along with <strong>PI</strong></p>
<p>Main problem is the position of <strong>PI</strong> part wont be always the same. Sometimes it could be at the end. Sometimes at the middle.</p>
<p>So how can I get that number extracted using regex?
I'm really stucked with this</p>
| 0debug |
Minimum Android version with flutter : <p>Which minimum android version is supported by flutter?
Do some plugins have any affect on which version is not supported?</p>
<p>I tried to run my flutter app on an android emulator, but with the version android 16 it doesn't work and the app crashes. Do I have to change the compile version in some config files or why doesn't it work?</p>
| 0debug |
Can't figure out why simple method is infinitely looping in Java : <p>It's just a simple little method that gets user input to convert an integer from decimal to binary. It uses do-while loops to restart and verify valid input. When it catches an InputMismatchException, it starts to infinitely loop this:</p>
<pre><code>Must enter a positive integer, try again.
Enter positive integer for binary conversion:
</code></pre>
<p>I don't know why the Scanner isn't causing the program to wait for new input when I call nextInt().</p>
<p>Here's the code for the method:</p>
<pre><code>public static void main (String[] theArgs) {
final Scanner inputScanner = new Scanner(System.in);
boolean invalidInput = false;
boolean running = true;
int input = 0;
do {
do {
System.out.println("Enter positive integer for binary conversion:");
try {
input = inputScanner.nextInt();
if (input < 1) {
System.out.println("Must be a positive integer, try again.");
invalidInput = true;
} else {
invalidInput = false;
}
} catch (final InputMismatchException e) {
System.out.println("Must enter a positive integer, try again.");
invalidInput = true;
}
} while (invalidInput);
System.out.println(StackUtilities.decimalToBinary(input));
System.out.println("Again? Enter 'n' for no, or anything else for yes:");
if (inputScanner.next().equals("n")) {
running = false;
}
} while (running);
}
</code></pre>
| 0debug |
Is there any alternate command of ExecuteNonQuery? : <p>I am making project on Hospital Management Information System using c#, and want to insert data to SQL Server from c#, but ExecuteNonQuery Command is not working. Is there any alternate of this command?</p>
<pre><code>connection.Open();
command = new SqlCommand(sql, connection);
command.CommandType = CommandType.Text;
int i = command.ExecuteNonQuery();
command.Dispose();
connection.Close();
</code></pre>
| 0debug |
having trouble using join function in sql : im trying to join two tables using the join function
workbench keeps coming up with error and dont understand why
please help
select city,cityid,countryid
from cities join countries
on cities.CountryID = countries.CountryID; | 0debug |
arrow keys not working in chrome : <p>I am building a static website with lots of JS plugins.
Now, the problem is:
Arrow keys, Home/End keys are not working in Chrome but working fine in Firefox.
I have wasted a lot of time searching for a solution, but nothings resolve the problem.
Please help!</p>
| 0debug |
Java typical usage of Void autoboxing type : <p>What is the practical usage of Void reference type in java? How can it help me in practical programming?</p>
| 0debug |
def validity_triangle(a,b,c):
total = a + b + c
if total == 180:
return True
else:
return False | 0debug |
int h261_decode_picture_header(H261Context *h){
MpegEncContext * const s = &h->s;
int format, i;
static int h261_framecounter = 0;
uint32_t startcode;
align_get_bits(&s->gb);
startcode = (h->last_bits << (12 - (8-h->bits_left))) | get_bits(&s->gb, 20-8 - (8- h->bits_left));
for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=1){
startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF;
if(startcode == 0x10)
break;
}
if (startcode != 0x10){
av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
return -1;
}
s->picture_number = get_bits(&s->gb, 5);
skip_bits1(&s->gb);
skip_bits1(&s->gb);
skip_bits1(&s->gb);
format = get_bits1(&s->gb);
if (format == 0){
s->width = 176;
s->height = 144;
s->mb_width = 11;
s->mb_height = 9;
}else{
s->width = 352;
s->height = 288;
s->mb_width = 22;
s->mb_height = 18;
}
s->mb_num = s->mb_width * s->mb_height;
skip_bits1(&s->gb);
skip_bits1(&s->gb);
while (get_bits1(&s->gb) != 0){
skip_bits(&s->gb, 8);
}
if(h261_framecounter > 1)
s->pict_type = P_TYPE;
else
s->pict_type = I_TYPE;
h261_framecounter++;
h->gob_number = 0;
return 0;
}
| 1threat |
static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf)
{
int l1 = gen_new_label();
uint32_t ccbit;
TCGCond cond;
TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv r_tmp = tcg_temp_local_new(TCG_TYPE_I32);
if (cc)
ccbit = 1 << (24 + cc);
else
ccbit = 1 << 23;
if (tf)
cond = TCG_COND_EQ;
else
cond = TCG_COND_NE;
gen_load_gpr(t0, rd);
gen_load_gpr(t1, rs);
tcg_gen_andi_i32(r_tmp, fpu_fcr31, ccbit);
tcg_gen_brcondi_i32(cond, r_tmp, 0, l1);
tcg_temp_free(r_tmp);
tcg_gen_mov_tl(t0, t1);
tcg_temp_free(t1);
gen_set_label(l1);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
| 1threat |
Creating a trigger from sql view : I have two tables that are updated by one function(GLPOST AND GLPOSTO).
I have created a view(GLREP) from this two tables that transpose the rows of GLPOSTO into columns as this is how i want my data.
Now i want to create a trigger(OPTIONAL) on this view to insert to a new table(GLREPORTEXCEL) once the view collects the data from the various tables in the view format.
View GLREP
CREATE VIEW [dbo].[GLREP] AS (SELECT * FROM (SELECT GLPOST.ACCTID,JRNLDATE, GLPOST.FISCALYR, GLPOST.FISCALPERD, GLPOST.SRCECURN, GLPOST.BATCHNBR, GLPOST.ENTRYNBR, GLPOST.JNLDTLDESC,
GLPOST.JNLDTLREF, GLPOST.TRANSAMT, GLPOST.CONVRATE,GLPOST.SCURNAMT, GLPOSTO.OPTFIELD,GLPOST.CNTDETAIL, CSOPTFD.VDESC
FROM GLPOST left JOIN GLPOSTO ON GLPOST.ACCTID = GLPOSTO.ACCTID AND GLPOST.POSTINGSEQ = GLPOSTO.POSTINGSEQ and glpost.CNTDETAIL=glposto.CNTDETAIL left JOIN
CSOPTFD ON GLPOSTO.OPTFIELD = CSOPTFD.OPTFIELD AND GLPOSTO.VALUE = CSOPTFD.VALUE ) as source pivot (MAX([VDESC]) FOR [OPTFIELD] IN (ADVANCE,MEDICAL,MILEAGE,MOTORVEHICLE,PROMOTION,STAFF)) AS PVT )
MY TRIGGER THAT IS NOT WORKING(OPTIONAL)
CREATE TRIGGER OPTIONAL
ON GLREP
for INSERT
AS
INSERT INTO GLREPORTEXCEL
(ACCTID, TRANDATE, FISCALYR, FISCALPERD, SRCECURN, BATCHNBR, ENTRYNBR, JNLDTLDESC, JNLDTLREF, TRANSAMT, CONVRATE, SCURNAMT, CNTDETAIL, STAFF, ADVANCE, MEDICAL, MILEAGE,MOTORVEHICLE,PROMOTION)
SELECT
ACCTID, JRNLDATE, FISCALYR, FISCALPERD, SRCECURN, BATCHNBR, ENTRYNBR, JNLDTLDESC, JNLDTLREF, TRANSAMT, CONVRATE, SCURNAMT, CNTDETAIL, STAFF, ADVANCE, MEDICAL, MILEAGE,MOTORVEHICLE,PROMOTION
FROM inserted
NEW TABLE THAT I WANT TO INSERT IS CALLED :GLREPORTEXCEL | 0debug |
How to start for loop from the beginning of the list on which we are iterating if some condition in the loop turns True(see below) : def fi_da_prfac(var):
fac = []
prfac = []
z = range(2, (var/2)+1)
z.append(var)
for t in z:
if var == t:
prfac.append(t)
z = range(2, (var/2)+1)
z.append(var)
break
else:
if var % int(t) == 0:
prfac.append(t)
var = var/t
del z
z = range(2, (var/2)+1)
z.append(var)
del t
return prfac
I am a beginner at coding. I am trying to write a code to find the Prime factorisation of a given number. If we analyze the code, what I want to do is that if I find a factor, I want to start the for loop again ie. start the for loop from t = 2. I didnt find any way to do it. So I deleted "t" at the end. However the code isnt giving the desired output. I tried a lot to debug it but couldn't. Please help
| 0debug |
What's the difference between RecyclerView.setItemViewCacheSize and RecycledViewPool.setMaxRecycledViews? : <p>The documentation says that <code>setItemViewCacheSize</code> </p>
<blockquote>
<p>sets the number of offscreen views to retain before adding them to the
potentially shared recycled view pool.</p>
</blockquote>
<p>and <code>setMaxRecycledViews</code> </p>
<blockquote>
<p>sets the maximum number of ViewHolders to hold in the pool before
discarding.</p>
</blockquote>
<p>But don't they both function as a cache where views are taken from (i.e., the first sets the number of views cached by the RV, while the second sets that of the RVP)? </p>
<p>Also, when a view is needed, where is it taken first, from the RVP or from the RV's cache?</p>
<p>And what's the optimal (scrolling-wise, ignoring memory) configuration for the two for a simple unnested recyclerview?</p>
| 0debug |
static int get_physical_address(CPUState *env, target_phys_addr_t *physical,
int *prot, int *access_index,
target_ulong address, int rw, int mmu_idx)
{
int is_user = mmu_idx == MMU_USER_IDX;
if (rw == 2)
return get_physical_address_code(env, physical, prot, address,
is_user);
else
return get_physical_address_data(env, physical, prot, address, rw,
is_user);
}
| 1threat |
React Formik use submitForm outside <Formik /> : <h2>Current Behavior</h2>
<pre><code><Formik
isInitialValid
initialValues={{ first_name: 'Test', email: 'test@mail.com' }}
validate={validate}
ref={node => (this.form = node)}
onSubmitCallback={this.onSubmitCallback}
render={formProps => {
const fieldProps = { formProps, margin: 'normal', fullWidth: true, };
const {values} = formProps;
return (
<Fragment>
<form noValidate>
<TextField
{...fieldProps}
required
autoFocus
value={values.first_name}
type="text"
name="first_name"
/>
<TextField
{...fieldProps}
name="last_name"
type="text"
/>
<TextField
{...fieldProps}
required
name="email"
type="email"
value={values.email}
/>
</form>
<Button onClick={this.onClick}>Login</Button>
</Fragment>
);
}}
/>
</code></pre>
<p>I'm trying this solution <a href="https://github.com/jaredpalmer/formik/issues/73#issuecomment-317169770" rel="noreferrer">https://github.com/jaredpalmer/formik/issues/73#issuecomment-317169770</a> but it always return me <code>Uncaught TypeError: _this.props.onSubmit is not a function</code></p>
<p>When I tried to <code>console.log(this.form)</code> there is <code>submitForm</code> function.</p>
<p>Any solution guys?</p>
<hr>
<p>
- Formik Version: latest
- React Version: v16
- OS: Mac OS</p>
| 0debug |
Typescript Error: Property 'files' does not exist on type 'HTMLElement' : <p>I wish to create an upload function for my Apps by using IONIC.</p>
<p>Here is my HTML code:</p>
<pre><code><input ion-button block type="file" id="uploadBR">
<input ion-button block type="file" id="uploadIC">
<button ion-button block (click)="upload()">Confirm Claim Restaurant</button>
</code></pre>
<p>Here is my <code>upload()</code> function:</p>
<pre><code>upload(){
let BR = document.getElementById('uploadBR').files[0]
let IC = document.getElementById('uploadIC').files[0]
console.log(BR)
console.log(IC)
}
</code></pre>
<p>In normal HTML it should work, but it doesn't work with my IONIC.</p>
<p>When building the App, it will show the error <code>Typescript Error: Property 'files' does not exist on type 'HTMLElement'.</code></p>
<p>Am i do it in wrong way or it has to be done in different way with typescript?</p>
<p>Thanks.</p>
| 0debug |
Why click tree throws 'System.Windows.Documents.Run' is not a Visual or Visual3D' InvalidOperationException? : <p>Sometimes right-clicking treeviewitem results unhandled InvalidOperationException. In code behind I select the right clicked row:</p>
<pre><code> static TreeViewItem VisualUpwardSearch(DependencyObject source)
{
while (source != null && !(source is TreeViewItem))
source = VisualTreeHelper.GetParent(source);
return source as TreeViewItem;
}
private void OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
if (treeViewItem != null)
{
treeViewItem.Focus();
e.Handled = true;
}
}
</code></pre>
<p>According to stacktrace above is the source of the problem. </p>
<p>xaml:</p>
<pre><code><UserControl.Resources>
<HierarchicalDataTemplate ItemsSource="{Binding ClassesItemsSource}" DataType="{x:Type pnls:FavoriteObjectTableViewModel}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="{Binding Bitmap}" />
<Label Content="{Binding TableName}"/>
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type pnls:FavoriteObjectClassViewModel}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Bitmap, Converter={StaticResource UriToCachedImageConverter}}"/>
<Label Content="{Binding ClassName}"/>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<TreeView Name="Insert_ObjectTreeIE" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding TablesItemsSource}">
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<EventSetter Event="PreviewMouseRightButtonDown" Handler="OnPreviewMouseRightButtonDown"></EventSetter>
<EventSetter Event="MouseDoubleClick" Handler="OnMouseDoubleClick" />
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</code></pre>
<p>Stacktrace:</p>
<pre><code>e.StackTrace " at MS.Internal.Media.VisualTreeUtils.AsVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)\r\n
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)\r\n
at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)\r\n
at Tekla.Nis.Application.Shared.UI.Panels.FavoriteObjectsView.VisualUpwardSearch(DependencyObject source) in c:\\XXX\\161wpf\\src\\SharedAppFeature\\Panels\\FavoriteObjectsView.xaml.cs:line 45\r\n
at Application.Shared.UI.Panels.FavoriteObjectsView.OnPreviewMouseRightButtonDown(Object sender, MouseButtonEventArgs e) in c:\\XXX\\161wpf\\src\\NisSharedAppFeature\\Panels\\FavoriteObjectsView.xaml.cs:line 52\r\n
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)\r\n
at System.Windows.UIElement.OnPreviewMouseDownThunk(Object sender, MouseButtonEventArgs e)\r\n
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n at System.Windows.ContentElement.RaiseTrustedEvent(RoutedEventArgs args)\r\n
at System.Windows.Input.InputManager.ProcessStagingArea()\r\n
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)\r\n
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)\r\n
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)\r\n
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)\r\n
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)\r\n
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)\r\n
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)\r\n
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)\r\n
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)\r\n
at System.Windows.Application.RunDispatcher(Object ignore)\r\n
at System.Windows.Application.RunInternal(Window window)\r\n
at System.Windows.Application.Run(Window window)\r\n
at System.Windows.Application.Run()\r\n at "my application start location"
</code></pre>
<p>I can reproduce this only sometimes. My colleague said left click item 1 and right click item 2 produces this every time in certain tree.</p>
| 0debug |
hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr)
{
CPUPPCState *env = &cpu->env;
ppc_slb_t *slb;
hwaddr pte_offset;
ppc_hash_pte64_t pte;
unsigned apshift;
if (msr_dr == 0) {
return addr & 0x0FFFFFFFFFFFFFFFULL;
}
slb = slb_lookup(cpu, addr);
if (!slb) {
return -1;
}
pte_offset = ppc_hash64_htab_lookup(cpu, slb, addr, &pte);
if (pte_offset == -1) {
return -1;
}
apshift = hpte_page_shift(slb->sps, pte.pte0, pte.pte1);
if (!apshift) {
return -1;
}
return deposit64(pte.pte1 & HPTE64_R_RPN, 0, apshift, addr)
& TARGET_PAGE_MASK;
}
| 1threat |
Moment js convert milliseconds into date and time : <p>I have current time in milliseconds as - 1454521239279</p>
<p>How do I convert it to 03 FEB 2016 and time as 11:10 PM ?</p>
| 0debug |
static void await_reference_mb_row(const H264Context *const h, H264Picture *ref,
int mb_y)
{
int ref_field = ref->reference - 1;
int ref_field_picture = ref->field_picture;
int ref_height = 16 * h->mb_height >> ref_field_picture;
if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_FRAME))
return;
ff_thread_await_progress(&ref->tf,
FFMIN(16 * mb_y >> ref_field_picture,
ref_height - 1),
ref_field_picture && ref_field);
}
| 1threat |
plus array column with with conversion that array_column in php : I want to create a accounting system. I insert all information that i need them in array but I have problem to showing array.
my accounting system has some ways to get shop and my price column in array have all the ways that isolated with `,` sign.
my array like this:
```php
$array = [
array(
'deposit_id' => 317,
'deposit_date' => '1398/9/21',
'deposit_price' => '40,0,14',
'deposit_code' => 1111,
'deposit_gender' => 0,
'deposit_phone_send' => '09124139155',
'deposit_how_get' => '',
'deposit_user_select' => 'user 2',
'deposit_for' => '3dmax',
'deposit_status' => 0,
'deposit_description' => 'null',
'deposit_abutment_id' => 52
),
array(
'deposit_id' => 400,
'deposit_date' => '1398/9/22',
'deposit_price' => '20,10,0',
'deposit_code' => 2431,
'deposit_gender' => 1,
'deposit_phone_send' => '09102781932',
'deposit_how_get' => '',
'deposit_user_select' => 'user 2',
'deposit_for' => 'Autocad',
'deposit_status' => 0,
'deposit_description' => 'null',
'deposit_abutment_id' => 55
),
];
```
I want to showing the `deposit_price` column with all ways and for all array member like this.
```html
<!--
Cash deposit = plus all member `deposit column` with first sign `,`. that meaning 60
Card deposit = plus all member `deposit column` with second sign `,`. that meaning 10
POST deposti = plus all member `deposit column` with third sign `,`. that meaning 14
all deposit = plus all `deposit_price` column with `,` sign that meaning 84
and i want to showing the in html like this;
-->
<h2>Cash deposit<h2>
<p>60</p>
<hr>
<h2>Card deposit<h2>
<p>10</p>
<hr>
<h2>POS deposit<h2>
<p>14</p>
<hr>
<h2>all deposit<h2>
<p>84</p>
```
| 0debug |
How to get image from the page and store in variable via jquery? :
img src="~/Images/Barcodes/MGRNNo.jpg" id="barCodeImage" width="150px" height="60"
I want to store the above image in varibale via jquery
like
var barcodeimage=$('#barCodeImage').image();
and
I want to print it
like
applet.append64(barcodeimage);
applet.print();
is it possible ?
| 0debug |
static int local_set_xattr(const char *path, FsCred *credp)
{
int err;
if (credp->fc_uid != -1) {
err = setxattr(path, "user.virtfs.uid", &credp->fc_uid, sizeof(uid_t),
0);
if (err) {
return err;
}
}
if (credp->fc_gid != -1) {
err = setxattr(path, "user.virtfs.gid", &credp->fc_gid, sizeof(gid_t),
0);
if (err) {
return err;
}
}
if (credp->fc_mode != -1) {
err = setxattr(path, "user.virtfs.mode", &credp->fc_mode,
sizeof(mode_t), 0);
if (err) {
return err;
}
}
if (credp->fc_rdev != -1) {
err = setxattr(path, "user.virtfs.rdev", &credp->fc_rdev,
sizeof(dev_t), 0);
if (err) {
return err;
}
}
return 0;
}
| 1threat |
dshow_cycle_pins(AVFormatContext *avctx, enum dshowDeviceType devtype,
IBaseFilter *device_filter, IPin **ppin)
{
IEnumPins *pins = 0;
IPin *device_pin = NULL;
IPin *pin;
int r;
const GUID *mediatype[2] = { &MEDIATYPE_Video, &MEDIATYPE_Audio };
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio";
r = IBaseFilter_EnumPins(device_filter, &pins);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not enumerate pins.\n");
return AVERROR(EIO);
}
while (IEnumPins_Next(pins, 1, &pin, NULL) == S_OK && !device_pin) {
IKsPropertySet *p = NULL;
IEnumMediaTypes *types;
PIN_INFO info = {0};
AM_MEDIA_TYPE *type;
GUID category;
DWORD r2;
IPin_QueryPinInfo(pin, &info);
IBaseFilter_Release(info.pFilter);
if (info.dir != PINDIR_OUTPUT)
goto next;
if (IPin_QueryInterface(pin, &IID_IKsPropertySet, (void **) &p) != S_OK)
goto next;
if (IKsPropertySet_Get(p, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY,
NULL, 0, &category, sizeof(GUID), &r2) != S_OK)
goto next;
if (!IsEqualGUID(&category, &PIN_CATEGORY_CAPTURE))
goto next;
if (IPin_EnumMediaTypes(pin, &types) != S_OK)
goto next;
IEnumMediaTypes_Reset(types);
while (IEnumMediaTypes_Next(types, 1, &type, NULL) == S_OK && !device_pin) {
if (IsEqualGUID(&type->majortype, mediatype[devtype])) {
device_pin = pin;
goto next;
}
CoTaskMemFree(type);
}
next:
if (types)
IEnumMediaTypes_Release(types);
if (p)
IKsPropertySet_Release(p);
if (device_pin != pin)
IPin_Release(pin);
}
IEnumPins_Release(pins);
if (!device_pin) {
av_log(avctx, AV_LOG_ERROR,
"Could not find output pin from %s capture device.\n", devtypename);
return AVERROR(EIO);
}
*ppin = device_pin;
return 0;
}
| 1threat |
Missing host to link to! Please provide the :host parameter, for Rails 4 : <blockquote>
<p>Missing host to link to! Please provide the :host parameter, set
default_url_options[:host], or set :only_path to true</p>
</blockquote>
<p>I randomly get this error at time, generally restarting the server fixes the issue for a while, and then it shows up again.
I have added
<code>config.action_mailer.default_url_options = "localhost:3000"</code>, in the development and test.rb files.</p>
<p>Also, I have used <code>include Rails.application.routes.url_helpers</code>
in one module to get access to the routes, I read this could be the reason I get these errors but removing it will leave me with no access to the routes.<br>
The module is for the datatables gem.</p>
| 0debug |
Concept of creating Array of structures in C with three properties : <p>Hi all what I wish to create is some code in C that will allow me to store R,G,B values separately (this will be from an image), I have done some research and assume that using Array of structures to be the best way but still unsure. I then wish to access values from these structures to carry out some simple calculations. The problem I am having is getting my head around accessing the structure/arrays. I'm finding the conceptual part quite difficult if anyone can use a simple example it doesn't have to be relevant to my task but some sample code 3 properties to one structure would be helpful showing how the values can be accessed. I am also looking to understand how I load the structure with values. Any tips or help would be appreciated.</p>
| 0debug |
undefined index - register form : <pre><code> <?php
$mysqli = mysqli_connect('localhost', 'test', 'test123', 'test');
if ($mysqli->connect_errno) {
echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
exit();
}
global $mysqli;
$username = $_POST['username'];
$password = $_POST['password'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$exists = 0;
$result = $mysqli->query("SELECT username from users WHERE username = '{$username}' LIMIT 1");
if ($result->num_rows == 1) {
$exists = 1;
$result = $mysqli->query("SELECT password from users WHERE password = '{$password}' LIMIT 1");
if ($result->num_rows == 1) $exists = 2;
} else {
$result = $mysqli->query("SELECT email from users WHERE email = '{$email}' LIMIT 1");
if ($result->num_rows == 1) $exists = 3;
}
if ($exists == 1) echo "<p>Username already exists!</p>";
else if ($exists == 2) echo "<p>Username and Email already exists!</p>";
else if ($exists == 3) echo "<p>Email already exists!</p>";
else {
# insert data into mysql database
$sql = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`)
VALUES (NULL, '{$username}', '{$password}', '{$firstname}', '{$lastname}', '{$email}')";
if ($mysqli->query($sql)) {
//echo "New Record has id ".$mysqli->insert_id;
echo '<meta http-equiv="refresh" content="0; url=test.html">';
} else {
echo "<p>MySQL error no {$mysqli->errno} : {$mysqli->error}</p>";
exit();
}
}
?>
</code></pre>
<p>I am trying to create a register page, so when the user fills in the relevant details it register them to the database in MYSQL and stores details.</p>
<p>Therfore they can then go ahead to login, the error I am having is 'Undefined index' showing on all variables - username, password, firstname, lastname and email.</p>
<p>I have added all these variables to my backend db but still nothing..</p>
<p>HTML code:</p>
<pre><code><body>
<div class="container">
<h1 class="text-center">Booking</h1>
<form class="form-signin" method="POST" action="register.php">
<h2 class="form-signin-heading">Register</h2>
<div id="all-form">
<h3>User Details</h3>
<input required type="text" class="form-control" placeholder="Name">
<input required type="text" class="form-control" placeholder="Email Address">
<h4>Login Details</h4>
<input required type="text" class="form-control" placeholder="Username">
<input required type="password" class="form-control" placeholder="Password">
<input required type="password" class="form-control" placeholder="Confirm Password">
<button class="btn btn-primary btn-sm" type="register">Register</button>
<p><a href="signup2.html">Already registered? Sign in here </a></p>
</form>
</div>
</div>
<!-- /container -->
</body>
</code></pre>
| 0debug |
Java Application JMenuBar for all Jforms : I am new to Java. I have programming experience on other programming languages , especially in PowerBuilder
I am writing a Java application with many forms and reports
I want to have a menu common for all jforms and reports ( any window on my application ).
I thought I could create a basic mainframe with the menu on it and the open any other window inside this main frame. I can't figure this out , only with InternalFrames but this is not what I want.
I made my JmenuBar , I put it on JPanel and then I put Jpanel on a maximized JFrame i called "mainframe". Any window from JmenuBar opens in front of "mainframe" Jframe. When I click on "mainframe" any open window goes back of cource , focus is on the "mainframe".
I wrote a mouselistener for Jpanel which brings any open window toFront except "mainframe" of cource. That seems to make the job but I have to write the same listener for the JMenuBar and this has the disavantage of windows "flashing" any time they are coming toFront.
My truly question is :
What is the way you work with JmenuBars?
Do I have to put JmenuBar to any JForm I create?
How can I have a mainframe ( maybe maximized) with the JMenuBar on it always on back and any other window opens inFront of this frame?
What I realy need is a main frame with menu for my application and everything happens inside this frame.
Thanks a lot
Kostas
| 0debug |
Why isn't `curve_fit` able to estimate the covariance of the parameter if the parameter fits exactly? : <p>I don't understand <code>curve_fit</code> isn't able to estimate the covariance of the parameter, thus raising the <code>OptimizeWarning</code> below. The following MCVE explains my problem:</p>
<p><strong>MCVE python snippet</strong></p>
<pre><code>from scipy.optimize import curve_fit
func = lambda x, a: a * x
popt, pcov = curve_fit(f = func, xdata = [1], ydata = [1])
print(popt, pcov)
</code></pre>
<p><strong>Output</strong></p>
<pre><code>\python-3.4.4\lib\site-packages\scipy\optimize\minpack.py:715:
OptimizeWarning: Covariance of the parameters could not be estimated
category=OptimizeWarning)
[ 1.] [[ inf]]
</code></pre>
<p>For <code>a = 1</code> the function fits <code>xdata</code> and <code>ydata</code> exactly. Why isn't the error/variance <code>0</code>, or something close to <code>0</code>, but <code>inf</code> instead?</p>
<p>There is this quote from the <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html" rel="noreferrer"><code>curve_fit</code> SciPy Reference Guide</a>:</p>
<blockquote>
<p>If the Jacobian matrix at the solution doesn’t have a full rank, then ‘lm’ method returns a matrix filled with np.inf, on the other hand ‘trf’ and ‘dogbox’ methods use Moore-Penrose pseudoinverse to compute the covariance matrix.</p>
</blockquote>
<p>So, what's the underlying problem? Why doesn't the Jacobian matrix at the solution have a full rank?</p>
| 0debug |
void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl)
{
int i;
const int8_t (*tab)[2];
const int slice_qp = av_clip(sl->qscale - 6*(h->sps.bit_depth_luma-8), 0, 51);
if (sl->slice_type_nos == AV_PICTURE_TYPE_I) tab = cabac_context_init_I;
else tab = cabac_context_init_PB[sl->cabac_init_idc];
for( i= 0; i < 1024; i++ ) {
int pre = 2*(((tab[i][0] * slice_qp) >>4 ) + tab[i][1]) - 127;
pre^= pre>>31;
if(pre > 124)
pre= 124 + (pre&1);
sl->cabac_state[i] = pre;
}
}
| 1threat |
static void dump_regs(TCGContext *s)
{
TCGTemp *ts;
int i;
char buf[64];
for(i = 0; i < s->nb_temps; i++) {
ts = &s->temps[i];
printf(" %10s: ", tcg_get_arg_str_idx(s, buf, sizeof(buf), i));
switch(ts->val_type) {
case TEMP_VAL_REG:
printf("%s", tcg_target_reg_names[ts->reg]);
break;
case TEMP_VAL_MEM:
printf("%d(%s)", (int)ts->mem_offset, tcg_target_reg_names[ts->mem_reg]);
break;
case TEMP_VAL_CONST:
printf("$0x%" TCG_PRIlx, ts->val);
break;
case TEMP_VAL_DEAD:
printf("D");
break;
default:
printf("???");
break;
}
printf("\n");
}
for(i = 0; i < TCG_TARGET_NB_REGS; i++) {
if (s->reg_to_temp[i] >= 0) {
printf("%s: %s\n",
tcg_target_reg_names[i],
tcg_get_arg_str_idx(s, buf, sizeof(buf), s->reg_to_temp[i]));
}
}
}
| 1threat |
Getting a HttpStatusCode of 0 : <p>Why am I getting a HttpStatusCode of 0 if I point the service my client is connecting to to a bad URL.</p>
<p>My statusCodeAsInt is showing up as a 0. Why is it not showing up as a 404 and being handled?</p>
<pre><code>IRestResponse response = client.Execute(restReq);
HttpStatusCode statusCode = response.StatusCode;
var statusCodeAsInt = (int) statusCode;
if (statusCodeAsInt >= 500)
{
throw new InvalidOperationException("A server error occurred: " + response.ErrorMessage, response.ErrorException);
}
if (statusCodeAsInt >= 400)
{
throw new InvalidOperationException("Request could not be understood by the server: " + response.ErrorMessage,
response.ErrorException);
}
</code></pre>
<p>What is the proper way to handle this RestResponse?</p>
| 0debug |
Can't understand how c++ set works : I am using c++ stl set class for a leetcode question. from googlein I heard set keeps the elements in ordered manner and I heard that set.begin() returns the smallest element. But I also heard set uses red black trees and has log(n) time complexity. I don't understand how these two can go together, as in how does set.begin() return smallest element when a redblack tree doesn't guarantee the smallest element will be the head. Also set.begin() function makes it seem like this container uses an array instead of a linked list to build the redblack tree, which again I don't understand how an array can be used instead of a tree.Can someone explain me the implementation of c++ set?
Thank you. | 0debug |
static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
{
struct vmsvga_state_s *s = opaque;
if (s->vga.text_update)
s->vga.text_update(&s->vga, chardata);
}
| 1threat |
static av_cold int aac_encode_init(AVCodecContext *avctx)
{
AACEncContext *s = avctx->priv_data;
int i;
const uint8_t *sizes[2];
uint8_t grouping[AAC_MAX_CHANNELS];
int lengths[2];
avctx->frame_size = 1024;
for (i = 0; i < 16; i++)
if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i])
break;
if (i == 16) {
av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate);
return -1;
}
if (avctx->channels > AAC_MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", avctx->channels);
return -1;
}
if (avctx->profile != FF_PROFILE_UNKNOWN && avctx->profile != FF_PROFILE_AAC_LOW) {
av_log(avctx, AV_LOG_ERROR, "Unsupported profile %d\n", avctx->profile);
return -1;
}
if (1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * avctx->channels) {
av_log(avctx, AV_LOG_ERROR, "Too many bits per frame requested\n");
return -1;
}
s->samplerate_index = i;
dsputil_init(&s->dsp, avctx);
ff_mdct_init(&s->mdct1024, 11, 0, 1.0);
ff_mdct_init(&s->mdct128, 8, 0, 1.0);
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
ff_init_ff_sine_windows(10);
ff_init_ff_sine_windows(7);
s->chan_map = aac_chan_configs[avctx->channels-1];
s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0]));
s->cpe = av_mallocz(sizeof(ChannelElement) * s->chan_map[0]);
avctx->extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = 5;
put_audio_specific_config(avctx);
sizes[0] = swb_size_1024[i];
sizes[1] = swb_size_128[i];
lengths[0] = ff_aac_num_swb_1024[i];
lengths[1] = ff_aac_num_swb_128[i];
for (i = 0; i < s->chan_map[0]; i++)
grouping[i] = s->chan_map[i + 1] == TYPE_CPE;
ff_psy_init(&s->psy, avctx, 2, sizes, lengths, s->chan_map[0], grouping);
s->psypp = ff_psy_preprocess_init(avctx);
s->coder = &ff_aac_coders[2];
s->lambda = avctx->global_quality ? avctx->global_quality : 120;
ff_aac_tableinit();
return 0;
}
| 1threat |
pcie_cap_v1_fill(uint8_t *exp_cap, uint8_t port, uint8_t type, uint8_t version)
{
pci_set_word(exp_cap + PCI_EXP_FLAGS,
((type << PCI_EXP_FLAGS_TYPE_SHIFT) & PCI_EXP_FLAGS_TYPE) |
version);
pci_set_long(exp_cap + PCI_EXP_DEVCAP, PCI_EXP_DEVCAP_RBER);
pci_set_long(exp_cap + PCI_EXP_LNKCAP,
(port << PCI_EXP_LNKCAP_PN_SHIFT) |
PCI_EXP_LNKCAP_ASPMS_0S |
PCI_EXP_LNK_MLW_1 |
PCI_EXP_LNK_LS_25);
pci_set_word(exp_cap + PCI_EXP_LNKSTA,
PCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25 |PCI_EXP_LNKSTA_DLLLA);
}
| 1threat |
I can't figure out how to count even numbers in Javascript : for (count = 1; count < 11; count = count + 2 ) {
if(count % 2 == 1 ) {
console.log(count)
}
This is my code right now and it prints out odd numbers. 1, 3, 5, 7, 9. I need it to print out 2, 4, 6, 8, 10. But I can't figure out how. I'm new to javascript
| 0debug |
how to Disply two textbox values in one textbox c# : [i want this output][1] how to show two textbox values in one textbox c#
i dont want to add or multiply only display the Value that i enterned in textbox
[1]: https://i.stack.imgur.com/vTICG.png | 0debug |
Remove decimal points from a decimal variable if it has .00 : <p>I have a decimal variable and would like to convert it to a string by removing decimal points if it is .00.</p>
<p>For example, I have 23.00 and 25.1458 and I would like both these variables to strings as 23 and 25.1</p>
<p>I am using string conversion <code>string temp => $"{value:n0}"</code> but this one removes decimal points for the later variable too (25.1458) instead I just want to trim only .00 decimals</p>
| 0debug |
How to download from mediafire : I am developing app and I have some .mp3 files at drive. I have only free account, because files are only 2,5GB. There is no direct download link, but in download button is link, but this link is generated at every reloading of web. I cannot get this link by parsing with jsoup. Can you help me? Or some advice for drive. It cannot be Google drive, because it scan files and files greater than 90MB cannot be scanned and there is same problem. I want only 2,5gb.
Thanks and sorry for my English. | 0debug |
if (message.content.startswith(prefix+'ping')) { message.channel.sendmessage('pong! \'${date.now() - message.createdtimemestamp} ms\''); }else : if (message.content.startswith(prefix+'ping')) {
message.channel.sendmessage('pong! \'${date.now() - message.createdtimemestamp} ms\'');
}else
`TypeError:message.content.startswith is not a function`
-
**What is the solution to this problem**
| 0debug |
Property 'value' does not exist on type 'EventTarget' : <p>I am using TypeScript Version 2 for an Angular 2 component code.</p>
<p>I am getting error "Property 'value' does not exist on type 'EventTarget'" for below code, what could be the solution. Thanks!</p>
<p><strong>e.target.value.match(/\S+/g) || []).length</strong></p>
<pre><code>import { Component, EventEmitter, Output } from '@angular/core';
@Component({
selector: 'text-editor',
template: `
<textarea (keyup)="emitWordCount($event)"></textarea>
`
})
export class TextEditorComponent {
@Output() countUpdate = new EventEmitter<number>();
emitWordCount(e: Event) {
this.countUpdate.emit(
(e.target.value.match(/\S+/g) || []).length);
}
}
</code></pre>
| 0debug |
Passing Argument to JavaScript Object Getter : <pre><code>var URIController = {
get href() {
return url.location.href;
}
}
</code></pre>
<p>I have above object structure. But <code>URIController.href</code> property depends on another object, <code>url</code>. </p>
<p>If the <code>url</code> is defined globally, <code>URIController.href</code> works. But I want to pass <code>url</code> object to <code>href</code> getter manually.</p>
<pre><code>var URIController = {
get href(url) {
return url.location.href;
}
}
</code></pre>
<p>Changed the getter to accept url parameter but </p>
<pre><code>URIController.href(url)
</code></pre>
<p>throws error because href is not a function.</p>
<p>Is it possible to pass arguments to getter in javascript?</p>
| 0debug |
Using conditional selection to subset multiple variables in a dataset : <p>I need to use conditional selection to create a subset of the data with records from the control group, weight > 440, and DMI > 13. I also need to find the cattle breed with the largest number of records in this subset of data.</p>
<p>The code I tried was:</p>
<pre><code>> dat2[dat2$Treatment == "control" & dat2$Weight>440 & dat2$DMI >13]
</code></pre>
<p>but I am not sure that is correct.</p>
<pre><code>> dput(head(dat2))
structure(list(Animal = 1:6, Weight = c(455.96, 418.05, 436.31,
448.22, 418.35, 467.78), DMI = c(14.81, 17.63, 17.81, 15.01,
15.42, 12.58), Breed = structure(c(3L, 3L, 2L, 2L, 3L, 3L), .Label =
c("Angus",
"Brahman", "Hereford", "Nelore"), class = "factor"), Treatment =
structure(c(1L,
3L, 1L, 1L, 3L, 1L), .Label = c("Control", "High", "Low"), class = ]
"factor"),
Sex = structure(c(1L, 1L, 2L, 2L, 1L, 1L), .Label = c("Castrate",
"Female", "Male"), class = "factor")), .Names = c("Animal",
"Weight", "DMI", "Breed", "Treatment", "Sex"), row.names = c(NA,
6L), class = "data.frame")
</code></pre>
| 0debug |
static int mace_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;
int16_t **samples;
MACEContext *ctx = avctx->priv_data;
int i, j, k, l, ret;
int is_mace3 = (avctx->codec_id == AV_CODEC_ID_MACE3);
frame->nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (int16_t **)frame->extended_data;
for(i = 0; i < avctx->channels; i++) {
int16_t *output = samples[i];
for (j=0; j < buf_size / (avctx->channels << is_mace3); j++)
for (k=0; k < (1 << is_mace3); k++) {
uint8_t pkt = buf[(i << is_mace3) +
(j*avctx->channels << is_mace3) + k];
uint8_t val[2][3] = {{pkt >> 5, (pkt >> 3) & 3, pkt & 7 },
{pkt & 7 , (pkt >> 3) & 3, pkt >> 5}};
for (l=0; l < 3; l++) {
if (is_mace3)
chomp3(&ctx->chd[i], output, val[1][l], l);
else
chomp6(&ctx->chd[i], output, val[0][l], l);
output += 1 << (1-is_mace3);
*got_frame_ptr = 1;
return buf_size; | 1threat |
build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
{
AcpiTableMcfg *mcfg;
const MemMapEntry *memmap = guest_info->memmap;
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(memmap[VIRT_PCIE_ECAM].base);
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size
/ PCIE_MMCFG_SIZE_MIN) - 1;
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL);
}
| 1threat |
Remove Global "use strict' from babel-preset-env : <p>I want to remove the global 'use strict' that babel-preset-env adds with babel 6.x.</p>
<p>I read the other post about es2015. </p>
<p>I've tried the following .babelrc configuration, to no avail:</p>
<pre><code>{
"presets": [["env", {"loose":true}]],
"plugins": [
["transform-es2015-modules-commonjs", {
"strict" : false
}]
]
}
</code></pre>
<p>I do not want to edit the actual file in node_modules as the other post suggested for es2015. That's quite a hack and won't persist.</p>
<p>The only solution so far is to use gulp-iife to wrap every file. Is there really no way to pass an option in my .babelrc file to disable this?</p>
<p>Which plugin in 'env' is even doing this?</p>
<p>Thanks</p>
| 0debug |
unix command line program does not exit after closing stdin : <p>I create a <code>Process</code> object in Java (the program is html tidy if that is important), feed it some data via stdin (<code>Process.getOutputStream()</code>), and closed the stream, but when I call <code>Process.waitFor()</code> it never returns because the process doesn't exit. How do I fix this without calling <code>Process.destroy()</code>?</p>
| 0debug |
Enums support with Realm? : <p>I'm working on an android app and Realm, and I need to create an enum attribute for one of my objects; but I discovered in this <a href="https://github.com/realm/realm-java/issues/776" rel="noreferrer">post</a> that Realm doesn't support enum yet. </p>
<p>My object is like this:</p>
<pre><code>public class ShuttleOption extends RealmObject {
private int Id;
private String Label;
private ShuttleTypes OriginShuttleType;
}
</code></pre>
<p>and my enum class (ShuttleTypes) corresponds with:</p>
<pre><code>HOME = 1;
</code></pre>
<p>and </p>
<pre><code>WORK = 2;
</code></pre>
<p>Can anybody suggest me how to do it?</p>
| 0debug |
Where is likely the performance bug here? : <p>Many of the test cases are timing out. I've made sure I'm using lazy evaluation everywhere, linear (or better) routines, etc. I'm shocked that this is still not meeting the performance benchmarks. </p>
<pre><code>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Mine
{
public int Distance { get; set; } // from river
public int Gold { get; set; } // in tons
}
class Solution
{
static void Main(String[] args)
{
// helper function for reading lines
Func<string, int[]> LineToIntArray = (line) => Array.ConvertAll(line.Split(' '), Int32.Parse);
int[] line1 = LineToIntArray(Console.ReadLine());
int N = line1[0], // # of mines
K = line1[1]; // # of pickup locations
// Populate mine info
List<Mine> mines = new List<Mine>();
for(int i = 0; i < N; ++i)
{
int[] line = LineToIntArray(Console.ReadLine());
mines.Add(new Mine() { Distance = line[0], Gold = line[1] });
}
// helper function for cost of a move
Func<Mine, Mine, int> MoveCost = (mine1, mine2) =>
Math.Abs(mine1.Distance - mine2.Distance) * mine1.Gold;
int sum = 0; // running total of move costs
// all move combinations on the current list of mines,
// given by the indicies of the mines
var indices = Enumerable.Range(0, N);
var moves = from i1 in indices
from i2 in indices
where i1 != i2
select new int[] { i1, i2 };
while(N != K) // while number of mines hasn't been consolidated to K
{
// get move with the least cost
var cheapest = moves.Aggregate(
(prev, cur) => MoveCost(mines[prev[0]],mines[prev[1]])
< MoveCost(mines[cur[0]], mines[cur[1]])
? prev : cur
);
int i = cheapest[0], // index of source mine of cheapest move
j = cheapest[1]; // index of destination mine of cheapest move
// add cost to total
sum += MoveCost(mines[i], mines[j]);
// move gold from source to destination
mines[j].Gold += mines[i].Gold;
// remove from moves any that had the i-th mine as a destination or source
moves = from move in moves
where move[0] == i || move[1] == i
select move;
// update size number of mines after consolidation
--N;
}
Console.WriteLine(sum);
}
}
</code></pre>
| 0debug |
Create date - Carbon in Laravel : <p>I'm starting to read about <code>Carbon</code> and can't seem to figure out how to create a <code>carbon date</code>.</p>
<p>In the docs is says you can;</p>
<blockquote>
<p><code>Carbon::createFromDate($year, $month, $day, $tz);
Carbon::createFromTime($hour, $minute, $second, $tz);
Carbon::create($year, $month, $day, $hour, $minute, $second, $tz);</code></p>
</blockquote>
<p>But what if I just recieve a <code>date</code> like <code>2016-01-23</code>? Do I have to strip out each part and feed it to <code>carbon</code> before I can create a <code>carbon</code> date? or maybe I receive <code>time</code> like <code>11:53:20</code>??</p>
<p>I'm dealing with dynamic dates and time and writing code to separate parts of time or date doesn't feel right.</p>
<p>Any help appreciated. </p>
| 0debug |
Static variable in ActionListener : <p>How to create a variable in ActionListener that its value increases and leaves saved over all objects(as static variable but ActionListener does not allow to declare it) if the condition is proper?</p>
| 0debug |
static int alsa_run_out (HWVoiceOut *hw)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
int rpos, live, decr;
int samples;
uint8_t *dst;
st_sample_t *src;
snd_pcm_sframes_t avail;
live = audio_pcm_hw_get_live_out (hw);
if (!live) {
return 0;
}
avail = alsa_get_avail (alsa->handle);
if (avail < 0) {
dolog ("Could not get number of available playback frames\n");
return 0;
}
decr = audio_MIN (live, avail);
samples = decr;
rpos = hw->rpos;
while (samples) {
int left_till_end_samples = hw->samples - rpos;
int len = audio_MIN (samples, left_till_end_samples);
snd_pcm_sframes_t written;
src = hw->mix_buf + rpos;
dst = advance (alsa->pcm_buf, rpos << hw->info.shift);
hw->clip (dst, src, len);
while (len) {
written = snd_pcm_writei (alsa->handle, dst, len);
if (written <= 0) {
switch (written) {
case 0:
if (conf.verbose) {
dolog ("Failed to write %d frames (wrote zero)\n", len);
}
goto exit;
case -EPIPE:
if (alsa_recover (alsa->handle)) {
alsa_logerr (written, "Failed to write %d frames\n",
len);
goto exit;
}
if (conf.verbose) {
dolog ("Recovering from playback xrun\n");
}
continue;
case -EAGAIN:
goto exit;
default:
alsa_logerr (written, "Failed to write %d frames to %p\n",
len, dst);
goto exit;
}
}
rpos = (rpos + written) % hw->samples;
samples -= written;
len -= written;
dst = advance (dst, written << hw->info.shift);
src += written;
}
}
exit:
hw->rpos = rpos;
return decr;
}
| 1threat |
PPC_OP(subfeo)
{
do_subfeo();
RETURN();
}
| 1threat |
Java ArrayList of Strings Throwing ArrayIndexOutOfBoundException : <p>Here is my problem:</p>
<ol>
<li><p>I have a Java String returned from my Web service in the below form:</p>
<p>21,6.417,0.3055714,27,0.7778,0.04761905</p></li>
<li><p>Now I have splitted this string into separate Strings by using split function by comma delimiter.</p>
<p>dataList = Arrays.asList(data.split(","));</p></li>
<li><p>I need to loop through this list and assign these Values into separate Strings like below:</p>
<pre><code>int playsCount = Integer.parseInt(dataList.get(0));
float sumTimeViewed = Float.valueOf(dataList.get(1));
float avgTimeViewed = Float.valueOf(dataList.get(2));
int loadsCount = Integer.parseInt(dataList.get(3));
float loadPlayRatio = Float.valueOf(dataList.get(4));
float avgViewDropOff = Float.valueOf(dataList.get(5));
</code></pre></li>
<li><p>Now While getting the values and assigning to the Individual int and floats, getting ArrayIndexOutofBoundsException. This is because some times the list is returning the size as 4 than 6. Here is the code:</p>
<pre><code>reportDataList = getReportData(entry.id);
//System.out.println("reportDataList.size()"+reportDataList.size());
if(reportDataList.size() >= 1) {
for(int i=0;i<reportDataList.size();i++) {
if(!reportDataList.get(0).equals("")) {
playsCount = Integer.parseInt(reportDataList.get(0));
}
if(!reportDataList.get(1).equals("")) {
sumTimeViewed = Float.valueOf(reportDataList.get(1));
}
if(!reportDataList.get(2).equals("")) {
avgTimeViewed = Float.valueOf(reportDataList.get(2));
}
if(!reportDataList.get(3).equals("")) {
loadsCount = Integer.parseInt(reportDataList.get(3));
}
if(!reportDataList.get(4).equals("")) {
loadPlayRatio =Float.valueOf(reportDataList.get(4));
}
if(!reportDataList.get(5).equals("")) {
avgViewDropOff = Float.valueOf(reportDataList.get(5));
}
}
}
</code></pre></li>
</ol>
<p>And here is the getReportData method:</p>
<pre><code>private List<String> getReportData(String id) throws KalturaApiException {
List<String> headerList = null;
List<String> dataList = new ArrayList<String>();
ReportService reportService = client.getReportService();
ReportType reportType = ReportType.TOP_CONTENT;
ReportInputFilter reportInputFilter = new ReportInputFilter();
reportInputFilter.fromDate = 1390156200;
reportInputFilter.toDate = 1453660200;
ReportTotal reportTotal = reportService.getTotal(reportType, reportInputFilter, id);
String data = reportTotal.data;
if(data != null) {
dataList = Arrays.asList(data.split(","));
}
if(dataList.size() >= 1) {
System.out.println("dataList.size() ------->"+dataList.size());
}
return dataList;
}
</code></pre>
<p>How to resolve this problem for any List size acceptable?</p>
<p>Thanks in Advance
Raji</p>
| 0debug |
JavaScript Creating a Table dynamically : <p>I am trying to create a table using JS with random number of rows. The table does create, rows are being inserted outside of the 'for' loop, but when I place rows creation inside the loop, it doesn't create them:</p>
<pre><code>function createTable (rn){
var table.document.createElement("table");
document.getElementById("anchor").appendChild(table);
for(var r=0;r<rn;r++){
var tr=table.insertRow(r);
var td1=tr.insertCell(0), td2=tr.insertCell(1);
td1.innerHTML = "td1";
td2.innerHTML = "td2";
}
}
</code></pre>
| 0debug |
static void h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale)
{
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
const int strength = ff_h263_loop_filter_strength[qscale];
__asm__ volatile (
H263_LOOP_FILTER
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %0 \n\t"
"movq %%mm6, %3 \n\t"
: "+m"(*(uint64_t*)(src - 2 * stride)),
"+m"(*(uint64_t*)(src - 1 * stride)),
"+m"(*(uint64_t*)(src + 0 * stride)),
"+m"(*(uint64_t*)(src + 1 * stride))
: "g"(2 * strength), "m"(ff_pb_FC)
);
}
}
| 1threat |
IE 11 input not displaying typed text : <p>A work's client has reported an issue in our application when working with IE11.</p>
<p>On an specific form, sometimes, when opening it, if you type, the typed text won't show. If I open developer tools, it suddenly shows.</p>
<p>This is the rendered html belonging to that form:</p>
<pre><code><div class="col-sm-6 ">
<div class="form-group" data-ng-show="myform.txtPropietario.visible">
<label class="col-md-4 control-label my-show-hide-animation">Propietario:</label>
<div class="col-md-8">
<div class=" ">
<input name="txtPropietario" class="form-control text-left ng-pristine ng-valid" input-alpha-numeric="ES" onblur="this.value=this.value.toUpperCase();" data-ng-model="myform.values.txtPropietario" data-ng-disabled="myform.txtPropietario.disabled" type="text" step="0.01" maxlength="50" placeholder=" "></div>
<ul class="errores my-show-hide-animation ng-hide" data-ng-show="myform.seccionPanelPagoServiciosname.txtPropietario.$invalid &amp;&amp; myform.procesado"><li data-ng-show="myform.seccionPanelPagoServiciosname.txtPropietario.$error.required" class="ng-hide"><span>Campo obligatorio</span></li><li data-ng-show="myform.seccionPanelPagoServiciosname.txtPropietario.$error.pattern" class="ng-hide"><span>El formato del dato ingresado no es válido.</span></li>
</ul>
</div>
</div>
</div>
</code></pre>
<p>The app work's over AngularJs and html is built over Bootstrap 3.
Any idea why is this happening? </p>
| 0debug |
Google Play Services breaks GSM network : <p>Update of Google Play Services is required for hangouts, google+ and other apps. But Google Play Services (8.4.89) breaks GSM network, with this errors:</p>
<blockquote>
<p>E/WifiManager(2841): mWifiServiceMessenger == null
<strong>E/MPlugin(2947): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport</strong>
E/WifiManager(2947): mWifiServiceMessenger == null
E/MPlugin(1814): Unsupported class:
com.mediatek.common.telephony.IOnlyOwnerSimSupport
E/GmsWearableNodeHelper(1814): GoogleApiClient connection failed:
ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null,
message=null} 03-02 16:51:54.329: E/MPlugin(2878): Unsupported class:
com.mediatek.common.telephony.IOnlyOwnerSimSupport
E/ReceiverController(803): filterReceiver() ignored with null action
03-02 16:51:54.676: E/ReceiverController(803): filterReceiver()
ignored with null action
E/BaseAppContext(2878):
Tried to stop global GMSCore RequestQueue. This is likely unintended,
so ignoring.
E/MPlugin(1814): Unsupported class:
com.mediatek.common.telephony.IOnlyOwnerSimSupport 03-02 16:51:56.209:
E/MPlugin(3054): Unsupported class:
com.mediatek.common.telephony.IOnlyOwnerSimSupport 03-02 16:51:56.285:
E/Babel_SMS(3054): canonicalizeMccMnc: invalid mccmnc 03-02
E/Babel_SMS(3054): canonicalizeMccMnc: invalid mccmnc
nullnull
E/SQLiteLog(3054): (284) automatic index
on conversation_participants_view(conversation_id) 03-02 16:51:56.910:
E/SQLiteLog(3054): (284) automatic index on</p>
</blockquote>
<p>After update Google Play Services with Google Market, GSM does not have any coverage, and no SIM is present (according to Android).
Mobile is Dual SIM based on Mediatek 6735 with Android 5.1
Uninstalling Google Play Services updates, and rebooting GSM works again.
A possible workaround, reboot with original Google Play Services, and after this install Google Play Services updates.</p>
<p>Google Play Services bug, incompatible device, ...?</p>
| 0debug |
VS Code C# - System.NotSupportedException: No data is available for encoding 1252 : <p>I am trying to use ExcelDataReader to read an .xls file on Ubuntu. I am using VS Code with C#. Here is the code:</p>
<pre><code>var stream = File.Open(filePath, mode: FileMode.Open, access: FileAccess.Read);
var reader = ExcelReaderFactory.CreateReader(stream);
</code></pre>
<p>I also tried this:</p>
<pre><code>var reader = ExcelDataReader.ExcelReaderFactory.CreateBinaryReader(stream);
</code></pre>
<p>When I run, I am getting the following exception:</p>
<blockquote>
<p>Unhandled Exception: System.NotSupportedException: No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
at System.Text.Encoding.GetEncoding(Int32 codepage)</p>
</blockquote>
<p>I already installed the <code>libmono-i18n-west4.0-cil</code> (tried also with <code>libmono-i18n4.0-all</code>) as I found out some people recommending this, but the problem persists. Also installed the package <code>System.Text.Encoding.CodePages</code> without success.</p>
<p>Can anyone help to solve this?</p>
| 0debug |
Program throw runtime error when i assign value to a char pointer after allocating dynamic memory? : I want to change the contents of the char pointer after allocating dynamic memory, is it possible ? if not, why? My program throws runtime error.
#include <stdio.h>
int main()
{
char * str = (char *) malloc (10 * sizeof(char));
str = "Hello";
str[2] = 'L'; // here the program throws run time error
printf("%s",str);
return 0;
} | 0debug |
How to build an array of ArrayList<Integer> in Java? : <p>I wrote a piece of code like this </p>
<pre><code>ArrayList<Integer>[]list=new ArrayList<Integer>[128];
</code></pre>
<p>But Eclipse says </p>
<blockquote>
<p>Cannot create a generic array of ArrayList</p>
</blockquote>
<p>I also tried code like this </p>
<pre><code>ArrayList<Integer>[]list=(ArrayList<Integer>[])new Object[128];
</code></pre>
<p>But Eclipse throws exception:</p>
<blockquote>
<p>[Ljava.lang.Object; cannot be cast to [Ljava.util.ArrayList;</p>
</blockquote>
<p>So how can I build an array of ArrayList< Integer > ?</p>
<p>Thanks a lot!!</p>
| 0debug |
What is the fastest way to see if a node has a child with a specific tag in javascript? : I want to check if a node has a certain tag in itself or one of it's children in Javascript.
<html>
<body>
<p>
<h3><a> This link lead nowhere!</a> </h3>
</p>
</body>
</html>
For example, in the above code, if I was given the node which is responsible for the p tag, and want to check if it has a link in it, what would be the fastest way to just check that (without having the actual node for the link)?
If the given node's name was "node", would it be faster to do:
function nodeContainsTag(node) {
return node.tagName == "A" || node.getElementsByTagName("a").length > 0 ;
}
or
function nodeContainsTag(node) {
return node.outerHTML.indexOf("<a") > 0;
}
Is the second function even guaranteed to work (i.e. do I need to check case sensitivity(`"<A"`) and spacing (ex: `"< a"`))? | 0debug |
static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
const uint8_t **buf, int buf_size)
{
MpegEncContext *s = &s1->mpeg_enc_ctx;
AVCodecContext *avctx= s->avctx;
int ret;
const int field_pic= s->picture_structure != PICT_FRAME;
s->resync_mb_x=
s->resync_mb_y= -1;
if (mb_y >= s->mb_height){
av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", s->mb_y, s->mb_height);
return -1;
}
init_get_bits(&s->gb, *buf, buf_size*8);
ff_mpeg1_clean_buffers(s);
s->interlaced_dct = 0;
s->qscale = get_qscale(s);
if(s->qscale == 0){
av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
return -1;
}
while (get_bits1(&s->gb) != 0) {
skip_bits(&s->gb, 8);
}
s->mb_x=0;
for(;;) {
int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
if (code < 0){
av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
return -1;
}
if (code >= 33) {
if (code == 33) {
s->mb_x += 33;
}
} else {
s->mb_x += code;
break;
}
}
s->resync_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y= mb_y;
s->mb_skip_run= 0;
ff_init_block_index(s);
if (s->mb_y==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) {
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1],
s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")),
s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"",
s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors,
s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :"");
}
}
for(;;) {
#ifdef HAVE_XVMC
if(s->avctx->xvmc_acceleration > 1)
XVMC_init_block(s);
#endif
s->dsp.clear_blocks(s->block[0]);
ret = mpeg_decode_mb(s, s->block);
s->chroma_qscale= s->qscale;
dprintf("ret=%d\n", ret);
if (ret < 0)
return -1;
if(s->current_picture.motion_val[0] && !s->encoding){
const int wrap = field_pic ? 2*s->b8_stride : s->b8_stride;
int xy = s->mb_x*2 + s->mb_y*2*wrap;
int motion_x, motion_y, dir, i;
if(field_pic && !s->first_field)
xy += wrap/2;
for(i=0; i<2; i++){
for(dir=0; dir<2; dir++){
if (s->mb_intra || (dir==1 && s->pict_type != B_TYPE)) {
motion_x = motion_y = 0;
}else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)){
motion_x = s->mv[dir][0][0];
motion_y = s->mv[dir][0][1];
} else {
motion_x = s->mv[dir][i][0];
motion_y = s->mv[dir][i][1];
}
s->current_picture.motion_val[dir][xy ][0] = motion_x;
s->current_picture.motion_val[dir][xy ][1] = motion_y;
s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
s->current_picture.ref_index [dir][xy ]=
s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i];
}
xy += wrap;
}
}
s->dest[0] += 16;
s->dest[1] += 8;
s->dest[2] += 8;
MPV_decode_mb(s, s->block);
if (++s->mb_x >= s->mb_width) {
ff_draw_horiz_band(s, 16*s->mb_y, 16);
s->mb_x = 0;
s->mb_y++;
if(s->mb_y<<field_pic >= s->mb_height){
int left= s->gb.size_in_bits - get_bits_count(&s->gb);
if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)))
|| (avctx->error_resilience >= FF_ER_AGGRESSIVE && left>8)){
av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d\n", left);
return -1;
}else
goto eos;
}
ff_init_block_index(s);
}
if (s->mb_skip_run == -1) {
s->mb_skip_run = 0;
for(;;) {
int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
if (code < 0){
av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
return -1;
}
if (code >= 33) {
if (code == 33) {
s->mb_skip_run += 33;
}else if(code == 35){
if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){
av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n");
return -1;
}
goto eos;
}
} else {
s->mb_skip_run += code;
break;
}
}
}
}
eos:
*buf += get_bits_count(&s->gb)/8 - 1;
return 0;
}
| 1threat |
The DbContext of type cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions : <p>I am trying to upgrade our current .Net Core application from 1.1 to 2.0 and am getting this runtime error: "The DbContext of type 'CoreContext' cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions".</p>
<p>It is caused by using the new IServiceCollection.AddDbContextPool<> function. When I use IServiceCollection.AddDbContext<> it still works.</p>
<p>This application is DB-First, so I generate all our contexts using 'Scaffold-DbContext'. Due to that, and the need to inject other services I have an extension on every context like this:</p>
<pre><code>public partial class CoreContext
{
public CoreContext(
DbContextOptions<CoreContext> options,
IUserService userService,
IAuditRepository auditRepository
) : base(options) {...}
}
</code></pre>
<p>Whenever I run the Scaffold-DbContext I just remove the autogenerated Constructor from CoreContext, but even if I put it in there I still get this error.</p>
<pre><code>public partial class CoreContext : DbContext
{
public CoreContext(DbContextOptions<CoreContext> options) : base(options) {}
}
</code></pre>
<p>I've already updated Program.cs to the new style:</p>
<pre><code>public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
}
</code></pre>
<p>And the Startup.cs is pretty straightforward:</p>
<pre><code>public IServiceProvider ConfigureServices(IServiceCollection services)
{
...
services.AddDbContextPool<CoreContext>(options => options.UseSqlServer(absConnectionString));
...
}
</code></pre>
<p>I am using Autofac for DI if that helps. For now I'll default back to the non-Pooling alternative, but it would be nice to take advantage of this feature.</p>
| 0debug |
JQuery set input box value to this.value onclick? : <pre><code>$("#something1").click(function(){
$("#something2").val(this.val);
});
</code></pre>
<p>I'm trying to set the value of something2 to the value of something1 onclick ...</p>
| 0debug |
Polymorphic Relationship With Laravel : <p>I have the photo that can be belongs to a post and comment, So i have created <code>photos table</code> which have these columns</p>
<pre><code>- photable_id
- photable_type
- user_id
- file_name
</code></pre>
<p>The question is: what if i have a photo that belongs to a post and the same photo belongs to another post or comment ?</p>
| 0debug |
Xcode device Unavailable, runtime profile not found : <p>In the following environment:</p>
<pre><code>Xcode 8.3.2
react-native-cli 2.0.1
react-native: 0.44.0
macOS Sierra 10.12.5
</code></pre>
<p>Just updated Xcode and macOS to run React Native and keep on practicing as I was some days ago... but everytime I try to run:</p>
<pre><code>react-native run-ios
</code></pre>
<p>I get the error:</p>
<pre><code>Scanning 555 folders for symlinks in /Users/juangarcia/projects/react-tests/CountDown/node_modules (6ms)
Found Xcode project CountDown.xcodeproj
Could not find iPhone 6 simulator
</code></pre>
<p>I try to see the list of devices available and I get:</p>
<pre><code>~/projects/react-tests/CountDownSample » xcrun simctl list devices
== Devices ==
-- iOS 10.3 --
-- tvOS 10.2 --
Apple TV 1080p (323FA90C-0366-4B5B-AEEE-D0477C61762A) (Shutdown)
-- watchOS 3.2 --
Apple Watch - 38mm (F42C0C0D-325B-41DD-948D-E44B0A08B951) (Shutdown)
Apple Watch - 42mm (75D8BAF1-27CB-47EE-9EE3-D400B962F8BC) (Shutdown)
Apple Watch Series 2 - 38mm (64D01BD4-5C37-4885-A73A-52479D9CCF4F) (Shutdown)
Apple Watch Series 2 - 42mm (8471C9FD-BCF3-4DDC-B386-F17E128C5EB1) (Shutdown)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-9-3 --
iPhone 4s (1FF2D0D3-F136-43A7-8148-7B1849A7B1E3) (Shutdown) (unavailable, runtime profile not found)
iPhone 5 (859D4D90-F1B5-4DE8-B976-6984F85CAFE3) (Shutdown) (unavailable, runtime profile not found)
iPhone 5s (5B2AD8CD-9B3F-413C-BF16-FA96F807BB2B) (Shutdown) (unavailable, runtime profile not found)
iPhone 6 (2573D214-4371-47A8-BFF6-3341862954E0) (Shutdown) (unavailable, runtime profile not found)
iPhone 6 Plus (8916CD9B-4D8B-463F-8583-75A2CE4F61FD) (Shutdown) (unavailable, runtime profile not found)
iPhone 6s (41093980-7912-4F98-9D06-981A533FAAFE) (Shutdown) (unavailable, runtime profile not found)
iPhone 6s Plus (6A85D2AE-D867-4341-979C-FEE8308DE93E) (Shutdown) (unavailable, runtime profile not found)
iPad 2 (BFBB5477-B6D9-48C3-B529-516D2D9105A7) (Shutdown) (unavailable, runtime profile not found)
iPad Retina (C49B5920-F4FF-4D7F-AA74-7AE2367FF09D) (Shutdown) (unavailable, runtime profile not found)
iPad Air (4101FC8E-D8B9-4496-AD2B-1484661C15DE) (Shutdown) (unavailable, runtime profile not found)
iPad Air 2 (9952B05C-829F-428F-AC76-EB1F8FB55D72) (Shutdown) (unavailable, runtime profile not found)
iPad Pro (735082E2-4470-4D9A-BAA1-BEDA8426B725) (Shutdown) (unavailable, runtime profile not found)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.tvOS-9-2 --
Apple TV 1080p (AD48DE24-6295-4EFC-9787-A9B5D8118503) (Shutdown) (unavailable, runtime profile not found)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.watchOS-2-2 --
Apple Watch - 38mm (C3F2A7C3-3967-4159-9B79-13CBA63E399E) (Shutdown) (unavailable, runtime profile not found)
Apple Watch - 42mm (656005A9-7555-4872-A7FB-FB6BCB65139C) (Shutdown) (unavailable, runtime profile not found)
</code></pre>
<p>react takes by default Iphone 6 to work with, and it is not available</p>
<p><strong>how can I make it available again? and why did this happen?</strong></p>
| 0debug |
Condition not falling in IF scope in C : <p>I am inputting fizzbuzz and it should be executing it but it isn't, Then i tried looking whats in argv1, Its printing fizzbuzz at the terminal!!
If it has fizzbuzz then why its not falling in the if condition? </p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include "my_functions.h"
int main(int argc, char *argv[]){
if (argc == 2)
{
if (argv[1] == "fizzbuzz")
{
printName();
checkArgument(argc,argv);
}
else
{
printf("%s\n", argv[1]);
}
}
else
{
printf("Incorrect\n");
}
return 0;
}
</code></pre>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.