problem stringlengths 26 131k | labels class label 2
classes |
|---|---|
static inline uint32_t efsctsiz(uint32_t val)
{
CPU_FloatU u;
u.l = val;
if (unlikely(float32_is_nan(u.f)))
return 0;
return float32_to_int32_round_to_zero(u.f, &env->vec_status);
}
| 1threat |
def subset(ar, n):
res = 0
ar.sort()
for i in range(0, n) :
count = 1
for i in range(n - 1):
if ar[i] == ar[i + 1]:
count+=1
else:
break
res = max(res, count)
return res | 0debug |
How to separate one file or folder with all history from one git repo to another? : <p>Let me explain. For some time I developed some code. Now I want to separate a part and make it open-source. My main problem is to <strong>save all commit history, which concerns that files</strong>.</p>
| 0debug |
When upgrading Angular 5 to 6, I get incompatible peer dependency (using ng update @angular/core) : <p>I am trying to update my Angular app from v5 to v6 following <a href="https://update.angular.io/" rel="noreferrer">this guide</a>.</p>
<p>I have ran all these commands successfully:</p>
<pre><code>npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
</code></pre>
<p>The problem is that I get an error when running this command:</p>
<pre><code>ng update @angular/core
Package "@angular/flex-layout" has an incompatible peer dependency to "rxjs" (requires "^5.5.0", would install "6.2.0").
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.6.2")
Incompatible peer dependencies found. See above.
</code></pre>
<p>I am not sure how to handle this & I don't want to try things on my own to avoid breaking the app.</p>
<p>Can someone please advise what to do?</p>
<p>My current dependencies are as follows:</p>
<pre><code>{
....
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.10",
"@angular/cdk": "^5.2.5",
"@angular/common": "^5.2.10",
"@angular/compiler": "^5.2.10",
"@angular/core": "^5.2.10",
"@angular/flex-layout": "^5.0.0-beta.14",
"@angular/forms": "^5.2.10",
"@angular/http": "^5.2.10",
"@angular/material": "^5.2.5",
"@angular/platform-browser": "^5.2.10",
"@angular/platform-browser-dynamic": "^5.2.10",
"@angular/router": "^5.2.10",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^3.0.1",
"core-js": "^2.5.5",
"hammerjs": "^2.0.8",
"primeng": "^5.2.4",
"rxjs": "^5.5.11",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.3",
"@angular/cli": "^6.0.3",
"@angular/compiler-cli": "^5.2.11",
"@angular/language-service": "^5.2.10",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.106",
"codelyzer": "^4.3.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.2",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.3.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.6.2"
}
}
</code></pre>
| 0debug |
How to Play Video in Unity 2D? : <p>i need to play Videos in my 2d game. many Tutorials in Youtube how to play Videos but its 3d. so share with me how to play Video File in unity </p>
<ul>
<li>Video Format</li>
</ul>
| 0debug |
static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
{
const int mb_x= s->mb_x;
const int mb_y= s->mb_y;
int i;
#if 0
if (s->interlaced_dct) {
dct_linesize = s->linesize * 2;
dct_offset = s->linesize;
} else {
dct_linesize = s->linesize;
dct_offset = s->linesize * 8;
}
#endif
if (s->mb_intra) {
UINT8 *ptr;
int wrap;
wrap = s->linesize;
ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16;
get_pixels(s->block[0], ptr , wrap);
get_pixels(s->block[1], ptr + 8, wrap);
get_pixels(s->block[2], ptr + 8 * wrap , wrap);
get_pixels(s->block[3], ptr + 8 * wrap + 8, wrap);
wrap >>=1;
ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8;
get_pixels(s->block[4], ptr, wrap);
ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8;
get_pixels(s->block[5], ptr, wrap);
}else{
op_pixels_func *op_pix;
qpel_mc_func *op_qpix;
UINT8 *dest_y, *dest_cb, *dest_cr;
UINT8 *ptr;
int wrap;
dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize ) + mb_x * 16;
dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8;
dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8;
if ((!s->no_rounding) || s->pict_type==B_TYPE){
op_pix = put_pixels_tab;
op_qpix= qpel_mc_rnd_tab;
}else{
op_pix = put_no_rnd_pixels_tab;
op_qpix= qpel_mc_no_rnd_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix);
if ((!s->no_rounding) || s->pict_type==B_TYPE)
op_pix = avg_pixels_tab;
else
op_pix = avg_no_rnd_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix);
}
wrap = s->linesize;
ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16;
diff_pixels(s->block[0], ptr , dest_y , wrap);
diff_pixels(s->block[1], ptr + 8, dest_y + 8, wrap);
diff_pixels(s->block[2], ptr + 8 * wrap , dest_y + 8 * wrap , wrap);
diff_pixels(s->block[3], ptr + 8 * wrap + 8, dest_y + 8 * wrap + 8, wrap);
wrap >>=1;
ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8;
diff_pixels(s->block[4], ptr, dest_cb, wrap);
ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8;
diff_pixels(s->block[5], ptr, dest_cr, wrap);
}
#if 0
{
float adap_parm;
adap_parm = ((s->avg_mb_var << 1) + s->mb_var[s->mb_width*mb_y+mb_x] + 1.0) /
((s->mb_var[s->mb_width*mb_y+mb_x] << 1) + s->avg_mb_var + 1.0);
printf("\ntype=%c qscale=%2d adap=%0.2f dquant=%4.2f var=%4d avgvar=%4d",
(s->mb_type[s->mb_width*mb_y+mb_x] > 0) ? 'I' : 'P',
s->qscale, adap_parm, s->qscale*adap_parm,
s->mb_var[s->mb_width*mb_y+mb_x], s->avg_mb_var);
}
#endif
if (s->h263_msmpeg4) {
msmpeg4_dc_scale(s);
} else if (s->h263_pred) {
h263_dc_scale(s);
} else {
s->y_dc_scale = 8;
s->c_dc_scale = 8;
}
for(i=0;i<6;i++) {
s->block_last_index[i] = dct_quantize(s, s->block[i], i, s->qscale);
}
switch(s->out_format) {
case FMT_MPEG1:
mpeg1_encode_mb(s, s->block, motion_x, motion_y);
break;
case FMT_H263:
if (s->h263_msmpeg4)
msmpeg4_encode_mb(s, s->block, motion_x, motion_y);
else if(s->h263_pred)
mpeg4_encode_mb(s, s->block, motion_x, motion_y);
else
h263_encode_mb(s, s->block, motion_x, motion_y);
break;
case FMT_MJPEG:
mjpeg_encode_mb(s, s->block);
break;
}
}
| 1threat |
Bootstrap column and row : <p>I'm using bootstrap columns which allows a maximum of 12. I need two different divs in one row, one having 12 cols and the other 4. I need the one of 4 cols to appear on the one of 12. Means both of divs will be in the same row. Please how do I achieve this. Thanks.</p>
| 0debug |
Disappearing Picturebox images : <p>I was successful in loading an image from a file into a picturebox in visual basic. Or so i thought. I had a msgbox in the code and the picture showed up in the picturebox. take the msgbox out and no picture. Any Ideas? Thanks</p>
<pre><code> Private Sub DrawImageinSquarePanel(Panelname As PictureBox, ImageFile As String)
g = Panelname.CreateGraphics() 'creates new graphics element in panel
Dim newImage As Image = Image.FromFile(ImageFile) ' Create image.
Dim SquareDim As Integer 'Size of longest dimension in source image
If newImage.Width > newImage.Height Then
SquareDim = newImage.Width
Else
SquareDim = newImage.Height
End If
MsgBox(Panelname.Width & " " & Panelname.Height) 'the magic msgbox!!
' scale factor
Dim imageAttr As New ImageAttributes
imageAttr.SetGamma(Panelname.Width / SquareDim)
Dim ScaleFactor As Single = Panelname.Width / SquareDim
' Create rectangle for source and destination image.
Dim srcRect As New Rectangle(0, 0, newImage.Width, newImage.Height)
Dim destRect As New Rectangle((Panelname.Width - newImage.Width * ScaleFactor) / 2, (Panelname.Height - newImage.Height * ScaleFactor) / 2, newImage.Width * ScaleFactor, newImage.Height * ScaleFactor)
Dim units As GraphicsUnit = GraphicsUnit.Pixel
' Draw image to screen.
g.DrawImage(newImage, destRect, srcRect, units)
End Sub
</code></pre>
| 0debug |
static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
int srcSliceY, int srcSliceH, uint8_t *dst[],
int dstStride[])
{
const enum PixelFormat srcFormat = c->srcFormat;
const enum PixelFormat dstFormat = c->dstFormat;
const int srcBpp = (c->srcFormatBpp + 7) >> 3;
const int dstBpp = (c->dstFormatBpp + 7) >> 3;
const int srcId = c->srcFormatBpp;
const int dstId = c->dstFormatBpp;
void (*conv)(const uint8_t *src, uint8_t *dst, int src_size) = NULL;
#define CONV_IS(src, dst) (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)
if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
if ( CONV_IS(ABGR, RGBA)
|| CONV_IS(ARGB, BGRA)
|| CONV_IS(BGRA, ARGB)
|| CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
else if (CONV_IS(ABGR, ARGB)
|| CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
else if (CONV_IS(ABGR, BGRA)
|| CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
else if (CONV_IS(BGRA, RGBA)
|| CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
else if (CONV_IS(BGRA, ABGR)
|| CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
} else
if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
(isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
switch (srcId | (dstId << 16)) {
case 0x000F0010: conv = rgb16to15; break;
case 0x000F0018: conv = rgb24to15; break;
case 0x000F0020: conv = rgb32to15; break;
case 0x0010000F: conv = rgb15to16; break;
case 0x00100018: conv = rgb24to16; break;
case 0x00100020: conv = rgb32to16; break;
case 0x0018000F: conv = rgb15to24; break;
case 0x00180010: conv = rgb16to24; break;
case 0x00180020: conv = rgb32to24; break;
case 0x0020000F: conv = rgb15to32; break;
case 0x00200010: conv = rgb16to32; break;
case 0x00200018: conv = rgb24to32; break;
}
} else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
(isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
switch (srcId | (dstId << 16)) {
case 0x000C000C: conv = rgb12tobgr12; break;
case 0x000F000F: conv = rgb15tobgr15; break;
case 0x000F0010: conv = rgb16tobgr15; break;
case 0x000F0018: conv = rgb24tobgr15; break;
case 0x000F0020: conv = rgb32tobgr15; break;
case 0x0010000F: conv = rgb15tobgr16; break;
case 0x00100010: conv = rgb16tobgr16; break;
case 0x00100018: conv = rgb24tobgr16; break;
case 0x00100020: conv = rgb32tobgr16; break;
case 0x0018000F: conv = rgb15tobgr24; break;
case 0x00180010: conv = rgb16tobgr24; break;
case 0x00180018: conv = rgb24tobgr24; break;
case 0x00180020: conv = rgb32tobgr24; break;
case 0x0020000F: conv = rgb15tobgr32; break;
case 0x00200010: conv = rgb16tobgr32; break;
case 0x00200018: conv = rgb24tobgr32; break;
}
}
if (!conv) {
av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
} else {
const uint8_t *srcPtr = src[0];
uint8_t *dstPtr = dst[0];
if ((srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1) &&
!isRGBA32(dstFormat))
srcPtr += ALT32_CORR;
if ((dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_BGR32_1) &&
!isRGBA32(srcFormat))
dstPtr += ALT32_CORR;
if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
!(srcStride[0] % srcBpp))
conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
srcSliceH * srcStride[0]);
else {
int i;
dstPtr += dstStride[0] * srcSliceY;
for (i = 0; i < srcSliceH; i++) {
conv(srcPtr, dstPtr, c->srcW * srcBpp);
srcPtr += srcStride[0];
dstPtr += dstStride[0];
}
}
}
return srcSliceH;
}
| 1threat |
Error Invoking 'Customize'. Details: Object reference not set to an instand on an object : I'm using visual studio 2017 I have a popupmenu on my designer view where I have added a list of popup menu items. When I try to customize the menu items by clicking on popupmenu and then the customize button. Instead of displaying the popupmenu items it displays an error message saying "Error Invoking 'Customize'. Details: Object reference not set to an instand on an object".
What can I do to solve this? I have no idea on what to do. Attached to this is a picture of the error message.
[error message][1]
[1]: https://i.stack.imgur.com/OZs8Q.png | 0debug |
static void gen_msa(CPUMIPSState *env, DisasContext *ctx)
{
uint32_t opcode = ctx->opcode;
check_insn(ctx, ASE_MSA);
check_msa_access(ctx);
switch (MASK_MSA_MINOR(opcode)) {
case OPC_MSA_I8_00:
case OPC_MSA_I8_01:
case OPC_MSA_I8_02:
gen_msa_i8(env, ctx);
break;
case OPC_MSA_I5_06:
case OPC_MSA_I5_07:
gen_msa_i5(env, ctx);
break;
case OPC_MSA_BIT_09:
case OPC_MSA_BIT_0A:
gen_msa_bit(env, ctx);
break;
case OPC_MSA_3R_0D:
case OPC_MSA_3R_0E:
case OPC_MSA_3R_0F:
case OPC_MSA_3R_10:
case OPC_MSA_3R_11:
case OPC_MSA_3R_12:
case OPC_MSA_3R_13:
case OPC_MSA_3R_14:
case OPC_MSA_3R_15:
gen_msa_3r(env, ctx);
break;
case OPC_MSA_ELM:
gen_msa_elm(env, ctx);
break;
case OPC_MSA_3RF_1A:
case OPC_MSA_3RF_1B:
case OPC_MSA_3RF_1C:
gen_msa_3rf(env, ctx);
break;
case OPC_MSA_VEC:
gen_msa_vec(env, ctx);
break;
case OPC_LD_B:
case OPC_LD_H:
case OPC_LD_W:
case OPC_LD_D:
case OPC_ST_B:
case OPC_ST_H:
case OPC_ST_W:
case OPC_ST_D:
{
int32_t s10 = sextract32(ctx->opcode, 16, 10);
uint8_t rs = (ctx->opcode >> 11) & 0x1f;
uint8_t wd = (ctx->opcode >> 6) & 0x1f;
uint8_t df = (ctx->opcode >> 0) & 0x3;
TCGv_i32 tdf = tcg_const_i32(df);
TCGv_i32 twd = tcg_const_i32(wd);
TCGv_i32 trs = tcg_const_i32(rs);
TCGv_i32 ts10 = tcg_const_i32(s10);
switch (MASK_MSA_MINOR(opcode)) {
case OPC_LD_B:
case OPC_LD_H:
case OPC_LD_W:
case OPC_LD_D:
gen_helper_msa_ld_df(cpu_env, tdf, twd, trs, ts10);
break;
case OPC_ST_B:
case OPC_ST_H:
case OPC_ST_W:
case OPC_ST_D:
gen_helper_msa_st_df(cpu_env, tdf, twd, trs, ts10);
break;
}
tcg_temp_free_i32(twd);
tcg_temp_free_i32(tdf);
tcg_temp_free_i32(trs);
tcg_temp_free_i32(ts10);
}
break;
default:
MIPS_INVAL("MSA instruction");
generate_exception(ctx, EXCP_RI);
break;
}
} | 1threat |
def find_Min(arr,low,high):
while (low < high):
mid = low + (high - low) // 2;
if (arr[mid] == arr[high]):
high -= 1;
elif (arr[mid] > arr[high]):
low = mid + 1;
else:
high = mid;
return arr[high]; | 0debug |
Matplotlib: TypeError: 'AxesSubplot' object is not subscriptable : <p>I am trying to make a simple box plot of a variable 'x' contained in two dataframes, df1 and df2. To do this I am using the following code:</p>
<pre><code>fig, axs = plt.subplots()
axs[0, 0].boxplot([df1['x'], df2['x']])
plt.show();
</code></pre>
<p>However, I get this:</p>
<pre><code>---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-108-ce962754d553> in <module>()
----> 2 axs[0, 0].boxplot([df1['x'], df2['x']])
3 plt.show();
4
TypeError: 'AxesSubplot' object is not subscriptable
</code></pre>
<p>Any ideas?</p>
| 0debug |
Need someone to explain this code : <p>I have been trying to understand this:</p>
<pre><code>var arrayOfLabels =
[
"Hello",
"Hey",
"Hi",
"Howdy"
]
@IBOutlet weak var labelHere: UILabel!
var currentElementIndex = 0
@IBAction func clickForNextElement(_ sender: UIButton) {
currentElementIndex += 1
let numberOfElements = arrayOfLabels.count // arrayOfLabels.count = Amount of elements in arrayOfLabels
let nextElement = currentElementIndex % numberOfElements
labelHere.text = arrayOfLabels[nextElement]
}
</code></pre>
<p>I don't get what % does, what the constant "numberOfElements" & "nextElement" does.. I do get a little bit, like i would be able to code something similar to this without understanding it. That's why i need some simple, detailed explanation. </p>
<p>Thank you!</p>
| 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
How chnage image size before uploaded on server : <p>I want to change image size before uploaded on server/mysql database, As its for member, so member can uploaded big images in size and i want to prevent and assign a new image size of their images.</p>
<p>I need it in PHP.</p>
<p>Thanks</p>
| 0debug |
check ALL arguments in c# that they can be numeric : <p>I am writing a small console application in C# and it requires two numeric parameters/arguments to be passed to it. I am checking for no params, more than 2 params, if two params. I am also converting those params if 2 returned to numeric for calculations I'm doing. One thing I'm not doing is verifying what's being passed is a number so assume program will crap out if I pass a letter. Is there a look routing I can just run to verify the params passed are in deed able to be numbers? I can handle the kick out from there but curious how you check if an argument CAN be a number or not.</p>
<p>Thanks.</p>
<p>JR</p>
| 0debug |
Why does clang still need libgcc.a to compile my code? : <pre><code>int main(int argc, char **argv)
{
return 0;
}
</code></pre>
<p>I cross compile (host= linux x86_64, target= linux aarch64)</p>
<p><code>/path/to/clang --target=aarch64-linux-gnu -v main.cpp -o main -fuse-ld=lld -L./libs -lc -lc_nonshared -Xlinker -Map=a.map</code></p>
<p>In the -L./libs folder I've put all the dependencies from the target. When I exclude libgcc.a this linker error happens</p>
<p><code>ld.lld: error: unable to find library -lgcc</code></p>
<p>I've added the -Map option to get information about the linked static libraries. In the map file I cannot see references to libgcc.a ... but I battle to read the map file. There are plenty of lines with <code><internal></code>. Not sure what those are. See a.map at the bottom</p>
<p><strong>Questions</strong></p>
<ol>
<li>Why is libgcc.a still required for such a simple program? I read <a href="https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html" rel="noreferrer">1</a> and <a href="https://stackoverflow.com/questions/9414625/do-i-really-need-libgcc">2</a> and I looked at <a href="https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins" rel="noreferrer">3</a>.</li>
<li>Does
<ul>
<li>(a) the linker require libgcc to do its own linking work, or </li>
<li>(b) does the linker use libgcc because my code requires something that is provided for by libgcc</li>
<li>I think it's (b), but I just want to be sure.</li>
</ul></li>
</ol>
<hr>
<p>a.map</p>
<pre><code> VMA LMA Size Align Out In Symbol
10270 10270 1b 1 .interp
10270 10270 1b 1 <internal>:(.interp)
10290 10290 a8 8 .dynsym
10290 10290 a8 8 <internal>:(.dynsym)
10338 10338 e 2 .gnu.version
10338 10338 e 2 <internal>:(.gnu.version)
10348 10348 20 4 .gnu.version_r
10348 10348 20 4 <internal>:(.gnu.version_r)
10368 10368 1c 8 .gnu.hash
10368 10368 1c 8 <internal>:(.gnu.hash)
10384 10384 87 1 .dynstr
10384 10384 87 1 <internal>:(.dynstr)
10410 10410 18 8 .rela.dyn
10410 10410 18 8 <internal>:(.rela.dyn)
10428 10428 48 8 .rela.plt
10428 10428 48 8 <internal>:(.rela.plt)
10470 10470 20 4 .note.ABI-tag
10470 10470 20 4 crt1.o:(.note.ABI-tag)
10470 10470 0 1 $d
10490 10490 4 4 .rodata
10490 10490 4 4 <internal>:(.rodata)
10494 10494 c 4 .eh_frame_hdr
10494 10494 c 4 <internal>:(.eh_frame_hdr)
104a0 104a0 4 4 .eh_frame
20000 20000 210 8 .text
20000 20000 48 8 crt1.o:(.text)
20000 20000 0 1 $x
20000 20000 0 1 _start
2002c 2002c 0 1 $d
20048 20048 14 4 crti.o:(.text)
20048 20048 0 1 $x
20048 20048 14 1 call_weak_fn
20060 20060 e0 8 crtbegin.o:(.text)
20060 20060 0 1 $x
20060 20060 0 1 deregister_tm_clones
20090 20090 0 1 $d
20098 20098 0 1 $x
20098 20098 0 1 register_tm_clones
200d0 200d0 0 1 $d
200d8 200d8 0 1 $x
200d8 200d8 0 1 __do_global_dtors_aux
20108 20108 0 1 frame_dummy
20138 20138 0 1 $d
20140 20140 54 4 /tmp/main-762849.o:(.text)
20140 20140 0 1 $x.0
20140 20140 10 1 do_math(int*)
20150 20150 44 1 main
20194 20194 7c 4 ./libs/libc_nonshared.a(elf-init.oS):(.text)
20194 20194 0 1 $x
20194 20194 78 1 __libc_csu_init
2020c 2020c 4 1 __libc_csu_fini
20210 20210 0 1 crtend.o:(.text)
20210 20210 0 1 crtn.o:(.text)
20210 20210 14 4 .init
20210 20210 c 4 crti.o:(.init)
20210 20210 0 1 $x
20210 20210 0 1 _init
2021c 2021c 8 1 crtn.o:(.init)
2021c 2021c 0 1 $x
20224 20224 10 4 .fini
20224 20224 8 4 crti.o:(.fini)
20224 20224 0 1 $x
20224 20224 0 1 _fini
2022c 2022c 8 1 crtn.o:(.fini)
2022c 2022c 0 1 $x
20240 20240 50 16 .plt
20240 20240 50 16 <internal>:(.plt)
30000 30000 10 8 .data
30000 30000 4 1 crt1.o:(.data)
30000 30000 0 1 data_start
30000 30000 0 1 __data_start
30004 30004 0 1 crti.o:(.data)
30008 30008 8 8 crtbegin.o:(.data)
30008 30008 0 1 $d
30008 30008 0 1 __dso_handle
30010 30010 0 1 ./libs/libc_nonshared.a(elf-init.oS):(.data)
30010 30010 0 1 crtend.o:(.data)
30010 30010 0 1 crtn.o:(.data)
30010 30010 0 8 .tm_clone_table
30010 30010 0 8 crtbegin.o:(.tm_clone_table)
30010 30010 0 1 __TMC_LIST__
30010 30010 0 8 crtend.o:(.tm_clone_table)
30010 30010 0 1 __TMC_END__
30010 30010 30 8 .got.plt
30010 30010 30 8 <internal>:(.got.plt)
40000 40000 8 8 .jcr
40000 40000 0 8 crtbegin.o:(.jcr)
40000 40000 0 1 __JCR_LIST__
40000 40000 8 8 crtend.o:(.jcr)
40000 40000 0 1 $d
40000 40000 0 1 __JCR_END__
40008 40008 8 8 .fini_array
40008 40008 8 8 crtbegin.o:(.fini_array)
40008 40008 0 1 $d
40008 40008 0 1 __do_global_dtors_aux_fini_array_entry
40010 40010 8 8 .init_array
40010 40010 8 8 crtbegin.o:(.init_array)
40010 40010 0 1 $d
40010 40010 0 1 __frame_dummy_init_array_entry
40018 40018 180 8 .dynamic
40018 40018 180 8 <internal>:(.dynamic)
40198 40198 8 8 .got
40198 40198 8 8 <internal>:(.got)
50000 50000 1 1 .bss
50000 50000 0 1 crt1.o:(.bss)
50000 50000 0 1 crti.o:(.bss)
50000 50000 1 1 crtbegin.o:(.bss)
50000 50000 1 1 completed.7557
50000 50000 0 1 $d
50001 50001 0 1 ./libs/libc_nonshared.a(elf-init.oS):(.bss)
50001 50001 0 1 crtend.o:(.bss)
50001 50001 0 1 crtn.o:(.bss)
0 0 24 1 .gnu_debuglink
0 0 c 1 crt1.o:(.gnu_debuglink)
c c c 1 crti.o:(.gnu_debuglink)
18 18 c 1 crtn.o:(.gnu_debuglink)
0 0 9d 1 .comment
0 0 9d 1 <internal>:(.comment)
0 0 5b8 8 .symtab
0 0 5b8 8 <internal>:(.symtab)
0 0 119 1 .shstrtab
0 0 119 1 <internal>:(.shstrtab)
0 0 228 1 .strtab
0 0 228 1 <internal>:(.strtab)
</code></pre>
| 0debug |
static void init_event_facility_class(ObjectClass *klass, void *data)
{
SysBusDeviceClass *sbdc = SYS_BUS_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(sbdc);
SCLPEventFacilityClass *k = EVENT_FACILITY_CLASS(dc);
dc->reset = reset_event_facility;
dc->vmsd = &vmstate_event_facility;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
k->init = init_event_facility;
k->command_handler = command_handler;
k->event_pending = event_pending;
}
| 1threat |
How to add tinted mask with text over images on hover : <p><img src="https://i.ibb.co/ck1BZYk/Screen-Shot-2019-02-16-at-6-43-04-PM.png" alt="my image"></p>
<p>Looking to achieve the effect in the image above. I have a bunch of svg icons. When the user hovers over each image, the image tints and white text is revealed unique to each icon. </p>
<p>What's the best practice for this effect? Make the icons the background image? Right now they are inline svg.</p>
| 0debug |
Having a Strange Issue in C++ : <p>I'm very, very new to coding.
Thought I'd start with C++, which I've been writing for about 3 days.
In order to teach myself, I've been using a mix of Sololearn, Hackerrank and writing a Text-Based Adventure Game. </p>
<p>Herein lies my issue.</p>
<p>I'm in the process of writing start-scenarios for the 3 playables in my project.
These are within separate if statements, with any decisions within those being nested if statements.
To include character health, all of this is within a single while loop, which is true while Health >= 1. </p>
<p>However,
I'm having a strange issue where, when selecting one of the 'options' (nested if statements below 'Orc'), when ran, it outputs more than one option, then repeats all text from character creation, up to that point, once.</p>
<p>This only happens when the if statement is a string.
If I change the code so that there is no string for "Item", and set "Bucket", "Rug", and "Bars" as int 1,2,3, it works as I would expect it to.
Is this an issue with strings in C++?</p>
<p>I have researched everything I can think of, including usung getline instead of cin for numerous cin statements, in case that was causing the issue, and yet no joy. </p>
<p>Please find my code below. Have I missed something?
Also, being almost completely new to this, is there a better way in which I could do this? </p>
<p>Finally, please note that only the 'Orc' segment works correctly if you feel the need to run it to get a better idea of the issue that I'm having - 'Human' and 'Elf' currently create infinite loops because I haven't written far enough into them to break the while loop yet. </p>
<p>Thanks in advance for your help!</p>
<pre><code>#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
//Name Entry
string Name;
cout << "Enter Name: " << endl;
getline (cin, Name);
//Age Entry
int Age;
cout << "Enter Age: " << endl;
cin >> Age;
//Race Entry
string Race;
cout << "Enter Race: " << endl;
cin.ignore();
getline (cin, Race);
//Stats
int Strength;
int Agility;
int Speech;
int Intellect;
int Social;
int Health=1;
//Racial Starts
while (Health >= 1) {
//Human
if (Race == "Human" || Race == "human") {
Strength = 10;
Agility = 10;
Speech = 8;
Intellect = 7;
Social = 20;
Health = 100;
cout << "Human Selected." << endl;
cout << "Starting Game!" << endl << endl;
cout << "You are in a finely furnished bedroom." << endl;}
//Elf
if (Race == "Elf" || Race == "elf") {
Strength = 8;
Agility = 14;
Speech = 12;
Intellect = 13;
Social = 10;
Health = 80;
cout << "Elf Selected." << endl;
cout << "Starting Game!" << endl << endl;
cout << "You are cleaning a finely furnished bedroom." <<endl;}
//Orc
if (Race == "Orc" || Race == "orc") {
Strength = 18;
Agility = 5;
Speech = 6;
Intellect = 3;
Social = 5;
Health = 200;
cout << "Orc Selected" << endl;
cout << "Starting Game!" << endl << endl;
cout << "You are locked in a cell." << endl << "The cell is made up of three stone walls." << endl << "There are no windows." << endl;
cout << "There is a rug on the cobbled stone floor, and a bucket in the corner." << endl << "Iron bars face into a guard's chamber." << endl << endl;
cout << "The guard is sleeping." << endl << "A shortsword rests in a scabbard on the table in fromt of him." << endl;
//Actions in this room
int Item;
cout << "Your escape lies with either the Bucket, the Rug or the Bars." << endl << "Pick an item." << endl;
string Item;
cin >> Item;
if (Item == "bucket" || Item == "Bucket") {
cout << "You place the Bucket on your head." << endl << "The bucket is full of your own excrement." << endl << "You die of disease." << endl;
Health = Health-1000; }
if (Item == "Rug" || Item == "rug") {
cout << "You lie on the rug and fall asleep." << endl << "The guard wakes up." << endl << "His irrational hatred for you causes him to draw his sword, enter your cell and sever your head." << endl;
Health = Health-1000; }
if (Item == "Bars" || Item == "bars") {
cout << "You try the bars." << endl << "You realise that this cell was not built to hold an Orc." << endl << "You bend the bars easily and step out of the cell." << endl; }
}
}
cout << "Game Over";
system("pause");
return 0;
}
</code></pre>
| 0debug |
static int alloc_refcount_block(BlockDriverState *bs,
int64_t cluster_index, void **refcount_block)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
refcount_table_index = cluster_index >> s->refcount_block_bits;
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index] & REFT_OFFSET_MASK;
if (refcount_block_offset) {
if (offset_into_cluster(s, refcount_block_offset)) {
qcow2_signal_corruption(bs, true, -1, -1, "Refblock offset %#"
PRIx64 " unaligned (reftable index: "
"%#x)", refcount_block_offset,
refcount_table_index);
return -EIO;
}
return load_refcount_block(bs, refcount_block_offset,
refcount_block);
}
}
*refcount_block = NULL;
ret = qcow2_cache_flush(bs, s->l2_table_cache);
if (ret < 0) {
return ret;
}
int64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
int block_index = (new_block >> s->cluster_bits) &
(s->refcount_block_size - 1);
s->set_refcount(*refcount_block, block_index, 1);
} else {
ret = update_refcount(bs, new_block, s->cluster_size, 1, false,
QCOW2_DISCARD_NEVER);
if (ret < 0) {
goto fail_block;
}
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, *refcount_block);
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite_sync(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
return -EAGAIN;
}
ret = qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
if (ret < 0) {
goto fail_block;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
uint64_t blocks_used = DIV_ROUND_UP(MAX(cluster_index + 1,
(new_block >> s->cluster_bits) + 1),
s->refcount_block_size);
if (blocks_used > QCOW_MAX_REFTABLE_SIZE / sizeof(uint64_t)) {
return -EFBIG;
}
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters =
size_to_clusters(s, table_size * sizeof(uint64_t));
blocks_clusters = 1 +
((table_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * s->refcount_block_size) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint64_t *new_table = g_try_new0(uint64_t, table_size);
void *new_blocks = g_try_malloc0(blocks_clusters * s->cluster_size);
assert(table_size > 0 && blocks_clusters > 0);
if (new_table == NULL || new_blocks == NULL) {
ret = -ENOMEM;
goto fail_table;
}
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
s->set_refcount(new_blocks, block++, 1);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
g_free(new_blocks);
new_blocks = NULL;
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite_sync(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
be64_to_cpus(&new_table[i]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t),
QCOW2_DISCARD_OTHER);
ret = load_refcount_block(bs, new_block, refcount_block);
if (ret < 0) {
return ret;
}
return -EAGAIN;
fail_table:
g_free(new_blocks);
g_free(new_table);
fail_block:
if (*refcount_block != NULL) {
qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
}
return ret;
}
| 1threat |
How to get pipenv running in docker? : <p>Im installing pipenv in my docker:</p>
<pre><code>RUN pip install pipenv
RUN cd /my/app/path/ && pipenv install
RUN cd /my/app/path/ && pipenv shell
</code></pre>
<p>Im getting the error:</p>
<pre><code>Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 2057, in shell
do_shell(three=three, python=python, fancy=fancy, shell_args=shell_args)
File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 1952, in do_shell
shell = os.path.abspath(PIPENV_SHELL)
File "/usr/lib/python2.7/posixpath.py", line 360, in abspath
if not isabs(path):
File "/usr/lib/python2.7/posixpath.py", line 54, in isabs
return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'
</code></pre>
<p>If I run</p>
<pre><code>RUN cd /my/app/path/ && pipenv install --system
</code></pre>
<p>instead, im getting another error:</p>
<pre><code>build 30-Sep-2017 16:50:45 Step 5/9 : RUN cd /my/app/path && pipenv install --system
build 30-Sep-2017 16:50:45 ---> Running in cffd31633074
build 30-Sep-2017 16:50:46 [91mPipfile.lock not found, creating…
build 30-Sep-2017 16:50:46 [0m[91mLocking [dev-packages] dependencies…
build 30-Sep-2017 16:50:46 [0m[91mLocking [packages] dependencies…
build 30-Sep-2017 16:50:49 [0m[91mCRITICAL:pip.utils:Error [Errno 2] No such file or directory while executing command python setup.py egg_info
build 30-Sep-2017 16:50:49 [0m[91mTraceback (most recent call last):
build 30-Sep-2017 16:50:49 File "/usr/local/bin/pipenv", line 11, in <module>
build 30-Sep-2017 16:50:49 sys.exit(cli())
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
build 30-Sep-2017 16:50:49 [0m[91m return self.main(*args, **kwargs)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 697, in main
build 30-Sep-2017 16:50:49 [0m[91m rv = self.invoke(ctx)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 1066, in invoke
build 30-Sep-2017 16:50:49 [0m[91m return _process_result(sub_ctx.command.invoke(sub_ctx))
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
build 30-Sep-2017 16:50:49 [0m[91m return ctx.invoke(self.callback, **ctx.params)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
build 30-Sep-2017 16:50:49 return callback(*args, **kwargs)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 1782, in install
build 30-Sep-2017 16:50:49 [0m[91m do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 1290, in do_init
build 30-Sep-2017 16:50:49 [0m[91m do_lock(system=system)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 1080, in do_lock
build 30-Sep-2017 16:50:49 [0m[91m pre=pre
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 421, in resolve_deps
build 30-Sep-2017 16:50:49 [0m[91m resolved_tree.update(resolver.resolve())
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/piptools/resolver.py", line 101, in resolve
build 30-Sep-2017 16:50:49 [0m[91m has_changed, best_matches = self._resolve_one_round()
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/piptools/resolver.py", line 199, in _resolve_one_round
build 30-Sep-2017 16:50:49 [0m[91m for dep in self._iter_dependencies(best_match):
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/piptools/resolver.py", line 293, in _iter_dependencies
build 30-Sep-2017 16:50:49 dependencies = self.repository.get_dependencies(ireq)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/piptools/repositories/pypi.py", line 171, in get_dependencies
build 30-Sep-2017 16:50:49 result = reqset._prepare_file(self.finder, ireq)
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/pip/req/req_set.py", line 639, in _prepare_file
build 30-Sep-2017 16:50:49 [0m[91m abstract_dist.prep_for_dist()
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
build 30-Sep-2017 16:50:49 [0m[91m self.req_to_install.run_egg_info()
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
build 30-Sep-2017 16:50:49 [0m[91m command_desc='python setup.py egg_info')
build 30-Sep-2017 16:50:49 File "/usr/local/lib/python2.7/dist-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
build 30-Sep-2017 16:50:49 [0m[91m cwd=cwd, env=env)
build 30-Sep-2017 16:50:49 File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
build 30-Sep-2017 16:50:49 [0m[91m errread, errwrite)
build 30-Sep-2017 16:50:49 File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
build 30-Sep-2017 16:50:49 [0m[91m raise child_exception
build 30-Sep-2017 16:50:49 OSError: [Errno 2] No such file or directory
error 30-Sep-2017 16:50:49 The command '/bin/sh -c cd /opt/supercrunch/function-service/lib && pipenv install --system' returned a non-zero code: 1
build 30-Sep-2017 16:50:49 [0mSending build context to Docker daemon 40.96 kB
</code></pre>
<p>But when I instead do the following:</p>
<pre><code>RUN pip install pipenv
RUN cd /my/app/path && pipenv install
RUN cd /my/app/path && pipenv install --system
</code></pre>
<p>It is working...</p>
<p>So two question: First: Why is <code>pipenv shell</code> giving me this error and Second: Why do I have to do <code>pipenv install</code> before <code>pipenv install --system</code> to get it working?</p>
<p>I would like to use pipenv to create virtual environments with different python versions and differne dependency versions.</p>
| 0debug |
Kafka10.1 heartbeat.interval.ms, session.timeout.ms and max.poll.interval.ms : <p>I am using kafka 0.10.1.1 and confused with the following 3 properties.</p>
<pre><code>heartbeat.interval.ms
session.timeout.ms
max.poll.interval.ms
</code></pre>
<p><strong>heartbeat.interval.ms</strong> - This was added in 0.10.1 and it will send heartbeat between polls.
<strong>session.timeout.ms</strong> - This is to start rebalancing if no request to kafka and it gets reset on every poll.
<strong>max.poll.interval.ms</strong> - This is across the poll.</p>
<p>But, when does kafka starts rebalancing? Why do we need these 3? What are the default values for all of them?</p>
<p>Thanks</p>
| 0debug |
how to create a multiple section tableview with horizontal scrolling like as below image? : [I want to implement same as this image][1]
[1]: https://i.stack.imgur.com/Wwqas.png
i am trying to create a similar collection view as above image in tableview but i have no clue how to do it. My data is coming from server using web service. | 0debug |
Is there a way in excel to evaluate the content of another cell in the same spreadsheet without any VBA or any other addon : I have a requirement where a cell , say A1 contains a formula , say SUM(B1:b5).
In A2 I want to execute content of A!. But when I put =(=A1) in A2 excel gives me formula error. Is there any wat I can execute content of A1 in A2 as formula
Mind you no VBA is allowed. Can someone please help? | 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
static void e1000_pre_save(void *opaque)
{
E1000State *s = opaque;
NetClientState *nc = qemu_get_queue(s->nic);
if (s->mit_timer_on) {
e1000_mit_timer(s);
}
if (nc->link_down &&
s->compat_flags & E1000_FLAG_AUTONEG &&
s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG) {
s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
}
}
| 1threat |
static int bfi_read_header(AVFormatContext * s)
{
BFIContext *bfi = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *vstream;
AVStream *astream;
int fps, chunk_header;
vstream = avformat_new_stream(s, NULL);
if (!vstream)
return AVERROR(ENOMEM);
astream = avformat_new_stream(s, NULL);
if (!astream)
return AVERROR(ENOMEM);
avio_skip(pb, 8);
chunk_header = avio_rl32(pb);
bfi->nframes = avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
fps = avio_rl32(pb);
avio_skip(pb, 12);
vstream->codecpar->width = avio_rl32(pb);
vstream->codecpar->height = avio_rl32(pb);
avio_skip(pb, 8);
vstream->codecpar->extradata = av_malloc(768);
if (!vstream->codecpar->extradata)
return AVERROR(ENOMEM);
vstream->codecpar->extradata_size = 768;
avio_read(pb, vstream->codecpar->extradata,
vstream->codecpar->extradata_size);
astream->codecpar->sample_rate = avio_rl32(pb);
if (astream->codecpar->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", astream->codecpar->sample_rate);
return AVERROR_INVALIDDATA;
}
avpriv_set_pts_info(vstream, 32, 1, fps);
vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vstream->codecpar->codec_id = AV_CODEC_ID_BFI;
vstream->codecpar->format = AV_PIX_FMT_PAL8;
vstream->nb_frames =
vstream->duration = bfi->nframes;
astream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
astream->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
astream->codecpar->channels = 1;
astream->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
astream->codecpar->bits_per_coded_sample = 8;
astream->codecpar->bit_rate =
astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
avio_seek(pb, chunk_header - 3, SEEK_SET);
avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
return 0;
}
| 1threat |
how to remove a cells from coloumn : it's quietly simple when I run this simple syntax in my text editor :
[Syntax][1]
then the output :
[output][2]
the problem is how I can remove the column so till I get this :
[csv create without python][3]
[1]: https://i.stack.imgur.com/TmWZ5.png
[2]: https://i.stack.imgur.com/XchQU.png
[3]: https://i.stack.imgur.com/PD1y4.png | 0debug |
static int kvm_put_fpu(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
struct kvm_fpu fpu;
int i;
memset(&fpu, 0, sizeof fpu);
fpu.fsw = env->fpus & ~(7 << 11);
fpu.fsw |= (env->fpstt & 7) << 11;
fpu.fcw = env->fpuc;
fpu.last_opcode = env->fpop;
fpu.last_ip = env->fpip;
fpu.last_dp = env->fpdp;
for (i = 0; i < 8; ++i) {
fpu.ftwx |= (!env->fptags[i]) << i;
}
memcpy(fpu.fpr, env->fpregs, sizeof env->fpregs);
memcpy(fpu.xmm, env->xmm_regs, sizeof env->xmm_regs);
fpu.mxcsr = env->mxcsr;
return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_FPU, &fpu);
}
| 1threat |
Axios/Vue - Prevent axios.all() to keep executing : <p>In my application wile authenticating the user I call the fetchData function. If the user token become invalid, the application will run <code>axios.all()</code> and my interceptor will return a lot of errors.</p>
<p>How to prevent <code>axios.all()</code> of keep runing after the first error? And show only one notification to the user?</p>
<p>interceptors.js</p>
<pre><code>export default (http, store, router) => {
http.interceptors.response.use(response => response, (error) => {
const {response} = error;
let message = 'Ops. Algo de errado aconteceu...';
if([401].indexOf(response.status) > -1){
localforage.removeItem('token');
router.push({
name: 'login'
});
Vue.notify({
group: 'panel',
type: 'error',
duration: 5000,
text: response.data.message ? response.data.message : message
});
}
return Promise.reject(error);
})
}
</code></pre>
<p>auth.js</p>
<pre><code>const actions = {
fetchData({commit, dispatch}) {
function getChannels() {
return http.get('channels')
}
function getContacts() {
return http.get('conversations')
}
function getEventActions() {
return http.get('events/actions')
}
// 20 more functions calls
axios.all([
getChannels(),
getContacts(),
getEventActions()
]).then(axios.spread(function (channels, contacts, eventActions) {
dispatch('channels/setChannels', channels.data, {root: true})
dispatch('contacts/setContacts', contacts.data, {root: true})
dispatch('events/setActions', eventActions.data, {root: true})
}))
}
}
</code></pre>
| 0debug |
DynamoDB update Item multi action : <p>I am trying to update an item in DynamoDB table:</p>
<pre><code>var params = {
TableName: 'User',
Key: {
id: 'b6cc8100-74e4-11e6-8e52-bbcb90cbdd26',
},
UpdateExpression: 'ADD past_visits :inc, past_chats :inc',
ExpressionAttributeValues: {
':inc': 1
},
ReturnValues: 'ALL_NEW'
};
docClient.update(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
</code></pre>
<p>It's working. But I want to set some more value (reset_time = :value') like this:</p>
<pre><code>var params = {
TableName: 'User',
Key: {
id: 'b6cc8100-74e4-11e6-8e52-bbcb90cbdd26',
},
UpdateExpression: 'ADD past_visits :inc, past_chats :inc, SET reset_time = :value',
ExpressionAttributeValues: {
':inc': 1,
':value': 0
},
ReturnValues: 'ALL_NEW'
};
docClient.update(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
</code></pre>
<p>Can DynamoDb support multi action in one query ?</p>
| 0debug |
Why must must ngrx / redux effects return actions? Is using a noop action like elm considered bad practice? : <p>I'm using a redux-style state management design with Angular and ngrx/store and ngrx/effects. Whenever I don't return an action from an effect, I get an error: </p>
<pre><code>Cannot read property 'type' of undefined
</code></pre>
<p>I researched the issue and found that in an elm architecture there is something called a "noop" action that does nothing that you can call when you don't want to chain another action with your effect. Calling this noop action everywhere seems extremely repetitive to me. I am wondering if this would be a bad practice to follow. Is there a reason you cannot have an effect that does not return an action? Is the intention of effects to always have 1 action fire another action? I'm wondering if I am misunderstanding how to use effects.</p>
<p>Thanks!</p>
| 0debug |
How to uninstall LLVM? : <p>I installed LLVM from source (using CMake and <code>make install</code>) but I am unable to uninstall it because there is no <code>make uninstall</code> avalaible.</p>
<p>This is LLVM version 3.5.2.</p>
<p>I use ArchLinux.</p>
<p>How can I uninstall LLVM in an automated way?</p>
| 0debug |
CircleCI: Error unmarshaling return header; nested exception is: : <p>We keep getting the following exception on CircleCI while building out project. Everything runs well when running the job from the CircleCI CLI. Has anyone found a fix / resolution for this?</p>
<pre><code>Compilation with Kotlin compile daemon was not successful
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:236)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.sun.proxy.$Proxy104.compile(Unknown Source)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.incrementalCompilationWithDaemon(GradleKotlinCompilerWork.kt:284)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:198)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:141)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:118)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:158)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:153)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompilerAsync(GradleKotlinCompilerRunner.kt:92)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:447)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:355)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.executeImpl(Tasks.kt:312)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:284)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:404)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:393)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:222)
... 110 more
Unable to clear jar cache after compilation, maybe daemon is already down: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
Could not connect to kotlin daemon. Using fallback strategy.
</code></pre>
| 0debug |
sklearn stratified sampling based on a column : <p>I have a fairly large CSV file containing amazon review data which I read into a pandas data frame. I want to split the data 80-20(train-test) but while doing so I want to ensure that the split data is proportionally representing the values of one column (Categories), i.e all the different category of reviews are present both in train and test data proportionally.</p>
<p>The data looks like this:</p>
<pre><code>**ReviewerID** **ReviewText** **Categories** **ProductId**
1212 good product Mobile 14444425
1233 will buy again drugs 324532
5432 not recomended dvd 789654123
</code></pre>
<p>Im using the following code to do so:</p>
<pre><code>import pandas as pd
Meta = pd.read_csv('C:\\Users\\xyz\\Desktop\\WM Project\\Joined.csv')
import numpy as np
from sklearn.cross_validation import train_test_split
train, test = train_test_split(Meta.categories, test_size = 0.2, stratify=y)
</code></pre>
<p>it gives the following error</p>
<pre><code>NameError: name 'y' is not defined
</code></pre>
<p>As I'm relatively new to python I cant figure out what I'm doing wrong or whether this code will stratify based on column categories. It seems to work fine when i remove the stratify option as well as the categories column from train-test split.</p>
<p>Any help will be appreciated.</p>
| 0debug |
Beginner JavaScript OOP vs Functional : <p>I'm just starting to research different programming styles (OOP, functional, procedural).</p>
<p>I'm learning JavaScript and starting into underscore.js and came along <a href="http://underscorejs.org/#oop" rel="noreferrer">this</a> small section in the docs.
The docs say that underscore.js can be used in a Object-Oriented or Functional style and that both of these result in the same thing.</p>
<pre><code>_.map([1, 2, 3], function(n){ return n * 2; });
_([1, 2, 3]).map(function(n){ return n * 2; });
</code></pre>
<p>I don't understand which one is functional and which one is OOP, and I don't understand why, even after some research into these programming paradigms.</p>
| 0debug |
def hamming_Distance(n1,n2) :
x = n1 ^ n2
setBits = 0
while (x > 0) :
setBits += x & 1
x >>= 1
return setBits | 0debug |
def max_product_tuple(list1):
result_max = max([abs(x * y) for x, y in list1] )
return result_max | 0debug |
I create search bar in java.But it has some error how i fixed it. Kindly help me : try {
con = DriverManager.getConnection(url, username, password);
String qry = "SELECT * FOME users WHERE id=?";
pst = con.prepareStatement(qry);
pst.setString(1, txtSearch.getText());
rs = pst.executeQuery();
tblEmployee.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
e.printStackTrace(); //Show what is the catched error
}
rs = pst.executeQuery(); is not work and get like this error
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FOME users WHERE id='df'' at line 1
| 0debug |
static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp)
{
LOCAL_ALIGNED_16(DCTELEM, block16, [16]);
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ],
q_ac = rv34_qscale_tab[s->qscale];
uint8_t *dst = s->dest[0];
DCTELEM *ptr = s->block[0];
int avail[6*8] = {0};
int i, j, itype, has_ac;
memset(block16, 0, 16 * sizeof(*block16));
if(r->avail_cache[1])
avail[0] = 1;
if(r->avail_cache[2])
avail[1] = avail[2] = 1;
if(r->avail_cache[3])
avail[3] = avail[4] = 1;
if(r->avail_cache[4])
avail[5] = 1;
if(r->avail_cache[5])
avail[8] = avail[16] = 1;
if(r->avail_cache[9])
avail[24] = avail[32] = 1;
has_ac = rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac);
if(has_ac)
r->rdsp.rv34_inv_transform(block16);
else
r->rdsp.rv34_inv_transform_dc(block16);
itype = ittrans16[intra_types[0]];
itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
r->h.pred16x16[itype](dst, s->linesize);
for(j = 0; j < 4; j++){
for(i = 0; i < 4; i++, cbp >>= 1){
int dc = block16[i + j*4];
if(cbp & 1){
has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
}else
has_ac = 0;
if(has_ac){
ptr[0] = dc;
r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr);
}else
r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc);
}
dst += 4*s->linesize;
}
itype = ittrans16[intra_types[0]];
if(itype == PLANE_PRED8x8) itype = DC_PRED8x8;
itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
for(j = 1; j < 3; j++){
dst = s->dest[j];
r->h.pred8x8[itype](dst, s->uvlinesize);
for(i = 0; i < 4; i++, cbp >>= 1){
uint8_t *pdst;
if(!(cbp & 1)) continue;
pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize;
rv34_process_block(r, pdst, s->uvlinesize,
r->chroma_vlc, 1, q_dc, q_ac);
}
}
}
| 1threat |
What is the Parigot Mendler encoding? : <p>The following encoding of Nats is used in some Cedille sources:</p>
<pre><code>cNat : ★
cNat = ∀ X : ★ . X ➔ (∀ R : ★ . (R ➔ X) ➔ R ➔ X) ➔ X
cZ : cNat
cZ = Λ X . λ z . λ s . z
cS : ∀ A : ★ . (A ➔ cNat) ➔ A ➔ cNat
cS = Λ A . λ e . λ d . Λ X . λ z . λ s . s · A (λ a . e a · X z s) d
</code></pre>
<p>I wonder if this is a common encoding used in other languages (Agda, Idris, Coq). If so, how can I interpret it, how it works, and how can I construct members of this type?</p>
<p>I've tried applying <code>cS</code> as in:</p>
<pre><code>c0 = cZ
c1 = (cS -CNat (λ p : CNat . p) C0)
c2 = (cS -CNat (λ p : CNat . p) C1)
c3 = (cS -CNat (λ p : CNat . p) C2)
</code></pre>
<p>Which checks, but looks rather weird to me. <code>p</code> could be replaced by any <code>cNat</code> inside lambdas, for example. This doesn't look isomorphic to <code>cNat</code> to me. I guess I don't get this structure.</p>
| 0debug |
static int connect_to_ssh(BDRVSSHState *s, QDict *options,
int ssh_flags, int creat_mode, Error **errp)
{
int r, ret;
const char *host, *user, *path, *host_key_check;
int port;
if (!qdict_haskey(options, "host")) {
ret = -EINVAL;
error_setg(errp, "No hostname was specified");
goto err;
}
host = qdict_get_str(options, "host");
if (qdict_haskey(options, "port")) {
port = qdict_get_int(options, "port");
} else {
port = 22;
}
if (!qdict_haskey(options, "path")) {
ret = -EINVAL;
error_setg(errp, "No path was specified");
goto err;
}
path = qdict_get_str(options, "path");
if (qdict_haskey(options, "user")) {
user = qdict_get_str(options, "user");
} else {
user = g_get_user_name();
if (!user) {
error_setg_errno(errp, errno, "Can't get user name");
ret = -errno;
goto err;
}
}
if (qdict_haskey(options, "host_key_check")) {
host_key_check = qdict_get_str(options, "host_key_check");
} else {
host_key_check = "yes";
}
g_free(s->hostport);
s->hostport = g_strdup_printf("%s:%d", host, port);
s->sock = inet_connect(s->hostport, errp);
if (s->sock < 0) {
ret = -EIO;
goto err;
}
s->session = libssh2_session_init();
if (!s->session) {
ret = -EINVAL;
session_error_setg(errp, s, "failed to initialize libssh2 session");
goto err;
}
#if TRACE_LIBSSH2 != 0
libssh2_trace(s->session, TRACE_LIBSSH2);
#endif
r = libssh2_session_handshake(s->session, s->sock);
if (r != 0) {
ret = -EINVAL;
session_error_setg(errp, s, "failed to establish SSH session");
goto err;
}
ret = check_host_key(s, host, port, host_key_check, errp);
if (ret < 0) {
goto err;
}
ret = authenticate(s, user, errp);
if (ret < 0) {
goto err;
}
s->sftp = libssh2_sftp_init(s->session);
if (!s->sftp) {
session_error_setg(errp, s, "failed to initialize sftp handle");
ret = -EINVAL;
goto err;
}
DPRINTF("opening file %s flags=0x%x creat_mode=0%o",
path, ssh_flags, creat_mode);
s->sftp_handle = libssh2_sftp_open(s->sftp, path, ssh_flags, creat_mode);
if (!s->sftp_handle) {
session_error_setg(errp, s, "failed to open remote file '%s'", path);
ret = -EINVAL;
goto err;
}
r = libssh2_sftp_fstat(s->sftp_handle, &s->attrs);
if (r < 0) {
sftp_error_setg(errp, s, "failed to read file attributes");
return -EINVAL;
}
qdict_del(options, "host");
qdict_del(options, "port");
qdict_del(options, "user");
qdict_del(options, "path");
qdict_del(options, "host_key_check");
return 0;
err:
if (s->sftp_handle) {
libssh2_sftp_close(s->sftp_handle);
}
s->sftp_handle = NULL;
if (s->sftp) {
libssh2_sftp_shutdown(s->sftp);
}
s->sftp = NULL;
if (s->session) {
libssh2_session_disconnect(s->session,
"from qemu ssh client: "
"error opening connection");
libssh2_session_free(s->session);
}
s->session = NULL;
return ret;
}
| 1threat |
Alpine 3.3, Python 2.7.11, urllib2 causing SSL: CERTIFICATE_VERIFY_FAILED : <p>I have this small Dockerfile</p>
<pre><code>FROM alpine:3.3
RUN apk --update add python
CMD ["python", "-c", "import urllib2; response = urllib2.urlopen('https://www.python.org')"]
</code></pre>
<p>Building it with <code>docker build -t alpine-py/01 .</code> and then running it with <code>docker run -it --rm alpine-py/01</code> creates the following output</p>
<pre><code>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1240, in https_open
context=self._context)
File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
</code></pre>
<p>Yesterday I got bitten by the recent OpenSSL 1.0.2g release, which caused <code>py-cryptograpy</code> to not compile. Luckily the guys from <code>py-cryptography</code> released a new version on PyPI a couple of hours later. The issue was that a function in OpenSSL got a new signature.</p>
<p>Could this be related or am I missing something?</p>
| 0debug |
What is the concern about bad request(400) or forbidden(403)? : <p>I am implementing an endpoint which offer some secret data and I want to make a simple verify mechanism. Which status should I response when user does not have the correct crediential?</p>
<p>400? 403? Or something else?</p>
<p>thanks.</p>
| 0debug |
Flutter - Vertical Divider : <p>In flutter, is there an option to draw a vertical line between components as in the image. </p>
<p><a href="https://i.stack.imgur.com/rzquW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rzquW.png" alt="enter image description here"></a></p>
| 0debug |
Javascript reduce a number by a percentage within a class : <p>I have a third-party estimation tool that is consistently providing results 30% higher than it should, and getting the company to update the tool isn't an option. So, how can I use Javascript/jQuery DOM to adjust the numbers being rendered?</p>
<pre><code><div class="general-avg"><strong>$276,000</strong></div>
</code></pre>
<p>I would like to capture the $276,000 as a variable and then reduce it by 30%. Can anyone explain how to do this? TIA</p>
| 0debug |
Returning multiple elements in JSX : <p>I'm trying to return two links if the user is not logged in. Something like this:</p>
<pre><code><Nav>
{if(this.state.user) {
<NavItem onClick={this.logout}>Log out</NavItem>
} else {
<NavItem onClick={this.login}>Log in</NavItem>
<NavItem onClick={this.register}>Register</NavItem>
}
}
</Nav>
</code></pre>
<p>I know I can do this with a ternary operator:</p>
<pre><code><Nav>
{this.state.user ?
<NavItem onClick={this.logout}>Log out</NavItem>
:
<NavItem onClick={this.login}>Log in</NavItem>
}
</Nav>
</code></pre>
<p>The problem is I want to render the two NavItems. I saw I can do it with a function, but when I try to do it in a function like this:</p>
<pre><code>myFunction(){
return(
<NavItem onClick={this.login}>Zaloguj się</NavItem>
<NavItem onClick={this.login}>Zaloguj się</NavItem>
)
}
</code></pre>
<p>It tells me that the second element is unreachable and breaks. So how can I return two elements? Stringifying the code doesn't help</p>
| 0debug |
Change gravity of image drawable in textview : <p>I've added image Drawable start in a TextView . Problem is i cant control the gravity of that Drawable in TextView </p>
<p>What i need to achieve
<a href="https://i.stack.imgur.com/e1B7N.png" rel="noreferrer"><img src="https://i.stack.imgur.com/e1B7N.png" alt="What i need to achieve "></a></p>
<p>What i have achieved so far </p>
<p><a href="https://i.stack.imgur.com/CSEDX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CSEDX.png" alt="What i have achieved so far "></a></p>
<p>This is my TextView </p>
<pre><code> <TextView
android:id="@+id/tv_8_digit_check"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawablePadding="@dimen/dimen_4"
android:drawableStart="@drawable/ic_validate"
android:text="@string/at_least_8_characters_txt"
android:textColor="@color/white_trans"
android:textSize="12sp" />
</code></pre>
<p>Any suggestion on how can i set gravity of that Drawable to top/start? Thanks </p>
| 0debug |
insert into column data into new table : I have one table that a two column and want to insert this two column data in another table means e.g.
Table 1 Column1 Column2
A B
table1 column1 and column2 value insert into second table as row wise
means result should be below
Table2 column3
A
B | 0debug |
tasmerrors! urgent! font : After compiling by Tasm 5 and 3 (I tried with both version of Tasm) it show me a few Error! that I dont know why!
please help me
thanks a lot
**==Error messages==**
C:\TASM>tasm fonts.txt
Turbo Assembler Uersion 3.0(also: TURBO ASSEMBLER 5.0) Copyright © 1988, 1991 Borland International
Assembling file: fonts.txt
*-*Error*-» fonts.txt(4) Illegal instruction
*-*Error*-» fonts.txt(15) Illegal instruction
*-*Error*-» fonts.txt( 148) Undefined symbol: FONT1
*-*Error*-» fonts.txt( 154) Undefined symbol: FONT2
Error messages: 4
Warning messages: None
Passes: 1
Rema ining memory: 470k
**===================my codes:===========================**
`.MODEL LARGE, PASCAL
.386
.DATA
FONT1
db 000h,000h,000h,000h,000h,000h,000h,030h,048h,048h,030h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,060h,070h,070h,038h,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,044h,0FCh,0F8h,060h,030h,030h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,04Ah,0FEh,0F4h,060h,030h,030h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,04Eh,0F0h,0FEh,07Ch,030h,030h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,030h,038h,02Ch,044h,042h,082h,092h,0FEh,06Ch,000h,000h,000h
db 000h,000h,000h,000h,040h,07Ch,03Ch,004h,004h,004h,006h,007h,003h,000h,000h,000h
db 000h,000h,000h,000h,082h,0C6h,0C6h,06Ch,028h,038h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,010h,010h,010h,038h,028h,06Ch,0C6h,0C6h,082h,000h,000h,000h
db 000h,000h,000h,000h,070h,0F8h,088h,0F8h,078h,008h,00Ch,00Eh,006h,000h,000h,000h
FONT2
db 000h,000h,000h,000h,000h,000h,000h,030h,048h,048h,030h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,030h,038h,038h,01Ch,00Ch,00Ch,004h,004h,004h,000h,000h,000h
db 000h,000h,000h,000h,022h,07Eh,07Ch,030h,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,025h,07Fh,07Ah,030h,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,027h,078h,07Fh,03Eh,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,018h,01Ch,016h,022h,021h,041h,041h,07Fh,036h,000h,000h,000h
db 000h,000h,000h,000h,042h,07Eh,03Eh,004h,004h,004h,006h,003h,003h,001h,000h,000h
db 000h,000h,000h,000h,041h,063h,063h,036h,014h,01Ch,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,008h,008h,008h,01Ch,014h,036h,063h,063h,041h,000h,000h,000h
db 000h,000h,000h,000h,038h,07Ch,044h,07Ch,03Ch,004h,004h,006h,007h,003h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,018h,020h,038h,038h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,0FFh,000h,000h,000h,000h,000h
db 000h,000h,000h,01Ch,03Eh,022h,020h,010h,008h,008h,000h,008h,000h,000h,000h,000h
db 000h,002h,032h,04Ch,000h,010h,018h,018h,018h,018h,018h,018h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,010h,008h,011h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,00Ch,010h,00Ch,00Ah,014h,008h,000h,000h,000h,000h
db 000h,000h,000h,010h,018h,018h,018h,018h,018h,018h,018h,018h,000h,000h,000h,000h
db 000h,000h,000h,008h,008h,008h,008h,008h,008h,00Fh,007h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,041h,081h,0FFh,07Eh,000h,008h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,001h,0FFh,0FEh,000h,020h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,041h,081h,0FFh,07Eh,000h,028h,010h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,001h,0FFh,0FEh,000h,050h,020h,000h,000h
db 000h,000h,000h,000h,000h,028h,000h,041h,081h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,028h,000h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,010h,028h,000h,041h,081h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,010h,028h,000h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,01Fh,03Fh,060h,044h,040h,061h,03Eh
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,0FFh,0FEh,000h,008h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,01Fh,03Fh,060h,04Ah,044h,061h,03Eh
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,0FFh,0FEh,000h,038h,010h,000h,000h
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,01Fh,03Fh,060h,040h,040h,061h,03Eh
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,000h,01Ch,026h,003h,01Fh,03Fh,060h,040h,040h,061h,03Eh
db 000h,000h,000h,000h,008h,000h,01Ch,026h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,00Ch,006h,003h,03Fh,03Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,000h,00Ch,006h,003h,03Fh,03Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,002h,007h,003h,003h,006h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,000h,002h,000h,002h,007h,003h,003h,007h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,004h,00Ah,000h,002h,007h,003h,003h,006h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,000h,000h,000h,001h,049h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,014h,000h,001h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,008h,014h,000h,001h,049h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,003h,005h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,000h,000h,006h,009h,051h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,000h,003h,005h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,004h,000h,006h,009h,051h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,020h,020h,020h,02Eh,031h,021h,0FFh,0FEh,000h,000h,000h,000h,000h
db 011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h
db 055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh
db 0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0F8h,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,0F8h,018h,0F8h,018h,018h,018h,018h,018h,018h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0F6h,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FEh,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,0F8h,018h,0F8h,018h,018h,018h,018h,018h,018h
db 036h,036h,036h,036h,036h,036h,036h,0F6h,006h,0F6h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,0FEh,006h,0F6h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,0F6h,006h,0FEh,000h,000h,000h,000h,000h,000h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0FEh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,0F8h,018h,0F8h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0F8h,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,01Fh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0FFh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,01Fh,018h,018h,018h,018h,018h,018h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0FFh,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,01Fh,018h,01Fh,018h,018h,018h,018h,018h,018h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,037h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,037h,030h,03Fh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,03Fh,030h,037h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,0F7h,000h,0FFh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,0FFh,000h,0F7h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,037h,030h,037h,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,0FFh,000h,0FFh,000h,000h,000h,000h,000h,000h
db 036h,036h,036h,036h,036h,036h,036h,0F7h,000h,0F7h,036h,036h,036h,036h,036h,036h
db 018h,018h,018h,018h,018h,018h,018h,0FFh,000h,0FFh,000h,000h,000h,000h,000h,000h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0FFh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,0FFh,000h,0FFh,018h,018h,018h,018h,018h,018h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,03Fh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,01Fh,018h,01Fh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,01Fh,018h,01Fh,018h,018h,018h,018h,018h,018h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,03Fh,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0FFh,036h,036h,036h,036h,036h,036h
db 018h,018h,018h,018h,018h,018h,018h,0FFh,018h,0FFh,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0F8h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,01Fh,018h,018h,018h,018h,018h,018h
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
db 0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h
db 00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,020h,024h,020h,02Eh,031h,021h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,00Ch,01Eh,020h,03Eh,03Eh,040h,080h,080h,0C1h,0FEh,07Ch
db 000h,000h,000h,000h,000h,000h,038h,044h,038h,03Fh,04Fh,080h,080h,0C2h,0FCh,078h
db 000h,000h,000h,000h,000h,000h,01Ch,022h,01Ch,0FFh,0E7h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,00Ch,01Eh,020h,0FEh,0FCh,000h,000h,000h,000h,000h
db 000h,000h,000h,004h,000h,00Ch,01Eh,020h,03Eh,03Eh,040h,080h,080h,0C1h,0FEh,07Ch
db 000h,000h,000h,000h,010h,000h,038h,044h,038h,03Fh,04Fh,080h,080h,0C2h,0FCh,078h
db 000h,000h,000h,000h,008h,000h,01Ch,022h,01Ch,0FFh,0E7h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,004h,000h,00Ch,01Eh,020h,0FEh,0FCh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,002h,000h,002h,047h,085h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,002h,000h,002h,007h,005h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,014h,000h,002h,007h,005h,087h,081h,081h,083h,07Eh,03Ch,000h
db 000h,000h,000h,000h,00Ah,000h,002h,007h,005h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,001h,003h,006h,00Ch,008h,00Ch,086h,083h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,001h,003h,006h,00Ch,008h,00Ch,006h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,005h,00Bh,016h,00Ch,008h,00Ch,086h,083h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,005h,00Bh,016h,00Ch,008h,00Ch,006h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,001h,001h,001h,001h,001h,001h,001h,081h,081h,0FEh,07Ch,000h,000h
db 000h,000h,000h,001h,061h,031h,019h,009h,005h,007h,00Eh,038h,000h,000h,000h,000h
db 000h,000h,000h,001h,001h,001h,001h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,006h,00Bh,07Fh,0FEh,080h,080h,080h,080h,080h
db 000h,000h,000h,000h,000h,000h,000h,006h,00Fh,0FDh,0FFh,006h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,010h,001h,081h,081h,081h,0FEh,07Ch,000h
db 000h,000h,000h,000h,000h,004h,000h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,006h,009h,00Fh,00Fh,003h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,004h,00Eh,00Fh,013h,013h,01Fh,00Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,010h,0F3h,0F3h,00Ch,004h,000h,000h,000h
db 000h,000h,000h,000h,000h,00Ch,01Eh,03Fh,0C9h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,007h,007h,00Eh,083h,081h,0FFh,07Eh,000h
db 000h,000h,000h,000h,000h,000h,006h,00Fh,010h,01Eh,08Fh,081h,081h,0FEh,07Ch,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,001h,0FFh,0FEh,000h,024h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
.CODE
Assume es:@DATA
public Font
FONT proc PASCAL
lea bp, FONT1
mov dx,48
mov bx,1000h
mov cx,10
mov ax,1110h
int 10h
lea bp,FONT2
mov dx,128
push ds
pop es
mov bx,1000h
mov cx,127
mov ax,1110h
int 10h
ret
FONT ENDP
END
`
Some friends said:Line 14,15 needed a ":" at end of labels eg.`font1:` but these are not a label, these are NAME for a group of "db" and already used a ":" at the end of it and after compile it show me errors (CS UNREACHABLE FROM CURRENT SEGMENT(for: LINE 4,15))
**it's urgent and urgent!**
thaks a lot
| 0debug |
Continue loop on array after it's over : <p>I have an array with length of 26, each element a letter of the alphabet. I also have an N which can be from -10 to 10.
The N takes the letter and changes it this way.
if my letter is 'a' and N = 2 my 'a' will become 'c', if my letter is 'c' and N = -1 my 'c' will become 'b'.</p>
<p>When i have a letter like 'z' which is the last element of the array and i give N a value it returns undefined.</p>
<p>How can I make it continue to loop on the array. For example if my letter is 'y' and N = 5 then it will give me a 'd'. Hope you understood me xD.</p>
| 0debug |
Why seems there is no JavaScript code until I scroll? : I just started using javascript, and I do not understand why my javascript code doesn't works until I start to scroll a little bit(so I see my logo and my menu page like there is no Javascript code). I don't understand also why it works only at the end of the body, and not in the tag head or by linking it.
<script type="text/javascript">
$(window).scroll(function() {
var scrollPos = $(this).scrollTop();
$(".textLogo").css({
'font-size' : 690 - scrollPos + '%'
});
});
$(window).scroll(function() {
var scrollTop = $(this).scrollTop();
$('.menu').css({
opacity: function() {
var elementHeight = $(this).height();
return 1 - (elementHeight - scrollTop) / elementHeight;
}
});
});
</script>
CSS
.textLogo{
color: #1C1C1C;
text-align: center;
font-size: 110px;
padding: 120px;
position: absolute;
margin-bottom: 800px;
width: 100%;
} | 0debug |
Portuguese Vehicle plate verification : I want to validate if a plate of a portuguese car is valid.
Portuguese Plate is XX-XX-XX alpha numeric.
It's Alpha numeric but you can´t have a number and a Char on the same position
Example : A5-99-AB -> It's wrong / 55-99-AB-> it's right
| 0debug |
How can i speed up my Android App testing : if have an app release in the playstore and whenever i am working on updates, my testcycles take way too long.
The problem is, if i want to copy my own built apk to my phone, it recognizes it as may apk from the playstore and asks if i want to update it. If i try to update, it stops and says it could not be installed.
So what i have to do is upload my app to google dev console als intern test track and wait until it is there as an update on my phone. This can take nearly an hour. So if i want to test simple stuff, i have to wait nearly an hour to see the results. That is not practicable.
Is there any way to fasten my testing workflow up?
I think i am missing a really simple thing right now.
Currently i am working with some google play game services. Maybe that makes any difference. | 0debug |
Does Firebase still support Mac OS X - July 2016 : <p>I have an iOS App that uses the Firebase Realtime Database that I would like to create for Mac OS X. Does Firebase still support Mac OS X in the latest update as the Firebase console only shows the option to Add Firebase to an iOS, Android or web app.</p>
<p>If so, where can I find it?</p>
<p>Thank you</p>
| 0debug |
static inline TCGv gen_ld16u(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld16u(tmp, addr, index);
return tmp;
}
| 1threat |
Sub folder are not copying : This is the [function][1] that i am using to copy folders content into antoher folder but its not copying the sub folder not its internal data:
private static void DirectoryCopy(
string sourceDirName, string destDirName, bool copySubDirs)
{
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
DirectoryInfo[] dirs = dir.GetDirectories();
// If the source directory does not exist, throw an exception.
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}
// If the destination directory does not exist, create it.
if (!Directory.Exists(destDirName))
{
Debug.Log("Directory created.." + destDirName);
Directory.CreateDirectory(destDirName);
}
// Get the file contents of the directory to copy.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
// Create the path to the new copy of the file.
string temppath = Path.Combine(destDirName, file.Name);
// Copy the file.
file.CopyTo(temppath, false);
}
// If copySubDirs is true, copy the subdirectories.
if (copySubDirs)
{
foreach (DirectoryInfo subdir in dirs)
{
// Create the subdirectory.
string temppath = Path.Combine(destDirName, subdir.Name);
// Copy the subdirectories.
DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
}
While I am calling it
string destingationPath = startupFolder + @"\NetworkingDemoPlayerWithNetworkAwareShooting1_Data";
DirectoryCopy("NetworkingDemoPlayerWithNetworkAwareShooting1_Data", destingationPath, true);
[1]: http://stackoverflow.com/questions/1974019/folder-copy-in-c-sharp | 0debug |
i want to create a table in javascript in which i have a for loop that generates terms in a sequence : I have to generate a sequence with a difference of 9. starting from 7. sequence should have 20 terms. I have tested my for loop and its working fine. Question is, how do I embedd this for loop in a table in javascript? Just want the table to have one column (sequence in for loop)
<script type="text/javascript">
var i;
var p;
for (i = 0; i<20;i++)
{
p=i*9+7;
document.writeln(p + "<br>");
}
</script>
| 0debug |
Which are the best methods to reduce the number of variables in R? : <p>Which are the best methods to reduce the number of variables?
What are the R functions to perform the same?</p>
| 0debug |
c# double rounding for xx.5 : Is it a good idea to write an extension method for my application , and specify precision or is there any other good idea or other way to achieve **expected** results?
Due to the behavior of Convert.ToInt32 to truncate , I am doing something like **below** to achieve expected results
> **Note:** Application requirement is to have percentages as **Integer** and not **decimals** eg 50.50 is 51 and not 50.5
public decimal TotalScore { get; set; }
public int TotalCount { get; set; }
[DataMember(Name = "currentScore")]
public int? CurrentScore
{
get
{
if (TotalCount > 0)
{
//eg 0.8149863 * 100 = 81.50 ~ 82
//Convert.ToInt32 use Math.Truncate , so better to round it first
//default MidpointRounding.Toeven SO : 2.5 ~ 2 and 3.5 ~ 4
return Convert.ToInt32((Math.Round(Math.Round(TotalScore * 100, 2, MidpointRounding.AwayFromZero), MidpointRounding.AwayFromZero)) / TotalCount);
}
else
{
return null;
}
}
set
{
//Due to the fact WCF will fail with ReadOnly properties.
}
}
example:
`'0.8149863 * 100 = 81.50 ~ 82'`
`'0.2021111 * 100 = 20.21 ~ 20'`
`'0.5889681 * 100 = 58.89 ~ 59'`
> **Note:** The behavior for Math.Round is as expected when closer to '0' or '10' , but above double rounding is done specially for 'xx.5'(and works for other cases) **Convert.ToInt32** uses truncate and makes no expense in getting accurate results
I need above behavior quiet a lot , so decided to write an extension as **below** , so to call the extension when calculating percentages on decimal and expecting integer value in return
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <param name="count"></param>
/// <param name="decimals">Number of decimal places </param>
/// <returns></returns>
public static int ToIntPercentageWithPrecision(this decimal value , int count , int decimals )
{
return Convert.ToInt32((Math.Round(Math.Round(value * 100, decimals, MidpointRounding.AwayFromZero), MidpointRounding.AwayFromZero)) / count);
}
However above solution is not readable and looks confusing . Need a clean and readable solution with accuracy. | 0debug |
CSS Pointer Events – Accept Drag, Reject Click : <p><strong>tldr; I need an element to register drag and drop pointer events, but pass click and other pointer events to elements behind it.</strong></p>
<p>I am building a drag and drop photo upload feature in react using <a href="https://react-dropzone.netlify.com/" rel="noreferrer" title="react-dropzone"><code>react-dropzone</code></a>. I want the <code>dropzone</code> to be over the whole page, so if you drag a file onto any part of the page, you can drop it to upload the image. The <code>dropzone</code> is transparent when no file is dragged over it, so I need clicks to register with elements behind it.</p>
<p>To accomplish this, I gave the dropzone component the following style:</p>
<pre><code>position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
</code></pre>
<p>However, <code>pointer-events: none;</code> causes the <code>dropzone</code> to not recognize the necessary drag and drop events. Is there any way to recognize these specific pointer events, while passing others (like click) to elements behind the <code>dropzone</code>?</p>
| 0debug |
Remove strings from a list that starts with '0' : My code
----------
l=['99','08','096']
for i in l:
if i.startswith('0'):
i.replace('0','')
print(l)
Output
---------
l=['99','08','096']
| 0debug |
How do I simplify this Python coding? : **I want to simplify the last bit of the code**
UserSen = input("Enter a sentence of your choice, ")
position = {} # word -> position
words = UserSen.split()
for word in words:
if word not in position: # new word`
position[word] = len(position) + 1 # store its position
print(*map(position.__getitem__, word), sep=",")
**Just this print bit as I do not understand the "map", "getitem" and "sep" as I have not learnt this in school so it is irrelevant for me to use it.** | 0debug |
firebase deploy --only hosting gives Error: HTTP Error: 410, Unknown Error : <p>this is my log : </p>
<pre><code> [info] === Deploying to 'test-123'...
[info]
[info] i deploying hosting
[info] i hosting: preparing public directory for upload...
[debug] [2018-10-25T15:39:54.587Z] >>> HTTP REQUEST PUT https://deploy.firebase.com/v1/hosting/test-123/uploads/-LPfsRseOoTTgVVj-keR?fileCount=81&message=
Thu Oct 25 2018 21:09:54 GMT+0530 (India Standard Time)
[debug] [2018-10-25T15:40:00.337Z] <<< HTTP RESPONSE 410
[debug] [2018-10-25T15:40:00.337Z] <<< HTTP RESPONSE BODY undefined
[debug] [2018-10-25T15:40:00.339Z] TypeError: Cannot read property 'error' of undefined
at module.exports (C:\Users\user\AppData\Roaming\npm\node_modules\firebase-tools\lib\responseToError.js:10:13)
at Request._callback (C:\Users\user\AppData\Roaming\npm\node_modules\firebase-tools\lib\api.js:47:25)
at Request.self.callback (C:\Users\user\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\request\request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\request\request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\request\request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
[error]
[error] Error: An unexpected error has occurred.
</code></pre>
<p>till yesterday everything was fine</p>
<p>when i deploy functions one by one or all at the same time everything works fine</p>
<p>please suggest something if someone knows about it</p>
<p>it says HTTPS ERROR 410 which i googled and found out that means the resource has moved </p>
<p>so the url requested might not be working but when i put that in browser its working fine</p>
<p>and i upgraded node, all npm modules still no luck</p>
| 0debug |
Mat-autocomplete - How to access selected option? : <p>I know that <code>[value]</code> stores the selected Object (Offer in my case). According to materials documentation, <code>optionSelected</code> emits an event. I tried <code>[optionSelected] = "fooFn"</code> but it doesn't exist. I just want to access the Offer object. Thanks!</p>
<p>offer-search.component.html:</p>
<pre><code> <h5 #offerP>option - autoComplete</h5>
<mat-form-field id="form-field">
<input type="text" matInput [formControl]="myControl" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
<mat-option *ngFor="let option of filteredOptions$ | async" [value]="option">
{{ option.foodItem.name }}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</code></pre>
| 0debug |
void fft_calc_altivec(FFTContext *s, FFTComplex *z)
{
POWERPC_TBL_DECLARE(altivec_fft_num, s->nbits >= 6);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int ln = s->nbits;
int j, np, np2;
int nblocks, nloops;
register FFTComplex *p, *q;
FFTComplex *exptab = s->exptab;
int l;
FFTSample tmp_re, tmp_im;
POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6);
np = 1 << ln;
p=&z[0];
j=(np >> 1);
do {
BF(p[0].re, p[0].im, p[1].re, p[1].im,
p[0].re, p[0].im, p[1].re, p[1].im);
p+=2;
} while (--j != 0);
p=&z[0];
j=np >> 2;
if (s->inverse) {
do {
BF(p[0].re, p[0].im, p[2].re, p[2].im,
p[0].re, p[0].im, p[2].re, p[2].im);
BF(p[1].re, p[1].im, p[3].re, p[3].im,
p[1].re, p[1].im, -p[3].im, p[3].re);
p+=4;
} while (--j != 0);
} else {
do {
BF(p[0].re, p[0].im, p[2].re, p[2].im,
p[0].re, p[0].im, p[2].re, p[2].im);
BF(p[1].re, p[1].im, p[3].re, p[3].im,
p[1].re, p[1].im, p[3].im, -p[3].re);
p+=4;
} while (--j != 0);
}
nblocks = np >> 3;
nloops = 1 << 2;
np2 = np >> 1;
do {
p = z;
q = z + nloops;
for (j = 0; j < nblocks; ++j) {
BF(p->re, p->im, q->re, q->im,
p->re, p->im, q->re, q->im);
p++;
q++;
for(l = nblocks; l < np2; l += nblocks) {
CMUL(tmp_re, tmp_im, exptab[l].re, exptab[l].im, q->re, q->im);
BF(p->re, p->im, q->re, q->im,
p->re, p->im, tmp_re, tmp_im);
p++;
q++;
}
p += nloops;
q += nloops;
}
nblocks = nblocks >> 1;
nloops = nloops << 1;
} while (nblocks != 0);
POWERPC_TBL_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
#else
#ifdef CONFIG_DARWIN
register const vector float vczero = (const vector float)(0.);
#else
register const vector float vczero = (const vector float){0.,0.,0.,0.};
#endif
int ln = s->nbits;
int j, np, np2;
int nblocks, nloops;
register FFTComplex *p, *q;
FFTComplex *cptr, *cptr1;
int k;
POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6);
np = 1 << ln;
{
vector float *r, a, b, a1, c1, c2;
r = (vector float *)&z[0];
c1 = vcii(p,p,n,n);
if (s->inverse)
{
c2 = vcii(p,p,n,p);
}
else
{
c2 = vcii(p,p,p,n);
}
j = (np >> 2);
do {
a = vec_ld(0, r);
a1 = vec_ld(sizeof(vector float), r);
b = vec_perm(a,a,vcprmle(1,0,3,2));
a = vec_madd(a,c1,b);
b = vec_perm(a1,a1,vcprmle(1,0,3,2));
b = vec_madd(a1,c1,b);
b = vec_perm(b,b,vcprmle(2,3,1,0));
vec_st(vec_madd(b,c2,a), 0, r);
vec_st(vec_nmsub(b,c2,a), sizeof(vector float), r);
r += 2;
} while (--j != 0);
}
nblocks = np >> 3;
nloops = 1 << 2;
np2 = np >> 1;
cptr1 = s->exptab1;
do {
p = z;
q = z + nloops;
j = nblocks;
do {
cptr = cptr1;
k = nloops >> 1;
do {
vector float a,b,c,t1;
a = vec_ld(0, (float*)p);
b = vec_ld(0, (float*)q);
c = vec_ld(0, (float*)cptr);
t1 = vec_madd(c, vec_perm(b,b,vcprmle(2,2,0,0)),vczero);
c = vec_ld(sizeof(vector float), (float*)cptr);
b = vec_madd(c, vec_perm(b,b,vcprmle(3,3,1,1)),t1);
vec_st(vec_add(a,b), 0, (float*)p);
vec_st(vec_sub(a,b), 0, (float*)q);
p += 2;
q += 2;
cptr += 4;
} while (--k);
p += nloops;
q += nloops;
} while (--j);
cptr1 += nloops * 2;
nblocks = nblocks >> 1;
nloops = nloops << 1;
} while (nblocks != 0);
POWERPC_TBL_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
#endif
}
| 1threat |
static void wm8750_audio_out_cb(void *opaque, int free_b)
{
struct wm8750_s *s = (struct wm8750_s *) opaque;
wm8750_out_flush(s);
s->req_out = free_b;
s->data_req(s->opaque, free_b >> 2, s->req_in >> 2);
}
| 1threat |
How to sort a 2D character array in lexicographical order in C? : <p>I want to sort a 2D array in lexicographical order.</p>
<p>Suppose the given 2D array is </p>
<pre><code>ebacd
fghij
olmkn
trpqs
xywuv
</code></pre>
<p>Now after arranging it in lexicographical order the array 2D array will be</p>
<pre><code>abcde
fghij
klmno
pqrst
uvwxy
</code></pre>
<p>Please provide me a logic so that I can get solve this problem. Provided number of rows and columns of the array will be same.</p>
| 0debug |
What is the difference between colorPrimary and colorPrimaryDark in themes : <p>I'm trying to understand how the theme works in android. I don't know why colorPrimaryDark won't work with me or maybe i'm doing it wrong.</p>
<p>I tried this set and my action bar turns red because of colorPrimary:</p>
<pre><code><style name="MenuTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#FF0000</item>
<item name="colorPrimaryDark">#0000FF</item>
<item name="colorAccent">#00FF00</item>
<item name="actionMenuTextColor">#0000FF</item>
</style>
</code></pre>
<p>I tried to remove the colorPrimary and it turns black (which I thought it will use blue because of colorPrimaryDark:</p>
<pre><code><style name="MenuTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">#0000FF</item>
<item name="colorAccent">#00FF00</item>
<item name="actionMenuTextColor">#0000FF</item>
</style>
</code></pre>
<p>I tried to remove the colorPrimaryDark and left the colorPrimary and it turns red again:</p>
<pre><code><style name="MenuTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#FF0000</item>
<item name="actionMenuTextColor">#0000FF</item>
</style>
</code></pre>
<p>I don't know if i'm using it in wrong way or it's not really changing at all. Can anyone tell me the difference among them?</p>
<p>I also tried actionMenuTextColor to change the text color in actionBar but nothing happened. I found out the solution using <strong>parent="Theme.AppCompat.Light.DarkActionBar"</strong> instead of <strong>parent="Theme.AppCompat.Light"</strong> alone. But of course it will only turn into white. I'm still trying to make it in different color if there is any way.</p>
| 0debug |
How to properly setState to array of objects? : <p>I have an array ob objects that creates <code>Close</code> buttons depending on how many there are of them. When i click <code>Close</code> button i would expect the array to be updated (removed) then the button element will disappear from screen. </p>
<p>I have worked out in <code>console.log</code> but unable to properly do setState :( </p>
<p>Example code here: <a href="https://codesandbox.io/s/sharp-kilby-hn2d9" rel="nofollow noreferrer">https://codesandbox.io/s/sharp-kilby-hn2d9</a></p>
<p>Any help would be greatly appreciated, i believe it's just the formatting of setState i need to do it properly, but because its array of an objects and so on i just cant figure that one out. </p>
| 0debug |
static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
PCXContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p = &s->picture;
GetByteContext gb;
int compressed, xmin, ymin, xmax, ymax, ret;
unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,
bytes_per_scanline;
uint8_t *ptr, *scanline;
if (avpkt->size < 128)
return AVERROR_INVALIDDATA;
bytestream2_init(&gb, avpkt->data, avpkt->size);
if (bytestream2_get_byteu(&gb) != 0x0a || bytestream2_get_byteu(&gb) > 5) {
av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
return AVERROR_INVALIDDATA;
}
compressed = bytestream2_get_byteu(&gb);
bits_per_pixel = bytestream2_get_byteu(&gb);
xmin = bytestream2_get_le16u(&gb);
ymin = bytestream2_get_le16u(&gb);
xmax = bytestream2_get_le16u(&gb);
ymax = bytestream2_get_le16u(&gb);
avctx->sample_aspect_ratio.num = bytestream2_get_le16u(&gb);
avctx->sample_aspect_ratio.den = bytestream2_get_le16u(&gb);
if (xmax < xmin || ymax < ymin) {
av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");
return AVERROR_INVALIDDATA;
}
w = xmax - xmin + 1;
h = ymax - ymin + 1;
bytestream2_skipu(&gb, 49);
nplanes = bytestream2_get_byteu(&gb);
bytes_per_line = bytestream2_get_le16u(&gb);
bytes_per_scanline = nplanes * bytes_per_line;
if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8) {
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
return AVERROR_INVALIDDATA;
}
switch ((nplanes<<8) + bits_per_pixel) {
case 0x0308:
avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&gb, 60);
if (p->data[0])
avctx->release_buffer(avctx, p);
if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
return ret;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
if ((ret = ff_get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
scanline = av_malloc(bytes_per_scanline);
if (!scanline)
return AVERROR(ENOMEM);
if (nplanes == 3 && bits_per_pixel == 8) {
for (y=0; y<h; y++) {
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++) {
ptr[3*x ] = scanline[x ];
ptr[3*x+1] = scanline[x+ bytes_per_line ];
ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
}
ptr += stride;
}
} else if (nplanes == 1 && bits_per_pixel == 8) {
int palstart = avpkt->size - 769;
for (y=0; y<h; y++, ptr+=stride) {
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
memcpy(ptr, scanline, w);
}
if (bytestream2_tell(&gb) != palstart) {
av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");
bytestream2_seek(&gb, palstart, SEEK_SET);
}
if (bytestream2_get_byte(&gb) != 12) {
av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
ret = AVERROR_INVALIDDATA;
goto end;
}
} else if (nplanes == 1) {
GetBitContext s;
for (y=0; y<h; y++) {
init_get_bits8(&s, scanline, bytes_per_scanline);
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++)
ptr[x] = get_bits(&s, bits_per_pixel);
ptr += stride;
}
} else {
int i;
for (y=0; y<h; y++) {
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++) {
int m = 0x80 >> (x&7), v = 0;
for (i=nplanes - 1; i>=0; i--) {
v <<= 1;
v += !!(scanline[i*bytes_per_line + (x>>3)] & m);
}
ptr[x] = v;
}
ptr += stride;
}
}
ret = bytestream2_tell(&gb);
if (nplanes == 1 && bits_per_pixel == 8) {
pcx_palette(&gb, (uint32_t *) p->data[1], 256);
ret += 256 * 3;
} else if (bits_per_pixel * nplanes == 1) {
AV_WN32A(p->data[1] , 0xFF000000);
AV_WN32A(p->data[1]+4, 0xFFFFFFFF);
} else if (bits_per_pixel < 8) {
bytestream2_seek(&gb, 16, SEEK_SET);
pcx_palette(&gb, (uint32_t *) p->data[1], 16);
}
*picture = s->picture;
*got_frame = 1;
end:
av_free(scanline);
return ret;
}
| 1threat |
alert('Hello ' + user_input); | 1threat |
how to find tomorrow and yesterday date in accsess : please i want filter form too show tomorrow and yesterday date
my form working good today by this macro
if [Forms]![issues]![OpenedDateFilter]="today"
applyfilter
where condition
(Year([Opened Date])=Year(Date()) And Month([Due Date])=Month(Date()) And Day([Opened Date])=Day(Date()))
thank you and please help | 0debug |
Converting Matlab code to C++ (no image processing is included in the code) : <p>I want to convert my Matlab code to c++. I did search for it but I got more confused.
Could anyone show me the simplest way to do that? If any information about code is needed please let me know. Any help is highly appreciated.</p>
| 0debug |
uint64_t blk_mig_bytes_transferred(void)
{
BlkMigDevState *bmds;
uint64_t sum = 0;
blk_mig_lock();
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
sum += bmds->completed_sectors;
}
blk_mig_unlock();
return sum << BDRV_SECTOR_BITS;
}
| 1threat |
Big Error in android studio : [please solve this problem and thank you][1]
My Buil.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.seffalabdelaziz.crazyman"
minSdkVersion 11
targetSdkVersion 25
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
[1]: https://i.stack.imgur.com/5sZF6.jpg | 0debug |
DisplayState *init_displaystate(void)
{
gchar *name;
int i;
if (!display_state) {
display_state = g_new0(DisplayState, 1);
}
for (i = 0; i < nb_consoles; i++) {
if (consoles[i]->console_type != GRAPHIC_CONSOLE &&
consoles[i]->ds == NULL) {
text_console_do_init(consoles[i]->chr, display_state);
}
name = g_strdup_printf("console[%d]", i);
object_property_add_child(container_get(object_get_root(), "/backend"),
name, OBJECT(consoles[i]), &error_abort);
g_free(name);
}
return display_state;
}
| 1threat |
How do open programs programatically using registery : ok I have been building voice applications for awhile, and I want to try something different. I want to open programs without manually putting in the programs into code.
Process.Start("notepad.exe");
I am wandering how you would execute a program using the registry, for example:
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
now the reason why I want to do this, is, I don't know what programs the client will have on the computer system.. I have tried researching and everything I find is like how I have been programming.
So is there a way to pull the program executable and execute the program.
Full Example:
if (speech == " ")
{
Start.Process(Application.ExecutablePath);
}
or is there anyway to accomplish this.. Please only people who know how to code should respond.. Please don't tell me exactly what I have posted.. Read the question, before answering.
| 0debug |
First n prime numbers using PrimeCheck fucntion : My task is to print the first n prime numbers using a CheckPrime function. I managed to do this with one number but what should I do in order for this to work and show me the first 'n' prime numbers?!
Code:
#include <iostream>
using namespace std;
int eprim(int num)
{
int bec=1,i;
for(i=2;i<=num/2;i++)
{
if(num%1==0)
{
bec=0;
break;
}
}
return bec;
}
int main()
{
int num,bec,i,n,
cout<<"intr numarul"<<endl;
cin>>num;
bec = eprim(num);
if (bec==1)
{
cout<<"este prim";
}else cout<<"Nu este prim";
return 0;
} | 0debug |
How to create package with main and test classes : I'm making a PageRank class that relies on som linear algebra operations that I've written myself. Since I couldn't be bothered to learn JUnit testing, I decided to write my own testing class for my PageRank class. Unfortunately, it wasn't as easy as I expected. Here's my basic idea:
pagerank/PageRankTest.java
package pagerank;
public class PageRankTester{
public static PageRank pagerank = new PageRank();
public static void main(String[] args){
testNorm();
testSubtract();
testDot();
testMatrixMul();
}
private static void testNorm(){
// Tests pagerank.norm()
}
private static void testSubtract(){
// Tests pagerank.subtract()
}
public static void testDot(){
// Tests pagerank.dot()
}
public static void testMatrixMul(){
// Tests pagerank.matrixMul()
}
}
pagerank/PageRank.java:
package pagerank;
import java.util.*;
import java.io.*;
public class PageRank {
public PageRank( String filename ) {
}
/* --------------------------------------------- */
private double[] dot(double[] x, double[][] P){
//returns dot product between vector and matrix
return res;
}
private double[][] matrixMul(double x, double[][] J){
//returns x*J
return J;
}
private double[] subtract(double[] x, double[] y){
//returns elementwise x-y
return v;
}
private double norm(double[] x){
// returns euclidean norm of x
return norm;
}
public static void main( String[] args ) {
if ( args.length != 1 ) {
System.err.println( "Please give the name of the link file" );
}
else {
new PageRank( args[0] );
}
}
}
This causes a number of issues.
**1:** When compiling the test class using `javac PageRankTester.java` I get the following error:
$ javac PageRankTester.java
PageRankTester.java:4: error: cannot find symbol
public static PageRank pagerank = new PageRank();
^
symbol: class PageRank
location: class PageRankTester
PageRankTester.java:4: error: cannot find symbol
public static PageRank pagerank = new PageRank();
^
symbol: class PageRank
location: class PageRankTester
2 errors
I thought when you put everything in a package you didn't have to import? My only conclusion is that I'm compiling the wrong way, because I've worked in packages where I don't need to import anything from another package.
**2:** Compiling PageRank.java works fine, but when trying to run PageRank using `java PageRank` I get:
$ java PageRank
Error: Could not find or load main class PageRank
Caused by: java.lang.NoClassDefFoundError: pagerank/PageRank (wrong name: PageRank)
I've tried `java -cp . PageRank`, to prevent this error, but with no success.
What is the proper way to achieve what I want here? | 0debug |
Hql ArrayList returning more than one type of class : this is not a "problem" because everything is working correctly, but it is really mind–boggling that it is working correctly and i can't find the answer.
So i have some simple hibernate HQL Query:
- List<Comment> commentList = session.createQuery("select c, u from Comment as c, User as u where c.postRef.id = :post_id").setParameter("post_id", postId).getResultList();
When it runs, and i look at the debugger it returns the commentList that looks like this:
- commentList - "ArrayList<E>",
- elementData - Object[10]
- [0] - Object[2]
- [0] Comment
- [1] User
- [1] - null
- [2] - null ... ( etc, to the end it's null)
And i just cannot understand it, how is it possible that in this ArrayList<E> there are two types of objects? Both Comment And User in one ArrayList, i can assume that this is creating ArrayList of objects or something, but then how is this possible that it returns ArrayList<Object> properly to List<Comment> without throwing any exception? And then my Method is also of return type "public List<Comment>", and i return this exact commentList, and everything works perfectly fine.
Appreciate any help | 0debug |
How to build Neural Network in Spark? : <p>The flow should be:</p>
<p>Input -> Word2Vectors -> Output -> NeuralNetwork</p>
<p>I have tried word2vec function of spark but I am confused with the format "MultilayerPerceptronClassifier" need as a input?</p>
| 0debug |
Why converting from base 10 to base 2 is considered slow? : <p>As stated <a href="http://codeforces.com/blog/entry/22712" rel="nofollow">here</a> it is quadratic, but why?</p>
| 0debug |
void qmp_blockdev_change_medium(const char *device, const char *filename,
bool has_format, const char *format,
bool has_read_only,
BlockdevChangeReadOnlyMode read_only,
Error **errp)
{
BlockBackend *blk;
BlockDriverState *medium_bs = NULL;
int bdrv_flags, ret;
QDict *options = NULL;
Error *err = NULL;
blk = blk_by_name(device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
goto fail;
}
if (blk_bs(blk)) {
blk_update_root_state(blk);
}
bdrv_flags = blk_get_open_flags_from_root_state(blk);
bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING |
BDRV_O_PROTOCOL);
if (!has_read_only) {
read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN;
}
switch (read_only) {
case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN:
break;
case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY:
bdrv_flags &= ~BDRV_O_RDWR;
break;
case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE:
bdrv_flags |= BDRV_O_RDWR;
break;
default:
abort();
}
if (has_format) {
options = qdict_new();
qdict_put(options, "driver", qstring_from_str(format));
}
assert(!medium_bs);
ret = bdrv_open(&medium_bs, filename, NULL, options, bdrv_flags, errp);
if (ret < 0) {
goto fail;
}
blk_apply_root_state(blk, medium_bs);
bdrv_add_key(medium_bs, NULL, &err);
if (err) {
error_propagate(errp, err);
goto fail;
}
qmp_blockdev_open_tray(device, false, false, &err);
if (err) {
error_propagate(errp, err);
goto fail;
}
qmp_x_blockdev_remove_medium(device, &err);
if (err) {
error_propagate(errp, err);
goto fail;
}
qmp_blockdev_insert_anon_medium(device, medium_bs, &err);
if (err) {
error_propagate(errp, err);
goto fail;
}
qmp_blockdev_close_tray(device, errp);
fail:
bdrv_unref(medium_bs);
}
| 1threat |
Back colour of button not changing when updated in FOR loop - VB.Net : Working in Visual Studio 2017, in Visual Basic in a Windows Form App (.NET Framework).
I'm trying to create a button where the back-colour of the button is a changing gradient. I made a simple algorithm to make the gradient change, and a time delay function to wait between the colour changes. However, the colour just doesn't update within the for loops as it carries out and only shows the final result, so how to fix it? Think it's an issue with the time delay function, but not sure, anyways here's the code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Public Sub bg_MouseClick(sender As Object, e As MouseEventArgs) Handles bg.MouseClick
Dim r As Integer = 241
Dim g As Integer = 121
Dim b As Integer = 121
For x = g To r
g += 1
bg.BackColor = Color.FromArgb(r, g, b)
timeDelay(0.01)
Next
For x = b To r
r -= 1
bg.BackColor = Color.FromArgb(r, g, b)
timeDelay(0.01)
Next
For x = b To g
b += 1
bg.BackColor = Color.FromArgb(r, g, b)
timeDelay(0.01)
Next
For x = r To g
g -= 1
bg.BackColor = Color.FromArgb(r, g, b)
timeDelay(0.01)
Next
For x = g To b
r += 1
bg.BackColor = Color.FromArgb(r, g, b)
timeDelay(0.01)
Next
For x = g To b
b -= 1
bg.BackColor = Color.FromArgb(r, g, b)
timeDelay(0.01)
Next
MessageBox.Show("Finished")
End Sub
Public Sub timeDelay(ByVal secondsDelayedBy As Double)
Dim stopwatch As New Stopwatch
Dim endtimer = False
stopwatch.Start()
Do Until endtimer = True
If stopwatch.ElapsedMilliseconds > (secondsDelayedBy * 1000) Then
endtimer = True
stopwatch.Stop()
End If
Loop
End Sub
End Class | 0debug |
Ionic 4 ion-title in toolbar is not centered on android : <p>I am wondering if this a common problem. My <code>ion-title</code> is not centered in the toolbar on android. </p>
<p>I googled it but I couldn't find anything for ionic 4, what I did found was a pretty good solution in ionic 3.</p>
<p>here it is: <a href="https://stackoverflow.com/a/30021395/4983589">https://stackoverflow.com/a/30021395/4983589</a></p>
<p>I am wondering if somebody know how to do this in ionic4?</p>
<p>Here an image how it looks on android:</p>
<p><a href="https://i.stack.imgur.com/Yaxq8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Yaxq8.png" alt="enter image description here"></a></p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
How to write Kafka consumers - single threaded vs multi threaded : <p>I have written a single Kafka consumer (using Spring Kafka), that reads from a single topic and is a part of a consumer group. Once a message is consumed, it will perform all downstream operations and move on to the next message offset. I have packaged this as a WAR file and my deployment pipeline pushes this out to a single instance. Using my deployment pipeline, I could potentially deploy this artifact to multiple instances in my deployment pool.</p>
<p>However, I am not able to understand the following, when I want multiple consumers as part of my infrastructure - </p>
<ul>
<li><p>I can actually define multiple instances in my deployment pool and
have this WAR running on all those instances. This would mean, all of
them are listening to the same topic, are a part of the same consumer
group and will actually divide the partitions among themselves. The
downstream logic will work as is. This works perfectly fine for my
use case, however, I am not sure, if this is the optimal approach to
follow ?</p></li>
<li><p>Reading online, I came across resources <a href="https://howtoprogram.xyz/2016/05/29/create-multi-threaded-apache-kafka-consumer/" rel="noreferrer">here</a> and <a href="https://www.confluent.io/blog/tutorial-getting-started-with-the-new-apache-kafka-0-9-consumer-client/" rel="noreferrer">here</a>,
where people are defining a single consumer thread, but internally,
creating multiple worker threads. There are also examples where we
could define multiple consumer threads that do the downstream logic.
Thinking about these approaches and mapping them to deployment
environments, we could achieve the same result (as my theoretical
solution above could), but with less number of machines.</p></li>
</ul>
<p>Personally, I think my solution is simple, scalable but might not be optimal, while the second approach might be optimal, but wanted to know your experiences, suggestions or any other metrics / constraints I should consider ? Also, I am thinking with my theoretical solution, I could actually employ bare bones simple machines as Kafka consumers.</p>
<p>While I know, I haven’t posted any code, please let me know if I need to move this question to another forum. If you need specific code examples, I can provide them too, but I didn’t think they are important, in the context of my question.</p>
| 0debug |
static inline int pic_is_unused(H264Context *h, Picture *pic)
{
if (pic->f.data[0] == NULL)
return 1;
if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
return 1;
return 0;
}
| 1threat |
La cascade ne marche pas sur doctrine : Je suis sous symfony 4.2.11 et j'ai besoin d'enregistrer une entité PageTemplate. Or cette entité contient des entités PageTemplateBlock qui doivent être mis à jour en base. L'entité PageTemplateBlock contient des entités PageTemplateBlockProfiled, PageTemplateBlockView et PageBlockItemVersion qui doivent aussi être mis à jour.
Au début tout marchait bien sauf que les entités PageBockItemVersion étaient supprimés par cascade..
Du coup, j'ai essayé de récupérer la liste de mes PageBlockItemVersion pour les persister (c'est sale)..
Et là je suis bloqué pour un contrainte d'intégrité SQL... Doctrine supprime mes entités correctement mais il insert un PageTemplateBlock avant le PageTemplate --'
Bref aidez-moi s'il vous plait, je doit régler ce problème rapidement et je n'ai plus d'espoirs
Résultat:
[Requêtes exécutés][1]
[Message d'erreur][2]
PageTemplate
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var string
* @ORM\Column(type="string")
*/
private $name;
/**
* @var string|null
* @ORM\Column(type="string", nullable=true)
*/
private $description;
/**
* @var Site
* @ORM\ManyToOne(targetEntity="Site", inversedBy="pageTemplates")
*/
private $site;
/**
* @var PageTemplateBlock[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageTemplateBlock", mappedBy="template", cascade={"remove", "persist"}, orphanRemoval=true)
* @ORM\OrderBy({"order"="ASC"})
*/
private $blocks;
/**
* @var PageVersion[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageVersion", mappedBy="pageTemplate", cascade={"remove", "persist"}, orphanRemoval=true)
*/
private $pageVersions;
` ``
PageTemplateBlock
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageTemplate
* @ORM\ManyToOne(targetEntity="PageTemplate", inversedBy="blocks")
*/
private $template;
/**
* @var integer
* @ORM\Column(type="integer", name="_order")
*/
private $order;
/**
* @var string
* @ORM\Column(type="string")
*/
private $name;
/**
* @var string|null
* @ORM\Column(type="string", nullable=true)
*/
private $description;
/**
* @var PageTemplateBlockProfiled[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageTemplateBlockProfiled", mappedBy="block", cascade={"remove", "persist"}, orphanRemoval=true)
*/
private $profiledData;
/**
* @var PageTemplateBlockView[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageTemplateBlockView", mappedBy="block", cascade={"remove", "persist"}, orphanRemoval=true)
*/
private $views;
/**
* @var PageBlockItemVersion[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageBlockItemVersion", mappedBy="pageTemplateBlock", cascade={"remove", "persist"}, orphanRemoval=true, fetch="EAGER")
*/
private $pageItems;
` ``
PageTemplateBlockProfiled
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageTemplateBlock
* @ORM\ManyToOne(targetEntity="PageTemplateBlock", inversedBy="profiledData")
* @ORM\JoinColumn(name="block_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $block;
/**
* @var Profile
* @ORM\ManyToOne(targetEntity="Profile", inversedBy="profiledItems")
*/
private $profile;
/**
* @var string|null
* @ORM\Column(type="string", nullable=true)
*/
private $node;
` ``
PageTemplateBlockView
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageTemplateBlock
* @ORM\ManyToOne(targetEntity="PageTemplateBlock", inversedBy="views")
* @ORM\JoinColumn(name="block_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $block;
/**
* @var View
* @ORM\ManyToOne(targetEntity="View", inversedBy="pageTemplateBlock")
*/
private $view;
/**
* @var integer
* @ORM\Column(type="integer", name="_order")
*/
private $order;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
private $locked;
/**
* @var array|null
* @ORM\Column(type="array", nullable=true)
*/
private $data;
` ``
PageBlockItemVersion
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageVersion
* @ORM\ManyToOne(targetEntity="PageVersion", inversedBy="items")
*/
private $pageVersion;
/**
* @var PageTemplateBlock
* @ORM\ManyToOne(targetEntity="PageTemplateBlock", inversedBy="pageVersions")
* @ORM\JoinColumn(name="page_template_block_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $pageTemplateBlock;
/**
* @var int
* @ORM\Column(type="integer", name="_order")
*/
private $order;
/**
* @var array
* @ORM\Column(type="array")
*/
private $data;
/**
* @var View
* @ORM\ManyToOne(targetEntity="View", inversedBy="pageBlockItems")
*/
private $view;
``
[1]: https://i.stack.imgur.com/kXr4K.png
[2]: https://i.stack.imgur.com/R2VO7.png | 0debug |
Is &arr[size] valid? : <p>Let's say I have a function, called like this:</p>
<pre><code>void mysort(int *arr, std::size_t size)
{
std::sort(&arr[0], &arr[size]);
}
int main()
{
int a[] = { 42, 314 };
mysort(a, 2);
}
</code></pre>
<p>My question is: does the code of <code>mysort</code> (more specifically, <code>&arr[size]</code>) have defined behaviour?</p>
<p>I know it would be perfectly valid if replaced by <code>arr + size</code>; pointer arithmetic allows pointing past-the-end normally. However, my question is specifically about the use of <code>&</code> and <code>[]</code>.</p>
<p>Per C++11 5.2.1/1, <code>arr[size]</code> is equivalent to <code>*(arr + size)</code>.</p>
<p>Quoting 5.3.1/1, the rules for unary <code>*</code>:</p>
<blockquote>
<p>The unary <code>*</code> operator performs indirection: the expression to which it is applied shall be a <strong>pointer to an
object type</strong>, or a pointer to a function type and the <strong>result is an lvalue referring to the object</strong> or function
<strong>to which the expression points</strong>. If the type of the expression is “pointer to <code>T</code>,” the type of the result is “<code>T</code>.”
[ <em>Note:</em> a pointer to an incomplete type (other than <em>cv</em> <code>void</code>) can be dereferenced. The lvalue thus obtained
can be used in limited ways (to initialize a reference, for example); this lvalue must not be converted to a
prvalue, see 4.1. <em>—end note</em> ]</p>
</blockquote>
<p>Finally, 5.3.1/3 giving the rules for <code>&</code>:</p>
<blockquote>
<p>The result of the unary <code>&</code> operator is a pointer to its operand. The operand shall be an lvalue ... if the type of
the expression is <code>T</code>, the result has type “pointer to <code>T</code>” and is a prvalue that is the <strong>address of the designated object</strong> (1.7) or a pointer to the designated function.</p>
</blockquote>
<p>(Emphasis and ellipses mine).</p>
<p>I can't quite make up my mind about this. I know for sure that forcing an lvalue-to-rvalue conversion on <code>arr[size]</code> would be Undefined. But no such conversion happens in the code. <code>arr + size</code> does not point to an object; but while the paragraphs above talk about objects, they never seem to explicitly call out the necessity for an object to actually exist at that location (unlike e.g. the lvalue-to-rvalue conversion in 4.1/1).</p>
<p>So, the questio is: is <code>mysort</code>, the way it's called, valid or not?</p>
<p>(Note that I'm quoting C++11 above, but if this is handled more explicitly in a later standard/draft, I would be perfectly happy with that).</p>
| 0debug |
What programming language is best suited for a 2D platformer game with my experience? : <p>Me and a few friends want to start building a 2D puzzle platformer. It uses a lot of tiles and we experienced that our test level did not run smoothly with Java. Do any of you have suggestions on which programming language/engine would be best suited to make the game? </p>
<p>We have experience with Java and Actionscript 3.</p>
<p>Thank you in advance for your advise.</p>
| 0debug |
Recursion stops after some executions : <p>I am trying to find the largest prime factor of a number. The code stops working (at least I think like that) after some executions. <code>printf</code> parts are for debugging.
The number is 600851475143.</p>
<pre><code>long recursed(long i, long j){
if (j == 1){
return i;
}
else if (i%j != 0){
printf("Else if i : %ld %ld\n", i, j);
return recursed(i, j-1);
}
else{
i /= j;
printf("Else i : %ld\n", i);
return recursed(i, i-1);
}
}
</code></pre>
| 0debug |
void object_property_add_str(Object *obj, const char *name,
char *(*get)(Object *, Error **),
void (*set)(Object *, const char *, Error **),
Error **errp)
{
StringProperty *prop = g_malloc0(sizeof(*prop));
prop->get = get;
prop->set = set;
object_property_add(obj, name, "string",
get ? property_get_str : NULL,
set ? property_set_str : NULL,
property_release_str,
prop, errp);
}
| 1threat |
Generate a html document to display my data from c# : Trying to find the best way to put/explain this.
I'm working with some API's in c# and the information I'm pulling from them, I want to display in a html document which is generated when my standalone.exe is run. Can't seem to find a clear way to do this. Any suggestions?
Thanks. | 0debug |
My code does not work, please help. It is very simple, but does not know why. : This is a test code. It is suppose to show "How are you doing today? Buddy", but it does not show anything on the page right now and console does not say anything. Anyone knows why? Help please. Thank you.
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
function demo(){
let newPara = window.document.createElement("p");
newPara.innerHTML="<h1>How are you doing today? Buddy</h1>";
document.body.append(newPara);
}
</script>
</head>
<body>
<div onload="demo()">
</div>
</body>
</html>
| 0debug |
Git apply skips patches : <p>I'm trying to apply a patch that includes binary files with <code>git apply</code> but only the files are added. I tried running <code>git apply failing.patch -v</code> and it prints something like:</p>
<blockquote>
<p>Skipped patch 'file.txt'.<br>
Checking patch file.bin...<br>
Applied patch file.bin cleanly.</p>
</blockquote>
<p>How can I find out what's the reason of the skip? As the current message is not very enlightening.</p>
| 0debug |
MySQL query with increment based on already existing values and only in rows with collum "Confirmed" not zero : I have a table that is manually edited from a webstore.
I would like to do this faster with a query.
Table: Orders
I would like to auto increment collum 'Invoice number' in all rows if collum 'status id' (is not zero / 1-5)
And i would like to start from a ceratain row (The next row after last manual input) | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.