problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
{
LJpegEncContext *s = avctx->priv_data;
if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
avctx->color_range == AVCOL_RANGE_MPEG) &&
avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
av_log(avctx, AV_LOG_ERROR,
"Limited range YUV is non-standard, set strict_std_compliance to "
"at least unofficial to use it.\n");
return AVERROR(EINVAL);
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
if (!s->scratch)
goto fail;
ff_idctdsp_init(&s->idsp, avctx);
ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
ff_zigzag_direct);
ff_mjpeg_init_hvsample(avctx, s->hsample, s->vsample);
ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance,
s->huff_code_dc_luminance,
avpriv_mjpeg_bits_dc_luminance,
avpriv_mjpeg_val_dc);
ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance,
s->huff_code_dc_chrominance,
avpriv_mjpeg_bits_dc_chrominance,
avpriv_mjpeg_val_dc);
return 0;
} | 1threat |
Javascript: print html as plain text : <p>I'm trying to print plain html from javascript and can't figured out how to do so.
Example:</p>
<pre><code>$('#elem').html('This is a normal string'); // --> This is a normal string
$('#elem').html('This <b>contains</b> html')
//Current-> This contains html (contains is bold)
//Wanted-> This <b>contains</b> html
</code></pre>
<p>I want to do this because I'm working with comments written by users and don't want html tags to apply if they put some in their comments. But for other reasons I need to see the tags.</p>
<p>Thanks for your help!</p>
| 0debug |
Use regex backreference inside character except class [^] : <p>Lets take:</p>
<p><code>stringi = 'xnxx xnnx xnnxn'</code></p>
<p>My regex is: <code>(n)[^n]</code></p>
<p>I want to make my regex a little more dynamic like that:</p>
<p><code>(n)[^\1]</code> -<code>\1</code> beeing the capt. grp 1</p>
<p>My desired result would be that:</p>
<ul>
<li><code>(n)[^\1]</code> would be equal <code>(n)[^n]</code></li>
<li><code>(x)[^\1]</code> would be equal <code>(x)[^x]</code></li>
</ul>
<p>How can I not match a <code>NOT-\1</code> character?</p>
| 0debug |
void avdevice_register_all(void)
{
static int inited;
if (inited)
return;
inited = 1;
REGISTER_MUXDEMUX (AUDIO_BEOS, audio_beos);
REGISTER_DEMUXER (BKTR, bktr);
REGISTER_DEMUXER (DV1394, dv1394);
REGISTER_MUXDEMUX (OSS, oss);
REGISTER_DEMUXER (V4L2, v4l2);
REGISTER_DEMUXER (V4L, v4l);
REGISTER_DEMUXER (X11_GRAB_DEVICE, x11_grab_device);
REGISTER_DEMUXER (LIBDC1394, libdc1394);
}
| 1threat |
static int qdev_add_one_global(QemuOpts *opts, void *opaque)
{
GlobalProperty *g;
ObjectClass *oc;
g = g_malloc0(sizeof(*g));
g->driver = qemu_opt_get(opts, "driver");
g->property = qemu_opt_get(opts, "property");
g->value = qemu_opt_get(opts, "value");
oc = object_class_dynamic_cast(object_class_by_name(g->driver),
TYPE_DEVICE);
if (oc) {
DeviceClass *dc = DEVICE_CLASS(oc);
if (dc->hotpluggable) {
g->not_used = false;
} else {
g->not_used = true;
}
} else {
g->not_used = true;
}
qdev_prop_register_global(g);
return 0;
}
| 1threat |
Couldn't Create a mercurial Repository : <p>I Used Git for Windows, Setup git.exe location and after that I received this error.
How to fix this?<br>
It is my first time using VCS.</p>
<p><a href="https://i.stack.imgur.com/ZgrAY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZgrAY.png" alt="enter image description here"></a></p>
| 0debug |
Else if statement executing unexpectedly, behaving as else statement : <p>I'm working on a simple function to convert ascii codes to array indexes, and I'm have a bit of trouble with the else-if statement. </p>
<pre><code>int getIndex(char character) {
int code = int(character);
int index = -1;
if (code == int(' ')){
index = 26;
} else if (int('a') <= code <= int('z')) {
index = code - int('a');
}
return index;
}
</code></pre>
<p>The if condition works fine and fires on spaces, but the else if statement fires in every other case, regardless of whether the character is in the range a to z or not. Is there a problem I can't see with the condition? </p>
| 0debug |
"font-family: monospace, monospace" : <p>I'm just curious, in <code>normalize.css</code>, the monospace font rules contain</p>
<pre><code>font-family: monospace, monospace;
</code></pre>
<p>Is there a difference to</p>
<pre><code>font-family: monospace;
</code></pre>
<p>? There must be a reason for using that. Maybe it's a workaround for the behaviour of some browsers?</p>
| 0debug |
Coding unity shaders with unity visual studio : <p>Recently I've been coding shaders for unity in visual studio and I've noticed that since unity shaders are written in a combination of unity's shader lab language and CG, visual studio 2015 doesn't seem to recognize the languages. Because of this, visual studio is not reconizing keywords, has no intellesense, and worse of all tabbing incorrectly whenever I press enter to go to a new line. I've tried this visual studio extension <a href="https://visualstudiogallery.msdn.microsoft.com/ed812631-a7d3-4ca3-9f84-7efb240c7bb5" rel="noreferrer">https://visualstudiogallery.msdn.microsoft.com/ed812631-a7d3-4ca3-9f84-7efb240c7bb5</a> and it doesn't seem to fully work. I was wondering if anyone on here has had experience working with shaders and has an extension they know about to fix this problem.</p>
| 0debug |
void qmp_nbd_server_stop(Error **errp)
{
while (!QTAILQ_EMPTY(&close_notifiers)) {
NBDCloseNotifier *cn = QTAILQ_FIRST(&close_notifiers);
nbd_close_notifier(&cn->n, nbd_export_get_blockdev(cn->exp));
}
qemu_set_fd_handler2(server_fd, NULL, NULL, NULL, NULL);
close(server_fd);
server_fd = -1;
}
| 1threat |
Localstorage encryption alogorithms : I am using localStorage to store token value and other basic user details for offline application mechanism in an Ionic Application.Localstorage is not the secured way to store these sensitive data.Is there any plugin or any other ways to store so that data is protected ? Targetting for
Windows Phone / iOS / Android.All the three | 0debug |
int kvm_arch_release_virq_post(int virq)
{
MSIRouteEntry *entry, *next;
QLIST_FOREACH_SAFE(entry, &msi_route_list, list, next) {
if (entry->virq == virq) {
trace_kvm_x86_remove_msi_route(virq);
QLIST_REMOVE(entry, list);
break;
}
}
return 0;
} | 1threat |
How do I map OAuth 2 token to UserDetails object in a resource server? : <p>I have 2 separate Spring Boot applications, one serving as an an OAuth 2 authorization server, and the other as resource server. I'm using Spring's <code>RemoteTokenServices</code> in my resource server to check tokens from the authorization server. Now, I'm trying to define protected controller code in my resource server application, but I'm not sure how to map the <code>UserDetails</code> class to the authentication principal provided through the OAuth 2 mechanism. </p>
<p>I have set up my authorization server with a custom <code>TokenEnhancer</code> that adds more details to the token such that <code>/oauth/check_token?token=<token></code> returns with custom fields, which I want to map to my resource server controllers.</p>
<p>In a more monolithic setup where the authorization server is also the resource server, I can define controller methods that make use of the authenticated principal this way:</p>
<pre><code>//User implements UserDetails
public Map<String, Object> getResource(@AuthenticationPrincipal User user) {
//code that uses the user object
}
</code></pre>
<p>However, this doesn't seem to work as straight forward in a more distributed approach. The mapping fails, and the <code>user</code> parameter ends up being a null object. I tried using the following approach:</p>
<pre><code>public Map<String, Object> getResource(Authentication authentication) {
//code that uses the authentication object
}
</code></pre>
<p>While the code above successfully maps the authentication details, it doesn't provide a way for me to directly access the custom fields I've set through the <code>TokenEnhancer</code> I mentioned earlier. I can't seem to find anything from the Spring docs regarding this.</p>
| 0debug |
Launch an event when checking a checkbox in Angular2 : <p>I'm newbie in Angular2 and in web globally , I want to launch an action that changes an oject paramater value in the Database when checking a <code>checkbox</code> and or unchecking it using <code>Material-Design</code>, I tried with <code>[(ngModel)]</code> but nothing happened. the idea is that i have to add some propositions with <code>checked | unchecked</code> status to tell if it is a <code>true</code> or <code>false</code> proposition. Here is the proposition model </p>
<pre><code> export class PropositionModel {
id:string;
wordingP:string; // the proposition
propStatus:Boolean; // the proposition status
}
</code></pre>
<p>here is the Html code for a proposition :</p>
<pre><code><div class="uk-width-xlarge-1-1 uk-width-medium-1-2">
<div (submit)="addProp1()" class="uk-input-group">
<span class="uk-input-group-addon"><input type="checkbox" data-md-icheck/></span>
<label>Proposition 1</label>
<input [(ngModel)]="proposition1.wordingP" type="text" class="md-input" required class="md-input"/>
</div>
</div>
</code></pre>
<p>here is the TypeScript code for adding the proposition:</p>
<pre><code>addProp1() {
this.proposition1 = new PropositionModel();
this.proposition1.propStatus = false;
this.propositionService.addProposition(this.proposition1)
.subscribe(response=> {
console.log(response);
console.log(this.proposition1);
this.proposition1 = new PropositionModel();})
}
</code></pre>
<p>And as you can see i made it a <code>false</code> by default for the <code>proposition status</code> and I want to change it once i checked the proposition.
Here is an image how it looks for a better issue understanding.
<a href="https://i.stack.imgur.com/on1ie.png" rel="noreferrer"><img src="https://i.stack.imgur.com/on1ie.png" alt="enter image description here"></a></p>
<p>Any help Please ? </p>
| 0debug |
find all substrings between ${ and } in javascript : <p>i have collections of text with some text between ${ and } like "this is ${test} string ${like}". How can I extract all there strings. Output : test,like</p>
| 0debug |
Android Studio: Gradle Refresh Failed - Could not find com.android.tools.build:gradle:2.2.0-alpha6 : <p>I've just pulled down an Android project from git, and Android Studio is giving me the following error whenever I attempt to open it;</p>
<pre><code>Error:Could not find com.android.tools.build:gradle:2.2.0-alpha6.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.jar
https://maven.fabric.io/public/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.pom
https://maven.fabric.io/public/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.jar
Required by:
newApp_Android:app:unspecified
</code></pre>
<p>I've installed Gradle locally, and set up environment paths via System.</p>
<p>Under Project Structure/Project, the following setup is in use;</p>
<pre><code>Gradle Version : 2.10
Android Plugin Version : 2.2.0-alpha6
Android Plugin Repository : jcenter
Default Library Repository : jcenter
</code></pre>
<p>Could anyone point me in the right direction on this?</p>
| 0debug |
when i run this code i get error admin is not defined : how to retrieve user list from fire base authentication i want to retrieve all register user list how. when i using list user function then message is admin is not define. i am using this function
function listAllUsers(nextPageToken) {
admin.auth().listUsers(1000, nextPageToken)
.then(function(listUsersResult) {
listUsersResult.users.forEach(function(userRecord) {
console.log('user', userRecord.toJSON());
});
if (listUsersResult.pageToken) {
listAllUsers(listUsersResult.pageToken);
}
})
.catch(function(error) {
console.log('Error listing users:', error);
});
}
i am using thsi code to get all user list from firebase auth but i can not get it. error will be admin is not define | 0debug |
static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end)
{
int pal_start, pal_count, i, ret, fps;
if(buf_end - buf < 16) {
av_log(s->avctx, AV_LOG_WARNING, "truncated header\n");
return AVERROR_INVALIDDATA;
s->width = AV_RL16(&buf[4]);
s->height = AV_RL16(&buf[6]);
ret = ff_set_dimensions(s->avctx, s->width, s->height);
if (ret < 0)
return ret;
fps = AV_RL16(&buf[10]);
if (fps > 0)
s->avctx->time_base = (AVRational){ 1, fps };
pal_start = AV_RL16(&buf[12]);
pal_count = AV_RL16(&buf[14]);
buf += 16;
for (i=pal_start; i<pal_start+pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) {
s->palette[i] = AV_RB24(buf);
buf += 3;
return 0; | 1threat |
static uint32_t openpic_cpu_read_internal(void *opaque, hwaddr addr,
int idx)
{
openpic_t *opp = opaque;
IRQ_src_t *src;
IRQ_dst_t *dst;
uint32_t retval;
int n_IRQ;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx "\n", __func__, idx, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF)
return retval;
dst = &opp->dst[idx];
addr &= 0xFF0;
switch (addr) {
case 0x00:
retval = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;
break;
case 0x80:
retval = dst->pctp;
break;
case 0x90:
retval = idx;
break;
case 0xA0:
DPRINTF("Lower OpenPIC INT output\n");
qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]);
n_IRQ = IRQ_get_next(opp, &dst->raised);
DPRINTF("PIAC: irq=%d\n", n_IRQ);
if (n_IRQ == -1) {
retval = IPVP_VECTOR(opp->spve);
} else {
src = &opp->src[n_IRQ];
if (!test_bit(&src->ipvp, IPVP_ACTIVITY) ||
!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {
reset_bit(&src->ipvp, IPVP_ACTIVITY);
retval = IPVP_VECTOR(opp->spve);
} else {
IRQ_setbit(&dst->servicing, n_IRQ);
retval = IPVP_VECTOR(src->ipvp);
}
IRQ_resetbit(&dst->raised, n_IRQ);
dst->raised.next = -1;
if (!test_bit(&src->ipvp, IPVP_SENSE)) {
reset_bit(&src->ipvp, IPVP_ACTIVITY);
src->pending = 0;
}
if ((n_IRQ >= opp->irq_ipi0) && (n_IRQ < (opp->irq_ipi0 + MAX_IPI))) {
src->ide &= ~(1 << idx);
if (src->ide && !test_bit(&src->ipvp, IPVP_SENSE)) {
openpic_set_irq(opp, n_IRQ, 1);
openpic_set_irq(opp, n_IRQ, 0);
set_bit(&src->ipvp, IPVP_ACTIVITY);
}
}
}
break;
case 0xB0:
retval = 0;
break;
default:
break;
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| 1threat |
Angular 4 Property does not exist on type Object on build : <p>I'm building a project using Angular, I started the project using angular-cli and when I try to run <code>ng build --prod</code> i keep getting this error:</p>
<blockquote>
<p>Property 'description' does not exist on type Object</p>
</blockquote>
<p>The code generating this error is the following:</p>
<pre><code>export class AppComponent {
product: Object = {};
constructor(
private store: StoreService,
private request: RequestService,
) {
this.product = this.request.getProduct(_id);
}
}
<p>{{product.description}}</p>
</code></pre>
<p>I was reading some content about this and the error is because I'm using type definition to define product as Object, but I'm not passing any property definition.</p>
<p>I know I could define an Interface, like I do with arrays, but I wasn't able to do it. I don't know if I'm defining it wrong, this is how I tried:</p>
<pre><code>export interface ProductInterface {
id: Number;
description: String;
title: String;
}
product: Object<ProductInterface> = {};
</code></pre>
<p>But it also gives me errors. What do I need to do to avoid this?</p>
| 0debug |
static void filter_mb( H264Context *h, int mb_x, int mb_y ) {
MpegEncContext * const s = &h->s;
const int mb_xy= mb_x + mb_y*s->mb_stride;
uint8_t *img_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16;
uint8_t *img_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
uint8_t *img_cr = s->current_picture.data[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
int linesize, uvlinesize;
int dir;
#if 0
if( !s->decode )
return;
#endif
if( h->sps.mb_aff ) {
return;
}
linesize = s->linesize;
uvlinesize = s->uvlinesize;
for( dir = 0; dir < 2; dir++ )
{
int start = 0;
int edge;
if( ( dir == 0 && mb_x == 0 ) || ( dir == 1 && mb_y == 0 ) ) {
start = 1;
}
if( h->disable_deblocking_filter_idc == 2 ) {
}
for( edge = start; edge < 4; edge++ ) {
int mbn_xy = edge > 0 ? mb_xy : ( dir == 0 ? mb_xy -1 : mb_xy - s->mb_stride );
int bS[4];
int qp;
if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) ||
IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) {
bS[0] = bS[1] = bS[2] = bS[3] = ( edge == 0 ? 4 : 3 );
} else {
int i;
for( i = 0; i < 4; i++ ) {
static const uint8_t block_idx_xy[4][4] = {
{ 0, 2, 8, 10}, { 1, 3, 9, 11},
{ 4, 6, 12, 14}, { 5, 7, 13, 15}
};
int x = dir == 0 ? edge : i;
int y = dir == 0 ? i : edge;
int xn = (x - (dir == 0 ? 1 : 0 ))&0x03;
int yn = (y - (dir == 0 ? 0 : 1 ))&0x03;
if( h->non_zero_count[mb_xy][block_idx_xy[x][y]] != 0 ||
h->non_zero_count[mbn_xy][block_idx_xy[xn][yn]] != 0 ) {
bS[i] = 2;
}
else if( h->slice_type == P_TYPE ) {
const int b8_xy = h->mb2b8_xy[mb_xy]+(y>>1)*h->b8_stride+(x>>1);
const int b8n_xy= h->mb2b8_xy[mbn_xy]+(yn>>1)*h->b8_stride+(xn>>1);
const int b_xy = h->mb2b_xy[mb_xy]+y*h->b_stride+x;
const int bn_xy = h->mb2b_xy[mbn_xy]+yn*h->b_stride+xn;
if( s->current_picture.ref_index[0][b8_xy] != s->current_picture.ref_index[0][b8n_xy] ||
ABS( s->current_picture.motion_val[0][b_xy][0] - s->current_picture.motion_val[0][bn_xy][0] ) >= 4 ||
ABS( s->current_picture.motion_val[0][b_xy][1] - s->current_picture.motion_val[0][bn_xy][1] ) >= 4 )
bS[i] = 1;
else
bS[i] = 0;
}
else {
return;
}
}
}
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
if( dir == 0 ) {
filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( get_chroma_qp( h, s->current_picture.qscale_table[mb_xy] ) +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp );
filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp );
}
} else {
filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( get_chroma_qp( h, s->current_picture.qscale_table[mb_xy] ) +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
}
}
}
}
}
| 1threat |
void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
{
if (mask & CPSR_NZCV) {
env->ZF = (~val) & CPSR_Z;
env->NF = val;
env->CF = (val >> 29) & 1;
env->VF = (val << 3) & 0x80000000;
}
if (mask & CPSR_Q)
env->QF = ((val & CPSR_Q) != 0);
if (mask & CPSR_T)
env->thumb = ((val & CPSR_T) != 0);
if (mask & CPSR_IT_0_1) {
env->condexec_bits &= ~3;
env->condexec_bits |= (val >> 25) & 3;
}
if (mask & CPSR_IT_2_7) {
env->condexec_bits &= 3;
env->condexec_bits |= (val >> 8) & 0xfc;
}
if (mask & CPSR_GE) {
env->GE = (val >> 16) & 0xf;
}
if ((env->uncached_cpsr ^ val) & mask & CPSR_M) {
switch_mode(env, val & CPSR_M);
}
mask &= ~CACHED_CPSR_BITS;
env->uncached_cpsr = (env->uncached_cpsr & ~mask) | (val & mask);
}
| 1threat |
Telegram Bot Event When Users Join To Channel : <p>After create telegram bot, access and admin this bot to channel. how to get channel members list or event when users join to this channel?</p>
| 0debug |
Azure move app service to a different app service plan : <p>I have the following setup:</p>
<ul>
<li>Resource group 1
<ul>
<li>App service plan 1</li>
<li>App Service 1 (app service plan 1)</li>
</ul></li>
<li>Resource group 2
<ul>
<li>App service plan 2</li>
<li>App Service 2 (app service plan 2)</li>
<li>App Service 3 (app service plan 1)</li>
</ul></li>
</ul>
<p>I would like to move <code>App Service 3</code> which is into <code>Resource group 2</code> but uses <code>app service plan 1</code>, to <code>app service plan 2</code>.</p>
<p>Is this possible? I have tried to use the feature "Change App service plan" available on the new portal but when I click on it a blade appear saying that "No App Service plan found".</p>
<p>I suspect that the blade looks for app service plan available on the original resource group and does not permit neither to create a new one.</p>
<p>Please see the attached picture for details.</p>
<p>Thanks </p>
<p><a href="https://i.stack.imgur.com/6wrHx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6wrHx.png" alt="enter image description here"></a></p>
| 0debug |
static void mirror_write_complete(void *opaque, int ret)
{
MirrorOp *op = opaque;
MirrorBlockJob *s = op->s;
aio_context_acquire(blk_get_aio_context(s->common.blk));
if (ret < 0) {
BlockErrorAction action;
bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, false, -ret);
if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) {
s->ret = ret;
}
}
mirror_iteration_done(op, ret);
aio_context_release(blk_get_aio_context(s->common.blk));
}
| 1threat |
problème Exception in Application start method : I am trying to create a JavaFX program, and every time whene i add any thing from the lebrary of jfoenix I try to run my code I am getting an exception - I'm not entirely sure what it means though...
my code is :
public class home extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("home.fxml"));
Scene scene = new Scene(root,1300,768);
scene.getStylesheets().add(getClass().getResource("Style.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
my controller is :
public class HomeController implements Initializable {
@FXML
private JFXButton log;
@FXML
private JFXButton engr;
@FXML
private Pane login,eng;
@FXML
private void changeofpages(MouseEvent event) {
if (event.getTarget()== log){
login.setVisible(true);
eng.setVisible(false);
}else
if (event.getTarget()== engr){
eng.setVisible(true);
login.setVisible(false);
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
} | 0debug |
Download Blob file from Website inside Android WebViewClient : <p>I have an HTML Web page with a button that triggers a POST request when the user clicks on. When the request is done, the following code is fired:</p>
<pre><code>window.open(fileUrl);
</code></pre>
<p>Everything works great in the browser, but when implement that inside of a Webview Component, the new tab doesn't is opened.</p>
<p>FYI: On my Android App, I have set the followings things:</p>
<pre><code>webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setSupportMultipleWindows(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
</code></pre>
<p>On the <code>AndroidManifest.xml</code> I have the following permissions:</p>
<pre><code><uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>
</code></pre>
<p>I try too with a <code>setDownloadListener</code> to catch the download. Another approach was replaced the <code>WebViewClient()</code> for <code>WebChromeClient()</code> but the behavior was the same.</p>
| 0debug |
How to fix background Color Javascript and Html function? : Javascript function is not working(see below)
<div onmouseout="colorBack(id)">Hi everyone</div>
<script>
function colorBack(x){
id.style.backgroundColor="red";
}
</script>
| 0debug |
Infinite loop and CPU usage on single core and multicore : <p>Interviewer has asked me this question and I want to understand concept ie how CPU usages varies :</p>
<p>1) If infinite loop is running in single-threaded design with single core machine </p>
<p>2) If infinite loop is running in single-threaded design with multi-core machine ( 4 core )</p>
<p>3) If infinite loop is running in multi-threaded design with single core machine </p>
<p>4)If infinite loop is running in multi-threaded design with multi-core machine (4 core )</p>
<p>5) What will happen when application is having more threads then hardware core. For ex : Application is creating 30 threads in 4 core machine. Will it increase the performance of application or decrease the performance ?</p>
<p>6) What will happen when application is having less threads then hardware core. For ex : Application is creating 5 threads in 4 core machine. Will it increase the performance of application or decrease the performance ?</p>
<p>Requesting you to explain the concepts so that things are clear. I have lot of confusion. </p>
| 0debug |
Decoding Kubernetes secret : <p>I inherited a Kubernetes/Docker setup, and I accidentally crashed the pod by changing something relating to the DB password.</p>
<p>I am trying to troubleshoot this.</p>
<p>I don't have much Kubernetes or Docker experience, so I'm still learning how to do things.</p>
<p>The value is contained inside the db-user-pass credential I believe, which is an Opaque type secret.</p>
<p>I'm describing it:</p>
<pre><code>kubectl describe secrets/db-user-pass
Name: db-user-pass
Namespace: default
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
password: 16 bytes
username: 13 bytes
</code></pre>
<p>but I have no clue how to get any data from this secret. The example on the Kubernetes site seems to assume I'll have a base64 encoded string, but I can't even seem to get that. How do I get the value for this?</p>
| 0debug |
static void uc32_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
UniCore32CPUClass *ucc = UNICORE32_CPU_CLASS(oc);
ucc->parent_realize = dc->realize;
dc->realize = uc32_cpu_realizefn;
cc->class_by_name = uc32_cpu_class_by_name;
cc->has_work = uc32_cpu_has_work;
cc->do_interrupt = uc32_cpu_do_interrupt;
cc->cpu_exec_interrupt = uc32_cpu_exec_interrupt;
cc->dump_state = uc32_cpu_dump_state;
cc->set_pc = uc32_cpu_set_pc;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = uc32_cpu_handle_mmu_fault;
#else
cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;
#endif
dc->vmsd = &vmstate_uc32_cpu;
} | 1threat |
Java - How to parse numbers and characters from this string? : <p>i have a calculator, my problem is that i want to somehow parse the int from the string and then calculate the result, i know subtraction should be first but is there any pattern to do this correctly?
<a href="https://i.stack.imgur.com/Ueul1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ueul1.png" alt="calc"></a></p>
| 0debug |
static BlockAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs,
int64_t sector_num,
QEMUIOVector *qiov,
int nb_sectors,
BdrvRequestFlags flags,
BlockCompletionFunc *cb,
void *opaque,
bool is_write)
{
Coroutine *co;
BlockAIOCBCoroutine *acb;
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
acb->req.sector = sector_num;
acb->req.nb_sectors = nb_sectors;
acb->req.qiov = qiov;
acb->req.flags = flags;
acb->is_write = is_write;
co = qemu_coroutine_create(bdrv_co_do_rw);
qemu_coroutine_enter(co, acb);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
| 1threat |
bool qdict_get_bool(const QDict *qdict, const char *key)
{
QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL);
return qbool_get_bool(qobject_to_qbool(obj));
}
| 1threat |
Why this output behave like annoying.I am trying to understand this :
this is the code snippet :
public static void main(String[] args) {
int a = \u0030;
System.out.println(a);
}
**this code is printing 0 for me.** | 0debug |
static void test_visitor_out_null(TestOutputVisitorData *data,
const void *unused)
{
QObject *arg;
QDict *qdict;
QObject *nil;
visit_start_struct(data->ov, NULL, NULL, 0, &error_abort);
visit_type_null(data->ov, "a", &error_abort);
visit_end_struct(data->ov, &error_abort);
arg = qmp_output_get_qobject(data->qov);
g_assert(qobject_type(arg) == QTYPE_QDICT);
qdict = qobject_to_qdict(arg);
g_assert_cmpint(qdict_size(qdict), ==, 1);
nil = qdict_get(qdict, "a");
g_assert(nil);
g_assert(qobject_type(nil) == QTYPE_QNULL);
qobject_decref(arg);
}
| 1threat |
int ff_load_image(uint8_t *data[4], int linesize[4],
int *w, int *h, enum AVPixelFormat *pix_fmt,
const char *filename, void *log_ctx)
{
AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx = NULL;
AVCodec *codec;
AVCodecContext *codec_ctx;
AVFrame *frame;
int frame_decoded, ret = 0;
AVPacket pkt;
av_register_all();
iformat = av_find_input_format("image2");
if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Failed to open input file '%s'\n", filename);
return ret;
}
codec_ctx = format_ctx->streams[0]->codec;
codec = avcodec_find_decoder(codec_ctx->codec_id);
if (!codec) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to find codec\n");
ret = AVERROR(EINVAL);
goto end;
}
if ((ret = avcodec_open2(codec_ctx, codec, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
goto end;
}
if (!(frame = avcodec_alloc_frame()) ) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc frame\n");
ret = AVERROR(ENOMEM);
goto end;
}
ret = av_read_frame(format_ctx, &pkt);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to read frame from file\n");
goto end;
}
ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
if (ret < 0 || !frame_decoded) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
goto end;
}
ret = 0;
*w = frame->width;
*h = frame->height;
*pix_fmt = frame->format;
if ((ret = av_image_alloc(data, linesize, *w, *h, *pix_fmt, 16)) < 0)
goto end;
ret = 0;
av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h);
end:
if (codec_ctx)
avcodec_close(codec_ctx);
if (format_ctx)
avformat_close_input(&format_ctx);
av_freep(&frame);
if (ret < 0)
av_log(log_ctx, AV_LOG_ERROR, "Error loading image file '%s'\n", filename);
return ret;
}
| 1threat |
How can I sort by name? : In my Symfony Controller, in listarAction, I list all articles of the database, but I'd like to sort them by the name of article. I have this:
public function listarAction(Request $request) { {
$em = $this->getDoctrine()->getManager();
$articulos = $em->getRepository("BDBundle:Articulos")->findAll();
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$articulos, $request->query->getInt('page', 1), 5);
return $this->render('AppBundle:Default:productos_listar.html.twig', array(
'pagination' => $pagination
));
}
}
How would it be the correct form? Thanks.
| 0debug |
AddRange throws "Cannot implicitly convert type" exception : <p>I have no idea why this is not working:</p>
<pre><code> Dictionary<string, List<GameObject>> prefabs = new Dictionary<string, List<GameObject>>();
List<GameObject> slotPrefabs = new List<GameObject>();
// yadda yadda yadda
if (prefabs.ContainsKey(slot))
{
prefabs[slot] = prefabs[slot].AddRange(slotPrefabs);
}
else
{
prefabs.Add(slot, slotPrefabs);
}
</code></pre>
<p>It's giving me:</p>
<blockquote>
<p>Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'</p>
</blockquote>
<p>I just want to add to the existing list of the dictionary key if it already exists.</p>
| 0debug |
(Eliminate duplicates) : (Eliminate duplicates) Write a method that returns a new array by eliminating the
duplicate values in the array using the following method header:
public static int[] eliminateDuplicates(int[] list)
Write a test program that reads in 10 integers, invokes the method, and displays
the distinct numbers separated by exactly one space. Here is a sample run of the
program:
Enter 10 numbers: 1 2 3 2 1 6 3 4 5 2
The distinct numbers are: 1 2 3 6 4 5
package bucky;
import java.util.Scanner;
public class Arrays {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter ten numbers: ");
int[] list = new int[10];
for (int i = 0; i < list.length; i++) {
list[i] = in.nextInt();
}
eliminateDuplicates(list);
System.out.print("The distinct numbers are: ");
for (int i = 0; i < list.length; i++) {
System.out.print(list[i]);
}
}
public static int[] eliminateDuplicates(int[] list) {
int count = 0;
int j = 0;
int[] nArray = new int[list.length];
while (j < list.length) {
for (int i = 1; i < list.length; i++) {
int low = list[j];
if (list[i] == low) {
count++;
} else {
nArray[i] = low;
}
}
j++;
}
return nArray;
}
}
| 0debug |
static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
#if HAVE_FAST_64BIT
#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
uint64_t temp;
if (DC_SHIFT - extra_shift > 0) {
temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
} else {
temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
}
temp += temp << 16;
temp += temp << 32;
((uint64_t *)row)[0] = temp;
((uint64_t *)row)[1] = temp;
return;
}
#else
if (!(((uint32_t*)row)[1] |
((uint32_t*)row)[2] |
((uint32_t*)row)[3] |
row[1])) {
uint32_t temp;
if (DC_SHIFT - extra_shift > 0) {
temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
} else {
temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
}
temp += temp << 16;
((uint32_t*)row)[0]=((uint32_t*)row)[1] =
((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
return;
}
#endif
a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
a1 = a0;
a2 = a0;
a3 = a0;
a0 += W2 * row[2];
a1 += W6 * row[2];
a2 -= W6 * row[2];
a3 -= W2 * row[2];
b0 = MUL(W1, row[1]);
MAC(b0, W3, row[3]);
b1 = MUL(W3, row[1]);
MAC(b1, -W7, row[3]);
b2 = MUL(W5, row[1]);
MAC(b2, -W1, row[3]);
b3 = MUL(W7, row[1]);
MAC(b3, -W5, row[3]);
if (AV_RN64A(row + 4)) {
a0 += W4*row[4] + W6*row[6];
a1 += - W4*row[4] - W2*row[6];
a2 += - W4*row[4] + W2*row[6];
a3 += W4*row[4] - W6*row[6];
MAC(b0, W5, row[5]);
MAC(b0, W7, row[7]);
MAC(b1, -W1, row[5]);
MAC(b1, -W5, row[7]);
MAC(b2, W7, row[5]);
MAC(b2, W3, row[7]);
MAC(b3, W3, row[5]);
MAC(b3, -W1, row[7]);
}
row[0] = (a0 + b0) >> (ROW_SHIFT + extra_shift);
row[7] = (a0 - b0) >> (ROW_SHIFT + extra_shift);
row[1] = (a1 + b1) >> (ROW_SHIFT + extra_shift);
row[6] = (a1 - b1) >> (ROW_SHIFT + extra_shift);
row[2] = (a2 + b2) >> (ROW_SHIFT + extra_shift);
row[5] = (a2 - b2) >> (ROW_SHIFT + extra_shift);
row[3] = (a3 + b3) >> (ROW_SHIFT + extra_shift);
row[4] = (a3 - b3) >> (ROW_SHIFT + extra_shift);
}
| 1threat |
Ngrx 6.1.0 - Select is deprecated - What is the new syntax? : <p>The following ngrx select is deprecated.</p>
<pre><code>this.store.select(state => state.academy.academy).subscribe((academy) => {
this.academy = academy;
});
</code></pre>
<p>I found this at store.d.ts</p>
<pre><code>@deprecated from 6.1.0. Use the pipeable `select` operator instead.
</code></pre>
<p>So... what's the correct syntax?</p>
<p>I try </p>
<pre><code>this.store.pipe(select(state => state.academy.academy).subscribe((academy) => {
this.academy = academy;
}))
</code></pre>
<p>Error: Cannot find name 'select'. Did you mean 'onselect'?</p>
| 0debug |
void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
QXLDevSurfaceCreate *surface,
qxl_async_io async)
{
if (async != QXL_SYNC) {
#if SPICE_INTERFACE_QXL_MINOR >= 1
spice_qxl_create_primary_surface_async(&ssd->qxl, id, surface, 0);
#else
abort();
#endif
} else {
ssd->worker->create_primary_surface(ssd->worker, id, surface);
}
}
| 1threat |
Python - dump of lists into csv export : I need to ad column headers and then export the following to csv.
But whenever I export the list I am only get the last line with each of the characters in columns.
This is the current output I am getting:
[![Current output of list][1]][1]
If I do df=pd.DataFrame([d])
Then I get the following :
[![enter image description here][2]][2]
[1]: https://i.stack.imgur.com/y4O6v.png
[2]: https://i.stack.imgur.com/F1qHR.png | 0debug |
static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
const char *devaddr,
const char *opts)
{
PCIDevice *dev;
DriveInfo *dinfo = NULL;
int type = -1;
char buf[128];
if (get_param_value(buf, sizeof(buf), "if", opts)) {
if (!strcmp(buf, "scsi"))
type = IF_SCSI;
else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
} else {
monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf);
return NULL;
}
} else {
monitor_printf(mon, "no if= specified\n");
return NULL;
}
if (get_param_value(buf, sizeof(buf), "file", opts)) {
dinfo = add_init_drive(opts);
if (!dinfo)
return NULL;
if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
return NULL;
}
} else {
dinfo = NULL;
}
switch (type) {
case IF_SCSI:
dev = pci_create("lsi53c895a", devaddr);
break;
case IF_VIRTIO:
if (!dinfo) {
monitor_printf(mon, "virtio requires a backing file/device.\n");
return NULL;
}
dev = pci_create("virtio-blk-pci", devaddr);
qdev_prop_set_drive(&dev->qdev, "drive", dinfo);
break;
default:
dev = NULL;
}
if (dev)
qdev_init(&dev->qdev);
return dev;
}
| 1threat |
With preg_match it's possible to have the same pattern and have different replacements? : <p>I create this pattern </p>
<pre><code>$pattern = "/<a href='(?<href>.+?)'>(?<name>.+?)<\/a>/i";
</code></pre>
<p>And i have this example,</p>
<pre><code>$string = "<a href='https://www.php.net/'>https://www.php.net/</a>
<a href='https://stackoverflow.com/'>https://stackoverflow.com/</a>
<a href='https://www.google.com/'>https://www.google.com/</a>";
</code></pre>
<p>Using this, i can find the matches and extract the href, and the name. </p>
<pre><code>preg_match_all($pattern, $string, $matches);
Array
(
[0] => Array
(
[0] => https://www.php.net/
[1] => https://stackoverflow.com/
[2] => https://www.google.com/
)
[href] => Array
(
[0] => https://www.php.net/
[1] => https://stackoverflow.com/
[2] => https://www.google.com/
)
[1] => Array
(
[0] => https://www.php.net/
[1] => https://stackoverflow.com/
[2] => https://www.google.com/
)
[name] => Array
(
[0] => https://www.php.net/
[1] => https://stackoverflow.com/
[2] => https://www.google.com/
)
[2] => Array
(
[0] => https://www.php.net/
[1] => https://stackoverflow.com/
[2] => https://www.google.com/
)
)
</code></pre>
<p>The problem is when I use the preg_replace, since the pattern is the same, it changes the same information for all the URL, and i need to change only the name and preserve the rest of the information accordingly.</p>
<p>Using,</p>
<pre><code>if(preg_match_all($pattern, $string, $matches))
{
$string = preg_replace($pattern, "<a href='$1'>Name</a>", $string);
}
</code></pre>
<p>I can get the results from the groups, and preserve the first part of the href. But if i try to change the name, it's the same for all results. </p>
<p>If I try to use "str_replace", I can have different results as intended, but this gave me 2 problems. One is that if i try to replace the name, i also change the href, and if i have similar URL with "more slashes" it will change the match part, and leave the rest of the information.</p>
<p>In a database I have list of URL with a column that have names, and if the string match any row in the table I need to change the name accordingly and preserve the href. </p>
<p>Any help? </p>
<p>Thank you.</p>
<p>Kind regards!</p>
| 0debug |
compreTo() method in java is not working : In java if
s1 = "d";
s2 = "D"
System.out.println(s1.compareTo(s2));
It will give output 32 always no matter what alphabet you use if they are same i.e. one is capital and one is smaller.
Why is this so??? | 0debug |
Syntax error with try/except statement highlighing 'except' : I have a very simple try/except block to basically force the variable 'password' to be defined as an integer from user input.
It is likely a dumb question, but I have tried looking around and cannot find some solution.
try:
password = int(input('Bob should have issued you with your 4-digit numerical password, please enter it here: ')
except ValueError:
print("Please do not type letters or symbols!!")
while type(password) != 'int':
try:
password = int(input('Bob should have issued you with your 4-digit numerical password, please enter it here: ')
except ValueError:
print("Please do not type letters or symbols!!")
print('Complete, we have your password.')
But, when I try run this python shell, it comes up with a Syntax Error, highlighting 'except'... | 0debug |
How to write a CSV file without using external libraries : <p>I have already checked out these libraries <code>oledb</code>, <code>Microsoft Text Writer</code>, and <code>TextFieldParser</code>. We are not allowed to use oledb and Microsoft Text Driver on the server. Also, not allowed to use external libraries. I see that TextFieldParser only reads the file. Is there a way to write a CSV file natively in C#? I am aware that write a CSV is pretty complex so I don't want to roll my own solution. </p>
| 0debug |
static inline void start_exclusive(void)
{
CPUState *other;
pthread_mutex_lock(&exclusive_lock);
exclusive_idle();
pending_cpus = 1;
for (other = first_cpu; other; other = other->next_cpu) {
if (other->running) {
pending_cpus++;
cpu_interrupt(other, CPU_INTERRUPT_EXIT);
}
}
if (pending_cpus > 1) {
pthread_cond_wait(&exclusive_cond, &exclusive_lock);
}
}
| 1threat |
static int ram_save_iterate(QEMUFile *f, void *opaque)
{
int ret;
int i;
int64_t t0;
int total_sent = 0;
qemu_mutex_lock_ramlist();
if (ram_list.version != last_version) {
reset_ram_globals();
}
ram_control_before_iterate(f, RAM_CONTROL_ROUND);
t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
i = 0;
while ((ret = qemu_file_rate_limit(f)) == 0) {
int bytes_sent;
bytes_sent = ram_save_block(f, false);
if (bytes_sent == 0) {
break;
}
total_sent += bytes_sent;
acct_info.iterations++;
check_guest_throttling();
if ((i & 63) == 0) {
uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) / 1000000;
if (t1 > MAX_WAIT) {
DPRINTF("big wait: %" PRIu64 " milliseconds, %d iterations\n",
t1, i);
break;
}
}
i++;
}
qemu_mutex_unlock_ramlist();
ram_control_after_iterate(f, RAM_CONTROL_ROUND);
if (ret < 0) {
bytes_transferred += total_sent;
return ret;
}
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
total_sent += 8;
bytes_transferred += total_sent;
return total_sent;
}
| 1threat |
Redirect to log in page if session does not exist in PHP : <p>So I have this page that can only be accessed if a user is logged in. If not, he will be redirected to the home page (if the user visits the page directly). What I want to do, is to redirect the user to the login page, and if it the login is successful, then will get redirected to the page.</p>
| 0debug |
static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
const char *devaddr,
const char *opts_str)
{
Error *local_err = NULL;
QemuOpts *opts;
PCIBus *root = pci_find_primary_bus();
PCIBus *bus;
int ret, devfn;
if (!root) {
monitor_printf(mon, "no primary PCI bus (if there are multiple"
" PCI roots, you must use device_add instead)");
return NULL;
}
bus = pci_get_bus_devfn(&devfn, root, devaddr);
if (!bus) {
monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
return NULL;
}
if (!qbus_is_hotpluggable(BUS(bus))) {
monitor_printf(mon, "PCI bus doesn't support hotplug\n");
return NULL;
}
opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
if (!opts) {
return NULL;
}
qemu_opt_set(opts, "type", "nic");
ret = net_client_init(opts, 0, &local_err);
if (local_err) {
qerror_report_err(local_err);
error_free(local_err);
return NULL;
}
if (nd_table[ret].devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
return NULL;
}
return pci_nic_init(&nd_table[ret], root, "rtl8139", devaddr);
}
| 1threat |
Regex to be made which should include international and cyrilic characters : The regex should fullfill the below conditions:
- Minimum of 3 characters (includes alphabets and numbers, not
including Special Characters
)
- It Must have at least 3 compulsory alpha-numeric characters excluding
special characters
- All alphabets cannot be the same in a standalone word. However, if
they are a part of the word, we will allow the same. For example -
AAA is not allowed but Haaadoop is allowed
- Consecutive alphabets less than or equal to 3 are allowed in a word.
Ex– Haaadoop is allowed but Haaaadoop is not allowed.
- Three or more consecutive Standalone alphabets are not allowed.
Example - AA is allowed. AAA is not allowed.
- All numbers can be the same. Example – 111 is allowed
- If more than 1 special character (In a word or Standalone) are
consecutively entered, it is invalid. Example A-B is allowed, A- -B
or A-&B is not allowed
- Allow special characters #&()_+[]:;',/.\\\-"*
- Consecutive dashes, apostrophes are not allowed in any part of the
string
- It should accept these international and cyrilic characters as well
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞߟàáâãäåæçАаБбВвГгДдЕеЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯяèéêëìíîïðñòóôõöøùúûüýþÿ
| 0debug |
How to create a list of random numbers? : <p>So I am trying to create a method in which random numbers between 1000 and -1000 are declared and stored in an arraylist. The issue is, I need to use a user inputted number to determine how many random numbers I need. Therefore, I assume I need some sort of loop which will create a random number(within the given boundaries) for the given amount of times the user desires. To make things clear, if the user inputted the number 10, than 10 random numbers would be created and stored in the arraylist.</p>
<p>For this example, the user inputted data is gathered from a jtextField called n2sInput.</p>
<p>If anyone could explain, or create a sample code of how to do this, I would greatly appreciate it!</p>
<p>Thanks</p>
| 0debug |
static void replication_close(BlockDriverState *bs)
{
BDRVReplicationState *s = bs->opaque;
if (s->replication_state == BLOCK_REPLICATION_RUNNING) {
replication_stop(s->rs, false, NULL);
if (s->mode == REPLICATION_MODE_SECONDARY) {
g_free(s->top_id);
replication_remove(s->rs);
| 1threat |
static int write_representation(AVFormatContext *s, AVStream *stream, int id,
int output_width, int output_height,
int output_sample_rate) {
AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0);
AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0);
AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0);
AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);
AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);
if (!irange || cues_start == NULL || cues_end == NULL || filename == NULL ||
!bandwidth) {
return -1;
}
avio_printf(s->pb, "<Representation id=\"%d\"", id);
avio_printf(s->pb, " bandwidth=\"%s\"", bandwidth->value);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_width)
avio_printf(s->pb, " width=\"%d\"", stream->codec->width);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_height)
avio_printf(s->pb, " height=\"%d\"", stream->codec->height);
if (stream->codec->codec_type = AVMEDIA_TYPE_AUDIO && output_sample_rate)
avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codec->sample_rate);
avio_printf(s->pb, ">\n");
avio_printf(s->pb, "<BaseURL>%s</BaseURL>\n", filename->value);
avio_printf(s->pb, "<SegmentBase\n");
avio_printf(s->pb, " indexRange=\"%s-%s\">\n", cues_start->value, cues_end->value);
avio_printf(s->pb, "<Initialization\n");
avio_printf(s->pb, " range=\"0-%s\" />\n", irange->value);
avio_printf(s->pb, "</SegmentBase>\n");
avio_printf(s->pb, "</Representation>\n");
return 0;
}
| 1threat |
Why is AppTheme.NoActionBar not working? : <p>I've created an Android app in Android Studio, and it has created these styles by default:</p>
<pre><code><style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</code></pre>
<p>However, in an activity, I try to set this as a theme:</p>
<pre><code><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
...
android:theme="@style/AppTheme.NoActionBar">
</code></pre>
<p>But when I run the app I'm getting the action bar:</p>
<p><a href="https://i.stack.imgur.com/dVFTn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dVFTn.png" alt="enter image description here"></a></p>
<p>Why am I getting an action bar? Am I doing something obviously wrong, or is Android Studio, Google's official IDE for it's own platform, trying to confuse/mislead its developers?</p>
<p>Here is my activity code, there's nothing in it that can cause the action bar to appear by itself:</p>
<pre><code>public class WelcomeActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.activity_welcome);
}
}
</code></pre>
| 0debug |
tslint - Missing trailing comma (trailing-comma) on the last line : <p>I cannot figure out why my <code>tslint</code> even want to see the trailing comma on the end of the last line in the <code>objects</code>? How can I set the <code>ignore</code> rule for the last line of the objects for example? Thanks.</p>
<p>Exemple:</p>
<pre><code> props = {
prop1: 21, // good
prop2: 2, // good
prop3: false // error: [tslint] Missing trailing comma (trailing-comma)
}
</code></pre>
<p>Rule for <code>trailing-comma</code> in my <code>tsconfig.json</code>:</p>
<pre><code>"trailing-comma": [true, {
"singleline": "never",
"multiline": {
"objects": "always",
"arrays": "always",
"functions": "never",
"typeLiterals": "ignore"
}
}]
</code></pre>
| 0debug |
static V9fsFidState *lookup_fid(V9fsState *s, int32_t fid)
{
V9fsFidState *f;
for (f = s->fid_list; f; f = f->next) {
if (f->fid == fid) {
v9fs_do_setuid(s, f->uid);
return f;
}
}
return NULL;
}
| 1threat |
Get substring from parenthesis JAVA : <p><strong>No full solutions please!</strong></p>
<blockquote>
<blockquote>
<p>Given a string that contains a single pair of parenthesis, compute recursively a new string made of only of the parenthesis and their
contents, so "xyz(abc)123" yields "(abc)".</p>
</blockquote>
<p>parenBit("xyz(abc)123") → "(abc)" </p>
<p>parenBit("x(hello)") → "(hello)"</p>
<p>parenBit("(xy)1") → "(xy)"</p>
</blockquote>
<p>My solution doesn't work</p>
<pre><code>public String parenBit(String str) {
char c;
int start = 0;
int end = 0;
for(int i=0; i < str.length(); i++){
c = str.charAt(i);
if(c == '('){
start = i;
} if(c == '('){
end = i;
return str.substring(start, end);
}
}
return "andrew";
}
</code></pre>
<p>It doesnt print out anything. Why?</p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
Is it possible to run Google Chrome in headless mode with extensions? : <p>I cannot use my currently installed extensions in Google Chrome using headless mode. Is there any way to enable them?</p>
<p>An easy way to check if the extensions work is by adding, for example, the "<a href="https://chrome.google.com/webstore/detail/comic-sans-everything/oaehjhfpohkdjkpcdbblepomnflojfli?utm_source=chrome-app-launcher-info-dialog" rel="noreferrer">Comic Sans Everything</a>" extension.</p>
<p>So Google looks like that:</p>
<p><a href="https://i.stack.imgur.com/osjWy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/osjWy.png" alt="Google looks beautiful"></a></p>
<p>However, if I take a screenshot of the page using the headless mode (<code>google-chrome --headless --disable-gpu --screenshot https://www.google.com</code>), the result is:</p>
<p><a href="https://i.stack.imgur.com/gDeHq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gDeHq.png" alt="Google in headless mode"></a></p>
| 0debug |
javascript 2 elements in different variables, how to combine them? : <p>I have to variables, containing 2 different elements. I want to combine them into a single jquery selector. At the moment I have something like this:</p>
<pre><code>function getActiveElem(){
return $('div').find('.active');
}
var elem1 = $('.elem1'),
elem2 = getActiveElem();
</code></pre>
<p>I can't do it like this:
<code>$('div .active, .elem1')</code> because the <code>getActiveElem</code> is a little more complex than the example.
What I would like to do is this: <code>$(elem1, elem2)</code> to get both elements, but that isn't working.</p>
<p>Ultimately I want to animate these 2 items at the same time. Right now it's like this:</p>
<pre><code>elem1.animate({});
elem2.animate({});
</code></pre>
<p>And I'd like it to be </p>
<pre><code>$(elem1, elem2).animate({});
</code></pre>
<p>Is this possible? Does it even make sense? I'm animating a custom slider but there's some weird whitespace between the slides, I thought it might be because of the 2 seperate slide events.</p>
| 0debug |
Hey Folks Need Some Assistance : I'm hoping someone could show me the right direction to go with this. I'm working on a javascript project for a restaurant website. What i'm supposed to do is, show different lunch/dinner/happy hour specials at different times throughout the day( dynamic). I'm thinking arrays with the specials. and something like a getDay() or getTime() method to show a certain special, but i'm not sure 100% about how to approach this. Any help would be greatly appreciated. Also, my code needs to be strictly javascript/html. no jquery or json or anything else. Thank you! | 0debug |
how to specify new environment location for conda create : <p>the default location for packages is .conda folder in my home directory. however, on the server I am using, there is a very strict limit of how much space I can use, which basically avoids me from putting anything under my home directory. how can I specify the location for the virtual environment that I want to create? Thanks! server is running Ubuntu. </p>
| 0debug |
If and else statements don't work if my number variable is over certain value : <p>When I input a value over 18.5 it state normal but anything under works. How do I set up the If and Else statements?</p>
<p>I am a student for a online course in C, and I have to do a program that calculates someone's BMI and display if they are "Normal", "Overweight", etc.</p>
<pre><code>//Clear the screen
system("clear");
//Declare variables
float weight, height, bmi;
int number_of_inputs = 2; //Interger constant or literal
//Get grades from user
printf("Please enter Weight in Pounds: ");
scanf("%f", &weight);
printf("Please enter your Height in inches: ");
scanf("%f", &height);
//Calculate the BMI
bmi = 703 * (weight / (height * height) );
//Display what is the health status of the user
if (bmi >= 18.5 <= 24)
{
printf("Your Health Status is Normal \n");
}
else if (bmi <= 18.5 >= 0)
{
printf("Your Health Status is Underweight \n");
}
else if (bmi >= 25 <= 29)
{
printf("Your Health Status is Overweight \n");
}
else if (bmi >= 30 <= 999)
{
printf("Your Health Status is Obese \n");
}
printf("BMI: %f \n", bmi);
return (0);
</code></pre>
<p>Any value over 18.5 won't print the correct If/Else statement but anything under will</p>
| 0debug |
static BlockAIOCB *blkverify_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockCompletionFunc *cb, void *opaque)
{
BDRVBlkverifyState *s = bs->opaque;
BlkverifyAIOCB *acb = blkverify_aio_get(bs, false, sector_num, qiov,
nb_sectors, cb, opaque);
acb->verify = blkverify_verify_readv;
acb->buf = qemu_blockalign(bs->file->bs, qiov->size);
qemu_iovec_init(&acb->raw_qiov, acb->qiov->niov);
qemu_iovec_clone(&acb->raw_qiov, qiov, acb->buf);
bdrv_aio_readv(s->test_file, sector_num, qiov, nb_sectors,
blkverify_aio_cb, acb);
bdrv_aio_readv(bs->file, sector_num, &acb->raw_qiov, nb_sectors,
blkverify_aio_cb, acb);
return &acb->common;
}
| 1threat |
void runstate_set(RunState new_state)
{
if (new_state >= RUN_STATE_MAX ||
!runstate_valid_transitions[current_run_state][new_state]) {
fprintf(stderr, "invalid runstate transition\n");
abort();
}
current_run_state = new_state;
}
| 1threat |
Xamarin.Forms - Button Pressed & Released Event : <p>I want to my event to trigger when button <strong>pressed and released</strong>, but I can only find <strong>Click</strong> event in Xamarin.Forms.</p>
<p>I believe there must be some work around to get this functionality. My basic need is to <em>start a process when button is pressed and stop when released</em>. It seems to be a very basic feature but Xamarin.Forms doesn't have it right now.</p>
<p>I tried TapGestureRecognizer on button, but button is firing only click event.</p>
<pre><code>MyButton.Clicked += (sender, args) =>
{
Log.V(TAG, "CLICKED");
};
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) => {
Log.V(TAG, "TAPPED");
};
MyButton.GestureRecognizers.Add(tapGestureRecognizer);
</code></pre>
<p>Keep in mind that I need those events to be working in Android and iOS togather.</p>
| 0debug |
const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){
const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
void *dst;
if(!o || o->offset<=0)
return NULL;
if(o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
return NULL;
dst= ((uint8_t*)obj) + o->offset;
if(o_out) *o_out= o;
if(o->type == FF_OPT_TYPE_STRING)
return dst;
switch(o->type){
case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
default: return NULL;
}
return buf;
}
| 1threat |
mix deps.get failed (seems missing ssl?) : <p>I'm sorry but I'm new to Elixir. while building phoenix application, <code>mix deps.get</code> failed with an error.</p>
<pre><code>% mix deps.get
Could not find Hex, which is needed to build dependency :phoenix
Shall I install Hex? [Yn] y
** (MatchError) no match of right hand side value: {:error, {:ssl, {'no such file or directory', 'ssl.app'}}}
(mix) lib/mix/utils.ex:409: Mix.Utils.read_httpc/1
(mix) lib/mix/utils.ex:354: Mix.Utils.read_path/2
(mix) lib/mix/local.ex:107: Mix.Local.read_path!/2
(mix) lib/mix/local.ex:86: Mix.Local.find_matching_versions_from_signed_csv!/2
(mix) lib/mix/tasks/local.hex.ex:23: Mix.Tasks.Local.Hex.run/1
(mix) lib/mix/dep/loader.ex:140: Mix.Dep.Loader.with_scm_and_app/4
(mix) lib/mix/dep/loader.ex:98: Mix.Dep.Loader.to_dep/3
(elixir) lib/enum.ex:1043: anonymous fn/3 in Enum.map/2
%
</code></pre>
<p>erlang and elixir has been installed via <a href="https://github.com/yrashk/kerl" rel="noreferrer">kerl</a> and <a href="https://github.com/HashNuke/asdf" rel="noreferrer">asdf</a>.
and my installation log is here <a href="http://otiai10.hatenablog.com/entry/2016/02/03/154953" rel="noreferrer">http://otiai10.hatenablog.com/entry/2016/02/03/154953</a></p>
<p>envirionment</p>
<ul>
<li>MacOS: 10.11.2</li>
<li>Erlang: 18.0</li>
<li>Elixir: 1.1.1</li>
</ul>
<p>What is happening and what should I do?</p>
| 0debug |
static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
{
int start = 0, w, w2, g;
const float lambda = s->lambda;
const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f;
const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f);
const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda;
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
start = 0;
for (g = 0; g < sce->ics.num_swb; g++) {
if (start*freq_mult > NOISE_LOW_LIMIT*(lambda/170.0f)) {
float energy = 0.0f, threshold = 0.0f, spread = 0.0f;
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
FFPsyBand *band = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
energy += band->energy;
threshold += band->threshold;
spread += band->spread;
}
if (spread > spread_threshold*sce->ics.group_len[w] &&
((sce->zeroes[w*16+g] && energy >= threshold) ||
energy < threshold*thr_mult*sce->ics.group_len[w])) {
sce->band_type[w*16+g] = NOISE_BT;
sce->pns_ener[w*16+g] = energy / sce->ics.group_len[w];
sce->zeroes[w*16+g] = 0;
}
}
start += sce->ics.swb_sizes[g];
}
}
}
| 1threat |
Why is my program directly crashing?(C) : typedef int score;
typedef struct tnode *ptrtonode;
typedef ptrtonode tree;
struct tnode{
score s;
tree next;
bool know;
};
scanf("%d",&n);
tree t[n];
for(i=0;i<n;i++){
scanf("%d",&x);
t[i]->s=x;
t[i]->next=NULL;
t[i]->know=false;
}
This is a code snippet.
When it runs 't[i]->s=x;', this program will crash.
I do not know why.
Thanks! | 0debug |
SyntaxError - expected an indented block : <p>when i run this i get "SyntaxError - expected an indented block" popup. I have no idea how to fix it and I need help.</p>
<pre><code>solved_places ={
"a1": False, "a2": False, "a3": False, "a4": False, "a5": False, "a6": False, "a7": False, "a8": False, "a9": False, "a10": False,
"b1": False, "b2": False, "b3": False, "b4": False, "b5": False, "b6": False, "b7": False, "b8": False, "b9": False, "b10": False,
"c1": False, "c2": False, "c3": False, "c4": False, "c5": False, "c6": False, "c7": False, "c8": False, "c9": False, "c10": False,
"d1": False, "d2": False, "d3": False, "d4": False, "d5": False, "d6": False, "d7": False, "d8": False, "d9": False, "d10": False,
"e1": False, "e2": False, "e3": False, "e4": False, "e5": False, "e6": False, "e7": False, "e8": False, "e9": False, "e10": False,
"f1": False, "f2": False, "f3": False, "f4": False, "f5": False, "f6": False, "f7": False, "f8": False, "f9": False, "f10": False,
"g1": False, "g2": False, "g3": False, "g4": False, "g5": False, "g6": False, "g7": False, "g8": False, "g9": False, "g10": False,
"h1": False, "h2": False, "h3": False, "h4": False, "h5": False, "h6": False, "h7": False, "h8": False, "h9": False, "h10": False,
"i1": False, "i2": False, "i3": False, "i4": False, "i5": False, "i6": False, "i7": False, "i8": False, "i9": False, "i10": False,
"j1": False, "j2": False, "j3": False, "j4": False, "j5": False, "j6": False, "j7": False, "j8": False, "j9": False, "j10": False,
}
</code></pre>
| 0debug |
lodash orderby with null and real values not ordering correctly : <p>I have an Angular 2 typescript application that is using lodash for various things.</p>
<p>I have an array of objects that I am ordering using a property in the object...</p>
<pre><code>_.orderBy(this.myArray, ['propertyName'], ['desc']);
</code></pre>
<p>This works well however my problem is that sometimes 'propertyName' can have a null value.
These are ordered as the first item in a descending list, the highest real values then follow.</p>
<p>I want to make these null values appear last in the descending ordering.</p>
<p>I understand why the nulls come first.</p>
<p>Does anyone know how to approach this?</p>
| 0debug |
Why Form freezes when using BackgroundWorker in C#? : I am new to C# and I am using windows forms
I have a problem with doing some work in BackgroundWorker.
I have 2 forms (`Form1` and `Form2`) and 3 `User Controls` `UC1`, `UC2` and `UC3`.
`Form1` has only one `button` which shows `Form2` which you click on it.
`Form2` has 4 `buttons` (`Btn_ShowUC1`, `Btn_ShowUC2`, `Btn_ShowUC3` and `Button_Close`) and 3 `BackgroundWorkers`.
What I am trying to do is: when I click on `button1` in `Form1`, `Form2` show up and then I want to show the relevant `User control` and hide the rest when I click on any button in `Form2`. For example: click on `Btn_ShowUC1` `user control1` shows up and hide the rest, click on `Btn_ShowUC2` `user control2` shows up and hide the rest and so on. Now showing and hiding the `user controls` in UI sometimes cuases `Form2` to freeze therefore I used BackgroundWorkers to Show/Hide `user control` process.
I am using 3 `BackgroundWorkers` for each relavant button in case one `BackgroundWorker` is busy to do the show/hide processs.
In Form1:
Form2 f2 = new Form2();
private void button1_Click(object sender, EventArgs e)
{
f2.ShowDialog();
}
In Form2:
UserControl CurrentUserControl;
UserControl1 uc1 = new UserControl1();
UserControl2 uc2 = new UserControl2();
UserControl3 uc3 = new UserControl3();
public Form2()
{
InitializeComponent();
Controls.Add(uc1);
Controls.Add(uc2);
Controls.Add(uc3);
}
private void Form2_Load(object sender, EventArgs e)
{
foreach (Control ctrl in this.Controls)
{
if (ctrl is UserControl)
{
ctrl.Visible = false;
}
}
uc1.Visible = true;
}
private void Btn_ShowUC1_Click(object sender, EventArgs e)
{
CurrentUserControl = uc1;
backgroundWorker1.RunWorkerAsync();
}
private void Btn_ShowUC2_Click(object sender, EventArgs e)
{
CurrentUserControl = uc2;
backgroundWorker2.RunWorkerAsync();
}
private void Btn_ShowUC3_Click(object sender, EventArgs e)
{
CurrentUserControl = uc3;
backgroundWorker3.RunWorkerAsync();
}
private void Button_Close_Click(object sender, EventArgs e)
{
close();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
foreach (Control ctrl in this.Controls)
{
if (ctrl is UserControl)
{
ctrl.Visible = false;
}
}
CurrentUserControl.Visible = true;
}
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
{
foreach (Control ctrl in this.Controls)
{
if (ctrl is UserControl)
{
ctrl.Visible = false;
}
}
CurrentUserControl.Visible = true;
}
private void backgroundWorker3_DoWork(object sender, DoWorkEventArgs e)
{
foreach (Control ctrl in this.Controls)
{
if (ctrl is UserControl)
{
ctrl.Visible = false;
}
}
CurrentUserControl.Visible = true;
}
When `Form2` loads `usercontrol1` shows up and when I click any any button the relevant user control shows up and every thing works well. However, When I close `form2` and open it again and click on any button none of the `user controls` show up and `Form2` freezes and it throws error saying "This backGroundWorker is currently busy and can not run multiple tasks concurrently"
Why I am having this error? I mean I am using 3 different `backGroundWorkers`.
Note this is all the code I have in the project.
Anyone knows how can I fix it? I mean I want to show/hide the user controls in separate thread when I click on any button without freezing the form.
I will be very happy to hear any different ideas.
Thank you | 0debug |
static int parse_fade(struct sbg_parser *p, struct sbg_fade *fr)
{
struct sbg_fade f;
if (lex_char(p, '<'))
f.in = SBG_FADE_SILENCE;
else if (lex_char(p, '-'))
f.in = SBG_FADE_SAME;
else if (lex_char(p, '='))
f.in = SBG_FADE_ADAPT;
else
return 0;
if (lex_char(p, '>'))
f.out = SBG_FADE_SILENCE;
else if (lex_char(p, '-'))
f.out = SBG_FADE_SAME;
else if (lex_char(p, '='))
f.out = SBG_FADE_ADAPT;
else
return AVERROR_INVALIDDATA;
*fr = f;
return 1;
}
| 1threat |
static const char *full_name(QObjectInputVisitor *qiv, const char *name)
{
StackObject *so;
char buf[32];
if (qiv->errname) {
g_string_truncate(qiv->errname, 0);
} else {
qiv->errname = g_string_new("");
}
QSLIST_FOREACH(so , &qiv->stack, node) {
if (qobject_type(so->obj) == QTYPE_QDICT) {
g_string_prepend(qiv->errname, name);
g_string_prepend_c(qiv->errname, '.');
} else {
snprintf(buf, sizeof(buf), "[%u]", so->index);
g_string_prepend(qiv->errname, buf);
}
name = so->name;
}
if (name) {
g_string_prepend(qiv->errname, name);
} else if (qiv->errname->str[0] == '.') {
g_string_erase(qiv->errname, 0, 1);
} else {
return "<anonymous>";
}
return qiv->errname->str;
}
| 1threat |
Inherit from const type passed as template parameter : <p>The following code is not valid:</p>
<pre><code>struct base {
};
struct inherit : const base {
};
</code></pre>
<p>You cannot inherit from a <code>const</code> type.</p>
<p>Does the situation change when templates are involved? In other words, is this code valid:</p>
<pre><code>struct base {
};
template<typename T>
struct inherit : T {
using T::T;
};
int main() {
inherit<base const>{};
}
</code></pre>
<p>gcc is says it is fine, but clang reports </p>
<pre><code><source>:6:2: error: 'const base' is not a direct base of 'inherit<const base>', cannot inherit constructors
using T::T;
^ ~
<source>:10:2: note: in instantiation of template class 'inherit<const base>' requested here
inherit<base const>{};
^
1 error generated.
Compiler returned: 1
</code></pre>
<p>To make clang happy, I need to do something like this:</p>
<pre><code>template<typename T>
struct inherit : T {
using U = std::remove_const_t<T>;
using U::U;
};
</code></pre>
<p>Which version is correct? Or are neither of them correct and I need to inherit from <code>std::remove_const_t<T></code>?</p>
| 0debug |
How do I implement a scrollable drawer with flutter, It shows a bottom overflow when I rotate : Bottom overflow in drawer when I rotate the screen**strong text** | 0debug |
TFS alternative : <p>What is alternative to TFS-server with good integration to Visual Studio and uploading test results from Nunit to that system? I need tracking unit test result, reporting unit track result, but TFS-server is expensive. Maybe exist OpenSource software for this goals?</p>
| 0debug |
creation of a structure of cells : I have a set of data as can be seen from the attached snapshot. As can be observed, it is a set of repetitive data. I am trying to write a code such that the code would create a main structure "RoadXML" with all the subsequent text in the cell as structure elements.
For eg: " RoadXML.Network.SubNetworks.SubNetwork.RoadNetwork.Grounds.Ground" should produce a structure RoadXML which has a struct element "Networks" which inturn is a structure. Likewise " Networks" should have " Subnetworks" as an element which is a structure and so on... Furthurmore, the rest of the data should append itself to the main structure under its respective fields. Hence in the end only one structure would remain with all the data in the excel sheet as its structure elements.
Now the problem is that, when repetitive sets of elements are present in the excel sheet as can be seen from the screenshot, only the last set of data remains thus overwriting the data that has been already stored. That is to say (with reference to the attached screenshot) data from rows 30 to 34 over writes all the data from rows 15 to 29 that has been alreaady stored.
Requesting assistance for getting over this issue that i have.
Thanks in advance,
Sachin [image][1]
[1]: https://i.stack.imgur.com/JNjW5.jpg | 0debug |
static void test_commands(void)
{
char *response;
int i;
for (i = 0; hmp_cmds[i] != NULL; i++) {
if (verbose) {
fprintf(stderr, "\t%s\n", hmp_cmds[i]);
}
response = hmp(hmp_cmds[i]);
g_free(response);
}
}
| 1threat |
How to Use LoginGdi+ theme : <p>Guys would you please tell me how to use this theme in my project ?
I like this theme & I want to know how to use it<br>
the theme link <a href="http://xertzproductions.weebly.com/login-gdi-theme.html" rel="nofollow">http://xertzproductions.weebly.com/login-gdi-theme.html</a>
I tried but I failed !
thanks in advance</p>
| 0debug |
unity + php + database data output issue : guys~! [enter image description here][1]
In the picture, the log is print pretty!
but, in unity the output is wrong.
How can I solve it?
[1]: http://i.stack.imgur.com/WuPhx.png
and this is my source
private void Awake()
{
info = new Dictionary<string, string>();
}
private IEnumerator Start()
{
WWW dash = new WWW("http://localhost/test.php");
yield return dash;
string[] Separators = new string[] { "\n" };
string[] lines = dash.text.Split(Separators, System.StringSplitOptions.RemoveEmptyEntries);
info.Clear();
for(int i=0; i<lines.Length; i++)
{
GameObject tmp = Instantiate(scorepre);
string[] parts = lines[i].Split(',');
string Name = parts[1];
string Detail = parts[2];
info.Add(Name, Detail);
Debug.Log(Name + " - " + Detail);
named.GetComponent<Text>().text = Name;
detailed.GetComponent<Text>().text = Detail;
tmp.transform.SetParent(infoParent);
} | 0debug |
int main (int argc, char **argv)
{
int ret = 0, got_frame;
if (argc != 4 && argc != 5) {
fprintf(stderr, "usage: %s [-refcount=<old|new_norefcount|new_refcount>] "
"input_file video_output_file audio_output_file\n"
"API example program to show how to read frames from an input file.\n"
"This program reads frames from a file, decodes them, and writes decoded\n"
"video frames to a rawvideo file named video_output_file, and decoded\n"
"audio frames to a rawaudio file named audio_output_file.\n\n"
"If the -refcount option is specified, the program use the\n"
"reference counting frame system which allows keeping a copy of\n"
"the data for longer than one decode call. If unset, it's using\n"
"the classic old method.\n"
"\n", argv[0]);
exit(1);
}
if (argc == 5) {
const char *mode = argv[1] + strlen("-refcount=");
if (!strcmp(mode, "old")) api_mode = API_MODE_OLD;
else if (!strcmp(mode, "new_norefcount")) api_mode = API_MODE_NEW_API_NO_REF_COUNT;
else if (!strcmp(mode, "new_refcount")) api_mode = API_MODE_NEW_API_REF_COUNT;
else {
fprintf(stderr, "unknow mode '%s'\n", mode);
exit(1);
}
argv++;
}
src_filename = argv[1];
video_dst_filename = argv[2];
audio_dst_filename = argv[3];
av_register_all();
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
fprintf(stderr, "Could not open source file %s\n", src_filename);
exit(1);
}
if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
fprintf(stderr, "Could not find stream information\n");
exit(1);
}
if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
video_stream = fmt_ctx->streams[video_stream_idx];
video_dec_ctx = video_stream->codec;
video_dst_file = fopen(video_dst_filename, "wb");
if (!video_dst_file) {
fprintf(stderr, "Could not open destination file %s\n", video_dst_filename);
ret = 1;
goto end;
}
ret = av_image_alloc(video_dst_data, video_dst_linesize,
video_dec_ctx->width, video_dec_ctx->height,
video_dec_ctx->pix_fmt, 1);
if (ret < 0) {
fprintf(stderr, "Could not allocate raw video buffer\n");
goto end;
}
video_dst_bufsize = ret;
}
if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
audio_stream = fmt_ctx->streams[audio_stream_idx];
audio_dec_ctx = audio_stream->codec;
audio_dst_file = fopen(audio_dst_filename, "wb");
if (!audio_dst_file) {
fprintf(stderr, "Could not open destination file %s\n", video_dst_filename);
ret = 1;
goto end;
}
}
av_dump_format(fmt_ctx, 0, src_filename, 0);
if (!audio_stream && !video_stream) {
fprintf(stderr, "Could not find audio or video stream in the input, aborting\n");
ret = 1;
goto end;
}
if (api_mode == API_MODE_OLD)
frame = avcodec_alloc_frame();
else
frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate frame\n");
ret = AVERROR(ENOMEM);
goto end;
}
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (video_stream)
printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename);
if (audio_stream)
printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
AVPacket orig_pkt = pkt;
do {
ret = decode_packet(&got_frame, 0);
if (ret < 0)
break;
pkt.data += ret;
pkt.size -= ret;
} while (pkt.size > 0);
av_free_packet(&orig_pkt);
}
pkt.data = NULL;
pkt.size = 0;
do {
decode_packet(&got_frame, 1);
} while (got_frame);
printf("Demuxing succeeded.\n");
if (video_stream) {
printf("Play the output video file with the command:\n"
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
av_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height,
video_dst_filename);
}
if (audio_stream) {
enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
int n_channels = audio_dec_ctx->channels;
const char *fmt;
if (av_sample_fmt_is_planar(sfmt)) {
const char *packed = av_get_sample_fmt_name(sfmt);
printf("Warning: the sample format the decoder produced is planar "
"(%s). This example will output the first channel only.\n",
packed ? packed : "?");
sfmt = av_get_packed_sample_fmt(sfmt);
n_channels = 1;
}
if ((ret = get_format_from_sample_fmt(&fmt, sfmt)) < 0)
goto end;
printf("Play the output audio file with the command:\n"
"ffplay -f %s -ac %d -ar %d %s\n",
fmt, n_channels, audio_dec_ctx->sample_rate,
audio_dst_filename);
}
end:
if (video_dec_ctx)
avcodec_close(video_dec_ctx);
if (audio_dec_ctx)
avcodec_close(audio_dec_ctx);
avformat_close_input(&fmt_ctx);
if (video_dst_file)
fclose(video_dst_file);
if (audio_dst_file)
fclose(audio_dst_file);
if (api_mode == API_MODE_OLD)
avcodec_free_frame(&frame);
else
av_frame_free(&frame);
av_free(video_dst_data[0]);
return ret < 0;
}
| 1threat |
$_POST variable in chmod permissions : <p>I wonder how to enter a $_POST variable to chmod permission :</p>
<p>I tried this way:</p>
<pre><code><?php
$file = 'myfile.txt';
$permission = $_POST['permission'];
chmod($file, $permission);
?>
</code></pre>
<p>Unfortunately $permission variable, does not work in chmod.</p>
<pre><code> $_POST['permission'] is '0755'
</code></pre>
<p>Is there any way to convert a variable to the correct format?</p>
| 0debug |
Convert Uint8Array into hex string equivalent in node.js : <p>I am using node.js v4.5. Suppose I have this Uint8Array variable.</p>
<pre><code>var uint8 = new Uint8Array(4);
uint8[0] = 0x1f;
uint8[1] = 0x2f;
uint8[2] = 0x3f;
uint8[3] = 0x4f;
</code></pre>
<p>This array can be of any length but let's assume the length is 4. </p>
<p>I would like to have a function that that converts <code>uint8</code> into the hex string equivalent. </p>
<pre><code>var hex_string = convertUint8_to_hexStr(uint8);
//hex_string becomes "1f2f3f4f"
</code></pre>
| 0debug |
ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
{
NE2000State *s = qemu_get_nic_opaque(nc);
int size = size_;
uint8_t *p;
unsigned int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received len=%d\n", size);
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
return -1;
if (s->rxcr & 0x10) {
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
if (!(s->rxcr & 0x04))
return size;
} else if (buf[0] & 0x01) {
if (!(s->rxcr & 0x08))
return size;
mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
return size;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
s->mem[6] == buf[3] &&
s->mem[8] == buf[4] &&
s->mem[10] == buf[5]) {
} else {
return size;
}
}
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
index = s->curpag << 8;
if (index >= NE2000_PMEM_END) {
index = s->start;
}
total_len = size + 4;
next = index + ((total_len + 4 + 255) & ~0xff);
if (next >= s->stop)
next -= (s->stop - s->start);
p = s->mem + index;
s->rsr = ENRSR_RXOK;
if (buf[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = next >> 8;
p[2] = total_len;
p[3] = total_len >> 8;
index += 4;
while (size > 0) {
if (index <= s->stop)
avail = s->stop - index;
else
avail = 0;
len = size;
if (len > avail)
len = avail;
memcpy(s->mem + index, buf, len);
buf += len;
index += len;
if (index == s->stop)
index = s->start;
size -= len;
}
s->curpag = next >> 8;
s->isr |= ENISR_RX;
ne2000_update_irq(s);
return size_;
}
| 1threat |
How do you find duplicate strings in a list? : <p>I have a list with several stings, with some being duplicates. I need to pull out all the duplicate strings and append them into a new list. How can I do that?</p>
<pre><code>list_i = ['a','b','a','c','a','c','g','w','s','c','d','a','b','c','a','e']
</code></pre>
| 0debug |
static int block_load(QEMUFile *f, void *opaque, int version_id)
{
static int banner_printed;
int len, flags;
char device_name[256];
int64_t addr;
BlockDriverState *bs;
uint8_t *buf;
do {
addr = qemu_get_be64(f);
flags = addr & ~BDRV_SECTOR_MASK;
addr >>= BDRV_SECTOR_BITS;
if (flags & BLK_MIG_FLAG_DEVICE_BLOCK) {
int ret;
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)device_name, len);
device_name[len] = '\0';
bs = bdrv_find(device_name);
if (!bs) {
fprintf(stderr, "Error unknown block device %s\n",
device_name);
return -EINVAL;
}
buf = qemu_malloc(BLOCK_SIZE);
qemu_get_buffer(f, buf, BLOCK_SIZE);
ret = bdrv_write(bs, addr, buf, BDRV_SECTORS_PER_DIRTY_CHUNK);
qemu_free(buf);
if (ret < 0) {
return ret;
}
} else if (flags & BLK_MIG_FLAG_PROGRESS) {
if (!banner_printed) {
printf("Receiving block device images\n");
banner_printed = 1;
}
printf("Completed %d %%%c", (int)addr,
(addr == 100) ? '\n' : '\r');
fflush(stdout);
} else if (!(flags & BLK_MIG_FLAG_EOS)) {
fprintf(stderr, "Unknown flags\n");
return -EINVAL;
}
if (qemu_file_has_error(f)) {
return -EIO;
}
} while (!(flags & BLK_MIG_FLAG_EOS));
return 0;
}
| 1threat |
static void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
int lastInLumBuf, int lastInChrBuf)
{
const int dstH= c->dstH;
const int flags= c->flags;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrUPixBuf= c->chrUPixBuf;
int16_t **chrVPixBuf= c->chrVPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
int16_t *vLumFilterPos= c->vLumFilterPos;
int16_t *vChrFilterPos= c->vChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int chrDstY= dstY>>c->chrDstVSubSample;
const int firstLumSrcY= vLumFilterPos[dstY];
const int firstChrSrcY= vChrFilterPos[chrDstY];
c->blueDither= ff_dither8[dstY&1];
if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
c->greenDither= ff_dither8[dstY&1];
else
c->greenDither= ff_dither4[dstY&1];
c->redDither= ff_dither8[(dstY+1)&1];
if (dstY < dstH - 2) {
const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
int i;
if (flags & SWS_ACCURATE_RND) {
int s= APCK_SIZE / 8;
for (i=0; i<vLumFilterSize; i+=2) {
*(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
*(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
lumMmxFilter[s*i+APCK_COEF/4 ]=
lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
*(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
*(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
alpMmxFilter[s*i+APCK_COEF/4 ]=
alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
}
}
for (i=0; i<vChrFilterSize; i+=2) {
*(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
*(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
chrMmxFilter[s*i+APCK_COEF/4 ]=
chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
}
} else {
for (i=0; i<vLumFilterSize; i++) {
*(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
lumMmxFilter[4*i+2]=
lumMmxFilter[4*i+3]=
((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
*(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
alpMmxFilter[4*i+2]=
alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
}
}
for (i=0; i<vChrFilterSize; i++) {
*(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
chrMmxFilter[4*i+2]=
chrMmxFilter[4*i+3]=
((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
}
}
}
}
| 1threat |
static void scoop_writeb(void *opaque, target_phys_addr_t addr, uint32_t value)
{
ScoopInfo *s = (ScoopInfo *) opaque;
value &= 0xffff;
switch (addr) {
case SCOOP_MCR:
s->mcr = value;
break;
case SCOOP_CDR:
s->cdr = value;
break;
case SCOOP_CPR:
s->power = value;
if (value & 0x80)
s->power |= 0x8040;
break;
case SCOOP_CCR:
s->ccr = value;
break;
case SCOOP_IRR_IRM:
s->irr = value;
break;
case SCOOP_IMR:
s->imr = value;
break;
case SCOOP_ISR:
s->isr = value;
break;
case SCOOP_GPCR:
s->gpio_dir = value;
scoop_gpio_handler_update(s);
break;
case SCOOP_GPWR:
case SCOOP_GPRR:
s->gpio_level = value & s->gpio_dir;
scoop_gpio_handler_update(s);
break;
default:
zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr);
}
}
| 1threat |
void fd_start_incoming_migration(const char *infd, Error **errp)
{
int fd;
QEMUFile *f;
DPRINTF("Attempting to start an incoming migration via fd\n");
fd = strtol(infd, NULL, 0);
f = qemu_fdopen(fd, "rb");
if(f == NULL) {
error_setg_errno(errp, errno, "failed to open the source descriptor");
return;
}
qemu_set_fd_handler2(fd, NULL, fd_accept_incoming_migration, NULL, f);
}
| 1threat |
Why does VBA exist? : I have this function (which I based off a function [here][1]):
Function Foo(ByVal r As range) As String
MsgBox "WHAT. The function worked? Wow!"
End Function
I have tried calling it like so:
Let max_row = cells.CurrentRegion.Columns.Count
Set r = range(cells(2, ID_COL), cells(max_row, ID_COL))
Foo r
And I Always Get the Error: "run-time error 13, type mismatch" once the code hits the call to Foo.
Additionally, putting parentheses around the "r"
Foo(r)
Auto corrects to:
Foo (r)
Which gives the error: "Object Expected"
I assume this means that parentheses deference a pointer to its value, and are not meant for function calls, because VBA was not designed to be a good or even adequate language.
I have also tried writing the function as:
Function Foo(r As range) As String
MsgBox "WHAT. The function worked? Wow!"
End Function
But with no success.
Any ideas?
[1]: http://stackoverflow.com/questions/15888353/concatenate-multiple-ranges-using-vba | 0debug |
What is: A curly brace enclosure with a first variable name then a colon which separates the same variable name again? {name:name} : <p>This possibly relates to Javascript, TypeScript, or Angular 2. I'm not sure?</p>
<p>Here is an example:</p>
<pre><code>onSearch( term:string)
{
this.router.navigate([' search', {term: term}]);
}
</code></pre>
<p>I don't understand what the '{term: term}' is doing?</p>
| 0debug |
How to specify ranges to java.util.Random? : <p>I don't know why Java's designers didn't design java.util.Random objects to return random numbers like this: </p>
<p><code>rand.nextInt(minValue, maxValue);</code></p>
<p>I don't understand how to pass min and max values to this function. I've seen this recommended:</p>
<p><code>random.nextInt(max + 1 - (min)) + min</code></p>
<p>but what does that mean? Does that mean: </p>
<p><code>random.nextInt(FULL_RANGE + 1) + START_OF_RANGE</code></p>
<p>For example, if I wanted to generate values between -1 and 1, inclusive, is this how I do it:</p>
<p><code>int oneOfThreeChoices = rand.nextInt(1 + 1 + 1) - 1;</code></p>
| 0debug |
void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
{
POWERPC_TBL_DECLARE(altivec_put_pixels16_xy2_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int j;
POWERPC_TBL_START_COUNT(altivec_put_pixels16_xy2_num, 1);
for (j = 0; j < 4; j++) {
int i;
const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
const uint32_t b =
(((const struct unaligned_32 *) (pixels + 1))->l);
uint32_t l0 =
(a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
uint32_t h0 =
((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
uint32_t l1, h1;
pixels += line_size;
for (i = 0; i < h; i += 2) {
uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l);
l1 = (a & 0x03030303UL) + (b & 0x03030303UL);
h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
*((uint32_t *) block) =
h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
pixels += line_size;
block += line_size;
a = (((const struct unaligned_32 *) (pixels))->l);
b = (((const struct unaligned_32 *) (pixels + 1))->l);
l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
*((uint32_t *) block) =
h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
pixels += line_size;
block += line_size;
} pixels += 4 - line_size * (h + 1);
block += 4 - line_size * h;
}
POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
#else
register int i;
register vector unsigned char
pixelsv1, pixelsv2, pixelsv3, pixelsv4;
register vector unsigned char
blockv, temp1, temp2;
register vector unsigned short
pixelssum1, pixelssum2, temp3,
pixelssum3, pixelssum4, temp4;
register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
POWERPC_TBL_START_COUNT(altivec_put_pixels16_xy2_num, 1);
temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels);
pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F)
{
pixelsv2 = temp2;
}
else
{
pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels));
}
pixelsv3 = vec_mergel(vczero, pixelsv1);
pixelsv4 = vec_mergel(vczero, pixelsv2);
pixelsv1 = vec_mergeh(vczero, pixelsv1);
pixelsv2 = vec_mergeh(vczero, pixelsv2);
pixelssum3 = vec_add((vector unsigned short)pixelsv3,
(vector unsigned short)pixelsv4);
pixelssum3 = vec_add(pixelssum3, vctwo);
pixelssum1 = vec_add((vector unsigned short)pixelsv1,
(vector unsigned short)pixelsv2);
pixelssum1 = vec_add(pixelssum1, vctwo);
for (i = 0; i < h ; i++) {
blockv = vec_ld(0, block);
temp1 = vec_ld(line_size, pixels);
temp2 = vec_ld(line_size + 16, pixels);
pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels));
if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F)
{
pixelsv2 = temp2;
}
else
{
pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels));
}
pixelsv3 = vec_mergel(vczero, pixelsv1);
pixelsv4 = vec_mergel(vczero, pixelsv2);
pixelsv1 = vec_mergeh(vczero, pixelsv1);
pixelsv2 = vec_mergeh(vczero, pixelsv2);
pixelssum4 = vec_add((vector unsigned short)pixelsv3,
(vector unsigned short)pixelsv4);
pixelssum2 = vec_add((vector unsigned short)pixelsv1,
(vector unsigned short)pixelsv2);
temp4 = vec_add(pixelssum3, pixelssum4);
temp4 = vec_sra(temp4, vctwo);
temp3 = vec_add(pixelssum1, pixelssum2);
temp3 = vec_sra(temp3, vctwo);
pixelssum3 = vec_add(pixelssum4, vctwo);
pixelssum1 = vec_add(pixelssum2, vctwo);
blockv = vec_packsu(temp3, temp4);
vec_st(blockv, 0, block);
block += line_size;
pixels += line_size;
}
POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
#endif
}
| 1threat |
Number generated randomly ? and problem here with the 2nd if statement? : <p>it is show that error in the 2nd If statement why???</p>
<pre><code>import java.security.SecureRandom;
public class Test
{
public static void main(String[] args)
{
System.out.println("T : " + Tfun());
}
public static String Tfun()
{
SecureRandom r = new SecureRandom();
int T = 1+r.nextInt(10);
if(T >= 1 && T <= 5)
Integer.toString(T);
return "Fast_Plod";
if(T >= 6 && T <= 7)
Integer.toString(T);
return "Slow_Plod";
}
}
</code></pre>
<p>how to fix that? what is the problem exactly?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.