problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void gen_mfsr(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
t0 = tcg_const_tl(SR(ctx->opcode));
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
tcg_temp_free(t0);
#endif
}
| 1threat
|
What is the "Uncategorized" Android Notification Channel and when does it appear? : <p>While transitioning an application to Android O, I have noticed a strange thing. Sometimes my foreground service notification goes into a channel that I have not made, called "Uncategorized". I have no idea how or when this happens. </p>
<p>The channels are always created before the notifications start being posted, and the ID of the channel is correct. I have tried putting in a random String as the channel ID to see if I could reproduce the issue, but the notification just doesn't get posted in that case. So it seems to be some weird case when the channel was already created before.</p>
<p>This is the channel's page:</p>
<p><a href="https://i.stack.imgur.com/9fRT2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9fRT2.png" alt="Uncategorized channel page"></a></p>
<p>And this is the channel appearing in the list of all channels of the app (note, I have removed the icon for privacy reasons).</p>
<p><a href="https://i.stack.imgur.com/Lp8iA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Lp8iA.png" alt="The channel presented in the list of all channels"></a></p>
<p>Does anyone have any experience with this and could they explain when this can happen? Unfortunately, I found no documentation regarding this, and heard nothing about it in the Google I/O talks.</p>
| 0debug
|
How to create Qr code with multiple variable on a single qr code in android : My application project have qr code generator feature. I use the Zxing library to coding qr code generator, but it can generate qr code only single variable. i want to create qr code with 3 variable on a single qr code. please help me to create this.
p.s. I'm a rookie for Android.
| 0debug
|
how many bytes is this struct? - how many bytes is pointer to a struct? : <pre><code>struct hello {
size_t num;
struct jump *next;
}
</code></pre>
<p>I get that size_t is 4bytes but how many bytes is struct jump *next?</p>
| 0debug
|
static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int size;
int ret;
MPJPEGDemuxContext *mpjpeg = s->priv_data;
if (mpjpeg->boundary == NULL) {
mpjpeg->boundary = av_strdup("--");
mpjpeg->searchstr = av_strdup("\r\n--");
if (!mpjpeg->boundary || !mpjpeg->searchstr) {
av_freep(&mpjpeg->boundary);
av_freep(&mpjpeg->searchstr);
return AVERROR(ENOMEM);
}
mpjpeg->searchstr_len = strlen(mpjpeg->searchstr);
}
ret = parse_multipart_header(s->pb, &size, mpjpeg->boundary, s);
if (ret < 0)
return ret;
if (size > 0) {
ret = av_get_packet(s->pb, pkt, size);
} else {
int remaining = 0, len;
const int read_chunk = 2048;
av_init_packet(pkt);
pkt->data = NULL;
pkt->size = 0;
pkt->pos = avio_tell(s->pb);
ffio_ensure_seekback(s->pb, read_chunk);
while ((ret = av_append_packet(s->pb, pkt, read_chunk - remaining)) >= 0) {
len = ret + remaining;
char *start = pkt->data + pkt->size - len;
do {
if (!memcmp(start, mpjpeg->searchstr, mpjpeg->searchstr_len)) {
avio_seek(s->pb, -(len-2), SEEK_CUR);
pkt->size -= (len-2);
return pkt->size;
}
len--;
start++;
} while (len >= mpjpeg->searchstr_len);
remaining = len;
}
if (ret == AVERROR_EOF) {
ret = pkt->size > 0 ? pkt->size : AVERROR_EOF;
} else {
av_packet_unref(pkt);
}
}
return ret;
}
| 1threat
|
Auth0: Create user in local database after Auth0 sign up : <p>I am using Auth0 to host all my user data. I also have my own backend, and I wish to have a <code>Users</code> table in it, which will map my db's generated <code>userId</code> to Auth0's <code>user_id</code>. I am hesitating between two flows on sign-up:</p>
<h1>Sign-up flow 1:</h1>
<ol>
<li>Frontend shows the Lock, user signs up.</li>
<li>After Auth0 redirects back to the frontend, frontend has the Auth0 <code>user_id</code>.</li>
<li>Frontend makes a call to backend on <code>POST /users</code> (public endpoint) to create a new user with <code>user_id</code>.</li>
<li>On each authenticated request to my backend resources server, the JWT contains the auth0 <code>user_id</code>, so the db makes a lookup between the <code>user_id</code> and my <code>userId</code>.</li>
</ol>
<h1>Sign-up flow 2:</h1>
<ol>
<li>Frontend shows the Lock, user signs up.</li>
<li>Configure a post-registration hook on Auth0 which calls <code>POST /users</code> on my backend. This call will generate my db's <code>userId</code> and send it back to Auth0.</li>
<li>Put this <code>userId</code> into Auth0's <code>user_metadata</code>.</li>
<li>This <code>user_metadata</code> will be included in the JWT, so that all calls to my backend to fetch resources will include the db's <code>userId</code> (no need for additional lookup).</li>
</ol>
<p>I feel 2 is more solid. Are there other sign-up flows? Do some auth0 customers use a similar flow to my #2? I didn't find much in their documentation.</p>
| 0debug
|
static void IRQ_local_pipe(OpenPICState *opp, int n_CPU, int n_IRQ)
{
IRQ_dst_t *dst;
IRQ_src_t *src;
int priority;
dst = &opp->dst[n_CPU];
src = &opp->src[n_IRQ];
priority = IPVP_PRIORITY(src->ipvp);
if (priority <= dst->pctp) {
DPRINTF("%s: IRQ %d has too low priority on CPU %d\n",
__func__, n_IRQ, n_CPU);
return;
}
if (IRQ_testbit(&dst->raised, n_IRQ)) {
DPRINTF("%s: IRQ %d was missed on CPU %d\n",
__func__, n_IRQ, n_CPU);
return;
}
src->ipvp |= IPVP_ACTIVITY_MASK;
IRQ_setbit(&dst->raised, n_IRQ);
if (priority < dst->raised.priority) {
DPRINTF("%s: IRQ %d is hidden by raised IRQ %d on CPU %d\n",
__func__, n_IRQ, dst->raised.next, n_CPU);
return;
}
IRQ_get_next(opp, &dst->raised);
if (IRQ_get_next(opp, &dst->servicing) != -1 &&
priority <= dst->servicing.priority) {
DPRINTF("%s: IRQ %d is hidden by servicing IRQ %d on CPU %d\n",
__func__, n_IRQ, dst->servicing.next, n_CPU);
return;
}
DPRINTF("Raise OpenPIC INT output cpu %d irq %d\n", n_CPU, n_IRQ);
openpic_irq_raise(opp, n_CPU, src);
}
| 1threat
|
static void tmu2_start(MilkymistTMU2State *s)
{
int pbuffer_attrib[6] = {
GLX_PBUFFER_WIDTH,
0,
GLX_PBUFFER_HEIGHT,
0,
GLX_PRESERVED_CONTENTS,
True
};
GLXPbuffer pbuffer;
GLuint texture;
void *fb;
hwaddr fb_len;
void *mesh;
hwaddr mesh_len;
float m;
trace_milkymist_tmu2_start();
pbuffer_attrib[1] = s->regs[R_DSTHRES];
pbuffer_attrib[3] = s->regs[R_DSTVRES];
pbuffer = glXCreatePbuffer(s->dpy, s->glx_fb_config, pbuffer_attrib);
glXMakeContextCurrent(s->dpy, pbuffer, pbuffer, s->glx_context);
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
glPixelStorei(GL_PACK_SWAP_BYTES, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
glPixelStorei(GL_PACK_ALIGNMENT, 2);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
fb_len = 2ULL * s->regs[R_TEXHRES] * s->regs[R_TEXVRES];
fb = cpu_physical_memory_map(s->regs[R_TEXFBUF], &fb_len, 0);
if (fb == NULL) {
glDeleteTextures(1, &texture);
glXMakeContextCurrent(s->dpy, None, None, NULL);
glXDestroyPbuffer(s->dpy, pbuffer);
return;
}
glTexImage2D(GL_TEXTURE_2D, 0, 3, s->regs[R_TEXHRES], s->regs[R_TEXVRES],
0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, fb);
cpu_physical_memory_unmap(fb, fb_len, 0, fb_len);
if ((s->regs[R_TEXHMASK] & 0x3f) > 0x20) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
if ((s->regs[R_TEXHMASK] >> 6) & s->regs[R_TEXHRES]) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
}
if ((s->regs[R_TEXVMASK] >> 6) & s->regs[R_TEXVRES]) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
m = (float)(s->regs[R_BRIGHTNESS] + 1) / 64.0f;
glColor4f(m, m, m, (float)(s->regs[R_ALPHA] + 1) / 64.0f);
fb_len = 2ULL * s->regs[R_DSTHRES] * s->regs[R_DSTVRES];
fb = cpu_physical_memory_map(s->regs[R_DSTFBUF], &fb_len, 0);
if (fb == NULL) {
glDeleteTextures(1, &texture);
glXMakeContextCurrent(s->dpy, None, None, NULL);
glXDestroyPbuffer(s->dpy, pbuffer);
return;
}
glDrawPixels(s->regs[R_DSTHRES], s->regs[R_DSTVRES], GL_RGB,
GL_UNSIGNED_SHORT_5_6_5, fb);
cpu_physical_memory_unmap(fb, fb_len, 0, fb_len);
glViewport(0, 0, s->regs[R_DSTHRES], s->regs[R_DSTVRES]);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, s->regs[R_DSTHRES], 0.0, s->regs[R_DSTVRES], -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
mesh_len = MESH_MAXSIZE*MESH_MAXSIZE*sizeof(struct vertex);
mesh = cpu_physical_memory_map(s->regs[R_VERTICESADDR], &mesh_len, 0);
if (mesh == NULL) {
glDeleteTextures(1, &texture);
glXMakeContextCurrent(s->dpy, None, None, NULL);
glXDestroyPbuffer(s->dpy, pbuffer);
return;
}
tmu2_gl_map((struct vertex *)mesh,
s->regs[R_TEXHRES], s->regs[R_TEXVRES],
s->regs[R_HMESHLAST], s->regs[R_VMESHLAST],
s->regs[R_DSTHOFFSET], s->regs[R_DSTVOFFSET],
s->regs[R_DSTSQUAREW], s->regs[R_DSTSQUAREH]);
cpu_physical_memory_unmap(mesh, mesh_len, 0, mesh_len);
fb_len = 2 * s->regs[R_DSTHRES] * s->regs[R_DSTVRES];
fb = cpu_physical_memory_map(s->regs[R_DSTFBUF], &fb_len, 1);
if (fb == NULL) {
glDeleteTextures(1, &texture);
glXMakeContextCurrent(s->dpy, None, None, NULL);
glXDestroyPbuffer(s->dpy, pbuffer);
return;
}
glReadPixels(0, 0, s->regs[R_DSTHRES], s->regs[R_DSTVRES], GL_RGB,
GL_UNSIGNED_SHORT_5_6_5, fb);
cpu_physical_memory_unmap(fb, fb_len, 1, fb_len);
glDeleteTextures(1, &texture);
glXMakeContextCurrent(s->dpy, None, None, NULL);
glXDestroyPbuffer(s->dpy, pbuffer);
s->regs[R_CTL] &= ~CTL_START_BUSY;
trace_milkymist_tmu2_pulse_irq();
qemu_irq_pulse(s->irq);
}
| 1threat
|
Git text invisible : <p>I have problems with using my GIT. Everything works fine when running the CMD and the '$' shows up and my text shows up. But when i go to my git log my text suddenly dissapears, It's just a ':' and i can type commands but not see them.</p>
<p>When i go out from the git log the text still is not appearing. I have a picture in my link below.</p>
<p>If i type CTRL+C 2 times i can see the '$' sign but the text is still gone.</p>
<p><a href="https://i.stack.imgur.com/CZ6nx.png" rel="noreferrer">Git-text-dissapear-picture</a></p>
| 0debug
|
static inline void RENAME(yuv2rgb565_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
x86_reg uv_off = c->uv_off << 1;
const uint16_t *buf1= buf0;
if (uvalpha < 2048) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB16(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB16(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
}
| 1threat
|
static void bdrv_aio_co_cancel_em(BlockDriverAIOCB *blockacb)
{
BlockDriverAIOCBCoroutine *acb =
container_of(blockacb, BlockDriverAIOCBCoroutine, common);
bool done = false;
acb->done = &done;
while (!done) {
qemu_aio_wait();
}
}
| 1threat
|
QueryException: ResultTransformer is not allowed for 'select new' queries : <p>I have the following SpringData Repository Query:</p>
<pre><code> @Query("SELECT new com.mypackage.MobileCaseList(c.ident, concat(c.subtype, ' - ', c.contactName), c.type, coalesce(c.updateTimestamp,c.insertTimestamp) )" +
"FROM MobileCase c WHERE c.mobileUser.ident = ?1 AND c.origin = 'SOURCE' ORDER BY c.appointmentFrom NULLS LAST")
List<MobileCaseList> findCasesForUser(String userIdent);
</code></pre>
<p>And following runtime code:</p>
<pre><code> List<MobileCaseList> result = caseRepo.findCasesForUser(userIdent);
</code></pre>
<p>This worked fine until now - no idea what causes the exception now. On my PC (localhost) it still works!? But on the Ubuntu server the query execution fails with following error:</p>
<pre><code>2016-02-17 12:56:49.696 ERROR 13397 --- [http-nio-9090-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: ResultTransformer is not allowed for 'select new' queries.; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: ResultTransformer is not allowed for 'select new' queries.] with root cause
org.hibernate.QueryException: ResultTransformer is not allowed for 'select new' queries.
at org.hibernate.loader.hql.QueryLoader.checkQuery(QueryLoader.java:502) ~[hibernate-core-4.3.11.Final.jar!/:na]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496) ~[hibernate-core-4.3.11.Final.jar!/:na]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387) ~[hibernate-core-4.3.11.Final.jar!/:na]
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236) ~[hibernate-core-4.3.11.Final.jar!/:na]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1300) ~[hibernate-core-4.3.11.Final.jar!/:na]
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) ~[hibernate-core-4.3.11.Final.jar!/:na]
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573) ~[hibernate-entitymanager-4.3.11.Final.jar!/:na]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) ~[hibernate-entitymanager-4.3.11.Final.jar!/:na]
at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:114) ~[spring-data-jpa-1.10.0.M1.jar!/:na]
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:78) ~[spring-data-jpa-1.10.0.M1.jar!/:na]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:102) ~[spring-data-jpa-1.10.0.M1.jar!/:na]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:92) ~[spring-data-jpa-1.10.0.M1.jar!/:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482) ~[spring-data-commons-1.12.0.M1.jar!/:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) ~[spring-data-commons-1.12.0.M1.jar!/:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar!/:na]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) ~[spring-data-commons-1.12.0.M1.jar!/:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar!/:na]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.2.4.RELEASE.jar!/:na]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[spring-tx-4.2.4.RELEASE.jar!/:na]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.2.4.RELEASE.jar!/:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar!/:na]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.2.4.RELEASE.jar!/:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar!/:na]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:131) ~[spring-data-jpa-1.10.0.M1.jar!/:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar!/:na]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.2.4.RELEASE.jar!/:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar!/:na]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) ~[spring-aop-4.2.4.RELEASE.jar!/:na
at com.sun.proxy.$Proxy144.findCasesForUser(Unknown Source) ~[na:na]
</code></pre>
<p><strong>Any ideas, suggestions...?</strong></p>
| 0debug
|
How to use "MediaStore" in nativescript : I need to open android recorder like this
````
let intent: Intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
````
Unfortunately, nativescript doesn't know "MediaStore". How can i import this definition.
| 0debug
|
Linux C get the default interface and its inet address without getifaddrs : "Default interface" refers to ppp0:
<pre><code>Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 wlp3s0
172.30.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 wlp3s0</code></pre>
Which one is used by default when I access WAN instead of LAN.
I need to run it on Android,so I can't use <code>getifaddrs</code>,because <code>ifaddrs.h</code> is <strong>NOT</strong> in the Android NDK.
| 0debug
|
void av_log_default_callback(void *avcl, int level, const char *fmt, va_list vl)
{
static int print_prefix = 1;
static int count;
static char prev[1024];
char line[1024];
static int is_atty;
AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
int tint = av_clip(level >> 8, 0, 256);
level &= 0xff;
if (level > av_log_level)
return;
line[0] = 0;
if (print_prefix && avc) {
if (avc->parent_log_context_offset) {
AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
avc->parent_log_context_offset);
if (parent && *parent) {
snprintf(line, sizeof(line), "[%s @ %p] ",
(*parent)->item_name(parent), parent);
}
}
snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ",
avc->item_name(avcl), avcl);
}
vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
print_prefix = strlen(line) && line[strlen(line) - 1] == '\n';
#if HAVE_ISATTY
if (!is_atty)
is_atty = isatty(2) ? 1 : -1;
#endif
if (print_prefix && (flags & AV_LOG_SKIP_REPEATED) &&
!strncmp(line, prev, sizeof line)) {
count++;
if (is_atty == 1)
fprintf(stderr, " Last message repeated %d times\r", count);
return;
}
if (count > 0) {
fprintf(stderr, " Last message repeated %d times\n", count);
count = 0;
}
colored_fputs(av_clip(level >> 3, 0, 6), tint, line);
av_strlcpy(prev, line, sizeof line);
}
| 1threat
|
Excel cells matching in VBA : <p>I want to use a number in a cell of my main excel sheet and use it to search for a specific line in another excel file that start with this number. After, the program needs to use the value of a specific cell in this line for a cell in my main excel sheet. </p>
<p>EX : value of the first cell in my sheet : <strong>6.02</strong> . Now the program need to find this value in a column of another file. The line that start with <strong>6.02</strong> contain a cell with the value <strong>dog</strong>. The value <strong>dog</strong> need to go inside a cell next to the first one that contain <strong>6.02</strong>. </p>
<p>I need your help because I know nothing about VBA. I'm starting today! </p>
<p>Thank you very much !!</p>
| 0debug
|
swift: nscoding decodeObject with nil all the time : <p>I got the following codes on writing an object named Packet and send to the other side through Multipeer connectivity. However, I got the following error whenever it try to decode the encoded object.</p>
<pre><code> class Packet : NSObject, NSCoding {
var tmp1: Double = 0
var tmp2: Double = 0
struct PropertyKey {
static let tmp1Key = "tmp1Key"
static let tmp2Key = "tmp2Key"
}
init(tmp1: Double, tmp2: Double) {
self.tmp1 = tmp1
self.tmp2 = tmp2
super.init()
}
deinit {
}
required convenience init(coder aDecoder: NSCoder) {
debugPrint("initcoder")
let tmp1 = aDecoder.decodeObject(forKey: PropertyKey.tmp1Key) as! Double // crash here
let tmp2 = aDecoder.decodeObject(forKey: PropertyKey.tmp2Key) as! Double
self.init(tmp1: tmp1, tmp2: tmp2)
}
public func encode(with aCoder: NSCoder) {
debugPrint("encodeCoder")
aCoder.encode(tmp1, forKey: PropertyKey.tmp1Key)
aCoder.encode(tmp2, forKey: PropertyKey.tmp2Key)
}
}
</code></pre>
<p>The error I got is
---- Print out from me ---- "initcoder"
fatal error: unexpectedly found nil while unwrapping an Optional value
2016-09-30 13:32:55.901189 Connection[323:33022] fatal error: unexpectedly found nil while unwrapping an Optional value</p>
<p>But when I construct the object, all the values are set.
I contracted a Packet object with no problem.</p>
<p>---- Additional information ------
I used the following codes for encode and decode the data when send to the other side through multiplier connectivity.</p>
<pre><code> func dataForPacket(packet: Packet) -> Data {
let data = NSMutableData()
let archiver = NSKeyedArchiver(forWritingWith: data)
archiver.encode(packet, forKey: "Packet")
archiver.finishEncoding()
debugPrint("dataForPacket \(data) \(packet)")
return data as Data
}
func packetForData(_ data: Data) -> Packet {
debugPrint("packetForData")
let unarchiver = NSKeyedUnarchiver(forReadingWith: data)
let packet: Packet = unarchiver.decodeObject(forKey: "Packet") as! Packet
// crash here (as this will call the init of the Packet class)
debugPrint("packetForData \(packet)")
return packet
}
</code></pre>
<p>I wonder what can cause the error. Thanks.</p>
| 0debug
|
How to use "if() and else if()" condition in Windows Batch files : <p>I am trying to create a batch file which can create a folder in current working directory with present date. But, I wanted to print if the date is first or twenty second then I should create like "1stJan2000" or "22ndJan2000". So, I want to know how to use "IF() and ELSE IF()" in Windows batch files. Please Help me or give a solution to create folder as per my requirement. </p>
<p>Thanks in advance.</p>
| 0debug
|
Flask & Alchemy - (psycopg2.OperationalError) FATAL: password authentication failed : <p>I'm new to python. I have to develop a simple Flask app (in my local Ubuntu 16.4) with PostgreSQL as database.</p>
<p>I install pgadmin, Flask, SQLAlchemy and postgres and also this is my app code:</p>
<pre><code>from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://dbUserName:userNamePassword@localhost/dbName'
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True)
email = db.Column(db.String(120), unique=True)
def __init__(self, username, email):
self.username = username
self.email = email
def __repr__(self):
return '<User %r>' % self.username
@app.route('/')
def index():
return "Hello Flask"
if __name__ == "__main__":
app.run()
</code></pre>
<p>Also I create a database and new user in pgAdmin (and replace them with related variable in my code), but when I try to test this code in python shell I found error.</p>
<p>my python code:</p>
<pre><code>from app import db
</code></pre>
<p>result:</p>
<pre><code>/home/user/point2map2/venv/lib/python3.5/site-packages/flask_sqlalchemy/__init__.py:839: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
</code></pre>
<p>Then:</p>
<pre><code>db.create_all()
</code></pre>
<p>result:</p>
<pre><code>(psycopg2.OperationalError) FATAL: password authentication failed for user "dbUserName"
FATAL: password authentication failed for user "dbUserName"
</code></pre>
<p>after a lot of search in forum I found this guide:</p>
<blockquote>
<p>in your pg_hba.conf</p>
<pre><code># IPv4 local connections:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
host all all 127.0.0.1/32 trust
</code></pre>
</blockquote>
<p>But its not work for me.</p>
| 0debug
|
static int qemu_rdma_reg_control(RDMAContext *rdma, int idx)
{
rdma->wr_data[idx].control_mr = ibv_reg_mr(rdma->pd,
rdma->wr_data[idx].control, RDMA_CONTROL_MAX_BUFFER,
IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE);
if (rdma->wr_data[idx].control_mr) {
rdma->total_registrations++;
return 0;
}
fprintf(stderr, "qemu_rdma_reg_control failed!\n");
return -1;
}
| 1threat
|
static int dvbsub_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
DVBSubContext *ctx = avctx->priv_data;
AVSubtitle *sub = data;
const uint8_t *p, *p_end;
int segment_type;
int page_id;
int segment_length;
#ifdef DEBUG_PACKET_CONTENTS
int i;
av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n");
for (i=0; i < buf_size; i++) {
av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
if (i % 16 == 15)
av_log(avctx, AV_LOG_INFO, "\n");
}
if (i % 16)
av_log(avctx, AV_LOG_INFO, "\n");
#endif
if (buf_size <= 2 || *buf != 0x0f)
return -1;
p = buf;
p_end = buf + buf_size;
while (p < p_end && *p == 0x0f) {
p += 1;
segment_type = *p++;
page_id = AV_RB16(p);
p += 2;
segment_length = AV_RB16(p);
p += 2;
if (page_id == ctx->composition_id || page_id == ctx->ancillary_id ||
ctx->composition_id == -1 || ctx->ancillary_id == -1) {
switch (segment_type) {
case DVBSUB_PAGE_SEGMENT:
dvbsub_parse_page_segment(avctx, p, segment_length);
break;
case DVBSUB_REGION_SEGMENT:
dvbsub_parse_region_segment(avctx, p, segment_length);
break;
case DVBSUB_CLUT_SEGMENT:
dvbsub_parse_clut_segment(avctx, p, segment_length);
break;
case DVBSUB_OBJECT_SEGMENT:
dvbsub_parse_object_segment(avctx, p, segment_length);
break;
case DVBSUB_DISPLAYDEFINITION_SEGMENT:
dvbsub_parse_display_definition_segment(avctx, p, segment_length);
case DVBSUB_DISPLAY_SEGMENT:
*data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);
break;
default:
av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
segment_type, page_id, segment_length);
break;
}
}
p += segment_length;
}
return p - buf;
}
| 1threat
|
Angular 6 template cache problem (for html files) : We have template cache problem for html files and we would like to solve it without deleting the cache data(If we delete it, we see performance issue).
Do you have any suggestions for it ?
| 0debug
|
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
{
QemuOpts *opts;
int fd;
opts = qemu_opts_create_nofail(&socket_optslist);
switch (remote->kind) {
case SOCKET_ADDRESS_KIND_INET:
qemu_opt_set(opts, "host", remote->inet->host);
qemu_opt_set(opts, "port", remote->inet->port);
if (local) {
qemu_opt_set(opts, "localaddr", local->inet->host);
qemu_opt_set(opts, "localport", local->inet->port);
}
fd = inet_dgram_opts(opts, errp);
break;
default:
error_setg(errp, "socket type unsupported for datagram");
return -1;
}
qemu_opts_del(opts);
return fd;
}
| 1threat
|
static void msmouse_event(void *opaque,
int dx, int dy, int dz, int buttons_state)
{
CharDriverState *chr = (CharDriverState *)opaque;
unsigned char bytes[4] = { 0x40, 0x00, 0x00, 0x00 };
bytes[0] |= (MSMOUSE_HI2(dy) << 2) | MSMOUSE_HI2(dx);
bytes[1] |= MSMOUSE_LO6(dx);
bytes[2] |= MSMOUSE_LO6(dy);
bytes[0] |= (buttons_state & 0x01 ? 0x20 : 0x00);
bytes[0] |= (buttons_state & 0x02 ? 0x10 : 0x00);
bytes[3] |= (buttons_state & 0x04 ? 0x20 : 0x00);
qemu_chr_be_write(chr, bytes, 4);
}
| 1threat
|
void RENAME(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest,
unsigned width, unsigned height, int src1Stride,
int src2Stride, int dstStride){
unsigned h;
for(h=0; h < height; h++)
{
unsigned w;
#ifdef HAVE_MMX
#ifdef HAVE_SSE2
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2)\n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((long)width-15)
: "memory", "%"REG_a""
);
#else
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((long)width-15)
: "memory", "%"REG_a
);
#endif
for(w= (width&(~15)); w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#else
for(w=0; w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#endif
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
#ifdef HAVE_MMX
asm(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| 1threat
|
How to select/comment on a range of lines in github pull request? : <p>There is an option to comment on a range of lines in file on github, see <a href="https://stackoverflow.com/questions/18070876/how-to-refer-to-a-specific-line-or-range-of-lines-in-github/18072686">How to refer to a specific line or range of lines in github?</a></p>
<p>But is there similar option to comment on range of lines inside pull request?
<a href="https://i.stack.imgur.com/0EX4A.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0EX4A.png" alt="enter image description here"></a></p>
<p>When I click on line, only single line is highlighted yellow and R### (e.g. R446) is appended to url, clicking another line with shift pressed doesn't do anything. I tried to change url to R446-450 but it didn't do anything. Changing it to #L450-458 also didn't do anything. Also even that single highlighted line doesn't seem to affect anything.</p>
<p>Clicking blue plus that appears on hover creates comment window, but it only commenting on a single line.</p>
<p>Commenting on single line results in this
<a href="https://i.stack.imgur.com/OwY40.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OwY40.png" alt="enter image description here"></a></p>
<p>Comment on pull-request page shows only 4 lines above selected/commented line, but I'm interested in showing 7 lines, not 4</p>
| 0debug
|
Issue with new database for android application : I have a problem when I run my android application , it still remember old DB even I changed DB in assets/databases
Could you please help me
Many thanks
| 0debug
|
Regex for group. I want to remove 1) comma from a string surrounded by double quotes (") and double quotes as well nee to be removed : Input String
Arab World,ARB,"Adolescent fertility rate (births per 1,000 women ages 15-19)",SP.ADO.TFRT,1960,133.56090740552298
Output String
Arab World,ARB,Adolescent fertility rate (births per 1,000 women ages 15-19),SP.ADO.TFRT,1960,133.56090740552298
Input String
Arab World,ARB,"International migrant stock, total",SM.POP.TOTL,1960,3324685.0
Output String
Arab World,ARB,International migrant stock total,SM.POP.TOTL,1960,3324685.0
| 0debug
|
Unable to install java8 with homebrew : <p>Installing <code>java8</code> with Homebrew seems to no longer be working. After running:</p>
<pre><code>brew install caskroom/cask/java8
</code></pre>
<p>I get the following error:</p>
<pre><code>Error: Cask 'java8' is unavailable: '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask/Casks/java8.rb' does not exist.
</code></pre>
<p>Simply doing:</p>
<pre><code>brew cask install java8
</code></pre>
<p>Errors out with:</p>
<pre><code>Error: Cask 'java8' is unavailable: No Cask with this name exists.
</code></pre>
<p>This seems like a recent development because I remember installing it this way a few months ago. Any suggestions on how to properly install <code>java8</code> on MacOS nowadays?</p>
| 0debug
|
print_insn_ppi (int field_b, struct disassemble_info *info)
{
static const char *sx_tab[] = { "x0", "x1", "a0", "a1" };
static const char *sy_tab[] = { "y0", "y1", "m0", "m1" };
fprintf_ftype fprintf_fn = info->fprintf_func;
void *stream = info->stream;
unsigned int nib1, nib2, nib3;
unsigned int altnib1, nib4;
const char *dc = NULL;
const sh_opcode_info *op;
if ((field_b & 0xe800) == 0)
{
fprintf_fn (stream, "psh%c\t#%d,",
field_b & 0x1000 ? 'a' : 'l',
(field_b >> 4) & 127);
print_dsp_reg (field_b & 0xf, fprintf_fn, stream);
return;
}
if ((field_b & 0xc000) == 0x4000 && (field_b & 0x3000) != 0x1000)
{
static const char *du_tab[] = { "x0", "y0", "a0", "a1" };
static const char *se_tab[] = { "x0", "x1", "y0", "a1" };
static const char *sf_tab[] = { "y0", "y1", "x0", "a1" };
static const char *sg_tab[] = { "m0", "m1", "a0", "a1" };
if (field_b & 0x2000)
{
fprintf_fn (stream, "p%s %s,%s,%s\t",
(field_b & 0x1000) ? "add" : "sub",
sx_tab[(field_b >> 6) & 3],
sy_tab[(field_b >> 4) & 3],
du_tab[(field_b >> 0) & 3]);
}
else if ((field_b & 0xf0) == 0x10
&& info->mach != bfd_mach_sh_dsp
&& info->mach != bfd_mach_sh3_dsp)
{
fprintf_fn (stream, "pclr %s \t", du_tab[(field_b >> 0) & 3]);
}
else if ((field_b & 0xf3) != 0)
{
fprintf_fn (stream, ".word 0x%x\t", field_b);
}
fprintf_fn (stream, "pmuls%c%s,%s,%s",
field_b & 0x2000 ? ' ' : '\t',
se_tab[(field_b >> 10) & 3],
sf_tab[(field_b >> 8) & 3],
sg_tab[(field_b >> 2) & 3]);
return;
}
nib1 = PPIC;
nib2 = field_b >> 12 & 0xf;
nib3 = field_b >> 8 & 0xf;
nib4 = field_b >> 4 & 0xf;
switch (nib3 & 0x3)
{
case 0:
dc = "";
nib1 = PPI3;
break;
case 1:
dc = "";
break;
case 2:
dc = "dct ";
nib3 -= 1;
break;
case 3:
dc = "dcf ";
nib3 -= 2;
break;
}
if (nib1 == PPI3)
altnib1 = PPI3NC;
else
altnib1 = nib1;
for (op = sh_table; op->name; op++)
{
if ((op->nibbles[1] == nib1 || op->nibbles[1] == altnib1)
&& op->nibbles[2] == nib2
&& op->nibbles[3] == nib3)
{
int n;
switch (op->nibbles[4])
{
case HEX_0:
break;
case HEX_XX00:
if ((nib4 & 3) != 0)
continue;
break;
case HEX_1:
if ((nib4 & 3) != 1)
continue;
break;
case HEX_00YY:
if ((nib4 & 0xc) != 0)
continue;
break;
case HEX_4:
if ((nib4 & 0xc) != 4)
continue;
break;
default:
abort ();
}
fprintf_fn (stream, "%s%s\t", dc, op->name);
for (n = 0; n < 3 && op->arg[n] != A_END; n++)
{
if (n && op->arg[1] != A_END)
fprintf_fn (stream, ",");
switch (op->arg[n])
{
case DSP_REG_N:
print_dsp_reg (field_b & 0xf, fprintf_fn, stream);
break;
case DSP_REG_X:
fprintf_fn (stream, sx_tab[(field_b >> 6) & 3]);
break;
case DSP_REG_Y:
fprintf_fn (stream, sy_tab[(field_b >> 4) & 3]);
break;
case A_MACH:
fprintf_fn (stream, "mach");
break;
case A_MACL:
fprintf_fn (stream, "macl");
break;
default:
abort ();
}
}
return;
}
}
fprintf_fn (stream, ".word 0x%x", field_b);
}
| 1threat
|
POWERPC_FAMILY(POWER5P)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER5";
dc->desc = "POWER5+";
pcc->init_proc = init_proc_power5plus;
pcc->check_pow = check_pow_970FX;
pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_STFIWX |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B |
PPC_SEGMENT_64B | PPC_SLBI;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_VR) |
(1ull << MSR_POW) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI);
pcc->mmu_model = POWERPC_MMU_64B;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
#endif
pcc->excp_model = POWERPC_EXCP_970;
pcc->bus_model = PPC_FLAGS_INPUT_970;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x10000;
}
| 1threat
|
move an image to a top of a cell (urgent) : I put an image on a cell and all margins were separated from the image, the thing is that I united the borders again with display: block; but the top margin is , and I want to move the photo up to touch with the title and this with the top margin but as a limit and not allowed to rise me more , I need urgent help the project must be delivered in a few days in class . There is the photo [image][1]
[1]: http://i.stack.imgur.com/U3XK9.png
| 0debug
|
Return part of string between specific character pair, in string with multiple character pairs : <p>Text file or string:</p>
<p>SomeText1/SomeText2/SomeText3/SomeText4/SomeText5</p>
<pre class="lang-py prettyprint-override"><code>#What I am looking for:
split_func(3, "/")
>>> SomeText3
</code></pre>
| 0debug
|
Laravel 5.3 date validator: equal to or after start_date : <p>I'm using Laravel 5.3 to validate start_date and end_date for an event.
end_date should be equal to start_date or the after date. <code>end_date >= start_date</code></p>
<pre><code>$validator = Validator::make($data, [
'start_date' => 'required|date',
'end_date' => 'required|date|after:start_date',
]);
</code></pre>
<p>I tried to use <strong>after</strong>, but it only works for end_date > start_date.
Of course, I can add custom rule using <code>Validator::extend</code>, but I'd like to know if we can do without adding custom rule.</p>
<p>Is there any way to add negative rule or add >= rule?</p>
<p>Thanks</p>
| 0debug
|
Trying to do a bulk upsert with Mongoose. What's the cleanest way to do this? : <p>I have a collection that holds documents that contains three fields: first_name, last_name, and age. I'm trying to figure out what query in Mongoose I can use to do a bulk upsert. My app is occasionally receiving a new array of objects with those same three fields. I want the query to check if the first AND last name already exist within a document, and if they do - update the age if it's different. Otherwise, if the first and last name don't exist, insert a new document.</p>
<p>Currently, I'm only doing the import - and haven't yet built out the logic for this upsert piece. </p>
<pre><code>app.post('/users/import', function(req, res) {
let data = req.body;
let dataArray = [];
data.forEach(datum => {
dataArray.push({
first: datum.first,
last: datum.last,
age: datum.age
})
})
User.insertMany(dataArray, answer => {
console.log(`Data Inserted:`,answer)
})
</code></pre>
<p>`</p>
<p>And my User model looks like this:</p>
<pre><code>const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const userSchema = new Schema({
first: String,
last: String,
age: Number,
created_at: { type: Date, default: Date.now }
});
var User = mongoose.model('User', userSchema);
module.exports = User;
</code></pre>
| 0debug
|
How to check that all elements in a list are unique : <p>How can i write a program to check that all elements in a list are unique.
I have a list that is entered by the user and i would like the program to check that the elements are unique, if they are, say list=[1,2,3,4,5], then the program continues. If not, say list=[1,2,3,4,5,5,5], then the user must reenter the list.
Thankyou </p>
| 0debug
|
static int vmdk_add_extent(BlockDriverState *bs,
BlockDriverState *file, bool flat, int64_t sectors,
int64_t l1_offset, int64_t l1_backup_offset,
uint32_t l1_size,
int l2_size, uint64_t cluster_sectors,
VmdkExtent **new_extent,
Error **errp)
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
int64_t length;
if (cluster_sectors > 0x200000) {
error_setg(errp, "Invalid granularity, image may be corrupt");
return -EFBIG;
}
if (l1_size > 512 * 1024 * 1024) {
error_setg(errp, "L1 size too big");
return -EFBIG;
}
length = bdrv_getlength(file);
if (length < 0) {
return length;
}
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->file = file;
extent->flat = flat;
extent->sectors = sectors;
extent->l1_table_offset = l1_offset;
extent->l1_backup_table_offset = l1_backup_offset;
extent->l1_size = l1_size;
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = flat ? sectors : cluster_sectors;
extent->next_cluster_sector =
ROUND_UP(DIV_ROUND_UP(length, BDRV_SECTOR_SIZE), cluster_sectors);
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else {
extent->end_sector = extent->sectors;
}
bs->total_sectors = extent->end_sector;
if (new_extent) {
*new_extent = extent;
}
return 0;
}
| 1threat
|
Display timeline in HTML table : <p>I have this table, which shows the current status of the request. A sample table will look as below in HTML</p>
<p><a href="https://i.stack.imgur.com/daDHy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/daDHy.png" alt="enter image description here"></a></p>
<p>Table is pretty simple, only issue is how to display that timeline in the status. I won't mind using some grid for same purpose if it shows timeline as below or something similar.</p>
<p>Timeline in New Approved In Progress etc.</p>
| 0debug
|
On click listener doesn't wait for touch up : <p>The onClick event is fired as soon as we touch down and doesn't wait till the up event.</p>
<pre><code> @Override
public View getPage(int position, View convertView, ViewGroup parent, final Topic item1, final Topic item2, CloseListener closeListener) {
final FriendsHolder holder;
if (convertView == null) {
holder = new FriendsHolder();
convertView = getActivity().getLayoutInflater().inflate(R.layout.friends_merge_page, parent, false);
holder.leftAvatar = ButterKnife.findById(convertView,R.id.first);
holder.rightAvatar = ButterKnife.findById(convertView,R.id.second);
holder.leftAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myParentActivity.setUrl(item1.getMainLink());
}
});
holder.rightAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myParentActivity.setUrl(item2.getMainLink());
}
});
</code></pre>
<p>The left and right avatar views of the holder are the views in question. There is a flip listener on them too. But as soon as I touch them the click event gets fired.</p>
| 0debug
|
static void bt_dummy_lmp_acl_resp(struct bt_link_s *link,
const uint8_t *data, int start, int len)
{
fprintf(stderr, "%s: stray ACL response PDU, fixme\n", __FUNCTION__);
exit(-1);
}
| 1threat
|
iscsi_readv_writev_bh_cb(void *p)
{
IscsiAIOCB *acb = p;
qemu_bh_delete(acb->bh);
if (!acb->canceled) {
acb->common.cb(acb->common.opaque, acb->status);
}
qemu_aio_release(acb);
if (acb->canceled) {
return;
}
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
| 1threat
|
Javascript - how to use variables to replace the existing code at run time : <p>I have the below code and i want to replace the code at run time depending on a variable value, how do i achieve this using javascript. Also please ignore the FormA , animate etc as they are used by kony mobile. </p>
<pre><code>//desired out put inside the run time code.
FormA.ItemFlexContainer0.animate
//index has a value of 0 for now.
var index = 0;
var ItemFlexContainerString = "ItemFlexContainer"+index;
FormA.ItemFlexContainerString.animate
Error :- Type Error null is not an object
</code></pre>
<p>Since ItemFlexContainerString doesnt exist it will throw the error. </p>
| 0debug
|
Beginning a Swift document : <p>What is the first line of code (or declaration) that should be included in a Swift document?</p>
<p>For example, a HTML document usually start with the DTD then what about Swift? I couldn't find any mention about this when reading books about Swift. </p>
<p>Also, what is the filename and extension? As in a HTML document would be index.html</p>
| 0debug
|
static void h264_v_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
{
h264_loop_filter_luma_c(pix, stride, 1, alpha, beta, tc0);
}
| 1threat
|
e1000e_cleanup_msix(E1000EState *s)
{
if (msix_enabled(PCI_DEVICE(s))) {
e1000e_unuse_msix_vectors(s, E1000E_MSIX_VEC_NUM);
msix_uninit(PCI_DEVICE(s), &s->msix, &s->msix);
}
}
| 1threat
|
How to search for a string and print it's related details in c++ : I'm trying to compare an inputed string to a returned string while looping through a file and if the inputed string is equal to the returned string from the file it prints the details associated with the file but it keeps giving me the error message invalid use of void expression...
> void search_course(string course){ int check=0; student st;
> ifstream file;
> file.open("student.dat",ios::binary|ios::out); if(!file) { cout<<"No Such file in Database..."; return; } while(!file.eof()
> && check==0) { file.read((char *) &st, sizeof(student));
> if(strcmp(st.return_prog(), course) == 0) { st.showid_detail();
> }
> }
> file.close(); } int main(){
> system("CLS"); string course="physics"; search_course(course); return 0; }
The showid_detail() is a function in a class which displays information about a record as follows....id, index, name, course, year, Hall
return_prog() is a void function that outputs a course of a student
I expected the code to display all those students doing physics, but it kept telling me invalid use of void expression...
| 0debug
|
docker-compose up -d <name>; No such service: <name> : <p>I have built an image using my dockerfile with the following command:</p>
<pre><code>docker build –t <name>:0.2.34 .
</code></pre>
<p>and then I have tried to use my docker-compose.yml:</p>
<pre><code>strat:
container_name: <name>
image: <name>:0.2.34
restart: always
command: bash -lc 'blah'
</code></pre>
<p>to bring up my container:</p>
<pre><code>docker-compose up -d <name>
</code></pre>
<p>Which gives me the following 'error':</p>
<pre><code>No such service: <name>
</code></pre>
| 0debug
|
void qemu_co_queue_init(CoQueue *queue)
{
QTAILQ_INIT(&queue->entries);
queue->ctx = qemu_get_aio_context();
}
| 1threat
|
How to refer laravel csrf field inside a vue template : <p>I have a vue template that contains a form:</p>
<pre><code><form id="logout-form" :action="href" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</code></pre>
<p>In laravel, forms must have a csrf_field() defined. But within a vue component, the statement <code>{{ csrf_field() }}</code> means that I have a method named <code>csrf_field</code> in my vue instance and I am calling it.</p>
<p>How do I add csrf_field under this circumstance?</p>
| 0debug
|
eval "$(docker-machine env default)" : <p>I have issues with launching docker with docker-compose.</p>
<p>When I run <code>docker-compose -f dev.yml build</code> I following error > </p>
<pre><code>Building postgres
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
</code></pre>
<p>However if I run <code>docker-machine ls</code> machine is clearly up > </p>
<pre><code>NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 v1.12.1
</code></pre>
<p>I fixed the error by running <code>eval "$(docker-machine env default)"</code> after which <code>docker-compose -f dev.yml build</code> completes successfully.</p>
<p>My question why did this work, what actually happens and how do I undo it?</p>
<p>Also is this a safe way to fix this? Right now this just my laptop, but these containers are supposed to hit company servers in near future. </p>
<p>I am not super fluent with bash but I been always told not to run <code>eval</code> and especially not to run eval with " </p>
| 0debug
|
How to convert this php code to ruby (RoR) code? : <p>I am new in ruby on rails. I am migrating from php to ruby. Now I have some php projects which are being converted into ruby code.But How can I convert this switch code to ruby on rails 4?
function ajax($command) {</p>
<pre><code> switch ($command) {
case 'page_reload':
$this->ajax_delete_entries_of_current_uid();
break;
case 'labchem_products':
$this->ajax_labchem_products();
break;
case 'labchem_carts':
$this->ajax_labchem_carts();
break;
case 'labchem_customers':
$this->ajax_labchem_customers();
break;
case 'products_selected':
$this->ajax_products_selected();
break;
case 'products_total':
$this->ajax_products_total();
break;
case 'products_delivery_info':
$this->ajax_products_delivery_info();
break;
case 'labchem_orders':
$this->ajax_labchem_orders();
break;
default: break;
}
}
</code></pre>
| 0debug
|
Way dos it not go to any thing but "Equilateral: Three equal sides" : have made a code to see what kind of triangle but it just gives only one answer
public static void main(String[] args) {
String tal1 = JOptionPane.showInputDialog("Enter the first side of the
triangle ");
Double d1 = Double.parseDouble(tal1);
String tal2 = JOptionPane.showInputDialog("Enter the second side of the
triangle");
Double d2 = Double.parseDouble(tal2);
String tal3 = JOptionPane.showInputDialog("Enter the Third side of the
triangle");
Double d3 = Double.parseDouble(tal3);
if (d1<0 || d2<0 || d3 < 0)
JOptionPane.showMessageDialog(null,"trinagle not 0");
else if (d1 >= (d2+d3) || d3 >= (d2+d1) || d2 >= (d1+d3) )
JOptionPane.showMessageDialog(null,"Not a triangle");
else if (d1==d2 && d1==d3 && d2==d3 )
JOptionPane.showMessageDialog(null,"Equilateral: Three equal sides");
else if ((d1==d2 && d2!=d3) || (d1!=d2 && d3==d1) || (d3==d2 && d3!=d1) )
JOptionPane.showMessageDialog(null,"Isosceles: Two equal sides");
else if(d1!=d2 && d2!=d3 && d3!=d1)
JOptionPane.showMessageDialog(null,"Escalene: No equal sides");
else
JOptionPane.showMessageDialog(null,"wrong");
System.exit(0);
}
i have change some of the code but dont know what to do
| 0debug
|
How to make Pipeline job to wait for all triggered parallel jobs? : <p>I've Groovy script as part of the Pipeline job in Jenkins as below:</p>
<pre><code>node {
stage('Testing') {
build job: 'Test', parameters: [string(name: 'Name', value: 'Foo1')], quietPeriod: 2, wait: false
build job: 'Test', parameters: [string(name: 'Name', value: 'Bar1')], quietPeriod: 2, wait: false
build job: 'Test', parameters: [string(name: 'Name', value: 'Baz1')], quietPeriod: 2, wait: false
build job: 'Test', parameters: [string(name: 'Name', value: 'Foo2')], quietPeriod: 2, wait: false
build job: 'Test', parameters: [string(name: 'Name', value: 'Bar2')], quietPeriod: 2, wait: false
build job: 'Test', parameters: [string(name: 'Name', value: 'Baz2')], quietPeriod: 2, wait: false
}
}
</code></pre>
<p>which executes multiple other freestyle jobs in parallel, because of <code>wait</code> flag being set to <code>false</code>. However I'd like for the caller job to finish when all jobs are finished. Currently the Pipeline job triggers all the jobs and finishes it-self after few seconds which is not what I want, because I cannot track the total time and I don't have ability to cancel all triggered jobs at one go.</p>
<p>How do I correct above script for Pipeline job to finish when all jobs in parallel are completed?</p>
<p>I've tried to wrap build jobs in <code>waitUntil {}</code> block, but it didn't work.</p>
| 0debug
|
expected a component class, got [object Object] : <p>I get an error with this code. However, changing to react-native's removes the error. Can you use div with react-native? If not, why is this error so obscure...?</p>
<pre><code>var React = require('react');
var ReactNative = require('react-native');
var {
StyleSheet,
Text,
View,
} = ReactNative;
let Auto = React.createClass({
getInitialState: function() {
return { value: 'Ma' }
},
render: function() {
return (
<div className="fuck-react">
Blah blah blah
</div>
)
}
</code></pre>
<p>});</p>
| 0debug
|
static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
{
AudioFIRContext *s = ctx->priv;
const float *src = (const float *)s->in[0]->extended_data[ch];
int index1 = (s->index + 1) % 3;
int index2 = (s->index + 2) % 3;
float *sum = s->sum[ch];
AVFrame *out = arg;
float *block;
float *dst;
int n, i, j;
memset(sum, 0, sizeof(*sum) * s->fft_length);
block = s->block[ch] + s->part_index * s->block_size;
memset(block, 0, sizeof(*block) * s->fft_length);
s->fdsp->vector_fmul_scalar(block + s->part_size, src, s->dry_gain, s->nb_samples);
emms_c();
av_rdft_calc(s->rdft[ch], block);
block[2 * s->part_size] = block[1];
block[1] = 0;
j = s->part_index;
for (i = 0; i < s->nb_partitions; i++) {
const int coffset = i * s->coeff_size;
const FFTComplex *coeff = s->coeff[ch * !s->one2many] + coffset;
block = s->block[ch] + j * s->block_size;
s->fcmul_add(sum, block, (const float *)coeff, s->part_size);
if (j == 0)
j = s->nb_partitions;
j--;
}
sum[1] = sum[2 * s->part_size];
av_rdft_calc(s->irdft[ch], sum);
dst = (float *)s->buffer->extended_data[ch] + index1 * s->part_size;
for (n = 0; n < s->part_size; n++) {
dst[n] += sum[n];
}
dst = (float *)s->buffer->extended_data[ch] + index2 * s->part_size;
memcpy(dst, sum + s->part_size, s->part_size * sizeof(*dst));
dst = (float *)s->buffer->extended_data[ch] + s->index * s->part_size;
if (out) {
float *ptr = (float *)out->extended_data[ch];
s->fdsp->vector_fmul_scalar(ptr, dst, s->gain * s->wet_gain, out->nb_samples);
emms_c();
}
return 0;
}
| 1threat
|
How to add event in google calendar from my android application : Hello i am beginner in android and i have task add event in google calendar from my android application please help me with complete source code. I have search but not found solution with complete source code.
| 0debug
|
static bool net_tx_pkt_parse_headers(struct NetTxPkt *pkt)
{
struct iovec *l2_hdr, *l3_hdr;
size_t bytes_read;
size_t full_ip6hdr_len;
uint16_t l3_proto;
assert(pkt);
l2_hdr = &pkt->vec[NET_TX_PKT_L2HDR_FRAG];
l3_hdr = &pkt->vec[NET_TX_PKT_L3HDR_FRAG];
bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, 0, l2_hdr->iov_base,
ETH_MAX_L2_HDR_LEN);
if (bytes_read < sizeof(struct eth_header)) {
l2_hdr->iov_len = 0;
return false;
}
l2_hdr->iov_len = sizeof(struct eth_header);
switch (be16_to_cpu(PKT_GET_ETH_HDR(l2_hdr->iov_base)->h_proto)) {
case ETH_P_VLAN:
l2_hdr->iov_len += sizeof(struct vlan_header);
break;
case ETH_P_DVLAN:
l2_hdr->iov_len += 2 * sizeof(struct vlan_header);
break;
}
if (bytes_read < l2_hdr->iov_len) {
l2_hdr->iov_len = 0;
return false;
}
l3_proto = eth_get_l3_proto(l2_hdr->iov_base, l2_hdr->iov_len);
switch (l3_proto) {
case ETH_P_IP:
l3_hdr->iov_base = g_malloc(ETH_MAX_IP4_HDR_LEN);
bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,
l3_hdr->iov_base, sizeof(struct ip_header));
if (bytes_read < sizeof(struct ip_header)) {
l3_hdr->iov_len = 0;
return false;
}
l3_hdr->iov_len = IP_HDR_GET_LEN(l3_hdr->iov_base);
pkt->l4proto = ((struct ip_header *) l3_hdr->iov_base)->ip_p;
bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags,
l2_hdr->iov_len + sizeof(struct ip_header),
l3_hdr->iov_base + sizeof(struct ip_header),
l3_hdr->iov_len - sizeof(struct ip_header));
if (bytes_read < l3_hdr->iov_len - sizeof(struct ip_header)) {
l3_hdr->iov_len = 0;
return false;
}
break;
case ETH_P_IPV6:
if (!eth_parse_ipv6_hdr(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,
&pkt->l4proto, &full_ip6hdr_len)) {
l3_hdr->iov_len = 0;
return false;
}
l3_hdr->iov_base = g_malloc(full_ip6hdr_len);
bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,
l3_hdr->iov_base, full_ip6hdr_len);
if (bytes_read < full_ip6hdr_len) {
l3_hdr->iov_len = 0;
return false;
} else {
l3_hdr->iov_len = full_ip6hdr_len;
}
break;
default:
l3_hdr->iov_len = 0;
break;
}
net_tx_pkt_calculate_hdr_len(pkt);
pkt->packet_type = get_eth_packet_type(l2_hdr->iov_base);
return true;
}
| 1threat
|
type (key:Int, value: Any) does not conform to protocol sequence - Loop through dictionary : I have a dictionary as `[Int: Any]()`
my code:
var test = [Int: Any]()
test = self.header_all_items[header] as! [Int : Any]
for tes in test{
for (key:value)in tes{ // error line
print(key)
}
}
I got this error :
type (key:Int, value: Any) does not conform to protocol sequence
| 0debug
|
Google Play services out of date. Requires 11011000 but found 10289574 : <p>I've been strugling with this problem about week now. Been searching similar topics about this but still can't resolve my problem.</p>
<p>The Prolem is that when i'm trying to run my program on Polar m600 wear or wear emulator (Android V 7.1.1 and API25) they'r giving me this message "Google Play services out of date. Requires 11011000 but found 10289574".</p>
<p>I've followed the "Getting the Last Known Location" part in the android developer site. (Link for the site <a href="https://developer.android.com/training/location/retrieve-current.html#play-services" rel="noreferrer">https://developer.android.com/training/location/retrieve-current.html#play-services</a>)</p>
<p>Here's my Mainactivity code which i'm using</p>
<pre><code>public class MainActivity extends Activity {
private FusedLocationProviderClient mFusedLocationClient;
public Location mLastLocation;
private TextView mTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTextView = (TextView) stub.findViewById(R.id.text);
}
});
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
return;
}
mFusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
mLastLocation = location;
Log.d("Location is:",""+mLastLocation);
if (location != null) {
}
}
});
}
}
</code></pre>
<p>Here's my manifest.xml`</p>
<pre><code><uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</code></pre>
<p></p>
<p>And last but not least my build.gradle</p>
<pre><code>android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "ims.fhj.at.testnavigators"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:2.0.3'
compile 'com.google.android.gms:play-services-wearable:11.0.1'
compile 'com.google.android.gms:play-services:11.0.1'}
</code></pre>
| 0debug
|
Is it possible to update a hash key in amazon dynamo db : <p>I want to update hash key value in amazon dynamo db table.I also have a range key in the same table.Is it possible to do this?</p>
| 0debug
|
void bdrv_detach_aio_context(BlockDriverState *bs)
{
BdrvAioNotifier *baf;
BdrvChild *child;
if (!bs->drv) {
return;
}
QLIST_FOREACH(baf, &bs->aio_notifiers, list) {
baf->detach_aio_context(baf->opaque);
}
if (bs->drv->bdrv_detach_aio_context) {
bs->drv->bdrv_detach_aio_context(bs);
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_detach_aio_context(child->bs);
}
bs->aio_context = NULL;
}
| 1threat
|
convert strings to number array from file python : i have a text file like this
**.txt**
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
and i would like to view this as an array in python this is what i have so far
**python file**
file_board = open('index.txt')
board = file_board.read().split(',')
print board
print len(board)
**output**
['[[1', ' 2', ' 3]', ' [4', ' 5', ' 6]', ' [7', ' 8', ' 9]]\n']
9
list index out of range
so what i want todo is some how make this in to a 2D array for manipulation
**Note** I would like to do this without any external libraries, build in libraries are fine
| 0debug
|
start_list(Visitor *v, const char *name, Error **errp)
{
StringInputVisitor *siv = to_siv(v);
if (parse_str(siv, name, errp) < 0) {
return;
}
siv->cur_range = g_list_first(siv->ranges);
if (siv->cur_range) {
Range *r = siv->cur_range->data;
if (r) {
siv->cur = r->begin;
}
}
}
| 1threat
|
AngularJS ng-repeat não exibe os dados : Estou fazendo uma requisiçao via get no backend LARAVEL, consigo trazer os dados, exibo no console.log, porem no ng-repeat ele nao exibe. Segue meu código
<!DOCTYPE html>
<html ng-app="myApp">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-controller="myCtrl">
<tr ng-repeat="t in teste">
<td>{{t.id}}</td>
<td>{{t.total}}</td>
</tr>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("//localhost:8000/angular")
.then(function(response) {
$scope.teste = response.data;
console.log($scope.teste);
});
});
</script>
</body>
</html>
| 0debug
|
How return object that has specific value in string? : <p>So I have array with object inside. That object has a property call name that is a string of values</p>
<p>How can I return object that has "apples" in the name properties </p>
<pre><code>fruits = [
{
name: 'apples, lemon',
quantity: 2
},
{
name: 'bananas, pearl',
quantity: 0
},
{
name: 'cherries,
pineapple',
quantity: 5
}
];
</code></pre>
| 0debug
|
static gboolean gd_focus_out_event(GtkWidget *widget,
GdkEventCrossing *crossing, gpointer opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
gtk_release_modifiers(s);
return TRUE;
}
| 1threat
|
App Availability on Google Play Store by Location for visiting Clients : <p>I have an android app that is only Available in Philippines. But I have an query from my clients that this app is not showing them when they visiting in philippines from another country. I want to app should be available for all customers when they are in Philippines but not available to other countries.</p>
| 0debug
|
static int ide_qdev_init(DeviceState *qdev)
{
IDEDevice *dev = IDE_DEVICE(qdev);
IDEDeviceClass *dc = IDE_DEVICE_GET_CLASS(dev);
IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);
if (!dev->conf.bs) {
error_report("No drive specified");
goto err;
}
if (dev->unit == -1) {
dev->unit = bus->master ? 1 : 0;
}
if (dev->unit >= bus->max_units) {
error_report("Can't create IDE unit %d, bus supports only %d units",
dev->unit, bus->max_units);
goto err;
}
switch (dev->unit) {
case 0:
if (bus->master) {
error_report("IDE unit %d is in use", dev->unit);
goto err;
}
bus->master = dev;
break;
case 1:
if (bus->slave) {
error_report("IDE unit %d is in use", dev->unit);
goto err;
}
bus->slave = dev;
break;
default:
error_report("Invalid IDE unit %d", dev->unit);
goto err;
}
return dc->init(dev);
err:
return -1;
}
| 1threat
|
How can i verify a user registartion using sms verification? : <p>i want to create a user registration by sms verification. after entering mobile number in my website(php) will send(and also will be stored to database against user id) a random 4 or 6 digit code to users number. then user will have to enter that code to my websites confirmation page. then it will check that code with the stored code in the database. if it matches then user is verified. <strong>I want to know what will be the cheapest sms service i can use in india ?</strong> <strong>if there are any free ervice like this then it will be good(atleast for testing).</strong></p>
| 0debug
|
Different code in different build variant : <p>I have two build variants in my app, one is an standard app edition and the second one is a customization app.</p>
<pre><code>productFlavors {
customConfig {
minSdkVersion 14
applicationId 'es.com.custom'
targetSdkVersion 22
versionCode 3
versionName '3.0.0'
}
standard {
minSdkVersion 14
applicationId 'es.com.standard'
targetSdkVersion 22
versionCode 3
versionName '3.0.0'
}
</code></pre>
<p>For the customization I have to implement new features, but just for the customization, so those new features will be not available on the standard version. I am not sure what i have to do. </p>
<p>1.- Two classes , one with the standard requirements and one with the custom requirements<br>
2.- In the standard class do something like:</p>
<pre><code> if (getPackageName()==customConfig )
// do the custom things
else
//do the standard things
</code></pre>
| 0debug
|
Ayuda, quiero pasar esta consulta a Eloquent en laravel : Estoy tratando de hacer una consulta con eloquent, trato de obtener todos los usuarios que tiene uno o mas anuncios, teniendo en cuenta que es una relación uno a muchos(users a anuncios).
Esta consulta en general hace lo que quiero, pero nose si esta bien hecha y tampoco como pasarla a Eloquen por medio del modelo User.
SELECT users.id, COUNT( anuncio.id ) AS 'total' FROM users
INNER JOIN anuncio ON users.id = anuncio.usuario_id WHERE
(SELECT COUNT( * ) FROM anuncio WHERE anuncio.usuario_id = users.id) >0
GROUP BY users.id ORDER BY total DESC
He tratado de varias maneras que solo me devuelven Builder.
Por ejemplo:
$listas = new User;
$listas = $listas->join('anuncio','users.id','=','anuncio.usuario_id');
$listas = $listas->select(array('users.*', DB::raw('COUNT(anuncio.id) AS total')));
$listas = $listas->where(function($query) use ($listas){
$query->select(DB::raw('COUNT(anuncio.usuario_id)'))
->where('anuncio.usuario_id','=','users.id')
->groupBy('anuncio.usuario_id');
},'>','0');
$listas = $listas->orderBy('total','DESC')->paginate(48);
Por cualquier sugerencia les estare muy agradecido
| 0debug
|
Is there a type of password protection that works on local files? : <p>With my website, which is on my pc is not using localhost and I'm wondering if there are any password protection techniques that doesn't require php/htaccess or a localhost network. Just pure HTML files on my pc. I know there is no way to be fully protected since its local on my pc, but just a simple one where I can store passwords in a text file and my website uses that to get login information.</p>
<p>Thanks.</p>
| 0debug
|
button being placed outside site inner : For a reason I cant find the button that is supposed to be centered underneath the two collums is being placed to the side
https://tandarts-haarlem.nl/haarlem-zuid-centrum/
Can anyone tell me what im missing?
| 0debug
|
void net_cleanup(void)
{
VLANState *vlan;
#if !defined(_WIN32)
for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) {
VLANClientState *vc;
for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
if (vc->fd_read == tap_receive) {
char ifname[64];
TAPState *s = vc->opaque;
if (strcmp(vc->model, "tap") == 0 &&
sscanf(vc->info_str, "ifname=%63s ", ifname) == 1 &&
s->down_script[0])
launch_script(s->down_script, ifname, s->fd);
}
#if defined(CONFIG_VDE)
if (vc->fd_read == vde_from_qemu) {
VDEState *s = vc->opaque;
vde_close(s->vde);
}
#endif
}
}
#endif
}
| 1threat
|
static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch,
Error **errp)
{
struct vmsvga_state_s *s = opaque;
DisplaySurface *surface = qemu_console_surface(s->vga.con);
if (!s->enable) {
s->vga.screen_dump(&s->vga, filename, cswitch, errp);
return;
}
if (surface_bits_per_pixel(surface) == 32) {
DisplaySurface *ds = qemu_create_displaysurface_from(
surface_width(surface),
surface_height(surface),
32,
surface_stride(surface),
s->vga.vram_ptr, false);
ppm_save(filename, ds, errp);
g_free(ds);
}
}
| 1threat
|
java.lang.ClassNotFoundException sun.misc.GC : <p><strong>Version</strong>
Java: 10.0.1
Tomcat: 8.0.36
Ubuntu: 18.04 (64 bit)
Eclipse: Photon (64 bit)</p>
<p>Error: When I run the Tomcat server, I found below error. Please don't tell me to decrease the version if possible, because I love to use latest technology.</p>
<pre><code> SEVERE: Failed to trigger creation of the GC Daemon thread during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs.
java.lang.ClassNotFoundException: sun.misc.GC
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:291)
at org.apache.catalina.core.JreMemoryLeakPreventionListener.lifecycleEvent(JreMemoryLeakPreventionListener.java:286)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:394)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99)
at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)
</code></pre>
| 0debug
|
static int ppc6xx_tlb_check (CPUState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int access_type)
{
ppc_tlb_t *tlb;
int nr, best, way;
int ret;
best = -1;
ret = -1;
for (way = 0; way < env->nb_ways; way++) {
nr = ppc6xx_tlb_getnum(env, eaddr, way,
access_type == ACCESS_CODE ? 1 : 0);
tlb = &env->tlb[nr];
if ((eaddr & TARGET_PAGE_MASK) != tlb->EPN) {
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "TLB %d/%d %s [%08x %08x] <> %08x\n",
nr, env->nb_tlb,
pte_is_valid(tlb->pte0) ? "valid" : "inval",
tlb->EPN, tlb->EPN + TARGET_PAGE_SIZE, eaddr);
}
#endif
continue;
}
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "TLB %d/%d %s %08x <> %08x %08x %c %c\n",
nr, env->nb_tlb,
pte_is_valid(tlb->pte0) ? "valid" : "inval",
tlb->EPN, eaddr, tlb->pte1,
rw ? 'S' : 'L', access_type == ACCESS_CODE ? 'I' : 'D');
}
#endif
switch (pte_check(ctx, tlb->pte0, tlb->pte1, 0, rw)) {
case -3:
return -1;
case -2:
ret = -2;
best = nr;
break;
case -1:
default:
break;
case 0:
ret = 0;
best = nr;
goto done;
}
}
if (best != -1) {
done:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel > 0) {
fprintf(logfile, "found TLB at addr 0x%08lx prot=0x%01x ret=%d\n",
ctx->raddr & TARGET_PAGE_MASK, ctx->prot, ret);
}
#endif
pte_update_flags(ctx, &env->tlb[best].pte1, ret, rw);
}
return ret;
}
| 1threat
|
Should I prefer Rcpp::NumericVector over std::vector? : <p>Is there any reason why I should prefer <code>Rcpp::NumericVector</code> over <code>std::vector<double></code>?</p>
<p>For example, the two functions below</p>
<pre><code>// [[Rcpp::export]]
Rcpp::NumericVector foo(const Rcpp::NumericVector& x) {
Rcpp::NumericVector tmp(x.length());
for (int i = 0; i < x.length(); i++)
tmp[i] = x[i] + 1.0;
return tmp;
}
// [[Rcpp::export]]
std::vector<double> bar(const std::vector<double>& x) {
std::vector<double> tmp(x.size());
for (int i = 0; i < x.size(); i++)
tmp[i] = x[i] + 1.0;
return tmp;
}
</code></pre>
<p>Are equivalent when considering their working and benchmarked performance. I understand that Rcpp offers sugar and vectorized operations, but if it is only about taking R's vector as input and returning vector as output, then would there be any difference which one of those I use? Can using <code>std::vector<double></code> lead to any possible problems when interacting with R?</p>
| 0debug
|
static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
{
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
PCIRegion *pci_region = dev->real_device.regions;
int ret, pos;
Error *local_err = NULL;
pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0);
pci_set_word(pci_dev->config + PCI_STATUS,
pci_get_word(pci_dev->config + PCI_STATUS) &
~PCI_STATUS_CAP_LIST);
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
verify_irqchip_in_kernel(&local_err);
if (local_err) {
error_propagate(errp, local_err);
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSI, pos, 10,
&local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
pci_dev->msi_cap = pos;
pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS,
pci_get_word(pci_dev->config + pos + PCI_MSI_FLAGS) &
PCI_MSI_FLAGS_QMASK);
pci_set_long(pci_dev->config + pos + PCI_MSI_ADDRESS_LO, 0);
pci_set_word(pci_dev->config + pos + PCI_MSI_DATA_32, 0);
pci_set_word(pci_dev->wmask + pos + PCI_MSI_FLAGS,
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(pci_dev->wmask + pos + PCI_MSI_ADDRESS_LO, 0xfffffffc);
pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0);
if (pos != 0 && kvm_device_msix_supported(kvm_state)) {
int bar_nr;
uint32_t msix_table_entry;
verify_irqchip_in_kernel(&local_err);
if (local_err) {
error_propagate(errp, local_err);
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;
ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSIX, pos, 12,
&local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
pci_dev->msix_cap = pos;
pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS,
pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) &
PCI_MSIX_FLAGS_QSIZE);
pci_set_word(pci_dev->wmask + pos + PCI_MSIX_FLAGS,
PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
msix_table_entry = pci_get_long(pci_dev->config + pos + PCI_MSIX_TABLE);
bar_nr = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;
msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;
dev->msix_table_addr = pci_region[bar_nr].base_addr + msix_table_entry;
dev->msix_max = pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS);
dev->msix_max &= PCI_MSIX_FLAGS_QSIZE;
dev->msix_max += 1;
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PM, 0);
if (pos) {
uint16_t pmc;
ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF,
&local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
assigned_dev_setup_cap_read(dev, pos, PCI_PM_SIZEOF);
pmc = pci_get_word(pci_dev->config + pos + PCI_CAP_FLAGS);
pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);
pci_set_word(pci_dev->config + pos + PCI_CAP_FLAGS, pmc);
pci_set_word(pci_dev->config + pos + PCI_PM_CTRL,
PCI_PM_CTRL_NO_SOFT_RESET);
pci_set_byte(pci_dev->config + pos + PCI_PM_PPB_EXTENSIONS, 0);
pci_set_byte(pci_dev->config + pos + PCI_PM_DATA_REGISTER, 0);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_EXP, 0);
if (pos) {
uint8_t version, size = 0;
uint16_t type, devctl, lnksta;
uint32_t devcap, lnkcap;
version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);
version &= PCI_EXP_FLAGS_VERS;
if (version == 1) {
size = 0x14;
} else if (version == 2) {
size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos);
if (size < 0x34) {
error_setg(errp, "Invalid size PCIe cap-id 0x%x",
PCI_CAP_ID_EXP);
return -EINVAL;
} else if (size != 0x3c) {
error_report("WARNING, %s: PCIe cap-id 0x%x has "
"non-standard size 0x%x; std size should be 0x3c",
__func__, PCI_CAP_ID_EXP, size);
}
} else if (version == 0) {
uint16_t vid, did;
vid = pci_get_word(pci_dev->config + PCI_VENDOR_ID);
did = pci_get_word(pci_dev->config + PCI_DEVICE_ID);
if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) {
size = 0x3c;
}
}
if (size == 0) {
error_setg(errp, "Unsupported PCI express capability version %d",
version);
return -EINVAL;
}
ret = pci_add_capability2(pci_dev, PCI_CAP_ID_EXP, pos, size,
&local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
assigned_dev_setup_cap_read(dev, pos, size);
type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS);
type = (type & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {
error_setg(errp, "Device assignment only supports endpoint "
"assignment, device type %d", type);
return -EINVAL;
}
devcap = pci_get_long(pci_dev->config + pos + PCI_EXP_DEVCAP);
devcap &= ~PCI_EXP_DEVCAP_FLR;
pci_set_long(pci_dev->config + pos + PCI_EXP_DEVCAP, devcap);
devctl = pci_get_word(pci_dev->config + pos + PCI_EXP_DEVCTL);
devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) |
PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;
pci_set_word(pci_dev->config + pos + PCI_EXP_DEVCTL, devctl);
devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME;
pci_set_word(pci_dev->wmask + pos + PCI_EXP_DEVCTL, ~devctl);
pci_set_word(pci_dev->config + pos + PCI_EXP_DEVSTA, 0);
lnkcap = pci_get_long(pci_dev->config + pos + PCI_EXP_LNKCAP);
lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |
PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |
PCI_EXP_LNKCAP_L1EL);
pci_set_long(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap);
lnksta = pci_get_word(pci_dev->config + pos + PCI_EXP_LNKSTA);
lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);
pci_set_word(pci_dev->config + pos + PCI_EXP_LNKSTA, lnksta);
if (version >= 2) {
pci_set_long(pci_dev->config + pos + PCI_EXP_SLTCAP, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_SLTCTL, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_SLTSTA, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_RTCTL, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_RTCAP, 0);
pci_set_long(pci_dev->config + pos + PCI_EXP_RTSTA, 0);
}
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PCIX, 0);
if (pos) {
uint16_t cmd;
uint32_t status;
ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PCIX, pos, 8,
&local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
assigned_dev_setup_cap_read(dev, pos, 8);
cmd = pci_get_word(pci_dev->config + pos + PCI_X_CMD);
cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |
PCI_X_CMD_MAX_SPLIT);
pci_set_word(pci_dev->config + pos + PCI_X_CMD, cmd);
status = pci_get_long(pci_dev->config + pos + PCI_X_STATUS);
status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN);
status |= (pci_bus_num(pci_dev->bus) << 8) | pci_dev->devfn;
status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL |
PCI_X_STATUS_SPL_ERR);
pci_set_long(pci_dev->config + pos + PCI_X_STATUS, status);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0);
if (pos) {
ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VPD, pos, 8,
&local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
assigned_dev_setup_cap_read(dev, pos, 8);
assigned_dev_direct_config_write(dev, pos + 2, 6);
}
for (pos = 0; (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos));
pos += PCI_CAP_LIST_NEXT) {
uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS);
ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VNDR, pos, len,
&local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
assigned_dev_setup_cap_read(dev, pos, len);
assigned_dev_direct_config_write(dev, pos + 2, len - 2);
}
if ((pci_get_word(pci_dev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=
(assigned_dev_pci_read_byte(pci_dev, PCI_STATUS) &
PCI_STATUS_CAP_LIST)) {
dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
}
return 0;
}
| 1threat
|
What does the following Python code do? : <p>I'm not sure, especially, what the last line does. I saw it in a Python book.</p>
<pre><code>from random import randint
random_bits = 0
for i in range(64):
if randint(0, 1):
random_bits |= 1 << i
</code></pre>
| 0debug
|
What is the equivalent of Java static methods in Kotlin? : <p>There is no <code>static</code> keyword in Kotlin.</p>
<p>What is the best way to represent a <code>static</code> Java method in Kotlin?</p>
| 0debug
|
Group by ID ,Group by ID ,Group by ID ,Group by ID ,Group by ID ,Group by ID , : Im new in coding so please if u a have answer , just say it in easy way !
i have many users with unique userID in table-1 with their specifications,
i have other table-2 that Supervisors choose hours that users work
.(i connect userID of table-2 to table-1 and it's ok)
supervisors are many so maybe their is many row with different hour for same useriD.
so i create view with
select w_userid,sum(w_hour)as total from Workk group by w_userid
for show me one userID with sum of his hours.
but i cant add it in database layer .so could someone help me ?
| 0debug
|
What is .net alternative to jhipster : <p>Which framework provides similar features to .Net as jhipster does for Java. I understand that there are separate libraries that can be brought together to work as the solution, but is there something pre-packaged to make things as quick and smooth as jhipster does?</p>
| 0debug
|
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
uint16_t *y_list, int *flag,
int multiplier, float *out, int samples)
{
int lx, ly, i;
lx = 0;
ly = y_list[0] * multiplier;
for (i = 1; i < values; i++) {
int pos = list[i].sort;
if (flag[pos]) {
int x1 = list[pos].x;
int y1 = y_list[pos] * multiplier;
if (lx < samples)
render_line(lx, ly, FFMIN(x1,samples), y1, out);
lx = x1;
ly = y1;
}
if (lx >= samples)
break;
}
if (lx < samples)
render_line(lx, ly, samples, ly, out);
}
| 1threat
|
Swift strictness : <p>Well, it says on their website that Swift is a strict language. However, I am not sure in what ways it is considered to be strict. Can you please elaborate on that?</p>
| 0debug
|
What is the "S" in "npm i -S" : <p>I'm seeing this command on some packages and I wonder what the <code>-s</code> argument means, for example</p>
<pre><code>npm i -S classnames flexboxgrid
</code></pre>
<p>I mean, I know that, just like <code>i</code> is an abbreviation of <code>install</code>, it is an abbreviation of something, however I tried looking at <code>npm help</code>, <code>npm help help</code>, <code>npm apihelp npm</code>, <code>npm help npm</code>, nothing practically helpful there. This is like giving a dictionary to an illiterate; many words, but nothing about option arguments or their abbreviations.</p>
| 0debug
|
NativeModule: AsyncStorage is null, with @RNC/AsyncStorage : <p>I'm working on a React Native project created with Expo. I've been using regular old <code>AsyncStorage</code>, importing from <code>react-native</code>, and all has been well.</p>
<p>In looking up how to mock <code>AsyncStorage</code> for testing, I saw that <code>react-native-community/react-native-async-storage</code> has its own mock built in. </p>
<p>So I installed the community plugin with <code>yarn add</code> and switched out all my import statements.</p>
<p>When I run my app, I'm getting an error (which I'm retyping myself, excuse some ellipses): </p>
<pre><code>[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
To fix this issue try these steps:
-Run `react-native link @react-native-community/async-storage` in the project root.
-Rebuild and restart the app
-Run the packager with `--clearCache` flag.
-If you are using CocoaPods on iOS...
-If this happens while testing with Jest...
</code></pre>
<p>So I tried running <code>react-native link @react-native-community/async-storage</code> but I keep getting this error:</p>
<pre><code>Something went wrong while linking. Error: Cannot read property 'pbxprojPath' of null
</code></pre>
<p>Some research showed me that Expo apps can't (and don't need to) link. </p>
<p>I tried <code>npm start --clearCache</code> to no avail.</p>
<p>Also, I don't have an <code>ios</code> (or <code>android</code>) folder in my project. This has always been kind of confusing for me because I see it referenced all over the place. I run my app in the Simulator/Emulator (and device) through the Expo app. Once I tried ejecting and there were problems. So, I don't have an <code>ios</code> folder.</p>
<p>(I'll go back to using the old native <code>AsyncStorage</code> from <code>react-native</code> and creating a mock myself, but I'd like to know how to solve this, and similar problems that may arise in the future.)</p>
| 0debug
|
error mysql db table, trying to load up : Could anyone tell me whats wrong, i get this error when trying to load up the DB,
QL Query failed: INSERT INTO scxpm_statz (uniqueid) VALUES ('STEAM_0:1:406062330') ON DUPLICATE KEY UPDATE[enter image description here][1]
[1]: https://i.stack.imgur.com/SA4Qo.jpg
| 0debug
|
Python 3 list comparison : I have a list with the following elements
> queue = [[(1, 5), 4, (1, 4)], [(2, 2), 6, (2, 3)], [(1, 3), 6, (2,
> 3)], [(1, 3), 6, (1, 4)]]
and another one called
> neighbors = [[(1, 5), 4, (1, 4)], [(1, 3), 6, (1, 4)], [(2, 4), 4, (1,
> 4)], [(0, 4), 6, (1, 4)]]
How can I check that the first tuple element on the second list exists in the first?
usually I would do something like:
for item in neighbors:
> if item[0] in queue:
> Do something
But it's not working, how can iI do this?
Thanks
| 0debug
|
Static class in typescript : <p>Is there any way to create an static class in typescript, node.js </p>
<p>I want to create an static class to keep all constants and string in that.</p>
<p>what could be the best way to do that ? </p>
| 0debug
|
static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
{
static const char shutdown_str[8] = "Shutdown";
static int shutdown_index = 0;
switch(addr) {
case 0x400:
case 0x401:
break;
case 0x402:
case 0x403:
#ifdef DEBUG_BIOS
fprintf(stderr, "%c", val);
#endif
break;
case 0x8900:
if (val == shutdown_str[shutdown_index]) {
shutdown_index++;
if (shutdown_index == 8) {
shutdown_index = 0;
qemu_system_shutdown_request();
}
} else {
shutdown_index = 0;
}
break;
case 0x501:
case 0x502:
fprintf(stderr, "VGA BIOS panic, line %d\n", val);
exit(1);
case 0x500:
case 0x503:
#ifdef DEBUG_BIOS
fprintf(stderr, "%c", val);
#endif
break;
}
}
| 1threat
|
e1000e_process_tx_desc(E1000ECore *core,
struct e1000e_tx *tx,
struct e1000_tx_desc *dp,
int queue_index)
{
uint32_t txd_lower = le32_to_cpu(dp->lower.data);
uint32_t dtype = txd_lower & (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D);
unsigned int split_size = txd_lower & 0xffff;
uint64_t addr;
struct e1000_context_desc *xp = (struct e1000_context_desc *)dp;
bool eop = txd_lower & E1000_TXD_CMD_EOP;
if (dtype == E1000_TXD_CMD_DEXT) {
e1000x_read_tx_ctx_descr(xp, &tx->props);
e1000e_process_snap_option(core, le32_to_cpu(xp->cmd_and_length));
return;
} else if (dtype == (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D)) {
tx->props.sum_needed = le32_to_cpu(dp->upper.data) >> 8;
tx->props.cptse = (txd_lower & E1000_TXD_CMD_TSE) ? 1 : 0;
e1000e_process_ts_option(core, dp);
} else {
e1000e_process_ts_option(core, dp);
tx->props.cptse = 0;
}
addr = le64_to_cpu(dp->buffer_addr);
if (!tx->skip_cp) {
if (!net_tx_pkt_add_raw_fragment(tx->tx_pkt, addr, split_size)) {
tx->skip_cp = true;
}
}
if (eop) {
if (!tx->skip_cp && net_tx_pkt_parse(tx->tx_pkt)) {
if (e1000x_vlan_enabled(core->mac) &&
e1000x_is_vlan_txd(txd_lower)) {
net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt,
le16_to_cpu(dp->upper.fields.special), core->vet);
}
if (e1000e_tx_pkt_send(core, tx, queue_index)) {
e1000e_on_tx_done_update_stats(core, tx->tx_pkt);
}
}
tx->skip_cp = false;
net_tx_pkt_reset(tx->tx_pkt);
tx->props.sum_needed = 0;
tx->props.cptse = 0;
}
}
| 1threat
|
Value vs Reference types - why do both exist? : <p>I know what both are, value and reference, but my question is why do both exist?</p>
<p>I mean why all primitives aren't also reference (or treated as such)? I know the primitives aren't affected by garbage collector, which i see as a drawback, and I can't find any pros to them, so what am I missing?</p>
| 0debug
|
Swift UIButton Click To Show UIPickerView and Select ID show on Button Title : MY Scenario, I am trying to create `button` click to open `pickerview` and selected picker data show on button title using swift. Here, `Toolbar` also I would like to add into the pickerview controller.
let button = UIButton(type: .custom)
button.setTitle("",for: .normal)
button.frame = CGRect(x: CGFloat(amount_textfield.frame.size.width - 9), y: CGFloat(5), width: CGFloat(9), height: CGFloat(20))
button.addTarget(self, action: #selector(self.refresh), for: .touchUpInside)
amount_textfield.leftView = button
amount_textfield.leftViewMode = .always
@IBAction func refresh(_ sender: Any) {
// Here, I need to execute picker view
}
| 0debug
|
How to rename multiple directory from DOS prompt with different names : How to rename multiple directory from DOS prompt with different names like below :
> alnaddy.com-7-5-2014 -> alnaddy.com
>
> cairoscene.org-7-5-2014 -> cairoscene.org
>
> elshaab.org-7-5-2014 -> elshaab.org
>
> goal.com-7-5-2014 -> goal.com
I have a list of thousands of directories .
thanks
| 0debug
|
static int net_rx_ok(NetClientState *nc)
{
struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
RING_IDX rc, rp;
if (netdev->xendev.be_state != XenbusStateConnected) {
return 0;
}
rc = netdev->rx_ring.req_cons;
rp = netdev->rx_ring.sring->req_prod;
xen_rmb();
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "%s: no rx buffers (%d/%d)\n",
__FUNCTION__, rc, rp);
return 0;
}
return 1;
}
| 1threat
|
whay do i get error with edit.php in new modul Vtiger? : Hay I have create a new modul and then i did not have in ther a directory "view", so i copy that directory from other modul and paste that in my modul but then i have problem with "Edit.php". than my page is completey white it dosent wont it load but when i change the name of edit.php than works.
can anywhan explan to me what do i need to do to modify my modul or to do something with my problem.
thanks in advance !!
eidit file
<?php
Class Products_Edit_View extends Vtiger_Edit_View {
public function process(Vtiger_Request $request) {
$moduleName = $request->getModule();
$recordId = $request->get('record');
$recordModel = $this->record;
if(!$recordModel){
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
}
}
$baseCurrenctDetails = $recordModel->getBaseCurrencyDetails();
$viewer = $this->getViewer($request);
$viewer->assign('BASE_CURRENCY_NAME', 'curname' . $baseCurrenctDetails['currencyid']);
$viewer->assign('BASE_CURRENCY_ID', $baseCurrenctDetails['currencyid']);
$viewer->assign('BASE_CURRENCY_SYMBOL', $baseCurrenctDetails['symbol']);
$viewer->assign('TAXCLASS_DETAILS', $recordModel->getTaxClassDetails());
$viewer->assign('IMAGE_DETAILS', $recordModel->getImageDetails());
parent::process($request);
}
/**
* Function to get the list of Script models to be included
* @param Vtiger_Request $request
* @return <Array> - List of Vtiger_JsScript_Model instances
*/
function getHeaderScripts(Vtiger_Request $request) {
$headerScriptInstances = parent::getHeaderScripts($request);
$jsFileNames = array(
'libraries.jquery.multiplefileupload.jquery_MultiFile'
);
$jsScriptInstances = $this->checkAndConvertJsScripts($jsFileNames);
$headerScriptInstances = array_merge($headerScriptInstances, $jsScriptInstances);
return $headerScriptInstances;
}
}
| 0debug
|
static int enable_write_target(BDRVVVFATState *s)
{
BlockDriver *bdrv_qcow;
QEMUOptionParameter *options;
Error *local_err = NULL;
int ret;
int size = sector2cluster(s, s->sector_count);
s->used_clusters = calloc(size, 1);
array_init(&(s->commits), sizeof(commit_t));
s->qcow_filename = g_malloc(1024);
ret = get_tmp_filename(s->qcow_filename, 1024);
if (ret < 0) {
goto err;
}
bdrv_qcow = bdrv_find_format("qcow");
options = parse_option_parameters("", bdrv_qcow->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count * 512);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, "fat:");
ret = bdrv_create(bdrv_qcow, s->qcow_filename, options, &local_err);
if (ret < 0) {
qerror_report_err(local_err);
error_free(local_err);
goto err;
}
s->qcow = NULL;
ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, bdrv_qcow,
&local_err);
if (ret < 0) {
qerror_report_err(local_err);
error_free(local_err);
goto err;
}
#ifndef _WIN32
unlink(s->qcow_filename);
#endif
s->bs->backing_hd = bdrv_new("");
s->bs->backing_hd->drv = &vvfat_write_target;
s->bs->backing_hd->opaque = g_malloc(sizeof(void*));
*(void**)s->bs->backing_hd->opaque = s;
return 0;
err:
g_free(s->qcow_filename);
s->qcow_filename = NULL;
return ret;
}
| 1threat
|
Classes and Java Object help Me Understand my Assignment : 1. Create a class that contains an address book entry and name it AddressBook. The table below describes the information that an address book entry has.
Name, Address, Mobile Number, Email Address. here is my code which not sure if it's correct
public class AddressBook {
private String name;
private String address;
private int mobilenumber;
private String emailaddress;
public AddressBook(){
}
public AddressBook (String name, String address, int mobilenumber, String emailaddress){
this.name = name;
this.address = address;
this.mobilenumber = mobilenumber;
this.emailaddress = emailaddress;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getAddress(){
return address;
}
public void setAddress(String address){
this.address = address;
}
public int getMobileNumber(){
return mobilenumber;
}
public void setMobileNumber(int mobilenumber){
this.mobilenumber = mobilenumber;}
public String getEmailAddress(){
return emailaddress;
}
public void setEmailAddress(String emailaddress){
this.emailaddress = emailaddress;
}
public String toString(){
return "Name: " + name + "Address: " + address + "Mobile Number: " + mobilenumber + "Email Address: " + emailaddress;
}
}
2. Create a class and name it AddressBookTest which will contain the main method for implementation of the AddressBook class methods from #1 of this activity. Instantiate an array of AddressBook objects of 100 entries. Create a menu that will implement the following methods:
Main Menu
1. Add Entry
2. Delete Entry
3. View All Entries
4. Update An Entry
5. Exit
The program should loop back to the main menu after implementing a method chosen by the user. Note that options 2, 3 and 4 should not be implemented if no entry has been added yet. The program ends at the Exit option.
here my current code, I don't know how to delete, view all or update?
import java.util.Scanner;
public class AddressBookTest {
public static void main(String[] args) {
System.out.println("***PROGRAM INFORMATION*** \nNAME -> IS THE NAME OF THE PERSON IN THE ADDRESSBOOK \nADDRESS -> THE ADDRESS OF THE PERSON \nMOBILE NUMBER -> THE MOBILE NUMBER OF THE PERSON \nEMAIL ADDRESS -> THE EMAIL ADDRESS OF THE PERSON\n");
String input;
Scanner in = new Scanner(System.in);
AddressBook[] entry = new AddressBook[100];
do
{
System.out.println("Main Menu");
System.out.println("1. Add an Entry");
System.out.println("2. Delete an Entry");
System.out.println("3. View All Entries");
System.out.println("4. Update an Entry");
System.out.println("5. Exit");
System.out.print("Please enter Choices from 1 to 5: ");
input =(in.nextLine());
switch (input) {
case "1":
for(int i = 0; i < 100; i++){
entry[i] = new AddressBook();
System.out.println("***Adding Entry in Address Book***");
System.out.print("First Name: ");
String name = in.next();
System.out.print("Address: ");
String address = in.next();
System.out.print("Mobile Number: ");
int MN = in.nextInt();
System.out.print("Email Address: ");
String EA = in.next();
System.out.println("***Added " + (i+1) + " Entry/Entries\n");
}
break;
case "2":
break;
case "3":
break;
case "4":
break;
default:
break;
}
}while(!input.equals("5"));
System.out.println("***THANK YOU FOR USING MY PROGRAM...***");
}
}
| 0debug
|
Android String to double conversion : <p>When converting 0.0001 from string to double using Double.parseDouble(stringValue) returns 1.0E-4. How to get a 4 decimal placed double value as 0.0001. </p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.