problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Visual studio code color picker : <p>I love visual studio code but there's one thing that is missing in my opinion.<br />
A color picker. <br />
Does anyone know if there's a color picker for visual studio code just like in visual studio?</p>
| 0debug
|
C++ Division Error? : <p>Hi so whenever I try to do division such as <strong>double x = 3 * (5/10);</strong> it will make x = 0 for some reason. Is there a reason this happens in c++ I'm learning and have no clue why this happens. </p>
| 0debug
|
def even_bit_toggle_number(n) :
res = 0; count = 0; temp = n
while(temp > 0 ) :
if (count % 2 == 0) :
res = res | (1 << count)
count = count + 1
temp >>= 1
return n ^ res
| 0debug
|
How to write "@" in android emulator ? : <p>I have a MAC and with OPT-ò (italian keyboard layout) I can write "@" in ALL application but not in "Android emulator". I don't want to press "char per char" via virtual keyboard in my app. Is it possibile (and how) write "@" without virtual keyboard? </p>
| 0debug
|
Deleting subfolder and files in window through cmd and timestamp backup : <p>I want to delete files and folders from a folder by using cmd in windows.How can i do?</p>
<p>And i need to copy a file and paste appending timestamp by time.</p>
<p>Help will be appreciated</p>
<p>Thanks!</p>
| 0debug
|
PHP Wamp server : <p>Hey I have a database that contains information about different countries. I also have a html page where you can submit information about countries. Can someone help me to write a code that says that the information has been stored in the database instead of it just redirecting to a blank page?</p>
<p>Here is my html page where you submit information:</p>
<pre><code><!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Sett inn land</title>
</head>
<body>
<form action="geoinn.php" method="get">
Land: <input type="text" name="navn"> <br>
Hovedstad: <input type="text" name="hovedstad"> <br>
Areal: <input type="text" name="areal"> <br>
Folketall: <input type="text" name="folketall"> <br>
<input type="submit" value="Legg inn informasjon">
</form>
</body>
</html>
</code></pre>
<p>And here is the page that you are redirected to when you click submit on the other page. This is the page where I want to have a code saying either that "The information has been stored in our database" or that it has not:</p>
<pre><code> <?php
$tjener = "localhost";
$brukernavn = "root";
$passord ="";
$database ="Geografi";
$kobling = mysqli_connect($tjener,$brukernavn,$passord,$database);
$kobling->set_charset("utf8");
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Geografi</title>
</head>
<body>
<?php
$land = $_GET["navn"];
$hovedstad = $_GET["hovedstad"];
$areal = $_GET["areal"];
$folketall = $_GET["folketall"];
$sql ="INSERT INTO land (navn,hovedstad, areal, folketall) VALUES('$land','$hovedstad','$areal', '$folketall')";
mysqli_query($kobling, $sql);
mysqli_close($kobling);
?>
</body>
</html>
</code></pre>
| 0debug
|
How to set a program that count similar items in a string? : <p>I have this list</p>
<pre><code>dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby']
</code></pre>
<p>I need a function that would tell me that there is 3 gold coin, 1 dagger and 1 ruby in the dragon loot.</p>
| 0debug
|
What are primitive, internal, builtin, and special functions? : <p>I have seen that some functions that call C-code are described as <code>primitive</code>, <code>internal</code>, <code>builtin</code>, or <code>special</code>. What are these functions?</p>
| 0debug
|
Vue. How to get a value of a "key" attribute in created element : <p>I try to create a components and get its key for using in axios.
Elements created, but I can't get a key. It's undefined</p>
<pre><code><div class="container" id="root">
<paddock is="paddock-item" v-for="paddock in paddocks" :key="paddock.key" class="paddock">
</paddock>
</div>
<script>
var pItem = {
props: ['key'],
template: '<div :test="key"></div>',
created: function() {
console.log(key);
}
};
new Vue({
el: '#root',
components: {
'paddock-item': pItem
},
data: {
paddocks: [
{key: 1},
{key: 2},
{key: 3},
{key: 4}
]
}
})
</script>
</code></pre>
<p>I try some variants, but no result - @key was empty.</p>
| 0debug
|
Currency based on Http request getlocale throwing illegalargumentException : I am trying to get currency symbols based on locale, currency code in a servlet.
I tried to do Currency getInstance(request.getlocale()) and it is throwing IllegalArgumentException.
Locale has language as "en" but country value empty.
How to get currency symbols for a locale, currency code??
| 0debug
|
what could be the regular expression for the text "192.168.71.1 GET HTTP/1.0 /test/abc"? : what could be the relevant regular expression for the text "192.168.71.1 GET HTTP/1.0 /test/abc"
i have tried for regular expressions separately but could not combine all these with a space in betweeen
| 0debug
|
How to write a block of text(multiple lines text) to a file in windows via batch file without using multiple echo call? : I have been trying to write multiple lines of text to a text file in windows but don't know how to do this. Also, search on the internet a lot about this but all solutions use echo command multiple times. Is there any way to do this without using echo command multiple times like "cat" in Linux.
| 0debug
|
void aio_set_fd_handler(AioContext *ctx,
int fd,
bool is_external,
IOHandler *io_read,
IOHandler *io_write,
void *opaque)
{
AioHandler *node;
bool is_new = false;
node = find_aio_handler(ctx, fd);
if (!io_read && !io_write) {
if (node) {
g_source_remove_poll(&ctx->source, &node->pfd);
if (ctx->walking_handlers) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
QLIST_REMOVE(node, node);
g_free(node);
}
}
} else {
if (node == NULL) {
node = g_new0(AioHandler, 1);
node->pfd.fd = fd;
QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);
g_source_add_poll(&ctx->source, &node->pfd);
is_new = true;
}
node->io_read = io_read;
node->io_write = io_write;
node->opaque = opaque;
node->is_external = is_external;
node->pfd.events = (io_read ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);
node->pfd.events |= (io_write ? G_IO_OUT | G_IO_ERR : 0);
}
aio_epoll_update(ctx, node, is_new);
aio_notify(ctx);
}
| 1threat
|
static inline int mov_get_stsc_samples(MOVStreamContext *sc, int index)
{
int chunk_count;
if (mov_stsc_index_valid(index, sc->stsc_count))
chunk_count = sc->stsc_data[index + 1].first - sc->stsc_data[index].first;
else
chunk_count = sc->chunk_count - (sc->stsc_data[index].first - 1);
return sc->stsc_data[index].count * chunk_count;
}
| 1threat
|
Angular4: Http -> HttpClient - requestOptions : <p>So, I am trying to migrate from 'old' http to the new httpClient</p>
<p>with the http client I am using this format in my service:</p>
<pre><code>return this.http.get(environment.api+ '.feed.json', requestOptions)
</code></pre>
<p>how do I use this in httpClient?</p>
<p>tried many thiungs... including </p>
<pre><code>return this.http.get(environment.api+ '.feed.json', {params: requestOptions.params})
</code></pre>
<p>but getting a type missmatch :(</p>
| 0debug
|
IEnumerable<T> Queue.Count is not returning an integer : <p>I am attempting to define a queue named movingAverages with a size of queue.Count - period. I am getting an error "int IEnumerable.Count() ... - cannot be applied to method and int.... </p>
<pre><code>private static IEnumerable<DateClose> MovingAverage(
IEnumerable<DateClose> queue, int period)
{
Queue<DateClose> movingAverages = new Queue<DateClose>(queue.Count + period);
return movingAverages;
}
</code></pre>
| 0debug
|
static void pci_config(void)
{
QVirtioPCIDevice *dev;
QOSState *qs;
int n_size = TEST_IMAGE_SIZE / 2;
uint64_t capacity;
qs = pci_test_start();
dev = virtio_blk_pci_init(qs->pcibus, PCI_SLOT);
capacity = qvirtio_config_readq(&dev->vdev, 0);
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
qvirtio_set_driver_ok(&dev->vdev);
qmp_discard_response("{ 'execute': 'block_resize', "
" 'arguments': { 'device': 'drive0', "
" 'size': %d } }", n_size);
qvirtio_wait_config_isr(&dev->vdev, QVIRTIO_BLK_TIMEOUT_US);
capacity = qvirtio_config_readq(&dev->vdev, 0);
g_assert_cmpint(capacity, ==, n_size / 512);
qvirtio_pci_device_disable(dev);
g_free(dev);
qtest_shutdown(qs);
}
| 1threat
|
Monitor bluetooth peripheral state changes even when the app is killed : <p>At the moment I am using <code>CBCentralManager</code>'s constructor that accepts its delegate and other params. From that point on if the app is in foreground or background state the delegate method is called as expected as soon as the bluetooth state changes (such as turnOn/turnOff). When the app is not running even in background i.e when the app is killed, the app is not launched and the delegate method is never called by the system.</p>
<p>I've made sure that i have <code>bluetooth-central</code> and <code>bluetooth-peripheral</code> under <code>UIBackgroundModes</code> in the <code>Info.plist</code>.</p>
<p>So is there any way to receive the state change notifications even when the app is not running at all?</p>
<p><strong>Sidenote</strong>: Our app relies on bluetooth to function properly so it is important to keep the bluetooth turned on. Idea is if a user turns off the bluetooth we need to alert them via local notification that it needs to be turned on for our app function properly.</p>
| 0debug
|
How to download any files from server in android studio kotlin : <p>I am fairly new to Kotlin so I will like to try to create app that let users download files eg videos and save them into internal storage. Please help me out. Thanks in advance 🙏🏾 </p>
| 0debug
|
static void gen_dccci(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
#endif
}
| 1threat
|
void vnc_tight_clear(VncState *vs)
{
int i;
for (i=0; i<ARRAY_SIZE(vs->tight_stream); i++) {
if (vs->tight_stream[i].opaque) {
deflateEnd(&vs->tight_stream[i]);
}
}
buffer_free(&vs->tight);
buffer_free(&vs->tight_zlib);
buffer_free(&vs->tight_gradient);
#ifdef CONFIG_VNC_JPEG
buffer_free(&vs->tight_jpeg);
#endif
}
| 1threat
|
static int xen_pt_register_regions(XenPCIPassthroughState *s)
{
int i = 0;
XenHostPCIDevice *d = &s->real_device;
for (i = 0; i < PCI_ROM_SLOT; i++) {
XenHostPCIIORegion *r = &d->io_regions[i];
uint8_t type;
if (r->base_addr == 0 || r->size == 0) {
continue;
}
s->bases[i].access.u = r->base_addr;
if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) {
type = PCI_BASE_ADDRESS_SPACE_IO;
} else {
type = PCI_BASE_ADDRESS_SPACE_MEMORY;
if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) {
type |= PCI_BASE_ADDRESS_MEM_PREFETCH;
}
if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) {
type |= PCI_BASE_ADDRESS_MEM_TYPE_64;
}
}
memory_region_init_io(&s->bar[i], OBJECT(s), &ops, &s->dev,
"xen-pci-pt-bar", r->size);
pci_register_bar(&s->dev, i, type, &s->bar[i]);
XEN_PT_LOG(&s->dev, "IO region %i registered (size=0x%08"PRIx64
" base_addr=0x%08"PRIx64" type: %#x)\n",
i, r->size, r->base_addr, type);
}
if (d->rom.base_addr && d->rom.size) {
uint32_t bar_data = 0;
if (xen_host_pci_get_long(d, PCI_ROM_ADDRESS, &bar_data)) {
return 0;
}
if ((bar_data & PCI_ROM_ADDRESS_MASK) == 0) {
bar_data |= d->rom.base_addr & PCI_ROM_ADDRESS_MASK;
xen_host_pci_set_long(d, PCI_ROM_ADDRESS, bar_data);
}
s->bases[PCI_ROM_SLOT].access.maddr = d->rom.base_addr;
memory_region_init_io(&s->rom, OBJECT(s), &ops, &s->dev,
"xen-pci-pt-rom", d->rom.size);
pci_register_bar(&s->dev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_MEM_PREFETCH,
&s->rom);
XEN_PT_LOG(&s->dev, "Expansion ROM registered (size=0x%08"PRIx64
" base_addr=0x%08"PRIx64")\n",
d->rom.size, d->rom.base_addr);
}
return 0;
}
| 1threat
|
static void dv_decode_ac(DVVideoDecodeContext *s,
BlockInfo *mb, DCTELEM *block, int last_index)
{
int last_re_index;
int shift_offset = mb->shift_offset;
const UINT8 *scan_table = mb->scan_table;
const UINT8 *shift_table = mb->shift_table;
int pos = mb->pos;
int level, pos1, sign, run;
int partial_bit_count;
OPEN_READER(re, &s->gb);
#ifdef VLC_DEBUG
printf("start\n");
#endif
partial_bit_count = mb->partial_bit_count;
if (partial_bit_count > 0) {
UINT8 buf[4];
UINT32 v;
int l, l1;
GetBitContext gb1;
l = 16 - partial_bit_count;
UPDATE_CACHE(re, &s->gb);
#ifdef VLC_DEBUG
printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16));
#endif
v = (mb->partial_bit_buffer << l) | SHOW_UBITS(re, &s->gb, l);
buf[0] = v >> 8;
buf[1] = v;
#ifdef VLC_DEBUG
printf("v=%04x cnt=%d %04x\n",
v, partial_bit_count, (mb->partial_bit_buffer << l));
#endif
init_get_bits(&gb1, buf, 4);
{
OPEN_READER(re1, &gb1);
UPDATE_CACHE(re1, &gb1);
GET_RL_VLC(level, run, re1, &gb1, dv_rl_vlc[0],
TEX_VLC_BITS, 2);
l = re1_index;
CLOSE_READER(re1, &gb1);
}
#ifdef VLC_DEBUG
printf("****run=%d level=%d size=%d\n", run, level, l);
#endif
l1 = (level != 256 && level != 0);
l -= partial_bit_count;
if ((re_index + l + l1) > last_index)
return;
last_re_index = 0;
re_index += l;
mb->partial_bit_count = 0;
UPDATE_CACHE(re, &s->gb);
goto handle_vlc;
}
for(;;) {
UPDATE_CACHE(re, &s->gb);
#ifdef VLC_DEBUG
printf("%2d: bits=%04x index=%d\n",
pos, SHOW_UBITS(re, &s->gb, 16), re_index);
#endif
last_re_index = re_index;
GET_RL_VLC(level, run, re, &s->gb, dv_rl_vlc[0],
TEX_VLC_BITS, 2);
handle_vlc:
#ifdef VLC_DEBUG
printf("run=%d level=%d\n", run, level);
#endif
if (level == 256) {
if (re_index > last_index) {
cannot_read:
re_index = last_re_index;
mb->eob_reached = 0;
break;
}
mb->eob_reached = 1;
break;
} else if (level != 0) {
if ((re_index + 1) > last_index)
goto cannot_read;
sign = SHOW_SBITS(re, &s->gb, 1);
level = (level ^ sign) - sign;
LAST_SKIP_BITS(re, &s->gb, 1);
pos += run;
if (pos >= 64) {
goto read_error;
}
pos1 = scan_table[pos];
level = level << (shift_table[pos1] + shift_offset);
block[pos1] = level;
} else {
if (re_index > last_index)
goto cannot_read;
pos += run;
if (pos >= 64) {
read_error:
#if defined(VLC_DEBUG) || 1
printf("error pos=%d\n", pos);
#endif
mb->eob_reached = 1;
break;
}
}
}
CLOSE_READER(re, &s->gb);
mb->pos = pos;
}
| 1threat
|
Laravel - Send Notifications via Job class - Enqueueing Notifications to redis queue without sending them twice : <p>I want to enqueue notifications to redis queue via a job class.
I ask myself what is the best practice to send notifications via a job and not sending them multiple times. My job is triggered by an artisan command which is triggered every minute to grab and send the latest notifications from database. My fear is that the notification query lasts too long, so the job which grabs the notification hasn'nt finished yet until the next notification sending job is triggered and partly sends the same notifications. Should I put an additional flag in my notifications table to mark notifications as queued or can you solve this anyhow by using redis cache?
Best regards</p>
| 0debug
|
static av_cold int g726_init(AVCodecContext * avctx)
{
G726Context* c = avctx->priv_data;
unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2;
if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) {
av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");
return -1;
}
if(avctx->channels != 1){
av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
return -1;
}
if(index>3){
av_log(avctx, AV_LOG_ERROR, "Unsupported number of bits %d\n", index+2);
return -1;
}
g726_reset(c, index);
c->code_size = index+2;
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
if (avctx->codec->decode)
avctx->sample_fmt = SAMPLE_FMT_S16;
return 0;
}
| 1threat
|
static void pack_yuv(TiffEncoderContext * s, uint8_t * dst, int lnum)
{
AVFrame *p = &s->picture;
int i, j, k;
int w = (s->width - 1) / s->subsampling[0] + 1;
uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]];
for (i = 0; i < w; i++){
for (j = 0; j < s->subsampling[1]; j++)
for (k = 0; k < s->subsampling[0]; k++)
*dst++ = p->data[0][(lnum + j) * p->linesize[0] +
i * s->subsampling[0] + k];
*dst++ = *pu++;
*dst++ = *pv++;
}
}
| 1threat
|
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
{
int pqindex, lowquant;
int status;
int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab;
int field_mode, fcm;
v->numref = 0;
v->p_frame_skipped = 0;
if (v->second_field) {
v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
if (v->fptype & 4)
v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
v->s.current_picture_ptr->f.pict_type = v->s.pict_type;
if (!v->pic_header_flag)
goto parse_common_info;
}
field_mode = 0;
if (v->interlace) {
fcm = decode012(gb);
if (fcm) {
if (fcm == ILACE_FIELD)
field_mode = 1;
}
} else {
fcm = PROGRESSIVE;
}
if (!v->first_pic_header_flag && v->field_mode != field_mode)
return AVERROR_INVALIDDATA;
v->field_mode = field_mode;
v->fcm = fcm;
if (v->field_mode) {
v->s.mb_height = FFALIGN(v->s.height + 15 >> 4, 2);
v->fptype = get_bits(gb, 3);
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
if (v->fptype & 4)
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
} else {
v->s.mb_height = v->s.height + 15 >> 4;
switch (get_unary(gb, 0, 4)) {
case 0:
v->s.pict_type = AV_PICTURE_TYPE_P;
break;
case 1:
v->s.pict_type = AV_PICTURE_TYPE_B;
break;
case 2:
v->s.pict_type = AV_PICTURE_TYPE_I;
break;
case 3:
v->s.pict_type = AV_PICTURE_TYPE_BI;
break;
case 4:
v->s.pict_type = AV_PICTURE_TYPE_P;
v->p_frame_skipped = 1;
break;
}
}
if (v->tfcntrflag)
skip_bits(gb, 8);
if (v->broadcast) {
if (!v->interlace || v->psf) {
v->rptfrm = get_bits(gb, 2);
} else {
v->tff = get_bits1(gb);
v->rff = get_bits1(gb);
}
}
if (v->panscanflag) {
avpriv_report_missing_feature(v->s.avctx, "Pan-scan");
}
if (v->p_frame_skipped) {
return 0;
}
v->rnd = get_bits1(gb);
if (v->interlace)
v->uvsamp = get_bits1(gb);
if (v->field_mode) {
if (!v->refdist_flag)
v->refdist = 0;
else if ((v->s.pict_type != AV_PICTURE_TYPE_B) && (v->s.pict_type != AV_PICTURE_TYPE_BI)) {
v->refdist = get_bits(gb, 2);
if (v->refdist == 3)
v->refdist += get_unary(gb, 0, 16);
}
if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
v->frfd = (v->bfraction * v->refdist) >> 8;
v->brfd = v->refdist - v->frfd - 1;
if (v->brfd < 0)
v->brfd = 0;
}
goto parse_common_info;
}
if (v->fcm == PROGRESSIVE) {
if (v->finterpflag)
v->interpfrm = get_bits1(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI;
}
}
}
parse_common_info:
if (v->field_mode)
v->cur_field_type = !(v->tff ^ v->second_field);
pqindex = get_bits(gb, 5);
if (!pqindex)
return -1;
v->pqindex = pqindex;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = ff_vc1_pquant_table[0][pqindex];
else
v->pq = ff_vc1_pquant_table[1][pqindex];
v->pquantizer = 1;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pquantizer = pqindex < 9;
if (v->quantizer_mode == QUANT_NON_UNIFORM)
v->pquantizer = 0;
v->pqindex = pqindex;
if (pqindex < 9)
v->halfpq = get_bits1(gb);
else
v->halfpq = 0;
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits1(gb);
if (v->postprocflag)
v->postproc = get_bits(gb, 2);
if (v->parse_only)
return 0;
if (v->first_pic_header_flag)
rotate_luts(v);
switch (v->s.pict_type) {
case AV_PICTURE_TYPE_I:
case AV_PICTURE_TYPE_BI:
if (v->fcm == ILACE_FRAME) {
status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
}
status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->condover = CONDOVER_NONE;
if (v->overlap && v->pq <= 8) {
v->condover = decode012(gb);
if (v->condover == CONDOVER_SELECT) {
status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
}
}
break;
case AV_PICTURE_TYPE_P:
if (v->field_mode) {
v->numref = get_bits1(gb);
if (!v->numref) {
v->reffield = get_bits1(gb);
v->ref_field_type[0] = v->reffield ^ !v->cur_field_type;
}
}
if (v->extended_mv)
v->mvrange = get_unary(gb, 0, 3);
else
v->mvrange = 0;
if (v->interlace) {
if (v->extended_dmv)
v->dmvrange = get_unary(gb, 0, 3);
else
v->dmvrange = 0;
if (v->fcm == ILACE_FRAME) {
v->fourmvswitch = get_bits1(gb);
v->intcomp = get_bits1(gb);
if (v->intcomp) {
v->lumscale = get_bits(gb, 6);
v->lumshift = get_bits(gb, 6);
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[0], v->last_lutuv[0], 1);
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[1], v->last_lutuv[1], 1);
v->last_use_ic = 1;
}
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
av_log(v->s.avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
mbmodetab = get_bits(gb, 2);
if (v->fourmvswitch)
v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[mbmodetab];
else
v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];
imvtab = get_bits(gb, 2);
v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
twomvbptab = get_bits(gb, 2);
v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];
if (v->fourmvswitch) {
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
}
}
}
v->k_x = v->mvrange + 9 + (v->mvrange >> 1);
v->k_y = v->mvrange + 8;
v->range_x = 1 << (v->k_x - 1);
v->range_y = 1 << (v->k_y - 1);
if (v->pq < 5)
v->tt_index = 0;
else if (v->pq < 13)
v->tt_index = 1;
else
v->tt_index = 2;
if (v->fcm != ILACE_FRAME) {
int mvmode;
mvmode = get_unary(gb, 1, 4);
lowquant = (v->pq > 12) ? 0 : 1;
v->mv_mode = ff_vc1_mv_pmode_table[lowquant][mvmode];
if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
int mvmode2;
mvmode2 = get_unary(gb, 1, 3);
v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][mvmode2];
if (v->field_mode) {
v->intcompfield = decode210(gb) ^ 3;
} else
v->intcompfield = 3;
v->lumscale2 = v->lumscale = 32;
v->lumshift2 = v->lumshift = 0;
if (v->intcompfield & 1) {
v->lumscale = get_bits(gb, 6);
v->lumshift = get_bits(gb, 6);
}
if ((v->intcompfield & 2) && v->field_mode) {
v->lumscale2 = get_bits(gb, 6);
v->lumshift2 = get_bits(gb, 6);
} else if(!v->field_mode) {
v->lumscale2 = v->lumscale;
v->lumshift2 = v->lumshift;
}
if (v->field_mode && v->second_field) {
if (v->cur_field_type) {
INIT_LUT(v->lumscale , v->lumshift , v->curr_luty[v->cur_field_type^1], v->curr_lutuv[v->cur_field_type^1], 0);
INIT_LUT(v->lumscale2, v->lumshift2, v->last_luty[v->cur_field_type ], v->last_lutuv[v->cur_field_type ], 1);
} else {
INIT_LUT(v->lumscale2, v->lumshift2, v->curr_luty[v->cur_field_type^1], v->curr_lutuv[v->cur_field_type^1], 0);
INIT_LUT(v->lumscale , v->lumshift , v->last_luty[v->cur_field_type ], v->last_lutuv[v->cur_field_type ], 1);
}
v->next_use_ic = v->curr_use_ic = 1;
} else {
INIT_LUT(v->lumscale , v->lumshift , v->last_luty[0], v->last_lutuv[0], 1);
INIT_LUT(v->lumscale2, v->lumshift2, v->last_luty[1], v->last_lutuv[1], 1);
}
v->last_use_ic = 1;
}
v->qs_last = v->s.quarter_sample;
if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else
v->s.quarter_sample = 1;
} else
v->s.quarter_sample = 1;
v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN
|| (v->mv_mode == MV_PMODE_INTENSITY_COMP
&& v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
}
if (v->fcm == PROGRESSIVE) {
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV)
|| v->mv_mode == MV_PMODE_MIXED_MV) {
status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
} else {
v->mv_type_is_raw = 0;
memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
}
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->s.mv_table_index = get_bits(gb, 2);
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
} else if (v->fcm == ILACE_FRAME) {
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = 1;
v->s.mspel = 1;
} else {
mbmodetab = get_bits(gb, 3);
imvtab = get_bits(gb, 2 + v->numref);
if (!v->numref)
v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
else
v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) {
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];
} else {
v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];
}
}
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0;
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
case AV_PICTURE_TYPE_B:
if (v->fcm == ILACE_FRAME) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
if (v->bfraction == 0) {
return -1;
}
}
if (v->extended_mv)
v->mvrange = get_unary(gb, 0, 3);
else
v->mvrange = 0;
v->k_x = v->mvrange + 9 + (v->mvrange >> 1);
v->k_y = v->mvrange + 8;
v->range_x = 1 << (v->k_x - 1);
v->range_y = 1 << (v->k_y - 1);
if (v->pq < 5)
v->tt_index = 0;
else if (v->pq < 13)
v->tt_index = 1;
else
v->tt_index = 2;
if (v->field_mode) {
int mvmode;
if (v->extended_dmv)
v->dmvrange = get_unary(gb, 0, 3);
mvmode = get_unary(gb, 1, 3);
lowquant = (v->pq > 12) ? 0 : 1;
v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode];
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV);
v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || v->mv_mode == MV_PMODE_1MV_HPEL);
status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
mbmodetab = get_bits(gb, 3);
if (v->mv_mode == MV_PMODE_MIXED_MV)
v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];
else
v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];
imvtab = get_bits(gb, 3);
v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
if (v->mv_mode == MV_PMODE_MIXED_MV) {
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
}
v->numref = 1;
} else if (v->fcm == ILACE_FRAME) {
if (v->extended_dmv)
v->dmvrange = get_unary(gb, 0, 3);
if (get_bits1(gb))
av_log(v->s.avctx, AV_LOG_WARNING, "Intensity compensation set for B picture\n");
v->intcomp = 0;
v->mv_mode = MV_PMODE_1MV;
v->fourmvswitch = 0;
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = 1;
v->s.mspel = 1;
status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
mbmodetab = get_bits(gb, 2);
v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];
imvtab = get_bits(gb, 2);
v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
twomvbptab = get_bits(gb, 2);
v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
} else {
v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
v->s.mspel = v->s.quarter_sample;
status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->s.mv_table_index = get_bits(gb, 2);
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
}
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0;
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
}
if (v->fcm != PROGRESSIVE && !v->s.quarter_sample) {
v->range_x <<= 1;
v->range_y <<= 1;
}
v->c_ac_table_index = decode012(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->y_ac_table_index = decode012(gb);
}
v->s.dc_table_index = get_bits1(gb);
if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
&& v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->bi_type = 0;
if (v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->s.pict_type = AV_PICTURE_TYPE_B;
v->bi_type = 1;
}
return 0;
}
| 1threat
|
ngClass compare number with array of numbers dynamically - Angular : <p>I have something like this:</p>
<pre><code>[ngClass]="{className: singleNumber == arrayOfNumbers}
</code></pre>
<p>How do I compare <code>1 === [1,2,3,4]</code> ? it works if I do this: arrayOfNumbers[0]</p>
| 0debug
|
How to recursively get the number of elements until reached all sqaures in 5 x 5 grid in scala : So I have a grid 5 x 5 grid. And my initial position is at (0,0)
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
# 0 0 0 0
I have a method that finds all possible position in 'L' shape from that position
So from **`(0,0)`**.
So either
- **( x + 2 )( y + 1 )**
or
- **( x + 1 )( y + 2 )**
We have two positions
0 0 0 0 0
0 0 0 0 0
0 # 0 0 0
0 0 0 0 0
# 0 0 0 0
or
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 # 0 0
# 0 0 0 0
Then my method will call it self from the list of all the possible moves and finds the position of each one.
The recursion only breaks if the last position in the possible moves list is the same as the initial position.
So the possible moves for position:
- `(0)(0)` is `List((1,2),(2,1))`
- `List((possible moves for (1,2) ), (possible moves for (2,1) ) )`
and so on:
My method so far
=
<!-- language: scala -->
def CountTour(dimension: Int, path: Path): Int = {
// possibleMoves returns list of possible moves
val Moves = possibleMoves(dim, path, path.head).contains(path.last)
// if the last element is not the same as first position, and has visited the whole graph, then break the recursion
if (legalMoves && path.size == (dim * dim)) {
1
} else {
// else call the same method again with each possible move
val newList = for (i <- legal_moves(dim, path, path.head)) yield i
count_tours(dim,newList)
}
}
<!-- end snippet -->
However this won't work. How can i fix it?
| 0debug
|
what are mapping functions in c++? : <p>I have searched about mapping functions in n dimensional array but didn't find particular answer. I want to know that how multidimensional arrays works i c++? what is general formula for finding element at particular index in n dimensional array.?</p>
| 0debug
|
AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
{
AVFilterFormats *ret;
unsigned i, j, k = 0;
ret = av_mallocz(sizeof(AVFilterFormats));
ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count,
b->format_count));
for(i = 0; i < a->format_count; i ++)
for(j = 0; j < b->format_count; j ++)
if(a->formats[i] == b->formats[j])
ret->formats[k++] = a->formats[i];
if(!(ret->format_count = k)) {
av_free(ret->formats);
av_free(ret);
return NULL;
}
ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));
for(i = 0; i < a->refcount; i ++) {
ret->refs[ret->refcount] = a->refs[i];
*ret->refs[ret->refcount++] = ret;
}
for(i = 0; i < b->refcount; i ++) {
ret->refs[ret->refcount] = b->refs[i];
*ret->refs[ret->refcount++] = ret;
}
av_free(a->refs);
av_free(a->formats);
av_free(a);
av_free(b->refs);
av_free(b->formats);
av_free(b);
return ret;
}
| 1threat
|
When would you not drop a table before creating it? : <p>I don't understand why you wouldn't ever not drop a table before creating it. Do you want to do this when you want to restart a table from scratch and delete everything? I mean, you can't create the same table without dropping it first right? So wouldn't you always need to to use drop first?</p>
| 0debug
|
What is the difference between fields and properties in Julia? : <p>Julia has the setter functions <code>setproperty!</code> and <code>setfield!</code> and the getter functions <code>getproperty</code> and <code>getfield</code> that operate on structs. What is the difference between properties and fields in Julia?</p>
<p>For example, the following seems to indicate that they do the same thing:</p>
<pre><code>julia> mutable struct S
a
end
julia> s = S(2)
S(2)
julia> getfield(s, :a)
2
julia> getproperty(s, :a)
2
julia> setfield!(s, :a, 3)
3
julia> s
S(3)
julia> setproperty!(s, :a, 4)
4
julia> s
S(4)
</code></pre>
| 0debug
|
Change service config parameters at runtime : <p>I'm using mailgun to send mails thought Laravel 5.2. It configured on config/services.php like that:</p>
<pre><code> 'mailgun' => [
'domain' => env('mailgun_domain','mydomain.com'),
'secret' => env('mailgin_secret','my-secret-key-132152345423')
],
</code></pre>
<p>But, I need change that settings in run time, before call Mail::send, to use the correct service parameters. It must be changed many times during runtime.</p>
<p>I <strong>cannot configure it by .env file</strong>, because all data will be get from database, where the user setups the domain and secret.</p>
| 0debug
|
Is kubectl port-forward encrypted? : <p>I couldn't find any information on wherever a connection creation between cluster's pod and locahost is encrypted when running "kubectl port-forward" command.</p>
<p>It seems like it uses "<a href="https://linux.die.net/man/1/socat" rel="noreferrer">socat</a>" library which supports encryption, but I'm not sure if kubernetes actually uses it.</p>
| 0debug
|
virtio_crypto_check_cryptodev_is_used(const Object *obj, const char *name,
Object *val, Error **errp)
{
if (cryptodev_backend_is_used(CRYPTODEV_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(errp,
"can't use already used cryptodev backend: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, errp);
}
}
| 1threat
|
Why does increase() return a value of 1.33 in prometheus? : <p>We graph a timeseries with <code>sum(increase(foo_requests_total[1m]))</code> to show the number of foo requests per minute. Requests come in quite sporadically - just a couple of requests per day. The value that is shown in the graph is always 1.3333. Why is the value not 1? There was one request during this minute.</p>
<p><a href="https://i.stack.imgur.com/eGgIh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eGgIh.png" alt="enter image description here"></a></p>
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
static av_cold int cook_decode_init(AVCodecContext *avctx)
{
COOKContext *q = avctx->priv_data;
const uint8_t *edata_ptr = avctx->extradata;
const uint8_t *edata_ptr_end = edata_ptr + avctx->extradata_size;
int extradata_size = avctx->extradata_size;
int s = 0;
unsigned int channel_mask = 0;
q->avctx = avctx;
if (extradata_size <= 0) {
av_log(avctx,AV_LOG_ERROR,"Necessary extradata missing!\n");
return -1;
}
av_log(avctx,AV_LOG_DEBUG,"codecdata_length=%d\n",avctx->extradata_size);
q->sample_rate = avctx->sample_rate;
q->nb_channels = avctx->channels;
q->bit_rate = avctx->bit_rate;
av_lfg_init(&q->random_state, 0);
while(edata_ptr < edata_ptr_end){
if (extradata_size >= 8){
q->subpacket[s].cookversion = bytestream_get_be32(&edata_ptr);
q->subpacket[s].samples_per_frame = bytestream_get_be16(&edata_ptr);
q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr);
extradata_size -= 8;
}
if (avctx->extradata_size >= 8){
bytestream_get_be32(&edata_ptr);
q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr);
q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr);
extradata_size -= 8;
}
q->subpacket[s].samples_per_channel = q->subpacket[s].samples_per_frame / q->nb_channels;
q->subpacket[s].bits_per_subpacket = avctx->block_align * 8;
q->subpacket[s].log2_numvector_size = 5;
q->subpacket[s].total_subbands = q->subpacket[s].subbands;
q->subpacket[s].num_channels = 1;
av_log(avctx,AV_LOG_DEBUG,"subpacket[%i].cookversion=%x\n",s,q->subpacket[s].cookversion);
q->subpacket[s].joint_stereo = 0;
switch (q->subpacket[s].cookversion) {
case MONO:
if (q->nb_channels != 1) {
av_log_ask_for_sample(avctx, "Container channels != 1.\n");
return -1;
}
av_log(avctx,AV_LOG_DEBUG,"MONO\n");
break;
case STEREO:
if (q->nb_channels != 1) {
q->subpacket[s].bits_per_subpdiv = 1;
q->subpacket[s].num_channels = 2;
}
av_log(avctx,AV_LOG_DEBUG,"STEREO\n");
break;
case JOINT_STEREO:
if (q->nb_channels != 2) {
av_log_ask_for_sample(avctx, "Container channels != 2.\n");
return -1;
}
av_log(avctx,AV_LOG_DEBUG,"JOINT_STEREO\n");
if (avctx->extradata_size >= 16){
q->subpacket[s].total_subbands = q->subpacket[s].subbands + q->subpacket[s].js_subband_start;
q->subpacket[s].joint_stereo = 1;
q->subpacket[s].num_channels = 2;
}
if (q->subpacket[s].samples_per_channel > 256) {
q->subpacket[s].log2_numvector_size = 6;
}
if (q->subpacket[s].samples_per_channel > 512) {
q->subpacket[s].log2_numvector_size = 7;
}
break;
case MC_COOK:
av_log(avctx,AV_LOG_DEBUG,"MULTI_CHANNEL\n");
if(extradata_size >= 4)
channel_mask |= q->subpacket[s].channel_mask = bytestream_get_be32(&edata_ptr);
if(cook_count_channels(q->subpacket[s].channel_mask) > 1){
q->subpacket[s].total_subbands = q->subpacket[s].subbands + q->subpacket[s].js_subband_start;
q->subpacket[s].joint_stereo = 1;
q->subpacket[s].num_channels = 2;
q->subpacket[s].samples_per_channel = q->subpacket[s].samples_per_frame >> 1;
if (q->subpacket[s].samples_per_channel > 256) {
q->subpacket[s].log2_numvector_size = 6;
}
if (q->subpacket[s].samples_per_channel > 512) {
q->subpacket[s].log2_numvector_size = 7;
}
}else
q->subpacket[s].samples_per_channel = q->subpacket[s].samples_per_frame;
break;
default:
av_log_ask_for_sample(avctx, "Unknown Cook version.\n");
return -1;
}
if(s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) {
av_log(avctx,AV_LOG_ERROR,"different number of samples per channel!\n");
return -1;
} else
q->samples_per_channel = q->subpacket[0].samples_per_channel;
q->subpacket[s].numvector_size = (1 << q->subpacket[s].log2_numvector_size);
if (q->subpacket[s].total_subbands > 53) {
av_log_ask_for_sample(avctx, "total_subbands > 53\n");
return -1;
}
if ((q->subpacket[s].js_vlc_bits > 6) || (q->subpacket[s].js_vlc_bits < 0)) {
av_log(avctx,AV_LOG_ERROR,"js_vlc_bits = %d, only >= 0 and <= 6 allowed!\n",q->subpacket[s].js_vlc_bits);
return -1;
}
if (q->subpacket[s].subbands > 50) {
av_log_ask_for_sample(avctx, "subbands > 50\n");
return -1;
}
q->subpacket[s].gains1.now = q->subpacket[s].gain_1;
q->subpacket[s].gains1.previous = q->subpacket[s].gain_2;
q->subpacket[s].gains2.now = q->subpacket[s].gain_3;
q->subpacket[s].gains2.previous = q->subpacket[s].gain_4;
q->num_subpackets++;
s++;
if (s > MAX_SUBPACKETS) {
av_log_ask_for_sample(avctx, "Too many subpackets > 5\n");
return -1;
}
}
init_pow2table();
init_gain_table(q);
init_cplscales_table(q);
if (init_cook_vlc_tables(q) != 0)
return -1;
if(avctx->block_align >= UINT_MAX/2)
return -1;
q->decoded_bytes_buffer =
av_mallocz(avctx->block_align
+ DECODE_BYTES_PAD1(avctx->block_align)
+ FF_INPUT_BUFFER_PADDING_SIZE);
if (q->decoded_bytes_buffer == NULL)
return -1;
if ( init_cook_mlt(q) != 0 )
return -1;
if (1) {
q->scalar_dequant = scalar_dequant_float;
q->decouple = decouple_float;
q->imlt_window = imlt_window_float;
q->interpolate = interpolate_float;
q->saturate_output = saturate_output_float;
}
if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) {
} else {
av_log_ask_for_sample(avctx,
"unknown amount of samples_per_channel = %d\n",
q->samples_per_channel);
return -1;
}
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (channel_mask)
avctx->channel_layout = channel_mask;
else
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
#ifdef DEBUG
dump_cook_context(q);
#endif
return 0;
}
| 1threat
|
static void bdrv_sync_complete(void *opaque, int ret)
{
}
| 1threat
|
Python (Turtle) drawing help Please : So my problem is that my height of the tower variable is not printing at all, and I feel if it did it would not work, I cannot understand why this isn't working please help.
My Code:
import turtle
bob = turtle.Turtle()
turtle.setup(width = 400, height = 300)
turtle.bgcolor("orange")
n = int(input("Please enter number of towers: "))
h = (input("Please enter height of towers : "))
x = str(h.split(","))
def ocean():
bob.setpos(-200, 0)
bob.color("midnightblue", "midnightblue")
bob.begin_fill()
for x in range(1, 3):
bob.forward(400)
bob.right(90)
bob.forward(150)
bob.right(90)
bob.end_fill()
def tower():
bob.right(90)
for x in range (0,n):
bob.forward(x)
ocean()
tower()
| 0debug
|
mode of a duplicate classifier is worth it? : hello i have a question about a classifier concept.
case 1
if i have a classifier and the performance of that classifier up to 90%.
and i create n another classifier with the same algorithm and same dataset and get performance 90% too.
case2
same like case 1 but every classifier with a different algorithm.
and in the end
the result i get from
mode(classifier1,classifier2,classifier3,...,classifiern).
is that technique worth it or useless (case1, and case2)?
thanks.
| 0debug
|
Install tensorflow on Ubuntu 14.04 : <p>I'm trying to follow <a href="https://www.tensorflow.org/get_started/os_setup#pip_installation" rel="noreferrer">these instructions</a> </p>
<p><code>sudo apt-get install python-pip python-dev</code></p>
<p><code>sudo pip install tensorflow</code></p>
<pre><code>user@user-VirtualBox:~$ sudo pip install tensorflow
Downloading/unpacking tensorflow
Could not find any downloads that satisfy the requirement tensorflow
Cleaning up...
No distributions at all found for tensorflow
Storing debug log for failure in /home/user/.pip/pip.log
</code></pre>
<p>Here is pip log:</p>
<pre><code>user@user-VirtualBox:~$ cat /home/user/.pip/pip.log
------------------------------------------------------------
/usr/bin/pip run on Thu Jan 26 17:25:02 2017
Downloading/unpacking tensorflow
Getting page https://pypi.python.org/simple/tensorflow/
URLs to search for versions for tensorflow:
* https://pypi.python.org/simple/tensorflow/
Analyzing links from page https://pypi.python.org/simple/tensorflow/
Skipping https://pypi.python.org/packages/00/16/c8ba385fc6511ca362f32326cd1d6a99bbbabbc8341607ff70c290e0be7b/tensorflow-0.12.1-cp34-cp34m-manylinux1_x86_64.whl#md5=981c0a406eb9865423b11c03b489040d (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/01/c5/adefd2d5c83e6d8b4a8efa5dd00e44dc05de317b744fb58aef6d8366ce2b/tensorflow-0.12.0-cp27-cp27mu-manylinux1_x86_64.whl#md5=ebcd1b32ccf2279bfa688542cbdad5fb (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/03/51/b68d9d6481d16fd709290030ae8a8a13212587bc87fae718e521bdafa723/tensorflow-0.12.0rc1-cp27-cp27mu-manylinux1_x86_64.whl#md5=9329984aa4f6388f5ec2a170e4ae968e (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/11/c9/2ec86336a8a401a57fabed5b10ee7f0493fc334b33e9672766b1149dd923/tensorflow-0.12.0-cp35-cp35m-win_amd64.whl#md5=d515d2ae08ae25fc8bf81e3374448146 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/16/6e/fa1f09a32d3ba5bf6a2b79c6ec16a43c91e3a79e0035ab3eb52ecad22e0d/tensorflow-0.12.1-cp35-cp35m-macosx_10_11_x86_64.whl#md5=faf5d055cdaecd75e5f0b37a04676102 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/25/23/24681ce011cd33ea5b22b8efd0f28a3f1294085c6ca6f70cc3abd62bf75d/tensorflow-0.12.0rc1-cp35-cp35m-macosx_10_11_x86_64.whl#md5=6c964e9575ed88892b94195a05aa8e65 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/25/c4/162ea5fa9e012f5a5e125105f6b290e56f9fd617a7aadd57d9a26bb386ca/tensorflow-0.12.0rc1-cp34-cp34m-manylinux1_x86_64.whl#md5=4e77b31ae9fc0e36489875ce0f72b267 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/33/4b/20e517870effa573405d30dafc22f330f24c0a8928659b4ad5a44b9a9af2/tensorflow-0.12.0rc0-cp35-cp35m-macosx_10_11_x86_64.whl#md5=8d1376a68f768efa57b1344fc2df0472 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/33/ab/3a62133d6c9f6281959f3ca96ad2a796fb4fed8d642c4f33d9fd97d8bf6f/tensorflow-0.12.0rc1-cp27-cp27m-macosx_10_11_x86_64.whl#md5=491802c10e992905d7e80108b9b16920 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/34/53/0e10581ad88bca25e5005874e46130b12efbd5eb1bda493dbf9b1648cbe2/tensorflow-0.12.1-cp27-cp27m-macosx_10_11_x86_64.whl#md5=d3f44a0596a623458c42c2a694abb0af (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/4a/c3/1ad85e5c4fde90b2e9a5101283d97dd41ba6c24f44a1c3a8495ef7098bb5/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl#md5=dad56a38acf7ca501b1bfeeef53f3710 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/64/9c/72aff7713c507f7e6c15df011e0ed18ac85e5bfa16c3763d8cba44585d79/tensorflow-0.12.0rc0-cp34-cp34m-manylinux1_x86_64.whl#md5=93431c5cd8a019d08a72e6c0a75eaaf4 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/64/a3/0054a3329579de44d557f491adbcaf8127809a7992bc46af80f0a589e29b/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl#md5=d657836c76a5cd3c6d5560034bd7ade6 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/66/47/d6bb91a11684733ad565b891d561097ef10f8cb7bae87e5ad692207024e3/tensorflow-0.12.0rc1-cp35-cp35m-manylinux1_x86_64.whl#md5=2351fe799a0869487699537ab0e33019 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/67/06/15153c48b2281bc59f8a70f2ae681723ece29ebc0015883117fb28abaf68/tensorflow-0.12.0rc0-cp35-cp35m-manylinux1_x86_64.whl#md5=ebc1ee880633a60e5256e745a27d4058 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/7e/c6/837f4e249aae5c86a632eaaa9779e601eca1487772f8ad75c347bf9e813f/tensorflow-0.12.1-cp27-cp27mu-manylinux1_x86_64.whl#md5=c98fd26b79a97cc490c942bbafed5462 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/7e/ea/e42e47ddb39d2043a06dc93b5aec042bae8571be52ea664aa03246a83c32/tensorflow-0.12.0-cp35-cp35m-macosx_10_11_x86_64.whl#md5=f8b165ae638eb169220ccbf02658475b (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/90/cf/1d1e12f9f39b6a0ed1c49792ef5ce7615dddc2ce7287fc83ede0dddb9b3c/tensorflow-0.12.0rc0-cp27-cp27m-macosx_10_11_x86_64.whl#md5=7be7b7488a6be83546758a40d5442901 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/91/7c/98b25b74241194d4312a7e230c85a77b254224191dbf17b484811f8a9f61/tensorflow-0.12.1-cp36-cp36m-macosx_10_11_x86_64.whl#md5=3b2f5f08fe61471ea973a4bdbdfbae43 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/96/d6/096f6624a8a48d41801eb23863d35a37532baf32f6d3aa2e03c96f66e6ab/tensorflow-0.12.0-cp34-cp34m-manylinux1_x86_64.whl#md5=a6a0af9cf2a5fc33053f638b05cb3940 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/9e/7c/f50ca985e43cff46a6d92abb088e8328b9be13335dc44af291ac1ed11862/tensorflow-0.12.0-cp35-cp35m-manylinux1_x86_64.whl#md5=2c07109df1a9865a7a44b6fe08756e8d (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/a7/86/cb47c1213779939583091fc97e0950c323d655186824cdbc0f657f42930c/tensorflow-0.12.0-cp27-cp27m-macosx_10_11_x86_64.whl#md5=fc429a5b5b74517e08216ee8b1d04e59 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/b2/da/9132af1e2ef3771b63619072a6d82800bd60acbf2c8bea8e4f26514c768a/tensorflow-0.12.0rc1-cp35-cp35m-win_amd64.whl#md5=69b6c2e9440fd2d7a2d86249933fcde0 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/e5/5c/56e6522fdcd6f8739dcbc4de62e8b0040e141785bb42e5b53a83b0ba3e58/tensorflow-0.12.1-cp35-cp35m-manylinux1_x86_64.whl#md5=c6e3ba8579754f37d37be26e863f9d95 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/e7/73/85ff235957f2652f78a2cd7f0a045d3f983302991cb7af2fddedf27d56fe/tensorflow-0.12.1-cp33-cp33m-manylinux1_x86_64.whl#md5=d77e48ef3b45e543ca165db93f27e0ff (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/e9/a5/45b172f20e2fabd19c7f18a44570fc82acc4c628ec9bc4b313de39c4fe37/tensorflow-0.12.1-cp36-cp36m-manylinux1_x86_64.whl#md5=def6ab7dc3930f34f3000caef34f4333 (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Skipping https://pypi.python.org/packages/f6/2a/e5bb6320a3fc2886f2677ffa0d4396eefb5914cfc19db94e672c650f0700/tensorflow-0.12.0rc0-cp27-cp27mu-manylinux1_x86_64.whl#md5=00a6b89122d86fd527558a2740fd6f8f (from https://pypi.python.org/simple/tensorflow/) because it is not compatible with this Python
Could not find any downloads that satisfy the requirement tensorflow
Cleaning up...
Removing temporary dir /tmp/pip_build_root...
No distributions at all found for tensorflow
Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1178, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 277, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for tensorflow
</code></pre>
<p>So as I understand it needs some other python version? my python version is
<code>python --version</code> Python 2.7.6</p>
<p>Also I tried (and it works):</p>
<p><code>export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl
</code></p>
<p><code>sudo pip install --upgrade $TF_BINARY_URL</code></p>
<p>But I wonder why installation via <code>sudo pip install tensorflow</code> not working?</p>
| 0debug
|
How to get a text from SearchView? : <p>I need to get a text from SearchView and compare it to strings in my activity's ListView and show a Toast if the word in a SearchView is in my ListView. How do I do that? Here's my working code for the SearchView:</p>
<pre><code>MenuItem ourSearchItem = menu.findItem(R.id.menu_item_search);
SearchView sv = (SearchView) ourSearchItem.getActionView();
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
adapter.getFilter().filter(newText);
}
return false;
}
});
</code></pre>
| 0debug
|
how to get value of cell in table and display it in textbox : <p>I have a table like this:</p>
<pre><code><table id="mytable">
<tr>
<th>Customer Id</th>
<th>Name</th>
</tr>
<tr>
<td>123</td>
<td>A</td>
</tr>
<tr>
<td>456</td>
<td>B</td>
</tr>
<tr>
<td>789</td>
<td>C</td>
</tr>
</table>
<form>
<input type="text" name="txtDsCode" id="txtDsCode"/>
</form>
</code></pre>
<p>When I click on the <code>textbox</code> and then click on the <code>cell</code> in the table , the value of the cell will display in the <code>textbox</code>.
How should i do it with javascript?
Thanks all!</p>
| 0debug
|
static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params;
VAAPIEncodeH264Context *priv = ctx->priv_data;
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
int i;
{
vseq->seq_parameter_set_id = 0;
vseq->level_idc = avctx->level;
vseq->max_num_ref_frames = 1 + (avctx->max_b_frames > 0);
vseq->picture_width_in_mbs = priv->mb_width;
vseq->picture_height_in_mbs = priv->mb_height;
vseq->seq_fields.bits.chroma_format_idc = 1;
vseq->seq_fields.bits.frame_mbs_only_flag = 1;
vseq->seq_fields.bits.direct_8x8_inference_flag = 1;
vseq->seq_fields.bits.log2_max_frame_num_minus4 = 4;
vseq->seq_fields.bits.pic_order_cnt_type = 0;
if (avctx->width != ctx->surface_width ||
avctx->height != ctx->surface_height) {
vseq->frame_cropping_flag = 1;
vseq->frame_crop_left_offset = 0;
vseq->frame_crop_right_offset =
(ctx->surface_width - avctx->width) / 2;
vseq->frame_crop_top_offset = 0;
vseq->frame_crop_bottom_offset =
(ctx->surface_height - avctx->height) / 2;
} else {
vseq->frame_cropping_flag = 0;
}
vseq->vui_parameters_present_flag = 1;
if (avctx->sample_aspect_ratio.num != 0) {
vseq->vui_fields.bits.aspect_ratio_info_present_flag = 1;
if (avctx->sample_aspect_ratio.num ==
avctx->sample_aspect_ratio.den) {
vseq->aspect_ratio_idc = 1;
} else {
vseq->aspect_ratio_idc = 255;
vseq->sar_width = avctx->sample_aspect_ratio.num;
vseq->sar_height = avctx->sample_aspect_ratio.den;
}
}
if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
avctx->colorspace != AVCOL_SPC_UNSPECIFIED) {
mseq->video_signal_type_present_flag = 1;
mseq->video_format = 5;
mseq->video_full_range_flag = 0;
mseq->colour_description_present_flag = 1;
mseq->colour_primaries = avctx->color_primaries;
mseq->transfer_characteristics = avctx->color_trc;
mseq->matrix_coefficients = avctx->colorspace;
}
vseq->vui_fields.bits.bitstream_restriction_flag = 1;
mseq->motion_vectors_over_pic_boundaries_flag = 1;
mseq->max_bytes_per_pic_denom = 0;
mseq->max_bits_per_mb_denom = 0;
vseq->vui_fields.bits.log2_max_mv_length_horizontal = 16;
vseq->vui_fields.bits.log2_max_mv_length_vertical = 16;
mseq->max_num_reorder_frames = (avctx->max_b_frames > 0);
mseq->max_dec_pic_buffering = vseq->max_num_ref_frames;
vseq->bits_per_second = avctx->bit_rate;
vseq->vui_fields.bits.timing_info_present_flag = 1;
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
vseq->num_units_in_tick = avctx->framerate.den;
vseq->time_scale = 2 * avctx->framerate.num;
mseq->fixed_frame_rate_flag = 1;
} else {
vseq->num_units_in_tick = avctx->time_base.num;
vseq->time_scale = 2 * avctx->time_base.den;
mseq->fixed_frame_rate_flag = 0;
}
if (ctx->va_rc_mode == VA_RC_CBR) {
priv->send_timing_sei = 1;
mseq->nal_hrd_parameters_present_flag = 1;
mseq->cpb_cnt_minus1 = 0;
mseq->bit_rate_scale =
av_clip_uintp2(av_log2(avctx->bit_rate) - 15 - 6, 4);
mseq->bit_rate_value_minus1[0] =
(avctx->bit_rate >> mseq->bit_rate_scale + 6) - 1;
mseq->cpb_size_scale =
av_clip_uintp2(av_log2(ctx->hrd_params.hrd.buffer_size) - 15 - 4, 4);
mseq->cpb_size_value_minus1[0] =
(ctx->hrd_params.hrd.buffer_size >> mseq->cpb_size_scale + 4) - 1;
mseq->cbr_flag[0] = 0;
mseq->initial_cpb_removal_delay_length_minus1 = 23;
mseq->cpb_removal_delay_length_minus1 = 23;
mseq->dpb_output_delay_length_minus1 = 7;
mseq->time_offset_length = 0;
mseq->initial_cpb_removal_delay = 90000 *
(uint64_t)ctx->hrd_params.hrd.initial_buffer_fullness /
ctx->hrd_params.hrd.buffer_size;
mseq->initial_cpb_removal_delay_offset = 0;
} else {
priv->send_timing_sei = 0;
mseq->nal_hrd_parameters_present_flag = 0;
}
vseq->intra_period = ctx->p_per_i * (ctx->b_per_p + 1);
vseq->intra_idr_period = vseq->intra_period;
vseq->ip_period = ctx->b_per_p + 1;
}
{
vpic->CurrPic.picture_id = VA_INVALID_ID;
vpic->CurrPic.flags = VA_PICTURE_H264_INVALID;
for (i = 0; i < FF_ARRAY_ELEMS(vpic->ReferenceFrames); i++) {
vpic->ReferenceFrames[i].picture_id = VA_INVALID_ID;
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID;
}
vpic->coded_buf = VA_INVALID_ID;
vpic->pic_parameter_set_id = 0;
vpic->seq_parameter_set_id = 0;
vpic->num_ref_idx_l0_active_minus1 = 0;
vpic->num_ref_idx_l1_active_minus1 = 0;
vpic->pic_fields.bits.entropy_coding_mode_flag =
((avctx->profile & 0xff) != 66);
vpic->pic_fields.bits.weighted_pred_flag = 0;
vpic->pic_fields.bits.weighted_bipred_idc = 0;
vpic->pic_fields.bits.transform_8x8_mode_flag =
((avctx->profile & 0xff) >= 100);
vpic->pic_init_qp = priv->fixed_qp_idr;
}
{
mseq->profile_idc = avctx->profile & 0xff;
if (avctx->profile & FF_PROFILE_H264_CONSTRAINED)
mseq->constraint_set1_flag = 1;
if (avctx->profile & FF_PROFILE_H264_INTRA)
mseq->constraint_set3_flag = 1;
}
return 0;
}
| 1threat
|
Why my heroku node.js app is giving at=error code=H10 desc="App crashed" method=GET path="/"? : <p>I am trying to run my simple node app on Heroku. </p>
<p>Here is the directory structure</p>
<pre><code>├── app.js
├── assets
├── blog.html
├── index.html
├── node_modules
└── package.json
</code></pre>
<p>Here is my app.js</p>
<pre><code>let express = require('express'),
path = require('path');
var app = express();
let server = require('http').Server(app);
app.use(express.static(path.join(__dirname)));
app.get('/', function(req, res, next){
res.sendStatus(200);
});
app.get('/blog.html', function(req, res,next){
res.sendFile(path.join(__dirname+"/blog.html"));
});
app.post('/contact', function(req, res, next){
});
server.listen('8000', function() {
console.log("App is running on port 8000");
});
</code></pre>
<p>Here is the package.json</p>
<pre><code>{
"name": "website",
"version": "1.0.0",
"engines" : {
"node" : "6.3.1",
"npm" : "3.10.3"
},
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start" : "node app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.14.0"
}
}
</code></pre>
<p>When I go to the console it rightly prints app is starting at xxxx port.
But then the app crashes with the following message</p>
<pre><code>2016-08-10T13:12:49.839138+00:00 app[web.1]: App is running on port xxxx
2016-08-10T13:13:34.944963+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=saras-website.herokuapp.com request_id=28d8705a-d5a4-4aaa-bd8d-4c4c6101fbd4 fwd="106.51.20.181" dyno= connect= service= status=503 bytes=
2016-08-10T13:13:48.295315+00:00 heroku[web.1]: State changed from starting to crashed
2016-08-10T13:13:48.552740+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=saras-website.herokuapp.com request_id=b77e151f-7017-482d-b4ba-15d980534fd7 fwd="106.51.20.181" dyno= connect= service= status=503 bytes=
2016-08-10T13:13:50.163466+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=saras-website.herokuapp.com request_id=1e7b57e5-1056-4cb3-b41f-cd3f11794efe fwd="106.51.20.181" dyno= connect= service= status=503 bytes=
</code></pre>
<p>I don't know what am I doing wrong here... Help is appreciated</p>
| 0debug
|
resize program works for some and not others : > so the problem, is suppose to take 3 arguments (factor, infile and outfile) the factor is a positive integer from 1 - 100. the program then is suppose to resize the infile image depending on the factor, 1 produce the same image and 2 twice as big and so on to the outfile.
currently my program does this succesfully for some images and only on certain scale factors.
when i run it through my courses ide check program for this question the errors i recieve are;
**:) resize.c and bmp.h exist.
:) resize.c compiles.
:) doesn't resize small.bmp when n is 1
:( resizes small.bmp correctly when n is 2
Byte 34 of pixel data doesn't match. Expected 0xff, not 0x00
:( resizes small.bmp correctly when n is 3
Byte 48 of pixel data doesn't match. Expected 0xff, not 0x00
:( resizes small.bmp correctly when n is 4
Byte 62 of pixel data doesn't match. Expected 0xff, not 0x00
:( resizes small.bmp correctly when n is 5
Byte 80 of pixel data doesn't match. Expected 0xff, not 0x00
:) resizes large.bmp correctly when n is 2
:) resizes smiley.bmp correctly when n is 2**
```C
// Copies a BMP file and resizes it
#include <stdio.h>
#include <stdlib.h>
#include "bmp.h"
int main(int argc, char *argv[])
{
// ensure proper usage
if (argc != 4)
{
fprintf(stderr, "Usage: ./resize factor infile outfile\n");
return 1;
}
// Check argument 1 to see if integer within aceptable range
int factor = atoi(argv[1]);
if (factor <= 0 || factor > 100)
{
fprintf(stderr, "Must be a positive integer greater than 0 and eqaul or less than 100\n");
return 1;
}
// remember filenames
char *infile = argv[2];
char *outfile = argv[3];
// open input file
FILE *inptr = fopen(infile, "r");
if (inptr == NULL)
{
fprintf(stderr, "Could not open %s.\n", infile);
return 2;
}
// open output file
FILE *outptr = fopen(outfile, "w");
if (outptr == NULL)
{
fclose(inptr);
fprintf(stderr, "Could not create %s.\n", outfile);
return 3;
}
// read infile's BITMAPFILEHEADER
BITMAPFILEHEADER bf;
BITMAPFILEHEADER bf_New;
fread(&bf, sizeof(BITMAPFILEHEADER), 1, inptr);
bf_New = bf;
// read infile's BITMAPINFOHEADER
BITMAPINFOHEADER bi;
BITMAPINFOHEADER bi_New;
fread(&bi, sizeof(BITMAPINFOHEADER), 1, inptr);
bi_New = bi;
// ensure infile is (likely) a 24-bit uncompressed BMP 4.0
if (bf.bfType != 0x4d42 || bf.bfOffBits != 54 || bi.biSize != 40 ||
bi.biBitCount != 24 || bi.biCompression != 0)
{
fclose(outptr);
fclose(inptr);
fprintf(stderr, "Unsupported file format.\n");
return 4;
}
// set new height and width of BMP
bi_New.biHeight = bi.biHeight * factor;
bi_New.biWidth = bi.biWidth * factor;
// calculate padding for old file and new file
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
int padding_New = (4 - (bi_New.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
// set the file size for the new file
bi_New.biSizeImage = (bi_New.biWidth * sizeof(RGBTRIPLE) + padding_New) * abs(bi_New.biHeight);
bf_New.bfSize = bi_New.biSizeImage + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
// write outfile's BITMAPFILEHEADER
fwrite(&bf_New, sizeof(BITMAPFILEHEADER), 1, outptr);
// write outfile's BITMAPINFOHEADER
fwrite(&bi_New, sizeof(BITMAPINFOHEADER), 1, outptr);
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// itterate factor times
for (int k = 0; k < factor; k++)
{
// iterate over pixels in scanline
for (int j = 0; j < bi.biWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// iterate over horizontal pixels
for (int l = 0; l < factor; l++)
{
// write RGB triple to outfile itterate the same pixel by factor times
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
// skip over padding, if any
fseek(inptr, padding, SEEK_CUR);
// add new padding
for (int m = 0; m < padding_New; m++)
{
fputc(0x00, outptr);
}
// seek back to the beginning of row in input file, but not after iteration of printing
if (k + 1 < factor )
{
fseek(inptr, -(bi.biWidth * sizeof(RGBTRIPLE)), SEEK_CUR);
}
}
}
// close infile
fclose(inptr);
// close outfile
fclose(outptr);
// success
return 0;
}
```
| 0debug
|
Select only the most recent line of a table based on a field : <p>Given the following table:</p>
<pre><code>Column1 Column2 Column3
Name1 "2016-05-11" Value1
Name2 "2016-05-11" Value2
Name2 "2015-05-17" Value3
Name3 "2014-07-31" Value4
Name4 "2011-07-31" Value5
Name4 "2013-07-31" Value6
Name4 "2016-09-31" Value7
</code></pre>
<p>How do I select only the most recent value from Column2 for each Column1 value.
So the query result would be this:</p>
<pre><code>Column1 Column2 Column3
Name1 "2016-05-11" Value1
Name2 "2016-05-11" Value2
Name3 "2014-07-31" Value4
Name4 "2016-09-31" Value7
</code></pre>
| 0debug
|
How we can sort numbers lexicographically without converting them to strings in C language? : <p>I have tried to sort the numbers using dictionary sort with converting them to strings.But I don't know how to sort numbers using dictionary sort without converting them to strings</p>
| 0debug
|
static int vmdaudio_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type;
unsigned char *output_samples = (unsigned char *)data;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*data_size = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
if (block_type == BLOCK_TYPE_AUDIO) {
*data_size = vmdaudio_loadsound(s, output_samples, buf, 0, buf_size);
} else if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags = AV_RB32(buf);
int silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
if(*data_size < (s->block_align*silent_chunks + buf_size) * 2)
return -1;
*data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);
} else if (block_type == BLOCK_TYPE_SILENCE) {
*data_size = vmdaudio_loadsound(s, output_samples, buf, 1, 0);
}
return avpkt->size;
}
| 1threat
|
static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
int stride, int width, int height,
int delta, const uint8_t *ctable,
uint8_t *refdata)
{
int i, j;
int code;
int filled = 0;
int orig_height;
for(i = 0; i < height; i++)
memcpy(refdata + (i * width), dst + (i * stride), width);
orig_height = height;
height--;
dst = dst + height * stride;
while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {
code = bytestream2_get_byte(&qctx->buffer);
if(delta) {
while((code & 0xF0) == 0xF0) {
if(delta == 1) {
int me_idx;
int me_w, me_h, me_x, me_y;
uint8_t *me_plane;
int corr, val;
me_idx = code & 0xF;
me_w = qpeg_table_w[me_idx];
me_h = qpeg_table_h[me_idx];
corr = bytestream2_get_byte(&qctx->buffer);
val = corr >> 4;
if(val > 7)
val -= 16;
me_x = val;
val = corr & 0xF;
if(val > 7)
val -= 16;
me_y = val;
if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
(height - me_y - me_h < 0) || (height - me_y > orig_height) ||
(filled + me_w > width) || (height - me_h < 0))
av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n",
me_x, me_y, me_w, me_h, filled, height);
else {
me_plane = refdata + (filled + me_x) + (height - me_y) * width;
for(j = 0; j < me_h; j++) {
for(i = 0; i < me_w; i++)
dst[filled + i - (j * stride)] = me_plane[i - (j * width)];
}
}
}
code = bytestream2_get_byte(&qctx->buffer);
}
}
if(code == 0xE0)
break;
if(code > 0xE0) {
int p;
code &= 0x1F;
p = bytestream2_get_byte(&qctx->buffer);
for(i = 0; i <= code; i++) {
dst[filled++] = p;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0xC0) {
code &= 0x1F;
for(i = 0; i <= code; i++) {
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0x80) {
int skip;
code &= 0x3F;
if(!code)
skip = bytestream2_get_byte(&qctx->buffer) + 64;
else if(code == 1)
skip = bytestream2_get_byte(&qctx->buffer) + 320;
else
skip = code;
filled += skip;
while( filled >= width) {
filled -= width;
dst -= stride;
height--;
if(height < 0)
break;
}
} else {
if(code) {
dst[filled++] = ctable[code & 0x7F];
}
else
filled++;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
}
}
}
}
| 1threat
|
Stop people getting my ip from my domain name.? : <p>1st of all YES my domain name is pointed at my ip no hate.
The reason that is because i have a minecraft server + teamspeak server + Webserver.</p>
<p>NOW, i released a minecraft server 2 days ago, on the 1st day i got taken down from DDOS Attacks, Due to people pulling my ip from the Domain name AKA Host to IP.
Is there anyone to create a fake ip that people get from host to ip.
Ask Lets say my ip is: 1.2.3.4
and my domain name is: blabla.com
and people do the host to ip it will show the wrong ip such as: 2.4.6.8.
Is that possible?</p>
| 0debug
|
int qemu_devtree_nop_node(void *fdt, const char *node_path)
{
int offset;
offset = fdt_path_offset(fdt, node_path);
if (offset < 0)
return offset;
return fdt_nop_node(fdt, offset);
}
| 1threat
|
Build project with Microsoft.Build API : <p>I'm trying to build a project using the classes in Microsoft.Build.</p>
<p>The code is:</p>
<pre><code>var project = new ProjectInstance(CS_PROJ_FILE);
project.Build();
</code></pre>
<p>However it's throwing the following exception:</p>
<pre class="lang-none prettyprint-override"><code>Microsoft.Build.Shared.InternalErrorException occurred
HResult=0x80131500
Message=MSB0001: Internal MSBuild Error: Type information for Microsoft.Build.Utilities.ToolLocationHelper was present in the whitelist cache as Microsoft.Build.Utilities.ToolLocationHelper, Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a but the type could not be loaded. unexpectedly null
Source=Microsoft.Build
</code></pre>
<p>I've tried adding the following to the packages (both in a net452 and a net7 project):</p>
<ul>
<li>id="Microsoft.Build" version="15.1.1012"</li>
<li>id="Microsoft.Build.Framework" version="15.1.1012"</li>
<li>id="Microsoft.Build.Runtime" version="15.1.1012"</li>
<li>id="Microsoft.Build.Tasks.Core" version="15.1.1012"</li>
<li>id="Microsoft.Build.Utilities.Core" version="15.1.1012"</li>
</ul>
<p>Still get the same result.</p>
<p>I've also tried using the <code>BuildManager</code> like this:</p>
<pre><code>var buildManager = new BuildManager();
buildManager.Build(new BuildParameters(),
new BuildRequestData(new ProjectInstance(CS_PROJ_FILE),
new[] {"Build"}));
</code></pre>
| 0debug
|
static int decode_block_refinement(MJpegDecodeContext *s, DCTELEM *block, uint8_t *last_nnz,
int ac_index, int16_t *quant_matrix,
int ss, int se, int Al, int *EOBRUN)
{
int code, i=ss, j, sign, val, run;
int last = FFMIN(se, *last_nnz);
OPEN_READER(re, &s->gb);
if(*EOBRUN)
(*EOBRUN)--;
else {
for(;;i++) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
code -= 16;
if(code & 0xF) {
run = ((unsigned) code) >> 4;
UPDATE_CACHE(re, &s->gb);
val = SHOW_UBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
ZERO_RUN;
j = s->scantable.permutated[i];
val--;
block[j] = ((quant_matrix[j]^val)-val) << Al;
if(i == se) {
if(i > *last_nnz)
*last_nnz = i;
CLOSE_READER(re, &s->gb)
return 0;
}
}else{
run = ((unsigned) code) >> 4;
if(run == 0xF){
ZERO_RUN;
}else{
val = run;
run = (1 << run);
if(val) {
UPDATE_CACHE(re, &s->gb);
run += SHOW_UBITS(re, &s->gb, val);
LAST_SKIP_BITS(re, &s->gb, val);
}
*EOBRUN = run - 1;
break;
}
}
}
if(i > *last_nnz)
*last_nnz = i;
}
for(;i<=last;i++) {
j = s->scantable.permutated[i];
if(block[j])
REFINE_BIT(j)
}
CLOSE_READER(re, &s->gb);
return 0;
}
| 1threat
|
static void jump_to_IPL_code(uint64_t address)
{
write_subsystem_identification();
ResetInfo *current = 0;
save = *current;
current->ipl_addr = (uint32_t) (uint64_t) &jump_to_IPL_2;
current->ipl_continue = address & 0x7fffffff;
debug_print_int("set IPL addr to", current->ipl_continue);
sclp_print("\n");
asm volatile("lghi 1,1\n\t"
"diag 1,1,0x308\n\t"
: : : "1", "memory");
virtio_panic("\n! IPL returns !\n");
}
| 1threat
|
how to use and what is the use lambda expression in java8? : can anyone tell the use of lambda expression in java8?..
I have tried this below program and could not get the meaning of the program..
public static void main(String[] args) {
state s=new state();
MathOperation addition=( a, b) -> a+b;
System.out.println(s.operate(10.1,5.2,addition));
}
interface MathOperation{
double operation(double a, double b);
}
private static double operate(double a,double b,MathOperation mo){
return mo.operation(a, b);
}
| 0debug
|
Dev c++ code not compiling in viusual c++(codeblocks vs Visual Studio)(Begineer) : For some odd reason file declaration works diferently in Visual Studio the it does in code blocks.
The following code runs perfectly fine in code:blocks but won't compile in Visual,and i don't have a clue why so.Couldn't figure out
int n;
FILE * pFile;
pFile = fopen ("date.in","r");
fscanf(pFile,"%d",&n);
printf("%d", n);
return 0;
using cstdio and stdfax respectivly
| 0debug
|
Cross-Origin Request Blocked when loading local file : <p>I am currently developing a website and have trouble showing my font-icons in firefox. every browser except for firefox can load and show my font-icons, but on firefox I get the following error:</p>
<p><code>Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/Users/Me/Desktop/website/resources/dist/css/fonts/themify.ttf. (Reason: CORS request not http).</code></p>
<p>the path of the file is correct, as the browser lets me download the file when I enter the above listed URL. Anybody knows why I get this error?</p>
| 0debug
|
C# Count Threading Not Working : <p>Good afternoon everybody.
I am new to Parallel.ForEach and even newer to threading and I wanted to ask your opinion on what is wrong with this code.</p>
<pre><code> using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace MultiThreading_Example
{
class theMeter {
int count1 = 0;
public void CounterMeter()
{
while (this.count1 < 10000)
{
this.count1++;
Console.WriteLine(this.count1);
}
}
}
class Program
{
static void Main(string[] args)
{
theMeter met = new theMeter();
ThreadStart countForMe = new ThreadStart(met.CounterMeter);
for (int i = 0; i < 1000; i++)
{
Thread t1 = new Thread(countForMe);
t1.Start();
t1.Join();
t1.Abort();
}
Console.ReadLine();
}
}
}
</code></pre>
<p>Any idea what is wrong with this? I mean, I have tried doing it without t1.Join() and also have tried doing it on one thread. All are at the same speed. How can I get he program to process faster?</p>
<p>Thanks in advance!</p>
| 0debug
|
React Native and WMS : <p>I am developing a mobile application in React Native requiring the use of Web Map Services. I have not found any library or framework that allows use WMS and react native at same time. In React (Web) I found <a href="https://github.com/PaulLeCam/react-leaflet" rel="noreferrer">one</a>.
My question is:</p>
<p>Do you know if exists any library or framework that allows me to work with WMS and React Native, or if there is any possibility of integrating a library of React (web) in React native?</p>
<p>Thanks!</p>
| 0debug
|
static uint64_t g364fb_ctrl_read(void *opaque,
target_phys_addr_t addr,
unsigned int size)
{
G364State *s = opaque;
uint32_t val;
if (addr >= REG_CURS_PAT && addr < REG_CURS_PAT + 0x1000) {
int idx = (addr - REG_CURS_PAT) >> 3;
val = s->cursor[idx];
} else if (addr >= REG_CURS_PAL && addr < REG_CURS_PAL + 0x18) {
int idx = (addr - REG_CURS_PAL) >> 3;
val = ((uint32_t)s->cursor_palette[idx][0] << 16);
val |= ((uint32_t)s->cursor_palette[idx][1] << 8);
val |= ((uint32_t)s->cursor_palette[idx][2] << 0);
} else {
switch (addr) {
case REG_DISPLAY:
val = s->width / 4;
break;
case REG_VDISPLAY:
val = s->height * 2;
break;
case REG_CTLA:
val = s->ctla;
break;
default:
{
error_report("g364: invalid read at [" TARGET_FMT_plx "]",
addr);
val = 0;
break;
}
}
}
trace_g364fb_read(addr, val);
return val;
}
| 1threat
|
int v9fs_co_symlink(V9fsState *s, V9fsFidState *fidp,
const char *oldpath, const char *newpath, gid_t gid)
{
int err;
FsCred cred;
cred_init(&cred);
cred.fc_uid = fidp->uid;
cred.fc_gid = gid;
cred.fc_mode = 0777;
v9fs_co_run_in_worker(
{
err = s->ops->symlink(&s->ctx, oldpath, newpath, &cred);
if (err < 0) {
err = -errno;
}
});
return err;
}
| 1threat
|
Implement different concretions to an abstract class that implements a generic service : <p>I have a generic interface and one generic class with generic methods to query the database.</p>
<pre><code> public interface IRepositoryBase<Entity> {
IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IncludableQueryable<TEntity, object>> include = null);
}
public class RepositoryBase<TEntity>
: IDisposable, IRepositoryBase<TEntity>
where TEntity : class
{
public IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null)
{
IQueryable<TEntity> query = _context.Set<TEntity>();
if (include != null)
query = include(query);
return query.ToList();
}
}
</code></pre>
<p>I also have several classes that I call "services" that have the business logic and implement another generic interface.</p>
<pre><code> public interface IServiceBase<TEntity>
where TEntity : class
{
IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null);
}
public class ServiceBase<TEntity>
: IDisposable, IServiceBase<TEntity>
where TEntity : class
{
private readonly IRepositoryBase<TEntity>
_repository;
public ServiceBase(
IRepositoryBase<TEntity> repository)
{
_repository = repository;
}
public ServiceBase()
{
}
public IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null)
{
return _repository.GetAll(include);
}
}
public class PizzaService : ServiceBase<Piza>, IPizzaService
{
private readonly IPizzaRepository _pizzaRepository;
public PizzaService (IPizzaRepository pizzaRepository)
: base(pizzaRepository)
{
_pizzaRepository= pizzaRepository;
}
}
</code></pre>
<p>This way each service have their methods acessing their own table plus the methods in the ServiceBase.</p>
<p>There is a scenario where I have 3 concrete services like PizzaService, each one querying its own table, with really similar code, because of the table and the logic similarity.</p>
<p>I want to refactor those concrete services into one, changing only the method param and the repository being acessed, to be in compliance to DRY and ISP.</p>
<p>What I currently have:</p>
<pre><code> public interface IStopRule
{
string DsTerm { get; set; }
bool ShouldDelete { get; set; }
}
public interface IExampleRuleStopWordsBase<TEntity> : IServiceBase<TEntity>
where TEntity : class
{
}
public abstract class ExampleRuleStopWordsBase
: ServiceBase<IStopRule>, IExampleRuleStopWordsBase<IStopRule>
{
private readonly IRepositoryBase<IStopRule> _repo;
public ExampleRuleStopWordsBase(IRepositoryBase<IStopRule> repo)
: base()
{
_repo = repo;
}
public virtual string ApplyRule(string input)
{
var terms = GetAll();
foreach (var item in terms)
{
string regexPattern = @"\b(" + item.DsTerm + @")\b";
if (item.ShouldDelete && Regex.Match(input, regexPattern, RegexOptions.IgnoreCase).Success)
input = input.Replace(item.DsTerm, string.Empty);
}
input = input.Trim();
return input;
}
}
public class PizzaService : ExampleRuleStopWordsBase, IImportRule
{
public PizzaService(IRepositoryBase<IStopRule> repo)
: base(repo)
{
}
public void ApplyRule(Pizza pizza)
{
base.ApplyRule(pizza.Name);
}
}
public class PizzaProducerService : ExampleRuleStopWordsBase, IImportRule
{
public PizzaProducerService(IRepositoryBase<IStopRule> repo)
: base(repo)
{
}
public void ApplyRule(Pizza pizza)
{
base.ApplyRule(pizza.Producer.Name);
}
}
</code></pre>
<p>But I can't figure it out how to pass to the consturctor of ImportRuleStopWordsBase the right entity to make it use the right repository...</p>
<p>Obs: All interfaces and service implementations reside in Domain layers, whereas the implementation of the repository resides in Infrastructure layer.</p>
| 0debug
|
static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)
{
OSStatus status;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
UInt32 propertySize;
int err;
const char *typ = "playback";
AudioValueRange frameRange;
err = pthread_mutex_init(&core->mutex, NULL);
if (err) {
dolog("Could not create mutex\nReason: %s\n", strerror (err));
return -1;
}
audio_pcm_init_info (&hw->info, as);
propertySize = sizeof(core->outputDeviceID);
status = AudioHardwareGetProperty(
kAudioHardwarePropertyDefaultOutputDevice,
&propertySize,
&core->outputDeviceID);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ,
"Could not get default output Device\n");
return -1;
}
if (core->outputDeviceID == kAudioDeviceUnknown) {
dolog ("Could not initialize %s - Unknown Audiodevice\n", typ);
return -1;
}
propertySize = sizeof(frameRange);
status = AudioDeviceGetProperty(
core->outputDeviceID,
0,
0,
kAudioDevicePropertyBufferFrameSizeRange,
&propertySize,
&frameRange);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ,
"Could not get device buffer frame range\n");
return -1;
}
if (frameRange.mMinimum > conf.buffer_frames) {
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMinimum);
}
else if (frameRange.mMaximum < conf.buffer_frames) {
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMaximum);
}
else {
core->audioDevicePropertyBufferFrameSize = conf.buffer_frames;
}
propertySize = sizeof(core->audioDevicePropertyBufferFrameSize);
status = AudioDeviceSetProperty(
core->outputDeviceID,
NULL,
0,
false,
kAudioDevicePropertyBufferFrameSize,
propertySize,
&core->audioDevicePropertyBufferFrameSize);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ,
"Could not set device buffer frame size %" PRIu32 "\n",
(uint32_t)core->audioDevicePropertyBufferFrameSize);
return -1;
}
propertySize = sizeof(core->audioDevicePropertyBufferFrameSize);
status = AudioDeviceGetProperty(
core->outputDeviceID,
0,
false,
kAudioDevicePropertyBufferFrameSize,
&propertySize,
&core->audioDevicePropertyBufferFrameSize);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ,
"Could not get device buffer frame size\n");
return -1;
}
hw->samples = conf.nbuffers * core->audioDevicePropertyBufferFrameSize;
propertySize = sizeof(core->outputStreamBasicDescription);
status = AudioDeviceGetProperty(
core->outputDeviceID,
0,
false,
kAudioDevicePropertyStreamFormat,
&propertySize,
&core->outputStreamBasicDescription);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ,
"Could not get Device Stream properties\n");
core->outputDeviceID = kAudioDeviceUnknown;
return -1;
}
core->outputStreamBasicDescription.mSampleRate = (Float64) as->freq;
propertySize = sizeof(core->outputStreamBasicDescription);
status = AudioDeviceSetProperty(
core->outputDeviceID,
0,
0,
0,
kAudioDevicePropertyStreamFormat,
propertySize,
&core->outputStreamBasicDescription);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ, "Could not set samplerate %d\n",
as->freq);
core->outputDeviceID = kAudioDeviceUnknown;
return -1;
}
status = AudioDeviceAddIOProc(core->outputDeviceID, audioDeviceIOProc, hw);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ, "Could not set IOProc\n");
core->outputDeviceID = kAudioDeviceUnknown;
return -1;
}
if (!isPlaying(core->outputDeviceID)) {
status = AudioDeviceStart(core->outputDeviceID, audioDeviceIOProc);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ, "Could not start playback\n");
AudioDeviceRemoveIOProc(core->outputDeviceID, audioDeviceIOProc);
core->outputDeviceID = kAudioDeviceUnknown;
return -1;
}
}
return 0;
}
| 1threat
|
static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
int ret;
BDRVQcow2State *s = bs->opaque;
uint32_t head = offset % s->cluster_size;
uint32_t tail = (offset + count) % s->cluster_size;
trace_qcow2_pwrite_zeroes_start_req(qemu_coroutine_self(), offset, count);
if (head || tail) {
int64_t cl_start = (offset - head) >> BDRV_SECTOR_BITS;
uint64_t off;
unsigned int nr;
assert(head + count <= s->cluster_size);
if (!(is_zero_sectors(bs, cl_start,
DIV_ROUND_UP(head, BDRV_SECTOR_SIZE)) &&
is_zero_sectors(bs, (offset + count) >> BDRV_SECTOR_BITS,
DIV_ROUND_UP(-tail & (s->cluster_size - 1),
BDRV_SECTOR_SIZE)))) {
return -ENOTSUP;
qemu_co_mutex_lock(&s->lock);
offset = cl_start << BDRV_SECTOR_BITS;
count = s->cluster_size;
nr = s->cluster_size;
ret = qcow2_get_cluster_offset(bs, offset, &nr, &off);
if (ret != QCOW2_CLUSTER_UNALLOCATED &&
ret != QCOW2_CLUSTER_ZERO_PLAIN &&
ret != QCOW2_CLUSTER_ZERO_ALLOC) {
qemu_co_mutex_unlock(&s->lock);
return -ENOTSUP;
} else {
qemu_co_mutex_lock(&s->lock);
trace_qcow2_pwrite_zeroes(qemu_coroutine_self(), offset, count);
ret = qcow2_zero_clusters(bs, offset, count >> BDRV_SECTOR_BITS, flags);
qemu_co_mutex_unlock(&s->lock);
return ret;
| 1threat
|
static int parse_drive(DeviceState *dev, Property *prop, const char *str)
{
DriveInfo **ptr = qdev_get_prop_ptr(dev, prop);
*ptr = drive_get_by_id(str);
if (*ptr == NULL)
return -ENOENT;
return 0;
}
| 1threat
|
Why not send data with AJAX-script? : Tell me please, there is a form for sending data to the database. Without a script it works fine, but nothing happens with the script. In the console — Form Data has all the data, and the 200th code arrives, but is not added to the database.
PHP:
<?php
$data = $_POST;
if ( isset($data['add']) )
{ $posts = R::dispense('posts');
$posts->head = $data['head'];
$posts->desc = $data['desc'];
R::store($posts);
?>
HTML:
<form method="POST" id="FormID">
<input type="text" name="head" required />
<input type="text" name="head" required />
<button type="submit" name="add">Добавить</button>
JS:
<script>
$("#FormID").submit(function(e) {
var form = $(this);
var url = form.attr('action');
e.preventDefault();
$.ajax({
type: "POST",
url: url,
data: $("#FormID").serialize(),
success: function(data) {
c = "hello";
$('#FormStatus').text(c);
}
});});
</script>
| 0debug
|
div.my-class vs. .my-class any benefits? : <p>If I am to only use this class on a div. Is there any benefit to using the first over the second?</p>
<pre><code>div.my-class
.my-class
</code></pre>
| 0debug
|
PHP: Transforming Array Orientation : In PHP - Any Help for me in transforming array
it's actually a query result from mysql DB
> **Existing:**
> (
> [ITEM] => Array
> (
> [0] => PRODUCT A
> [1] => PRODUCT B
> [2] => PRODUCT C
>
> )
>
> [REFERENCE] => Array
> (
> [0] => 107AW3
> [1] => 204RS67O
> [2] => 25GTR56
>
> )
>
> **Wanted:**
> (
> [0] => Array
> (
> [ITEM] => Product A
> [REFERENCE] => 107AW3
> )
>
> [1] => Array
> (
> [ITEM] => Product B
> [REFERENCE] => 204RS67O
> )
>
> [2] => Array
> (
> [ITEM] => Product C
> [REFERENCE] => 25GTR56
> )
What can I do to transform the array into the wanted one?
a glance of info, it is actually a query from MySQL:
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$item_array[] = $row["item"];
$reference_array[] = $row["reference"];
}
}
table_content = array( 'ITEM'=>$item_array,
'REFERENCE'=>$reference_array);
echo '<pre>'; print_r($table_content); echo '</pre>';
| 0debug
|
def long_words(n, str):
word_len = []
txt = str.split(" ")
for x in txt:
if len(x) > n:
word_len.append(x)
return word_len
| 0debug
|
Class template argument deduction and default template parameters : <p>The following stripped down code doesn't work with the latest clang++5 but is accepted by g++7:</p>
<pre><code>template<typename Wrapped, typename U>
struct wrapper;
template<typename Wrapped, typename U=int>
struct wrapper
{
wrapper() = default;
// Automatic deduction guide
constexpr explicit wrapper(Wrapped) noexcept {}
};
int main()
{
struct {} dummy;
constexpr auto wrapped = wrapper(dummy);
}
</code></pre>
<p>It fails with the following error messages:</p>
<pre><code><source>:18:30: error: no viable constructor or deduction guide for deduction of template arguments of 'wrapper'
constexpr auto wrapped = wrapper(dummy);
^
<source>:12:24: note: candidate template ignored: couldn't infer template argument 'U'
constexpr explicit wrapper(Wrapped) noexcept {}
^
<source>:4:8: note: candidate template ignored: could not match 'wrapper<Wrapped, U>' against '(anonymous struct at <source>:17:5)'
struct wrapper;
^
<source>:9:5: note: candidate function template not viable: requires 0 arguments, but 1 was provided
wrapper() = default;
^
</code></pre>
<p>However if I move the default template parameter <code>=int</code> from the class template definition to the forward declaration, everything works perfectly (<code>U</code> being deduced to <code>int</code> as expected), as if only the default template parameter in the forward declaration was taken into account when create the set of fictional function templates used by deduction guides.</p>
<p>I tried to read the standard wording but couldn't get much out of it for this specific case. Is only taking the default template parameter in the forward declaration the intended behaviour when generating the fictional function templates, or is this a compiler bug?</p>
| 0debug
|
splitting a full url into parts : <p>I'm trying to split a url into parts so that I can work with these separately. </p>
<p>For e.g. the url:</p>
<p><code>'https://api.somedomain.co.uk/api/addresses?postcode=XXSDF&houseNo=34'</code></p>
<p>How can I split this into:
1) the source/origin (i.e. protocol + subdomain + domain)
2) path '/api/addresses'
3) Query: '?postcode=XXSDF&houseNo=34'</p>
| 0debug
|
int ff_mjpeg_decode_sos(MJpegDecodeContext *s)
{
int len, nb_components, i, h, v, predictor, point_transform;
int index, id;
const int block_size= s->lossless ? 1 : 8;
int ilv, prev_shift;
len = get_bits(&s->gb, 16);
nb_components = get_bits(&s->gb, 8);
if (len != 6+2*nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
for(i=0;i<nb_components;i++) {
id = get_bits(&s->gb, 8) - 1;
av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
for(index=0;index<s->nb_components;index++)
if (id == s->component_id[index])
break;
if (index == s->nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
s->comp_index[i] = index;
s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
s->h_scount[i] = s->h_count[index];
s->v_scount[i] = s->v_count[index];
s->dc_index[i] = get_bits(&s->gb, 4);
s->ac_index[i] = get_bits(&s->gb, 4);
if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
goto out_of_range;
if (!s->vlcs[0][s->dc_index[i]].table || !s->vlcs[1][s->ac_index[i]].table)
goto out_of_range;
predictor= get_bits(&s->gb, 8);
ilv= get_bits(&s->gb, 8);
prev_shift = get_bits(&s->gb, 4);
point_transform= get_bits(&s->gb, 4);
for(i=0;i<nb_components;i++)
s->last_dc[i] = 1024;
if (nb_components > 1) {
s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
} else if(!s->ls) {
h = s->h_max / s->h_scount[0];
v = s->v_max / s->v_scount[0];
s->mb_width = (s->width + h * block_size - 1) / (h * block_size);
s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
s->nb_blocks[0] = 1;
s->h_scount[0] = 1;
s->v_scount[0] = 1;
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d %s\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "",
predictor, point_transform, ilv, s->bits,
s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""));
for (i = s->mjpb_skiptosod; i > 0; i--)
skip_bits(&s->gb, 8);
if(s->lossless){
if(CONFIG_JPEGLS_DECODER && s->ls){
if(ff_jpegls_decode_picture(s, predictor, point_transform, ilv) < 0)
}else{
if(s->rgb){
if(ljpeg_decode_rgb_scan(s, predictor, point_transform) < 0)
}else{
if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)
}else{
if(s->progressive && predictor) {
if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0)
} else {
if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform) < 0)
emms_c();
return 0;
out_of_range:
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n");
| 1threat
|
static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp)
{
int ret = 0;
int64_t total_size = 0;
NFSClient *client = g_new0(NFSClient, 1);
QDict *options = NULL;
client->aio_context = qemu_get_aio_context();
total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
options = qdict_new();
ret = nfs_parse_uri(url, options, errp);
if (ret < 0) {
goto out;
}
ret = nfs_client_open(client, options, O_CREAT, errp, 0);
if (ret < 0) {
goto out;
}
ret = nfs_ftruncate(client->context, client->fh, total_size);
nfs_client_close(client);
out:
g_free(client);
return ret;
}
| 1threat
|
static void omap_screen_dump(void *opaque, const char *filename, bool cswitch,
Error **errp)
{
struct omap_lcd_panel_s *omap_lcd = opaque;
DisplaySurface *surface = qemu_console_surface(omap_lcd->con);
omap_update_display(opaque);
if (omap_lcd && surface_data(surface))
omap_ppm_save(filename, surface_data(surface),
omap_lcd->width, omap_lcd->height,
surface_stride(surface), errp);
}
| 1threat
|
Solving linter error no-undef for document : <p>I am using <code>airbnb</code> extension for linting my React Project. Now, in my <code>index.js</code> I have:</p>
<pre><code>import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('root'),
);
</code></pre>
<p>linter says:</p>
<pre><code>no-undef 'document' is not defined.at line 8 col 3
</code></pre>
<p>How can I solve this problem?</p>
| 0debug
|
static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
TCPCharDriver *s = chr->opaque;
uint8_t buf[READ_BUF_LEN];
int len, size;
if (!s->connected || s->max_size <= 0) {
return TRUE;
}
len = sizeof(buf);
if (len > s->max_size)
len = s->max_size;
size = tcp_chr_recv(chr, (void *)buf, len);
if (size == 0) {
s->connected = 0;
if (s->listen_chan) {
s->listen_tag = g_io_add_watch(s->listen_chan, G_IO_IN, tcp_chr_accept, chr);
}
if (s->tag) {
g_source_remove(s->tag);
s->tag = 0;
}
g_io_channel_unref(s->chan);
s->chan = NULL;
closesocket(s->fd);
s->fd = -1;
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
} else if (size > 0) {
if (s->do_telnetopt)
tcp_chr_process_IAC_bytes(chr, s, buf, &size);
if (size > 0)
qemu_chr_be_write(chr, buf, size);
}
return TRUE;
}
| 1threat
|
SSRS Lookup Based on Multiple Conditions : <p>I have a dataset (Volume) looks like this:</p>
<p><a href="https://i.stack.imgur.com/HhzIc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HhzIc.png" alt="enter image description here"></a></p>
<p>In my report, what I want to get is this: </p>
<p><a href="https://i.stack.imgur.com/nd6HP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nd6HP.png" alt="enter image description here"></a> </p>
<p>The Lookup expression: =Lookup (Fields!Id.Value, Fields!Id.Value, Fields!Volume.Value,"Volume") can only lookup on ID. Is there any way I can do lookup on ID first, and then lookup on Sub_Group to get the correct Volume? Thank you.</p>
| 0debug
|
uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
{
int r = sclp_service_call(env, r1, r2);
if (r < 0) {
program_interrupt(env, -r, 4);
return 0;
}
return r;
}
| 1threat
|
php move_uploaded_files and copy not working : both the functions work for file whose size is less than 10MB. It does not copy when the file size is more than 10MB.
php.ini files have following
post_max_size = 300M
upload_max_filesize = 300M
memory_limit = 128M
Destination directory has required permissions as it is working for smaller files.
| 0debug
|
static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
struct msghdr *msgh)
{
struct cmsghdr *cmsg = CMSG_FIRSTHDR(msgh);
abi_long msg_controllen;
abi_ulong target_cmsg_addr;
struct target_cmsghdr *target_cmsg, *target_cmsg_start;
socklen_t space = 0;
msg_controllen = tswapal(target_msgh->msg_controllen);
if (msg_controllen < sizeof (struct target_cmsghdr))
goto the_end;
target_cmsg_addr = tswapal(target_msgh->msg_control);
target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);
target_cmsg_start = target_cmsg;
if (!target_cmsg)
return -TARGET_EFAULT;
while (cmsg && target_cmsg) {
void *data = CMSG_DATA(cmsg);
void *target_data = TARGET_CMSG_DATA(target_cmsg);
int len = cmsg->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr));
int tgt_len, tgt_space;
if (msg_controllen < sizeof(struct cmsghdr)) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
break;
}
if (cmsg->cmsg_level == SOL_SOCKET) {
target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET);
} else {
target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level);
}
target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type);
tgt_len = TARGET_CMSG_LEN(len);
switch (cmsg->cmsg_level) {
case SOL_SOCKET:
switch (cmsg->cmsg_type) {
case SO_TIMESTAMP:
tgt_len = sizeof(struct target_timeval);
break;
default:
break;
}
default:
break;
}
if (msg_controllen < tgt_len) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
tgt_len = msg_controllen;
}
switch (cmsg->cmsg_level) {
case SOL_SOCKET:
switch (cmsg->cmsg_type) {
case SCM_RIGHTS:
{
int *fd = (int *)data;
int *target_fd = (int *)target_data;
int i, numfds = tgt_len / sizeof(int);
for (i = 0; i < numfds; i++) {
__put_user(fd[i], target_fd + i);
}
break;
}
case SO_TIMESTAMP:
{
struct timeval *tv = (struct timeval *)data;
struct target_timeval *target_tv =
(struct target_timeval *)target_data;
if (len != sizeof(struct timeval) ||
tgt_len != sizeof(struct target_timeval)) {
goto unimplemented;
}
__put_user(tv->tv_sec, &target_tv->tv_sec);
__put_user(tv->tv_usec, &target_tv->tv_usec);
break;
}
case SCM_CREDENTIALS:
{
struct ucred *cred = (struct ucred *)data;
struct target_ucred *target_cred =
(struct target_ucred *)target_data;
__put_user(cred->pid, &target_cred->pid);
__put_user(cred->uid, &target_cred->uid);
__put_user(cred->gid, &target_cred->gid);
break;
}
default:
goto unimplemented;
}
break;
case SOL_IP:
switch (cmsg->cmsg_type) {
case IP_TTL:
{
uint32_t *v = (uint32_t *)data;
uint32_t *t_int = (uint32_t *)target_data;
__put_user(*v, t_int);
break;
}
case IP_RECVERR:
{
struct errhdr_t {
struct sock_extended_err ee;
struct sockaddr_in offender;
};
struct errhdr_t *errh = (struct errhdr_t *)data;
struct errhdr_t *target_errh =
(struct errhdr_t *)target_data;
__put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
__put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad);
__put_user(errh->ee.ee_info, &target_errh->ee.ee_info);
__put_user(errh->ee.ee_data, &target_errh->ee.ee_data);
host_to_target_sockaddr((unsigned long) &target_errh->offender,
(void *) &errh->offender, sizeof(errh->offender));
break;
}
default:
goto unimplemented;
}
break;
case SOL_IPV6:
switch (cmsg->cmsg_type) {
case IPV6_HOPLIMIT:
{
uint32_t *v = (uint32_t *)data;
uint32_t *t_int = (uint32_t *)target_data;
__put_user(*v, t_int);
break;
}
case IPV6_RECVERR:
{
struct errhdr6_t {
struct sock_extended_err ee;
struct sockaddr_in6 offender;
};
struct errhdr6_t *errh = (struct errhdr6_t *)data;
struct errhdr6_t *target_errh =
(struct errhdr6_t *)target_data;
__put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
__put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad);
__put_user(errh->ee.ee_info, &target_errh->ee.ee_info);
__put_user(errh->ee.ee_data, &target_errh->ee.ee_data);
host_to_target_sockaddr((unsigned long) &target_errh->offender,
(void *) &errh->offender, sizeof(errh->offender));
break;
}
default:
goto unimplemented;
}
break;
default:
unimplemented:
gemu_log("Unsupported ancillary data: %d/%d\n",
cmsg->cmsg_level, cmsg->cmsg_type);
memcpy(target_data, data, MIN(len, tgt_len));
if (tgt_len > len) {
memset(target_data + len, 0, tgt_len - len);
}
}
target_cmsg->cmsg_len = tswapal(tgt_len);
tgt_space = TARGET_CMSG_SPACE(len);
if (msg_controllen < tgt_space) {
tgt_space = msg_controllen;
}
msg_controllen -= tgt_space;
space += tgt_space;
cmsg = CMSG_NXTHDR(msgh, cmsg);
target_cmsg = TARGET_CMSG_NXTHDR(target_msgh, target_cmsg,
target_cmsg_start);
}
unlock_user(target_cmsg, target_cmsg_addr, space);
the_end:
target_msgh->msg_controllen = tswapal(space);
return 0;
}
| 1threat
|
static void hpet_timer(void *opaque)
{
HPETTimer *t = (HPETTimer*)opaque;
uint64_t diff;
uint64_t period = t->period;
uint64_t cur_tick = hpet_get_ticks();
if (timer_is_periodic(t) && period != 0) {
if (t->config & HPET_TN_32BIT) {
while (hpet_time_after(cur_tick, t->cmp))
t->cmp = (uint32_t)(t->cmp + t->period);
} else
while (hpet_time_after64(cur_tick, t->cmp))
t->cmp += period;
diff = hpet_calculate_diff(t, cur_tick);
qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)
+ (int64_t)ticks_to_ns(diff));
} else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
if (t->wrap_flag) {
diff = hpet_calculate_diff(t, cur_tick);
qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)
+ (int64_t)ticks_to_ns(diff));
t->wrap_flag = 0;
}
}
update_irq(t);
}
| 1threat
|
Having trouble looping through an array in c++ : <p>I seem to be looping through my array wrong, I've got it set up to prompt the user for a list of numbers and I am supposed to be comparing it to another number that the user sets. </p>
<pre><code>#include <iostream>
using namespace std;
bool chk = true;
int main() {
/*
Write a program that asks the user to type 10 integers of an array and an integer s.
Then search the value s from the array and display the value of s if it is found in
the array otherwise print sorry not found..
*/
int userArray[10], i, greater = 0;
int s;
cout << "Enter a check number: \n";
cin >> s;
if (chk = true) {
//prompt for array list
for (i = 0; i < 9; i++) {
if (i == 0) {
cout << "Enter ten numbers: " << "\n";
cin >> userArray[i];
}
else {
cin >> userArray[i];
}
chk = false;
}
//loop through the array
for (int i = 0; i <= 10; i++) {
if (s = userArray[i]) {
//for testing
cout << userArray[i];
//cout << s;
}
else {
cout << "No match found!";
}
//I was just using this to pause the console and let me inspect result
cin >> greater;
return 0;
}
}
}
</code></pre>
<p>I assume the following code is where the problem lies. The idea is i set s = 2 enter in a list of numbers and then compare to s and print s if there is a match if not I print No match found. When I enter in a number that i know matches s it seems to print the first number in the array, but i thought since I loop through the numbers one by one in the for loop that it should display when it reaches the right number not when it stops. Thanks in advance</p>
<pre><code> //loop through the array
for (int i = 0; i <= 10; i++) {
if (s = userArray[i]) {
//for testing
cout << userArray[i];
//cout << s;
}
else {
cout << "No match found!";
}
</code></pre>
| 0debug
|
static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, int line_size)
{
int i;
vector unsigned char perm = vec_lvsl(0, pixels);
vector unsigned char bytes;
const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
vector signed short shorts;
for (i = 0; i < 8; i++) {
vector unsigned char pixl = vec_ld( 0, pixels);
vector unsigned char pixr = vec_ld(15, pixels);
bytes = vec_perm(pixl, pixr, perm);
shorts = (vector signed short)vec_mergeh(zero, bytes);
vec_st(shorts, i*16, (vector signed short*)block);
pixels += line_size;
}
}
| 1threat
|
How to pass each id from JSP to javascript? : In our JSP application, we are creating a html buttons in for loop. Say, for example,
<%for(int i=0;i<5;i++){%>
<input type="button" class="btn-success btn-rounded" id ="?????" value="abcd" onclick="changeButton()">
Now i want pass each button's id to javascript method , but it doesnt works.
Currently, the first button's id is passed.How to pass each button's id to javascript ?
| 0debug
|
Java - Calling the constructor of a superclass fails : <p>Here is a basic class I have set up to calculate earnings with stocks.
Focus on the "Stock" constructor here: </p>
<pre><code>public class Stock{
private String symbol;
private int totalShares;
private double totalCost;
public void Stock(String symbol){
this.symbol = symbol;
totalShares = 0;
totalCost = 0.0;
}
public double getProfit(double currentPrice){
double marketValue = totalShares * currentPrice;
return marketValue - totalCost;
}
public void purchase(int shares, double pricePerShare){
totalShares += shares;
totalCost += shares*pricePerShare;
}
public int getTotalShares(){
return totalShares;
}
}
</code></pre>
<p>I have created a subclass called DividendStock, which is supposed to calculate dividend earnings.</p>
<pre><code>public class DividendStock extends Stock{
private double dividends;
public DividendStock(String symbol){
super(symbol);
dividends = 0.0;
}
public void payDividend(double amountPerShare){
dividends += amountPerShare*getTotalShares();
}
}
</code></pre>
<p>The constructor of this class doesnt allow me to call the superclass's constuctor: super(symbol);
The error message is as goes: "constructor Stock in class Stock cannot be applied to given types;"</p>
<p>I have searched for a solution, but everything seems to be in place.
Any ideas of why it doesnt allow me to call this constructor? </p>
| 0debug
|
void unregister_savevm(const char *idstr, void *opaque)
{
SaveStateEntry *se, *new_se;
TAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
if (strcmp(se->idstr, idstr) == 0 && se->opaque == opaque) {
TAILQ_REMOVE(&savevm_handlers, se, entry);
qemu_free(se);
}
}
}
| 1threat
|
Javascrip onclick pick random html element and style it : Hello I am need some help with javascript
I am newbie self-taught
How can i code - I have a table and 2 buttons, when i press button I want to pick random table data (from 1 to 9) and change it background color
and when i press second button - change table data from 1 to 9 in order.
// my javascript knowledge is very low but i understand that i need to
give id for my each table data,
a button with onclick="random()",
function random () - but i dont know how to pick random ID i gave for my td
| 0debug
|
How to change display name of an app in react-native : <p>Apple have <a href="https://developer.apple.com/library/prerelease/content/qa/qa1823/_index.html" rel="noreferrer">clear instructions</a> on how to change the display name of an IOS app, but they are not useful for a react-native app because the folder structure is different. How do you change the display name if you have a react-native app?</p>
| 0debug
|
static uint32_t apic_mem_readw(void *opaque, target_phys_addr_t addr)
{
return 0;
}
| 1threat
|
How can it search inside the directory, if the directory is empty? : I just started learning python and found this snippet. It's supposed to count how many times a word appears. I guess, for all of you this will seem very logical, but unfortunately for me, it doesn't make any sense.
str = "house is where you live, you don't leave the house."
`dict = {}`
`list = str.split(" ")`
`for word in list:` # Loop over the list
`if word in dict:` # How can I loop over the dictionary if it's empty?
`dict[word] = dict[word] + 1`
`else:`
`dict[word] = 1`
So, my question here is, how can I loop over the dictionary? Shouldn't the dictionary be empty because I didn't pass anything inside?
Maybe I am not smart enough, but I don't see the logic. Can anybody explain me how does it work?
Many thanks
| 0debug
|
static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
{
ram_addr_t ram_addr;
void *p;
if ((tlb_entry->addr_write & ~TARGET_PAGE_MASK) == io_mem_ram.ram_addr) {
p = (void *)(unsigned long)((tlb_entry->addr_write & TARGET_PAGE_MASK)
+ tlb_entry->addend);
ram_addr = qemu_ram_addr_from_host_nofail(p);
if (!cpu_physical_memory_is_dirty(ram_addr)) {
tlb_entry->addr_write |= TLB_NOTDIRTY;
}
}
}
| 1threat
|
What's the purpose of this lambda? : <p>I see the following lambda in C++ code. What's the purpose of it?</p>
<pre class="lang-cpp prettyprint-override"><code>static const auto faster = [](){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
return nullptr;
}();
</code></pre>
| 0debug
|
pvscsi_update_irq_status(PVSCSIState *s)
{
PCIDevice *d = PCI_DEVICE(s);
bool should_raise = s->reg_interrupt_enabled & s->reg_interrupt_status;
trace_pvscsi_update_irq_level(should_raise, s->reg_interrupt_enabled,
s->reg_interrupt_status);
if (s->msi_used && msi_enabled(d)) {
if (should_raise) {
trace_pvscsi_update_irq_msi();
msi_notify(d, PVSCSI_VECTOR_COMPLETION);
}
return;
}
pci_set_irq(d, !!should_raise);
}
| 1threat
|
static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOSCSI *s = (VirtIOSCSI *)vdev;
VirtIOSCSIReq *req;
while ((req = virtio_scsi_pop_req(s, vq))) {
int type;
if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,
&type, sizeof(type)) < sizeof(type)) {
virtio_scsi_bad_req();
continue;
}
tswap32s(&req->req.tmf->type);
if (req->req.tmf->type == VIRTIO_SCSI_T_TMF) {
if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICtrlTMFReq),
sizeof(VirtIOSCSICtrlTMFResp)) < 0) {
virtio_scsi_bad_req();
} else {
virtio_scsi_do_tmf(s, req);
}
} else if (req->req.tmf->type == VIRTIO_SCSI_T_AN_QUERY ||
req->req.tmf->type == VIRTIO_SCSI_T_AN_SUBSCRIBE) {
if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICtrlANReq),
sizeof(VirtIOSCSICtrlANResp)) < 0) {
virtio_scsi_bad_req();
} else {
req->resp.an->event_actual = 0;
req->resp.an->response = VIRTIO_SCSI_S_OK;
}
}
virtio_scsi_complete_req(req);
}
}
| 1threat
|
Are neural networks capable of estimating human facial attractiveness in 2018? : <p>I'm trying to understand if the project I'm thinking about is feasible or not using Neural Networks. I'm aware of apps like MakeApp and FakeApp which use neural networks to manipulate human faces. </p>
<p>My question is - <strong>Can modern (2018) neural networks be trained to identify aspects of human facial attractiveness and give a percentile score?</strong></p>
<p>For example, given an image, I want to know if the neural network thinks this image is in the top 20% facial attractiveness. If possible, how big of a dataset I need to be able to train such network? Is it tens of thousands of human-scored images? </p>
| 0debug
|
I need to read user input (numberdecimal) and convert that input to double format. My app keep crashing. I am trying to display user input in textView : <p>Trying to read input and then display it in textview and utilize that user input. I am not sure how to read user input and use that input it could be string or number or numberdecimal type.
*</p>
<pre><code><EditView
android:id="@+id/editText1"
android:layout_width="368sp"
android:layout_height="35sp"
android:layout_marginTop="73dp"
android:background="#9E9E9E"
android:hint="Enter Initial Bill Total"
android:gravity="center_vertical|center_horizontal"
android:ems="10"
android:inputType="numberDecimal"
android:textSize="32dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="110dp"
app:layout_constraintTop_toBottomOf="@+id/editText1"
android:layout_marginLeft="163dp"
app:layout_constraintLeft_toLeftOf="parent" />
</code></pre>
<p>*
*</p>
<pre><code>public class MainActivity extends AppCompatActivity {
double d;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void display(int score) {
EditText mEdit = (EditText)findViewById(R.id.editText1);
String value = mEdit.getText().toString();
d = Double.parseDouble(value);
}
private void displaytext(double number) {
TextView quantityTextView = (TextView) findViewById(R.id.textView);
quantityTextView.setText("" + number);
}
}
</code></pre>
<p>*</p>
| 0debug
|
Custom list implementation iterator can't access last element (c++) : <p>I'm implementing a custom list for a personal project & I can't seem to access the last element with an iterator.</p>
<p>It's basically a flat doubly linked list (with next & previous node pointers). </p>
<p><strong>expression.hpp</strong></p>
<pre><code>#ifndef TPP_EXPRESSION_HPP
#define TPP_EXPRESSION_HPP
#include <cstddef>
#include <globals.hpp>
#include "node.hpp"
#include "iterator.hpp"
#include <iostream>
namespace tpp {
namespace expression {
class Expression {
std::size_t _size;
Node* left;
Node* right;
public:
void print() {
Node* node = left;
while (node != nullptr) {
std::cout << node->value << "\t";
node = node->next;
}
}
void append(byte val) {
Node* node = new Node(val);
if (right != nullptr) {
Node* tmp = right;
tmp->next = node;
right = node;
right->prev = tmp;
} else {
left = right = node;
}
_size++;
}
Iterator begin() {
std::cout << "Left: " << left->value << std::endl;
return Iterator(left);
}
const ConstIterator cbegin() const {
return ConstIterator(left);
}
Iterator end() {
std::cout << "Right: " << right->value << std::endl;
return Iterator(right);
}
const ConstIterator cend() const {
return ConstIterator(right);
}
bool is_empty() {
return _size == 0;
}
std::size_t size() {
return _size;
}
Expression() : _size(0), left(nullptr), right(nullptr) {
}
~Expression() {
Node* node = right;
while (node != nullptr) {
Node* old_back = node;
node = node->prev;
delete old_back;
}
left = nullptr;
right = nullptr;
}
};
} // expression
} // tpp
#endif //TPP_EXPRESSION_HPP
</code></pre>
<p><strong>iterator.hpp</strong></p>
<pre><code>#ifndef TPP_EXPRESSION_ITERATOR_HPP
#define TPP_EXPRESSION_ITERATOR_HPP
#include <globals.hpp>
#include "node.hpp"
#include <iostream>
namespace tpp {
namespace expression {
class Iterator {
Node* node;
public:
Iterator(Node* ptr) : node(ptr) {}
Iterator(const Iterator& rhs) : node(rhs.node) {}
Iterator& operator++() { std::cout << "Current: " << node->value << std::endl; node = node->next; std::cout << "Now: " << node->value << std::endl;return *this; }
Iterator& operator--() { node = node->prev; return *this; }
bool operator!=(const Iterator& rhs) { bool stats = node != rhs.node; std::cout << (stats ? "Not equal" : "Equal") << std::endl; return stats; }
bool operator==(const Iterator& rhs) { return node == rhs.node; }
byte& operator*() { std::cout << "Dereferencing " << node->value << std::endl; return node->value; }
};
class ConstIterator {
const Node* node;
public:
ConstIterator(const Node* ptr) : node(ptr) {}
ConstIterator(const ConstIterator& rhs) : node(rhs.node) {}
ConstIterator& operator++() { node = node->next; return *this; }
ConstIterator& operator--() { node = node->prev; return *this; }
bool operator!=(const ConstIterator& rhs) { return node != rhs.node; }
bool operator==(const ConstIterator& rhs) { return node == rhs.node; }
const byte& operator*() const { return node->value; }
};
} // expression
} // tpp
#endif //TPP_EXPRESSION_ITERATOR_HPP
</code></pre>
<p><strong>node.hpp</strong></p>
<pre><code>#ifndef TPP_EXPRESSION_NODE_HPP
#define TPP_EXPRESSION_NODE_HPP
#include <globals.hpp>
namespace tpp {
namespace expression {
struct Node {
Node* prev;
Node* next;
byte value;
Node(byte value) : value(value), prev(nullptr), next(nullptr) {}
Node() : value('\0'), prev(nullptr), next(nullptr) {}
};
}
} // tpp
#endif //TPP_EXPRESSION_NODE_HPP
</code></pre>
<p><strong>main.cpp</strong></p>
<pre><code>#include <iostream>
#include <globals.hpp>
#include <expression/include.hpp>
using namespace std;
int main()
{
tpp::expression::Expression e;
e.append('0');
e.append('1');
e.append('0');
e.append('1');
for (auto elem : e) {
std::cout << elem << std::endl;
}
e.print();
}
</code></pre>
<p><strong>Example output</strong></p>
<pre><code>Left: 0
Right: 1
Not equal
Dereferencing 0
0
Current: 0
Now: 1
Not equal
Dereferencing 1
1
Current: 1
Now: 0
Not equal
Dereferencing 0
0
Current: 0
Now: 1
Equal
0 1 0 1
</code></pre>
<p>Code is a mess, I was more focused on getting it working before I cleaned it up. Any help would be useful, thanks.</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.