problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
unable to delete tomcat server from eclipse : [I am unable to delete the previous existing server from the eclipse.Any help is much appreciated.][1]
[1]: https://i.stack.imgur.com/ugiOg.png | 0debug |
could anyone tell me if he ever saw this error on sql tools? : [enter image description here][1]
[1]: https://i.stack.imgur.com/be10r.png
i do not know what is the problem here
i tried to know better about this exception but all the details refer to the C# programming | 0debug |
Translate Message to Morse Code : <p>I am trying to translate a message into morse code. I am wondering how I can do this without typing a replace line (message = message.replace('a', '.-') for every single letter. Our instructor has provided us with this list of morse code to use. </p>
<pre><code>code = [["a", ".-"],["b","-..."],["c","-.-."],["d","-.."],
["e","."],["f","..-."],["g","--."],["h","...."],
["i",".."],["j",".---"],["k","-.-"],["l",".-.."],
["m","--"],["n","-."],["o","---"],["p",".--."],
["q","--.-"],["r",".-."],["s","..."],["t","-"],
["u","..-"],["v","...-"],["w",".--"],["x","-..-"],
["y","-.--"],["z","--.."]]
</code></pre>
<p>Thanks!</p>
| 0debug |
Please help me with why the output is an error ? (I faced the question in an exam) : Can't understand why curly braces are making the difference.
#include<stdio.h>
int main
{
{
int a=3;.
}
{
printf("%d", a);
}
return 0;
} | 0debug |
How do I switch an img when the user clicks it? : <p>I'm using wordpress. I've turned an image that I made into a button, and when the user CLICKS it, I want the image to change to another image of the same size, but a different color. Does anyone have a simple way of doing this?</p>
<p>Can I do everything in the "text field" of my page builder also... or do I need to also have some code in the background in my CSS editor.</p>
<p>Thanks :).</p>
| 0debug |
static int uhci_broadcast_packet(UHCIState *s, USBPacket *p)
{
UHCIPort *port;
USBDevice *dev;
int i, ret;
#ifdef DEBUG_PACKET
{
const char *pidstr;
switch(p->pid) {
case USB_TOKEN_SETUP: pidstr = "SETUP"; break;
case USB_TOKEN_IN: pidstr = "IN"; break;
case USB_TOKEN_OUT: pidstr = "OUT"; break;
default: pidstr = "?"; break;
}
printf("frame %d: pid=%s addr=0x%02x ep=%d len=%d\n",
s->frnum, pidstr, p->devaddr, p->devep, p->len);
if (p->pid != USB_TOKEN_IN) {
printf(" data_out=");
for(i = 0; i < p->len; i++) {
printf(" %02x", p->data[i]);
}
printf("\n");
}
}
#endif
for(i = 0; i < NB_PORTS; i++) {
port = &s->ports[i];
dev = port->port.dev;
if (dev && (port->ctrl & UHCI_PORT_EN)) {
ret = dev->handle_packet(dev, p);
if (ret != USB_RET_NODEV) {
#ifdef DEBUG_PACKET
if (ret == USB_RET_ASYNC) {
printf("usb-uhci: Async packet\n");
} else {
printf(" ret=%d ", ret);
if (p->pid == USB_TOKEN_IN && ret > 0) {
printf("data_in=");
for(i = 0; i < ret; i++) {
printf(" %02x", p->data[i]);
}
}
printf("\n");
}
#endif
return ret;
}
}
}
return USB_RET_NODEV;
}
| 1threat |
express routing mocha test : i have this test code for routing , how to make it function
///////////////////////////////////////////////////////////
describe("routing",function(){
it("should call function to return list of obj",function(done){
var server = require('../server.js')
request( server ).get('/listt')
.send({'id':3,'name':'name3'})
.end(function(err,res){
console.log("",res.body)
if(err){
done(err);
}else{
console.log(res.body);
var expected =[{'id':1,'name':'name1'},{'id':2,'name':'name2'},{'id':3,'name':'name3'}];
expect(res.body).to.equal (expected )
done();
}
});
});
}); | 0debug |
kotlin if (bar == null) vs. bar ?: run : <p>Here is sample</p>
<pre><code>if (bar == null) {
// do something
}
</code></pre>
<p>vs.</p>
<pre><code>bar ?: run {
// do something.
}
</code></pre>
<ol>
<li>which one is best practice? </li>
<li>what is mutating property? </li>
<li>first one dosen't work with mutating property? </li>
</ol>
| 0debug |
static inline void gen_store(DisasContext *s, int opsize, TCGv addr, TCGv val)
{
int index = IS_USER(s);
s->is_mem = 1;
switch(opsize) {
case OS_BYTE:
tcg_gen_qemu_st8(val, addr, index);
break;
case OS_WORD:
tcg_gen_qemu_st16(val, addr, index);
break;
case OS_LONG:
case OS_SINGLE:
tcg_gen_qemu_st32(val, addr, index);
break;
default:
qemu_assert(0, "bad store size");
}
gen_throws_exception = gen_last_qop;
}
| 1threat |
static uint64_t gic_do_cpu_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
GICState **backref = (GICState **)opaque;
GICState *s = *backref;
int id = (backref - s->backref);
return gic_cpu_read(s, id, addr);
}
| 1threat |
Why do I get the error object reference not set to instance of an ojbect while adding an object to a list in c# wpf? : <p>I have a C# WPF application with a form in it. The form is supposed to take two values(firstName and lastName) and then use the Instructor class to add it to my listview element. On the line <code>instList.Add(new Instructor...</code> I am getting the error <code>object reference not set to instance of an object</code>. Why does this happen?</p>
<p>This is my mainwindow.xaml.cs:</p>
<pre><code>namespace AssignmentTwoPartTwo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public List<Instructor> instList;
public MainWindow()
{
InitializeComponent();
List<Instructor> instList = new List<Instructor> { };
lvInstructorList.ItemsSource = instList;
}
private void btnCreateInstructor_Click(object sender, RoutedEventArgs e)
{
spCreateInstructor.Visibility = (spCreateInstructor.Visibility == Visibility.Hidden) ? Visibility.Visible : Visibility.Hidden;
}
private void btnInstructorSubmit_Click(object sender, RoutedEventArgs e)
{
instList.Add(new Instructor() { firstName = txtInstructorFirstName.Text, lastName = txtInstructorLastName.Text });
lvInstructorList.ItemsSource = instList;
}
}
}
</code></pre>
<p>This is Instructor.cs</p>
<pre><code>namespace AssignmentTwoPartTwo
{
public class Instructor
{
public string firstName { set; get; }
public string lastName { set; get; }
}
}
</code></pre>
| 0debug |
Open Wifi Settings by "prefs:root=WIFI" failed in iOS 10 : <p>I was using prefs:root=WIFI url scheme in my app with prefs entered in info.plist to open directly the iOS settings application in Wi-Fi settings and it was working great on iOS 9 but it does not work anymore on iOS 10.</p>
<p>Does anyone know if this is just a regression in the first developer preview or the way to open Wi-Fi settings has changed in iOS 10 or it is not allowed anymore?</p>
| 0debug |
How to filter array of dictionaries using nspredicate : <p>I am having an array of dictionaries with keys "name", "image", "email" and "phone" as keys. I want to filter the dictionaries containing email and phones separately using nspredicate, passing the dictionary key as search string. How can I achieve this. </p>
| 0debug |
What does gs protocol mean? : <p>I'm playing with <a href="https://cloud.google.com/speech/" rel="noreferrer">Google Speech Recognition API</a></p>
<p>After a successfully <a href="https://cloud.google.com/speech/docs/getting-started" rel="noreferrer">Getting started</a> I'm trying to understand and made some changes in this first example but I don't know what "gs" protocol is and how to set it to use my own audio file.</p>
<p>sync-request.json</p>
<pre><code>{
"config": {
"encoding":"FLAC",
"sample_rate": 16000
},
"audio": {
"uri":"gs://cloud-samples-tests/speech/brooklyn.flac"
}
}
</code></pre>
<p>I tried to change gs protocol to http protocol but doesn't work. </p>
<p>Thanks in advance.</p>
| 0debug |
Intl.NumberFormat either 0 or two fraction digits : <p>My formatter looks like this</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const formatter = new Intl.NumberFormat('en-NZ', {
style: 'currency',
currency: 'NZD',
minimumFractionDigits: 2,
});</code></pre>
</div>
</div>
</p>
<p>How can I adjust this so that whole numbers have 0 fraction digits</p>
<pre><code>formatter.format(4); // want output "$4"
</code></pre>
<p>whilst fractions always show two digits?</p>
<pre><code>formatter.format(4.1); // want output "$4.10"
</code></pre>
| 0debug |
Bootstrap 3 and vertically centering responsive image in div : <p>How do I get the image to vertically center in a Div/Row. I have searched but all the solutions seem to point to this being a good one - but it won't work for me. I'm using Bootstrap 3...</p>
<p><a href="https://www.bootply.com/vQFalT6KxG" rel="nofollow noreferrer">https://www.bootply.com/vQFalT6KxG</a></p>
| 0debug |
Javascript - Auto click on a button on page load : <p>I am trying to auto click on a button with id btn on page load. This is my snippet.</p>
<pre><code><button id="btn">Click me</button>
<script>
document.getElementById('btn').click();
alert("h")
</script>
</code></pre>
<p>How can I give an alert on page load? Pls help. Thanks.</p>
| 0debug |
Why having assert before main() causing compilation error? : Why assert is causing compilation error if I use it before main() call ?
It causes compilation error (Syntax error):
***"test.cpp:4:8: error: expected ')' before numeric constant"***
#include <stdio.h>
#include <assert.h>
assert(0); //If I comment assert from here, then it compiles fine.
int main()
{
assert(0);
return 0;
}
| 0debug |
Control multiple cameras with the same controls : <p>I have two different threejs scenes and each has its own camera. I can control each camera individually with a corresponding <code>TrackballControls</code> instance.</p>
<p>Is there a reliable way to 'lock' or 'bind' these controls together, so that manipulating one causes the same camera repositioning in the other? My current approach is to add <code>change</code> listeners to the controls and update both cameras to either's change, but this isn't very neat as, for one, both controls can be changing at once (due to dampening).</p>
| 0debug |
One-time login link in asp.net identity : <p>Some mobile apps like slack have popularized the idea of allowing your users to get a one-time use login link (Slack calls this the magic login link). </p>
<p>The idea is that you enter your email and instead of having to enter your password of a mobile, you request a magic login link that can be used once to log you in by opening that link on your phone.</p>
<p>I'm implementing this in asp.net identity 2.1, and I'm unsure how to ensure that the link that's generated can only be used once.</p>
<p>I generate a token like this:</p>
<pre><code>var token = await _userManager.GenerateUserTokenAsync("MyLoginLink",user.Id);
</code></pre>
<p>This token is added to a URL for the user. The action method that the link redirects you to checks that the link is valid for that user, and then logs you in:</p>
<pre><code>public async Task<ActionResult> LoginLink(string email, string token)
{
var user = await _userManager.FindByNameAsync(email);
// some checks ommited
//check for an expired token:
var result = await _userManager.VerifyUserTokenAsync(user.Id, "MyLoginLink", token);
if (!result)
{
// Failed
return RedirectToAction("Login");
}
await _userManager.UpdateSecurityStampAsync(user.Id);
await SignInAsync(user, true);
</code></pre>
<p>Now - if I update the security stamp with <code>user.UpdateSecurityStamp</code>, that re-generates the security stamp, which will invalidate this token, and ensure it can't be used again. The problem with that is that it also invalidates any existing logins, so if the user is also logged in on a desktop, they'll be forced to logoff and on again.</p>
<p>Is there a relatively simple way to create one-time use token like this in asp.net identity, that doesn't invalidate all existing logins?</p>
| 0debug |
ByteArrayOutputStream - get bytes from string : <p>How can I get similar result</p>
<pre><code>OutputStream outputStream = new ByteArrayOutputStream("asd".bytes())
</code></pre>
<p>this code don't compile</p>
| 0debug |
Dropdown on alert bootsrap v3 : ## Dropdown on alert box ##
I wanted to display a dropdown on my alert box
[What I have][1]
[1]: https://i.stack.imgur.com/Qefdk.png
I did this but nothing appears when I click on it.
That's my code :
[https://ghostbin.com/paste/wfqzv](https://ghostbin.com/paste/wfqzv)
| 0debug |
uint64_t mcf_uart_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
mcf_uart_state *s = (mcf_uart_state *)opaque;
switch (addr & 0x3f) {
case 0x00:
return s->mr[s->current_mr];
case 0x04:
return s->sr;
case 0x0c:
{
uint8_t val;
int i;
if (s->fifo_len == 0)
return 0;
val = s->fifo[0];
s->fifo_len--;
for (i = 0; i < s->fifo_len; i++)
s->fifo[i] = s->fifo[i + 1];
s->sr &= ~MCF_UART_FFULL;
if (s->fifo_len == 0)
s->sr &= ~MCF_UART_RxRDY;
mcf_uart_update(s);
qemu_chr_accept_input(s->chr);
return val;
}
case 0x10:
return 0;
case 0x14:
return s->isr;
case 0x18:
return s->bg1;
case 0x1c:
return s->bg2;
default:
return 0;
}
}
| 1threat |
Use Tensorflow Object Detection API to detect small objects in images : <p>I'd like to use the Tensorflow <a href="https://github.com/tensorflow/models/tree/master/research/object_detection" rel="noreferrer">Object Detection API</a> to identify objects in a series of webcam images. The <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md#coco-trained-models-coco-models" rel="noreferrer">Faster RCNN models</a> pre-trained on the COCO dataset appear to be suitable, as they contain all the object categories I need.</p>
<p>However, I'd like to improve the performance of the model at identifying fairly small objects within each image. If I understand correctly, I need to edit the anchor <code>scales</code> parameter in the <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/samples/configs/faster_rcnn_inception_v2_coco.config#L23" rel="noreferrer">config file</a> to get the model to use smaller bounding boxes.</p>
<p>My questions are: </p>
<ul>
<li>Do I need to re-train the model on the entire COCO dataset after I adjust this parameter? Or is there a way to change the model just for inference and avoid any re-training?</li>
<li>Are there any other tips/tricks to successfully identifying small objects, short of cropping the image into sections and running inference on each one separately?</li>
</ul>
<h3>Background info</h3>
<p>I'm currently feeding 1280x720 images to the model. At around 200x150 pixels I'm finding it harder to detect objects.</p>
| 0debug |
Forced Update of first two letter or mark as null if empty : Forced update of first letters if present else mark it as null when empty | 0debug |
YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE)
YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE)
YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE)
YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE)
static av_always_inline void
yuv2rgb_write(uint8_t *_dest, int i, unsigned Y1, unsigned Y2,
unsigned A1, unsigned A2,
const void *_r, const void *_g, const void *_b, int y,
enum PixelFormat target, int hasAlpha)
{
if (target == PIX_FMT_ARGB || target == PIX_FMT_RGBA ||
target == PIX_FMT_ABGR || target == PIX_FMT_BGRA) {
uint32_t *dest = (uint32_t *) _dest;
const uint32_t *r = (const uint32_t *) _r;
const uint32_t *g = (const uint32_t *) _g;
const uint32_t *b = (const uint32_t *) _b;
#if CONFIG_SMALL
int sh = hasAlpha ? ((target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24) : 0;
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
#else
if (hasAlpha) {
int sh = (target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24;
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
} else {
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
}
#endif
} else if (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) {
uint8_t *dest = (uint8_t *) _dest;
const uint8_t *r = (const uint8_t *) _r;
const uint8_t *g = (const uint8_t *) _g;
const uint8_t *b = (const uint8_t *) _b;
#define r_b ((target == PIX_FMT_RGB24) ? r : b)
#define b_r ((target == PIX_FMT_RGB24) ? b : r)
dest[i * 6 + 0] = r_b[Y1];
dest[i * 6 + 1] = g[Y1];
dest[i * 6 + 2] = b_r[Y1];
dest[i * 6 + 3] = r_b[Y2];
dest[i * 6 + 4] = g[Y2];
dest[i * 6 + 5] = b_r[Y2];
#undef r_b
#undef b_r
} else if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565 ||
target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555 ||
target == PIX_FMT_RGB444 || target == PIX_FMT_BGR444) {
uint16_t *dest = (uint16_t *) _dest;
const uint16_t *r = (const uint16_t *) _r;
const uint16_t *g = (const uint16_t *) _g;
const uint16_t *b = (const uint16_t *) _b;
int dr1, dg1, db1, dr2, dg2, db2;
if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565) {
dr1 = dither_2x2_8[ y & 1 ][0];
dg1 = dither_2x2_4[ y & 1 ][0];
db1 = dither_2x2_8[(y & 1) ^ 1][0];
dr2 = dither_2x2_8[ y & 1 ][1];
dg2 = dither_2x2_4[ y & 1 ][1];
db2 = dither_2x2_8[(y & 1) ^ 1][1];
} else if (target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555) {
dr1 = dither_2x2_8[ y & 1 ][0];
dg1 = dither_2x2_8[ y & 1 ][1];
db1 = dither_2x2_8[(y & 1) ^ 1][0];
dr2 = dither_2x2_8[ y & 1 ][1];
dg2 = dither_2x2_8[ y & 1 ][0];
db2 = dither_2x2_8[(y & 1) ^ 1][1];
} else {
dr1 = dither_4x4_16[ y & 3 ][0];
dg1 = dither_4x4_16[ y & 3 ][1];
db1 = dither_4x4_16[(y & 3) ^ 3][0];
dr2 = dither_4x4_16[ y & 3 ][1];
dg2 = dither_4x4_16[ y & 3 ][0];
db2 = dither_4x4_16[(y & 3) ^ 3][1];
}
dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
} else {
uint8_t *dest = (uint8_t *) _dest;
const uint8_t *r = (const uint8_t *) _r;
const uint8_t *g = (const uint8_t *) _g;
const uint8_t *b = (const uint8_t *) _b;
int dr1, dg1, db1, dr2, dg2, db2;
if (target == PIX_FMT_RGB8 || target == PIX_FMT_BGR8) {
const uint8_t * const d64 = dither_8x8_73[y & 7];
const uint8_t * const d32 = dither_8x8_32[y & 7];
dr1 = dg1 = d32[(i * 2 + 0) & 7];
db1 = d64[(i * 2 + 0) & 7];
dr2 = dg2 = d32[(i * 2 + 1) & 7];
db2 = d64[(i * 2 + 1) & 7];
} else {
const uint8_t * const d64 = dither_8x8_73 [y & 7];
const uint8_t * const d128 = dither_8x8_220[y & 7];
dr1 = db1 = d128[(i * 2 + 0) & 7];
dg1 = d64[(i * 2 + 0) & 7];
dr2 = db2 = d128[(i * 2 + 1) & 7];
dg2 = d64[(i * 2 + 1) & 7];
}
if (target == PIX_FMT_RGB4 || target == PIX_FMT_BGR4) {
dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
} else {
dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
}
}
}
| 1threat |
What kind of database I should use and how to design a database for ad network platform : <p>I want to build a ad serving platform like serving ads by words in the content. I want to make word as affiliated link. I have some campaigns with some tags words. When request comes to ad serving API it should serve suitable campaign for those words with some additional conditions. like device type and location etc... I've tried with Redis, couchbase and mongo but My API is not serving within a sec. please suggest me some database and how to design database. </p>
| 0debug |
static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
int opc)
{
int addr_reg, data_reg, arg0, arg1, arg2, mem_index, s_bits;
#if defined(CONFIG_SOFTMMU)
uint32_t *label1_ptr, *label2_ptr;
data_reg = *args++;
addr_reg = *args++;
mem_index = *args;
s_bits = opc;
arg0 = TCG_REG_O0;
arg1 = TCG_REG_O1;
arg2 = TCG_REG_O2;
#if defined(CONFIG_SOFTMMU)
tcg_out_arithi(s, arg1, addr_reg, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS,
SHIFT_SRL);
tcg_out_arithi(s, arg0, addr_reg, TARGET_PAGE_MASK | ((1 << s_bits) - 1),
ARITH_AND);
tcg_out_andi(s, arg1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
tcg_out_addi(s, arg1, offsetof(CPUState,
tlb_table[mem_index][0].addr_write));
tcg_out_arith(s, arg1, TCG_AREG0, arg1, ARITH_ADD);
tcg_out32(s, TARGET_LD_OP | INSN_RD(arg2) | INSN_RS1(arg1) |
INSN_RS2(TCG_REG_G0));
tcg_out_arith(s, TCG_REG_G0, arg0, arg2, ARITH_SUBCC);
label1_ptr = (uint32_t *)s->code_ptr;
tcg_out32(s, 0);
tcg_out_mov(s, arg0, addr_reg);
tcg_out_mov(s, arg1, data_reg);
tcg_out_movi(s, TCG_TYPE_I32, arg2, mem_index);
tcg_out32(s, CALL | ((((tcg_target_ulong)qemu_st_helpers[s_bits]
- (tcg_target_ulong)s->code_ptr) >> 2)
& 0x3fffffff));
tcg_out_ldst(s, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_ST_OP);
tcg_out_ldst(s, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_LD_OP);
label2_ptr = (uint32_t *)s->code_ptr;
tcg_out32(s, 0);
tcg_out_nop(s);
*label1_ptr = (INSN_OP(0) | INSN_COND(COND_E, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)s->code_ptr -
(unsigned long)label1_ptr));
tcg_out_ldst(s, arg1, arg1, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_write), HOST_LD_OP);
tcg_out_arith(s, arg0, addr_reg, arg1, ARITH_ADD);
arg0 = addr_reg;
switch(opc) {
case 0:
tcg_out_ldst(s, data_reg, arg0, 0, STB);
break;
case 1:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, STH);
tcg_out_ldst_asi(s, data_reg, arg0, 0, STHA, ASI_PRIMARY_LITTLE);
break;
case 2:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, STW);
tcg_out_ldst_asi(s, data_reg, arg0, 0, STWA, ASI_PRIMARY_LITTLE);
break;
case 3:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, STX);
tcg_out_ldst_asi(s, data_reg, arg0, 0, STXA, ASI_PRIMARY_LITTLE);
break;
default:
tcg_abort();
}
#if defined(CONFIG_SOFTMMU)
*label2_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)s->code_ptr -
(unsigned long)label2_ptr));
} | 1threat |
An array that takes the size depending on what I enter : <pre><code>import java.util.Scanner;
public class Singleton{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.println("Enter number of students: ");
int number = input.nextInt();
String names[] = new String[number];
for(int counter = 0; counter < 100; counter++){
System.out.print("Enter name: ");
names[counter] = input.nextLine();
names[counter] = names[counter].toLowerCase();
}
int grades[] = new int[names.length];
int count = 0;
for(String x: names){
System.out.print(x + "'s grade: ");
grades[count] = input.nextInt();
count++;
}
count = 0;
for(String x: names){
System.out.println(x + "'s grade is " + grades[count] + ".");
count++;
}
}
}
</code></pre>
<p>can you help me to get something so I can put any number of values in the array without asking how many students there are?</p>
| 0debug |
How to fix warning init() is deprecated : <p>For the code line:</p>
<pre><code>let bytesDecrypted = UnsafeMutablePointer<Int>()
</code></pre>
<p>I am getting the warning:
<strong>'init()' is deprecated: init() will be removed in Swift 3. Use <code>nil</code> instead</strong></p>
<p>What is the correct way to fix this warning?</p>
| 0debug |
Add column to data frames with specific condition in Spark/scala : <p>I have a data frame of the form (shown below) where for every id has a corresponding count of elements in the bucket. The bucket takes 3 values low, med and high.</p>
<pre><code>+---+------+-----+
| id|bucket|count|
+---+------+-----+
|id1| low| 2 |
|id1| med| 3 |
|id1| high| 4 |
|id2| low| 1 |
|id2| med| 4 |
|id3| low| 7 |
|id3| high| 1 |
|id4| med| 2 |
|id4| high| 1 |
+---+------+-----+
</code></pre>
<p>The output I desire is as follows</p>
<pre><code>+---+-----+-----+-----+
|id | low | med | high|
+---+-----+-----+-----+
|id1| 2| 3 | 4 |
|id2| 1| 4 | 0 |
|id3| 7| 0 | 1 |
|id4| 0| 2 | 1 |
+---+-----+-----+-----+
</code></pre>
<p>As seen if there is no entry for the bucket for that particular id the count in the output defaults to zero.</p>
<p>I am new to spark and unable to figure out the query for getting this result. The final schema is fixed. </p>
| 0debug |
Incorrect results when validating email addresses with JavaScript : <p>I have the following regex pattern that I like to use to validate email addresses:</p>
<pre><code>^[a-zA-Z0-9!#\$%&'\*\+\-\/=\?\^_`\{\|\}~\.]+@[a-zA-Z0-9-_]+\.[a-zA-Z0-9-.]+[a-zA-Z0-9]$
</code></pre>
<p>It's intended for user input and to be pretty forgiving, in that it will allow some fringe cases that aren't valid but will catch most mistakes.</p>
<p>I have been using this for ages in C# applications without issue. Below is a simple C# script that shows it working quite happily:</p>
<pre><code>string pattern = @"^[a-zA-Z0-9!#\$%&'\*\+\-\/=\?\^_`\{\|\}~\.]+@[a-zA-Z0-9-_]+\.[a-zA-Z0-9-.]+[a-zA-Z0-9]$";
string[] data = new string[] {
"foo@bar.com",
"foo@bar.co.uk",
"foo-foo@bar.com",
"foo.foo@bar.co.uk",
"foo_foo_69@bar_123.museum",
"o'foo@bar.com",
"foofoo@barbar",
"Foo@foo@bar.com",
"@bar.com",
"foo.com",
"foo@bar",
"foo@bar.co."
};
foreach (string email in data)
{
bool valid = Regex.IsMatch(email, pattern);
string state = valid ? "pass" : "fail";
Console.WriteLine($"{state}: {email}");
}
</code></pre>
<p>This little script gives the following output, and is exactly as I'd expect:</p>
<pre><code>pass: foo@bar.com
pass: foo@bar.co.uk
pass: foo-foo@bar.com
pass: foo.foo@bar.co.uk
pass: foo_foo_69@bar_123.museum
pass: o'foo@bar.com
fail: foofoo@barbar
fail: Foo@foo@bar.com
fail: @bar.com
fail: foo.com
fail: foo@bar
fail: foo@bar.co.
</code></pre>
<p>I now need to validate email addresses on the client side in JavaScript. When I try the same thing in JS I get slightly different results! Here is my JS version of the program above:</p>
<pre><code>var pattern = "^[a-zA-Z0-9!#\$%&'\*\+\-\/=\?\^_`\{\|\}~\.]+@[a-zA-Z0-9-_]+\.[a-zA-Z0-9-.]+[a-zA-Z0-9]$";
var data = [
/* the same list of emails as above */
];
for (var i = 0; i < data.length; i++) {
var valid = new RegExp(pattern).test(data[i]);
var state = valid ? "pass" : "fail";
console.log(state + ": " + data[i]);
}
</code></pre>
<p>This time I get the following output:</p>
<pre><code>pass: foo@bar.com
pass: foo@bar.co.uk
pass: foo-foo@bar.com
pass: foo.foo@bar.co.uk
pass: foo_foo_69@bar_123.museum
pass: o'foo@bar.com
pass: foofoo@barbar <- this should fail
pass: Foo@foo@bar.com <- and this!
fail: @bar.com
fail: foo.com
fail: foo@bar
fail: foo@bar.co.
</code></pre>
<p>Note the two passes in the middle that were failing in the C# version!!! Just to confirm that my regex pattern is OK I used regex101.com's excellent unit test feature to check it out, click <a href="https://regex101.com/r/7hdIvZ/2/tests" rel="nofollow noreferrer">here</a> to see my tests/results. Please note that I have deliberately set it up incorrectly (all tests 'expected' to match) so it highlights invalid email addresses. Any way here is a pic of the results, which as you can see match those I got using C#.</p>
<p><a href="https://i.stack.imgur.com/P32Qf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P32Qf.png" alt="test results"></a></p>
<p>If anyone could point out where I am going wrong I would appreciate it!</p>
| 0debug |
void tcg_prologue_init(TCGContext *s)
{
size_t prologue_size, total_size;
void *buf0, *buf1;
buf0 = s->code_gen_buffer;
s->code_ptr = buf0;
s->code_buf = buf0;
s->code_gen_prologue = buf0;
tcg_target_qemu_prologue(s);
buf1 = s->code_ptr;
flush_icache_range((uintptr_t)buf0, (uintptr_t)buf1);
prologue_size = tcg_current_code_size(s);
s->code_gen_ptr = buf1;
s->code_gen_buffer = buf1;
s->code_buf = buf1;
total_size = s->code_gen_buffer_size - prologue_size;
s->code_gen_buffer_size = total_size;
s->code_gen_highwater = s->code_gen_buffer + (total_size - 64*1024);
tcg_register_jit(s->code_gen_buffer, total_size);
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) {
qemu_log("PROLOGUE: [size=%zu]\n", prologue_size);
log_disas(buf0, prologue_size);
qemu_log("\n");
qemu_log_flush();
}
#endif
}
| 1threat |
void op_cp1_enabled(void)
{
if (!(env->CP0_Status & (1 << CP0St_CU1))) {
CALL_FROM_TB2(do_raise_exception_err, EXCP_CpU, 1);
}
RETURN();
}
| 1threat |
HttpClient POST request using x-www-form-urlencoded : <p>I'm trying to make a POST request with <code>x-www-form-urlencoded</code>content type header as follows:</p>
<pre><code>login(username, password): Observable<any> {
return this.http.post('/login', {
username: username,
password: password
},
{
headers: new HttpHeaders()
.set('Content-Type', 'x-www-form-urlencoded')
}
);
</code></pre>
<p>Unfortunately my API says that I sent empty username and password.</p>
<p>so I decided to make a postman request to my login endpoint and see where the problem comes from, and the postman request did return the username and password.</p>
<p>How comes that when I'm posting from postman my API return my username and password and when I post from my Angular app my API returns empty values? Is there anything I'm missing?</p>
| 0debug |
conflicting types for 'main' in leetcode platform : <pre><code> #include<stdio.h>
#include<stdlib.h>
int* twoSum(int* nums, int numsSize, int target) {
int *a=(int *)malloc(2*sizeof(int));
int i,j;
for(i=0;i<numsSize;i++)
for(j=i+1;j<numsSize;j++)
if(nums[i]+nums[j]==target)
{a[0]=i;a[1]=j;}
return a;
}
void main(){
int target,i;
int numsSize;
int b[2];
int num[10];
int *s;
s=b;
printf("Please input numsSize");
scanf("%d",&numsSize);
for(i=0;i<numsSize;i++)
scanf("%d",&num[i]);
printf("Please input target");
scanf("%d",&target);
s=twoSum(num,numsSize,target);
printf("【%d,%d】",s[0],s[1]);
}
</code></pre>
<p><strong><em>what's wrong with my code?</em></strong>
<em>I could run it smoothly on Visual Basic C++,but on the platform it implies that Line 58: conflicting types for 'main',i don't know what happened.</em></p>
| 0debug |
how to open web page and click on element in java android? : I'm building an app on Android android,
And I want it when I press any button in the application
It will open a web page and enter Text TextBox and click the button
On this web page automatically,
(All this should be run behind the scenes - אhat the user will not see)
There is any possibility to develop this in java android??
thanks shani | 0debug |
static int parse_bsfs(void *log_ctx, const char *bsfs_spec,
AVBitStreamFilterContext **bsfs)
{
char *bsf_name, *buf, *saveptr;
int ret = 0;
if (!(buf = av_strdup(bsfs_spec)))
return AVERROR(ENOMEM);
while (bsf_name = av_strtok(buf, ",", &saveptr)) {
AVBitStreamFilterContext *bsf = av_bitstream_filter_init(bsf_name);
if (!bsf) {
av_log(log_ctx, AV_LOG_ERROR,
"Cannot initialize bitstream filter with name '%s', "
"unknown filter or internal error happened\n",
bsf_name);
ret = AVERROR_UNKNOWN;
goto end;
}
*bsfs = bsf;
bsfs = &bsf->next;
buf = NULL;
}
end:
av_free(buf);
return ret;
}
| 1threat |
How to split up a large string into an array of individual sentences : <p>I have a string, with a bunch of sentences separated by periods. For example:</p>
<pre><code>const test = 'Dolore nostrud enim ea fugiat amet cupidatat enim. Fugiat qui tempor adipisicing velit et officia aliqua aliqua culpa ad veniam fugiat. Velit voluptate pariatur minim labore occaecat qui velit nostrud non deserunt non est voluptate. Quis est veniam sint nisi do.'
</code></pre>
<p>My desired outcome is to be able to turn each sentence of this paragraph into bullet points. I'm not concerned about creating the bullet points, I just need to break up this paragraph into an array of strings.</p>
<p>I'm assuming I need to write an algorithm that splits each sentence by a delimiter (doesn't have to a period but I used one in this example) and push them to a new array. I'm not that good working with regular expressions so I would appreciate any help.</p>
| 0debug |
"non-declaration statement outside function body" error golang : <p>I keep getting an non-declaration statement outside function body error for my http func method. I'm not sure why it keeps coming up after I fixed some global variables.</p>
<pre><code> package main
import (
"net/http"
"github.com/gorilla/websocket"
)
var audioMessage []byte
var whatType int
var recieverReady bool
http.HandleFunc("/send", func(w http.ResponseWriter, r *http.Request) {
conn, _ := websocket.Upgrade(r, w)
go func(){
for {
messageType, revdata, err := conn.ReadMessage()
if recieverReady {
audioMessage <- revdata
whatType <- messageType
}
}
}()
})
</code></pre>
| 0debug |
Can I setup VirtualHost with same Domain name and same Port : <p>AS topic, does my I idea come to true<br>
I need to define the DocumentRoot, ErrorLog and RedirectMatch for my symfony</p>
| 0debug |
static void gen_mtpr(int rb, int regno)
{
TCGv tmp;
int data;
if (rb == 31) {
tmp = tcg_const_i64(0);
} else {
tmp = cpu_ir[rb];
}
data = cpu_pr_data(regno);
if (data != 0) {
if (data & PR_BYTE) {
tcg_gen_st8_i64(tmp, cpu_env, data & ~PR_BYTE);
} else if (data & PR_LONG) {
tcg_gen_st32_i64(tmp, cpu_env, data & ~PR_LONG);
} else {
tcg_gen_st_i64(tmp, cpu_env, data);
}
}
if (rb == 31) {
tcg_temp_free(tmp);
}
}
| 1threat |
static int reg_irqs(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib fib)
{
int ret, len;
ret = css_register_io_adapter(S390_PCIPT_ADAPTER,
FIB_DATA_ISC(ldl_p(&fib.data)), true, false,
&pbdev->routes.adapter.adapter_id);
assert(ret == 0);
pbdev->summary_ind = get_indicator(ldq_p(&fib.aisb), sizeof(uint64_t));
len = BITS_TO_LONGS(FIB_DATA_NOI(ldl_p(&fib.data))) * sizeof(unsigned long);
pbdev->indicator = get_indicator(ldq_p(&fib.aibv), len);
map_indicator(&pbdev->routes.adapter, pbdev->summary_ind);
map_indicator(&pbdev->routes.adapter, pbdev->indicator);
pbdev->routes.adapter.summary_addr = ldq_p(&fib.aisb);
pbdev->routes.adapter.summary_offset = FIB_DATA_AISBO(ldl_p(&fib.data));
pbdev->routes.adapter.ind_addr = ldq_p(&fib.aibv);
pbdev->routes.adapter.ind_offset = FIB_DATA_AIBVO(ldl_p(&fib.data));
pbdev->isc = FIB_DATA_ISC(ldl_p(&fib.data));
pbdev->noi = FIB_DATA_NOI(ldl_p(&fib.data));
pbdev->sum = FIB_DATA_SUM(ldl_p(&fib.data));
DPRINTF("reg_irqs adapter id %d\n", pbdev->routes.adapter.adapter_id);
return 0;
}
| 1threat |
Jenkins Pipeline: How to write UTF-8 files with writeFile? : <p>I'm hoping this is not a bug and that I'm just doing something wrong. I have a Jenkins (v2.19.1) Pipeline job and in it's groovy script, I need to search and replace some text in an existing text file, on a Windows node.</p>
<p>I've used fart.exe and powershell to do the search and replace, but I would really like to do this with just the groovy in Jenkins and eliminate dependency on fart/powershell/etc. and make this code more reusable on both linux and windows nodes.</p>
<p>After much googling and trying various approaches, the closest I got was to use readFile and writeFile. However, I've not been able to get writeFile to create a UTF-8 file. It creates an ANSI file even when I specify UTF-8 (assuming I'm doing it correctly). </p>
<p>Here's what I have so far...</p>
<pre class="lang-java prettyprint-override"><code>def fileContents = readFile file: "test.txt", encoding: "UTF-8"
fileContents = fileContents.replace("hello", "world")
echo fileContents
writeFile file: "test.txt", text: fileContents, encoding: "UTF-8"
</code></pre>
<p>I've confirmed with multiple text editors that the test.txt file is UTF-8 when I start, and ANSI after the writeFile line. I've tried all combinations of including/not-including the encoding property and "utf-8" vs "UTF-8". But in all cases, the file is written out as ANSI (as reported by both Notepad++ and VS Code). Also, a question mark (HEX 3F) is added as the very first character of the file. </p>
<p>The echo line does not show the extra 3F character, so it seems the issue is in the writeFile line.</p>
| 0debug |
def check_String(str):
flag_l = False
flag_n = False
for i in str:
if i.isalpha():
flag_l = True
if i.isdigit():
flag_n = True
return flag_l and flag_n | 0debug |
Issue with connecting to sql database from visual studio : I've created a simple windows forms application in C# and now find it hard to connect it to an SQL database. I've created the database within visual studio itself. However, once I try to insert data I get an SQL exeption. My guess is there is problem in the connection data source i.e the con varirable. Please help me find a solution.
SqlConnection con = new SqlConnection("Data Source=DESKTOP-386S9BF/Shenal Burkey;Initial Catalog=Sample;Integrated Security=true;");
SqlCommand cmd;
SqlDataAdapter adapt;
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
{
cmd = new SqlCommand("insert into [dbo].[user] (Id,username,password) values(@id,@name,@state)", con);
con.Open();
cmd.Parameters.AddWithValue("@id", textBox1.Text);
cmd.Parameters.AddWithValue("@name", textBox2.Text);
cmd.Parameters.AddWithValue("@state", textBox3.Text);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record Inserted Successfully");
}
else {
MessageBox.Show("Please Provide Details!");
}
the database file name is \WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf
| 0debug |
Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
{
BDRVQcowState *s = bs->opaque;
Qcow2Cache *c;
int i;
c = g_malloc0(sizeof(*c));
c->size = num_tables;
c->entries = g_malloc0(sizeof(*c->entries) * num_tables);
for (i = 0; i < c->size; i++) {
c->entries[i].table = qemu_try_blockalign(bs->file, s->cluster_size);
if (c->entries[i].table == NULL) {
goto fail;
}
}
return c;
fail:
for (i = 0; i < c->size; i++) {
qemu_vfree(c->entries[i].table);
}
g_free(c->entries);
g_free(c);
return NULL;
}
| 1threat |
How to set state as an array and how to access them with setState and this.state : <p>I have created an array like this:</p>
<pre><code>state = {
arr: [ ]
}
</code></pre>
<p>I want to update state as well as access them </p>
<p>In my function I am using want to use it like </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>func() {
this.state.arr; // for accesing the array
//remaining codes
this.setState({arr: this.state.arr.push(2)}); //for updating
}</code></pre>
</div>
</div>
</p>
<p>this is resulting in error and wrong outputs there is something wrong in the code that have used </p>
| 0debug |
static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride){
const int index= size2index[log2h][log2w];
const int h= 1<<log2h;
int code= get_vlc2(&f->gb, block_type_vlc[1-(f->version>1)][index].table, BLOCK_TYPE_VLC_BITS, 1);
uint16_t *start= (uint16_t*)f->last_picture.data[0];
uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<<log2w);
assert(code>=0 && code<=6);
if(code == 0){
src += f->mv[ *f->bytestream++ ];
if(start > src || src > end){
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(dst, src, log2w, h, stride, 1, 0);
}else if(code == 1){
log2h--;
decode_p_block(f, dst , src , log2w, log2h, stride);
decode_p_block(f, dst + (stride<<log2h), src + (stride<<log2h), log2w, log2h, stride);
}else if(code == 2){
log2w--;
decode_p_block(f, dst , src , log2w, log2h, stride);
decode_p_block(f, dst + (1<<log2w), src + (1<<log2w), log2w, log2h, stride);
}else if(code == 3 && f->version<2){
mcdc(dst, src, log2w, h, stride, 1, 0);
}else if(code == 4){
src += f->mv[ *f->bytestream++ ];
if(start > src || src > end){
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(dst, src, log2w, h, stride, 1, av_le2ne16(*f->wordstream++));
}else if(code == 5){
mcdc(dst, src, log2w, h, stride, 0, av_le2ne16(*f->wordstream++));
}else if(code == 6){
if(log2w){
dst[0] = av_le2ne16(*f->wordstream++);
dst[1] = av_le2ne16(*f->wordstream++);
}else{
dst[0 ] = av_le2ne16(*f->wordstream++);
dst[stride] = av_le2ne16(*f->wordstream++);
}
}
}
| 1threat |
How to consolidate all applicable projects and nuget packages from the command line? : <p>I'm merging two solutions and now have the following situation</p>
<p><a href="https://i.stack.imgur.com/xpM4U.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xpM4U.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/DACgN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DACgN.png" alt="enter image description here"></a></p>
<p>It is a large project and consolidating a single package takes enough time. Consolidating 26 and I'll be here all day. Is there a way to batch consolidate so I can go an have lunch and it will be done when I get back?</p>
| 0debug |
@types/styled-components Duplicate identifier FormData : <p>If I add @types/styled-components in my project, I will have a bunch of errors in the build output:</p>
<pre><code>ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(36,15):
TS2300: Duplicate identifier 'FormData'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(81,5):
TS2717: Subsequent property declarations must have the same type. Property 'body' must be of type 'BodyInit', but here has type 'string | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Blob | FormData'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(107,14):
TS2300: Duplicate identifier 'RequestInfo'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(126,13):
TS2403: Subsequent variable declarations must have the same type. Variable 'Response' must be of type '{ new (body?: BodyInit, init?: ResponseInit): Response; prototype: Response; error(): Response; redirect(url: string, status?: number): Response; }', but here has type '{ new (body?: string | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Blob | FormData, init?: ResponseInit): Response; prototype: Response; error: () => Response; redirect: (url: string, status?: number) => Res...'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(196,5):
TS2717: Subsequent property declarations must have the same type. Property 'abort' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(197,5):
TS2717: Subsequent property declarations must have the same type. Property 'error' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(198,5):
TS2717: Subsequent property declarations must have the same type. Property 'load' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(199,5):
TS2717: Subsequent property declarations must have the same type. Property 'loadend' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(200,5):
TS2717: Subsequent property declarations must have the same type. Property 'loadstart' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(201,5):
TS2717: Subsequent property declarations must have the same type. Property 'progress' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(202,5):
TS2717: Subsequent property declarations must have the same type. Property 'timeout' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(206,5):
TS2717: Subsequent property declarations must have the same type. Property 'onabort' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(207,5):
TS2717: Subsequent property declarations must have the same type. Property 'onerror' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(208,5):
TS2717: Subsequent property declarations must have the same type. Property 'onload' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(209,5):
TS2717: Subsequent property declarations must have the same type. Property 'onloadend' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(210,5):
TS2717: Subsequent property declarations must have the same type. Property 'onloadstart' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(211,5):
TS2717: Subsequent property declarations must have the same type. Property 'onprogress' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(212,5):
TS2717: Subsequent property declarations must have the same type. Property 'ontimeout' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(243,6):
TS2300: Duplicate identifier 'XMLHttpRequestResponseType'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9297,14):
TS2300: Duplicate identifier 'require'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9315,11):
TS2451: Cannot redeclare block-scoped variable 'console'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9323,18):
TS2717: Subsequent property declarations must have the same type. Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9326,11):
TS2451: Cannot redeclare block-scoped variable 'navigator'.
ERROR in /Users/me/projects/react/node_modules/@types/webpack-env/index.d.ts(203,13):
TS2300: Duplicate identifier 'require'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(5196,11):
TS2300: Duplicate identifier 'FormData'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(5206,13):
TS2300: Duplicate identifier 'FormData'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(16513,11):
TS2320: Interface 'Window' cannot simultaneously extend types 'GlobalFetch' and 'WindowOrWorkerGlobalScope'.
Named property 'fetch' of types 'GlobalFetch' and 'WindowOrWorkerGlobalScope' are not identical.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17406,13):
TS2451: Cannot redeclare block-scoped variable 'navigator'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17510,13):
TS2451: Cannot redeclare block-scoped variable 'console'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17819,6):
TS2300: Duplicate identifier 'RequestInfo'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17992,6):
TS2300: Duplicate identifier 'XMLHttpRequestResponseType'.
</code></pre>
<p>For some reason it adds @types/react-native, which has some collisions with my react app.</p>
<p>I have the next tsconfig.json:</p>
<pre><code>{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"jsx": "react",
"outDir": "./production/",
"sourceMap": true,
"noImplicitAny": true,
"lib": ["esnext", "dom"],
"resolveJsonModule": true
},
"include": [
"./src/**/*"
]
}
</code></pre>
<p>The problem could be solved with adding exact types in the type property into tsconfig.json:</p>
<pre><code>{
"compilerOptions": {
...
"types": [
"jest",
"jest-diff",
"react",
"react-dom",
"react-intl",
"react-redux",
"react-router-dom",
"webpack-env",
"styled-components"
]
},
...
}
</code></pre>
<p>But this solution doesn't look nice to me. Is there any other fix?</p>
| 0debug |
`this` is undefined in expressJS route handler : <p><strong>groups.js</strong></p>
<pre><code>class groupsCtrl {
constructor() {
this.info = "test";
}
get(res, req) {
console.log("LOG ! ", JSON.stringify(this));
}
}
module.exports = new groupsCtrl(); //singleton
</code></pre>
<p><strong>routes.js</strong></p>
<pre><code>var express = require('express');
var router = express.Router();
var groupsCtrl = require('controllers/api_admin/groups.js');
router.get('/groups/', groupsCtrl.get);
</code></pre>
<p>This logs <code>LOG ! undefined</code></p>
<p>How can I have access to <code>this</code> in my controller class ?</p>
| 0debug |
void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t fs, uint32_t rt)
{
switch (fs) {
case 1:
if (!((env->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (rt == 0))) {
return;
}
if (env->CP0_Config5 & (1 << CP0C5_UFR)) {
env->CP0_Status &= ~(1 << CP0St_FR);
compute_hflags(env);
} else {
helper_raise_exception(env, EXCP_RI);
}
break;
case 4:
if (!((env->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (rt == 0))) {
return;
}
if (env->CP0_Config5 & (1 << CP0C5_UFR)) {
env->CP0_Status |= (1 << CP0St_FR);
compute_hflags(env);
} else {
helper_raise_exception(env, EXCP_RI);
}
break;
case 25:
if (arg1 & 0xffffff00)
return;
env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0x017fffff) | ((arg1 & 0xfe) << 24) |
((arg1 & 0x1) << 23);
break;
case 26:
if (arg1 & 0x007c0000)
return;
env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfffc0f83) | (arg1 & 0x0003f07c);
break;
case 28:
if (arg1 & 0x007c0000)
return;
env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfefff07c) | (arg1 & 0x00000f83) |
((arg1 & 0x4) << 22);
break;
case 31:
if (arg1 & 0x007c0000)
return;
env->active_fpu.fcr31 = arg1;
break;
default:
return;
}
restore_rounding_mode(env);
restore_flush_mode(env);
set_float_exception_flags(0, &env->active_fpu.fp_status);
if ((GET_FP_ENABLE(env->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(env->active_fpu.fcr31))
do_raise_exception(env, EXCP_FPE, GETPC());
}
| 1threat |
How do I make a property private in a class? : <pre><code>class makeAccount {
public $username;
public function __construct ($username,$password) {
$this->username = $username;
}
public function password($password) {
if(isset($password)) {
$this->password = $password;
return;
}
}
}
$user_1 = new makeAccount("abc123","12345");
print $user_1->password("12345");
</code></pre>
<p>I am new to php. I am just wondering how to make a private property. I want to have a password property that is private. Is there something wrong with my code?</p>
| 0debug |
The iPhone 4 and iPhone 4s simulators disappeared after upgrading to Xcode 8. How do I get them back? : <p>I have these iPhone simulators:</p>
<ul>
<li>iPhone 5</li>
<li>iPhone 5s</li>
<li>iPhone 6</li>
<li>iPhone 6 Plus</li>
<li>iPhone 6s</li>
<li>iPhone 6s Plus</li>
<li>iPhone 7</li>
<li>iPhone 7 Plus</li>
<li>iPhone SE</li>
</ul>
<p>What happened to the iPhone 4 and iPhone 4s?</p>
| 0debug |
static void kvm_openpic_realize(DeviceState *dev, Error **errp)
{
SysBusDevice *d = SYS_BUS_DEVICE(dev);
KVMOpenPICState *opp = KVM_OPENPIC(dev);
KVMState *s = kvm_state;
int kvm_openpic_model;
struct kvm_create_device cd = {0};
int ret, i;
if (!kvm_check_extension(s, KVM_CAP_DEVICE_CTRL)) {
error_setg(errp, "Kernel is lacking Device Control API");
return;
}
switch (opp->model) {
case OPENPIC_MODEL_FSL_MPIC_20:
kvm_openpic_model = KVM_DEV_TYPE_FSL_MPIC_20;
break;
case OPENPIC_MODEL_FSL_MPIC_42:
kvm_openpic_model = KVM_DEV_TYPE_FSL_MPIC_42;
break;
default:
error_setg(errp, "Unsupported OpenPIC model %" PRIu32, opp->model);
return;
}
cd.type = kvm_openpic_model;
ret = kvm_vm_ioctl(s, KVM_CREATE_DEVICE, &cd);
if (ret < 0) {
error_setg(errp, "Can't create device %d: %s",
cd.type, strerror(errno));
return;
}
opp->fd = cd.fd;
sysbus_init_mmio(d, &opp->mem);
qdev_init_gpio_in(dev, kvm_openpic_set_irq, OPENPIC_MAX_IRQ);
opp->mem_listener.region_add = kvm_openpic_region_add;
opp->mem_listener.region_del = kvm_openpic_region_del;
memory_listener_register(&opp->mem_listener, &address_space_memory);
msi_supported = true;
kvm_kernel_irqchip = true;
kvm_async_interrupts_allowed = true;
kvm_init_irq_routing(kvm_state);
for (i = 0; i < 256; ++i) {
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
}
kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
kvm_irqchip_commit_routes(s);
}
| 1threat |
How to disable "Run execution to here" in Visual Studio 15? : <p>How do I disable "Run execution to here" button that appears when moving cursor to the left of the code? It's really annoying when I accidentally click it while selecting code.</p>
<p><a href="https://i.stack.imgur.com/oWnc4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oWnc4.png" alt=""></a></p>
| 0debug |
static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
uint8_t *src, uint8_t *last, int size, int bpp)
{
int i, p, r, g, b, a;
switch (filter_type) {
case PNG_FILTER_VALUE_NONE:
memcpy(dst, src, size);
break;
case PNG_FILTER_VALUE_SUB:
for (i = 0; i < bpp; i++)
dst[i] = src[i];
if (bpp == 4) {
p = *(int *)dst;
for (; i < size; i += bpp) {
unsigned s = *(int *)(src + i);
p = ((s & 0x7f7f7f7f) + (p & 0x7f7f7f7f)) ^ ((s ^ p) & 0x80808080);
*(int *)(dst + i) = p;
}
} else {
#define OP_SUB(x, s, l) ((x) + (s))
UNROLL_FILTER(OP_SUB);
}
break;
case PNG_FILTER_VALUE_UP:
dsp->add_bytes_l2(dst, src, last, size);
break;
case PNG_FILTER_VALUE_AVG:
for (i = 0; i < bpp; i++) {
p = (last[i] >> 1);
dst[i] = p + src[i];
}
#define OP_AVG(x, s, l) (((((x) + (l)) >> 1) + (s)) & 0xff)
UNROLL_FILTER(OP_AVG);
break;
case PNG_FILTER_VALUE_PAETH:
for (i = 0; i < bpp; i++) {
p = last[i];
dst[i] = p + src[i];
}
if (bpp > 2 && size > 4) {
int w = bpp == 4 ? size : size - 3;
dsp->add_paeth_prediction(dst + i, src + i, last + i, w - i, bpp);
i = w;
}
ff_add_png_paeth_prediction(dst + i, src + i, last + i, size - i, bpp);
break;
}
}
| 1threat |
How to find people near me using google maps in android : <p>I want to store user longitude and latitude in mysql and want to push a notification when user is in 2Km Range In Android </p>
| 0debug |
Make the page the same before the form was submitted : <p>I have tab panels created using jquery. Each contains forms. First tab is the default active.</p>
<p>After entering data in form, for example, at the third tab and submit it, the page refreshes, the data were gone. Also the active tab went back to the first tab.</p>
<p>My problem is I want to stay on the tab where I submitted my data. By the way I'm using PHP. Please help me. Thank you in advance :)</p>
| 0debug |
App is rendering larger than viewport when I try to apply dynamic css sizing attributes : <p>I have tried applying 100vh to the divs root/body/application (these are my top 3 level divs) and my app continues to render larger than the viewport or browser window. I am using display: flex on the child divs.</p>
<p>I am trying to just get the app to fit the window.</p>
| 0debug |
static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,
RMDemuxContext *rm, RMStream *vst,
AVPacket *pkt, int len)
{
int hdr, seq, pic_num, len2, pos;
int type;
hdr = get_byte(pb); len--;
type = hdr >> 6;
if(type != 3){
seq = get_byte(pb); len--;
}
if(type != 1){
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
pic_num = get_byte(pb); len--;
}
if(len<0)
return -1;
rm->remaining_len = len;
if(type&1){
if(type == 3)
len= len2;
if(rm->remaining_len < len)
return -1;
rm->remaining_len -= len;
if(av_new_packet(pkt, len + 9) < 0)
return AVERROR(EIO);
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
get_buffer(pb, pkt->data + 9, len);
return 0;
}
if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){
vst->slices = ((hdr & 0x3F) << 1) + 1;
vst->videobufsize = len2 + 8*vst->slices + 1;
av_free_packet(&vst->pkt);
if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
return AVERROR(ENOMEM);
vst->videobufpos = 8*vst->slices + 1;
vst->cur_slice = 0;
vst->curpic_num = pic_num;
vst->pktpos = url_ftell(pb);
}
if(type == 2)
len = FFMIN(len, pos);
if(++vst->cur_slice > vst->slices)
return 1;
AV_WL32(vst->pkt.data - 7 + 8*vst->cur_slice, 1);
AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1);
if(vst->videobufpos + len > vst->videobufsize)
return 1;
if (get_buffer(pb, vst->pkt.data + vst->videobufpos, len) != len)
return AVERROR(EIO);
vst->videobufpos += len;
rm->remaining_len-= len;
if(type == 2 || (vst->videobufpos) == vst->videobufsize){
vst->pkt.data[0] = vst->cur_slice-1;
*pkt= vst->pkt;
vst->pkt.data=
vst->pkt.size= 0;
if(vst->slices != vst->cur_slice)
memmove(pkt->data + 1 + 8*vst->cur_slice, pkt->data + 1 + 8*vst->slices,
vst->videobufpos - 1 - 8*vst->slices);
pkt->size += 8*(vst->cur_slice - vst->slices);
pkt->pts = AV_NOPTS_VALUE;
pkt->pos = vst->pktpos;
return 0;
}
return 1;
}
| 1threat |
Difference between heartbeat.interval.ms and session.timeout.ms in Kafka consumer config : <p>I'm currently running kafka 0.10.0.1 and the corresponding docs for the two values in question are as follows:</p>
<p><strong>heartbeat.interval.ms -</strong>
The expected time between heartbeats to the consumer coordinator when using Kafka's group management facilities. Heartbeats are used to ensure that the consumer's session stays active and to facilitate rebalancing when new consumers join or leave the group. The value must be set lower than session.timeout.ms, but typically should be set no higher than 1/3 of that value. It can be adjusted even lower to control the expected time for normal rebalances.</p>
<p><strong>session.timeout.ms -</strong>
The timeout used to detect failures when using Kafka's group management facilities. When a consumer's heartbeat is not received within the session timeout, the broker will mark the consumer as failed and rebalance the group. Since heartbeats are sent only when poll() is invoked, a higher session timeout allows more time for message processing in the consumer's poll loop at the cost of a longer time to detect hard failures. See also max.poll.records for another option to control the processing time in the poll loop.</p>
<p>It isn't clear to me why the docs recommend setting <code>heartbeat.interval.ms</code> to 1/3 of <code>session.timeout.ms</code>. Does it not make sense to have these values be the same since the heartbeat is only sent when <code>poll()</code> is invoked, and thus when processing of the current records is done?</p>
| 0debug |
HTML Table maximize-able to full screen : <p>I've been searching a lot to find a sample table that has a maximize button to occupy the full screen.</p>
<p>Imagine having a table that has this <a href="https://cdn0.iconfinder.com/data/icons/controls-add-on/48/v-12-512.png" rel="nofollow noreferrer">icon</a> as a button somewhere and then you click it then table becomes full screen. </p>
<p>Bootstrap or any other version is fine :)</p>
| 0debug |
static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUS390XState *env)
{
int i;
rt_sigframe *frame;
abi_ulong frame_addr;
frame_addr = get_sigframe(ka, env, sizeof *frame);
qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
(unsigned long long)frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
qemu_log("%s: 1\n", __FUNCTION__);
copy_siginfo_to_user(&frame->info, info);
__put_user(0, &frame->uc.tuc_flags);
__put_user((abi_ulong)0, (abi_ulong *)&frame->uc.tuc_link);
__put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)),
&frame->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);
save_sigregs(env, &frame->uc.tuc_mcontext);
for (i = 0; i < TARGET_NSIG_WORDS; i++) {
__put_user((abi_ulong)set->sig[i],
(abi_ulong *)&frame->uc.tuc_sigmask.sig[i]);
}
if (ka->sa_flags & TARGET_SA_RESTORER) {
env->regs[14] = (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE;
} else {
env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE;
if (__put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn,
(uint16_t *)(frame->retcode))) {
goto give_sigsegv;
}
}
if (__put_user(env->regs[15], (abi_ulong *) frame)) {
goto give_sigsegv;
}
env->regs[15] = frame_addr;
env->psw.addr = (target_ulong) ka->_sa_handler | PSW_ADDR_AMODE;
env->regs[2] = sig;
env->regs[3] = frame_addr + offsetof(typeof(*frame), info);
env->regs[4] = frame_addr + offsetof(typeof(*frame), uc);
return;
give_sigsegv:
qemu_log("%s: give_sigsegv\n", __FUNCTION__);
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| 1threat |
static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
int flags)
{
MP3DecContext *mp3 = s->priv_data;
AVIndexEntry *ie, ie1;
AVStream *st = s->streams[0];
int64_t ret = av_index_search_timestamp(st, timestamp, flags);
int64_t best_pos;
int fast_seek = (s->flags & AVFMT_FLAG_FAST_SEEK) ? 1 : 0;
int64_t filesize = mp3->header_filesize;
if (mp3->usetoc == 2)
return -1;
if (filesize <= 0) {
int64_t size = avio_size(s->pb);
if (size > 0 && size > s->internal->data_offset)
filesize = size - s->internal->data_offset;
}
if ( (mp3->is_cbr || fast_seek)
&& (mp3->usetoc == 0 || !mp3->xing_toc)
&& st->duration > 0
&& filesize > 0) {
ie = &ie1;
timestamp = av_clip64(timestamp, 0, st->duration);
ie->timestamp = timestamp;
ie->pos = av_rescale(timestamp, filesize, st->duration) + s->internal->data_offset;
} else if (mp3->xing_toc) {
if (ret < 0)
return ret;
ie = &st->index_entries[ret];
} else {
return -1;
}
best_pos = mp3_sync(s, ie->pos, flags);
if (best_pos < 0)
return best_pos;
if (mp3->is_cbr && ie == &ie1 && mp3->frames) {
int frame_duration = av_rescale(st->duration, 1, mp3->frames);
ie1.timestamp = frame_duration * av_rescale(best_pos - s->internal->data_offset, mp3->frames, mp3->header_filesize);
}
ff_update_cur_dts(s, st, ie->timestamp);
return 0;
}
| 1threat |
jspm or npm to install packages? : <p>I'm new to jspm, transitioning from npm-only. I have one fundamental question. I have some dependencies in the package.json, and I runned jspm init, which created a nice jspm config.js file. My question is, what it the point of installing these packages from jspm (via <code>jspm install ...</code>)? Why not just install them through npm?</p>
<p>More specifically, in my package.json, what's the difference between putting these packages inside <code>dependencies: {} vs inside jspm.dependencies: {}</code></p>
| 0debug |
int avfilter_default_config_output_link(AVFilterLink *link)
{
if (link->src->input_count && link->src->inputs[0]) {
if (link->type == AVMEDIA_TYPE_VIDEO) {
link->w = link->src->inputs[0]->w;
link->h = link->src->inputs[0]->h;
link->time_base = link->src->inputs[0]->time_base;
} else if (link->type == AVMEDIA_TYPE_AUDIO) {
link->channel_layout = link->src->inputs[0]->channel_layout;
link->sample_rate = link->src->inputs[0]->sample_rate;
}
} else {
return -1;
}
return 0;
}
| 1threat |
void helper_cpuid(void)
{
if (EAX == 0) {
EAX = 1;
EBX = 0x756e6547;
ECX = 0x6c65746e;
EDX = 0x49656e69;
} else {
EAX = 0x52b;
EBX = 0;
ECX = 0;
EDX = CPUID_FP87 | CPUID_VME | CPUID_DE | CPUID_PSE |
CPUID_TSC | CPUID_MSR | CPUID_MCE |
CPUID_CX8;
}
}
| 1threat |
static int get_float64(QEMUFile *f, void *pv, size_t size)
{
float64 *v = pv;
*v = make_float64(qemu_get_be64(f));
return 0;
}
| 1threat |
static unsigned int dec_rfe_etc(DisasContext *dc)
{
cris_cc_mask(dc, 0);
if (dc->op2 == 15)
return 2;
switch (dc->op2 & 7) {
case 2:
DIS(fprintf(logfile, "rfe\n"));
cris_evaluate_flags(dc);
tcg_gen_helper_0_0(helper_rfe);
dc->is_jmp = DISAS_UPDATE;
break;
case 5:
DIS(fprintf(logfile, "rfn\n"));
cris_evaluate_flags(dc);
tcg_gen_helper_0_0(helper_rfn);
dc->is_jmp = DISAS_UPDATE;
break;
case 6:
DIS(fprintf(logfile, "break %d\n", dc->op1));
cris_evaluate_flags (dc);
tcg_gen_movi_tl(env_pc, dc->pc + 2);
t_gen_mov_env_TN(trap_vector,
tcg_const_tl(dc->op1 + 16));
t_gen_raise_exception(EXCP_BREAK);
dc->is_jmp = DISAS_UPDATE;
break;
default:
printf ("op2=%x\n", dc->op2);
BUG();
break;
}
return 2;
}
| 1threat |
static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
mm_end = end - 15;
#if 1
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"add $16, %1 \n\t"
"add $8, %0 \n\t"
"cmp %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(s)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
}
}
| 1threat |
Bash: get 3 element from string : <p>folks
I have string</p>
<pre><code> str1="MVM GT RT BHHT SYSTEMG RW"
</code></pre>
<p>I need to get "BHHT" and add it to variable str2.</p>
<p>I shouldn't use file. I need something like this:</p>
<p><code>str1 | cut -d ' ' -f 3</code></p>
| 0debug |
Where i can learn about openstack and cloud computing : <p>Where i can learn about openstack and cloud computing
Sites with proper courses and video tutorials will be prefered and i have no knowledge about them.</p>
| 0debug |
static int ff_h261_resync(H261Context *h){
MpegEncContext * const s = &h->s;
int left, ret;
if(show_bits(&s->gb, 15)==0){
ret= h261_decode_gob_header(h);
if(ret>=0)
return 0;
}
s->gb= s->last_resync_gb;
align_get_bits(&s->gb);
left= s->gb.size_in_bits - get_bits_count(&s->gb);
for(;left>15+1+4+5; left-=8){
if(show_bits(&s->gb, 15)==0){
GetBitContext bak= s->gb;
ret= h261_decode_gob_header(h);
if(ret>=0)
return 0;
s->gb= bak;
}
skip_bits(&s->gb, 8);
}
return -1;
}
| 1threat |
Swig tool and C++. Being too clever : <p><a href="http://www.swig.org/papers/PyTutorial98/PyTutorial98.pdf" rel="noreferrer">http://www.swig.org/papers/PyTutorial98/PyTutorial98.pdf</a>
It comes from above link:</p>
<p><a href="https://i.stack.imgur.com/G2kuq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/G2kuq.png" alt="enter image description here"></a></p>
<p>I know that it is an old publication so it is possible that information is outdated.</p>
<p>I would like to ask:</p>
<p>"Seems to work fine with C++ if you aren't being too clever"
What does it mean, to be too clever?</p>
<p>Is there known situation/case that I shuold be very careful where I am programming C++ modules and extending Python using <code>swig</code> tool?</p>
| 0debug |
Converting a Letter to a Number in C : <p>Alright so pretty simple, I want to convert a letter to a number so that a = 0, b = 1, etc. Now I know I can do</p>
<pre><code>number = letter + '0';
</code></pre>
<p>so when I input the letter 'a' it gives me the number 145. My question is, if I am to run this on a different computer or OS, would it still give me the same number 145 for when I input the letter 'a'?</p>
| 0debug |
Pong game bugging out - mayby pointer to class : <p>get a problem with my code, this is just an extract from a larger piece of code involving OpenGL but still demonstrates the problem. It works without the collision detection call (col.detect()) - if you consider unbouncy walls working - but when I uncomment it the program breaks. Nothing seems to be wrong with the code itself it compiles just fine but doesn't work the way that I am expecting.</p>
<p>Thanks for all the help
Best Regards</p>
<p><strong>collision.h</strong></p>
<pre><code>#pragma once
#include "Ball.h"
class collision
{
public:
collision();
collision(Ball ball);
void detect();
~collision();
private:
Ball *point;
};
</code></pre>
<p><strong>Ball.h</strong></p>
<pre><code>#pragma once
class Ball
{
public:
Ball();
double getpx();
double getpy();
double getvx();
double getvy();
void setpx(const double px);
void setpy(const double py);
void setvx(const double vx);
void setvy(const double vy);
void update();
~Ball();
private:
double position[2] = { 0, 0 };
double velocity[2] = { 0.1, 0 };
};
</code></pre>
<p><strong>collision.cpp</strong></p>
<pre><code>#include "collision.h"
collision::collision()
{
}
collision::collision(Ball ball)
{
point = &ball;
}
void collision::detect()
{
if (point->getpx() > 1 || point->getpx() < -1)
point->setvx(-point->getvx());
else if (point->getpy() > 1 || point->getpy() < -1)
point->setvy(-point->getvy());
}
collision::~collision()
{
}
</code></pre>
<p><strong>Ball.cpp</strong></p>
<pre><code>#include "Ball.h"
Ball::Ball()
{
}
double Ball::getpx()
{
return position[0];
}
double Ball::getpy()
{
return position[1];
}
double Ball::getvx()
{
return velocity[0];
}
double Ball::getvy()
{
return velocity[1];
}
void Ball::setpx(const double px)
{
position[0] = px;
}
void Ball::setpy(const double py)
{
position[1] = py;
}
void Ball::setvx(const double vx)
{
velocity[0] = vx;
}
void Ball::setvy(const double vy)
{
velocity[1] = vy;
}
void Ball::update()
{
position[0] += velocity[0];
position[1] += velocity[1];
}
Ball::~Ball()
{
}
</code></pre>
<p><strong>main.cpp</strong></p>
<pre><code>#include <iostream>
#include "Ball.h"
#include "collision.h"
using namespace std;
int main()
{
Ball tennis;
collision col(tennis);
while (true)
{
tennis.update();
col.detect();
cout << tennis.getpx() << endl;
cin.get();
}
return 0;
}
</code></pre>
| 0debug |
static inline void RENAME(rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*s));
__asm__ volatile("movq %0, %%mm7"::"m"(mask15rg));
__asm__ volatile("movq %0, %%mm6"::"m"(mask15b));
mm_end = end - 15;
while (s<mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $1, %%mm0 \n\t"
"psrlq $1, %%mm2 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm3 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
mm_end = end - 3;
while (s < mm_end) {
register uint32_t x= *((const uint32_t*)s);
*((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F);
s+=4;
d+=4;
}
if (s < end) {
register uint16_t x= *((const uint16_t*)s);
*((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F);
}
}
| 1threat |
What IP's are in this IP block and how to use them? : <p>I am very new to this IP block thing so please excuse any "nooby" mistakes.</p>
<p>I just purchased a dedicated server and in my control panel it says:</p>
<blockquote>
<p>IPv4 Assignment #1: 192.151.150.194/29</p>
</blockquote>
<p>Does this mean the following IP addresses are usable? </p>
<ul>
<li>192.151.150.193</li>
<li>192.151.150.194</li>
<li>192.151.150.195 </li>
<li>192.151.150.196</li>
<li>192.151.150.197</li>
<li>192.151.150.198</li>
</ul>
<p>If the IP's listed above are correct, do I have to enable them to use them?</p>
<p>Thanks,
Faraaz</p>
| 0debug |
No reference documentation in Android Studio : <p>A new problem just popped up yesterday. When I hover over a method or press Ctrl-Q, I used to get documentation info for that particular method.</p>
<p>But now I just get (pressing Ctrl-Q on <code>SharedPreferences.getLong()</code>):</p>
<pre><code>Following external urls were checked:
http://developer.android.com/reference/android/content/SharedPreferences.html#getLong-java.lang.String-long-
http://developer.android.com/reference/android/content/SharedPreferences.html#getLong(java.lang.String, long)
The documentation for this element is not found. Please add all the needed paths to API docs in Project Settings.
android.content.SharedPreferences
public abstract long getLong(String s, long l)
</code></pre>
<p>I googled a lot, but couldn't find an answer.
Which paths do I need to add and where?</p>
| 0debug |
When are .NET Core dependency injected instances disposed? : <p>ASP.NET Core uses extension methods on <code>IServiceCollection</code> to set up dependency injection, then when a type is needed it uses the appropriate method to create a new instance:</p>
<ul>
<li><code>AddTransient<T></code> - adds a type that is created again each time it's requested.</li>
<li><code>AddScoped<T></code> - adds a type that is kept for the scope of the request.</li>
<li><code>AddSingleton<T></code> - adds a type when it's first requested and keeps hold of it.</li>
</ul>
<p>I have types that implement <code>IDisposable</code> and that will cause problems if they aren't disposed - in each of those patterns when is <code>Dispose</code> actually called?</p>
<p>Is there anything I need to add (such as exception handling) to ensure that the instance is always disposed?</p>
| 0debug |
Angular2 - How to best handle expired authentication token? : <p>I am using Angular 2.1.2.</p>
<p>I have an authentication token (using angular2-jwt) and if it expires my webApi call fails with a 401 error. I am looking for a solution where the user will not lose any input data.</p>
<p>I can catch this 401 and open a modal with the login. The user then logs in, the modal goes away, and they see their input screen. However, the failed requests are showing errors so I need to reprocess the requests. If it was a router navigate the initial data has not loaded.</p>
<p>I could reload the page, but if I router.navigate to the same page it does not seem to actually reload the page. I don't want to do a full page reload on the single page app. Is there a way to force router.navigate to run, even if it's the current page?</p>
<p>Re-navigating is still a problem because I would lose any new input data that has not saved.</p>
<p>Ideally, the request would just 'pause' until the user logs in from the modal. I have not found a way to implement this.</p>
<p>Any ideas?
Is there a best practice?</p>
| 0debug |
int float32_le_quiet( float32 a, float32 b STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
|| ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
) {
if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
float_raise( float_flag_invalid STATUS_VAR);
}
return 0;
}
aSign = extractFloat32Sign( a );
bSign = extractFloat32Sign( b );
if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );
return ( a == b ) || ( aSign ^ ( a < b ) );
}
| 1threat |
converting daily stock data to weekly-based via pandas in Python : <p>I've got a <code>DataFrame</code> storing daily-based data which is as below:</p>
<pre><code>Date Open High Low Close Volume
2010-01-04 38.660000 39.299999 38.509998 39.279999 1293400
2010-01-05 39.389999 39.520000 39.029999 39.430000 1261400
2010-01-06 39.549999 40.700001 39.020000 40.250000 1879800
2010-01-07 40.090000 40.349998 39.910000 40.090000 836400
2010-01-08 40.139999 40.310001 39.720001 40.290001 654600
2010-01-11 40.209999 40.520000 40.040001 40.290001 963600
2010-01-12 40.160000 40.340000 39.279999 39.980000 1012800
2010-01-13 39.930000 40.669998 39.709999 40.560001 1773400
2010-01-14 40.490002 40.970001 40.189999 40.520000 1240600
2010-01-15 40.570000 40.939999 40.099998 40.450001 1244200
</code></pre>
<p>What I intend to do is to merge it into weekly-based data. After grouping:</p>
<ol>
<li>the <strong>Date</strong> should be every Monday (at this point, holidays scenario should be considered when Monday is not a trading day, we should apply the first trading day in current week as the Date).</li>
<li><strong>Open</strong> should be Monday's (or the first trading day of current week) Open.</li>
<li><strong>Close</strong> should be Friday's (or the last trading day of current week) Close.</li>
<li><strong>High</strong> should be the highest High of trading days in current week.</li>
<li><strong>Low</strong> should be the lowest Low of trading days in current week.</li>
<li><strong>Volumn</strong> should be the sum of all Volumes of trading days in current week.</li>
</ol>
<p>which should look like this:</p>
<pre><code>Date Open High Low Close Volume
2010-01-04 38.660000 40.700001 38.509998 40.290001 5925600
2010-01-11 40.209999 40.970001 39.279999 40.450001 6234600
</code></pre>
<p>Currently, my code snippet is as below, which function should I use to mapping daily-based data to the expected weekly-based data? Many thanks!</p>
<pre><code>import pandas_datareader.data as web
start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2016, 12, 31)
f = web.DataReader("MNST", "yahoo", start, end, session=session)
print f
</code></pre>
| 0debug |
How to convert the given date to dd-mm-yy format in javascript? : <p>How to convert the given date to format.</p>
<p>Input: Sun, 11 Jun 2017 14:14:37 GMT</p>
<p>Output: 11-06-17 DD-MM-YY</p>
<p>I have tried <code>split</code> and then the mapping of month text to month number. </p>
| 0debug |
Fragment not attached to a context : <p>In activity in Toolbar I got a button which need to call method from fragment and update list in that fragment. Now it is an error.
Calling in activity</p>
<pre><code>@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.menu_sort:
ListFragment listFragment = new ListFragment();
listFragment.sortByPopularity();
break;
}
return super.onOptionsItemSelected(item);
}
</code></pre>
<p>Fragment code. I have found an error when Activity not attached. But nothing with context</p>
<pre><code>public class ListFragment extends Fragment implements ListAdapter.ItemClickListener {
/**
* Needed
*/
RecyclerView recyclerView;
View view;
List<BasePojo.Result> list;
ListAdapter listAdapter;
public ListFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
/**
* Main Initialization
*/
view = inflater.inflate(R.layout.fragment_list, container, false);
recyclerView = view.findViewById(R.id.recycler_list_detailed);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
list = new ArrayList<>();
listAdapter = new ListAdapter(list, setOnItemClickCallback());
recyclerView.setAdapter(listAdapter);
RetrofitClient.getApiService().getPhotosList(getString(R.string.api_key)).enqueue(new Callback<BasePojo>() {
@Override
public void onResponse(Call<BasePojo> call, Response<BasePojo> response) {
BasePojo basePojo = response.body();
list.addAll(basePojo.getResults());
recyclerView.getAdapter().notifyDataSetChanged();
}
@Override
public void onFailure(Call<BasePojo> call, Throwable t) {
Log.d("tag", "Response failed" + t.toString());
}
});
return view;
}
@Override
public void onItemClick(View view, int position) {
Log.v("in on click", "value " + position);
}
private OnItemClickListener.OnItemClickCallback setOnItemClickCallback() {
OnItemClickListener.OnItemClickCallback onItemClickCallback = new OnItemClickListener.OnItemClickCallback() {
@Override
public void onItemClicked(View view, int position) {
BasePojo.Result itemClicked = list.get(position);
Bundle bundle = new Bundle();
bundle.putString("title", itemClicked.getOriginalTitle());
bundle.putString("overview", itemClicked.getOverview());
bundle.putString("release_date", itemClicked.getReleaseDate());
bundle.putString("vote_average", itemClicked.getVoteAverage().toString());
bundle.putString("poster_path", itemClicked.getPosterPath());
DetailedFragment detailedFragment = new DetailedFragment();
detailedFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.main_frame_list, detailedFragment);
Log.d("tag", "title is 111 " + bundle.get("title"));
transaction.commit();
}
};
return onItemClickCallback;
}
@Override
public void onAttachFragment(Fragment childFragment) {
super.onAttachFragment(childFragment);
}
public void sortByPopularity() {
RetrofitClient.getApiService().getPopularList(getString(R.string.api_key)).enqueue(new Callback<BasePojo>() {
@Override
public void onResponse(Call<BasePojo> call, Response<BasePojo> response) {
BasePojo basePojo = response.body();
list.addAll(basePojo.getResults());
recyclerView.getAdapter().notifyDataSetChanged();
}
@Override
public void onFailure(Call<BasePojo> call, Throwable t) {
Log.d("tag", "Response failed" + t.toString());
}
}); }
}
</code></pre>
<p>And here is an error</p>
<pre><code>05-09 12:48:26.915 5775-5775/com.borisruzanov.popularmovies E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.borisruzanov.popularmovies, PID: 5775
java.lang.IllegalStateException: Fragment ListFragment{6dbd6de} not attached to a context.
at android.support.v4.app.Fragment.requireContext(Fragment.java:614)
at android.support.v4.app.Fragment.getResources(Fragment.java:678)
at android.support.v4.app.Fragment.getString(Fragment.java:700)
at com.borisruzanov.popularmovies.ListFragment.sortByPopularity(ListFragment.java:110)
at com.borisruzanov.popularmovies.MainActivity.onOptionsItemSelected(MainActivity.java:47)
at android.app.Activity.onMenuItemSelected(Activity.java:3204)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:407)
at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:63)
at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:203)
at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:780)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:171)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:973)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:963)
at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:624)
at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:150)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22265)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
</code></pre>
<p>Thank you very much for your time and help. If my question looks not well please make a note and I will teach how to ask questions better</p>
| 0debug |
Cannot Resolve method getActivity()); : I am trying to take a screenshot while doing an esspresso test
here is my code and i cannot resolve the method getActivity and ive tried using this and that didnt work ethier.
@RunWith(AndroidJUnit4.class)
@LargeTest
// Name of the activity + Test
public class Screencap {
//Strings to be typed into tests declaration
public static final String STRING_TO_BE_TYPED = "Test1233";
public static final String loginID = "LIFEHEALTH";
public static final String Device = "TestDevice";
/**
* A JUnit {@link Rule @Rule} to launch your activity under test. This is a replacement
* for {@link ActivityInstrumentationTestCase2}.
* <p>
* Rules are interceptors which are executed for each test method and will run before
* any of your setup code in the {@link Before @Before} method.
* <p>
* {@link ActivityTestRule} will create and launch of the activity for you and also expose
* the activity under test. To get a reference to the activity you can use
* the {@link ActivityTestRule#getActivity()} method.
*/
//Rule that tells the system which screen to start/boot up on this is telling the device to start from the main menu screen.
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
//@Test must be there to start a test if this is missing it will not run the test
@Test
public void Screencap1 () { /* passes*/
//Enters login
onView(withId(R.id.editOid)) /*editTextUserInput*/
.perform(typeText(loginID), closeSoftKeyboard());
// then click next
onView(withId(R.id.btn_next)).perform(click());
// "Clicks the settings
onView(withId(R.id.btnSettings)).perform(click());
//Clicks Device Settings.
onView(withText("Device Settings")).perform(click());
//Scroll up
onView(withText("Configure IRMA Base")).perform(swipeUp());
onView(withText("Configure IRMA Base")).perform(swipeUp());
onView(withText("Configure IRMA Base")).perform(swipeUp());
onView(withText("Configure IRMA Base")).perform(swipeUp());
onView(withText("Configure IRMA Base")).perform(swipeUp());
onView(withText("Configure IRMA Base")).perform(swipeUp());
onView(withText("Barcode Reader Timeout")).perform(swipeUp());
onView(withText("Barcode Reader Timeout")).perform(swipeUp());
onView(withText("Barcode Reader Timeout")).perform(swipeUp());
//language
onView(withText("Language")).perform(doubleClick());
*this is where the issue is*
HelperClass.takeScreenshot("Whatever you want to call the file", getActivity());
//wait 1 min
try {
Thread.sleep(1 * 60 * 1000);
} catch (InterruptedException e) {
}
/* Clicks back button */
onView(withId(R.id.btn_back)).perform(click());
//clicks main menu button
onView(withText("Main Menu")).perform(click());
}
}
| 0debug |
How to break/continue across nested for each loops in Type Script : <p>I tried to use break inside nested for each loop and it says <strong>jump target cannot cross function boundary</strong>. please let me know how can i break nested for each loop when certain condition is met in type script.</p>
<pre><code>groups =[object-A,object-B,object-C]
groups.forEach(function (group) {
// names also an array
group.names.forEach(function (name) {
if (name == 'SAM'){
break; //can not use break here it says jump target cannot cross function boundary
}
}
}
</code></pre>
| 0debug |
webpack-dev-server proxy dosen't work : <p>I want to proxy /v1/* to <a href="http://myserver.com" rel="noreferrer">http://myserver.com</a>, and here is my script</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code> devServer: {
historyApiFallBack: true,
// progress: true,
hot: true,
inline: true,
// https: true,
port: 8081,
contentBase: path.resolve(__dirname, 'public'),
proxy: {
'/v1/*': {
target: 'http://api.in.uprintf.com',
secure: false
// changeOrigin: true
}
}
},</code></pre>
</div>
</div>
</p>
<p>but it doesn't work,
<a href="https://i.stack.imgur.com/BanoH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BanoH.png" alt="enter image description here"></a></p>
| 0debug |
R Studio: ctrl+shift+enter runs the entire code instead of the selected lines only : <p>I am using R Studio and I have encountered a problem: ctrl+shift+enter is running the entire code instead of the selected lines only. I can always use "Run", but I am used to ctrl+shift+enter... Anybody has any clue on how to fix this?</p>
| 0debug |
static void add_codec(FFServerStream *stream, AVCodecContext *av)
{
AVStream *st;
if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
return;
switch(av->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (av->bit_rate == 0)
av->bit_rate = 64000;
if (av->sample_rate == 0)
av->sample_rate = 22050;
if (av->channels == 0)
av->channels = 1;
break;
case AVMEDIA_TYPE_VIDEO:
if (av->bit_rate == 0)
av->bit_rate = 64000;
if (av->time_base.num == 0){
av->time_base.den = 5;
av->time_base.num = 1;
}
if (av->width == 0 || av->height == 0) {
av->width = 160;
av->height = 128;
}
if (av->bit_rate_tolerance == 0)
av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,
(int64_t)av->bit_rate*av->time_base.num/av->time_base.den);
if (av->qmin == 0)
av->qmin = 3;
if (av->qmax == 0)
av->qmax = 31;
if (av->max_qdiff == 0)
av->max_qdiff = 3;
av->qcompress = 0.5;
av->qblur = 0.5;
if (!av->nsse_weight)
av->nsse_weight = 8;
av->frame_skip_cmp = FF_CMP_DCTMAX;
if (!av->me_method)
av->me_method = ME_EPZS;
av->rc_buffer_aggressivity = 1.0;
if (!av->rc_eq)
av->rc_eq = av_strdup("tex^qComp");
if (!av->i_quant_factor)
av->i_quant_factor = -0.8;
if (!av->b_quant_factor)
av->b_quant_factor = 1.25;
if (!av->b_quant_offset)
av->b_quant_offset = 1.25;
if (!av->rc_max_rate)
av->rc_max_rate = av->bit_rate * 2;
if (av->rc_max_rate && !av->rc_buffer_size) {
av->rc_buffer_size = av->rc_max_rate;
}
break;
default:
abort();
}
st = av_mallocz(sizeof(AVStream));
if (!st)
return;
st->codec = avcodec_alloc_context3(NULL);
stream->streams[stream->nb_streams++] = st;
memcpy(st->codec, av, sizeof(AVCodecContext));
}
| 1threat |
static int combine_residual_frame(DCAXllDecoder *s, DCAXllChSet *c)
{
DCAContext *dca = s->avctx->priv_data;
int ch, nsamples = s->nframesamples;
DCAXllChSet *o;
if (!(dca->packet & DCA_PACKET_CORE)) {
av_log(s->avctx, AV_LOG_ERROR, "Residual encoded channels are present without core\n");
return AVERROR(EINVAL);
}
if (c->freq != dca->core.output_rate) {
av_log(s->avctx, AV_LOG_WARNING, "Sample rate mismatch between core (%d Hz) and XLL (%d Hz)\n", dca->core.output_rate, c->freq);
return AVERROR_INVALIDDATA;
}
if (nsamples != dca->core.npcmsamples) {
av_log(s->avctx, AV_LOG_WARNING, "Number of samples per frame mismatch between core (%d) and XLL (%d)\n", dca->core.npcmsamples, nsamples);
return AVERROR_INVALIDDATA;
}
o = find_next_hier_dmix_chset(s, c);
for (ch = 0; ch < c->nchannels; ch++) {
int n, spkr, shift, round;
int32_t *src, *dst;
if (c->residual_encode & (1 << ch))
continue;
spkr = ff_dca_core_map_spkr(&dca->core, c->ch_remap[ch]);
if (spkr < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Residual encoded channel (%d) references unavailable core channel\n", c->ch_remap[ch]);
return AVERROR_INVALIDDATA;
}
shift = 24 - c->pcm_bit_res + chs_get_lsb_width(s, c, 0, ch);
if (shift > 24) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid core shift (%d bits)\n", shift);
return AVERROR_INVALIDDATA;
}
round = shift > 0 ? 1 << (shift - 1) : 0;
src = dca->core.output_samples[spkr];
dst = c->bands[0].msb_sample_buffer[ch];
if (o) {
int scale_inv = o->dmix_scale_inv[c->hier_ofs + ch];
for (n = 0; n < nsamples; n++)
dst[n] += (SUINT)clip23((mul16(src[n], scale_inv) + round) >> shift);
} else {
for (n = 0; n < nsamples; n++)
dst[n] += (src[n] + round) >> shift;
}
}
return 0;
}
| 1threat |
Setting local repository ID when installing POMs : <p>I need a local repository for my project for a JAR file not available via the Maven Central repository. I install my JAR using <code>mvn install:install-file …</code> as per <a href="http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html" rel="noreferrer">http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html</a>, using <code>-DlocalRepositoryPath</code> to indicate the path in my Git repository, and using <code>-DcreateChecksum</code> to create checksums.</p>
<p>This installs the JAR, generates a POM, and generates checksums for all the files. But interestingly it also creates a <code>maven-metadata-local.xml</code> file in the groupId directory. From <a href="http://maven.apache.org/ref/3.2.5/maven-repository-metadata/" rel="noreferrer">http://maven.apache.org/ref/3.2.5/maven-repository-metadata/</a> I gather that <code>local</code> is the ID it is giving the local repository.</p>
<p>But in my POM (<code>mvn install:install-file</code> had no way of knowing) I use the ID <code>local-repo</code> for my repository:</p>
<pre><code><repositories>
<repository>
<id>local-repo</id>
<url>file:///${project.basedir}/repo</url>
</repository>
</repositories>
</code></pre>
<p>Of course I could change my POM to use simply <code><id>local</id></code> to match the generated files, but I don't like to do things without understanding why I'm doing it. So maybe someone could tell me:</p>
<ul>
<li>Do I need the <code>maven-metadata-local.xml</code>? Does it serve a purpose?</li>
<li>Does the <code>local</code> part need to match the repository ID I use in the POM?</li>
<li>Does <code>mvn install:install-file</code> have a parameter to allow me to indicate the ID to use for the local repository (e.g. to generate <code>maven-metadata-local-repo.xml</code>, or must I manually rename the file afterwards?</li>
</ul>
| 0debug |
static void nvdimm_dsm_reserved_root(AcpiNVDIMMState *state, NvdimmDsmIn *in,
hwaddr dsm_mem_addr)
{
switch (in->function) {
case 0x0:
nvdimm_dsm_function0(0x1 | 1 << 1 , dsm_mem_addr);
return;
case 0x1 :
nvdimm_dsm_func_read_fit(state, in, dsm_mem_addr);
return;
}
nvdimm_dsm_no_payload(NVDIMM_DSM_RET_STATUS_UNSUPPORT, dsm_mem_addr);
}
| 1threat |
Stuck at VS's unable to start program : So I am new to C, so I was writing really basic code on Visual Studio. The first program (Hello World) worked out perfectly. But when I added a second program (a loop) I can an "unable to start program, System could cannot find the file specified"
Exact error (I added the 3 dots in the file path for privacy reasons)
-----
Microsoft Visual Studio
---------------------------
Unable to start program 'C:\Users ... Learning Projects\Learning\Debug\Learning.exe'.
The system cannot find the file specified.
First Program:
#include <stdio.h>
//links the program with the standard input output file
//contains functions like printf
//main function
int main() {
printf("hello World \n");
return (0);
}
Second Program:
#include "stdio.h""
int main() {
int ch;
for (ch = 75; ch <= 100; ch++) {
printf("ASCII value = %d, Character = %c\n", ch, ch);
}
return (0);
}
This may be a stupid problem, but I am unable to figure out what is causing it. | 0debug |
alert('Hello ' + user_input); | 1threat |
Can i find comma separated value in table row in clause in sql query : [Can i find comma separated value in table row in clause in sql query ][1]
[1]: https://i.stack.imgur.com/KSAck.png
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$model = array(
array('id' => '1','category_id' => '1','size_id' => '1,2,3','series_id' => '1','model_no' => 'AI-5441','display_height' => '','Weight' => '','image' => '20382mode1.jpg'),
array('id' => '2','category_id' => '1','size_id' => '3','series_id' => '1','model_no' => 'AI-5741','display_height' => '','Weight' => '','image' => '19391mode1.jpg'),
array('id' => '3','category_id' => '1','size_id' => '4','series_id' => '1','model_no' => 'AI-5841','display_height' => '','Weight' => '','image' => '8242mode1.jpg')
);
<!-- end snippet -->
$sql = "SELECT * from model Where size_id IN ('1')";
How to write php sql query to get value of (matching in size_id' => '1,2,3') or how to match size In('1') into (size_id' => '1,2,3' of 'id' => '1') to get the row value.
| 0debug |
S3 Invalid Resource in bucket policy : <p>I'm trying to make my entire S3 bucket public, but when I try to add the policy:</p>
<pre><code>{
"Id": "Policy1454540872039",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1454540868094",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::sneakysnap/*",
"Principal": {
"AWS": [
"985506495298"
]
}
}
]
}
</code></pre>
<p>It tells me that my "Resource is invalid", but that is definitely the right <code>arn</code> and that is definitely the right bucket name. Anyone know what's going on?</p>
| 0debug |
How do I set multipart in axios with react? : <p>When I curl something, it works fine:</p>
<pre><code>curl -L -i -H 'x-device-id: abc' -F "url=http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" http://example.com/upload
</code></pre>
<p>How do I get this to work right with axios? I'm using react if that matters:</p>
<pre><code>uploadURL (url) {
return axios.post({
url: 'http://example.com/upload',
data: {
url: url
},
headers: {
'x-device-id': 'stuff',
'Content-Type': 'multipart/form-data'
}
})
.then((response) => response.data)
}
</code></pre>
<p>This doesn't work for some reason.</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.