problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static int64_t find_best_filter(const DCAADPCMEncContext *s, const int32_t *in, int len)
{
const premultiplied_coeffs *precalc_data = s->private_data;
int i, j, k = 0;
int vq;
int64_t err;
int64_t min_err = 1ll << 62;
int64_t corr[15];
for (i = 0; i <= DCA_ADPCM_COEFFS; i++)
for (j = i; j <= DCA_ADPCM_COEFFS; j++)
corr[k++] = calc_corr(in+4, len, i, j);
for (i = 0; i < DCA_ADPCM_VQCODEBOOK_SZ; i++) {
err = apply_filter(ff_dca_adpcm_vb[i], corr, *precalc_data);
if (err < min_err) {
min_err = err;
vq = i;
}
precalc_data++;
}
return vq;
}
| 1threat
|
How to extend css class with another style? : <p>I have nearly 30 classes and I want to apply this classes to my button element. I don't want to add class attribute for every button element. Is there any way to create a new button class like;</p>
<pre><code>.button{
.rounded-corner
.corner
.button-effective
//another 20 classes
}
</code></pre>
| 0debug
|
static int tiff_decode_tag(TiffContext *s)
{
unsigned tag, type, count, off, value = 0;
int i, j, k, pos, start;
int ret;
uint32_t *pal;
double *dp;
tag = tget_short(&s->gb, s->le);
type = tget_short(&s->gb, s->le);
count = tget_long(&s->gb, s->le);
off = tget_long(&s->gb, s->le);
start = bytestream2_tell(&s->gb);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
type);
return 0;
}
if (count == 1) {
switch (type) {
case TIFF_BYTE:
case TIFF_SHORT:
bytestream2_seek(&s->gb, -4, SEEK_CUR);
value = tget(&s->gb, type, s->le);
break;
case TIFF_LONG:
value = off;
break;
case TIFF_STRING:
if (count <= 4) {
bytestream2_seek(&s->gb, -4, SEEK_CUR);
break;
}
default:
value = UINT_MAX;
bytestream2_seek(&s->gb, off, SEEK_SET);
}
} else {
if (count <= 4 && type_sizes[type] * count <= 4) {
bytestream2_seek(&s->gb, -4, SEEK_CUR);
} else {
bytestream2_seek(&s->gb, off, SEEK_SET);
}
}
switch (tag) {
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
s->bppcount = count;
if (count > 4) {
av_log(s->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
s->bpp, count);
return AVERROR_INVALIDDATA;
}
if (count == 1)
s->bpp = value;
else {
switch (type) {
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
if (bytestream2_get_bytes_left(&s->gb) < type_sizes[type] * count)
return AVERROR_INVALIDDATA;
for (i = 0; i < count; i++)
s->bpp += tget(&s->gb, type, s->le);
break;
default:
s->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (count != 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single value, many provided\n");
return AVERROR_INVALIDDATA;
}
if (value > 4U) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel %d is too large\n", value);
return AVERROR_INVALIDDATA;
}
if (s->bppcount == 1)
s->bpp *= value;
s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch (s->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return AVERROR(ENOSYS);
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(s->avctx, AV_LOG_ERROR,
"JPEG compression is not supported\n");
return AVERROR_PATCHWELCOME;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
s->compr);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_ROWSPERSTRIP:
if (type == TIFF_LONG && value == UINT_MAX)
value = s->height;
if (value < 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Incorrect value of rows per strip\n");
return AVERROR_INVALIDDATA;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
s->strippos = 0;
s->stripoff = value;
} else
s->strippos = off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
if (s->strippos > bytestream2_size(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizesoff = 0;
s->stripsize = value;
s->strips = 1;
} else {
s->stripsizesoff = off;
}
s->strips = count;
s->sstype = type;
if (s->stripsizesoff > bytestream2_size(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_TILE_BYTE_COUNTS:
case TIFF_TILE_LENGTH:
case TIFF_TILE_OFFSETS:
case TIFF_TILE_WIDTH:
av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");
return AVERROR_PATCHWELCOME;
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch (value) {
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
value);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_FILL_ORDER:
if (value < 1 || value > 2) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) s->palette;
off = type_sizes[type];
if (count / 3 > 256 || bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3)
return AVERROR_INVALIDDATA;
off = (type_sizes[type] - 1) << 3;
for (k = 2; k >= 0; k--) {
for (i = 0; i < count / 3; i++) {
if (k == 2)
pal[i] = 0xFFU << 24;
j = (tget(&s->gb, type, s->le) >> off) << (k * 8);
pal[i] |= j;
}
}
s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (value == 2) {
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
return AVERROR_PATCHWELCOME;
}
break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if (s->compr == TIFF_G4)
s->fax_opts = value;
break;
#define ADD_METADATA(count, name, sep)\
if ((ret = add_metadata(count, type, name, sep, s)) < 0) {\
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\
return ret;\
}
case TIFF_MODEL_PIXEL_SCALE:
ADD_METADATA(count, "ModelPixelScaleTag", NULL);
break;
case TIFF_MODEL_TRANSFORMATION:
ADD_METADATA(count, "ModelTransformationTag", NULL);
break;
case TIFF_MODEL_TIEPOINT:
ADD_METADATA(count, "ModelTiepointTag", NULL);
break;
case TIFF_GEO_KEY_DIRECTORY:
ADD_METADATA(1, "GeoTIFF_Version", NULL);
ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");
s->geotag_count = tget_short(&s->gb, s->le);
if (s->geotag_count > count / 4 - 1) {
s->geotag_count = count / 4 - 1;
av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");
}
if (bytestream2_get_bytes_left(&s->gb) < s->geotag_count * sizeof(int16_t) * 4) {
s->geotag_count = 0;
return -1;
}
s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count);
if (!s->geotags) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
s->geotag_count = 0;
return AVERROR(ENOMEM);
}
for (i = 0; i < s->geotag_count; i++) {
s->geotags[i].key = tget_short(&s->gb, s->le);
s->geotags[i].type = tget_short(&s->gb, s->le);
s->geotags[i].count = tget_short(&s->gb, s->le);
if (!s->geotags[i].type)
s->geotags[i].val = get_geokey_val(s->geotags[i].key, tget_short(&s->gb, s->le));
else
s->geotags[i].offset = tget_short(&s->gb, s->le);
}
break;
case TIFF_GEO_DOUBLE_PARAMS:
if (count >= INT_MAX / sizeof(int64_t))
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int64_t))
return AVERROR_INVALIDDATA;
dp = av_malloc(count * sizeof(double));
if (!dp) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < count; i++)
dp[i] = tget_double(&s->gb, s->le);
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", ");
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
av_freep(&dp);
return AVERROR(ENOMEM);
}
s->geotags[i].val = ap;
}
}
}
av_freep(&dp);
break;
case TIFF_GEO_ASCII_PARAMS:
pos = bytestream2_tell(&s->gb);
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap;
bytestream2_seek(&s->gb, pos + s->geotags[i].offset, SEEK_SET);
if (bytestream2_get_bytes_left(&s->gb) < s->geotags[i].count)
return AVERROR_INVALIDDATA;
ap = av_malloc(s->geotags[i].count);
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
bytestream2_get_bufferu(&s->gb, ap, s->geotags[i].count);
ap[s->geotags[i].count - 1] = '\0';
s->geotags[i].val = ap;
}
}
}
break;
case TIFF_ARTIST:
ADD_METADATA(count, "artist", NULL);
break;
case TIFF_COPYRIGHT:
ADD_METADATA(count, "copyright", NULL);
break;
case TIFF_DATE:
ADD_METADATA(count, "date", NULL);
break;
case TIFF_DOCUMENT_NAME:
ADD_METADATA(count, "document_name", NULL);
break;
case TIFF_HOST_COMPUTER:
ADD_METADATA(count, "computer", NULL);
break;
case TIFF_IMAGE_DESCRIPTION:
ADD_METADATA(count, "description", NULL);
break;
case TIFF_MAKE:
ADD_METADATA(count, "make", NULL);
break;
case TIFF_MODEL:
ADD_METADATA(count, "model", NULL);
break;
case TIFF_PAGE_NAME:
ADD_METADATA(count, "page_name", NULL);
break;
case TIFF_PAGE_NUMBER:
ADD_METADATA(count, "page_number", " / ");
break;
case TIFF_SOFTWARE_NAME:
ADD_METADATA(count, "software", NULL);
break;
default:
av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
}
bytestream2_seek(&s->gb, start, SEEK_SET);
return 0;
}
| 1threat
|
How do I check if a particular app is installed on the user's device on iOS? : <p>Is there a function which I can use to check if the user has a particular app installed on their device. Ie, instagram</p>
| 0debug
|
(need a code of vba) I Need to copy the rest of the data of row after empty cell into next empy row from start e.(A1,2.3) : I need to get rest of the data after empty cell into next available empty row of the same sheet. you can review the attached image of input, and output which is required result. Images can clear more that I want
[Input][1]
[Output(required result)][2]
[1]: http://i.stack.imgur.com/OZCuV.png
[2]: http://i.stack.imgur.com/NRJdG.png
| 0debug
|
Running Jupyter notebook in a virtualenv: installed sklearn module not available : <p>I have installed a created a virtualenv <strong>machinelearn</strong> and installed a few python modules (pandas, scipy and sklearn) in that environment.</p>
<p>When I run jupyter notebook, I can import pandas and scipy in my notebooks - however, when I try to import sklearn, I get the following error message:</p>
<pre><code>import sklearn
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-8fd979e02004> in <module>()
----> 1 import sklearn
ImportError: No module named 'sklearn'
</code></pre>
<p>I am able to import all modules, at the command line - so I know they have been successfully installed:</p>
<pre><code>(machinelearn) me@yourbox:~/path/to/machinelearn$ python -c "import pandas, scipy, sklearn"
(machinelearn) me@yourbox:~/path/to/machinelearn$
</code></pre>
<p>How can I import sklearn in my jupyter notebook running in a virtualenv?</p>
| 0debug
|
static int64_t mp3_sync(AVFormatContext *s, int64_t target_pos, int flags)
{
int dir = (flags&AVSEEK_FLAG_BACKWARD) ? -1 : 1;
int64_t best_pos;
int best_score, i, j;
int64_t ret;
avio_seek(s->pb, FFMAX(target_pos - SEEK_WINDOW, 0), SEEK_SET);
ret = avio_seek(s->pb, target_pos, SEEK_SET);
if (ret < 0)
return ret;
#define MIN_VALID 3
best_pos = target_pos;
best_score = 999;
for(i=0; i<SEEK_WINDOW; i++) {
int64_t pos = target_pos + (dir > 0 ? i - SEEK_WINDOW/4 : -i);
int64_t candidate = -1;
int score = 999;
if (pos < 0)
continue;
for(j=0; j<MIN_VALID; j++) {
ret = check(s->pb, pos);
if(ret < 0)
break;
if ((target_pos - pos)*dir <= 0 && abs(MIN_VALID/2-j) < score) {
candidate = pos;
score = abs(MIN_VALID/2-j);
}
pos += ret;
}
if (best_score > score && j == MIN_VALID) {
best_pos = candidate;
best_score = score;
if(score == 0)
break;
}
}
return avio_seek(s->pb, best_pos, SEEK_SET);
}
| 1threat
|
Script to add pre-made ppt to new ppt : <p>I have several ppt files, and I am wanting to create a script that asks which of these pre-made ppt files I would like to use to create a NEW presentation.
example -
I have ppt1, ppt2, ppt3 and ppt4.
A script opens asking "Select the ppt files you want to add to your new presentation" and then a list of these files is shown. I put a checkmark by the ones I want (let's say ppt2 and ppt4) and when I click OK it takes these files and copies or adds them to a new ppt and asks what I want to name the new presentation. That's all. I would think this would be easy, but I am new and looking for assistance. I have searched and tested several different scripting for powerpoint suggestions but nothing seems to be what I am looking for, or does not work. Even a simple starting point and I can take it from there (or at least I hope) LOL
Thanks in advance.</p>
| 0debug
|
Nested function returning a variable through the outer function in python : <p>I have a requirement which I am going to try an explain through the below example:</p>
<p>Suppose we have a segment of code like this:</p>
<pre><code>def a:
def b:
x = 2
</code></pre>
<p>Now I want to return x through the function a. Is there any way to do it in python?</p>
| 0debug
|
Reload app in iOS simulator using Command-R not working : <p>I am using TabBarIOS component in React native. If I press Command-R, the reload of the app is not happening. I use the "Shake Gesture" to show the menu and then click Reload on the context menu to reload the app.</p>
<p>Is there a way to get Command-R to work with TabBarIOS component in React native?</p>
| 0debug
|
React Native ios picker is always open : <p>I have two pickers on my screen. Whenever I navigate to the screen in iOS app I find that the pickers are always open and all options are visible.</p>
<p><a href="https://i.stack.imgur.com/RppGo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RppGo.png" alt="enter image description here"></a></p>
<p>It works perfectly fine in Android where the options are visible only after we click on the picker.</p>
<p>Can somebody suggest a solution to fix this in iOS?</p>
| 0debug
|
Postgres Npgsql Connection Pooling : <p>I'd like to better understand <strong>Connection Pooling</strong> when using Npgsql for Postgres. (<a href="http://www.npgsql.org/" rel="noreferrer">http://www.npgsql.org/</a>)</p>
<p>When I use the connection string:</p>
<blockquote>
<p>UserID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100;</p>
</blockquote>
<p>Where is the "Pooling" going to take place? On my application server or on the database?</p>
<p>When I call connection.Open(), what happens? Is a connection taken from the pool if one exists and if not, a pool is created?</p>
<p>Any other general info around Connection Pooling would be appreciated.</p>
<p>Thanks.</p>
| 0debug
|
void bdrv_attach_aio_context(BlockDriverState *bs,
AioContext *new_context)
{
BdrvAioNotifier *ban;
BdrvChild *child;
if (!bs->drv) {
return;
}
bs->aio_context = new_context;
QLIST_FOREACH(child, &bs->children, next) {
bdrv_attach_aio_context(child->bs, new_context);
}
if (bs->drv->bdrv_attach_aio_context) {
bs->drv->bdrv_attach_aio_context(bs, new_context);
}
QLIST_FOREACH(ban, &bs->aio_notifiers, list) {
ban->attached_aio_context(new_context, ban->opaque);
}
}
| 1threat
|
How Do I print this box in python with a function? : https://i.imgur.com/sywMx9V.png really confused on how this works, if I formatted something wrong in this post my bad.
| 0debug
|
static void create_cpu_model_list(ObjectClass *klass, void *opaque)
{
struct CpuDefinitionInfoListData *cpu_list_data = opaque;
CpuDefinitionInfoList **cpu_list = &cpu_list_data->list;
CpuDefinitionInfoList *entry;
CpuDefinitionInfo *info;
char *name = g_strdup(object_class_get_name(klass));
S390CPUClass *scc = S390_CPU_CLASS(klass);
g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
info = g_new0(CpuDefinitionInfo, 1);
info->name = name;
info->has_migration_safe = true;
info->migration_safe = scc->is_migration_safe;
info->q_static = scc->is_static;
info->q_typename = g_strdup(object_class_get_name(klass));
if (cpu_list_data->model) {
Object *obj;
S390CPU *sc;
obj = object_new(object_class_get_name(klass));
sc = S390_CPU(obj);
if (sc->model) {
info->has_unavailable_features = true;
check_unavailable_features(cpu_list_data->model, sc->model,
&info->unavailable_features);
}
object_unref(obj);
}
entry = g_new0(CpuDefinitionInfoList, 1);
entry->value = info;
entry->next = *cpu_list;
*cpu_list = entry;
}
| 1threat
|
static void ioport_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIQXLDevice *d = opaque;
uint32_t io_port = addr;
qxl_async_io async = QXL_SYNC;
#if SPICE_INTERFACE_QXL_MINOR >= 1
uint32_t orig_io_port = io_port;
#endif
switch (io_port) {
case QXL_IO_RESET:
case QXL_IO_SET_MODE:
case QXL_IO_MEMSLOT_ADD:
case QXL_IO_MEMSLOT_DEL:
case QXL_IO_CREATE_PRIMARY:
case QXL_IO_UPDATE_IRQ:
case QXL_IO_LOG:
#if SPICE_INTERFACE_QXL_MINOR >= 1
case QXL_IO_MEMSLOT_ADD_ASYNC:
case QXL_IO_CREATE_PRIMARY_ASYNC:
#endif
break;
default:
if (d->mode != QXL_MODE_VGA) {
break;
}
dprint(d, 1, "%s: unexpected port 0x%x (%s) in vga mode\n",
__func__, io_port, io_port_to_string(io_port));
#if SPICE_INTERFACE_QXL_MINOR >= 1
if (io_port >= QXL_IO_UPDATE_AREA_ASYNC &&
io_port <= QXL_IO_DESTROY_ALL_SURFACES_ASYNC) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
}
#endif
return;
}
#if SPICE_INTERFACE_QXL_MINOR >= 1
orig_io_port = io_port;
switch (io_port) {
case QXL_IO_UPDATE_AREA_ASYNC:
io_port = QXL_IO_UPDATE_AREA;
goto async_common;
case QXL_IO_MEMSLOT_ADD_ASYNC:
io_port = QXL_IO_MEMSLOT_ADD;
goto async_common;
case QXL_IO_CREATE_PRIMARY_ASYNC:
io_port = QXL_IO_CREATE_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_PRIMARY_ASYNC:
io_port = QXL_IO_DESTROY_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_SURFACE_ASYNC:
io_port = QXL_IO_DESTROY_SURFACE_WAIT;
goto async_common;
case QXL_IO_DESTROY_ALL_SURFACES_ASYNC:
io_port = QXL_IO_DESTROY_ALL_SURFACES;
goto async_common;
case QXL_IO_FLUSH_SURFACES_ASYNC:
async_common:
async = QXL_ASYNC;
qemu_mutex_lock(&d->async_lock);
if (d->current_async != QXL_UNDEFINED_IO) {
qxl_guest_bug(d, "%d async started before last (%d) complete",
io_port, d->current_async);
qemu_mutex_unlock(&d->async_lock);
return;
}
d->current_async = orig_io_port;
qemu_mutex_unlock(&d->async_lock);
dprint(d, 2, "start async %d (%"PRId64")\n", io_port, val);
break;
default:
break;
}
#endif
switch (io_port) {
case QXL_IO_UPDATE_AREA:
{
QXLRect update = d->ram->update_area;
qxl_spice_update_area(d, d->ram->update_surface,
&update, NULL, 0, 0, async);
break;
}
case QXL_IO_NOTIFY_CMD:
qemu_spice_wakeup(&d->ssd);
break;
case QXL_IO_NOTIFY_CURSOR:
qemu_spice_wakeup(&d->ssd);
break;
case QXL_IO_UPDATE_IRQ:
qxl_update_irq(d);
break;
case QXL_IO_NOTIFY_OOM:
if (!SPICE_RING_IS_EMPTY(&d->ram->release_ring)) {
break;
}
d->oom_running = 1;
qxl_spice_oom(d);
d->oom_running = 0;
break;
case QXL_IO_SET_MODE:
dprint(d, 1, "QXL_SET_MODE %d\n", (int)val);
qxl_set_mode(d, val, 0);
break;
case QXL_IO_LOG:
if (d->guestdebug) {
fprintf(stderr, "qxl/guest-%d: %" PRId64 ": %s", d->id,
qemu_get_clock_ns(vm_clock), d->ram->log_buf);
}
break;
case QXL_IO_RESET:
dprint(d, 1, "QXL_IO_RESET\n");
qxl_hard_reset(d, 0);
break;
case QXL_IO_MEMSLOT_ADD:
if (val >= NUM_MEMSLOTS) {
qxl_guest_bug(d, "QXL_IO_MEMSLOT_ADD: val out of range");
break;
}
if (d->guest_slots[val].active) {
qxl_guest_bug(d, "QXL_IO_MEMSLOT_ADD: memory slot already active");
break;
}
d->guest_slots[val].slot = d->ram->mem_slot;
qxl_add_memslot(d, val, 0, async);
break;
case QXL_IO_MEMSLOT_DEL:
if (val >= NUM_MEMSLOTS) {
qxl_guest_bug(d, "QXL_IO_MEMSLOT_DEL: val out of range");
break;
}
qxl_del_memslot(d, val);
break;
case QXL_IO_CREATE_PRIMARY:
if (val != 0) {
qxl_guest_bug(d, "QXL_IO_CREATE_PRIMARY (async=%d): val != 0",
async);
goto cancel_async;
}
dprint(d, 1, "QXL_IO_CREATE_PRIMARY async=%d\n", async);
d->guest_primary.surface = d->ram->create_surface;
qxl_create_guest_primary(d, 0, async);
break;
case QXL_IO_DESTROY_PRIMARY:
if (val != 0) {
qxl_guest_bug(d, "QXL_IO_DESTROY_PRIMARY (async=%d): val != 0",
async);
goto cancel_async;
}
dprint(d, 1, "QXL_IO_DESTROY_PRIMARY (async=%d) (%s)\n", async,
qxl_mode_to_string(d->mode));
if (!qxl_destroy_primary(d, async)) {
dprint(d, 1, "QXL_IO_DESTROY_PRIMARY_ASYNC in %s, ignored\n",
qxl_mode_to_string(d->mode));
goto cancel_async;
}
break;
case QXL_IO_DESTROY_SURFACE_WAIT:
if (val >= NUM_SURFACES) {
qxl_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
"%d >= NUM_SURFACES", async, val);
goto cancel_async;
}
qxl_spice_destroy_surface_wait(d, val, async);
break;
#if SPICE_INTERFACE_QXL_MINOR >= 1
case QXL_IO_FLUSH_RELEASE: {
QXLReleaseRing *ring = &d->ram->release_ring;
if (ring->prod - ring->cons + 1 == ring->num_items) {
fprintf(stderr,
"ERROR: no flush, full release ring [p%d,%dc]\n",
ring->prod, ring->cons);
}
qxl_push_free_res(d, 1 );
dprint(d, 1, "QXL_IO_FLUSH_RELEASE exit (%s, s#=%d, res#=%d,%p)\n",
qxl_mode_to_string(d->mode), d->guest_surfaces.count,
d->num_free_res, d->last_release);
break;
}
case QXL_IO_FLUSH_SURFACES_ASYNC:
dprint(d, 1, "QXL_IO_FLUSH_SURFACES_ASYNC"
" (%"PRId64") (%s, s#=%d, res#=%d)\n",
val, qxl_mode_to_string(d->mode), d->guest_surfaces.count,
d->num_free_res);
qxl_spice_flush_surfaces_async(d);
break;
#endif
case QXL_IO_DESTROY_ALL_SURFACES:
d->mode = QXL_MODE_UNDEFINED;
qxl_spice_destroy_surfaces(d, async);
break;
default:
fprintf(stderr, "%s: ioport=0x%x, abort()\n", __FUNCTION__, io_port);
abort();
}
return;
cancel_async:
#if SPICE_INTERFACE_QXL_MINOR >= 1
if (async) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
qemu_mutex_lock(&d->async_lock);
d->current_async = QXL_UNDEFINED_IO;
qemu_mutex_unlock(&d->async_lock);
}
#else
return;
#endif
}
| 1threat
|
Swift: saving UIImageView to Camera Roll : Even tough this sounds super simple, I got stuck on this because of how my app works.
I'm using Swift.
I have a UIImageView that loads an online image. On the app, I will have a button that gives the user a choice to export the image to Camera Roll.
Most solutions such as UIImageWriteToSavedPhotosAlbum don't work with UIImageView.
Should I first capture a UIImage from the UIImageView and then save to Camera Roll? How? Or can I save directly?
Thanks!
| 0debug
|
How to login to real time company hadoop cluster : I am new to hadoop environment . I was joined in a company and was given KT and required documents for project . They asked me to login into cluster and start work immediately. Can any one suggest steps in login
| 0debug
|
TCP android Class Cast Exception : Hi I am trying to send a custom list of objects from Client to server. I am getting a class cast exception. I am using Android studio emulator for my client and running my Server on Eclipse. I even wrote a test code to check to see if it works in eclipse and it does. But for some reason does not work on android. I am new to android
import java.io.Serializable;
import java.util.Arrays;
public class Document implements Serializable {
private static final long serialVersionUID = 1L;
String id;
String name;
String address;
String[] category;
float lattitude;
float longitude;
String city;
double stars;
double overallRating;
// String attributes[];
Review[] reviews;
public Document(String id, String name, String address, String[] category, float longitude, float lattitude,
String city, double stars, double overallRating, Review[] review) {
super();
this.id = id;
this.name = name;
this.address = address;
this.category = category;
this.longitude = longitude;
this.lattitude = lattitude;
this.city = city;
this.stars = stars;
this.overallRating = overallRating;
this.reviews = review;
}
@Override
public String toString() {
return "Document [id=" + id + ", name=" + name + ", address=" + address + ", category="
+ Arrays.toString(category) + ", lattitude=" + lattitude + ", longitude=" + longitude + ", city=" + city
+ ", stars=" + stars + "]";
}
}
import java.io.Serializable;
public class Review implements Serializable {
private static final long serialVersionUID = -1595783420656910821L;
double stars;
String review;
public Review(double stars, String review) {
this.stars = stars;
this.review = review;
}
}
//Part of the server
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.List;
public class CommunicatewithMobileDevice implements Runnable {
Socket conn;
private InvertedIndexA invertedIndex;
private BufferedReader br;
private ObjectOutputStream oos;
private PrintWriter pw;
public CommunicatewithMobileDevice(Socket sock, InvertedIndexA invertedIndex) {
conn = sock;
this.invertedIndex = invertedIndex;
try {
br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()), true);
} catch (IOException e) {
e.printStackTrace();
}
}
public void run() {
try {
String ip = br.readLine();
String input[] = br.readLine().split(" ");
System.out.println(ip + " " + input[0] + " " + input[1]);
List<Document> docs = invertedIndex.search(ip, Float.valueOf(input[0]), Float.valueOf(input[1]));
System.out.println(docs.size());
oos = new ObjectOutputStream(this.conn.getOutputStream());
oos.writeObject(docs);
oos.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//A singleton or a server
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class Singleton implements Runnable {
private ServerSocket conn;
private static InvertedIndexA invertedIndex = new InvertedIndexA(Helper.loadCategories());
private boolean isStopped = false;
private Singleton() {
}
public static InvertedIndexA getInstance() {
return invertedIndex;
}
public static void main(String args[]) {
new Thread(new Singleton()).start();
}
public void acceptsClients() {
try {
synchronized (this) {
conn = new ServerSocket(1503);
}
while (!isStopped()) {
Socket sock = conn.accept();
//System.out.println("Conn accepted");
new Thread(new CommunicatewithMobileDevice(sock, invertedIndex)).start();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private synchronized boolean isStopped() {
return this.isStopped;
}
public synchronized void stop() {
this.isStopped = true;
try {
this.conn.close();
} catch (IOException e) {
throw new RuntimeException("Error closing server", e);
}
}
@Override
public void run() {
acceptsClients();
}
}
//The android client or a part of it
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import android.widget.ListView;
import android.widget.TextView;
import android.content.Context;
public class ListOfResults extends AppCompatActivity {
CommunicateWithServer comm;
GPSTracker gps;
String message = "";
List<Document> docs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_of_results);
comm = new CommunicateWithServer();
Bundle bundle = getIntent().getExtras();
message = bundle.getString("message");
//new Communicate().execute();
new Thread(runnable).start();
}
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
Socket sock = new Socket("129.21.114.74", 1503);
PrintWriter pw = new PrintWriter(sock.getOutputStream(), true);
pw.println(message);
double latitude = 0;
double longitude = 0;
pw.println(new String(Double.valueOf(latitude) + " " + Double.valueOf(longitude)));
ObjectInputStream ois = new ObjectInputStream(sock.getInputStream());
docs = (List<Document>) ois.readObject();
BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
//Log.e("print the val",br.readLine());
//System.out.println(docs.size());
Log.e("size", Integer.toString(docs.size()));
} catch (IOException | ClassNotFoundException e) {
// TODO Auto-generated catch block
System.out.println("yeassass");
}
}
};
public void populate(String result) {
Log.e("here", "here");
DocumentAdapter documentAdapter = new DocumentAdapter(this, docs);
ListView listView = (ListView) findViewById(R.id.listView1);
listView.setAdapter(documentAdapter);
}
}
//This was a test program i wrote to test the server code. Works fine here
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.List;
public class Test implements Runnable {
public Test() {
// TODO Auto-generated constructor stub
}
public static void main(String args[]) {
Test test = new Test();
new Thread(test).start();
}
public void run() {
testOp();
}
private void testOp() {
try {
Socket sock = new Socket("localhost", 1503);
PrintWriter pw = new PrintWriter(sock.getOutputStream(), true);
String location = Helper.getLocation();
location = location.substring(location.lastIndexOf(") ") + 2);
String split[] = location.split(",");
pw.println("Chinese");
pw.println(new String(split[0] + " " + split[1]));
ObjectInputStream ois = new ObjectInputStream(sock.getInputStream());
List<Document> docs = (List<Document>) ois.readObject();
System.out.println(docs);
} catch (IOException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| 0debug
|
Shiny - Can dynamically generated buttons act as trigger for an event : <p>I have a shiny code that generates actions buttons from a numericInput and each of those actions buttons generate a plot when clicked using a observeEvent. The problem is that I don't know how to trigger an event with dynamically generated buttons. The workaround I used was to make a observeEvent for each button but if I generate more buttons than the obserEvents I created it won't work.</p>
<pre><code>library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Dynamic selectInput"),
dashboardSidebar(
sidebarMenu(
menuItemOutput("menuitem")
)
),
dashboardBody(
numericInput("go_btns_quant","Number of GO buttons",value = 1,min = 1,max = 10),
uiOutput("go_buttons"),
plotOutput("plot")
)
)
server <- function(input, output, session) {
output$menuitem <- renderMenu({
menuItem("Menu item", icon = icon("calendar"))
})
output$go_buttons <- renderUI({
buttons <- as.list(1:input$go_btns_quant)
buttons <- lapply(buttons, function(i)
fluidRow(
actionButton(paste0("go_btn",i),paste("Go",i))
)
)
})
#Can this observeEvents be triggerd dynamicly?
observeEvent(input[[paste0("go_btn",1)]],{output$plot <-renderPlot({hist(rnorm(100,4,1),breaks = 10)})})
observeEvent(input[[paste0("go_btn",2)]],{output$plot <- renderPlot({hist(rnorm(100,4,1),breaks = 50)})})
observeEvent(input[[paste0("go_btn",3)]],{output$plot <- renderPlot({hist(rnorm(100,4,1),breaks = 100)})})
observeEvent(input[[paste0("go_btn",4)]],{output$plot <- renderPlot({hist(rnorm(100,4,1),breaks = 200)})})
observeEvent(input[[paste0("go_btn",5)]],{output$plot <- renderPlot({hist(rnorm(100,4,1),breaks = 500)})})
}
shinyApp(ui, server)
</code></pre>
| 0debug
|
static void vapic_write(void *opaque, target_phys_addr_t addr, uint64_t data,
unsigned int size)
{
CPUX86State *env = cpu_single_env;
target_phys_addr_t rom_paddr;
VAPICROMState *s = opaque;
cpu_synchronize_state(env);
switch (size) {
case 2:
if (s->state == VAPIC_INACTIVE) {
rom_paddr = (env->segs[R_CS].base + env->eip) & ROM_BLOCK_MASK;
s->rom_state_paddr = rom_paddr + data;
s->state = VAPIC_STANDBY;
}
if (vapic_prepare(s) < 0) {
s->state = VAPIC_INACTIVE;
break;
}
break;
case 1:
if (kvm_enabled()) {
pause_all_vcpus();
patch_byte(env, env->eip - 2, 0x66);
patch_byte(env, env->eip - 1, 0x90);
resume_all_vcpus();
}
if (s->state == VAPIC_ACTIVE) {
break;
}
if (update_rom_mapping(s, env, env->eip) < 0) {
break;
}
if (find_real_tpr_addr(s, env) < 0) {
break;
}
vapic_enable(s, env);
break;
default:
case 4:
if (!kvm_irqchip_in_kernel()) {
apic_poll_irq(env->apic_state);
}
break;
}
}
| 1threat
|
void do_divwo (void)
{
if (likely(!((Ts0 == INT32_MIN && Ts1 == -1) || Ts1 == 0))) {
xer_ov = 0;
T0 = (Ts0 / Ts1);
} else {
xer_so = 1;
xer_ov = 1;
T0 = (-1) * ((uint32_t)T0 >> 31);
}
}
| 1threat
|
Azure Web Apps : How to access specific instance directly via URL? : <p>We have deployed our Sitecore CMS on to Azure Web Apps and having some indexing issues or similar. i.e. the updated changes is reflected for some users and not for all.</p>
<p>We have a scale turned on to 2. </p>
<p>I would like to troubleshoot by accessing the instance 1 and 2 directly via URL to make sure both instances have index built 100%. </p>
<p>How do I access each Azure Web Role instances directly via URL?</p>
<p>Thanks.</p>
| 0debug
|
How to concatenate string in a for loop using scanner? : <p>package exercises;</p>
<p>import java.util.Scanner;</p>
<p>public class SentenceBuilder {</p>
<pre><code>public static void main(String[] args) {
final int MAX_WORDS = 5;
Scanner scan = new Scanner(System.in);
String word ="";
for (int i = 0; i < MAX_WORDS; i++){
System.out.println("Please enter word "+(i+1)+" of "+MAX_WORDS);
word = scan.nextLine();
}
System.out.println(word);// im stuck on how to concatenate the result
}
</code></pre>
<p>}</p>
| 0debug
|
static void encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *parent, int stride, int orientation){
const int w= b->width;
const int h= b->height;
int x, y;
if(1){
int run=0;
int runs[w*h];
int run_index=0;
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int v, p=0;
int l=0, lt=0, t=0, rt=0;
v= src[x + y*stride];
if(y){
t= src[x + (y-1)*stride];
if(x){
lt= src[x - 1 + (y-1)*stride];
}
if(x + 1 < w){
rt= src[x + 1 + (y-1)*stride];
}
}
if(x){
l= src[x - 1 + y*stride];
}
if(parent){
int px= x>>1;
int py= y>>1;
if(px<b->parent->width && py<b->parent->height)
p= parent[px + py*2*stride];
}
if(!(l|lt|t|rt|p)){
if(v){
runs[run_index++]= run;
run=0;
}else{
run++;
}
}
}
}
runs[run_index++]= run;
run_index=0;
run= runs[run_index++];
put_symbol2(&s->c, b->state[1], run, 3);
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int v, p=0;
int l=0, lt=0, t=0, rt=0;
v= src[x + y*stride];
if(y){
t= src[x + (y-1)*stride];
if(x){
lt= src[x - 1 + (y-1)*stride];
}
if(x + 1 < w){
rt= src[x + 1 + (y-1)*stride];
}
}
if(x){
l= src[x - 1 + y*stride];
}
if(parent){
int px= x>>1;
int py= y>>1;
if(px<b->parent->width && py<b->parent->height)
p= parent[px + py*2*stride];
}
if(l|lt|t|rt|p){
int context= av_log2(3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
put_rac(&s->c, &b->state[0][context], !!v);
}else{
if(!run){
run= runs[run_index++];
put_symbol2(&s->c, b->state[1], run, 3);
assert(v);
}else{
run--;
assert(!v);
}
}
if(v){
int context= av_log2(3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4);
put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]], v<0);
}
}
}
}
}
| 1threat
|
Did rewriting Roslyn in C# make it slower? : <p>I read this article: <a href="https://medium.com/microsoft-open-source-stories/how-microsoft-rewrote-its-c-compiler-in-c-and-made-it-open-source-4ebed5646f98" rel="nofollow noreferrer">https://medium.com/microsoft-open-source-stories/how-microsoft-rewrote-its-c-compiler-in-c-and-made-it-open-source-4ebed5646f98</a></p>
<p>Since C# has a built in garbage collector, is Roslyn slower than the previous compiler which was written in C++? Did they perform any benchmarks?</p>
| 0debug
|
ImmutableCollections SetN implementation detail : <p>I have sort of a hard time understanding an implementation detail from java-9 <code>ImmutableCollections.SetN</code>; specifically why is there a need to increase the inner array twice.</p>
<p>Suppose you do this:</p>
<pre><code>Set.of(1,2,3,4) // 4 elements, but internal array is 8
</code></pre>
<p>More exactly I perfectly understand why this is done (a double expansion) in case of a <code>HashMap</code> - where you never (almost) want the <code>load_factor</code> to be one. A value of <code>!=1</code> improves search time as entries are better dispersed to buckets for example.</p>
<p>But in case of an <em>immutable Set</em> - I can't really tell. Especially since the way an index of the internal array is chosen.</p>
<p>Let me provide some details. First how the index is searched:</p>
<pre><code> int idx = Math.floorMod(pe.hashCode() ^ SALT, elements.length);
</code></pre>
<p><code>pe</code> is the actual value we put in the set. <code>SALT</code> is just 32 bits generated at start-up, once per <code>JVM</code> (this is the actual randomization if you want). <code>elements.length</code> for our example is <code>8</code> (4 elements, but 8 here - double the size).</p>
<p>This expression is like a <em>negative-safe modulo operation</em>. Notice that the same logical thing is done in <code>HashMap</code> for example (<code>(n - 1) & hash</code>) when the bucket is chosen. </p>
<p>So if <code>elements.length is 8</code> for our case, then this expression will return any positive value that is less than 8 <code>(0, 1, 2, 3, 4, 5, 6, 7)</code>.</p>
<p>Now the rest of the method:</p>
<pre><code> while (true) {
E ee = elements[idx];
if (ee == null) {
return -idx - 1;
} else if (pe.equals(ee)) {
return idx;
} else if (++idx == elements.length) {
idx = 0;
}
}
</code></pre>
<p>Let's break it down:</p>
<pre><code>if (ee == null) {
return -idx - 1;
</code></pre>
<p>This is good, it means that the current slot in the array is empty - we can put our value there.</p>
<pre><code>} else if (pe.equals(ee)) {
return idx;
</code></pre>
<p>This is bad - slot is occupied and the already in place entry is equal to the one we want to put. <code>Set</code>s can't have duplicate elements - so an Exception is later thrown.</p>
<pre><code> else if (++idx == elements.length) {
idx = 0;
}
</code></pre>
<p>This means that this slot is occupied (hash collision), but elements are not equal. In a <code>HashMap</code> this entry would be put to the same bucket as a <code>LinkedNode</code> or <code>TreeNode</code> - but not the case here. </p>
<p>So <code>index</code> is incremented and the next position is tried (with the small caveat that it moves in a circular way when it reaches the last position).</p>
<p>And here is the question: if nothing too fancy (unless I'm missing something) is being done when searching the index, why is there a need to have an array twice as big? Or why the function was not written like this:</p>
<pre><code>int idx = Math.floorMod(pe.hashCode() ^ SALT, input.length);
// notice the diff elements.length (8) and not input.length (4)
</code></pre>
| 0debug
|
static char *assign_name(NetClientState *nc1, const char *model)
{
NetClientState *nc;
char buf[256];
int id = 0;
QTAILQ_FOREACH(nc, &net_clients, next) {
if (nc == nc1) {
continue;
}
if (strcmp(nc->model, model) == 0 &&
net_hub_id_for_client(nc, NULL) == 0) {
id++;
}
}
snprintf(buf, sizeof(buf), "%s.%d", model, id);
return g_strdup(buf);
}
| 1threat
|
void arm_cpu_do_interrupt(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
uint32_t moe;
assert(!IS_M(env));
arm_log_exception(cs->exception_index);
if (arm_is_psci_call(cpu, cs->exception_index)) {
arm_handle_psci_call(cpu);
qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n");
return;
}
switch (env->exception.syndrome >> ARM_EL_EC_SHIFT) {
case EC_BREAKPOINT:
case EC_BREAKPOINT_SAME_EL:
moe = 1;
break;
case EC_WATCHPOINT:
case EC_WATCHPOINT_SAME_EL:
moe = 10;
break;
case EC_AA32_BKPT:
moe = 3;
break;
case EC_VECTORCATCH:
moe = 5;
break;
default:
moe = 0;
break;
}
if (moe) {
env->cp15.mdscr_el1 = deposit64(env->cp15.mdscr_el1, 2, 4, moe);
}
switch (cs->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
if (env->thumb) {
mask = arm_lduw_code(env, env->regs[15] - 2, env->bswap_code)
& 0xff;
} else {
mask = arm_ldl_code(env, env->regs[15] - 4, env->bswap_code)
& 0xffffff;
}
if (((mask == 0x123456 && !env->thumb)
|| (mask == 0xab && env->thumb))
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[0] = do_arm_semihosting(env);
qemu_log_mask(CPU_LOG_INT, "...handled as semihosting call\n");
return;
}
}
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
if (env->thumb && semihosting_enabled) {
mask = arm_lduw_code(env, env->regs[15], env->bswap_code) & 0xff;
if (mask == 0xab
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[15] += 2;
env->regs[0] = do_arm_semihosting(env);
qemu_log_mask(CPU_LOG_INT, "...handled as semihosting call\n");
return;
}
}
env->exception.fsr = 2;
case EXCP_PREFETCH_ABORT:
env->cp15.ifsr_el2 = env->exception.fsr;
env->cp15.far_el[1] = deposit64(env->cp15.far_el[1], 32, 32,
env->exception.vaddress);
qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x IFAR 0x%x\n",
env->cp15.ifsr_el2, (uint32_t)env->exception.vaddress);
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
env->cp15.esr_el[1] = env->exception.fsr;
env->cp15.far_el[1] = deposit64(env->cp15.far_el[1], 0, 32,
env->exception.vaddress);
qemu_log_mask(CPU_LOG_INT, "...with DFSR 0x%x DFAR 0x%x\n",
(uint32_t)env->cp15.esr_el[1],
(uint32_t)env->exception.vaddress);
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
if (env->cp15.scr_el3 & SCR_IRQ) {
new_mode = ARM_CPU_MODE_MON;
mask |= CPSR_F;
}
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
if (env->cp15.scr_el3 & SCR_FIQ) {
new_mode = ARM_CPU_MODE_MON;
}
offset = 4;
break;
case EXCP_SMC:
new_mode = ARM_CPU_MODE_MON;
addr = 0x08;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 0;
break;
default:
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
return;
}
if (new_mode == ARM_CPU_MODE_MON) {
addr += env->cp15.mvbar;
} else if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
addr += 0xffff0000;
} else {
addr += env->cp15.vbar_el[1];
}
if ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_MON) {
env->cp15.scr_el3 &= ~SCR_NS;
}
switch_mode (env, new_mode);
env->uncached_cpsr &= ~PSTATE_SS;
env->spsr = cpsr_read(env);
env->condexec_bits = 0;
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->daif |= mask;
if (arm_feature(env, ARM_FEATURE_V4T)) {
env->thumb = (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_TE) != 0;
}
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| 1threat
|
Detect link in string and insert anchor tag in Javascript : <p>I have a string like this:</p>
<pre><code>let string = "This is some text, this [should be a link](https://www.google.com.ar)";
</code></pre>
<p>like markdown, but I don't want to use a whole markdown library cause the links are the only things I should look for.</p>
<p>this string above should generate this:</p>
<pre><code>"This is some text, this <a href="https://www.google.com.ar" target="_blank">should be a link</a>"
</code></pre>
<p>Edit: to be more precise, I don't want to use a markdown parse because I don't to replace all the other markdown stuff, just the links.</p>
| 0debug
|
Problem while summing good answes on online quiz system : I'm trying to build an online quiz system for a driving school.
They asked me to make available that questions and answers will be added on database. I did make it but the problem is that I'm having a hard time knowing if the answers are correct.
The code I'm using to generate the form is this:
$sql = mysql_query("SELECT * FROM questions ORDER BY question_id ASC");
while($row = mysql_fetch_array($sql)){
echo '
<section>
<h1>'.$row['question'].'?</h4>
</br> <hr> </br>
<div class="row">
<div class="col-sm-4 foto pb-2">
<img src="" style="max-width:100%;height: auto;" >
</div>
<div class="col-12 col-sm-8">
<div class="pergjigjet mb-2 pl-2 pr-2" style="padding-left: .5rem!important;padding-right: .5rem!important;margin-bottom: .5rem!important;">
<div class="pergjigje">
<label><input type="checkbox" name="q_'.$row['question_id'].'_a_1" value="1"> '.$row['answer1'].'.</label>
</div>
<div class="pergjigje">
<label><input type="checkbox" name="q_'.$row['question_id'].'_a_2" value="1"> '.$row['answer2'].'.</label>
</div>
<div class="pergjigje"><label>
<input type="checkbox" name="q_'.$row['question_id'].'_a_3" value="1"> '.$row['answere'].'.</label>
</div>
</div>
</div>
</section>
The quiz has total 30 questions and max 3 correct answers.
If you don't select all the right answers it needs to be wrong. It means that you don't get points if you haven't selected the right answers for the question.
Array of the post data is this.
array(4) {
["q_1_a_1"]=>
string(1) "1"
["q_1_a_2"]=>
string(1) "1"
["q_2_a_1"]=>
string(1) "1"
["q_2_a_2"]=>
string(1) "1"
}
The table is this,
id, question_id, exam_id, question, answer1, answer2, answer3, CorrectAnswers, QuestionPoints
I store the correct answers in this format
1,2
P.S the client asked me to use mysql, not mysqli or PDO
| 0debug
|
static int i2c_slave_post_load(void *opaque, int version_id)
{
I2CSlave *dev = opaque;
I2CBus *bus;
I2CNode *node;
bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
if ((bus->saved_address == dev->address) || (bus->broadcast)) {
node = g_malloc(sizeof(struct I2CNode));
node->elt = dev;
QLIST_INSERT_HEAD(&bus->current_devs, node, next);
}
return 0;
}
| 1threat
|
How to show object values in html persistently. : Let suppose I am having an object like y={1,2,3}.I want to display its value using angular in html.
So what I did is:
for(var i=0;i<y.length;i++){
$scope.data=y[i]; //transferring
}
and in my html it is written:
<html>
{{data}}
</html>
Now I know that it is showing the last value(3) because the data value is updated at the end and since the last value of the loop is 3 it sets the 3 in html.So my question is how can we fix this problem?
| 0debug
|
Using VBA or Excel to compare four columns of data : <p>I have one Excel worksheet with 4 columns of data. Column A and B show the name of the file and the page numbers and the data was retrieved awhile back. C and D show the name and pages but the data was retrieved this week and differs from the original. Some of the files now have more page numbers and some stayed the same. I want to find a way to either create an Excel formula or use VBA to give me the files where the page differs, so it would need to keep A and B together and then search C and D for the file name and see if the page numbers match up. There are over 9000 rows.</p>
| 0debug
|
Why do most asyncio examples use loop.run_until_complete()? : <p>I was going through the Python documentation for <code>asyncio</code> and I'm wondering why most examples use <code>loop.run_until_complete()</code> as opposed to <code>Asyncio.ensure_future()</code>.</p>
<p>For example: <a href="https://docs.python.org/dev/library/asyncio-task.html" rel="noreferrer">https://docs.python.org/dev/library/asyncio-task.html</a></p>
<p>It seems <code>ensure_future</code> would be a much better way to demonstrate the advantages of non-blocking functions. <code>run_until_complete</code> on the other hand, blocks the loop like synchronous functions do. </p>
<p>This makes me feel like I should be using <code>run_until_complete</code> instead of a combination of <code>ensure_future</code>with <code>loop.run_forever()</code> to run multiple co-routines concurrently.</p>
| 0debug
|
static int ast_read_header(AVFormatContext *s)
{
int codec;
AVStream *st;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avio_skip(s->pb, 8);
codec = avio_rb16(s->pb);
switch (codec) {
case 1:
st->codec->codec_id = AV_CODEC_ID_PCM_S16BE_PLANAR;
break;
default:
av_log(s, AV_LOG_ERROR, "unsupported codec %d\n", codec);
}
avio_skip(s->pb, 2);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channels = avio_rb16(s->pb);
if (!st->codec->channels)
return AVERROR_INVALIDDATA;
if (st->codec->channels == 2)
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
else if (st->codec->channels == 4)
st->codec->channel_layout = AV_CH_LAYOUT_4POINT0;
avio_skip(s->pb, 2);
st->codec->sample_rate = avio_rb32(s->pb);
if (st->codec->sample_rate <= 0)
return AVERROR_INVALIDDATA;
st->start_time = 0;
st->duration = avio_rb32(s->pb);
avio_skip(s->pb, 40);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
return 0;
}
| 1threat
|
Find duplicates in a table using LINQ : I am trying to find people with same name and surname in one table and so far I have written this LINQ query. This query gives me a cross join result. Can someone help me to remove the similar set of results, please?
For eg
if the result is
1,2
1,3
2,1
2,3
3,1
3,2
I want the result to be 1,2
1,3
2,3
var query = from ori in db.People
from dup in db.People
select new DuplicateDataSet
{
ActiveMember = ori,
DuplicateMember = dup
};
if (!string.IsNullOrEmpty(memberFirstName))
query = query.Where(w => w.ActiveMember.GivenName.Trim() == memberFirstName && w.DuplicateMember.GivenName.Trim() == memberFirstName );
if (!string.IsNullOrEmpty(memberSurname))
query = query.Where(w => w.ActiveMember.Surname.Trim() == memberSurname && w.DuplicateMember.Surname.Trim() == memberSurname);
query = query.Where(w => w.ActiveMember.PersonID != w.DuplicateMember.PersonID && w.ActiveMember.MemberID != w.DuplicateMember.MemberID);
newList = query.Take(100).ToList();
| 0debug
|
static void ds1338_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
k->init = ds1338_init;
k->event = ds1338_event;
k->recv = ds1338_recv;
k->send = ds1338_send;
dc->reset = ds1338_reset;
dc->vmsd = &vmstate_ds1338;
}
| 1threat
|
static void output_audio_block(AC3EncodeContext *s, int blk)
{
int ch, i, baie, bnd, got_cpl, ch0;
AC3Block *block = &s->blocks[blk];
if (!s->eac3) {
for (ch = 0; ch < s->fbw_channels; ch++)
put_bits(&s->pb, 1, 0);
}
if (!s->eac3) {
for (ch = 0; ch < s->fbw_channels; ch++)
put_bits(&s->pb, 1, 1);
}
put_bits(&s->pb, 1, 0);
if (s->eac3)
put_bits(&s->pb, 1, 0);
if (!s->eac3)
put_bits(&s->pb, 1, block->new_cpl_strategy);
if (block->new_cpl_strategy) {
if (!s->eac3)
put_bits(&s->pb, 1, block->cpl_in_use);
if (block->cpl_in_use) {
int start_sub, end_sub;
if (s->eac3)
put_bits(&s->pb, 1, 0);
if (!s->eac3 || s->channel_mode != AC3_CHMODE_STEREO) {
for (ch = 1; ch <= s->fbw_channels; ch++)
put_bits(&s->pb, 1, block->channel_in_cpl[ch]);
}
if (s->channel_mode == AC3_CHMODE_STEREO)
put_bits(&s->pb, 1, 0);
start_sub = (s->start_freq[CPL_CH] - 37) / 12;
end_sub = (s->cpl_end_freq - 37) / 12;
put_bits(&s->pb, 4, start_sub);
put_bits(&s->pb, 4, end_sub - 3);
if (s->eac3) {
put_bits(&s->pb, 1, 0);
} else {
for (bnd = start_sub+1; bnd < end_sub; bnd++)
put_bits(&s->pb, 1, ff_eac3_default_cpl_band_struct[bnd]);
}
}
}
if (block->cpl_in_use) {
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (block->channel_in_cpl[ch]) {
if (!s->eac3 || block->new_cpl_coords[ch] != 2)
put_bits(&s->pb, 1, block->new_cpl_coords[ch]);
if (block->new_cpl_coords[ch]) {
put_bits(&s->pb, 2, block->cpl_master_exp[ch]);
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
put_bits(&s->pb, 4, block->cpl_coord_exp [ch][bnd]);
put_bits(&s->pb, 4, block->cpl_coord_mant[ch][bnd]);
}
}
}
}
}
if (s->channel_mode == AC3_CHMODE_STEREO) {
if (!s->eac3 || blk > 0)
put_bits(&s->pb, 1, block->new_rematrixing_strategy);
if (block->new_rematrixing_strategy) {
for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++)
put_bits(&s->pb, 1, block->rematrixing_flags[bnd]);
}
}
if (!s->eac3) {
for (ch = !block->cpl_in_use; ch <= s->fbw_channels; ch++)
put_bits(&s->pb, 2, s->exp_strategy[ch][blk]);
if (s->lfe_on)
put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]);
}
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (s->exp_strategy[ch][blk] != EXP_REUSE && !block->channel_in_cpl[ch])
put_bits(&s->pb, 6, s->bandwidth_code);
}
for (ch = !block->cpl_in_use; ch <= s->channels; ch++) {
int nb_groups;
int cpl = (ch == CPL_CH);
if (s->exp_strategy[ch][blk] == EXP_REUSE)
continue;
put_bits(&s->pb, 4, block->grouped_exp[ch][0] >> cpl);
nb_groups = exponent_group_tab[cpl][s->exp_strategy[ch][blk]-1][block->end_freq[ch]-s->start_freq[ch]];
for (i = 1; i <= nb_groups; i++)
put_bits(&s->pb, 7, block->grouped_exp[ch][i]);
if (ch != s->lfe_channel && !cpl)
put_bits(&s->pb, 2, 0);
}
if (!s->eac3) {
baie = (blk == 0);
put_bits(&s->pb, 1, baie);
if (baie) {
put_bits(&s->pb, 2, s->slow_decay_code);
put_bits(&s->pb, 2, s->fast_decay_code);
put_bits(&s->pb, 2, s->slow_gain_code);
put_bits(&s->pb, 2, s->db_per_bit_code);
put_bits(&s->pb, 3, s->floor_code);
}
}
if (!s->eac3) {
put_bits(&s->pb, 1, block->new_snr_offsets);
if (block->new_snr_offsets) {
put_bits(&s->pb, 6, s->coarse_snr_offset);
for (ch = !block->cpl_in_use; ch <= s->channels; ch++) {
put_bits(&s->pb, 4, s->fine_snr_offset[ch]);
put_bits(&s->pb, 3, s->fast_gain_code[ch]);
}
}
} else {
put_bits(&s->pb, 1, 0);
}
if (block->cpl_in_use) {
if (!s->eac3 || block->new_cpl_leak != 2)
put_bits(&s->pb, 1, block->new_cpl_leak);
if (block->new_cpl_leak) {
put_bits(&s->pb, 3, s->bit_alloc.cpl_fast_leak);
put_bits(&s->pb, 3, s->bit_alloc.cpl_slow_leak);
}
}
if (!s->eac3) {
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
}
got_cpl = !block->cpl_in_use;
for (ch = 1; ch <= s->channels; ch++) {
int b, q;
if (!got_cpl && ch > 1 && block->channel_in_cpl[ch-1]) {
ch0 = ch - 1;
ch = CPL_CH;
got_cpl = 1;
}
for (i = s->start_freq[ch]; i < block->end_freq[ch]; i++) {
q = block->qmant[ch][i];
b = s->ref_bap[ch][blk][i];
switch (b) {
case 0: break;
case 1: if (q != 128) put_bits (&s->pb, 5, q); break;
case 2: if (q != 128) put_bits (&s->pb, 7, q); break;
case 3: put_sbits(&s->pb, 3, q); break;
case 4: if (q != 128) put_bits (&s->pb, 7, q); break;
case 14: put_sbits(&s->pb, 14, q); break;
case 15: put_sbits(&s->pb, 16, q); break;
default: put_sbits(&s->pb, b-1, q); break;
}
}
if (ch == CPL_CH)
ch = ch0;
}
}
| 1threat
|
React-native android ignores navigator.geolocation.getCurrentPosition : <p>I'm trying to use <code>navigator.geolocation.getCurrentPosition</code> on my Android device (Philips Xenium). It works absolutely ok in iphone and genimotion simulator.<br>
<code>navigator.geolocation.getCurrentPosition</code> returns absolutely nothing - no errors, no success.
However, if I turn off geolocation service in my smartphone, it returns <code>No available location provider</code>.</p>
<p>Also, <code>navigator.geolocation.watchPosition</code> works fine.</p>
| 0debug
|
bool runstate_needs_reset(void)
{
return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
runstate_check(RUN_STATE_SHUTDOWN) ||
runstate_check(RUN_STATE_GUEST_PANICKED);
}
| 1threat
|
ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
AVStream *st, RMStream *ast, int len, AVPacket *pkt,
int *seq, int *flags, int64_t *timestamp)
{
RMDemuxContext *rm = s->priv_data;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
rm->current_stream= st->id;
if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len))
return -1;
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
if ((st->codec->codec_id == CODEC_ID_RA_288) ||
(st->codec->codec_id == CODEC_ID_COOK) ||
(st->codec->codec_id == CODEC_ID_ATRAC3) ||
(st->codec->codec_id == CODEC_ID_SIPR)) {
int x;
int sps = ast->sub_packet_size;
int cfs = ast->coded_framesize;
int h = ast->sub_packet_h;
int y = ast->sub_packet_cnt;
int w = ast->audio_framesize;
if (*flags & 2)
y = ast->sub_packet_cnt = 0;
if (!y)
ast->audiotimestamp = *timestamp;
switch(st->codec->codec_id) {
case CODEC_ID_RA_288:
for (x = 0; x < h/2; x++)
get_buffer(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
break;
case CODEC_ID_ATRAC3:
case CODEC_ID_COOK:
for (x = 0; x < w/sps; x++)
get_buffer(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
break;
}
if (++(ast->sub_packet_cnt) < h)
return -1;
else {
ast->sub_packet_cnt = 0;
rm->audio_stream_num = st->index;
rm->audio_pkt_cnt = h * w / st->codec->block_align - 1;
av_new_packet(pkt, st->codec->block_align);
memcpy(pkt->data, ast->pkt.data, st->codec->block_align);
*timestamp = ast->audiotimestamp;
*flags = 2;
}
} else if (st->codec->codec_id == CODEC_ID_AAC) {
int x;
rm->audio_stream_num = st->index;
ast->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4;
if (ast->sub_packet_cnt) {
for (x = 0; x < ast->sub_packet_cnt; x++)
ast->sub_packet_lengths[x] = get_be16(pb);
rm->audio_pkt_cnt = ast->sub_packet_cnt - 1;
av_get_packet(pb, pkt, ast->sub_packet_lengths[0]);
*flags = 2;
}
} else {
av_get_packet(pb, pkt, len);
rm_ac3_swap_bytes(st, pkt);
}
} else
av_get_packet(pb, pkt, len);
if( (st->discard >= AVDISCARD_NONKEY && !(*flags&2))
|| st->discard >= AVDISCARD_ALL){
av_free_packet(pkt);
return -1;
}
pkt->stream_index = st->index;
#if 0
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->codec->codec_id == CODEC_ID_RV20){
int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
seq |= (*timestamp&~0x3FFF);
if(seq - *timestamp > 0x2000) seq -= 0x4000;
if(seq - *timestamp < -0x2000) seq += 0x4000;
}
}
#endif
pkt->pts= *timestamp;
if (*flags & 2)
pkt->flags |= PKT_FLAG_KEY;
return st->codec->codec_type == CODEC_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
}
| 1threat
|
void dsputil_init_ppc(void)
{
#if HAVE_ALTIVEC
if (has_altivec()) {
pix_abs16x16 = pix_abs16x16_altivec;
pix_abs8x8 = pix_abs8x8_altivec;
pix_sum = pix_sum_altivec;
diff_pixels = diff_pixels_altivec;
get_pixels = get_pixels_altivec;
} else
#endif
{
}
}
| 1threat
|
protobuf vs gRPC : <p>I try to understand protobuf and gRPC and how I can use both. Could you help me understand the following:</p>
<ul>
<li>Considering the OSI model what is were, for example is Protobuf at layer 4?</li>
<li>Thinking through a message transfer how is the "flow" what is gRPC doing what protobuf misses?</li>
<li>If the sender uses protobuf can the server use gRPC or does gRPC add something which only a gRPC client can deliver?</li>
<li>If gRPC can make synchron and asynchron communication possible, Protobuf is just for the marshalling and therefor does not have anything to do with state - true or false?</li>
<li>Can I use gRPC in a frontend application communicating instead of REST or GraphQL?</li>
</ul>
<p>I already know - or assume I do - that:</p>
<p><a href="https://developers.google.com/protocol-buffers/docs/reference/overview" rel="noreferrer">Protobuf</a></p>
<ul>
<li>Binary protocol for data interchange</li>
<li>Designed by Google</li>
<li>Uses generated "Struct" like description at client and server to un-/-marshall message</li>
</ul>
<p><a href="https://grpc.io/docs/guides/" rel="noreferrer">gRPC</a></p>
<ul>
<li>Uses protobuf (v3)</li>
<li>Again from Google</li>
<li>Framework for RPC calls</li>
<li>Makes use of HTTP/2 as well</li>
<li>Synchron and asynchron communication possible</li>
</ul>
<p>I again assume its an easy question for someone already using the technology. I still would thank you to be patient with me and help me out. I would also be really thankful for any network deep dive of the technologies.</p>
| 0debug
|
What is the difference between airflow trigger rule "all_done" and "all_success"? : <p>One of the requirement in the workflow I am working on is to wait for some event to happen for given time, if it does not happen mark the task as failed still the downstream task should be executed.</p>
<p>I am wondering if "all_done" means all the dependency tasks are done no matter if they have succeeded or not.</p>
| 0debug
|
Custom markers icons not displayed on android : <p>I have this code : </p>
<pre><code>this.service.getListe(data).forEach((data: any) => {
const marker: Marker = this.map.addMarkerSync(data);
marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params) => {
this.click(params);
});
});
</code></pre>
<p>Now the <code>getListe()</code> looks like : </p>
<pre><code>getListe(merchants: any) {
const Liste: BaseArrayClass<any> = new BaseArrayClass<any>();
merchants.map(item => {
Liste.push({
title: item.name,
animation: 'DROP',
position: {
lat: item.lat,
lng: item.long
},
icon: 'http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/24/Number-1-icon.png',
disableAutoPan: true
});
});
return Markers;
}
</code></pre>
<p>I tried and like this : </p>
<pre><code>icon: {
url: 'http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/24/Number-1-icon.png'
}
</code></pre>
<p>But the same behaviour, the problem is that on emulator and on real device the icon is not changing. On browser mode I have for markers the correct icon that I indicate in BaseArrayClass, but on emulator I have default icon. Have you an idea about that ? </p>
| 0debug
|
Windows 10 - Username with whitespace and PATH : <p>Upon installing Windows 10 I created my admin user as <code>Miha Šušteršič</code>. Now when I install programs that need to modify the environment variable PATH, most of them don't get added. For instance this happens with MongoDB and Git, but npm got added normally.</p>
<p>I think this is an issue with the whitespace in the path to the variables. I tried renaming my username to <code>M.Sustersic</code>, but the system folder Users\Miha Šušteršič\ did not get updated.</p>
<p>Is there a way for me to change this folder name automatically (so the rest of the app dependencies on \Users\Miha Šušteršič\AppData don't get bugged) or do I need to reinstall windows?</p>
<p>Is there something else I am missing here? I tried adding the dependencies on my own, but nothing worked so far.</p>
<p>Thanks for the help</p>
| 0debug
|
Symfony 3 createForm with construct parameters : <p>Since Symfony 2.8, you can only pass the FQCN into the controller createForm method. So, my question is, how do I pass construct parameters into the form class construct when I create the form in the controller?</p>
<p>< Symfony 2.8 I could do (MyController.php):</p>
<pre><code>$this->createForm(new MyForm($arg1, $arg2));
</code></pre>
<p>Symfony 2.8+ I can only do (MyController.php):</p>
<pre><code>$this->createForm(MyForm::class);
</code></pre>
<p>So how can I pass in my construct arguments? These arguments are provided in the controller actions so I can't use the "Forms as services" method...</p>
| 0debug
|
is_vlan_packet(E1000State *s, const uint8_t *buf)
{
return (be16_to_cpup((uint16_t *)(buf + 12)) ==
le16_to_cpup((uint16_t *)(s->mac_reg + VET)));
}
| 1threat
|
static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale){
int v;
int i=0;
uint8_t state[CONTEXT_SIZE];
memset(state, 128, sizeof(state));
for(v=0; i<128 ; v++){
int len= get_symbol(c, state, 0) + 1;
if(len + i > 128) return -1;
while(len--){
quant_table[i] = scale*v;
i++;
}
}
for(i=1; i<128; i++){
quant_table[256-i]= -quant_table[i];
}
quant_table[128]= -quant_table[127];
return 2*v - 1;
}
| 1threat
|
static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1,
TCGv arg2, int add_ca, int compute_ca,
int compute_ov)
{
TCGv t0, t1;
if ((!compute_ca && !compute_ov) ||
(!TCGV_EQUAL(ret, arg1) && !TCGV_EQUAL(ret, arg2))) {
t0 = ret;
} else {
t0 = tcg_temp_local_new();
}
if (add_ca) {
t1 = tcg_temp_local_new();
tcg_gen_mov_tl(t1, cpu_ca);
} else {
TCGV_UNUSED(t1);
}
if (compute_ca) {
tcg_gen_movi_tl(cpu_ca, 0);
}
if (compute_ov) {
tcg_gen_movi_tl(cpu_ov, 0);
}
if (add_ca) {
tcg_gen_not_tl(t0, arg1);
tcg_gen_add_tl(t0, t0, arg2);
gen_op_arith_compute_ca(ctx, t0, arg2, 0);
tcg_gen_add_tl(t0, t0, t1);
gen_op_arith_compute_ca(ctx, t0, t1, 0);
tcg_temp_free(t1);
} else {
tcg_gen_sub_tl(t0, arg2, arg1);
if (compute_ca) {
gen_op_arith_compute_ca(ctx, t0, arg2, 1);
}
}
if (compute_ov) {
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);
}
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, t0);
if (!TCGV_EQUAL(t0, ret)) {
tcg_gen_mov_tl(ret, t0);
tcg_temp_free(t0);
}
}
| 1threat
|
def cummulative_sum(test_list):
res = sum(map(sum, test_list))
return (res)
| 0debug
|
static void swap_channel_layouts_on_filter(AVFilterContext *filter)
{
AVFilterLink *link = NULL;
int i, j, k;
for (i = 0; i < filter->nb_inputs; i++) {
link = filter->inputs[i];
if (link->type == AVMEDIA_TYPE_AUDIO &&
link->out_channel_layouts->nb_channel_layouts == 1)
break;
}
if (i == filter->nb_inputs)
return;
for (i = 0; i < filter->nb_outputs; i++) {
AVFilterLink *outlink = filter->outputs[i];
int best_idx, best_score = INT_MIN, best_count_diff = INT_MAX;
if (outlink->type != AVMEDIA_TYPE_AUDIO ||
outlink->in_channel_layouts->nb_channel_layouts < 2)
continue;
for (j = 0; j < outlink->in_channel_layouts->nb_channel_layouts; j++) {
uint64_t in_chlayout = link->out_channel_layouts->channel_layouts[0];
uint64_t out_chlayout = outlink->in_channel_layouts->channel_layouts[j];
int in_channels = av_get_channel_layout_nb_channels(in_chlayout);
int out_channels = av_get_channel_layout_nb_channels(out_chlayout);
int count_diff = out_channels - in_channels;
int matched_channels, extra_channels;
int score = 0;
for (k = 0; k < FF_ARRAY_ELEMS(ch_subst); k++) {
uint64_t cmp0 = ch_subst[k][0];
uint64_t cmp1 = ch_subst[k][1];
if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
(out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
in_chlayout &= ~cmp0;
out_chlayout &= ~cmp1;
score += 10 * av_get_channel_layout_nb_channels(cmp1) - 2;
}
}
if ( (in_chlayout & AV_CH_LOW_FREQUENCY) &&
(out_chlayout & AV_CH_LOW_FREQUENCY))
score += 10;
in_chlayout &= ~AV_CH_LOW_FREQUENCY;
out_chlayout &= ~AV_CH_LOW_FREQUENCY;
matched_channels = av_get_channel_layout_nb_channels(in_chlayout &
out_chlayout);
extra_channels = av_get_channel_layout_nb_channels(out_chlayout &
(~in_chlayout));
score += 10 * matched_channels - 5 * extra_channels;
if (score > best_score ||
(count_diff < best_count_diff && score == best_score)) {
best_score = score;
best_idx = j;
best_count_diff = count_diff;
}
}
FFSWAP(uint64_t, outlink->in_channel_layouts->channel_layouts[0],
outlink->in_channel_layouts->channel_layouts[best_idx]);
}
}
| 1threat
|
Create better URL - .htaccess : <p>My URL is looking now like this:</p>
<blockquote>
<p>localhost/en/products/bear-toys/bear.php?id=26123</p>
</blockquote>
<p>And i need to looks like this:</p>
<blockquote>
<p>localhost/en/products/bear-toys/bear/26123</p>
</blockquote>
<p>or if i can get title of that product and store into URL:</p>
<blockquote>
<p>localhost/en/products/bear-toys/bear/blue-bear.php</p>
</blockquote>
<p>I know there is solution with <code>.htaccess</code> but im not good one in <code>.htaccess</code>. So any kind of help will be good. Thanks all</p>
| 0debug
|
How to change string to lower case? : <p>Trying to make it so that if the user enters any vowel capitalized, it will return true. So, that's where I added the "letter = letter.toLowerCase();" but it's not working still..</p>
<pre><code> public static boolean isVowel (String letter) {
letter = letter.toLowerCase();
if (letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u" ) {
return true;
} else {
return false;
}
}
</code></pre>
| 0debug
|
Check if Date is between two dates in mysql : <p>I have a mysql record with the columns start_date and end_date. Now I have a date (as example 2017-08-03) and i want to ask if this date is between the start_date and end_date in my mysql table.</p>
<p>Is this possible?</p>
| 0debug
|
Microservices: database and microservice instances : <p>Lets say we have a microservice A and a B. B has its own database. However B has to be horizontally scaled, thus we end up having 3 instances of B. What happens to the database? Does it scale accordingly, does it stays the same (centralized) database for the 3 B instances, does it become a distributed database, what happens?</p>
| 0debug
|
push() inserts elements outside Array body : Here is my code
let loadInitialImages = ($) => {
let html = "";
let images = new Array();
const APIURL = "https://api.shutterstock.com/v2/images/licenses";
const request = async() => {
const response = await fetch(APIURL, { headers: auth_header() } );
const json = await response.json();
json.data.map((v) => images.push(v.image.id)); //this is where the problem is
}
request();
console.log(images);
//images.map((id) => console.log(id));
}
Everything is working fine here but the problem is when I'm pushing the elements into the array is goes out of the array braces `[]` below is the screenshot of my array:
[![Array output][1]][1]
I'm not able to loop through the array here.
[1]: https://i.stack.imgur.com/FRlRa.png
| 0debug
|
static int ppc_hash64_get_physical_address(CPUPPCState *env,
struct mmu_ctx_hash64 *ctx,
target_ulong eaddr, int rw,
int access_type)
{
bool real_mode = (access_type == ACCESS_CODE && msr_ir == 0)
|| (access_type != ACCESS_CODE && msr_dr == 0);
if (real_mode) {
ctx->raddr = eaddr & 0x0FFFFFFFFFFFFFFFULL;
ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE;
return 0;
} else {
return get_segment64(env, ctx, eaddr, rw, access_type);
}
}
| 1threat
|
how to get audio.duration value by a function : <p>Im my audio player I need to get the duration of my audio track. I need a function that gets src of the audio and returns its duration. Here is what I am trying to do but does not work:</p>
<pre><code>function getDuration(src){
var audio = new Audio();
audio.src = "./audio/2.mp3";
var due;
return getVal(audio);
}
function getVal(audio){
$(audio).on("loadedmetadata", function(){
var val = audio.duration;
console.log(">>>" + val);
return val;
});
}
</code></pre>
<p>I tried to split into two functions but it does not work. It would be great if it was as on working function.</p>
<p>Any idea?</p>
| 0debug
|
Cannot print else statement in solution : <p>i solved an assignment question on my own but i seems not to be able to print an else statement successfully even though the code works.
The questions is below,</p>
<p>Create a program that prompts the user for the first number. Show on the screen which number was chosen and if the
Number is greater than 10 then show your predecessors until you reach number 10.</p>
<p>My solution is below,</p>
<pre><code> Console.WriteLine("Enter interger please: ");
int num = int.Parse(Console.ReadLine());
Console.WriteLine();
for (int num3 = num; 10 <= num3; num3-- )
{
if (num > 10)
{
Console.WriteLine(num3);
}
else
{
Console.WriteLine("The integer entered is less than zero and cannot be used in code ");
}
</code></pre>
| 0debug
|
R's order equivalent in python : <p>Any ideas what is the python's equivalent for R's <code>order</code>? </p>
<pre><code>order(c(10,2,-1, 20), decreasing = F)
# 3 2 1 4
</code></pre>
| 0debug
|
What is the best way to dynamically collect data from an SQL Database : <p>So currently I have a system that pulls data from an SQl database and displays the details in separate counts.</p>
<p>For Example, Total Tickets, Tickets with Support, Tickets with customer etc.</p>
<p>The only time this data get update is when the user reload the page or navigates to another part of the system.</p>
<p>I am looking to revamp the whole system to that the data is always valid instead of users needing to reload the page. </p>
<p>I have been looking into JQuery and AJAX however all the information I have been finding still requires user input.</p>
<p>So I would some advise or links on how to setup a system that requires no user input and instead pulls the data every X seconds and updates the page without refreshing it. </p>
<p>I also want to then be able to expand this functionality to display in-page alerts when new tickets are logged etc.</p>
| 0debug
|
Generic Global elegant way to add bar button items to any UIViewController of the project : <p>Usually we have a predefined set of <code>UIBarButtonItem</code> in the project that can be used in the project and multiple times like a left menu button to open a side menu, it can be used in different <code>UIViewController</code>s also a close button that dismiss the presented view controller. </p>
<p>The classic way is to add these buttons as needed, but this introduce a code duplication and we all want to avoid that.</p>
<p>My come up with an approach, but it's far from being perfect : </p>
<pre><code>enum BarButtonItemType {
case menu, close, notification
}
enum BarButtonItemPosition{
case right, left
}
extension UIViewController {
func add(barButtons:[BarButtonItemType], position: BarButtonItemPosition) {
let barButtonItems = barButtons.map { rightBarButtonType -> UIBarButtonItem in
switch rightBarButtonType {
case .menu:
return UIBarButtonItem(image: UIImage(named:"menu"),
style: .plain,
target: self,
action: #selector(presentLeftMenu(_:)))
case .notification:
return UIBarButtonItem(image: UIImage(named:"notification"),
style: .plain,
target: self,
action: #selector(showNotification(_:)))
case .close:
return UIBarButtonItem(image: UIImage(named:"close"),
style: .plain,
target: self,
action: #selector(dismissController(_:)))
}
}
switch position {
case .right:
self.navigationItem.rightBarButtonItems = barButtonItems
case .left:
self.navigationItem.leftBarButtonItems = barButtonItems
}
}
// MARK: Actions
@objc fileprivate func presentLeftMenu(_ sender:AnyObject) {
self.parent?.presentLeftMenuViewController(sender)
}
@objc fileprivate func dismissController(_ sender:AnyObject) {
self.dismiss(animated: true, completion: nil)
}
@objc fileprivate func showNotification(_ sender:AnyObject) {
let notificationViewController = UINavigationController(rootViewController:NotificationViewController())
self.present(notificationViewController, animated: true, completion: nil)
}
}
</code></pre>
<p>and then the usage:</p>
<pre><code>override func viewDidLoad() {
super.viewDidLoad()
self.add(barButtons: [.close], position: .right)
self.add(barButtons: [.menu], position: .left)
}
</code></pre>
<p>The limitations of my approach are:</p>
<ul>
<li><p>The extension needs to know how to instantiate new view controller (case of notification for example) and what if viewController must be inited with parameters</p></li>
<li><p>It assumes that you only want to present a <code>UIViewController</code></p></li>
<li><p>Not elegant.</p></li>
</ul>
<p>I am sure that there is better way with Swift language and protocol oriented programming that can achieve the intended result with more flexibility, any thoughts ?</p>
| 0debug
|
.NET Core with .NET Framework as TargetFramework : <p>I'm wondering what it means, exactly, when I have a .NET Core console app project that has its TargetFramework property (in the .csproj) set to a version of the full .NET Framework, e.g. </p>
<pre><code><TargetFramework>net461</TargetFramework>
</code></pre>
<ul>
<li>If I compile this as a console application, will it use the .NET Core runtime, or the .NET Framework runtime?</li>
<li>If it uses the .NET Core runtime, can I encounter any incompatibilities between supported features in .NET Core and .NET Framework if I remain on the Windows platform?</li>
</ul>
| 0debug
|
How can I send Data by an form without an inputfield? : I want to send data to another html file by a form, but i don't want to use an inputfield I just want to send an ID to the other file. How can I add the ID to the URL, when I want to get the Data by location.search?
<form method="GET" action="secondHTML.html">
<div class="modal-footer">
<button type="submit" name="ID" class="btn btn-primary">Save</button>
</div>
</form>
| 0debug
|
static int get_dimension(GetBitContext *gb, const int *dim)
{
int t = get_bits(gb, 3);
int val = dim[t];
if(val < 0)
val = dim[get_bits1(gb) - val];
if(!val){
do{
t = get_bits(gb, 8);
val += t << 2;
}while(t == 0xFF);
}
return val;
}
| 1threat
|
taking information from a structure and using in another function : <p>I need to know if I can call the information that is in tire_pressure in the structure and use it in another function? Basically I am not sure how to call it from one to the other. Do I have to declare the function in tireTest? Which is the function I am trying to access the tire_pressure information at. Thanks for the help</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct tires
{
char Manufacturer[40];
int tire_pressure[0];
int pressure_change[0];
}typedef tires;
// Prototypes
void getTireInformation(tires*, int);
void tirePressure(tires*, int);
void tireTest(tires*, int);
int main()
{
tires tire[4];
tires* ptire = &tire[0];
srand(time(NULL));
getTireInformation(ptire, 4);
tirePressure(ptire, 4);
tireTest(ptire, 4);
return 0;
}// end main
//============================
void getTireInformation(tires* ptire, int size)
{
int i = 0;
for (i = 0; i < size; i++)
{
printf("please enter Make for the tire: \n");
scanf("%s", &(ptire + i) ->Manufacturer);
}
printf("all tire make you entered ...just for verification:\n");
for(i = 0; i < size; i++)
printf("%s\n",(ptire +i) ->Manufacturer);
}//end getTireInformation
//=======================================================================
void tirePressure(tires* ptire, int size)
{
int i = 0;
int min = 18;
int max = 35;
for (i = 0; i < size; i++)
{
(ptire + i) ->tire_pressure[0] = rand() % (max - min + 1) + min;
printf("The Tire pressure is: ");
printf("%d\n",(ptire + i) -> tire_pressure[0]);
}// end for
}// end tirePressure
//==============================================================
void tireTest(tires* ptire, int size)
{
int i = 0;
int min = 2;
int max = 5;
int change[0] = {0};
i++;
for (i = 0; i < size; i++)
{
change[0] = rand() % (max - min + 1) + min;
//(ptire + i) -> pressure_change[0] = rand() % (max - min + 1) + min;
printf("Pressure change from test %d: %d\n",i + 1, change[0]);
//(ptire + i) -> pressure_change[0] = change[0] + tirePressure;
//printf("%d\n", (ptire +i) -> pressure_change);
}// end for
}
</code></pre>
| 0debug
|
MYSQL how i can ADD column that has comma separated name : <p>i want to add column inside table. column name is name,surname
how i can add this column inside already created table?
like alter table MyTable ADD name,surname Varchar(100) ???</p>
| 0debug
|
How to disable wifi show password in ubuntu 18.04 : <p>Is there any way to disable wifi show password in ubuntu 18.04 or is there any way stop system to store wifi passwords. </p>
| 0debug
|
which one is better for developing an service app(Native or Hybrid)? : <p>I want to know which one this items (Hybrid - Native) is better for developing an Service app like laundry or Carpet cleaning app?</p>
| 0debug
|
I need to Parse whole java code and save statements in a tree structure for making Control flow graph : <p>I need to identify java source code all type of statements and store them in a tree structure to make a control flow graph! what i cannot understand is how should i read a java source code so that my program may distinguish all different types of statements in java( if,for, classes, methods etc.)
Do i need to add the whole grammar of java language?</p>
<p>what i cannot understand is how should i read a java source code so that my program may distinguish all different types of statements in java( if,for, classes, methods etc.)</p>
| 0debug
|
Javascript - format number to 3 decimals : <p>trying to convert the number to a 3 decimals only but .toFixed(3) is being ignored. Any idea? Thx </p>
<pre><code>output2=output2.split("\n").filter(/./.test, /Number/).map(line => line.split(/,|\(|\)/).filter(number => number != "")[8]).join("\n")*(0.00254).toFixed(3);
</code></pre>
| 0debug
|
C++: Can std::tuple_size/tuple_element be specialized? : <p>Is specialization of <code>std::tuple_size</code> and <code>std::tuple_element</code> permitted for custom types?
I suppose it is, but I want to be absolutely sure, and I can't find any concrete information.</p>
<p>Example (namespaces, member functions and <code>get<I></code> overloads omitted):</p>
<pre><code>template <typename T, size_t N>
struct vector { T _data[N]; };
template<size_t I, typename T, size_t N>
constexpr T& get(vector<T,N>& vec) { return vec._data[I]; }
namespace std {
template<typename T, size_t N>
class tuple_size< vector<T,N> > : public std::integral_constant<size_t, N> { };
template<size_t I, typename T, size_t N>
class tuple_element< I, vector<T,N> > { public: using type = T; };
}
</code></pre>
<p>I need that for use with structured bindings:</p>
<pre><code>void f(vector<T,3> const& vec)
{
auto& [x,y,z] = vec;
// stuff...
}
</code></pre>
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
The ArgumentOutOfRangeException Error my C#code has : I am learning C# these days and still a beginner.
While practicing creating methods,
I made this method that yield the sum of the members of a numeric type's array.
(my codes are yet massive.. And I am not good at math as well..),
VS says it has The ArgumentOutOfRangeException Error.
But, I don't know how to fix this.
Please save me!
public static int SumAll(int[] a)
{
List<int> sum = new List<int>();
int sumAll;
if (a.Length == 0)
{
sumAll = 0;
}
else
{
sum[0] = a[0];
for (int i = 1; i < (a.Length - 1); i++)
{
sum[i] = sum[i - 1] + a[i];
}
sumAll = sum[a.Length - 1];
}
return sumAll;
}
| 0debug
|
CBOW v.s. skip-gram: why invert context and target words? : <p>In <a href="https://www.tensorflow.org/versions/r0.9/tutorials/word2vec/index.html#vector-representations-of-words" rel="noreferrer">this</a> page, it is said that: </p>
<blockquote>
<p>[...] skip-gram inverts contexts and targets, and tries to predict each context word from its target word [...]</p>
</blockquote>
<p>However, looking at the training dataset it produces, the content of the X and Y pair seems to be interexchangeable, as those two pairs of (X, Y): </p>
<blockquote>
<p><code>(quick, brown), (brown, quick)</code></p>
</blockquote>
<p>So, why distinguish that much between context and targets if it is the same thing in the end? </p>
<p>Also, doing <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/udacity/5_word2vec.ipynb" rel="noreferrer">Udacity's Deep Learning course exercise on word2vec</a>, I wonder why they seem to do the difference between those two approaches that much in this problem: </p>
<blockquote>
<p>An alternative to skip-gram is another Word2Vec model called CBOW (Continuous Bag of Words). In the CBOW model, instead of predicting a context word from a word vector, you predict a word from the sum of all the word vectors in its context. Implement and evaluate a CBOW model trained on the text8 dataset.</p>
</blockquote>
<p>Would not this yields the same results?</p>
| 0debug
|
void do_cpu_init(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
int sipi = env->interrupt_request & CPU_INTERRUPT_SIPI;
uint64_t pat = env->pat;
cpu_reset(CPU(cpu));
env->interrupt_request = sipi;
env->pat = pat;
apic_init_reset(env->apic_state);
env->halted = !cpu_is_bsp(env);
}
| 1threat
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
Cannot load underlying module for 'RealmSwift' : <p>I'm trying to install Realm for Swift via Cocoapods. </p>
<p>First what I did was <strong>pod init</strong> into my project<br><br>
Then I open podfile and changed it like this:</p>
<pre><code>target 'Taskio' do
use_frameworks!
pod 'RealmSwift'
end
</code></pre>
<p>Then I closed podfile and execute command <strong>pod install</strong> <br><br></p>
<p>Everything pass good. But now when i opened workspace I'm getting error while importing RealmSwift </p>
<p>Cannot load underlying module for 'RealmSwift'</p>
<p><a href="https://i.stack.imgur.com/GAyGU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GAyGU.png" alt="Error"></a></p>
| 0debug
|
inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_UYVY)
{
RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR32)
{
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR24)
{
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR16)
{
RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR15)
{
RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB32)
{
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB24)
{
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(isGray(srcFormat))
{
return;
}
#ifdef HAVE_MMX
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int i;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $4096, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
{
dst[i] = src1[srcW-1]*128;
dst[i+2048] = src2[srcW-1]*128;
}
}
else
{
#endif
long xInc_shr16 = (long) (xInc >> 16);
int xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_b", %%"REG_b" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN16
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_b"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"movzbl (%5, %%"REG_b"), %%edi \n\t"
"movzbl 1(%5, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 4096(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for(i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
#endif
}
}
| 1threat
|
differance between executable files : i have following c program
#include<stdio.h>
int main()
{
printf("hhhh");
return 0;
gcc print.c -o a.out
objcopy a.out b.oout
cmp a.out b.out
I have compiled this program and create executable file. then I have used objcopy command to copy this executable file into another but when I compare these files it is giving error that `files differ: byte 41, line 1` how can I know what contents are missing ?
| 0debug
|
how do I search device using core bluetooth in swift 3? : In my iOS app I want to search device using swift 3. How do I implement this functionality in my app using core bluetooth.
| 0debug
|
How do I write the following OR? : <p>This little piece of code always returns "Equal". I must have something wrong syntax wise but I really can't find what. It's driving me crazy.</p>
<pre><code><?php
$var = "1";
if($var == "2" or "3") {
echo "Equal";
} else {
echo "Different";
}
?>
</code></pre>
| 0debug
|
static int smacker_probe(AVProbeData *p)
{
if(p->buf[0] == 'S' && p->buf[1] == 'M' && p->buf[2] == 'K'
&& (p->buf[3] == '2' || p->buf[3] == '4'))
return AVPROBE_SCORE_MAX;
else
return 0;
}
| 1threat
|
How do I search a list of numbers for duplicates and drop the first of 2 duplicated values by 1? : <p>I get a list of numbers 90 - 480; this range is not completely filled. What I mean is that the list may be 90, 91, 92, 94, 95...and so on up to 480 and the missing 93 is expected. Every time I get the list there are lots of duplicates. Also, I might get up to 10 lists at a time. What I do know about the list is that if there are duplicates, 100% of the time, if I drop the first of the 2 duplicates by 1 value, then continue scanning for duplicates this will give me an accurate list. the list might look like: '90, 91, 92, 93, 95, 95, 96, 98, 100, 100, 102, 102.....' so to get this part of the list accurate I will need to change the first 95 to 94, the first 100 to 99, and the first 102 to 101. </p>
<p>Sorry if I am asking in the incorrect place but just for the sake of this question; the list is in excel but I could use Python or Linux as I have access to both of those as well. Thanks!</p>
| 0debug
|
StringBuilder uft-8 support in Java : <p>I created csv file in Java and inserted some values.This is source</p>
<pre><code>try {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate localDate = LocalDate.now();
System.out.println(dtf.format(localDate).toString() + ".csv");
String filename = dtf.format(localDate).toString() + ".csv";
StringBuilder builder = new StringBuilder();
if (Files.exists(Paths.get("D:\\" + filename))) {
System.out.println("File existed");
} else {
System.out.println("File not found!");
String ColumnNamesList = "UID,name,personalNumber,nationality,dateofbirth,dateofexp,documentcode,gender,issueState,documentType";
builder.append(ColumnNamesList + "\n");
}
builder.append(UID + ",");
builder.append(name + ",");
builder.append(personalNumber + ",");
builder.append(nationality + ",");
builder.append(dateofbirth + ",");
builder.append(dateofexp + ",");
builder.append(documentcode + ",");
builder.append(gender + ",");
builder.append(issueState + ",");
builder.append(documentType + ",");
builder.append('\n');
File file = new File("D:\\" + filename);
FileWriter fw = new FileWriter(file, true); // the true will append the new data
fw.write(builder.toString());
fw.close();
System.out.println("done!");
} catch (IOException ioe) {
System.err.println("IOException: " + ioe.getMessage());
}
</code></pre>
<p>Problem is that,my "name" value is not English alphabet and result in my file is null.
Is it a possible to add uft-8 support StringBuilder ? or how i can save some values in file with uft-8?
thanks</p>
| 0debug
|
static void omap_sti_fifo_write(void *opaque, target_phys_addr_t addr,
uint32_t value)
{
struct omap_sti_s *s = (struct omap_sti_s *) opaque;
int offset = addr - s->channel_base;
int ch = offset >> 6;
uint8_t byte = value;
if (ch == STI_TRACE_CONTROL_CHANNEL) {
qemu_chr_write(s->chr, "\r", 1);
} else if (ch == STI_TRACE_CONSOLE_CHANNEL || 1) {
if (value == 0xc0 || value == 0xc3) {
} else if (value == 0x00)
qemu_chr_write(s->chr, "\n", 1);
else
qemu_chr_write(s->chr, &byte, 1);
}
}
| 1threat
|
Using strided iterator to find unique arbitrarily-size tuples in cuda : I'm trying to write an kernel that finds unique tuples in a collection, but with one several important caveat: the application should be able to handle tuples of arbitrary dimensions i.e. unknown at compile-time. Furthermore, the size of the tuple may exceed 10. These two considerations rule out the thrust tuple. As such I've tried to represent the tuple in structure of array (SoA) form using the stride iterator implementation shamelessly ripped off from [here][1], as shown below:
#include <vector>
#include <iostream>
#include <thrust/unique.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/iterator/permutation_iterator.h>
typedef unsigned short ushort;
template<typename Iterator>
struct StridedIterator
{
typedef typename thrust::iterator_difference<Iterator>::type difference_type;
struct StrideFunctor : public thrust::unary_function<difference_type,difference_type>
{
difference_type m_stride;
StrideFunctor(difference_type stride ): m_stride( stride )
{
}
__host__ __device__
difference_type operator()(const difference_type& i) const
{
return m_stride * i;
}
};
typedef typename thrust::counting_iterator<difference_type> CountingIterator;
typedef typename thrust::transform_iterator<StrideFunctor, CountingIterator> TransformIterator;
typedef typename thrust::permutation_iterator<Iterator,TransformIterator> PermutationIterator;
typedef PermutationIterator Type;
StridedIterator( Iterator startIter , Iterator endIter , difference_type stride )
: m_startIter( startIter )
, m_endIter( endIter )
, m_stride( stride )
{
}
Type begin() const
{
return PermutationIterator( m_startIter , TransformIterator( CountingIterator(0) , StrideFunctor( m_stride ) ) );
}
Type end() const
{
return begin() + ( ( m_endIter - m_startIter ) + ( m_stride - 1 ) ) / m_stride;
}
Iterator m_startIter;
Iterator m_endIter;
difference_type m_stride;
};
int main()
{
// AoS version
/*
2 , 1 , -- unique
1 , 2 , -- unique
1 , 1 , -- unique
1 , 1 ,
1 , 3 , -- unique
2 , 2 , -- unique
3 , 1 , -- unique
2 , 1 ,
1 , 2 ,
1 , 1 ,
2 , 2 ,
2 , 2
*/
// 'SoA' -- twelve 2-tuples, 6 of which are unique
std::vector<ushort> input{
2 , 1 , 1 , 1 , 1 , 2 , 3 , 2 , 1 , 1 , 2 , 2 ,
1 , 2 , 1 , 1 , 3 , 2 , 1 , 1 , 2 , 1 , 2 , 2
};
thrust::host_vector<ushort> hData = input;
ushort dim = 2;
thrust::device_vector<ushort> data = hData;
typedef thrust::device_vector<ushort>::iterator Iterator;
StridedIterator<Iterator> stridedIter( data.begin() , data.end() , dim );
auto iter = thrust::unique( stridedIter.begin() , stridedIter.end() );
std::cout << stridedIter.end() - stridedIter.begin() << std::endl;
std::cout << iter - stridedIter.begin() << std::endl;
}
Unfortunately instead of getting the value of 6 post call to `thrust::unique` I'm getting 9. Please advise.
[1]: https://stackoverflow.com/a/42235487/181783
| 0debug
|
Hi i have created a private class "PathakP" but i am getting PathakP cannot be resolved to a type : Ok i tried to create a dialog box with Jbutton but when i am adding actionListener to it and passing the class to button which i have created to implements ActionListener i am getting "PathakP(Class Name) cannot be resolved to a type"
the code i have used is
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class GUI1 extends JFrame {
private JTextField J;
private Font pf,bf,itf,bif;
private JRadioButton pb,bb,ib,bib;
private ButtonGroup B;
private JButton ab;
public GUI1(){
super("To check the Font styles" );
setLayout(new FlowLayout());
J=new JTextField("This is the Text who's Font will be Changed pahtak is with me ",40);
add(J);
pb=new JRadioButton("Plain Button",true);
bb=new JRadioButton("Bold Button",false);
bib=new JRadioButton("Bold & Italic Button",false);
ib=new JRadioButton("Italic Button",false);
ab=new JButton("PathakButton");
add(ab);
add(pb);
add(bb);
add(bib);
add(ib);
B=new ButtonGroup();
B.add(pb);
B.add(bb);
B.add(bib);
B.add(ib);
pf=new Font("Serif",Font.PLAIN,15);
bf=new Font("Serif",Font.BOLD,15);
itf=new Font("Serif",Font.ITALIC,15);
bif=new Font("Serif",Font.BOLD+Font.ITALIC,16);
J.setFont(pf);
pb.addItemListener(new HandlerClass(pf));
bb.addItemListener(new HandlerClass(bf));
bib.addItemListener(new HandlerClass(bif));
ib.addItemListener(new HandlerClass(itf));
ab.addActionListener(new PathakP());
}
private class HandlerClass implements ItemListener{
private Font font;
public HandlerClass(Font f){
font=f;
}
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
J.setFont(font);
}
private class PathakP implements ActionListener{
public void actionPerformed(ActionEvent ae) {
JOptionPane.showMessageDialog(null, "This is just JOptionPane example");
}
}
}
}
------------------------------------------------------------
Main Class
import javax.swing.*;
public class Apples {
public static void main(String[] args) {
GUI1 G=new GUI1();
G.setVisible(true);
G.setSize(500,250);
G.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
-----------------
i don't believe there is any error in the main class
i can troubleshoot this error by just creating another class outside but i want to know why it is not taking the class i have created and show unused in it
| 0debug
|
static void intel_hda_update_irq(IntelHDAState *d)
{
int msi = d->msi && msi_enabled(&d->pci);
int level;
intel_hda_update_int_sts(d);
if (d->int_sts & (1 << 31) && d->int_ctl & (1 << 31)) {
level = 1;
} else {
level = 0;
}
dprint(d, 2, "%s: level %d [%s]\n", __FUNCTION__,
level, msi ? "msi" : "intx");
if (msi) {
if (level) {
msi_notify(&d->pci, 0);
}
} else {
pci_set_irq(&d->pci, level);
}
}
| 1threat
|
AttributeError: 'NoneType' object has no attribute 'get' The entry.get is returning this error. : I am using tkinter for my work. This is my code where the entry.get() doesn't work. I don't know what the error is for as this has worked previously in my work.
from tkinter import *
def please():
print (entry_2.get())#The error
window_2=Tk()
label_6=Label(window_2, text="New Username", font="Calibri 12
bold").grid(column=0)
label_7=Label(window_2, text="New Password", font="Calibri 12
bold").grid(row=1)
entry_1=Entry(window_2, font="Calibri 12 bold").grid(row=0, column=1)
#This is the entry toget the contents
entry_2=Entry(window_2, font="Calibri 12 bold", show="*").grid(row=1,
column=1)
label_address=Label(window_2, text="Address", font="Calibri 12 bold").
grid(row=2, column=0)
entry_address=Entry(window_2, font="Calibri 12 bold").grid(row=2, column=1)
label_dob=Label(window_2, text="Date Of Birth e.g.DD/MM/YEAR", font="Calibri
12 bold"). grid(row=3, column=0)
entry_dob=Entry(window_2, font="Calibri 12 bold").grid(row=3, column=1)
label_gender=Label(window_2, text="Gender e.g. Male/Female/Other",
font="Calibri 12 bold").grid(row=4, column=0)
entry_gender=Entry(window_2, font="Calibri 12 bold").grid(row=4, column=1)
label_interests=Label(window_2, text="Interests", font="Calibri 12
bold").grid(row=5, column=0)
entry_interests=Entry(window_2, font="Calibri 12 bold").grid(row=5,
column=1)
button_3=Button(window_2, text="Create", font="Calibri 12 bold",
command=please).grid(row=6, column=1)
window_2.mainloop()
| 0debug
|
static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
BlkMigDevState *bmds, int is_async)
{
BlkMigBlock *blk;
int64_t total_sectors = bmds->total_sectors;
int64_t sector;
int nr_sectors;
int ret = -EIO;
for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) {
if (bmds_aio_inflight(bmds, sector)) {
qemu_aio_flush();
}
if (bdrv_get_dirty(bmds->bs, sector)) {
if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
nr_sectors = total_sectors - sector;
} else {
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
}
blk = g_malloc(sizeof(BlkMigBlock));
blk->buf = g_malloc(BLOCK_SIZE);
blk->bmds = bmds;
blk->sector = sector;
blk->nr_sectors = nr_sectors;
if (is_async) {
blk->iov.iov_base = blk->buf;
blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
if (block_mig_state.submitted == 0) {
block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
}
blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov,
nr_sectors, blk_mig_read_cb, blk);
if (!blk->aiocb) {
goto error;
}
block_mig_state.submitted++;
bmds_set_aio_inflight(bmds, sector, nr_sectors, 1);
} else {
ret = bdrv_read(bmds->bs, sector, blk->buf, nr_sectors);
if (ret < 0) {
goto error;
}
blk_send(f, blk);
g_free(blk->buf);
g_free(blk);
}
bdrv_reset_dirty(bmds->bs, sector, nr_sectors);
break;
}
sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
bmds->cur_dirty = sector;
}
return (bmds->cur_dirty >= bmds->total_sectors);
error:
monitor_printf(mon, "Error reading sector %" PRId64 "\n", sector);
qemu_file_set_error(f, ret);
g_free(blk->buf);
g_free(blk);
return 0;
}
| 1threat
|
Is this the wright way to implement upcasting and downcasting in the following java code? : package test;
public class Test {
public static void main(String[] args) {
A a2= new B(); // 1
a2.display1();
a2.display();
((B)a2).display2(); // 2
((A)a2).display(); // 3
B b1=new B();
b1.display1(); // 4
}
}
class A
{
int a=10;
void display()
{
System.out.println("parent class "+a);
}
void display1()
{
System.out.println("parent class "+ (a+10));
}
}
class B extends A
{
int a=30;
@Override
void display()
{
System.out.println("child class "+a);
}
void display2()
{
System.out.println("child class "+(a+10));
}
}
1. whose object is created ?class A or B.
2. Is this downcasting
3. why this is not invoking the method of class A? how to invoke method of class A (override one) with this object and not with the object of A.
4. is this implicit upcasting?
5. If a class A have a nested Class B than during object creation of class A
does object of class b is also formed ?i was not able to use method of class B from object of A
| 0debug
|
Can't move 100K jpgs from my root to another folder : <p>I accidentally saved 100K jpgs to my root folder, I'd like to move just the jpgs and not the other files like my applications folder to a new folder on my desktop. I tried:</p>
<pre><code>home$ mv *.png ~/Desktop/images
</code></pre>
<p>But it returns:</p>
<pre><code>-bash: /bin/mv: Argument list too long
</code></pre>
<p>Any ideas?</p>
| 0debug
|
static void colo_compare_connection(void *opaque, void *user_data)
{
CompareState *s = user_data;
Connection *conn = opaque;
Packet *pkt = NULL;
GList *result = NULL;
int ret;
while (!g_queue_is_empty(&conn->primary_list) &&
!g_queue_is_empty(&conn->secondary_list)) {
qemu_mutex_lock(&s->timer_check_lock);
pkt = g_queue_pop_tail(&conn->primary_list);
qemu_mutex_unlock(&s->timer_check_lock);
result = g_queue_find_custom(&conn->secondary_list,
pkt, (GCompareFunc)colo_packet_compare_all);
if (result) {
ret = compare_chr_send(s->chr_out, pkt->data, pkt->size);
if (ret < 0) {
error_report("colo_send_primary_packet failed");
}
trace_colo_compare_main("packet same and release packet");
g_queue_remove(&conn->secondary_list, result->data);
packet_destroy(pkt, NULL);
} else {
trace_colo_compare_main("packet different");
qemu_mutex_lock(&s->timer_check_lock);
g_queue_push_tail(&conn->primary_list, pkt);
qemu_mutex_unlock(&s->timer_check_lock);
break;
}
}
}
| 1threat
|
How return sublist of items that not exist in second list? : Java 1.8
suppose I has 2 lists.
I need to return sublist of items in first list that not contain in second list.
E.g:
[1,2,3,4,5] - [1,2,3,4,5] -> return []
[1,2,3,4,5] - [1,22,3,4,5] -> return [2]
[1,2,3,4,5] - [6,7,8,9,10] -> return [1,2,3,4,5]
[1,2,3,4,5] - [1,2,3,4,5,6] -> return []
[1,2,3,4,5] - [6,7,8,9,2] -> return [1,3,4,5]
How I can do this simple?
I can write custom java method to do this. But maybe already exist any good solution.
Thanks.
| 0debug
|
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int i;
int w= s->width;
int h= s->height;
InternalBuffer *buf;
int *picture_number;
assert(pic->data[0]==NULL);
assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count);
if(avcodec_check_dimensions(s,w,h))
return -1;
if(s->internal_buffer==NULL){
s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer));
}
#if 0
s->internal_buffer= av_fast_realloc(
s->internal_buffer,
&s->internal_buffer_size,
sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)
);
#endif
buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num;
(*picture_number)++;
if(buf->base[0]){
pic->age= *picture_number - buf->last_pic_num;
buf->last_pic_num= *picture_number;
}else{
int h_chroma_shift, v_chroma_shift;
int pixel_size, size[3];
AVPicture picture;
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
avcodec_align_dimensions(s, &w, &h);
if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
w+= EDGE_WIDTH*2;
h+= EDGE_WIDTH*2;
}
avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
pixel_size= picture.linesize[0]*8 / w;
assert(pixel_size>=1);
if(pixel_size == 3*8)
w= ALIGN(w, STRIDE_ALIGN<<h_chroma_shift);
else
w= ALIGN(pixel_size*w, STRIDE_ALIGN<<(h_chroma_shift+3)) / pixel_size;
size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
size[0] = picture.linesize[0] * h;
size[1] -= size[0];
if(picture.data[2])
size[1]= size[2]= size[1]/2;
else
size[2]= 0;
buf->last_pic_num= -256*256*256*64;
memset(buf->base, 0, sizeof(buf->base));
memset(buf->data, 0, sizeof(buf->data));
for(i=0; i<3 && size[i]; i++){
const int h_shift= i==0 ? 0 : h_chroma_shift;
const int v_shift= i==0 ? 0 : v_chroma_shift;
buf->linesize[i]= picture.linesize[i];
buf->base[i]= av_malloc(size[i]+16);
if(buf->base[i]==NULL) return -1;
memset(buf->base[i], 128, size[i]);
if((s->flags&CODEC_FLAG_EMU_EDGE) || (s->pix_fmt == PIX_FMT_PAL8) || !size[2])
buf->data[i] = buf->base[i];
else
buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN);
}
pic->age= 256*256*256*64;
}
pic->type= FF_BUFFER_TYPE_INTERNAL;
for(i=0; i<4; i++){
pic->base[i]= buf->base[i];
pic->data[i]= buf->data[i];
pic->linesize[i]= buf->linesize[i];
}
s->internal_buffer_count++;
return 0;
}
| 1threat
|
C: How to append data to a file without using standard I/O libraries : <p>I was wondering if there is a way to append data to a file without using functions from standard I/O libraries (i.e. <code>stdio.h</code>). I though of doing something like this first:</p>
<pre><code>#include <fcntl.h>
#include <unistd.h>
int main() {
int fd = open("test.txt", O_WRONLY | O_CREAT, 0700);
ssize_t wr = write(fd, "hello world", sizeof("hello world");
}
</code></pre>
<p>But this only writes data to the file without appending it so instead repeatedly displaying "hello world", it only overwrites the previous data and displays it once. Can someone please help me out? Thanks</p>
| 0debug
|
Why doesn't jQuery/JavaScript work in Safari? : I'm developing a website for a client, and although all jQuery/Javascript code works fine on chrome (e.g. floating navbar, and smooth scroll when you click a navbar item), none of it seems to work in chrome? I've looked at other questions on StackOverflow, and the only advice i've found is to use a HTML validator, because safari can be iffy like that. Although I'm in the process of doing that now, I have a feeling it's something deeper, because most of the HTML issues revolve around obsolete center tags.
At the moment, the site is up at: http://www.grahamcafe.net23.net/Padre/index.html
Any ideas are much appreciated!
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.