problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static void vc1_sprite_flush(AVCodecContext *avctx)
{
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
AVFrame *f = &s->current_picture.f;
int plane, i;
if (f->data[0])
for (plane = 0; plane < (s->flags&CODEC_FLAG_GRAY ? 1 : 3); plane++)
for (i = 0; i < v->sprite_height>>!!plane; i++)
memset(f->data[plane] + i * f->linesize[plane],
plane ? 128 : 0, f->linesize[plane]);
}
| 1threat |
Displaying the contents of a textfile in the cmd by typing in the filename in a java program? : Write a program that reads in a file and displays its
contents. Get the input file name from the command line. For
example, if your program is in the file Display.class, you
would enter on the command line
java Display t1.txt
to display the file t1.txt.
how can this be done?
| 0debug |
Java null pointer Exception in android studio : <p>/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.anil.mynewapp, PID: 408
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.example.anil.mynewapp.SignupAuthentication.signupAuthentication(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)' on a null object reference
at com.example.anil.mynewapp.Second$1.onClick(Second.java:40)
at android.view.View.performClick(View.java:6294)</p>
| 0debug |
static void dwt_decode97_float(DWTContext *s, float *t)
{
int lev;
int w = s->linelen[s->ndeclevels - 1][0];
float *line = s->f_linebuf;
float *data = t;
line += 5;
for (lev = 0; lev < s->ndeclevels; lev++) {
int lh = s->linelen[lev][0],
lv = s->linelen[lev][1],
mh = s->mod[lev][0],
mv = s->mod[lev][1],
lp;
float *l;
l = line + mh;
for (lp = 0; lp < lv; lp++) {
int i, j = 0;
for (i = mh; i < lh; i += 2, j++)
l[i] = data[w * lp + j] * F_LFTG_K;
for (i = 1 - mh; i < lh; i += 2, j++)
l[i] = data[w * lp + j];
sr_1d97_float(line, mh, mh + lh);
for (i = 0; i < lh; i++)
data[w * lp + i] = l[i];
}
l = line + mv;
for (lp = 0; lp < lh; lp++) {
int i, j = 0;
for (i = mv; i < lv; i += 2, j++)
l[i] = data[w * j + lp] * F_LFTG_K;
for (i = 1 - mv; i < lv; i += 2, j++)
l[i] = data[w * j + lp];
sr_1d97_float(line, mv, mv + lv);
for (i = 0; i < lv; i++)
data[w * i + lp] = l[i];
}
}
}
| 1threat |
hwaddr ppc_hash32_get_phys_page_debug(CPUPPCState *env, target_ulong addr)
{
struct mmu_ctx_hash32 ctx;
if (unlikely(ppc_hash32_get_physical_address(env, &ctx, addr, 0, ACCESS_INT)
!= 0)) {
return -1;
}
return ctx.raddr & TARGET_PAGE_MASK;
}
| 1threat |
WAMP Server working with Laravel on Windows 7 Ultimate : <p>Hellow, My OS is Windows 7 Ultimate 64bit. I need install WAMP Server higher than php version 5.6.4 latest WAMP did not support with this OS. can you any body give me working download link to get suitable wamp server.</p>
| 0debug |
void swri_resample_dsp_x86_init(ResampleContext *c)
{
int av_unused mm_flags = av_get_cpu_flags();
switch(c->format){
case AV_SAMPLE_FMT_S16P:
if (ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL && mm_flags & AV_CPU_FLAG_MMX2) {
c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext
: ff_resample_common_int16_mmxext;
}
if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2
: ff_resample_common_int16_sse2;
}
if (HAVE_XOP_EXTERNAL && mm_flags & AV_CPU_FLAG_XOP) {
c->dsp.resample = c->linear ? ff_resample_linear_int16_xop
: ff_resample_common_int16_xop;
}
break;
case AV_SAMPLE_FMT_FLTP:
if (HAVE_SSE_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE) {
c->dsp.resample = c->linear ? ff_resample_linear_float_sse
: ff_resample_common_float_sse;
}
if (HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
c->dsp.resample = c->linear ? ff_resample_linear_float_avx
: ff_resample_common_float_avx;
}
if (HAVE_FMA3_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA3) {
c->dsp.resample = c->linear ? ff_resample_linear_float_fma3
: ff_resample_common_float_fma3;
}
if (HAVE_FMA4_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA4) {
c->dsp.resample = c->linear ? ff_resample_linear_float_fma4
: ff_resample_common_float_fma4;
}
break;
case AV_SAMPLE_FMT_DBLP:
if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
c->dsp.resample = c->linear ? ff_resample_linear_double_sse2
: ff_resample_common_double_sse2;
}
break;
}
}
| 1threat |
Set the precision for Decimal numbers in C# : <p>Is it possible to change the precision for Decimal numbers in C# globally ?</p>
<p>In TypeScript I am using the framework <a href="https://github.com/MikeMcl/decimal.js/" rel="noreferrer">Decimal.js</a>, where I can change the precision of the Decimal operations globally like so <code>Decimal.set({ precision: 15})</code>. This means that the operation will return at most 15 decimal digits.</p>
<ul>
<li><strong>TypeScript</strong>:the operation <code>5/3</code> returns <code>1.66666666666667</code></li>
<li><strong>C#</strong> the operation<code>5m/3m</code> returns <code>1.6666666666666666666666666667</code></li>
</ul>
<p>Is there some similar setting for Decimal values in C# ? How can I accomplish this in C# ?</p>
| 0debug |
static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
const uint8_t *buf, int buf_size)
{
int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int big_offsets, offset_size, is_8bit = 0;
const uint8_t *yuv_palette = 0;
uint8_t colormap[4] = { 0 }, alpha[256] = { 0 };
int date;
int i;
int is_menu = 0;
if (buf_size < 10)
return -1;
memset(sub_header, 0, sizeof(*sub_header));
if (AV_RB16(buf) == 0) {
big_offsets = 1;
offset_size = 4;
cmd_pos = 6;
} else {
big_offsets = 0;
offset_size = 2;
cmd_pos = 2;
}
cmd_pos = READ_OFFSET(buf + cmd_pos);
while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
date = AV_RB16(buf + cmd_pos);
next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
av_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
pos = cmd_pos + 2 + offset_size;
offset1 = -1;
offset2 = -1;
x1 = y1 = x2 = y2 = 0;
while (pos < buf_size) {
cmd = buf[pos++];
av_dlog(NULL, "cmd=%02x\n", cmd);
switch(cmd) {
case 0x00:
is_menu = 1;
break;
case 0x01:
sub_header->start_display_time = (date << 10) / 90;
break;
case 0x02:
sub_header->end_display_time = (date << 10) / 90;
break;
case 0x03:
if ((buf_size - pos) < 2)
goto fail;
colormap[3] = buf[pos] >> 4;
colormap[2] = buf[pos] & 0x0f;
colormap[1] = buf[pos + 1] >> 4;
colormap[0] = buf[pos + 1] & 0x0f;
pos += 2;
break;
case 0x04:
if ((buf_size - pos) < 2)
goto fail;
alpha[3] = buf[pos] >> 4;
alpha[2] = buf[pos] & 0x0f;
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((buf_size - pos) < 6)
goto fail;
x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
if (cmd & 0x80)
is_8bit = 1;
av_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
pos += 6;
break;
case 0x06:
if ((buf_size - pos) < 4)
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 4;
break;
case 0x86:
if ((buf_size - pos) < 8)
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 8;
break;
case 0x83:
if ((buf_size - pos) < 768)
goto fail;
yuv_palette = buf + pos;
pos += 768;
break;
case 0x84:
if ((buf_size - pos) < 256)
goto fail;
for (i = 0; i < 256; i++)
alpha[i] = 0xFF - buf[pos+i];
pos += 256;
break;
case 0xff:
goto the_end;
default:
av_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd);
goto the_end;
}
}
the_end:
if (offset1 >= 0) {
int w, h;
uint8_t *bitmap;
w = x2 - x1 + 1;
if (w < 0)
w = 0;
h = y2 - y1;
if (h < 0)
h = 0;
if (w > 0 && h > 0) {
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
bitmap = av_malloc(w * h);
sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
sub_header->num_rects = 1;
sub_header->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1, buf_size, is_8bit);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2, buf_size, is_8bit);
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
if (is_8bit) {
if (yuv_palette == 0)
goto fail;
sub_header->rects[0]->nb_colors = 256;
yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
} else {
sub_header->rects[0]->nb_colors = 4;
guess_palette(ctx,
(uint32_t*)sub_header->rects[0]->pict.data[1],
colormap, alpha, 0xffff00);
}
sub_header->rects[0]->x = x1;
sub_header->rects[0]->y = y1;
sub_header->rects[0]->w = w;
sub_header->rects[0]->h = h;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->pict.linesize[0] = w;
}
}
if (next_cmd_pos == cmd_pos)
break;
cmd_pos = next_cmd_pos;
}
if (sub_header->num_rects > 0)
return is_menu;
fail:
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
return -1;
}
| 1threat |
conditional statement (truth table) formula on excel : [can you help me? .Please help me to make the formula for if P then Q(p=>q)][1]
[1]: https://i.stack.imgur.com/8LC7R.png | 0debug |
c# File.Exists cannot find file : <p>How to correctly define if file exist or not?</p>
<pre><code>string FilePath = Path.Combine(dir, "www", "index.html");
if (!File.Exists(FilePath))
{
// get here anyway
}
string dir
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
</code></pre>
<p><code>File.Exists</code> return <code>false</code> anyway, whether the file exists or not.</p>
| 0debug |
For each and every element want to add unique content:url(); : <p>When I hover over word it should shows an appropriate pict as background</p>
<p>Considering to make it with js dataset but it still won't work</p>
<pre class="lang-html prettyprint-override"><code> <ul>
<li><a href="#">word</a></li>
<li><a href="#">word2</a></li>
<li><a href="#">word3</a></li>
<li><a href="#">word4</a></li>
</ul>
</code></pre>
<pre class="lang-css prettyprint-override"><code>
li a {
display: block;
text-decoration: none;
font-size: 3.3rem;
color: $dark-clr;
padding: 10px;
transition: all 0.4s ease;
font-weight: bold;
letter-spacing: 1.2px;
text-transform: capitalize;
&:hover {
color: $icons-clr;
}
}
li a::before {
content: url(/pict/1.jpg);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
z-index: -1;
transition: all 0.4s ease;
}
li a:hover::before {
opacity: 0.5;
}
</code></pre>
<p>Can't use attr src</p>
| 0debug |
Yii2/PHP/IIS7 - URL Rewrite and File Permissions (Pretty URL issue) : <p>I have a web.config file with the following text, although not relevant to my problem...</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Pretty URL">
<match url="." ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
</code></pre>
<p>Normally when I develop on my Windows machine the folder with my PHP source has permissions for all authenticated users and pretty URLs in my Yii2 website works without any issues.</p>
<p>Now, my next project requires me to deploy on a Windows machine where non-admin users will also use and I tested deploying a Yii2 website to a folder that gives IUSR user the ability to List, Read, & Execute files.</p>
<p>The website works, but the pretty url does not.</p>
<p>If I copy the folder contents to another location with regular authenticated user and SYSTEM permissions, it works as expected.</p>
<p>I think I am missing some permissions that will enable pretty URL to work properly with IIS7 URL Rewrite module, but not sure what.</p>
| 0debug |
Send object with axios get request : <p>I want to send a get request with an object. The object data will be used on the server to update session data. But the object doesn't seem to be sent correctly, because if I try to send it back to print it out, I just get:</p>
<p><code>" N; "</code></p>
<p>I can do it with jQuery like this and it works:</p>
<pre><code> $.get('/mysite/public/api/updatecart', { 'product': this.product }, data => {
console.log(data);
});
</code></pre>
<p>The object is sent back from server with laravel like this:</p>
<pre><code>public function updateCart(Request $request){
return serialize($request->product);
</code></pre>
<p>The same thing doesn't work with axios:</p>
<pre><code>axios.get('/api/updatecart', { 'product': this.product })
.then(response => {
console.log(response.data);
});
</code></pre>
<p>I set a default baseURL with axios so the url is different. It reaches the api endpoint correctly and the function returns what was sent in, which was apparently not the object. I only get "<strong>N;</strong> " as result.</p>
| 0debug |
Can I bundle the Visual Studio 2015 C++ Redistributable DLL's with my application? : <p>I've built a C++ application using Microsoft Visual Studio 2015 Community Edition. I'm using Advanced Installer to make sure that the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=48145">Visual C++ Redistributable for Visual Studio 2015</a> is a prerequisite.</p>
<p>However, the redistributable's installer isn't perfect. Some of my users have reported that the redistributable installer hangs, or it fails to install when it says it does, and then users get the "This program can't start because MSVCP140.dll is missing from your computer" error.</p>
<p>According to Microsoft, <a href="https://msdn.microsoft.com/en-us/library/ms235299.aspx">I can now package the redistributable DLLs along with my application, though they don't recommend it:</a></p>
<blockquote>
<p>To deploy redistributable Visual C++ files, you can use the Visual C++ Redistributable Packages (VCRedist_x86.exe, VCRedist_x64.exe, or VCRedist_arm.exe) that are included in Visual Studio. ... It's also possible to directly install redistributable Visual C++ DLLs in the application local folder, which is the folder that contains your executable application file. For servicing reasons, we do not recommend that you use this installation location.</p>
</blockquote>
<p>There are 4 files in <code>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64\Microsoft.VC140.CRT</code>. Does that mean I just need to copy them to my application's directory during the install process?</p>
<ul>
<li>MyApp.exe</li>
<li>concrt140.dll</li>
<li>msvcp140.dll</li>
<li>vccorlib140.dll</li>
<li>vcruntime140.dll</li>
</ul>
<p>Is this OK to do? Do I need to show a license? Why aren't more people doing this instead of requiring yet another preinstall of the redistributable?</p>
| 0debug |
Configuring GitKraken to push/fetch w/ Github : <p>I am trying to configure GitKraken with a particular repo I have on Github. As far as I can tell, once I give it my local project folder with the repo, it can see the remote. However, trying to push or pull gives me an error <code>Push/Fetch failed. could not connect to origin</code>.</p>
<p>It seems like it is an issue with authentication and SSH. I've tried to generate public/private keys in GitKrakens preferences auth page and add them to Github under the Github pane, but I get the same errors. </p>
<p>At this point I simply can't get things to work. I'm unfamiliar with the specifics of SSH. What is the issue here and how can I configure GitKraken to push/fetch with my upstream?</p>
| 0debug |
Lists in Python - Each array in different row : <p>how can I create a new list with the following format.</p>
<p>The 3 arrays inside each row should be in different rows.</p>
<pre><code>a= [['111,0.0,1', '111,1.27,2', '111,3.47,3'],
['222,0.0,1', '222,1.27,2', '222,3.47,3'],
['33,0.0,1', '33,1.27,2', '33,3.47,3'],
['44,0.0,1', '44,1.27,2', '4,3.47,3'],
['55,0.0,1', '55,1.27,2', '55,3.47,3']]
</code></pre>
<p>Final desired ouput:</p>
<pre><code> b=[['111,0.0,1',
'111,1.27,2',
'111,3.47,3',
'222,0.0,1',
'222,1.27,2',
'222,3.47,3',
'33,0.0,1',
'33,1.27,2',
'33,3.47,3',
'44,0.0,1',
'44,1.27,2',
'44,3.47,3',
'55,0.0,1',
'55,1.27,2',
'55,3.47,3']]
</code></pre>
| 0debug |
struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
int64_t whence, Error **errp)
{
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
GuestFileSeek *seek_data = NULL;
FILE *fh;
int ret;
if (!gfh) {
return NULL;
}
fh = gfh->fh;
ret = fseek(fh, offset, whence);
if (ret == -1) {
error_setg_errno(errp, errno, "failed to seek file");
if (errno == ESPIPE) {
gfh->state = RW_STATE_NEW;
}
} else {
seek_data = g_new0(GuestFileSeek, 1);
seek_data->position = ftell(fh);
seek_data->eof = feof(fh);
gfh->state = RW_STATE_NEW;
}
clearerr(fh);
return seek_data;
}
| 1threat |
Linux - How to Remove Git Credentials : <p>I ran</p>
<blockquote>
<p>git config credential.helper store</p>
</blockquote>
<p>and ran</p>
<blockquote>
<p>git push origin master</p>
</blockquote>
<p>where I entered my credentials and they were saved.</p>
<p>I read that they were stored in plaintext, and so now I want to remove my credentials from being saved and entered by default.</p>
<p>How can I do this?</p>
| 0debug |
static int movie_get_frame(AVFilterLink *outlink)
{
MovieContext *movie = outlink->src->priv;
AVPacket pkt;
int ret, frame_decoded;
AVStream *st = movie->format_ctx->streams[movie->stream_index];
if (movie->is_done == 1)
return 0;
while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
if (pkt.stream_index == movie->stream_index) {
avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
if (frame_decoded) {
movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE2, outlink->w, outlink->h);
av_image_copy(movie->picref->data, movie->picref->linesize,
(void*)movie->frame->data, movie->frame->linesize,
movie->picref->format, outlink->w, outlink->h);
avfilter_copy_frame_props(movie->picref, movie->frame);
movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
movie->frame->pkt_dts : movie->frame->pkt_pts;
if (!movie->frame->sample_aspect_ratio.num)
movie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio;
av_dlog(outlink->src,
"movie_get_frame(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n",
movie->file_name, movie->picref->pts,
(double)movie->picref->pts * av_q2d(st->time_base),
movie->picref->pos,
movie->picref->video->sample_aspect_ratio.num,
movie->picref->video->sample_aspect_ratio.den);
av_free_packet(&pkt);
return 0;
}
}
av_free_packet(&pkt);
}
if (ret == AVERROR_EOF)
movie->is_done = 1;
return ret;
}
| 1threat |
static bool cmd_smart(IDEState *s, uint8_t cmd)
{
int n;
if (s->hcyl != 0xc2 || s->lcyl != 0x4f) {
goto abort_cmd;
}
if (!s->smart_enabled && s->feature != SMART_ENABLE) {
goto abort_cmd;
}
switch (s->feature) {
case SMART_DISABLE:
s->smart_enabled = 0;
return true;
case SMART_ENABLE:
s->smart_enabled = 1;
return true;
case SMART_ATTR_AUTOSAVE:
switch (s->sector) {
case 0x00:
s->smart_autosave = 0;
break;
case 0xf1:
s->smart_autosave = 1;
break;
default:
goto abort_cmd;
}
return true;
case SMART_STATUS:
if (!s->smart_errors) {
s->hcyl = 0xc2;
s->lcyl = 0x4f;
} else {
s->hcyl = 0x2c;
s->lcyl = 0xf4;
}
return true;
case SMART_READ_THRESH:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
s->io_buffer[2 + 0 + (n * 12)] = smart_attributes[n][0];
s->io_buffer[2 + 1 + (n * 12)] = smart_attributes[n][11];
}
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
return false;
case SMART_READ_DATA:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
int i;
for (i = 0; i < 11; i++) {
s->io_buffer[2 + i + (n * 12)] = smart_attributes[n][i];
}
}
s->io_buffer[362] = 0x02 | (s->smart_autosave ? 0x80 : 0x00);
if (s->smart_selftest_count == 0) {
s->io_buffer[363] = 0;
} else {
s->io_buffer[363] =
s->smart_selftest_data[3 +
(s->smart_selftest_count - 1) *
24];
}
s->io_buffer[364] = 0x20;
s->io_buffer[365] = 0x01;
s->io_buffer[367] = (1 << 4 | 1 << 3 | 1);
s->io_buffer[368] = 0x03;
s->io_buffer[369] = 0x00;
s->io_buffer[370] = 0x01;
s->io_buffer[372] = 0x02;
s->io_buffer[373] = 0x36;
s->io_buffer[374] = 0x01;
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
return false;
case SMART_READ_LOG:
switch (s->sector) {
case 0x01:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
s->io_buffer[1] = 0x00;
s->io_buffer[452] = s->smart_errors & 0xff;
s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
case 0x06:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
if (s->smart_selftest_count == 0) {
s->io_buffer[508] = 0;
} else {
s->io_buffer[508] = s->smart_selftest_count;
for (n = 2; n < 506; n++) {
s->io_buffer[n] = s->smart_selftest_data[n];
}
}
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
return false;
case SMART_EXECUTE_OFFLINE:
switch (s->sector) {
case 0:
case 1:
case 2:
s->smart_selftest_count++;
if (s->smart_selftest_count > 21) {
s->smart_selftest_count = 0;
}
n = 2 + (s->smart_selftest_count - 1) * 24;
s->smart_selftest_data[n] = s->sector;
s->smart_selftest_data[n + 1] = 0x00;
s->smart_selftest_data[n + 2] = 0x34;
s->smart_selftest_data[n + 3] = 0x12;
break;
default:
goto abort_cmd;
}
return true;
}
abort_cmd:
ide_abort_command(s);
return true;
}
| 1threat |
Is there any way to reference other elements with Ruby's #map and #select? : I have an array of numbers, with I'd like to compare with its neighbours:
a = [1, 2, 3, 90, 4, 5, 6 ..., 10]
I'd like to remove any "too much different" items (ex.: 90).
Is there a "map / select with index", by which I could reference previous/next items ?
a.select { |i| i.too_much_different? i.prev, i.next } | 0debug |
Apple PushKit didUpdatePushCredentials is never called on iOS 9+ : <p>I am developing a VoIP app for iPhone. To receive calls, Apple developed PushKit so developers can send VoIP notifications using APNS.</p>
<p>Everything was working fine on iOS 8. When I updated to iOS 9, the <code>PKRegistryDelegate</code> does not fire the method <code>didUpdatePushCredentials</code> after registration.</p>
<p>Any ideas/suggestions?</p>
| 0debug |
Best way to get collect pounds or kilos in android from user? : <p>I am going to write a BMI app and I would like to allow the user to enter weight and height in either U.S. units or metric. I am not sure what is the best way to go about this because I would also like to be able for the user to save their preference. Should I use a switch widget? Thanks in advance. Also not sure if I am asking in the right place. </p>
| 0debug |
Incorrect items sizing in layer-list on pre-lollipop : <p>I have a layer-list </p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="2dp" android:left="2dp" android:bottom="2dp" android:top="2dp">
<bitmap
android:gravity="center"
android:src="@drawable/ic_menu_alert"/>
</item>
<item android:height="10dp" android:width="10dp" android:gravity="right|top">
<shape android:shape="oval">
<size android:height="10dp" android:width="10dp"/>
<solid android:color="@color/navigation_drawer_notification_red_color"/>
</shape>
</item>
</layer-list>
</code></pre>
<p>which shows this image </p>
<p><a href="https://i.stack.imgur.com/erKWX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/erKWX.png" alt="image"></a></p>
<p>On lollipop and above everything is fine but on pre-lollipop red circle lose all sizing and padding attributes and image looks like this</p>
<p><a href="https://i.stack.imgur.com/73XjX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/73XjX.png" alt="enter image description here"></a></p>
<p>I was looking for solution about 3 days and found nothing. I was trying to make my own toolbar layout and set to this imagebuuton scaleType="centerInside" but it didn't help. Could anyone help with this issue?</p>
<p>Thanks in advance!</p>
| 0debug |
static int v9fs_synth_opendir(FsContext *ctx,
V9fsPath *fs_path, V9fsFidOpenState *fs)
{
V9fsSynthOpenState *synth_open;
V9fsSynthNode *node = *(V9fsSynthNode **)fs_path->data;
synth_open = g_malloc(sizeof(*synth_open));
synth_open->node = node;
node->open_count++;
fs->private = synth_open;
return 0;
}
| 1threat |
static int escape124_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
int buf_size = avpkt->size;
Escape124Context *s = avctx->priv_data;
AVFrame *frame = data;
GetBitContext gb;
unsigned frame_flags, frame_size;
unsigned i;
unsigned superblock_index, cb_index = 1,
superblock_col_index = 0,
superblocks_per_row = avctx->width / 8, skip = -1;
uint16_t* old_frame_data, *new_frame_data;
unsigned old_stride, new_stride;
int ret;
if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
return ret;
if (!can_safely_read(&gb, 64))
return -1;
frame_flags = get_bits_long(&gb, 32);
frame_size = get_bits_long(&gb, 32);
if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
if (!s->frame.data[0])
return AVERROR_INVALIDDATA;
av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n");
*got_frame = 1;
if ((ret = av_frame_ref(frame, &s->frame)) < 0)
return ret;
return frame_size;
}
for (i = 0; i < 3; i++) {
if (frame_flags & (1 << (17 + i))) {
unsigned cb_depth, cb_size;
if (i == 2) {
cb_size = get_bits_long(&gb, 20);
cb_depth = av_log2(cb_size - 1) + 1;
} else {
cb_depth = get_bits(&gb, 4);
if (i == 0) {
cb_size = 1 << cb_depth;
} else {
cb_size = s->num_superblocks << cb_depth;
}
}
av_free(s->codebooks[i].blocks);
s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size);
if (!s->codebooks[i].blocks)
return -1;
}
}
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
new_frame_data = (uint16_t*)frame->data[0];
new_stride = frame->linesize[0] / 2;
old_frame_data = (uint16_t*)s->frame.data[0];
old_stride = s->frame.linesize[0] / 2;
for (superblock_index = 0; superblock_index < s->num_superblocks;
superblock_index++) {
MacroBlock mb;
SuperBlock sb;
unsigned multi_mask = 0;
if (skip == -1) {
skip = decode_skip_count(&gb);
}
if (skip) {
copy_superblock(new_frame_data, new_stride,
old_frame_data, old_stride);
} else {
copy_superblock(sb.pixels, 8,
old_frame_data, old_stride);
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned mask;
mb = decode_macroblock(s, &gb, &cb_index, superblock_index);
mask = get_bits(&gb, 16);
multi_mask |= mask;
for (i = 0; i < 16; i++) {
if (mask & mask_matrix[i]) {
insert_mb_into_sb(&sb, mb, i);
}
}
}
if (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned inv_mask = get_bits(&gb, 4);
for (i = 0; i < 4; i++) {
if (inv_mask & (1 << i)) {
multi_mask ^= 0xF << i*4;
} else {
multi_mask ^= get_bits(&gb, 4) << i*4;
}
}
for (i = 0; i < 16; i++) {
if (multi_mask & mask_matrix[i]) {
if (!can_safely_read(&gb, 1))
break;
mb = decode_macroblock(s, &gb, &cb_index,
superblock_index);
insert_mb_into_sb(&sb, mb, i);
}
}
} else if (frame_flags & (1 << 16)) {
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
mb = decode_macroblock(s, &gb, &cb_index, superblock_index);
insert_mb_into_sb(&sb, mb, get_bits(&gb, 4));
}
}
copy_superblock(new_frame_data, new_stride, sb.pixels, 8);
}
superblock_col_index++;
new_frame_data += 8;
if (old_frame_data)
old_frame_data += 8;
if (superblock_col_index == superblocks_per_row) {
new_frame_data += new_stride * 8 - superblocks_per_row * 8;
if (old_frame_data)
old_frame_data += old_stride * 8 - superblocks_per_row * 8;
superblock_col_index = 0;
}
skip--;
}
av_log(avctx, AV_LOG_DEBUG,
"Escape sizes: %i, %i, %i\n",
frame_size, buf_size, get_bits_count(&gb) / 8);
av_frame_unref(&s->frame);
if ((ret = av_frame_ref(&s->frame, frame)) < 0)
return ret;
*got_frame = 1;
return frame_size;
}
| 1threat |
Navigation Drawer item remains selected Android : <p>My navigation drawer keeps showing the last selected item.Is there any way to remove it.I want that if the user is at Home page, the navigation drawer items should be non-highlighted.</p>
<p>I have tried </p>
<pre><code>drawer.setSelected(false);
</code></pre>
<p>in onResume(). But it doesn't help.</p>
<p>Please refer the attached screenshot, it will help understand.</p>
<p><a href="https://i.stack.imgur.com/siTn1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/siTn1.jpg" alt="See the seetings options is highlighted even when I have come back from Settings activity"></a></p>
| 0debug |
hello can soomebody help me with timing events in my simon memory game : http://codepen.io/furball/pen/egGPeZ?editors=0010hello can soomebody help me with timing events in my simon memory game
I''ve tried using setTimeout but i dont know which events to time and how much time to set so that theyre distinguishable.
$('#play').click(function(){
console.log('start');
generate();
setTimeout(game,1000);
levelUp();});
Please refer to my pen | 0debug |
static int object_create(QemuOpts *opts, void *opaque)
{
const char *type = qemu_opt_get(opts, "qom-type");
const char *id = qemu_opts_id(opts);
Object *obj;
g_assert(type != NULL);
if (id == NULL) {
qerror_report(QERR_MISSING_PARAMETER, "id");
return -1;
}
obj = object_new(type);
if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) {
return -1;
}
object_property_add_child(container_get(object_get_root(), "/objects"),
id, obj, NULL);
return 0;
}
| 1threat |
Procedure is not working in the way it should? : <p>I've been told to write a procedure to find the last position of a substring in a string. It seems to be outputing false information and I'm not sure where I've gone wrong.</p>
<p>Can anyone help?</p>
<pre><code>def find_last(s, c):
last_position = -1
while s.find(c) != -1:
last_position = s.find(c)
s = s[last_position + len(c):]
return last_position
print(find_last('aaaa', 'a')) # returns 0, but the last position is 3
</code></pre>
| 0debug |
Ruby Prime number Sum : num = 1
last = 100
while (num <= last)
condition = true
x = 2
while (x <= num / 2)
if (num % x == 0)
condition = false
break
end
x = x + 1
end
if condition
puts num.to_s
end
num = num + 1
end
I am trying to make a sum of the first prime numbers. I found a way of showing the first 100, but I don't know how to get rid of 1 and how to make a sum with the numbers. I was thinking about storing them into an array, but I can not figure it out how. Thank you!
| 0debug |
static int serial_load(QEMUFile *f, void *opaque, int version_id)
{
SerialState *s = opaque;
if(version_id > 2)
return -EINVAL;
if (version_id >= 2)
qemu_get_be16s(f, &s->divider);
else
s->divider = qemu_get_byte(f);
qemu_get_8s(f,&s->rbr);
qemu_get_8s(f,&s->ier);
qemu_get_8s(f,&s->iir);
qemu_get_8s(f,&s->lcr);
qemu_get_8s(f,&s->mcr);
qemu_get_8s(f,&s->lsr);
qemu_get_8s(f,&s->msr);
qemu_get_8s(f,&s->scr);
return 0;
}
| 1threat |
void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext* dsp)
{
c->rv34_inv_transform = ff_rv34_inv_transform_noround_neon;
c->rv34_inv_transform_dc = ff_rv34_inv_transform_noround_dc_neon;
c->rv34_idct_add = ff_rv34_idct_add_neon;
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_neon;
}
| 1threat |
is sql server create dynamic table valued function? : Can any one explain this T-sql ode :
select * from (select getdate() ) as func(param)
you can copy & paste the code, and then run it | 0debug |
Retrofit 2.0 - How to get response body for 400 Bad Request error? : <p>So when I make a POST API call to my server, I get a 400 Bad Request error with JSON response.</p>
<pre><code>{
"userMessage": "Blah",
"internalMessage": "Bad Request blah blah",
"errorCode": 1
}
</code></pre>
<p>I call it by </p>
<pre><code>Call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
//AA
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
//BB
}
}
</code></pre>
<p>However the problem is that once I get the response, onFailure() is invoke so that //BB is called. Here, I have no way to access the JSON response.
When I log the api request and response, it doesn't show JSON response at all. And Throwable t is IOException. However, strangely, when I make the same call on Postman, it does return the expected JSON response with 400 error code. </p>
<p>So my question is how can I get the json response when I get 400 Bad Request error? Should I add something to okhttpclient?</p>
<p>Thanks</p>
| 0debug |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
Sorting Excel VBA Macro : I'm looking for sorting a column in excel using a macro based on following criteria. I'm giving a sample below. Can you please let me know an algorithm to sort accordingly.
[Sort Sample][1]
[1]: https://i.stack.imgur.com/FPvXQ.jpg | 0debug |
int decode_luma_intra_block(VC9Context *v, int mquant)
{
GetBitContext *gb = &v->s.gb;
int dcdiff;
dcdiff = get_vlc2(gb, v->luma_dc_vlc->table,
DC_VLC_BITS, 2);
if (dcdiff)
{
if (dcdiff == 119 )
{
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
}
else
{
if (mquant == 1)
dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
dcdiff = -dcdiff;
}
return 0;
}
| 1threat |
Can this code be realigned? : <p>I have this code for a falling petal effect. The original code is not mine, I know nothing about coding beyond how to maybe change a few things like image (as I've done with this version of the code), but I'm wondering if it's possible to make it appear to fall on only the left side of the page.</p>
<p>I'm extremely ignorant to this sort of thing, I've tried looking for an answer but I'm not even sure <em>how</em> to ask the question, so my best hope is that someone will understand what I'm looking for and be able to answer. I've played with it a little, but other than figuring out how to change the fall speed, I don't know if I'll be able to do it just fiddling. I am a little afraid it'd need to be completely re-written but for now, any help would be appreciated. (Original code is still credited and links back to the original on the tutorial blog it came from, I've removed it as it's not relevant to this question but can provide it if needed for whatever reason). </p>
<pre><code><script>if(typeof jQuery=='undefined'){document.write('<'+'script');document.write(' language="javascript"');document.write(' type="text/javascript"');document.write(' src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">');document.write('</'+'script'+'>')}</script><script>if(!image_urls){var image_urls=Array()}if(!flash_urls){var flash_urls=Array()}image_urls['rain1']="https://2.bp.blogspot.com/-LVX2LSAy4zM/VuyuSSQGKoI/AAAAAAAAAHk/0xFc8xRWzh8rUrbWaxkLaXFiSM6D46fiA/s1600/imageedit_2_9597694661.png";image_urls['rain2']="https://2.bp.blogspot.com/-LVX2LSAy4zM/VuyuSSQGKoI/AAAAAAAAAHk/0xFc8xRWzh8rUrbWaxkLaXFiSM6D46fiA/s1600/imageedit_2_9597694661.png";image_urls['rain3']="https://2.bp.blogspot.com/-LVX2LSAy4zM/VuyuSSQGKoI/AAAAAAAAAHk/0xFc8xRWzh8rUrbWaxkLaXFiSM6D46fiA/s1600/imageedit_2_9597694661.png";image_urls['rain4']="https://2.bp.blogspot.com/-LVX2LSAy4zM/VuyuSSQGKoI/AAAAAAAAAHk/0xFc8xRWzh8rUrbWaxkLaXFiSM6D46fiA/s1600/imageedit_2_9597694661.png";$(document).ready(function(){var c=$(window).width();var d=$(window).height();var e=function(a,b){return Math.round(a+(Math.random()*(b-a)))};var f=function(a){setTimeout(function(){a.css({left:e(0,c)+'px',top:'-30px',display:'block',opacity:'0.'+e(10,100)}).animate({top:(d-10)+'px'},e(7500,8000),function(){$(this).fadeOut('slow',function(){f(a)})})},e(1,8000))};$('<div></div>').attr('id','rainDiv')
.css({position:'fixed',width:(c-20)+'px',height:'1px',left:'0px',top:'-5px',display:'block'}).appendTo('body');for(var i=1;i<=20;i++){var g=$('<img/>').attr('src',image_urls['rain'+e(1,4)])
.css({position:'absolute',left:e(0,c)+'px',top:'-30px',display:'block',opacity:'0.'+e(10,100),'margin-left':0}).addClass('rainDrop').appendTo('#rainDiv');f(g);g=null};var h=0;var j=0;$(window).resize(function(){c=$(window).width();d=$(window).height()})});</script>
</code></pre>
| 0debug |
Angular pass resolve data to child-routes : <p>i have the following Component Structure</p>
<ul>
<li>project
<ul>
<li>edit-project</li>
<li>sub-ressource1</li>
<li>sub-ressource2</li>
<li>sub-ressource3</li>
</ul></li>
</ul>
<p>So my routing looks like this:</p>
<pre><code>const childroutes = [
{
path: '',
children: [
{ path: 'edit', component: EditProjectComponent},
{ path: 'subres1', component: Subres1Component},
{ path: 'subres2', component: Subres2Component},
{ path: 'subres3', component: Subres3Component},
{ path: 'subres4', component: Subres4Component}
]
}
]
{
path: 'project/:projectId',
component: ProjectDetailComponent,
children: childroutes,
resolve: { project: ProjectResolver} /** resolve Project from ProjectService **/
}
</code></pre>
<p>As you can see i resolve my Projectdata from a service and can access them in ProjectDetailComponent via</p>
<pre><code>this.route.snapshot.data
</code></pre>
<p>So now the question is, how can i pass the data resolved in "EditProjectComponent" to all its childroutes components?</p>
<p>I now that i could do the following to resolve project-data in childcomponents:</p>
<pre><code>const childroutes = [
{
path: '',
children: [
{ path: 'edit', component: EditProjectComponent,resolve: { project: ProjectResolver}},
{ path: 'subres1', component: Subres1Component,resolve: { project: ProjectResolver}},
{ path: 'subres2', component: Subres2Component,resolve: { project: ProjectResolver}},
{ path: 'subres3', component: Subres3Component,resolve: { project: ProjectResolver}},
{ path: 'subres4', component: Subres4Component,resolve: { project: ProjectResolver}}
]
}
]
</code></pre>
<p>But this seems ugly and wrong.</p>
| 0debug |
float32 float32_round_to_int( float32 a STATUS_PARAM)
{
flag aSign;
int16 aExp;
bits32 lastBitMask, roundBitsMask;
int8 roundingMode;
float32 z;
aExp = extractFloat32Exp( a );
if ( 0x96 <= aExp ) {
if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {
return propagateFloat32NaN( a, a STATUS_VAR );
}
return a;
}
if ( aExp <= 0x7E ) {
if ( (bits32) ( a<<1 ) == 0 ) return a;
STATUS(float_exception_flags) |= float_flag_inexact;
aSign = extractFloat32Sign( a );
switch ( STATUS(float_rounding_mode) ) {
case float_round_nearest_even:
if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
return packFloat32( aSign, 0x7F, 0 );
}
break;
case float_round_down:
return aSign ? 0xBF800000 : 0;
case float_round_up:
return aSign ? 0x80000000 : 0x3F800000;
}
return packFloat32( aSign, 0, 0 );
}
lastBitMask = 1;
lastBitMask <<= 0x96 - aExp;
roundBitsMask = lastBitMask - 1;
z = a;
roundingMode = STATUS(float_rounding_mode);
if ( roundingMode == float_round_nearest_even ) {
z += lastBitMask>>1;
if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
}
else if ( roundingMode != float_round_to_zero ) {
if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) {
z += roundBitsMask;
}
}
z &= ~ roundBitsMask;
if ( z != a ) STATUS(float_exception_flags) |= float_flag_inexact;
return z;
}
| 1threat |
static void iter_func(QObject *obj, void *opaque)
{
QInt *qi;
fail_unless(opaque == NULL);
qi = qobject_to_qint(obj);
fail_unless(qi != NULL);
fail_unless((qint_get_int(qi) >= 0) && (qint_get_int(qi) <= iter_max));
iter_called++;
}
| 1threat |
BlockJobInfo *block_job_query(BlockJob *job)
{
BlockJobInfo *info = g_new0(BlockJobInfo, 1);
info->type = g_strdup(BlockJobType_lookup[job->driver->job_type]);
info->device = g_strdup(bdrv_get_device_name(job->bs));
info->len = job->len;
info->busy = job->busy;
info->paused = job->paused;
info->offset = job->offset;
info->speed = job->speed;
info->io_status = job->iostatus;
info->ready = job->ready;
return info;
}
| 1threat |
How to add up items in check boxes in c#? : So I'm making a coffee shop (don't ask why :D) and I have 3 items right now with prices https://gyazo.com/8944d8097223667d44095b1c5db8ceeb and I made a list box which lists the ticked boxes. Now I want to create a label or something which says "Total cost:__" and the prices added together. Since I'm quite new to c#, I'm stuck on this and need some help. I don't know what code to paste in to here, so tell me the code you want to see and I'll reply ASAP! | 0debug |
Asm: Moving assembly instructions to specific address : <p>Well, I am trying to find an assembly instruction that moves whole instructions to a specific address(which is independent of the size of the instruction). If there is no such instruction, could anybody give me some ideas on how multithreading could be achieved without system calls or other software? In other words, let's suppose that I am making my own operating system, how can I enable multithreading with efficient code in assembly?</p>
| 0debug |
how can i fix SyntaxError: cannot use absolute path on element : I'm getting the error when i define the showing variable.
def crawl(name, state, page=1):
params={'search_terms': name, 'geo_location_terms': state, 'page': page}
data = requests.get(SEARCH_URL, params=params).text
tree = html.fromstring(data)
for items in tree.xpath("//div[@class='info']"):
name = items.findtext(".//span[@itemprop='name']")
address = items.findtext(".//span[@class='street-address']")
phone = items.findtext(".//div[@itemprop='telephone']")
showing = items.findtext("//*[@id='main-content']/div[2]/div[4]/p/text()")
I'm sure this is easy to fix but i'm new to `xpath` expressions.
Any help would be appreciated
| 0debug |
Android Emulator inside Android Studio too Slow : <p>The Android Emulator (inside Android Studio) that we use to run our developing app is too slow and as a consequence of that, it is very difficult for us to test the app every time, when we even make slightest changes to it.</p>
<p>We have changed some configurations of Emulator, updated the RAM to even 12 GB but there is only slightest change in performance in doing all those things. Can anyone help us in this regard?</p>
| 0debug |
Brace-or-equal-initializers default value in child doesn't seem work : <p>I try understand what's going on here, why <code>bar</code> doesn't have default value for <code>name</code> property</p>
<pre><code>#include <string>
struct Foo
{
std::string name = "foo default value";
std::size_t number = 23;
};
struct Bar : public Foo
{
std::string name = "here i want other value";
};
int main(int argc, char * argv[])
{
Foo foo;
std::cout<<"name="<< foo.name << " number=" << foo.number << std::endl;
Foo * bar = &Bar();
std::cout<<"name="<< bar->name << " number=" << bar->number << std::endl;
return 0;
}
</code></pre>
<p>output:</p>
<pre><code>name=foo default value number=23
name= number=23 // why name is empty string?
</code></pre>
<p>I assume that's default generated constructos are involed in final result. But can't get it right in my mind. Can someone explain what sorcery compiler does here?</p>
| 0debug |
Using HMAC SHA256 in Ruby : <p>I'm trying to apply HMAC-SHA256 for generate a key for an Rest API.</p>
<p>I'm doing something like this:</p>
<pre><code>def generateTransactionHash(stringToHash)
key = '123'
data = 'stringToHash'
digest = OpenSSL::Digest.new('sha256')
hmac = OpenSSL::HMAC.digest(digest, key, data)
puts hmac
end
</code></pre>
<p>The output of this is always this: (if I put '12345' as parameter or 'HUSYED815X', I do get the same)</p>
<pre><code>ۯw/{o���p�T����:��a�h��E|q
</code></pre>
<p>The API is not working because of this... Can some one help me with that?</p>
| 0debug |
How can I successfully store and load data from a game character? I'm not sure what's wrong : I was wrote a script that combines whale characters to create a new character. However, it is difficult to save and load data from a list of names, levels and locations of the newly created characters.
Whale data does not seem to be stored and loaded when the game is played.
I'd really thanks it if you could tell me where's wrong.
If you can tell me how to modify it, I am more grateful
I don't know if it's right to post it like this because it's my first question.
Thank you for reading this.
using system;
using System.Collections;
using System.Collections.General;
using system.IO;
using LitJson;
using UnityEngine;
using Random = UnityEngine.Random;
[System.Serializable]
Public class WhaleData
{
Public in dataLevel{get; set;// whale level
public Vector3 dataMousePosition{get; set;//the whale location
public string dataName{get; set;} //whale name
}
Public class Whale: MonoBehaviour
{
public int level;
Private pool isDrag;
Public GameObject NextPrepab;
Private Vector3 mousePosition;
Public WhaleData whaleData;
Private List[WhaleData] WhaleDatas = new List[WhaleData]();
private pool IsSave; //bool value to check for stored data
void start()
{
IsSave = PlayerPrefs.HasKey ("0_name"); //saved_level Check if a key value named //saved_level exists
//initialize all data values if no save data exists
If (!IsSave)
{
Debug.Log ("No data stored).");
PlayerPrefs.DeleteAll();
}
//recall value if save data exists
else
{
Debug.Log ("Stored Data").");
LoadData();
}
}
Private void Update ()
{
SaveData();
LoadData();
}
private void onMouseDown()
{
isDrag = true;
}
private void OnMouseDrag()
{
if (isDrag)
{
mousePosition.x = Input.mousePosition.x;
mousePosition.y = input.mousePositionY;
mousePosition.z = 10;
//change the mouse coordinates to the screen to world and set the position of this object
gameObject.transform.position = Camera.main.ScreenToWorldPoint(mousePosition);
// store the location of the whale in the whalData.dataMousePosition= gameObject.transform.position; //
}
}
private void onMouseUp()
{
//OverlapSphere : Return from the specified location to the collider array in contact within range
var colliders = Physics.OverlapSphere (transform.position, 0.1f);
foreach (var col in colliders) // arrangement of surrounding contacts
{
If (name!= col. gameObject.name) //if the name is different, go
{
If (level==col.gameObject.GetComponent[Whale>().level) //If the level of contact with the level stored in me is the same,
{
whatData.dataLevel = col.gameObject.GetComponent[Whale>().level; // store the level of the whale in the whalData class
var newWhale = Instantiate(NextPrepab, transform.position, quaternion.identity);
newWhale.name = Random.Range (0f, 200f).ToString(); //name is random.
dateData.dataName = name;// store the name of the whale in the whalData class
SaveData();
print(col.gameObject.name);
print(gameObject.name);
whatDatas.Add(whaleData);
Destroy (col.gameObject);
Destroy (gameObject);
// delete if there is any whale information with the same name as Whale's name that will disappear from the dateDatas list (use a simple calculation expression of the unknown method)
if (whaleDatas.Find(whaleData=>whaleData.dataName=colgameObject.GetComponent[Whale>(.name).dataName==colgameObject.GetComponent[Whale>(.name)
{
whaleDatasRemove (col.gameObject.GetComponent[Whale>(whaleData));
Destroy (col.gameObject);
Destroy (gameObject);
}
else
{
break;
}
break;
}
}
}
isDrag = false;
}
Public static void setVector3 (string key, Vector3 value)
{
PlayerPrefs.SetFloat (key + "X", value.x);
PlayerPrefs.SetFloat (key + "Y", value.y);
PlayerPrefs.SetFloat (key + "Z", value.z);
}
Public static Vector3 GetVector3 (string key)
{
Vector3 v3 = Vector3.zero;
v3.x = PlayerPrefs.GetFloat (key + "X");
v3.y = PlayerPrefs.GetFloat (key + "Y");
v3.z = PlayerPrefs.GetFloat (key + "Z");
return v3;
}
private void saveData()
{
for (int i=0; i <whaleDatas.Count; i++)
{
PlayerPrefs.SetString(i+"_name",whaleDatas[i‐dataName));
PlayerPrefs.SetInt(i+"_level",whaleDatas[i‐dataLevel));
Vector3 value = whatDatas[i].dataMousePosition;
string key = i + "_position";
SetVector3 (key,value);
PlayerPrefs.Save();
Debug.Log ("Saved");
}
}
private void LoadData()
{
for(int i=0; i <whaleDatas.Count; i++)
{
whaleDatas[i].dataName = PlayerPrefs.GetString(i+"_name");
whaleDatas[i].dataLevel = PlayerPrefs.GetInt(i+"_level");
string key = i + "_position";
whaleDatas[i].dataMousePosition = GetVector3(key);
}
}
} | 0debug |
Insert 3d objects (.obj) in WPF project : <p>I'm beginer in WPF, and i need to insert 3d objects (.obj) in the project and do some animations on theme.
I use Visual Studio 2015.</p>
<p>Can you tell me the best practice?
Thank you.</p>
| 0debug |
i can add a data and i can only see through phpmyadmin. : <p>here is the front end of it.
and this is the back end
<a href="http://localhost/phpmyadmin/#PMAURL-6:sql.php?db=bims&table=personal_info&server=1&target=&token=8254c6ededd52ca5284d30cf084621b9" rel="nofollow">http://localhost/phpmyadmin/#PMAURL-6:sql.php?db=bims&table=personal_info&server=1&target=&token=8254c6ededd52ca5284d30cf084621b9</a></p>
| 0debug |
How to convert Any? to Data in swift : <p>I need to convert from type <code>Any?</code> to <code>Data</code>. </p>
<p>something like this</p>
<pre><code>func getItem(item:Any?) {
let data = convertToData(item)
}
</code></pre>
| 0debug |
Does Firefox have an offline throttling mode/disable network feature? : <p>I'm doing some front end work and I need to test how the program reacts when it loses a network connection. Firefox has a "Work offline" setting but that drops the connection for every tab -- I only want to disable the network connection for a single tab. Chrome has this with an "Offline" checkbox in the Network tab of the devtools that makes this really convenient.</p>
<p>This is what this feature looks like in Chrome:</p>
<p><a href="https://i.stack.imgur.com/CkbNl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CkbNl.png" alt="Chrome screenshot"></a></p>
| 0debug |
void qemu_iovec_concat_iov(QEMUIOVector *dst,
struct iovec *src_iov, unsigned int src_cnt,
size_t soffset, size_t sbytes)
{
int i;
size_t done;
assert(dst->nalloc != -1);
for (i = 0, done = 0; done < sbytes && i < src_cnt; i++) {
if (soffset < src_iov[i].iov_len) {
size_t len = MIN(src_iov[i].iov_len - soffset, sbytes - done);
qemu_iovec_add(dst, src_iov[i].iov_base + soffset, len);
done += len;
soffset = 0;
} else {
soffset -= src_iov[i].iov_len;
assert(soffset == 0); | 1threat |
Delphi 10.How to format date time? : I have a question,how can I format this date-time in delphi `WED 16/11/2016 IT 15:26`.This is a value from XML and i want just 16/11/2016 15:26.Thank you. | 0debug |
Bypass Android's hidden API restrictions : <p>Starting with Android Pie, <a href="https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces" rel="noreferrer">access to certain hidden classes, methods and fields was restricted</a>. Before Pie, it was pretty easy to use these hidden non-SDK components by simply using reflection. </p>
<p>Now, however, apps targeting API 28 (Pie) or later will be met with ClassNotFoundException, NoSuchMethodError or NoSuchFieldException when trying to access components such as <code>Activity#createDialog()</code>. For most people this is fine, but as someone who likes to hack around the API, it can make things difficult.</p>
<p>How can I work around these restrictions?</p>
| 0debug |
What is the difference between initState and a class constructor in Flutter? : <p>I read the documentation but it is not clear.</p>
<p>It states "[initState is] Called when this object is inserted into the tree."</p>
<p>When a widget is inserted into a tree, it means it has been created, which means the class constructor is called. What is the purpose of init? Isn't the constructor's purpose to initialize the class instance?</p>
<p>Thank you guys for your time.</p>
| 0debug |
static void device_set_bootindex(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
BootIndexProperty *prop = opaque;
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(v, name, &boot_index, &local_err);
if (local_err) {
goto out;
}
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
*prop->bootindex = boot_index;
add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix);
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| 1threat |
int configure_filtergraph(FilterGraph *fg)
{
AVFilterInOut *inputs, *outputs, *cur;
int ret, i, simple = !fg->graph_desc;
const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter :
fg->graph_desc;
avfilter_graph_free(&fg->graph);
if (!(fg->graph = avfilter_graph_alloc()))
return AVERROR(ENOMEM);
if (simple) {
OutputStream *ost = fg->outputs[0]->ost;
char args[512];
AVDictionaryEntry *e = NULL;
snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
fg->graph->scale_sws_opts = av_strdup(args);
args[0] = '\0';
while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e,
AV_DICT_IGNORE_SUFFIX))) {
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
}
if (strlen(args))
args[strlen(args) - 1] = '\0';
fg->graph->resample_lavr_opts = av_strdup(args);
}
if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
return ret;
if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' does not have "
"exactly one input and output.\n", graph_desc);
return AVERROR(EINVAL);
}
for (cur = inputs, i = 0; cur; cur = cur->next, i++)
if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0)
return ret;
avfilter_inout_free(&inputs);
for (cur = outputs, i = 0; cur; cur = cur->next, i++)
configure_output_filter(fg, fg->outputs[i], cur);
avfilter_inout_free(&outputs);
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
return ret;
return 0;
}
| 1threat |
exception 'NSInvalidArgumentException' NSHealthUpdateUsageDescritption : <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSHealthUpdateUsageDescription must be set in the app's Info.plist in order to request write authorization.'</p>
<p>Info.plist has this entry</p>
<pre><code><key>NSHealthShareUsageDescription</key>
<string>some string value stating the reason</string>
</code></pre>
| 0debug |
TaskStackBuilder.addParentStack not working when I was building a notification : <p>I did everything as the official docs writes.But when i navigate backwards,the MainActivity(parent) doesn't open.Instead, the application closes.</p>
<p><strong>here is my code:</strong></p>
<pre><code>Intent resultIntent = new Intent(context, TestActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(TestActivity.class);
stackBuilder.addNextIntent(resultIntent);
</code></pre>
<p><strong>the manifest is as below:</strong></p>
<pre><code> <activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TestActivity"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Main2Activity" />
</activity>
</code></pre>
<p>Thank you.</p>
| 0debug |
android studio logcat error ... how to resolve the following error : Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init> | 0debug |
static void select_vgahw (const char *p)
{
const char *opts;
vga_interface_type = VGA_NONE;
if (strstart(p, "std", &opts)) {
if (vga_available()) {
vga_interface_type = VGA_STD;
fprintf(stderr, "Error: standard VGA not available\n");
exit(0);
} else if (strstart(p, "cirrus", &opts)) {
if (cirrus_vga_available()) {
vga_interface_type = VGA_CIRRUS;
fprintf(stderr, "Error: Cirrus VGA not available\n");
exit(0);
} else if (strstart(p, "vmware", &opts)) {
if (vmware_vga_available()) {
vga_interface_type = VGA_VMWARE;
fprintf(stderr, "Error: VMWare SVGA not available\n");
exit(0);
} else if (strstart(p, "xenfb", &opts)) {
vga_interface_type = VGA_XENFB;
} else if (strstart(p, "qxl", &opts)) {
vga_interface_type = VGA_QXL;
} else if (!strstart(p, "none", &opts)) {
invalid_vga:
fprintf(stderr, "Unknown vga type: %s\n", p);
exit(1);
const char *nextopt;
if (strstart(opts, ",retrace=", &nextopt)) {
if (strstart(opts, "dumb", &nextopt))
vga_retrace_method = VGA_RETRACE_DUMB;
else if (strstart(opts, "precise", &nextopt))
vga_retrace_method = VGA_RETRACE_PRECISE;
else goto invalid_vga;
} else goto invalid_vga; | 1threat |
void stream_start(BlockDriverState *bs, BlockDriverState *base,
const char *base_id, BlockDriverCompletionFunc *cb,
void *opaque, Error **errp)
{
StreamBlockJob *s;
Coroutine *co;
s = block_job_create(&stream_job_type, bs, cb, opaque, errp);
if (!s) {
return;
}
s->base = base;
if (base_id) {
pstrcpy(s->backing_file_id, sizeof(s->backing_file_id), base_id);
}
co = qemu_coroutine_create(stream_run);
trace_stream_start(bs, base, s, co, opaque);
qemu_coroutine_enter(co, s);
}
| 1threat |
Why is this one line crashing my script? : I have a script that works fine when in a .pyw, but when converted to an .exe, I've found that this one single line seems to crash the program:
`firstplan = subprocess.check_output(["powercfg", "-list"], shell=True ).split('\n')[3]`
Does anybody have any idea why? If I comment it out the program doesn't crash. I have two other very similar lines. | 0debug |
Revert a merge commit from a protected branch on GitHub.com : <p>We have protected our develop branch on GitHub so that nobody downstream can push their commit directly. The commits need to go through specific feature branch and get merged through a pull request.</p>
<p>There came a scenario where a feature branch is merged into the develop branch (after proper review and changes) and we are required to revert it later (maybe due to changes in requirements). If I try to revert the merge commit downstream, it will not allow me to push, since the branch is protected. I remember GitHub providing revert button when we merge the branch. But somehow I am not able to see (or find) the button now. We needed to revert the commit on priority so we removed the protection from the develop branch for the time being and pushed the revert commit (ugliest hack). </p>
<p>Are there any other better alternative for reverting a commit from protected branch? Maybe I am missing or misunderstood some GitHub features. </p>
<p>One more scenario is, what if I have deleted the branch from GitHub after I have merged, how would I revert it then?</p>
| 0debug |
Angular 4 display current time : <h1>What is the correct (canonical) way to display current time in angular 4 change detection system?</h1>
<p>The problem is as follows: current time changes constantly, each moment, by definition. But it is not detectable by Angular 4 change detection system. For this reason, in my opinion, it's necessary to explicitly call <code>ChangeDetectorRef::detectChanges</code>. However, in the process of calling this method, current time naturally changes its value. This leads to <code>ExpressionChangedAfterItHasBeenCheckedError</code>. In the following example (<a href="https://angular-tlpmtr.stackblitz.io" rel="noreferrer">see live</a>) this error appears withing a few seconds after loading the page:</p>
<pre><code>import { Component, ChangeDetectorRef } from '@angular/core';
@Component({
selector: 'my-app',
template: `{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />
{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />
{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />
{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />
{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />
{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />
{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />
{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}<br />{{ now }}`
})
export class AppComponent {
get now() : string { return Date(); }
constructor(cd: ChangeDetectorRef) {
setInterval(function() { cd.detectChanges(); }, 1);
}
}
</code></pre>
| 0debug |
How to change default black color of Grafana : <p>As the Grafana Dashboard comes with Default black back ground color. It is possible to change the color to some other color of user choice?</p>
| 0debug |
I dont understand why I am getting ArrayIndexOutOfBoundsException? : <p>I keep getting ArrayIndexOutOfBoundsException. I tried to resize all the arrays and traced my code but nothing seems to pop up to me!</p>
<p>I am comparing the numbers between arr and brr. I am trying to print out the numbers that are in brr but not arr and the numbers that are repeated less often than in brr.</p>
<p>I am putting these numbers in sperate array and printing it out. I also tried to do it using Lists but im getting the same Exception.</p>
<pre><code>public class Solution {
static int[] array = new int[200];
static int nextIndex = 0;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("enter n: ");
int n = s.nextInt();
System.out.println("enter numbers in arr: ");
//List<Integer> arr = new ArrayList<>();
int arr[];
arr = new int[200];
for (int i=0; i<n ; i++){
arr[i] = s.nextInt();
}
System.out.println("enter m: ");
int m = s.nextInt();
//List<Integer> brr = new ArrayList<>();
int brr[];
brr = new int[200];
System.out.println("enter numbers in brr: ");
for (int i=0; i<m ; i++){
brr[i] = s.nextInt();
}
//System.out.println("The missing nums are : ");
//List<Integer> finalArray;
//ArrayList<Integer> finalArray;
int finalArray[];
finalArray = new int[200];
finalArray = missingNums(arr,brr);
for (int i =0; i<finalArray.length; i++){
System.out.println(finalArray[i]);
}
}
public static int[] missingNums(int arr[], int brr[]){
int oFreq = 1, fFreq = 0;
int num, num2=-1;
for (int i=0; i<brr.length; i++){
num = brr[i];
//finding the frequency for each num in brr at a time
for (int j=0; j< brr.length; j++)
if (brr[j + 1] == num) {
oFreq++;
//System.out.println(oFreq);
}
//checking if the same num exists in arr and storing it in num2
for (int x = 0; x<arr.length; x++){
if (arr[x] == num)
num2 = arr[x];
else
push(num);
//nums.add(num);
}
//if the same number as in brr exists in arr find its frequency in arr
if (num2 != -1){
//find frequency of the number in arr
for (int x = 0; x<arr.length; x++){
if (num2 == arr[x])
fFreq++;
}
}
if (oFreq > fFreq)
push(num);
}
return (array);
}
public static void push(int e) {
array[nextIndex] = e;
++nextIndex;
}
public static int pop() {
--nextIndex;
return array[nextIndex];
}
}
</code></pre>
| 0debug |
static void test_cancel(void)
{
WorkerTestData data[100];
int num_canceled;
int i;
test_submit_many();
for (i = 0; i < 100; i++) {
data[i].n = 0;
data[i].ret = -EINPROGRESS;
data[i].aiocb = thread_pool_submit_aio(pool, long_cb, &data[i],
done_cb, &data[i]);
}
active = 100;
aio_notify(ctx);
aio_poll(ctx, false);
g_assert_cmpint(active, ==, 100);
g_usleep(1000000);
g_assert_cmpint(active, >, 50);
num_canceled = 0;
for (i = 0; i < 100; i++) {
if (atomic_cmpxchg(&data[i].n, 0, 3) == 0) {
data[i].ret = -ECANCELED;
bdrv_aio_cancel(data[i].aiocb);
active--;
num_canceled++;
}
}
g_assert_cmpint(active, >, 0);
g_assert_cmpint(num_canceled, <, 100);
for (i = 0; i < 100; i++) {
if (data[i].n != 3) {
bdrv_aio_cancel(data[i].aiocb);
}
}
qemu_aio_wait_all();
g_assert_cmpint(active, ==, 0);
for (i = 0; i < 100; i++) {
if (data[i].n == 3) {
g_assert_cmpint(data[i].ret, ==, -ECANCELED);
g_assert(data[i].aiocb != NULL);
} else {
g_assert_cmpint(data[i].n, ==, 2);
g_assert_cmpint(data[i].ret, ==, 0);
g_assert(data[i].aiocb == NULL);
}
}
}
| 1threat |
everytime i run my code i get the error. "JSON.typeMismatch(JSON.java:111)". how can I parse a JSON object wrapped with an array? here is my code : > package com.communications.dell.pullbw;
>
> import android.content.Context; import android.os.AsyncTask; import
> android.support.v7.app.AppCompatActivity; import android.os.Bundle;
> import android.view.LayoutInflater; import android.view.View; import
> android.view.ViewGroup; import android.widget.ArrayAdapter; import
> android.widget.ListView; import android.widget.TextView;
>
> import com.squareup.okhttp.OkHttpClient; import
> com.squareup.okhttp.Request; import com.squareup.okhttp.Response;
>
> import org.json.JSONArray; import org.json.JSONException; import
> org.json.JSONObject;
>
> import java.io.IOException; import java.util.ArrayList;
>
> public class FeedActivity extends AppCompatActivity implements
> OnFeedListener {
>
> ListView listView;
> FeedAdapter adapter;
> ArrayList<Post> posts;
>
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity_feed);
>
> listView = (ListView)findViewById(R.id.listView);
>
> adapter= new FeedAdapter(getApplicationContext(), R.layout.layout_feed_item);
>
> listView.setAdapter(adapter);
>
> FeedTask task= new FeedTask(this);
>
> task.execute("http://www.botswanayouth.com/wp-json/wp/v2/posts");
> }
>
> @Override
> public void onFeed(JSONArray array)
> {
> posts= new ArrayList<>();
> int length = array.length();
> for (int i = 0; i < length; ++i)
> {
> JSONObject object = array.optJSONObject(i);
>
> Post post = new Post(object.optString("title"),object.optString("excerpt"),object.optString("featured_media"));
>
> posts.add(post);
>
> }
> adapter.addAll(posts);
>
> }
>
> public class FeedTask extends AsyncTask<String, Void, JSONArray>
> {
> private OnFeedListener listener;
> public FeedTask(OnFeedListener listener)
> {
> this.listener= listener;
> }
> @Override
> protected JSONArray doInBackground(String... params) {
>
> String url = params[0];
> OkHttpClient client= new OkHttpClient();
> Request.Builder builder= new Request.Builder();
>
> Request request= builder.url(url).build();
>
> try {
> Response response= client.newCall(request).execute();
>
> String json= response.body().string();
>
> try
> {
> JSONObject object= new JSONObject(json);
> JSONArray array = object.optJSONArray("posts");
>
> return array;
> }
> catch (JSONException e)
> {
> e.printStackTrace();
> }
>
> }
> catch (IOException e)
> {
> e.printStackTrace();
> }
> return null;
> }
>
> @Override
> protected void onPostExecute(JSONArray array) {
> super.onPostExecute(array);
>
> if (null== array)
> return;
>
> if (null != listener)
> listener.onFeed(array);
> }
> }
>
> public class FeedAdapter extends ArrayAdapter<Post>
> {
> private int resource;
> public FeedAdapter(Context context, int resource)
> {
> super(context, resource);
> this.resource=resource;
> }
>
> @Override
> public View getView(int position, View convertView, ViewGroup parent) {
>
> if (null==convertView)
> {
> LayoutInflater inflater=LayoutInflater.from(getContext());
> convertView=inflater.inflate(resource, null);
> }
>
> Post post = getItem(position);
>
> TextView title = (TextView) convertView.findViewById(R.id.title);
> TextView desc = (TextView) convertView.findViewById(R.id.description);
> title.setText(post.title);
> desc.setText(post.description);
>
> return convertView;
> }
> }
>
> public class Post{
> public String title;
> public String description;
> public String thumbnail; //URL
>
> public Post(String title, String desc, String thumbnail)
> {
> this.title=title;
> this.description=desc;
> this.thumbnail=thumbnail;
> }
> }
>
>
> }
| 0debug |
static inline int get_chroma_qp(int chroma_qp_index_offset, int qscale){
return chroma_qp[av_clip(qscale + chroma_qp_index_offset, 0, 51)];
}
| 1threat |
How to find average of unique rows in python : I want to find the average of unique values using data frames in python
For example I have a dataset as follows
[c1] [c2]
foo 3.2
bar 4.3
foo 3.0
foo 2.3
bar 4.5
foo 1.9
bar 4.4
I want output like:
Count of foo = 4 and average of foo is 2.6 //(i.e., (3.2+3.0+2.3+1.9)/4))
count of bar = 3 and average of bar is 4.4 //(i.e., (4.3+4.5+4.4)/3)) | 0debug |
It needs to connect to a database, but it doesn't. : <pre><code><?php
session_start();
$host="localhost";
$username="root";
$password="";
$db_name="registrering";
$tbl_name="users";
$conn = mysqli_connect($host, $username, $password, $db_name);
if(!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
<html>
<head>
<title>user registration system using php and PHP and Mysq</title>
<!---<link rel="stylesheet" type="text/css" href="style.css">-->
</head>
<body>
<div style="float:right; width:70%">
<table width="150px" border="0" cellpadding="3" cellspacing="1">
<h2>Registrer<h2/>
<form method="post" action=" ">
<br>
<tr>
<td>Brugernavn</td>
<td>:</td>
<td><input type="text" name="Brugernavn"> </td>
</tr>
<br>
<tr>
<td>Email</td>
<td>:</td>
<td><input type="text" name="Email"> </td>
</tr>
<br>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="Password"></td>
</tr>
<input type="submit" name="registrer" value="Registrer">
<p>
Allerede medlem? <a href="login.php">Log ind</a>
</p>
</form>
</div>
</table>
</body>
</html>
<?php
if (isset($_POST["registrer"]))
{
$my_username=$_POST["Brugernavn"];
$my_email=$_POST["Email"];
$my_password=$_POST["Password"];
$sql = "INSERT INTO 'users'(`username`, `email`, `password`) VALUES ('$my_username','$my_email','$my_password')";
$resultat = mysqli_query($conn, $sql);
}
?>
</code></pre>
<p>It needs to connect to a database, but it doesn't. It's on a localhost and we can't insert data into a database. The database consists of a username, email and password.
We are using varchar(65) and utf8_general_ci.</p>
| 0debug |
Check if webpage contains text : <p>I am getting a webpage using <code>file_get_contents();</code>:</p>
<pre><code>$file = file_get_contents('http://example.com');
</code></pre>
<p>How do I check if the webpage contains the text 'hello' or 'bye'</p>
| 0debug |
Is there a way to make Swift be compiled ignoring the errors? : So, yeah. The title says everything, basically. If you, for example, are writing a class that is yet unused in your application and have errors in it, or if the compiler is just being dumb with all those safety measures, can you compile it anyway? Can you **make** the compiler compile it, even though it is a little bit hack-ish? In other words, how to make errors be treated as warnings? | 0debug |
phpMyAdmin AUTO_INCREMENT Uncontrolled Increase : I'm adding a new record using php to the table in the database, but the AUTO_INCREMENT value is getting ridiculously higher.
This is for a new Linux server, running MySQL 5, PHP 7.6 and Apache 2.
@$add_user = mysqli_query($conn, "INSERT INTO users(username, email, custom_title, avatar, message_count, is_moderator, is_admin, is_banned, is_onli`enter code here`ne, security_key) VALUES('$n_username','$n_email','$n_custom_title','$n_avatar','$n_message_count','$n_is_moderator','$n_is_admin','$n_is_banned','0','$security_key')");
https://i.hizliresim.com/vadEDR.png | 0debug |
OAuth2.0 implementation facing Request body has not been specified issue : I am seeing an error when i am executing my post call httpClient.executeMethod(post);It says 4800 [main] DEBUG org.apache.commons.httpclient.methods.EntityEnclosingMethod - Request body has not been specified | 0debug |
Menu item goes to second activity but does not load content (Android Studio) : So I have a Main Activity with the default activity which has the menu feature.
I went to the MainActivity.Java file and entered the code in the auto-generated 'if' statement for all buttons on the menu and when i run it nothing loads. I tried adding a background color and only the color loaded no text.
Here is the code inside the if statement -
Intent i = new Intent(FromActivity.this, ToActivity.class);
startActivity(i);
And in my XML file for the second activity here is the text view -
<TextView
android:text="Test"
android:width="wrap-content"
android:height="wrap-content"/>
| 0debug |
How to resolve Gradle plugin requires Studio 3.0 minimum : <p>I am getting <code>Error:This Gradle plugin requires Studio 3.0 minimum</code> when importing project<br>
Project repo: <a href="https://github.com/chrisbanes/cheesesquare" rel="noreferrer">https://github.com/chrisbanes/cheesesquare</a><br>
I had tried mentioned solution provided <a href="https://stackoverflow.com/questions/45171647/this-gradle-plugin-requires-android-studio-3-0-minimum">here</a> and <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwisp_zRlL7VAhUIK48KHd8wAtgQFgglMAA&url=https%3A%2F%2Fgithub.com%2Ffirebase%2Fquickstart-android%2Fissues%2F294&usg=AFQjCNEGCb1q0tySOWAbyhcPw-1Fm-lAuA" rel="noreferrer">here</a> but nothing worked :(</p>
| 0debug |
PPC_OP(update_nip)
{
env->nip = PARAM(1);
RETURN();
}
| 1threat |
xcode 8.3 framework not found FileProvider for architecture armv7 : <p>When I'm using xcode 9 beta 6 building a react-native project, it works fine. </p>
<p>But after I change to xcode 8.3, it builds failed, and shows me these information: </p>
<pre><code>ld: framework not found FileProvider for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Apple Mach-O Linker (ld) Error Group
: Linker command failed with exit code 1 (use -v to see invocation)
</code></pre>
<p>How could I do if I use xcode 8.3 to develop ? I'm not able to use xcode 9 because of this: <a href="https://stackoverflow.com/questions/45955074/xcode-was-crashed-after-adding-art-xcodeproj-into-library">Xcode was crashed after adding ART.xcodeproj into Library</a></p>
<p>Thanks to all bros : )</p>
| 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
why the elements of array changed after sort,C++,C : the elements of the array changed ,and became some numbers which are never being input
#include <stdlib.h>
#include <string.h>
#define MAX_SIZE 1000
int cmp(int a, int b)
{
return a>b;
}
void sort(int *data, int n, int (*cmp)(int, int))
{
for (;n>1;n--)
{
int i_max = 0;
for(int i = 1;i<n;i++)
if(cmp(data[i],data[i_max])) i_max = i;
int temp = data[i_max];
data[i_max] = data[n-1];
data[n-1] = temp;
}
}
int main()
{
int data[MAX_SIZE] , n;
scanf("%d",&n);
for(int i = 0 ; i < n ; i++)
{
int m;
puts("*****************");
scanf("%d",&m);
for(int j = 0 ; j < m ; j++)
scanf("%d",data+j);
sort(data, m, cmp);
puts("after sorting:");
for(int j = 0 ; j < m ; j++)
{
printf("%d ",data[j]);
}
puts("\n*****************");
}
return 0;
}
input:
5
5
12
346
5676434535
765654543596
3543456
6
5783945
5293
237894
273894
73
237482
4
27895
719287349723947
1
34
7
3472893
74897598347
757
178
579875498234
129
84
5
420938
23
837485
279
29871
output:
*****************
after sorting:
12 346 3543456 1150364908 1381467239(the last two numbers were never input before, and the former number disappeared)
*****************
*****************
after sorting:
73 5293 237482 237894 273894 5783945
*****************
*****************
after sorting:
1 34 27895 586728235
*****************
*****************
after sorting:
84 129 178 757 3472893 54913274 1883154315
*****************
***************** | 0debug |
Visitor *qmp_input_visitor_new(QObject *obj, bool strict)
{
QmpInputVisitor *v;
assert(obj);
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qmp_input_start_struct;
v->visitor.check_struct = qmp_input_check_struct;
v->visitor.end_struct = qmp_input_pop;
v->visitor.start_list = qmp_input_start_list;
v->visitor.next_list = qmp_input_next_list;
v->visitor.end_list = qmp_input_pop;
v->visitor.start_alternate = qmp_input_start_alternate;
v->visitor.type_int64 = qmp_input_type_int64;
v->visitor.type_uint64 = qmp_input_type_uint64;
v->visitor.type_bool = qmp_input_type_bool;
v->visitor.type_str = qmp_input_type_str;
v->visitor.type_number = qmp_input_type_number;
v->visitor.type_any = qmp_input_type_any;
v->visitor.type_null = qmp_input_type_null;
v->visitor.optional = qmp_input_optional;
v->visitor.free = qmp_input_free;
v->strict = strict;
v->root = obj;
qobject_incref(obj);
return &v->visitor;
}
| 1threat |
static void tracked_request_begin(BdrvTrackedRequest *req,
BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, bool is_write)
{
*req = (BdrvTrackedRequest){
.bs = bs,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.is_write = is_write,
};
qemu_co_queue_init(&req->wait_queue);
QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);
} | 1threat |
static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
{
DVVideoContext *s = avctx->priv_data;
DVwork_chunk *work_chunk = arg;
int quant, dc, dct_mode, class1, j;
int mb_index, mb_x, mb_y, last_index;
int y_stride, linesize;
DCTELEM *block, *block1;
int c_offset;
uint8_t *y_ptr;
const uint8_t *buf_ptr;
PutBitContext pb, vs_pb;
GetBitContext gb;
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [ 80 + FF_INPUT_BUFFER_PADDING_SIZE]);
LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5*80 + FF_INPUT_BUFFER_PADDING_SIZE]);
const int log2_blocksize = 3;
int is_field_mode[5];
assert((((int)mb_bit_buffer) & 7) == 0);
assert((((int)vs_bit_buffer) & 7) == 0);
memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));
buf_ptr = &s->buf[work_chunk->buf_offset*80];
block1 = &sblock[0][0];
mb1 = mb_data;
init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) {
quant = buf_ptr[3] & 0x0f;
buf_ptr += 4;
init_put_bits(&pb, mb_bit_buffer, 80);
mb = mb1;
block = block1;
is_field_mode[mb_index] = 0;
for (j = 0; j < s->sys->bpm; j++) {
last_index = s->sys->block_sizes[j];
init_get_bits(&gb, buf_ptr, last_index);
dc = get_sbits(&gb, 9);
dct_mode = get_bits1(&gb);
class1 = get_bits(&gb, 2);
if (DV_PROFILE_IS_HD(s->sys)) {
mb->idct_put = s->idct_put[0];
mb->scan_table = s->dv_zigzag[0];
mb->factor_table = &s->sys->idct_factor[(j >= 4)*4*16*64 + class1*16*64 + quant*64];
is_field_mode[mb_index] |= !j && dct_mode;
} else {
mb->idct_put = s->idct_put[dct_mode && log2_blocksize == 3];
mb->scan_table = s->dv_zigzag[dct_mode];
mb->factor_table = &s->sys->idct_factor[(class1 == 3)*2*22*64 + dct_mode*22*64 +
(quant + ff_dv_quant_offset[class1])*64];
}
dc = dc << 2;
dc += 1024;
block[0] = dc;
buf_ptr += last_index >> 3;
mb->pos = 0;
mb->partial_bit_count = 0;
av_dlog(avctx, "MB block: %d, %d ", mb_index, j);
dv_decode_ac(&gb, mb, block);
if (mb->pos >= 64)
bit_copy(&pb, &gb);
block += 64;
mb++;
}
av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index);
block = block1;
mb = mb1;
init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));
put_bits32(&pb, 0);
flush_put_bits(&pb);
for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) {
if (mb->pos < 64 && get_bits_left(&gb) > 0) {
dv_decode_ac(&gb, mb, block);
if (mb->pos < 64)
break;
}
}
if (j >= s->sys->bpm)
bit_copy(&vs_pb, &gb);
}
av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb));
block = &sblock[0][0];
mb = mb_data;
init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));
put_bits32(&vs_pb, 0);
flush_put_bits(&vs_pb);
for (mb_index = 0; mb_index < 5; mb_index++) {
for (j = 0; j < s->sys->bpm; j++) {
if (mb->pos < 64) {
av_dlog(avctx, "start %d:%d\n", mb_index, j);
dv_decode_ac(&gb, mb, block);
}
if (mb->pos >= 64 && mb->pos < 127)
av_log(avctx, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos);
block += 64;
mb++;
}
}
block = &sblock[0][0];
mb = mb_data;
for (mb_index = 0; mb_index < 5; mb_index++) {
dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y);
if ((s->sys->pix_fmt == PIX_FMT_YUV420P) ||
(s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
(s->sys->height >= 720 && mb_y != 134)) {
y_stride = (s->picture.linesize[0] << ((!is_field_mode[mb_index]) * log2_blocksize));
} else {
y_stride = (2 << log2_blocksize);
}
y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x) << log2_blocksize);
linesize = s->picture.linesize[0] << is_field_mode[mb_index];
mb[0] .idct_put(y_ptr , linesize, block + 0*64);
if (s->sys->video_stype == 4) {
mb[2].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 2*64);
} else {
mb[1].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 1*64);
mb[2].idct_put(y_ptr + y_stride, linesize, block + 2*64);
mb[3].idct_put(y_ptr + (1 << log2_blocksize) + y_stride, linesize, block + 3*64);
}
mb += 4;
block += 4*64;
c_offset = (((mb_y >> (s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] +
(mb_x >> ((s->sys->pix_fmt == PIX_FMT_YUV411P) ? 2 : 1))) << log2_blocksize);
for (j = 2; j; j--) {
uint8_t *c_ptr = s->picture.data[j] + c_offset;
if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
uint64_t aligned_pixels[64/8];
uint8_t *pixels = (uint8_t*)aligned_pixels;
uint8_t *c_ptr1, *ptr1;
int x, y;
mb->idct_put(pixels, 8, block);
for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->picture.linesize[j], pixels += 8) {
ptr1 = pixels + (1 << (log2_blocksize - 1));
c_ptr1 = c_ptr + (s->picture.linesize[j] << log2_blocksize);
for (x = 0; x < (1 << (log2_blocksize - 1)); x++) {
c_ptr[x] = pixels[x];
c_ptr1[x] = ptr1[x];
}
}
block += 64; mb++;
} else {
y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
s->picture.linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
linesize = s->picture.linesize[j] << is_field_mode[mb_index];
(mb++)-> idct_put(c_ptr , linesize, block); block += 64;
if (s->sys->bpm == 8) {
(mb++)->idct_put(c_ptr + y_stride, linesize, block); block += 64;
}
}
}
}
return 0;
}
| 1threat |
Andriod : How to Open Fragemnet2 Which is in Activity2 From Fragment Button in Activity1 : > I have Been Trying alot Unable to do it pls help out... I have Two
> Fragments fragment1 and fragment2 Activity1 as Fragement1 -> in this
> fragemnet one there is a Button on it. Onclick of that Button the
> Fragement in Activity2 Should open
>
>
> @Override
> public View onCreateView(LayoutInflater inflater, ViewGroup container,
> Bundle savedInstanceState)
> {
> View rootView = inflater.inflate(R.layout.fragment_tools, container, false);
> Button cntr = (Button) rootView.findViewById(R.id.counterid);
> cntr.setOnClickListener(new View.OnClickListener()
> {
> @Override
> public void onClick(View v)
> {
> Fragment fragment = new ToolsFragment();
> FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
> fragmentManager.beginTransaction().replace(R.id.fragmenttools,fragment).addToBackStack(null).commit();
> }
> });
> return rootView;
> } | 0debug |
Architect an API layer : <p>Broad, general question:</p>
<p>We have an app that is quickly approaching legacy status. It has three clients: Windows app, browser (web site) and mobile. The data access layer is convoluted at best and has grown organically over the years.</p>
<p>We want to re-architect the whole thing. The Windows app will go away ('cause who does <em>that</em> any more?) We will only have the browser based website and the mobile app, both of which will consume the (as of today, non-existant) API layer. This API layer will also be partially exposed to third parties should they wish to do their own integrations.</p>
<p>Here's my question:</p>
<p>What does this API layer look like? And by that, I mean... let's start in the Visual Studio solution. Is the API a separate website? So on IIS, will there be two sites... one for the public facing website and another for the API layer?</p>
<p>Or, should the API be a .dll within the main website, and have the endpoint URL's be part of the single website in IIS?</p>
<p>Eventually, we will want to update and publish one w/o impacting the other. I'm just unsure, on a very high level, how to structure the entire thing.</p>
<p>(If it matters: Each client has their own install, either locally on their network, or cloud hosted. All db's are single tenant.)</p>
| 0debug |
void json_start_array(QJSON *json, const char *name)
{
json_emit_element(json, name);
qstring_append(json->str, "[ ");
json->omit_comma = true;
}
| 1threat |
not able to call CFHTTP call in coldfusion : I am trying to call CFHTTP call from ColdFusion but it's not calling.
<cfhttp url="https://apracareers.localhost/be/index.cfm?event=apm.ExecuteRuleAndActionInApmApi&testExecID=1CCDBEBA-3892-8ED2-F158-A42B9D79317F" method="POST" resolveurl="no" charset="utf-8" >
<cfhttpparam type="Header" name="Accept-Encoding" value="*">
</cfhttp>
log i am getting - May 14, 2018 14:04:13 PM Information [A9ACF8BE-FFAD-0210-F70213D0E7DEF338] - Starting HTTP request {URL='https://apracareers.localhost/be/index.cfm?event=apm.ExecuteRuleAndActionInApmApi&testExecID=1CCDBEBA-3892-8ED2-F158-A42B9D79317F', method='POST'}
Thanks | 0debug |
Angular Mat Table Error: Missing definitions for header and row : <p>I am using MatTable from Angular Material 5.2.5. I trying to populate the table with data which is got through a server request.</p>
<p>The UI</p>
<pre><code> <mat-table [dataSource]="dataSource">
<ng-container matColumnDef="number">
<mat-header-cell *matHeaderCellDef>#</mat-header-cell>
<mat-cell *matCellDef="let i = index">{{i + 1}}</mat-cell>
</ng-container>
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
<mat-cell *matCellDef="let user">{{user.userName}}</mat-cell>
</ng-container>
...
</mat-table>
</code></pre>
<p>The component code</p>
<pre><code> public dataSource = new MatTableDataSource<User>()
public displayedColumns = ['number', 'name', 'email', 'phone', 'joiningDate']
</code></pre>
<p>Adding data to dataSource on receiving data from the server</p>
<pre><code> onGettingPartnerUsers(userList: User[]) {
console.log('userList', userList)
if (!Util.isFilledArray(userList)) {
// TODO show message no user found
} else {
this.dataSource.data = userList
}
}
</code></pre>
<p>I am getting the list of users. But this error is getting thrown.</p>
<pre><code>Error: Missing definitions for header and row, cannot determine which columns should be rendered.
</code></pre>
<p>What is the mistake?</p>
<p>PS: I am following <a href="https://medium.com/codingthesmartway-com-blog/angular-material-part-4-data-table-23874582f23a" rel="noreferrer">this</a> blog on using MatTable</p>
| 0debug |
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
MigrationState *s = migrate_get_current();
const char *p;
int detach = qdict_get_try_bool(qdict, "detach", 0);
int blk = qdict_get_try_bool(qdict, "blk", 0);
int inc = qdict_get_try_bool(qdict, "inc", 0);
const char *uri = qdict_get_str(qdict, "uri");
int ret;
if (s->state == MIG_STATE_ACTIVE) {
monitor_printf(mon, "migration already in progress\n");
return -1;
}
if (qemu_savevm_state_blocked(mon)) {
return -1;
}
if (migration_blockers) {
Error *err = migration_blockers->data;
qerror_report_err(err);
return -1;
}
s = migrate_init(mon, detach, blk, inc);
if (strstart(uri, "tcp:", &p)) {
ret = tcp_start_outgoing_migration(s, p);
#if !defined(WIN32)
} else if (strstart(uri, "exec:", &p)) {
ret = exec_start_outgoing_migration(s, p);
} else if (strstart(uri, "unix:", &p)) {
ret = unix_start_outgoing_migration(s, p);
} else if (strstart(uri, "fd:", &p)) {
ret = fd_start_outgoing_migration(s, p);
#endif
} else {
monitor_printf(mon, "unknown migration protocol: %s\n", uri);
ret = -EINVAL;
}
if (ret < 0) {
monitor_printf(mon, "migration failed: %s\n", strerror(-ret));
return ret;
}
if (detach) {
s->mon = NULL;
}
notifier_list_notify(&migration_state_notifiers, s);
return 0;
}
| 1threat |
Combine to powerpoints slide by slide? : I'm trying to find a way to combine two big powerpoints slide by slide:
PPT1: slide 1A - slide 2A - slide 3A - ... slide 100A
PPT2: slide 1B - slide 2B - slide 3B - ... slide 100B
--> PPT Merged: Slide 1A - Slide 1B - Slide 2A - Slide 2B - ...
To be honest, I have no clue on how to tackle this yet, any help is highly appreciated!
Thanks | 0debug |
background Image gone compressed when keyboard is open : I am making signup page using this image background.
[Background image][1]
[1]: https://i.stack.imgur.com/huxGd.png
It Look like:
[Signup page][2]
[2]: https://i.stack.imgur.com/XGvyJ.jpg
but when i focus edittext and keyboard is opened, background image is compressed. how can i resolve this. | 0debug |
How to properly close and reopen Room Database : <p>Hello I have 2 apps that rely on making and restoring the backups of the app's databases just by copying the databases files in and out the sdcard and am having a hard time figuring out how to reopen the Room Database singleton after closing it to make the databases' copies.</p>
<p>Building the database:</p>
<pre><code>@Database(version = 15, exportSchema = true, entities = [list of entities])
abstract class AppDatabase : RoomDatabase() {
//list of DAOs
companion object {
@Volatile private var INSTANCE: AppDatabase? = null
fun getInstance(context: Context): AppDatabase =
INSTANCE ?: synchronized(this) {
INSTANCE ?: buildDatabase(context).also {
INSTANCE = it
}
}
private fun buildDatabase(context: Context) =
Room.databaseBuilder(
context.applicationContext,
AppDatabase::class.java,
"Fazendao.sqlitedb"
)
.addMigrations(Migration1315)
.build()
}
}
</code></pre>
<p>Closing the database:</p>
<pre><code>fun closeDatabase() {
if(db.isOpen) {
db.openHelper.close()
}
}
</code></pre>
<p>Making the database file copy (inside a ViewModel):</p>
<pre><code>fun exportaBkpObservable(nome: String, auto: String, storage: File, database: File) {
disposable.clear()
setFlagsNull()
flagSubject.onNext(false)
disposable.add(
Observable.fromCallable {
repo.recordBkpName(nome)
}
.subscribeOn(Schedulers.io())
.flatMap {
return@flatMap try {
//closing the database
repo.closeDatabase()
Observable.just(
database.copyTo(File(storage, auto), true)
)
.flatMap {
val myDb = SQLiteDatabase.openOrCreateDatabase(it, null)
val ok = myDb.isDatabaseIntegrityOk
if(myDb.isOpen) myDb.close()
if(ok) {
Observable.just(ok)
} else {
Observable.error<Throwable>(Throwable("CORRUPTED DATABASE"))
}
}
} catch (t: Throwable) {
Observable.error<Throwable>(t)
}
}
.subscribe(
{},
{
errorFlag = "exportDB: " + it.message
errorSubject.onNext("exportDB: " + it.message)
},
{
//trying to reopen database
repo.openDatabase()
trueFlag = true
flagSubject.onNext(true)
}
)
)
}
</code></pre>
<p>The repo is the repository where the AppDatabase is injected, and in its turn is injected in the ViewModelFactory.</p>
<p>Injection:</p>
<pre><code>object MainInjection {
private fun providesIORepo(context: Context): IORepo {
return IORepo(AppDatabase.getInstance(context))
}
fun provideIOViewModelFactory(context: Context): IOViewModelFactory {
val data = providesIORepo(context)
return IOViewModelFactory(data)
}
}
</code></pre>
<p>And in the AppCompatActivity onCreate:</p>
<pre><code>val modelFactory = MainInjection.provideIOViewModelFactory(this)
viewModel = ViewModelProviders.of(this, modelFactory).get(IOViewModel::class.java)
</code></pre>
<p>Reopening the database:</p>
<pre><code>fun openDatabase() {
if(!db.isOpen){
db.openHelper.writableDatabase
}
}
</code></pre>
<p>Now the error messages:</p>
<p>Trying to reopen the database:</p>
<pre><code>E/ROOM: Invalidation tracker is initialized twice :/.
</code></pre>
<p>And consequently the crash when I try to access it from another function:</p>
<pre><code>Cannot perform this operation because the connection pool has been closed.
</code></pre>
<p>Sometimes after closing the database I have also:</p>
<pre><code>E/ROOM: Cannot run invalidation tracker. Is the db closed?
</code></pre>
<p>In this post <a href="https://medium.com/google-developers/incrementally-migrate-from-sqlite-to-room-66c2f655b377" rel="noreferrer">Incrementally migrate from SQLite to Room</a> the author opens and closes the database for each access to it, so I don't understand why my implementation is not working.</p>
<p>So where am I wrong ? Is there a way of deactivating the InvalidationTracker too ?</p>
<p>Should I use the following code to close the database and clear the Room instance every time I have to copy the database file. Is it safe ?:</p>
<pre><code>fun destroyInstance() {
if (INSTANCE?.isOpen == true) {
INSTANCE?.close()
}
INSTANCE = null
}
</code></pre>
<p>Thanks for the attention.</p>
| 0debug |
JSON converted from JS can't be decoded by PHP : <p>I am sending array as POST request which is converted to JSON using <code>JSON.stringify()</code>.</p>
<p>However, when I try to decode in PHP, it throws me some error.</p>
<pre><code>// JS
var arr1 = ['a', 'b', 'c', 'd', 'e'];
JSON.stringify({data: arr1})
</code></pre>
<p>In PHP:</p>
<pre><code>echo json_decode("{"data":["a","b","c","d","e"]}");
</code></pre>
<p>Please help me fix this!</p>
| 0debug |
How to change the size of R plots in Jupyter? : <p>I am wondering how to configure Jupyter to plot a smaller figure within R kernel.</p>
<p>I have tried using <code>options(repr.plot.width = 1, repr.plot.height = 0.75, repr.plot.res = 300)</code>, but the result is kinda messy. It is changing the size of the plot R produced. Are there any ways I can directly configure the output graph size in Jupyter.</p>
<p>In other words, how can I change the size in the first figure to the size in the second figure, while not messing up the plot.</p>
<p><a href="https://i.stack.imgur.com/16gtc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/16gtc.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/uvCNT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uvCNT.png" alt="enter image description here"></a></p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.