problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
i want to show word documents in python program output. : I have a few word files which i want want to present in python output on respective occasions.
These word files also contain multiple images.
So how can i collaborate them in the program to present it.
I tried
>>>from PIL import Image
but that gives image in other software hence not satisfying my demand.
| 0debug
|
def div_list(nums1,nums2):
result = map(lambda x, y: x / y, nums1, nums2)
return list(result)
| 0debug
|
Responsive outline? - Visual composer - #may1reboot : First of all, may the first be with you!
Now for my question. As always I started too late with fixing up my work. I'm trying to create an outline like in the attached image ([![examplepage][1]][1]). So far so good, the outline works and the outline-offset too.
But: in it's current state it is not responsive in any way (because of the way I gave the CSS), my knowledge just isn't on par yet, still learning though!
Is there any way I can set the outline-offset to percentages?
Current solution:
outline: 5px solid #ccc;
outline-offset: -50px;
[1]: https://i.stack.imgur.com/hQUyv.jpg
| 0debug
|
void cpu_check_irqs(CPUSPARCState *env)
{
CPUState *cs;
if (env->pil_in && (env->interrupt_index == 0 ||
(env->interrupt_index & ~15) == TT_EXTINT)) {
unsigned int i;
for (i = 15; i > 0; i--) {
if (env->pil_in & (1 << i)) {
int old_interrupt = env->interrupt_index;
env->interrupt_index = TT_EXTINT | i;
if (old_interrupt != env->interrupt_index) {
cs = CPU(sparc_env_get_cpu(env));
trace_sun4m_cpu_interrupt(i);
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
}
break;
}
}
} else if (!env->pil_in && (env->interrupt_index & ~15) == TT_EXTINT) {
cs = CPU(sparc_env_get_cpu(env));
trace_sun4m_cpu_reset_interrupt(env->interrupt_index & 15);
env->interrupt_index = 0;
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
}
}
| 1threat
|
create class and function in one header file without library : <p>Hello i want to create my own public c++ tool like auto socket connection. but i have two ways and i want to know which way is better.
way 1 :
insert the functions (with source) inside one header file and other people just include the header file and use the functions...
<br><strong>sock.h</strong></p>
<pre><code>#include <iostream>
class sock {
public:
bool create();
bool bind();
bool listen();
}
inline bool sock::create() { ... }
inline bool sock::bind() { ... }
inline bool sock::listen() { ... }
</code></pre>
<p>and second way is create a header file and also create static lib (c++)
<br><strong>sock.h</strong></p>
<pre><code>#include <iostream>
class sock {
public:
bool create();
bool bind();
bool listen();
}
</code></pre>
<p><strong>sock.cpp</strong></p>
<pre><code>#include "sock.h"
bool sock::create() { ... }
bool sock::bind() { ... }
bool sock::listen() { ... }
</code></pre>
<p>which way is better ? ( i choose the first way myself because it's easy for client to just include one header file and use the functions but in second way client must include the header and also include the lib file. is there any problem for first way?</p>
| 0debug
|
static void add_query_tests(QmpSchema *schema)
{
SchemaInfoList *tail;
SchemaInfo *si, *arg_type, *ret_type;
const char *test_name;
for (tail = schema->list; tail; tail = tail->next) {
si = tail->value;
if (si->meta_type != SCHEMA_META_TYPE_COMMAND) {
continue;
}
if (query_is_blacklisted(si->name)) {
continue;
}
arg_type = qmp_schema_lookup(schema, si->u.command.arg_type);
if (object_type_has_mandatory_members(arg_type)) {
continue;
}
ret_type = qmp_schema_lookup(schema, si->u.command.ret_type);
if (ret_type->meta_type == SCHEMA_META_TYPE_OBJECT
&& !ret_type->u.object.members) {
continue;
}
test_name = g_strdup_printf("qmp/%s", si->name);
qtest_add_data_func(test_name, si->name, test_query);
}
}
| 1threat
|
static void cpu_exit_tb_from_sighandler(CPUState *cpu, void *puc)
{
#ifdef __linux__
struct ucontext *uc = puc;
#elif defined(__OpenBSD__)
struct sigcontext *uc = puc;
#endif
#ifdef __linux__
#ifdef __ia64
sigprocmask(SIG_SETMASK, (sigset_t *)&uc->uc_sigmask, NULL);
#else
sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
#endif
#elif defined(__OpenBSD__)
sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL);
#endif
cpu_resume_from_signal(cpu, NULL);
}
| 1threat
|
Change date format taken from an API : <p>So I'm going through an API and receiving dates in the following format:
<code>2017-03-23</code> but I want it to be displayed like this: <code>3/23/2017</code>. What's the best way to go about this?</p>
<p>Thanks!</p>
| 0debug
|
React: Axios Network Error : <p>This is my first time using axios and I have encountered an error. </p>
<pre><code> axios.get(
`http://someurl.com/page1?param1=1&param2=${param2_id}`
)
.then(function(response) {
alert();
})
.catch(function(error) {
console.log(error);
});
</code></pre>
<p>With the right url and parameters, when I check network requests I indeed get the right answer from my server, but when I open console I see that it didn't call the callback, but instead it caught an error.</p>
<blockquote>
<p>Error: Network Error
Stack trace:
createError@<a href="http://localhost:3000/static/js/bundle.js:2188:15" rel="noreferrer">http://localhost:3000/static/js/bundle.js:2188:15</a>
handleError@<a href="http://localhost:3000/static/js/bundle.js:1717:14" rel="noreferrer">http://localhost:3000/static/js/bundle.js:1717:14</a></p>
</blockquote>
| 0debug
|
Split string Text separator between hyphen in sql server : Select Code From myTable
> In a jod, I have a problem:
>
> I have result string:
Code
ABCD_12
EBC_11
DEEDC_1
> When query data, I want to take the chain on the left "_"
>
> And Result:
Code
ABCD
EBC
DEEDC
Thank you
| 0debug
|
When I change orientation portrait to landscap, a function is restarted in android. How can I resove it? :
[![When I change orientation portrait to landscape(or landscaper to portrait), a function is restarted. I want the function is saved in android. I'm making a calculator. I don't want operator buttons to be enable before number buttons is clicked. So I made a function that make operator buttons click after number buttons is clicked. However, when I clicked a number to calculate, then change orientation, the operator buttons are not enable. It's supposed to be enable.
I mean, number click -> operator click -> number click -> equals button click -> the result is showed, this is okay. But number click -> change orientation -> operator buttons are not enable.... This is my code ↓][1]]
[1]: http://i.stack.imgur.com/UR76S.png
| 0debug
|
Prevent swiping between web pages in iPad Safari : <p>Swiping from the left and right edges of my iPad's Safari browser, moves between the currently open web pages. Is there any way to prevent it?</p>
<p>I have tried to add <code>touchstart</code> and <code>touchmove</code> handlers on the edge of the page that <code>stopPropagation</code> and <code>preventDefault</code>, but they seem to have no effect, nor does <code>touch-action</code> CSS.</p>
<p>A similar question was asked in 2014 with replies to the negative:
<a href="https://stackoverflow.com/questions/18889666/ios-7-is-there-a-way-to-disable-the-swipe-back-and-forward-functionality-in-sa">iOS 7 - is there a way to disable the swipe back and forward functionality in Safari?</a></p>
<p>Is there a workround now in 2018?</p>
| 0debug
|
How can moment.js be imported with typescript? : <p>I'm trying to learn Typescript. While I don't think it's relevant, I'm using VSCode for this demo.</p>
<p>I have a <code>package.json</code> that has these pieces in it:</p>
<pre><code>{
"devDependencies": {
"gulp": "^3.9.1",
"jspm": "^0.16.33",
"typescript": "^1.8.10"
},
"jspm": {
"moment": "npm:moment@^2.12.0"
}
}
</code></pre>
<p>Then I have a Typescript class <code>main.js</code> like this:</p>
<pre><code>import moment from 'moment';
export class Main {
}
</code></pre>
<p>My <code>gulpfile.js</code> looks like this:</p>
<pre><code>var gulp = require('gulp');
var typescript = require('gulp-tsb');
var compilerOptions = {
"rootDir": "src/",
"sourceMap": true,
"target": "es5",
"module": "amd",
"declaration": false,
"noImplicitAny": false,
"noResolve": true,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
};
var typescriptCompiler = typescript.create(compilerOptions);
gulp.task('build', function() {
return gulp.src('/src')
.pipe(typescriptCompiler())
.pipe(gulp.dest('/dest'));
});
</code></pre>
<p>When I run gulp build, I get the message: <code>"../main.ts(1,25): Cannot file module 'moment'."</code></p>
<p>If I use <code>import moment = require('moment');</code> then jspm will work and bring in the module when I run the application, but I'm still receiving the build error.
I also tried:</p>
<pre><code>npm install typings -g
typings install moment --ambient --save
</code></pre>
<p>Instead of making the problem better though, it got worse. Now I get the above error on build as well as the following: <code>"../typings/browser/ambient/moment/index.d.ts(9,21): Cannot find namespace 'moment'."</code></p>
<p>If I go to the file provided by typings and add at the bottom of the file:</p>
<pre><code>declare module "moment" { export = moment; }
</code></pre>
<p>I can get the second error to go away, but I still need the require statement to get moment to work in my <code>main.ts</code> file and am still getting the first build error.</p>
<p>Do I need to create my own <code>.d.ts</code> file for moment or is there just some setup piece I'm missing?</p>
| 0debug
|
static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
mismatch = 1;
{
OPEN_READER(re, &s->gb);
i = -1;
if (n < 4)
quant_matrix = s->inter_matrix;
else
quant_matrix = s->chroma_inter_matrix;
UPDATE_CACHE(re, &s->gb);
if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
level= (3 * qscale * quant_matrix[0]) >> 5;
if (GET_CACHE(re, &s->gb) & 0x40000000)
level = -level;
block[0] = level;
mismatch ^= level;
i++;
SKIP_BITS(re, &s->gb, 2);
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
for (;;) {
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
j = scantable[i];
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
i += run;
j = scantable[i];
if (level < 0) {
level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = -level;
} else {
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
}
}
if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mismatch ^= level;
block[j] = level;
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
CLOSE_READER(re, &s->gb);
}
block[63] ^= (mismatch & 1);
s->block_last_index[n] = i;
return 0;
}
| 1threat
|
static void gen_rfid(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(!ctx->mem_idx)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_rfid();
gen_sync_exception(ctx);
#endif
}
| 1threat
|
The windows.alert() command in javascript : <p>I was trying to make a Rickroll, and post it up on my website, but I was stumped very early I tried various methods on getting this to work but it wont... Could anyone spot my problem. I'm not great at javascript, and the other simaler question's solutions are too personal. </p>
<pre><code><!DOCTYPE HTML>
<html>
<title=You Got RickRolled>
<script>
windows.alert("We're no strangers to love");
windows.alert("You know the rules and so do I");
windows.alert("A full commitment's what I'm thinking of");
windows.alert("You wouldn't get this from any other guy");
windows.alert("I just wanna tell you how I'm feeling");
windows.alert("Gotta make you understand");
windows.alert("Never gonna give you up");
windows.alert("Never gonna let you down");
windows.alert("Never gonna run around and desert you");
windows.alert("Never gonna make you cry");
windows.alert("Never gonna say goodbye");
windows.alert("Never gonna tell a lie and hurt you");
windows.alert("We've known each other for so long");
windows.alert("Your heart's been aching, but");
windows.alert("You're too shy to say it");
windows.alert("Inside, we both know what's been going on");
windows.alert("We know the game and we're gonna play it");
windows.alert("And if you ask me how I'm feeling");
windows.alert("Don't tell me you're too blind to see");
windows.alert("Never gonna give you up");
windows.alert("Never gonna let you down");
windows.alert("Never gonna run around and desert you");
windows.alert("Never gonna make you cry");
windows.alert("Never gonna say goodbye");
windows.alert("Never gonna tell a lie and hurt you");
windows.alert("Never gonna give you up");
windows.alert("Never gonna let you down");
windows.alert("Never gonna run around and desert you");
windows.alert("Never gonna make you cry");
windows.alert("Never gonna say goodbye");
windows.alert("Never gonna tell a lie and hurt you");
windows.alert("(Ooh, give you up)");
windows.alert("(Ooh, give you up)");
windows.alert("Never gonna give, never gonna give");
windows.alert("(Give you up)");
windows.alert("Never gonna give, never gonna give");
windows.alert("(Give you up)");
windows.alert("We've known each other for so long");
windows.alert("Your heart's been aching, but");
windows.alert("You're too shy to say it");
windows.alert("Inside, we both know what's been going on");
windows.alert("We know the game and we're gonna play it");
windows.alert("I just wanna tell you how I'm feeling");
windows.alert("Gotta make you understand");
windows.alert("Never gonna give you up");
windows.alert("Never gonna let you down");
windows.alert("Never gonna run around and desert you");
windows.alert("Never gonna make you cry");
windows.alert("Never gonna say goodbye");
windows.alert("Never gonna tell a lie and hurt you");
windows.alert("Never gonna give you up");
windows.alert("Never gonna let you down");
windows.alert("Never gonna run around and desert you");
windows.alert("Never gonna make you cry");
windows.alert("Never gonna say goodbye");
windows.alert("Never gonna tell a lie and hurt you");
windows.alert("Never gonna give you up");
windows.alert("Never gonna let you down");
windows.alert("Never gonna run around and desert you");
windows.alert("Never gonna make you cry");
windows.alert("Never gonna say goodbye");
windows.alert("Never gonna tell a lie and hurt you");
</script>
</html>
</code></pre>
| 0debug
|
static int openpic_load(QEMUFile* f, void *opaque, int version_id)
{
OpenPICState *opp = (OpenPICState *)opaque;
unsigned int i;
if (version_id != 1)
return -EINVAL;
qemu_get_be32s(f, &opp->glbc);
qemu_get_be32s(f, &opp->veni);
qemu_get_be32s(f, &opp->pint);
qemu_get_be32s(f, &opp->spve);
qemu_get_be32s(f, &opp->tifr);
for (i = 0; i < opp->max_irq; i++) {
qemu_get_be32s(f, &opp->src[i].ipvp);
qemu_get_be32s(f, &opp->src[i].ide);
qemu_get_sbe32s(f, &opp->src[i].last_cpu);
qemu_get_sbe32s(f, &opp->src[i].pending);
}
qemu_get_be32s(f, &opp->nb_cpus);
for (i = 0; i < opp->nb_cpus; i++) {
qemu_get_be32s(f, &opp->dst[i].pctp);
qemu_get_be32s(f, &opp->dst[i].pcsr);
openpic_load_IRQ_queue(f, &opp->dst[i].raised);
openpic_load_IRQ_queue(f, &opp->dst[i].servicing);
}
for (i = 0; i < MAX_TMR; i++) {
qemu_get_be32s(f, &opp->timers[i].ticc);
qemu_get_be32s(f, &opp->timers[i].tibc);
}
return 0;
}
| 1threat
|
Why this query to get friends is returning FALSE? : I have a table named friends which contains 3 fields
user1id, user2id and status.
Status is a foreign key to an another table FriendshipStatuses and both of the other fields are foreign keys to user's table.
So I tried some different queries which resulted in false and getting friendships that were still in request.The query I provided is returning FALSE.
$userId contains the current logged in user's id
`SELECT users.username, users.fullName, users.user_id
FROM users WHERE users.user_id IN(SELECT user1id, user2id
WHERE user1id=$userId OR user2id = $userId)`
| 0debug
|
OnBotJava FirstTechChallenge : Ok so im new to using java and im doing a autonomus mode for my robotics team and I keep getting this error `ERROR: incompatible types:java.lang.String cannot be converted to double` what would cause this?
| 0debug
|
static int read_pakt_chunk(AVFormatContext *s, int64_t size)
{
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
CaffContext *caf = s->priv_data;
int64_t pos = 0, ccount;
int num_packets, i;
ccount = avio_tell(pb);
num_packets = avio_rb64(pb);
if (num_packets < 0 || INT32_MAX / sizeof(AVIndexEntry) < num_packets)
return AVERROR_INVALIDDATA;
st->nb_frames = avio_rb64(pb);
st->nb_frames += avio_rb32(pb);
st->nb_frames += avio_rb32(pb);
st->duration = 0;
for (i = 0; i < num_packets; i++) {
av_add_index_entry(s->streams[0], pos, st->duration, 0, 0, AVINDEX_KEYFRAME);
pos += caf->bytes_per_packet ? caf->bytes_per_packet : ff_mp4_read_descr_len(pb);
st->duration += caf->frames_per_packet ? caf->frames_per_packet : ff_mp4_read_descr_len(pb);
}
if (avio_tell(pb) - ccount != size) {
av_log(s, AV_LOG_ERROR, "error reading packet table\n");
return -1;
}
caf->num_bytes = pos;
return 0;
}
| 1threat
|
static int qemu_chr_open_win_pipe(QemuOpts *opts, CharDriverState **_chr)
{
const char *filename = qemu_opt_get(opts, "path");
CharDriverState *chr;
WinCharState *s;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
if (win_chr_pipe_init(chr, filename) < 0) {
g_free(s);
g_free(chr);
return -EIO;
}
qemu_chr_generic_open(chr);
*_chr = chr;
return 0;
}
| 1threat
|
static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
int maskshift = extract32(value, 0, 3);
if (arm_feature(env, ARM_FEATURE_LPAE) && (value & (1 << 31))) {
value &= ~((7 << 19) | (3 << 14) | (0xf << 3));
} else {
value &= 7;
}
env->cp15.c2_control = value;
env->cp15.c2_mask = ~(((uint32_t)0xffffffffu) >> maskshift);
env->cp15.c2_base_mask = ~((uint32_t)0x3fffu >> maskshift);
}
| 1threat
|
int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_try_str(qdict, "snapshot-file");
const char *format = qdict_get_try_str(qdict, "format");
BlockDriverState *bs;
BlockDriver *drv, *old_drv, *proto_drv;
int ret = 0;
int flags;
char old_filename[1024];
if (!filename) {
qerror_report(QERR_MISSING_PARAMETER, "snapshot-file");
ret = -1;
goto out;
}
bs = bdrv_find(device);
if (!bs) {
qerror_report(QERR_DEVICE_NOT_FOUND, device);
ret = -1;
goto out;
}
pstrcpy(old_filename, sizeof(old_filename), bs->filename);
old_drv = bs->drv;
flags = bs->open_flags;
if (!format) {
format = "qcow2";
}
drv = bdrv_find_format(format);
if (!drv) {
qerror_report(QERR_INVALID_BLOCK_FORMAT, format);
ret = -1;
goto out;
}
proto_drv = bdrv_find_protocol(filename);
if (!proto_drv) {
qerror_report(QERR_INVALID_BLOCK_FORMAT, format);
ret = -1;
goto out;
}
ret = bdrv_img_create(filename, format, bs->filename,
bs->drv->format_name, NULL, -1, flags);
if (ret) {
goto out;
}
qemu_aio_flush();
bdrv_flush(bs);
bdrv_close(bs);
ret = bdrv_open(bs, filename, flags, drv);
if (ret != 0) {
ret = bdrv_open(bs, old_filename, flags, old_drv);
if (ret != 0) {
qerror_report(QERR_OPEN_FILE_FAILED, old_filename);
} else {
qerror_report(QERR_OPEN_FILE_FAILED, filename);
}
}
out:
if (ret) {
ret = -1;
}
return ret;
}
| 1threat
|
Group by date and count average in JS : <p>I have a dataset with the timestamp and some params. It looks like that: </p>
<pre><code>const resp = [
{date: 1576098000, responseBot: 0.47, responseManager: 2.0},
{date: 1576098000, responseBot: 1.50, responseManager: null},
{date: 1576098000, responseBot: 1.05, responseManager: 2.3},
{date: 1576108800, responseBot: 1.00, responseManager: 3.3},
{date: 1576108800, responseBot: 0.60, responseManager: 1.5},
]
...
</code></pre>
<p>I need to get a grouped result (by date) and count an average of response (bot and manager). Expected result: </p>
<pre><code>[
{date: 1576098000, responseBotAvg: 1.006, responseManagerAvg: 2.15},
{date: 1576108800, responseBotAvg: 0.8, responseManagerAvg: 2.4}
]
</code></pre>
<p>What is the best way to achieve this result in pure javascript? </p>
| 0debug
|
How to open a cmd with a command a certain amount of times : <p>I have a cmd opening with a certain command and want it to duplicate the amount of times that they type.</p>
| 0debug
|
Compiling Error whenever i type '@echo off' in VBscript : when i type in '@echo off' in VBscript
i get an error:
[![The error i get when i type @echo off][1]][1]
[1]: http://i.stack.imgur.com/58ZEg.png
wth? how can i fix that?
| 0debug
|
static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VCR1Context *const a = avctx->priv_data;
AVFrame *const p = data;
const uint8_t *bytestream = buf;
int i, x, y, ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
if (buf_size < 32)
goto packet_small;
for (i = 0; i < 16; i++) {
a->delta[i] = *bytestream++;
bytestream++;
buf_size--;
}
for (y = 0; y < avctx->height; y++) {
int offset;
uint8_t *luma = &p->data[0][y * p->linesize[0]];
if ((y & 3) == 0) {
uint8_t *cb = &p->data[1][(y >> 2) * p->linesize[1]];
uint8_t *cr = &p->data[2][(y >> 2) * p->linesize[2]];
if (buf_size < 4 + avctx->width)
goto packet_small;
for (i = 0; i < 4; i++)
a->offset[i] = *bytestream++;
buf_size -= 4;
offset = a->offset[0] - a->delta[bytestream[2] & 0xF];
for (x = 0; x < avctx->width; x += 4) {
luma[0] = offset += a->delta[bytestream[2] & 0xF];
luma[1] = offset += a->delta[bytestream[2] >> 4];
luma[2] = offset += a->delta[bytestream[0] & 0xF];
luma[3] = offset += a->delta[bytestream[0] >> 4];
luma += 4;
*cb++ = bytestream[3];
*cr++ = bytestream[1];
bytestream += 4;
}
} else {
if (buf_size < avctx->width / 2)
goto packet_small;
offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF];
for (x = 0; x < avctx->width; x += 8) {
luma[0] = offset += a->delta[bytestream[2] & 0xF];
luma[1] = offset += a->delta[bytestream[2] >> 4];
luma[2] = offset += a->delta[bytestream[3] & 0xF];
luma[3] = offset += a->delta[bytestream[3] >> 4];
luma[4] = offset += a->delta[bytestream[0] & 0xF];
luma[5] = offset += a->delta[bytestream[0] >> 4];
luma[6] = offset += a->delta[bytestream[1] & 0xF];
luma[7] = offset += a->delta[bytestream[1] >> 4];
luma += 8;
bytestream += 4;
}
}
}
*got_frame = 1;
return buf_size;
packet_small:
av_log(avctx, AV_LOG_ERROR, "Input packet too small.\n");
return AVERROR_INVALIDDATA;
}
| 1threat
|
static void spapr_phb_class_init(ObjectClass *klass, void *data)
{
PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
HotplugHandlerClass *hp = HOTPLUG_HANDLER_CLASS(klass);
hc->root_bus_path = spapr_phb_root_bus_path;
dc->realize = spapr_phb_realize;
dc->props = spapr_phb_properties;
dc->reset = spapr_phb_reset;
dc->vmsd = &vmstate_spapr_pci;
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
hp->plug = spapr_phb_hot_plug_child;
hp->unplug = spapr_phb_hot_unplug_child;
}
| 1threat
|
How to format the output of kubectl describe to JSON : <p><code>kubectl get</code> command has this flag <code>-o</code> to format the output.</p>
<p>Is there a similar way to format the output of the <code>kubectl describe</code> command?</p>
<p>For example:</p>
<pre><code>kubectl describe -o="jsonpath={...}" pods my-rc
</code></pre>
<p>would print a JSON format for the list of pods in <code>my-rc</code> replication controller. But <code>-o</code> is not accepted for the <code>describe</code> command.</p>
| 0debug
|
cannot import image with create-react-app : <p>I'm using <code>create-react-app</code>, and I am struggling to load images. I am following the instructions as specified <a href="https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-images-fonts-and-files" rel="noreferrer">here</a>, but I keep seeing the following error:</p>
<pre><code>Failed to compile.
Error in ./src/components/Home/imageIndex.ts
(1,24): error TS2307: Cannot find module './party.png'
</code></pre>
<p>Does anyone know why when I run <code>yarn start</code> my app continues to fail to compile?</p>
<p>I have a <code>Home</code> component and this is how I am importing the file:</p>
<pre><code>import photo from './party.png';
</code></pre>
<p>The component is located in <code>src/components/Home/index.tsx</code> and the png file is located in <code>src/components/Home/party.png</code>.</p>
<p>here is my package.json:</p>
<pre><code>{
"name": "eai-reactjs-typescript-redux-starter",
"description": "A ReactJS/TypeScript + Redux starter template with a detailed README describing how to use these technologies together and constructive code comments.",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.5",
"redux": "^3.7.0",
"redux-logger": "^3.0.6"
},
"devDependencies": {
"@types/enzyme": "^2.8.0",
"@types/jest": "^19.2.3",
"@types/node": "^7.0.18",
"@types/react": "^15.0.24",
"@types/react-dom": "^15.5.0",
"@types/react-redux": "^4.4.40",
"@types/redux-logger": "^3.0.0",
"enzyme": "^2.8.2",
"react-addons-test-utils": "^15.5.1",
"react-scripts-ts": "1.4.0",
"redux-devtools-extension": "^2.13.2"
},
"scripts": {
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
}
}
</code></pre>
| 0debug
|
Tell me how to print items in a list in reverse order : <p>I want to convert a decimal number into binary. I did everything correctly but i cant print the output. Please tell me how do i reverse the list.</p>
<pre><code> q = int(input("Enter a number\n>"))
lup = 1
binary_digits=[]
while lup == 1:
deci = q%2
binary_digits.append(str(deci))
q = int(q/2)
if q<1:
lup = 100
print(binary_digits) #I know the output is reversed. I want to reverse
#it to make it in order.
</code></pre>
<p>Prints output in reverse.</p>
| 0debug
|
int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
int ret;
AVFrame *pict = data;
#ifdef PRINT_FRAME_TIME
uint64_t time= rdtsc();
#endif
s->flags= avctx->flags;
s->flags2= avctx->flags2;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict = s->next_picture_ptr->f;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(s->flags&CODEC_FLAG_TRUNCATED){
int next;
if(CONFIG_MPEG4_DECODER && s->codec_id==CODEC_ID_MPEG4){
next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
}else if(CONFIG_H263_DECODER && s->codec_id==CODEC_ID_H263){
next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
}else{
av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
return -1;
}
if( ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
return buf_size;
}
retry:
if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){
init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
}else
init_get_bits(&s->gb, buf, buf_size*8);
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if (ff_MPV_common_init(s) < 0)
return -1;
}
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i= ff_find_unused_picture(s, 0);
if (i < 0)
return i;
s->current_picture_ptr= &s->picture[i];
}
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) {
ret= ff_wmv2_decode_picture_header(s);
} else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
ret = ff_msmpeg4_decode_picture_header(s);
} else if (CONFIG_MPEG4_DECODER && s->h263_pred) {
if(s->avctx->extradata_size && s->picture_number==0){
GetBitContext gb;
init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
ret = ff_mpeg4_decode_picture_header(s, &gb);
}
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
ret = ff_flv_decode_picture_header(s);
} else {
ret = ff_h263_decode_picture_header(s);
}
if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
if (ret < 0){
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
return -1;
}
avctx->has_b_frames= !s->low_delay;
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->stream_codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") ||
s->codec_tag == AV_RL32("SIPP")
)
s->xvid_build= 0;
#if 0
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
&& s->padding_bug_score > 0 && s->low_delay)
s->xvid_build= 0;
#endif
}
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
s->divx_version= 400;
}
if(s->xvid_build>=0 && s->divx_version>=0){
s->divx_version=
s->divx_build= -1;
}
if(s->workaround_bugs&FF_BUG_AUTODETECT){
if(s->codec_tag == AV_RL32("XVIX"))
s->workaround_bugs|= FF_BUG_XVID_ILACE;
if(s->codec_tag == AV_RL32("UMP4")){
s->workaround_bugs|= FF_BUG_UMP4;
}
if(s->divx_version>=500 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
}
if(s->divx_version>502 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
}
if(s->xvid_build<=3U)
s->padding_bug_score= 256*256*256*64;
if(s->xvid_build<=1U)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
if(s->xvid_build<=12U)
s->workaround_bugs|= FF_BUG_EDGE;
if(s->xvid_build<=32U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
if(s->lavc_build<4653U)
s->workaround_bugs|= FF_BUG_STD_QPEL;
if(s->lavc_build<4655U)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->lavc_build<4670U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->lavc_build<=4712U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->divx_version==501 && s->divx_build==20020416)
s->padding_bug_score= 256*256*256*64;
if(s->divx_version<500U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
#if 0
if(s->divx_version==500)
s->padding_bug_score= 256*256*256*64;
if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1
&& s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0)
s->workaround_bugs|= FF_BUG_NO_PADDING;
if(s->lavc_build<4609U)
s->workaround_bugs|= FF_BUG_NO_PADDING;
#endif
}
if(s->workaround_bugs& FF_BUG_STD_QPEL){
SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
}
if(avctx->debug & FF_DEBUG_BUGS)
av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
s->divx_packed ? "p" : "");
#if HAVE_MMX
if (s->codec_id == CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
avctx->idct_algo= FF_IDCT_XVIDMMX;
avctx->coded_width= 0;
s->picture_number=0;
}
#endif
if ( s->width != avctx->coded_width
|| s->height != avctx->coded_height) {
ParseContext pc= s->parse_context;
s->parse_context.buffer=0;
ff_MPV_common_end(s);
s->parse_context= pc;
}
if (!s->context_initialized) {
avcodec_set_dimensions(avctx, s->width, s->height);
goto retry;
}
if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P || s->codec_id == CODEC_ID_H263I))
s->gob_index = ff_h263_get_gob_height(s);
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)) return get_consumed_bytes(s, buf_size);
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
if(s->next_p_frame_damaged){
if(s->pict_type==AV_PICTURE_TYPE_B)
return get_consumed_bytes(s, buf_size);
else
s->next_p_frame_damaged=0;
}
if((s->avctx->flags2 & CODEC_FLAG2_FAST) && s->pict_type==AV_PICTURE_TYPE_B){
s->me.qpel_put= s->dsp.put_2tap_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_2tap_qpel_pixels_tab;
}else if((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}else{
s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}
if(ff_MPV_frame_start(s, avctx) < 0)
return -1;
if (!s->divx_packed) ff_thread_finish_setup(avctx);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end;
}
if (avctx->hwaccel) {
if (avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer) < 0)
return -1;
}
ff_er_frame_start(s);
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){
ret = ff_wmv2_decode_secondary_picture_header(s);
if(ret<0) return ret;
if(ret==1) goto intrax8_decoded;
}
s->mb_x=0;
s->mb_y=0;
ret = decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
break;
}else{
int prev_x=s->mb_x, prev_y=s->mb_y;
if(ff_h263_resync(s)<0)
break;
if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
s->error_occurred = 1;
}
if(s->msmpeg4_version<4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0){
s->error_status_table[s->mb_num-1]= ER_MB_ERROR;
}
assert(s->bitstream_buffer_size==0);
frame_end:
if(s->codec_id==CODEC_ID_MPEG4 && s->divx_packed){
int current_pos= get_bits_count(&s->gb)>>3;
int startcode_found=0;
if(buf_size - current_pos > 5){
int i;
for(i=current_pos; i<buf_size-3; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
startcode_found=1;
break;
}
}
}
if(s->gb.buffer == s->bitstream_buffer && buf_size>7 && s->xvid_build>=0){
startcode_found=1;
current_pos=0;
}
if(startcode_found){
av_fast_malloc(
&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
s->bitstream_buffer_size= buf_size - current_pos;
}
}
intrax8_decoded:
ff_er_frame_end(s);
if (avctx->hwaccel) {
if (avctx->hwaccel->end_frame(avctx) < 0)
return -1;
}
ff_MPV_frame_end(s);
assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
assert(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if(s->last_picture_ptr || s->low_delay){
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
#ifdef PRINT_FRAME_TIME
av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time);
#endif
return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size);
}
| 1threat
|
i have bind this function to option tag under select tag now when i am table rows only first row gets changed plsss help me out with better solution : <table id="t" border="1">
<thead id="tb">
<tr>
<th class="id">Id</th>
<th class="name">Name</th>
<th class="address">Address</th>
<th class="phone">Phone</th>
<th class="email">Email</th>
<th class="age">Age</th>
</tr>
</thead>
<tbody>
<tr>
<%
while(rs.next()) {
%>
<td class="id" id="id" style="text-align: center;"><%=rs.getString(1)%></td>
<td class="name" id="na" style="text-align: center;"><%= rs.getString(2) %></td>
<td class="address" id="ad" style="text-align: center;"><%= rs.getString(3) %></td>
<td class="phone" id="ph" style="text-align: center;"><%= rs.getString(4) %></td>
<td class="email" id="em" style="text-align: center;"><%= rs.getString(5) %></td>
<td class="age" id="ag" style="text-align: center;"><%= rs.getString(6) %></td>
</tr>
<% } %>
</tbody>
</table>
function click_action_2(){
var y = document.getElementById("id");
y.innerHTML = "xx";
var x = document.getElementById("na");
x.innerHTML = "xxxx";
var z = document.getElementById("ad");
z.innerHTML = "xx xxxx xxxx";
var a = document.getElementById("ph");
a.innerHTML = "xxxxxxxxxx";
var b = document.getElementById("em");
b.innerHTML = "xxxxx@xxxxx.xxx";
var c = document.getElementById("ag");
c.innerHTML = "xx";
}
i have bind this function to option tag under select tag now when i am changing rows only first row gets changed plsss help me out with better solution
$("select").bind('change', function(){
switch($(this).val()){
case "1":
click_action_1();
break;
case "2":
click_action_2();
break;
case "3":
click_action_3();
break;
}
});
| 0debug
|
Heroku not recognized as an internal or external command (Windows) : <p>Following <a href="https://devcenter.heroku.com/articles/getting-started-with-python#deploy-the-app" rel="noreferrer">this</a> heroku tutorial to launch an app on heroku. But when I use the command <code>heroku create</code>, it says it's not recognized. I added <code>C:\Program Files\Heroku</code> to my PATH. How do I fix this?</p>
| 0debug
|
import re
def remove_whitespaces(text1):
return (re.sub(r'\s+', '',text1))
| 0debug
|
How to remove localization from file : <p>I'm trying to unlocalize xib and storyboard files, and keep all strings in Localizable.strings. How do I do this in XCode?</p>
<p>I've tried to uncheck all languages in the File Inspector, but if I remove the last language the whole file disappears. </p>
<p><a href="https://i.stack.imgur.com/JT2PB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JT2PB.png" alt="enter image description here"></a></p>
<p>A file that is not localized looks like this:</p>
<p><a href="https://i.stack.imgur.com/WnsvN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WnsvN.png" alt="enter image description here"></a> </p>
<p>Unlocalized files wont appear when you add a new language or when you export localizations with xliff.</p>
| 0debug
|
Can a Cloud Function read from Cloud Storage? : <p>The only docs I can find about using GCF+GCS is <a href="https://cloud.google.com/functions/docs/tutorials/storage" rel="noreferrer">https://cloud.google.com/functions/docs/tutorials/storage</a>. AFAICT this is just showing how to use GCS events to trigger GCF.</p>
<p>In the docs for <a href="https://cloud.google.com/functions/docs/writing/dependencies" rel="noreferrer">GCF dependencies</a>, it only mentions node modules. Is it possible for GCF code to read from a GCS bucket? Is it simply the case of requiring a node module that knows how to communicate with GCS and if so, are there any examples of that?</p>
| 0debug
|
Tomcat JDBC Connection Pool: testOnBorrow vs testWhileIdle : <p>For various reasons connections in a pool can become invalid: server connection timeout, network issues...</p>
<p>My understanding is that a Tomcat JDBC Connection Pool does not provide any guaranty about the validity of the connections it provides to the application.</p>
<p>To prevent (actually only lower the risk) getting an invalid connection from the pool a solution seems to be the configuration of connections validation. Validating a connection means to run a very basic query on the database (e.g. <code>SELECT 1;</code> on MySQL).</p>
<p>Tomcat JDBC Connection Pool offers several options to test the connection. The two I find the more interesting are <code>testOnBorrow</code> and <code>testWhileIdle</code>.</p>
<p>First I was thinking that <code>testOnBorrow</code> is the best option because it basically validate the connection before providing it to the application (with a max frequency defined by <code>validationInterval</code>).</p>
<p>But after a second though I realized that testing the connection right before using it might impact the responsiveness of the application. So I though that using <code>testWhileIdle</code> can be more efficient as it test connections while they are not used.</p>
<p>No matter which option I choose it seems that they only lower the risk from getting an invalid connection but this risk still exist. </p>
<p>So I end up asking: should I use <code>testOnBorrow</code> or <code>testWhileIdle</code> or a mix of both?</p>
<p>On a side note, I'm surprised that <code>validationInterval</code> does not apply to <code>testOnReturn</code> and I don't really get the purpose of <code>testOnConnect</code>.</p>
| 0debug
|
In an Android Gradle build, how to exclude dependencies from an included jar file? : <p>In my Android project, I use a library that comes as a jar.
I include it in the dependencies section like so:</p>
<pre><code>dependencies {
...
compile files('libs/thethirdpartylibrary.jar')
...
}
</code></pre>
<p>I also want to use the okhttp library, which I include like this:</p>
<pre><code>compile ('com.squareup.okhttp:okhttp:2.7.5')
</code></pre>
<p>(This particular version of okhttp depends on okio 1.6.0.)</p>
<p>The problem is that the thirdparty jar library depends on okio v0.9.0 and what's worse, bundles it.</p>
<p>As a result, I get a dex conflict error at build time.</p>
<p>I was able to resolve this by manually removing okio from the jar file and this seems to work. But I'm wondering if there's a way to do this in gradle.</p>
<p>My question: Can I remove bundled, transitive ( <- I hope I'm using this word the right way) dependencies from an included jar during build-time with gradle?</p>
| 0debug
|
static inline uint64_t vtd_get_slpte_addr(uint64_t slpte)
{
return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH);
}
| 1threat
|
python: creating a dictionary, coming up as "None" in a file : <p>when reading the file it is coming up as "None", how can i fix this so that it is a dictionary(made from two varibles) in a file.</p>
<pre><code>with open('RPS.txt','r') as f:
highscores = [line.strip() for line in f]
f = open('RPS.txt','a')
high = {player_score: name}
highscores = highscores.append(high)
print(highscores, file=f)
f.close()
</code></pre>
| 0debug
|
not a pbm, pgm or ppm file. by ocrad : <p>I'm sending a book page photo from browser to PHP. I'm writing the photo to disk using this:</p>
<pre><code>$decoded = base64_decode($img);
file_put_contents($output_file, $decoded);
</code></pre>
<p>However when I run <a href="https://www.gnu.org/software/ocrad/" rel="nofollow noreferrer">ocrad</a>/<a href="http://jocr.sourceforge.net/" rel="nofollow noreferrer">gocr</a> for the image then <code>gocr</code> shows error </p>
<blockquote>
<p>"bad magic bytes, expect 0x50 0x3[1-6] but got 0xff 0xd8"</p>
</blockquote>
<p>while <code>ocrad</code> says </p>
<blockquote>
<p>"ocrad: bad magic number - not a pbm, pgm or ppm file."</p>
</blockquote>
<p>What could be the problem?</p>
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
static int cinvideo_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
CinVideoContext *cin = avctx->priv_data;
int i, y, palette_type, palette_colors_count, bitmap_frame_type, bitmap_frame_size;
cin->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if (avctx->reget_buffer(avctx, &cin->frame)) {
av_log(cin->avctx, AV_LOG_ERROR, "delphinecinvideo: reget_buffer() failed to allocate a frame\n");
return -1;
}
palette_type = buf[0];
palette_colors_count = AV_RL16(buf+1);
bitmap_frame_type = buf[3];
buf += 4;
bitmap_frame_size = buf_size - 4;
if (palette_type == 0) {
for (i = 0; i < palette_colors_count; ++i) {
cin->palette[i] = bytestream_get_le24(&buf);
bitmap_frame_size -= 3;
}
} else {
for (i = 0; i < palette_colors_count; ++i) {
cin->palette[buf[0]] = AV_RL24(buf+1);
buf += 4;
bitmap_frame_size -= 4;
}
}
memcpy(cin->frame.data[1], cin->palette, sizeof(cin->palette));
cin->frame.palette_has_changed = 1;
switch (bitmap_frame_type) {
case 9:
cin_decode_rle(buf, bitmap_frame_size,
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
break;
case 34:
cin_decode_rle(buf, bitmap_frame_size,
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
break;
case 35:
cin_decode_huffman(buf, bitmap_frame_size,
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
break;
case 36:
bitmap_frame_size = cin_decode_huffman(buf, bitmap_frame_size,
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
break;
case 37:
cin_decode_huffman(buf, bitmap_frame_size,
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
break;
case 38:
cin_decode_lzss(buf, bitmap_frame_size,
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
break;
case 39:
cin_decode_lzss(buf, bitmap_frame_size,
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
break;
}
for (y = 0; y < cin->avctx->height; ++y)
memcpy(cin->frame.data[0] + (cin->avctx->height - 1 - y) * cin->frame.linesize[0],
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
cin->avctx->width);
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_table[CIN_PRE_BMP]);
*data_size = sizeof(AVFrame);
*(AVFrame *)data = cin->frame;
return buf_size;
}
| 1threat
|
Stop PyCharm If Error : <p>In PyCharm debugging mode, is there way to let it stop right after it hits an error but not exit and highlight the offending line? The analogous feature I have in mind is "dbstop if error" of Matlab.</p>
| 0debug
|
Flask admin remember form value : <p>In my application, I have Users and Posts as models. Each post has a foreign key to a username. When I create a ModelView on top of my Posts model I can create posts as specific users in the admin interface
as seen in the screenshot below</p>
<p><a href="https://i.stack.imgur.com/DdBkJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DdBkJ.png" alt="enter image description here"></a></p>
<p>After I have added a post and click "Save and Add Another", the "User" reverts back to "user1". How can I make the form remember the previous value "user2"? </p>
<p>My reserach has led me to believe it can be done by modifying on_model_change and on_form_prefill, and saving the previous value in the flask session, but it seems to be overengineering such a simple task. There must be a simpler way.</p>
<p>My code can be seen below</p>
<pre class="lang-py prettyprint-override"><code>from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import flask_admin
from flask_admin.contrib import sqla
app = Flask(__name__)
db = SQLAlchemy()
admin = flask_admin.Admin(name='Test')
class Users(db.Model):
"""
Contains users of the database
"""
user_id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), index=True, unique=True, nullable=False)
def __str__(self):
return self.username
class Posts(db.Model):
"""
Contains users of the database
"""
post_id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(11), db.ForeignKey(Users.username), nullable=False)
post = db.Column(db.String(256))
user = db.relation(Users, backref='user')
def build_sample_db():
db.drop_all()
db.create_all()
data = {'user1': 'post1', 'user1': 'post2', 'user2': 'post1'}
for user, post in data.items():
u = Users(username=user)
p = Posts(username=user, post=post)
db.session.add(u)
db.session.add(p)
db.session.commit()
class MyModelView(sqla.ModelView):
pass
if __name__ == '__main__':
app.config['SECRET_KEY'] = '123456790'
app.config['DATABASE_FILE'] = 'sample_db.sqlite'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database'
app.config['SQLALCHEMY_ECHO'] = True
db.init_app(app)
admin.init_app(app)
admin.add_view(MyModelView(Posts, db.session))
with app.app_context():
build_sample_db()
# Start app
app.run(debug=True)
</code></pre>
| 0debug
|
how can i create a list of dictionaries in python : i have a dictionary and tuple of friendship i need to create a list of dictionaries that each key the person and the values are his friends
users=[{"id":0,"name":"hero"},{"id":1,"name":"Dunn"},{"id":2,"name":"Sue"},{"id":3,"name":"Chie"},{"id":4,"name":"Thor"},
{"id": 5, "name": "Clive"},{"id":6,"name":"Hicks"},{"id":7,"name":"Devin"},{"id":8,"name":"Kate"},{"id":9,"name":"kelin"}]
friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4),
(4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)]
friend={}
friends=[]
for i in users:
for j,k in friendships:
if i['id']==j:
friend[i['name']]=k
friends.append(friend)
| 0debug
|
drupal 8 get taxonomy term value in node : <p>Drupal\node\Entity\Node Object
(
[in_preview] =>
[values:protected] => Array
(
[vid] => Array
(
[x-default] => 1
)</p>
<pre><code> [langcode] => Array
(
[x-default] => en
)
[field_destination] => Array
(
[x-default] => Array
(
[0] => Array
(
[target_id] => 2
)
)
)
</code></pre>
<p>Not able to get field_destination value directly. It's a taxonomy term attached with the content type. Any help appriciated.</p>
| 0debug
|
How to switch to frame having HTML <div id="mydiv"> <object id="frame" data="tdreporthome.html"></object> </div> using Selenium : <!DOCTYPE html>
<html>
<head>
<body>
<header class="masthead">
<div id="mydiv">
<object id="frame" data="tdreporthome.html"></object>
</div>
<footer class="navbar default-footer">
</body>
</html>
In the above html structure if i want to switch selenium control to frame how to do so using Selenium ?
| 0debug
|
target_ulong helper_rdhwr_cpunum(CPUMIPSState *env)
{
if ((env->hflags & MIPS_HFLAG_CP0) ||
(env->CP0_HWREna & (1 << 0)))
return env->CP0_EBase & 0x3ff;
else
do_raise_exception(env, EXCP_RI, GETPC());
return 0;
}
| 1threat
|
static int h264_slice_init(H264Context *h, H264SliceContext *sl,
const H2645NAL *nal)
{
int i, j, ret = 0;
if (h->picture_idr && nal->type != H264_NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid mix of IDR and non-IDR slices\n");
return AVERROR_INVALIDDATA;
}
av_assert1(h->mb_num == h->mb_width * h->mb_height);
if (sl->first_mb_addr << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
sl->first_mb_addr >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return AVERROR_INVALIDDATA;
}
sl->resync_mb_x = sl->mb_x = sl->first_mb_addr % h->mb_width;
sl->resync_mb_y = sl->mb_y = (sl->first_mb_addr / h->mb_width) <<
FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD)
sl->resync_mb_y = sl->mb_y = sl->mb_y + 1;
av_assert1(sl->mb_y < h->mb_height);
ret = ff_h264_build_ref_list(h, sl);
if (ret < 0)
return ret;
if (h->ps.pps->weighted_bipred_idc == 2 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, -1);
if (FRAME_MBAFF(h)) {
implicit_weight_table(h, sl, 0);
implicit_weight_table(h, sl, 1);
}
}
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h, sl);
ff_h264_direct_ref_list_init(h, sl);
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
h->nal_unit_type != H264_NAL_IDR_SLICE) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
nal->ref_idc == 0))
sl->deblocking_filter = 0;
if (sl->deblocking_filter == 1 && h->nb_slice_ctx > 1) {
if (h->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
sl->deblocking_filter = 2;
} else {
h->postpone_filter = 1;
}
}
sl->qp_thresh = 15 -
FFMIN(sl->slice_alpha_c0_offset, sl->slice_beta_offset) -
FFMAX3(0,
h->ps.pps->chroma_qp_index_offset[0],
h->ps.pps->chroma_qp_index_offset[1]) +
6 * (h->ps.sps->bit_depth_luma - 8);
sl->slice_num = ++h->current_slice;
if (sl->slice_num)
h->slice_row[(sl->slice_num-1)&(MAX_SLICES-1)]= sl->resync_mb_y;
if ( h->slice_row[sl->slice_num&(MAX_SLICES-1)] + 3 >= sl->resync_mb_y
&& h->slice_row[sl->slice_num&(MAX_SLICES-1)] <= sl->resync_mb_y
&& sl->slice_num >= MAX_SLICES) {
av_log(h->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", sl->slice_num, MAX_SLICES);
}
for (j = 0; j < 2; j++) {
int id_list[16];
int *ref2frm = h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j];
for (i = 0; i < 16; i++) {
id_list[i] = 60;
if (j < sl->list_count && i < sl->ref_count[j] &&
sl->ref_list[j][i].parent->f->buf[0]) {
int k;
AVBuffer *buf = sl->ref_list[j][i].parent->f->buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f->buf[0]->buffer == buf) {
id_list[i] = k;
break;
}
for (k = 0; k < h->long_ref_count; k++)
if (h->long_ref[k] && h->long_ref[k]->f->buf[0]->buffer == buf) {
id_list[i] = h->short_ref_count + k;
break;
}
}
}
ref2frm[0] =
ref2frm[1] = -1;
for (i = 0; i < 16; i++)
ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3);
ref2frm[18 + 0] =
ref2frm[18 + 1] = -1;
for (i = 16; i < 48; i++)
ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
(sl->ref_list[j][i].reference & 3);
}
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG,
"slice:%d %s mb:%d %c%s%s frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
sl->slice_num,
(h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
sl->mb_y * h->mb_width + sl->mb_x,
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
nal->type == H264_NAL_IDR_SLICE ? " IDR" : "",
h->poc.frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
sl->ref_count[0], sl->ref_count[1],
sl->qscale,
sl->deblocking_filter,
sl->slice_alpha_c0_offset, sl->slice_beta_offset,
sl->pwt.use_weight,
sl->pwt.use_weight == 1 && sl->pwt.use_weight_chroma ? "c" : "",
sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
}
return 0;
}
| 1threat
|
static void reverse_dc_prediction(Vp3DecodeContext *s,
int first_fragment,
int fragment_width,
int fragment_height)
{
#define PUL 8
#define PU 4
#define PUR 2
#define PL 1
int x, y;
int i = first_fragment;
int predicted_dc;
int vl, vul, vu, vur;
int l, ul, u, ur;
static const int predictor_transform[16][4] = {
{ 0, 0, 0, 0},
{ 0, 0, 0,128},
{ 0, 0,128, 0},
{ 0, 0, 53, 75}, |PL
{ 0,128, 0, 0},
{ 0, 64, 0, 64}, |PL
{ 0,128, 0, 0}, |PUR
{ 0, 0, 53, 75}, |PUR|PL
{128, 0, 0, 0}, L
{ 0, 0, 0,128}, L|PL
{ 64, 0, 64, 0}, L|PUR
{ 0, 0, 53, 75}, L|PUR|PL
{ 0,128, 0, 0}, L|PU
{-104,116, 0,116}, L|PU|PL
{ 24, 80, 24, 0}, L|PU|PUR
{-104,116, 0,116} L|PU|PUR|PL
};
static const unsigned char compatible_frame[8] = {
1,
0,
1,
1,
1,
2,
2,
1
};
int current_frame_type;
short last_dc[3];
int transform = 0;
vul = vu = vur = vl = 0;
last_dc[0] = last_dc[1] = last_dc[2] = 0;
for (y = 0; y < fragment_height; y++) {
for (x = 0; x < fragment_width; x++, i++) {
if (s->all_fragments[i].coding_method != MODE_COPY) {
current_frame_type =
compatible_frame[s->all_fragments[i].coding_method];
transform= 0;
if(x){
l= i-1;
vl = DC_COEFF(l);
if(FRAME_CODED(l) && COMPATIBLE_FRAME(l))
transform |= PL;
}
if(y){
u= i-fragment_width;
vu = DC_COEFF(u);
if(FRAME_CODED(u) && COMPATIBLE_FRAME(u))
transform |= PU;
if(x){
ul= i-fragment_width-1;
vul = DC_COEFF(ul);
if(FRAME_CODED(ul) && COMPATIBLE_FRAME(ul))
transform |= PUL;
}
if(x + 1 < fragment_width){
ur= i-fragment_width+1;
vur = DC_COEFF(ur);
if(FRAME_CODED(ur) && COMPATIBLE_FRAME(ur))
transform |= PUR;
}
}
if (transform == 0) {
predicted_dc = last_dc[current_frame_type];
} else {
predicted_dc =
(predictor_transform[transform][0] * vul) +
(predictor_transform[transform][1] * vu) +
(predictor_transform[transform][2] * vur) +
(predictor_transform[transform][3] * vl);
predicted_dc /= 128;
if ((transform == 13) || (transform == 15)) {
if (FFABS(predicted_dc - vu) > 128)
predicted_dc = vu;
else if (FFABS(predicted_dc - vl) > 128)
predicted_dc = vl;
else if (FFABS(predicted_dc - vul) > 128)
predicted_dc = vul;
}
}
if(s->coeffs[i].index){
*s->next_coeff= s->coeffs[i];
s->coeffs[i].index=0;
s->coeffs[i].coeff=0;
s->coeffs[i].next= s->next_coeff++;
}
s->coeffs[i].coeff += predicted_dc;
last_dc[current_frame_type] = DC_COEFF(i);
if(DC_COEFF(i) && !(s->coeff_counts[i]&127)){
s->coeff_counts[i]= 129;
s->coeffs[i].next= s->next_coeff;
(s->next_coeff++)->next=NULL;
}
}
}
}
}
| 1threat
|
Using JavaScript Axios/Fetch. Can you disable browser cache? : <p>I am trying to query a quote API for a freeCodeCamp project I'm updating to React.js. I am now trying to use <code>Fetch</code> or <code>Axios</code> to query the API but it's caching the response in the browser. I know in <code>$ajax</code> there is a <code>{ cache: false }</code> that would force the browser to do a new request.</p>
<p>Is there some way I will be able to do the same with <code>Fetch</code> or <code>Axios</code>?</p>
<p>The <code>cache-control</code> setting seems to be already set to <code>max-age: 0</code> by <code>Axios</code>.</p>
<p><a href="https://i.stack.imgur.com/NqsNq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NqsNq.png" alt="enter image description here"></a></p>
<p>This is my code I have that is querying the API.</p>
<pre><code>generateQuote = () => {
axios.get('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
.then(response => {
const { title, content, link } = response.data[0];
console.log(title, content, link)
this.setState(() => ({ title, content, link }));
})
.catch(err => {
console.log(`${err} whilst contacting the quote API.`)
})
</code></pre>
<p>}</p>
| 0debug
|
Return type for Android Room joins : <p>Let's say I want to do an <code>INNER JOIN</code> between two entities <code>Foo</code> and <code>Bar</code>:</p>
<pre><code>@Query("SELECT * FROM Foo INNER JOIN Bar ON Foo.bar = Bar.id")
List<FooAndBar> findAllFooAndBar();
</code></pre>
<p>Is it possible to force a return type like this?</p>
<pre><code>public class FooAndBar {
Foo foo;
Bar bar;
}
</code></pre>
<p>When I try to do that, I get this error:</p>
<pre><code>error: Cannot figure out how to read this field from a cursor.
</code></pre>
<p>I've also tried aliasing the table names to match the field names, but that didn't work either.</p>
<p>If this isn't possible, how should I cleanly construct a compatible return type that includes all fields for both entities?</p>
| 0debug
|
Python 2 - Print in every loop, all time that my loop works, i want to print it : EGG this code doesn work
cont = 1
while True:
if (cont < 500):
hahhahaah
hahahahha
cont += 50
i wanna to print every time like until the script close: 51, 101, 151, 201....
| 0debug
|
static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt)
{
uint32_t acells, scells, intc;
const VEDBoardInfo *daughterboard = (const VEDBoardInfo *)info;
acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells",
NULL, &error_fatal);
scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells",
NULL, &error_fatal);
intc = find_int_controller(fdt);
if (!intc) {
fprintf(stderr, "QEMU: warning: couldn't find interrupt controller in "
"dtb; will not include virtio-mmio devices in the dtb.\n");
} else {
int i;
const hwaddr *map = daughterboard->motherboard_map;
for (i = NUM_VIRTIO_TRANSPORTS - 1; i >= 0; i--) {
add_virtio_mmio_node(fdt, acells, scells,
map[VE_VIRTIO] + 0x200 * i,
0x200, intc, 40 + i);
}
}
}
| 1threat
|
ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)
{
if (so->s == -1 && so->extra) {
qemu_chr_fe_write(so->extra, buf, len);
return len;
}
return send(so->s, buf, len, flags);
}
| 1threat
|
save image in DB using .net core webapi : Happy new year......
I want to upload file and save it into MYSQL DB using .net core webapi. I have google many times but not getting proper search for that. I need help
thanks in advance
| 0debug
|
How to use ng-repeat in angularjs with using array? : myApp.controller("myctrl", function($scope) {
$scope.fullname = [
{ fname: 'Mohil', age: '25', city: 'San Jose', zip:'95112' },
{ fname: 'Darshit', age: '25', city: 'San Jose', zip:'95112'},
{ fname: 'Suchita', age: '25', city: 'Santa Clara', zip:'95182'}
| 0debug
|
How to subtract two inputs from another : How can I subtract two text inputs from the main input,
something like this
<input id="total" type="text " >
<input id="v1" type="text " >
<input id="v2" type="text " >
for example if i inserted 100 in the **total** input and then inserted 20 in **v1** and 30 in **v2**, the **total** input should change to 50..
| 0debug
|
How to get media from external source in hybris? : <p>How to integrate AEM DAM and Hybris.
In multimedia tab of products i need to browse to DAM system. Please suggest me.</p>
<p>Thanks in advance.</p>
| 0debug
|
PHP query not showing all results in html table : <p>So I have the following query to show all users from my database: </p>
<pre><code><ul class="names">
<table>
<tr>
<th>Navn</th>
<th>Email</th>
<th>Score</th>
</tr>
<?php
$connection = mysql_connect('localhost', 'users', 'password'); //The Blank string is the password
mysql_select_db('users');
$query = ("SELECT * FROM oneusers"); //You don't need a ; like you do in SQL
$result = mysql_query($query);
$row=mysql_fetch_array($result);
while($row = mysql_fetch_array($result)){ //Creates a loop to loop through results
echo "<tr><td>" . $row['iUserName'] . "</td><td>" . $row['iUserEmail'] . "</td><td>" . $row['iUserCash'] . " DKK</td></tr>"; //$row['index'] the index here is a field name
}
mysql_close(); //Make sure to close out the database connection
?>
</table>
</ul>
</code></pre>
<p>But for some reason it doesnt show all the data. </p>
<p>In only shows the user with iUserId 2 and not one. </p>
<p>Does anyone have an idea of what might be wrong? </p>
<p>I can log in with iUserId 1's credentials, and it shows fine the info on the login page. </p>
<p>But not here :S</p>
| 0debug
|
how to insert <script> inside a container : I am Working on a project in which I am trying to display a clock inside container. Means that the clock would be responsive.
i am wanting to write a <script> tag which displays time( digital clock) inside container
hope you guys understand my problem
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> UA </title>
<meta name="description" content="EVERYTHING FINE">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<style>
.grey{
background-color: #ccc;
padding: 20px;
}
</style>
</head>
<body>
<header>
<div class="jumbotron">
<div class="container">
<script>
............
</script>
</div>
</div>
</header>
<div class="grey">
<div class="container">
<div class="well">R&D</div>
</div>
</div>
<footer>
<div class="container">
<hr>
<p>
<small><a href="http://hazratferozmemon.org/#/">Jump To TrueTasawwuf</a> TRUE TASAWWUF</small></p>
<!--<p> <small><a href="http://twitter.com/wiredwiki">Ask whatever </a> On Twitter</small></p>-->
<!--<p> <small><a href="http://youtube.com/wiredwiki">Subscribe me</a> On Youtube</small>-->
</p>
</div> <!-- end container -->
</footer>
<!-- Latest compiled and minified JavaScript -->
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>
| 0debug
|
VS2015 Design view unresponsive issue : <p>I am able to work in the Source view with no problems. However, as soon as I click Design the source freezes and hangs. The same thing happens when I switch to Split as well. I cannot find much documentation/support for this issue and wondered if anyone else ran into this as well or has a potential fix? </p>
| 0debug
|
void helper_stl_raw(uint64_t t0, uint64_t t1)
{
stl_raw(t1, t0);
}
| 1threat
|
uint32_t HELPER(sar_cc)(CPUM68KState *env, uint32_t val, uint32_t shift)
{
uint64_t temp;
uint32_t result;
shift &= 63;
temp = (int64_t)val << 32 >> shift;
result = temp >> 32;
env->cc_c = (temp >> 31) & 1;
env->cc_n = result;
env->cc_z = result;
env->cc_v = result ^ val;
env->cc_x = shift ? env->cc_c : env->cc_x;
return result;
}
| 1threat
|
static void vmmouse_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = vmmouse_realizefn;
dc->no_user = 1;
dc->reset = vmmouse_reset;
dc->vmsd = &vmstate_vmmouse;
dc->props = vmmouse_properties;
}
| 1threat
|
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
{
AVStream *st;
int tag;
if (fc->nb_streams < 1)
return 0;
st = fc->streams[fc->nb_streams-1];
avio_rb32(pb);
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
ff_mp4_parse_es_descr(pb, NULL);
} else
avio_rb16(pb);
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag)
ff_mp4_read_dec_config_descr(fc, st, pb);
return 0;
}
| 1threat
|
Delete observation within a variable if between a given interval : <p>I have a database with 3 variables:</p>
<p><code>Var1 Var2 var3</code> </p>
<p><code>A 10 20</code> </p>
<p><code>B 2 20</code> </p>
<p><code>C -3 20</code> </p>
<p><code>D 1 20</code> </p>
<p>I want a general command that drop (omit) any observation if -1
<p>Any help?</p>
| 0debug
|
How to find distance between two set of co-ordinates in php : <p>Let suppose i have two set of co-ordinates, i got these co-ordinates from map source through android application and sent it to server, now server side will calculate distance between them and print.</p>
| 0debug
|
static void do_svc_interrupt(CPUS390XState *env)
{
uint64_t mask, addr;
LowCore *lowcore;
hwaddr len = TARGET_PAGE_SIZE;
lowcore = cpu_physical_memory_map(env->psa, &len, 1);
lowcore->svc_code = cpu_to_be16(env->int_svc_code);
lowcore->svc_ilen = cpu_to_be16(env->int_svc_ilen);
lowcore->svc_old_psw.mask = cpu_to_be64(get_psw_mask(env));
lowcore->svc_old_psw.addr = cpu_to_be64(env->psw.addr + env->int_svc_ilen);
mask = be64_to_cpu(lowcore->svc_new_psw.mask);
addr = be64_to_cpu(lowcore->svc_new_psw.addr);
cpu_physical_memory_unmap(lowcore, len, 1, len);
load_psw(env, mask, addr);
}
| 1threat
|
JDBC Optimisation of query : <p>my question is JDBC can optimise query or just the SGBD can do that, and if JDBC also can optimise which one is the best.
another question what is the difference between analyse and compiling query in JDBC? </p>
| 0debug
|
Vue.js pass function as prop and make child call it with data : <p>I have a posts list component and a post component.</p>
<p>I pass a method to call from the posts list to the post component, so when a button is click it will be called. </p>
<p>But I want to pass the post id when this function is clicked</p>
<p>Code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let PostsFeed = Vue.extend({
data: function () {
return {
posts: [....]
}
},
template: `
<div>
<post v-for="post in posts" :clicked="clicked" />
</div>
`,
methods: {
clicked: function(id) {
alert(id);
}
}
}
let Post = Vue.extend({
props: ['clicked'],
data: function () {
return {}
},
template: `
<div>
<button @click="clicked" />
</div>
`
}</code></pre>
</div>
</div>
</p>
<p>as you can see in Post component you have a click that runs a method he got from a prop, I want to add a variable to that method.</p>
<p>How do you do that?</p>
| 0debug
|
static int parse_header(OutputStream *os, const uint8_t *buf, int buf_size)
{
if (buf_size < 13)
return AVERROR_INVALIDDATA;
if (memcmp(buf, "FLV", 3))
return AVERROR_INVALIDDATA;
buf += 13;
buf_size -= 13;
while (buf_size >= 11 + 4) {
int type = buf[0];
int size = AV_RB24(&buf[1]) + 11 + 4;
if (size > buf_size)
return AVERROR_INVALIDDATA;
if (type == 8 || type == 9) {
if (os->nb_extra_packets > FF_ARRAY_ELEMS(os->extra_packets))
return AVERROR_INVALIDDATA;
os->extra_packet_sizes[os->nb_extra_packets] = size;
os->extra_packets[os->nb_extra_packets] = av_malloc(size);
if (!os->extra_packets[os->nb_extra_packets])
return AVERROR(ENOMEM);
memcpy(os->extra_packets[os->nb_extra_packets], buf, size);
os->nb_extra_packets++;
} else if (type == 0x12) {
if (os->metadata)
return AVERROR_INVALIDDATA;
os->metadata_size = size - 11 - 4;
os->metadata = av_malloc(os->metadata_size);
if (!os->metadata)
return AVERROR(ENOMEM);
memcpy(os->metadata, buf + 11, os->metadata_size);
}
buf += size;
buf_size -= size;
}
if (!os->metadata)
return AVERROR_INVALIDDATA;
return 0;
}
| 1threat
|
Convert Date Time to Format : I am trying to convert a string which is "20151107" to a date format like this "2015-11-07".
Here's my code :
public static DateTime CustomDateFormat(this string resultdate)
{
DateTime dt = DateTime.ParseExact(resultdate, "yyyyMMdd", CultureInfo.InvariantCulture);
return dt;
}
However this returns something like this "11/07/2015 00:00:00.00"
Any idea ? Thanks.
| 0debug
|
What's the difference in both the code snippets? How does it matter to compiler if I am not telling how many bytes needed for array : <p>The basic program of concatenating two strings. I am not getting the point of how not defining the length of str1 array is leading to core dump.</p>
<p>If I define the length of str1 let's say to str1[100] then the program is working fine. </p>
<pre><code>void myStrcat(char *a, char *b)
{
int m = strlen(a);
int n = strlen(b);
int i;
for (i = 0; i <= n; i++){
a[m+i] = b[i];
}
}
int main()
{
char str1[] = "String1 ";
char *str2 = "String2";
myStrcat(str1, str2);
printf("%s ", str1);
return 0;
}
</code></pre>
<p><strong>* stack smashing detected *</strong>: terminated
Aborted (core dumped)</p>
| 0debug
|
how to remove first 3 characters from a title using xslt : For example I have like "0002187433" from that @0002187433 I need to remove first 3 digits by using xslt and output i should get like "2187433". Request you to give me response asap.
I have tried like <xsl:value-of select="substring(0002187433,3,string-length(0002187433)-7)" disable-output-escaping="yes"/> but it is not working.
| 0debug
|
Use function outside method declaration : <p>I have a function <code>get_user_agent()</code>:</p>
<pre><code>def get_user_agent():
valid_user_agents = []
db = pymysql.connect(host='localhost', user='root',passwd='password',db='garbagedb')
cursor = db.cursor()
try:
with db.cursor() as cursor:
useragent_query = "SELECT `ua` FROM `useragent`"
cursor.execute(useragent_query)
useragent_value = cursor.fetchall()
valid_user_agents.append(useragent_value)
db.close()
except:
print("error SELECTing useragent_value")
return valid_user_agents
db = pymysql.connect(host='localhost', user='root',passwd='password',db='garbagedb')
cursor = db.cursor()
get_user_agent() # function invoked
</code></pre>
<p>Then to try to use the <code>list</code> <code>valid_user_agents</code> - This <strong>does not</strong> work:</p>
<pre><code>for ua in valid_user_agents:
print("do something?")
</code></pre>
<p>But then I cant use in a <code>for</code> loop, what am I doing wrong?</p>
| 0debug
|
Can empty HTML elements have attirbutes in HTML? : Empty HTML elements(i.e. elements having no content and no closing tag) like
- br
- hr
or any other HTML elements which I'm not aware of can have attributes in latest HTML5 standard?
Somebody please explain me in simple and easy to understand language.
Thanks.
| 0debug
|
how can I pass parameter from javascript to php : <p>the javascript code as below...how can I pass x to php?And there is not any button. </p>
<pre><code> function f(){
var x = document.getElementById("point").innerHTML;
}
</code></pre>
<p>And if I pass x to the php file,how can I receive it?</p>
| 0debug
|
How is the content of this webpage protected? : <p>I have a little homework webpage, so I am often looking for ideas. I went to Liz's ielts <a href="https://ieltsliz.com/ielts-multiple-choice-listening-turtles/" rel="nofollow noreferrer">page</a>.</p>
<p>Normally, a right click and you can look at the source code, but Liz is smart: if you right click you just get a "Alert content is protected" message.</p>
<p>Very interesting! I've never seen that before. How is that done?</p>
| 0debug
|
My app keeps crashing when i go to other activity : I am trying to make an app named 'moviesinfo', in which i have a login page, with sign up and forgot password option. When i try to login,the app crashes. I also don't know if the data entered on the sign up page is being stored in the database or not.
This is my mainactivity.java
```
package com.example.moviesinfo;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
SQLiteDatabase db;
SQLiteOpenHelper openHelper;
private EditText user;
private EditText password;
private Button btn;
private Button btn2;
private Button forgot;
Cursor cursor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
forgot=findViewById(R.id.forgot);
btn2=(Button) findViewById(R.id.signup);
user= (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
btn = (Button) findViewById(R.id.login);
openHelper= new DatabaseHelper(this);
db=openHelper.getReadableDatabase();
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username1= user.getText().toString();
String password1= password.getText().toString();
cursor = db.rawQuery("SELECT * FROM " +DatabaseHelper.TABLENAME + " WHERE " + DatabaseHelper.COL2 + "=? AND " + DatabaseHelper.COL3+"=?", new String[]{username1,password1});
if (cursor!=null){
if (cursor.getCount()>0){
cursor.moveToNext();
Intent intent = new Intent(MainActivity.this,listmenu.class);
startActivity(intent);
//Toast.makeText(getApplicationContext(),"Login Successful", Toast.LENGTH_SHORT).show();//
}else{
Toast.makeText(getApplicationContext(),"Error" , Toast.LENGTH_SHORT).show();
}
}
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sign_up();
}
});
forgot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
forgot();
}
});
}
private void sign_up()
{
Intent intent= new Intent(MainActivity.this, signup.class);
startActivity(intent);
}
private void forgot()
{
Intent intent= new Intent(MainActivity.this, forgot.class);
startActivity(intent);
}
}
```
This is the signup.java class
```
package com.example.moviesinfo;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.lang.String;
import java.util.ArrayList;
public class signup extends AppCompatActivity {
SQLiteOpenHelper openHelper;
DatabaseHelper db;
SQLiteDatabase db1;
public String uname = "";
public String pwd = "";
public ArrayList<String> cpwd = new ArrayList<String>();
EditText e1, e2, e3;
Button b1,b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
openHelper= new DatabaseHelper(this);
e1 = (EditText) findViewById(R.id.username);
e2 = (EditText) findViewById(R.id.password);
e3 = (EditText) findViewById(R.id.cpwd);
b1 = (Button) findViewById(R.id.save);
b2 = (Button) findViewById(R.id.login2);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
db1=openHelper.getWritableDatabase();
String username =e1.getText().toString();
String password =e2.getText().toString();
String confirm_password =e3.getText().toString();
insert_data(username,password,confirm_password);
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(signup.this,MainActivity.class);
startActivity(intent);
}
});
}
public void insert_data(String username, String password, String confirm_password)
{
ContentValues contentValues = new ContentValues();
contentValues.put(DatabaseHelper.COL2, username);
contentValues.put(DatabaseHelper.COL3, password);
contentValues.put(DatabaseHelper.COL4, confirm_password);
long id=db1.insert(DatabaseHelper.TABLENAME, null, contentValues);
}
}
```
This is the DatabseHelper.java class
```
package com.example.moviesinfo;
import com.example.moviesinfo.signup;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME="userdetails.db";
public static final String TABLENAME="user details";
public static final String COL1="id";
public static final String COL2="username";
public static final String COL3="password";
public static final String COL4="confirmpassword";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null,1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + "TABLENAME(ID INTEGER PRIMARY KEY AUTOINCREMENT,USERNAME TEXT,PASSWORD TEXT,CONFIRMPASSWORD TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " +TABLENAME);
onCreate(db);
}
}
```
I expect that when i click the login button it should jump to next activity with checking the login details from the database.
| 0debug
|
static RawAIOCB *raw_aio_setup(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVRawState *s = bs->opaque;
RawAIOCB *acb;
if (fd_open(bs) < 0)
return NULL;
acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque);
if (!acb)
return NULL;
acb->aiocb.aio_fildes = s->fd;
acb->aiocb.ev_signo = SIGUSR2;
acb->aiocb.aio_iov = qiov->iov;
acb->aiocb.aio_niov = qiov->niov;
acb->aiocb.aio_nbytes = nb_sectors * 512;
acb->aiocb.aio_offset = sector_num * 512;
acb->aiocb.aio_flags = 0;
if (s->aligned_buf)
acb->aiocb.aio_flags |= QEMU_AIO_SECTOR_ALIGNED;
acb->next = posix_aio_state->first_aio;
posix_aio_state->first_aio = acb;
return acb;
}
| 1threat
|
static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
{
AVStream *video_st = s->streams[0];
AVCodecParameters *video_par = s->streams[0]->codecpar;
AVCodecParameters *audio_par = s->streams[1]->codecpar;
int audio_rate = audio_par->sample_rate;
int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den;
int audio_kbitrate = audio_par->bit_rate / 1000;
int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate);
avio_wb32(pb, 0x94);
ffio_wfourcc(pb, "uuid");
ffio_wfourcc(pb, "PROF");
avio_wb32(pb, 0x21d24fce);
avio_wb32(pb, 0xbb88695c);
avio_wb32(pb, 0xfac9c740);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x3);
avio_wb32(pb, 0x14);
ffio_wfourcc(pb, "FPRF");
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x2c);
ffio_wfourcc(pb, "APRF");
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x2);
ffio_wfourcc(pb, "mp4a");
avio_wb32(pb, 0x20f);
avio_wb32(pb, 0x0);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_rate);
avio_wb32(pb, audio_par->channels);
avio_wb32(pb, 0x34);
ffio_wfourcc(pb, "VPRF");
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x1);
if (video_par->codec_id == AV_CODEC_ID_H264) {
ffio_wfourcc(pb, "avc1");
avio_wb16(pb, 0x014D);
avio_wb16(pb, 0x0015);
} else {
ffio_wfourcc(pb, "mp4v");
avio_wb16(pb, 0x0000);
avio_wb16(pb, 0x0103);
}
avio_wb32(pb, 0x0);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, frame_rate);
avio_wb32(pb, frame_rate);
avio_wb16(pb, video_par->width);
avio_wb16(pb, video_par->height);
avio_wb32(pb, 0x010001);
}
| 1threat
|
android application crashes when call intent : > Android application crashes when call intent
give a proper solution
public class InformationActivity extends Activity {
Button btn_submit;
CheckBox iz_check,bc_check,vc_check,ac_check,uc_check;
EditText no_et;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_info);
btn_submit = (Button) findViewById(R.id.btnsubmit1);
iz_check= (CheckBox) findViewById(R.id.check1);
bc_check=(CheckBox) findViewById(R.id.check2);
vc_check=(CheckBox) findViewById(R.id.check3);
ac_check=(CheckBox) findViewById(R.id.check4);
uc_check=(CheckBox) findViewById(R.id.check5);
no_et=(EditText) findViewById(R.id.edittext7);
btn_submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
//String str = no_et.getText().toString();
//SMSReceiver receiver = new SMSReceiver();
Intent navigationintent = new Intent(InformationActivity.this, MainActivity.class);
startActivity(navigationintent);
}
});
}
}
> Please give me a solution
| 0debug
|
def find_Volume(l,b,h) :
return ((l * b * h) / 2)
| 0debug
|
int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt)
{
int i;
double scale = 0;
if (s->dither.method > SWR_DITHER_TRIANGULAR_HIGHPASS && s->dither.method <= SWR_DITHER_NS)
return AVERROR(EINVAL);
out_fmt = av_get_packed_sample_fmt(out_fmt);
in_fmt = av_get_packed_sample_fmt( in_fmt);
if(in_fmt == AV_SAMPLE_FMT_FLT || in_fmt == AV_SAMPLE_FMT_DBL){
if(out_fmt == AV_SAMPLE_FMT_S32) scale = 1.0/(1L<<31);
if(out_fmt == AV_SAMPLE_FMT_S16) scale = 1.0/(1L<<15);
if(out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1.0/(1L<< 7);
}
if(in_fmt == AV_SAMPLE_FMT_S32 && out_fmt == AV_SAMPLE_FMT_S16) scale = 1L<<16;
if(in_fmt == AV_SAMPLE_FMT_S32 && out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1L<<24;
if(in_fmt == AV_SAMPLE_FMT_S16 && out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1L<<8;
scale *= s->dither.scale;
s->dither.ns_pos = 0;
s->dither.noise_scale= scale;
s->dither.ns_scale = scale;
s->dither.ns_scale_1 = 1/scale;
memset(s->dither.ns_errors, 0, sizeof(s->dither.ns_errors));
for (i=0; filters[i].coefs; i++) {
const filter_t *f = &filters[i];
if (fabs(s->out_sample_rate - f->rate) / f->rate <= .05 && f->name == s->dither.method) {
int j;
s->dither.ns_taps = f->len;
for (j=0; j<f->len; j++)
s->dither.ns_coeffs[j] = f->coefs[j];
s->dither.ns_scale_1 *= 1 - exp(f->gain_cB * M_LN10 * 0.005) * 2 / (1<<(8*av_get_bytes_per_sample(out_fmt)));
break;
}
}
if (!filters[i].coefs && s->dither.method > SWR_DITHER_NS) {
av_log(s, AV_LOG_WARNING, "Requested noise shaping dither not available at this sampling rate, using triangular hp dither\n");
s->dither.method = SWR_DITHER_TRIANGULAR_HIGHPASS;
}
av_assert0(!s->preout.count);
s->dither.noise = s->preout;
s->dither.temp = s->preout;
if (s->dither.method > SWR_DITHER_NS) {
s->dither.noise.bps = 4;
s->dither.noise.fmt = AV_SAMPLE_FMT_FLTP;
s->dither.noise_scale = 1;
}
return 0;
}
| 1threat
|
Fill Textbox when Radio button is selected - Visual Studio - Windows Form : <p>I am creating an app with various radio buttons. When one of the radio buttons is selected, I would like to get a value to be automatically entered into textbox (amount). </p>
<p>How this can be done?</p>
<p>Thank you,
Kamil</p>
| 0debug
|
static int udp_close(URLContext *h)
{
UDPContext *s = h->priv_data;
int ret;
if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
closesocket(s->udp_fd);
av_fifo_free(s->fifo);
#if HAVE_PTHREADS
if (s->thread_started) {
pthread_cancel(s->circular_buffer_thread);
ret = pthread_join(s->circular_buffer_thread, NULL);
if (ret != 0)
av_log(h, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret));
}
pthread_mutex_destroy(&s->mutex);
pthread_cond_destroy(&s->cond);
#endif
return 0;
}
| 1threat
|
static uint64_t lance_mem_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
SysBusPCNetState *d = opaque;
uint32_t val;
val = pcnet_ioport_readw(&d->state, addr);
trace_lance_mem_readw(addr, val & 0xffff);
return val & 0xffff;
}
| 1threat
|
First step Arduino Uno R3? : <p>I won the arduino uno r3 in an event, but I have doubts about how to take the first steps to learn how to program it. I would like to understand which courses I am looking for that work for my arduino model (uno r3) and which programming languages and which IDEs I can use. So I can look for a course in Udemy or another platform that I can learn without having to buy an arduino of another brand</p>
| 0debug
|
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
{
int ret;
switch (avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (!frame->width)
frame->width = avctx->width;
if (!frame->height)
frame->height = avctx->height;
if (frame->format < 0)
frame->format = avctx->pix_fmt;
if (!frame->sample_aspect_ratio.num)
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
return ret;
break;
case AVMEDIA_TYPE_AUDIO:
if (!frame->sample_rate)
frame->sample_rate = avctx->sample_rate;
if (frame->format < 0)
frame->format = avctx->sample_fmt;
if (!frame->channel_layout) {
if (avctx->channel_layout) {
if (av_get_channel_layout_nb_channels(avctx->channel_layout) !=
avctx->channels) {
av_log(avctx, AV_LOG_ERROR, "Inconsistent channel "
"configuration.\n");
return AVERROR(EINVAL);
}
frame->channel_layout = avctx->channel_layout;
} else {
if (avctx->channels > FF_SANE_NB_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Too many channels: %d.\n",
avctx->channels);
return AVERROR(ENOSYS);
}
frame->channel_layout = av_get_default_channel_layout(avctx->channels);
if (!frame->channel_layout)
frame->channel_layout = (1ULL << avctx->channels) - 1;
}
}
break;
default: return AVERROR(EINVAL);
}
frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE;
frame->reordered_opaque = avctx->reordered_opaque;
#if FF_API_GET_BUFFER
if (avctx->get_buffer) {
CompatReleaseBufPriv *priv = NULL;
AVBufferRef *dummy_buf = NULL;
int planes, i, ret;
if (flags & AV_GET_BUFFER_FLAG_REF)
frame->reference = 1;
ret = avctx->get_buffer(avctx, frame);
if (ret < 0)
return ret;
if (frame->buf[0])
return 0;
priv = av_mallocz(sizeof(*priv));
if (!priv) {
ret = AVERROR(ENOMEM);
goto fail;
}
priv->avctx = *avctx;
priv->frame = *frame;
dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0);
if (!dummy_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
#define WRAP_PLANE(ref_out, data, data_size) \
do { \
AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
if (!dummy_ref) { \
ret = AVERROR(ENOMEM); \
goto fail; \
} \
ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
dummy_ref, 0); \
if (!ref_out) { \
av_frame_unref(frame); \
ret = AVERROR(ENOMEM); \
goto fail; \
} \
} while (0)
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
if (!desc) {
ret = AVERROR(EINVAL);
goto fail;
}
planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1;
for (i = 0; i < planes; i++) {
int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
int plane_size = (frame->width >> h_shift) * frame->linesize[i];
WRAP_PLANE(frame->buf[i], frame->data[i], plane_size);
}
} else {
int planar = av_sample_fmt_is_planar(frame->format);
planes = planar ? avctx->channels : 1;
if (planes > FF_ARRAY_ELEMS(frame->buf)) {
frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf);
frame->extended_buf = av_malloc(sizeof(*frame->extended_buf) *
frame->nb_extended_buf);
if (!frame->extended_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++)
WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]);
for (i = 0; i < planes - FF_ARRAY_ELEMS(frame->buf); i++)
WRAP_PLANE(frame->extended_buf[i],
frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)],
frame->linesize[0]);
}
av_buffer_unref(&dummy_buf);
return 0;
fail:
avctx->release_buffer(avctx, frame);
av_freep(&priv);
av_buffer_unref(&dummy_buf);
return ret;
}
#endif
return avctx->get_buffer2(avctx, frame, flags);
}
| 1threat
|
static int do_readlink(struct iovec *iovec, struct iovec *out_iovec)
{
char *buffer;
int size, retval;
V9fsString target, path;
v9fs_string_init(&path);
retval = proxy_unmarshal(iovec, PROXY_HDR_SZ, "sd", &path, &size);
if (retval < 0) {
v9fs_string_free(&path);
return retval;
}
buffer = g_malloc(size);
v9fs_string_init(&target);
retval = readlink(path.data, buffer, size);
if (retval > 0) {
buffer[retval] = '\0';
v9fs_string_sprintf(&target, "%s", buffer);
retval = proxy_marshal(out_iovec, PROXY_HDR_SZ, "s", &target);
} else {
retval = -errno;
}
g_free(buffer);
v9fs_string_free(&target);
v9fs_string_free(&path);
return retval;
}
| 1threat
|
Java '+' operator between Arithmetic Add & String concatenation? : <p>As we know<br>
Java '+' operator is used for both </p>
<ul>
<li>Arithmetic Add</li>
<li>String concatenation</li>
</ul>
<p>Need to know exactly expected behavior and applied rule when i used both together<br>
When i try following java code </p>
<pre><code>System.out.println("3" + 3 + 3); // print 333 String concatenation ONLY
System.out.println(3 + "3" + 3); // print 333 String concatenation OLNY
System.out.println(3 + 3 + "3"); // print 63 Arithmetic Add & String concatenation
</code></pre>
| 0debug
|
def count_pairs(arr, n, k):
count=0;
for i in range(0,n):
for j in range(i+1, n):
if arr[i] - arr[j] == k or arr[j] - arr[i] == k:
count += 1
return count
| 0debug
|
ASP.NET Core Response.End()? : <p>I am trying to write a piece of middleware to keep certain client routes from being processed on the server. I looked at a lot of custom middleware classes that would short-circuit the response with </p>
<pre><code>context.Response.End();
</code></pre>
<p>I do not see the End() method in intellisense. How can I terminate the response and stop executing the http pipeline? Thanks in advance!</p>
<pre><code>public class IgnoreClientRoutes
{
private readonly RequestDelegate _next;
private List<string> _baseRoutes;
//base routes correcpond to Index actions of MVC controllers
public IgnoreClientRoutes(RequestDelegate next, List<string> baseRoutes)
{
_next = next;
_baseRoutes = baseRoutes;
}//ctor
public async Task Invoke(HttpContext context)
{
await Task.Run(() => {
var path = context.Request.Path;
foreach (var route in _baseRoutes)
{
Regex pattern = new Regex($"({route}).");
if(pattern.IsMatch(path))
{
//END RESPONSE HERE
}
}
});
await _next(context);
}//Invoke()
}//class IgnoreClientRoutes
</code></pre>
| 0debug
|
R rename columns by using third table : <p>My problem:
Ive got 3 tables: 2 with obs. and variables.
The variables of those two tables have diffenrent names, but describe the same thing. So I want to rename the variables in one table, to than merge them together without doubleing the amount of variables.
The third table is a table which contains the names of both variables, always the two matchings in a row.</p>
<p>How can I rename on tables variables using table #3?
Or else can I join/merge them directly using table #3</p>
| 0debug
|
Integrating Facebook Web SDK with ReactJS Component State : <p>I'm getting started with ReactJS, NodeJS, Webpack, and the Facebook SDK for user authentication. All these technologies and their associated software engineering principles/best practices are relatively new to me (even JavaScript is pretty new to me).</p>
<p>I've followed the tutorial here <a href="https://developers.facebook.com/docs/facebook-login/web" rel="noreferrer">https://developers.facebook.com/docs/facebook-login/web</a> and I've got Facebook authentication working great! But the way this tutorial content is structured, it looks to me like the SDK is designed only to expect the FB status response handlers to be included in the raw page HTML just inside the <code><body></code> tag. The following in particular references this:</p>
<pre><code> // Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</code></pre>
<p>This strategy strikes me as imperfect and hard to integrate with React components. Is there a way to relocate the Facebook login/authentication code and Facebook status update handlers from the HTML, for example, into scripts being bundled with React code via Webpack? Is it possible? Part of the reason for my question is that if I understand correctly, for my Facebook status update handler to be able to update my React components' state, that handler needs to be part of a component to have access to the relevant React component <code>this.setState(...)</code> function.</p>
<p>Am I even thinking about this correctly?</p>
| 0debug
|
How to setup custom breakpoints in the C program? : I'm working on a project, where I cannot disclose the details of the code. So, the application is all written in C and C++. Since, a particular file which wanted to debug has a lot of dependencies and exports, I need to debug the whole project. How do I set breakpoints in the code itself so that the debugging would stop at that particular point? I'm using Ubuntu 14.04 (since the project is compatible with this environment).
I've tried using
#include <csignal>
// Generate an interrupt
std::raise(SIGINT);
But I keep getting error
error: ‘raise’ is not a member of ‘std’
Even this also didn't work
#include <signal.h>
raise(SIGINT);
Plus the debugging wont stop at that point, so that I could foresee the function at that point. I only want to debug it from console, rather using any IDE.
| 0debug
|
How to create a thread pool in java ? : <p>What am I supposed to do if I am asked to create N threads to access N resource , is thread pooling the right solution?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.