problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
VSCode: Open file from file explorer with Enter key on Mac OSX : <p>When using VSCode on Windows, I can navigate the file explorer and hit <kbd>Enter</kbd> on the focused file and the file will open in the editor. On my Mac, however, when I do this, VSCode will open the rename input as follows:</p>
<p><a href="https://i.stack.imgur.com/up03Q.jpg"><img src="https://i.stack.imgur.com/up03Q.jpg" alt="enter image description here"></a></p>
<p>I'm not sure why it does this. Even in other text editors (e.g. Atom), the default behavior is to open the file on <kbd>Enter</kbd>. Is there any way to change this behavior so that the file opens on <kbd>Enter</kbd>? The only workaround I've found so far is <kbd>CTRL</kbd>+<kbd>Enter</kbd>, which opens the file in a new pane, but with a 3 pane limit in VSCode, this is quite limiting.</p>
| 0debug
|
static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
int num, den, presentation_delayed;
if(st->cur_dts != AV_NOPTS_VALUE){
if(pkt->pts != AV_NOPTS_VALUE)
pkt->pts= lsb2full(pkt->pts, st->cur_dts, st->pts_wrap_bits);
if(pkt->dts != AV_NOPTS_VALUE)
pkt->dts= lsb2full(pkt->dts, st->cur_dts, st->pts_wrap_bits);
}
if (pkt->duration == 0) {
compute_frame_duration(&num, &den, s, st, pc, pkt);
if (den && num) {
pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num);
}
}
presentation_delayed = 0;
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||
st->codec.codec_id == CODEC_ID_MPEG2VIDEO ||
st->codec.codec_id == CODEC_ID_MPEG4 ||
st->codec.codec_id == CODEC_ID_H264) &&
pc && pc->pict_type != FF_B_TYPE)
presentation_delayed = 1;
if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
presentation_delayed = 1;
}
if(st->cur_dts == AV_NOPTS_VALUE){
if(presentation_delayed) st->cur_dts = -pkt->duration;
else st->cur_dts = 0;
}
if (presentation_delayed) {
if (pkt->dts == AV_NOPTS_VALUE) {
if(st->last_IP_pts != AV_NOPTS_VALUE)
st->cur_dts = pkt->dts = st->last_IP_pts;
else
pkt->dts = st->cur_dts;
} else {
st->cur_dts = pkt->dts;
}
if (st->last_IP_duration == 0)
st->cur_dts += pkt->duration;
else
st->cur_dts += st->last_IP_duration;
st->last_IP_duration = pkt->duration;
st->last_IP_pts= pkt->pts;
} else {
if (pkt->pts == AV_NOPTS_VALUE) {
if (pkt->dts == AV_NOPTS_VALUE) {
pkt->pts = st->cur_dts;
pkt->dts = st->cur_dts;
}
else {
st->cur_dts = pkt->dts;
pkt->pts = pkt->dts;
}
} else {
st->cur_dts = pkt->pts;
pkt->dts = pkt->pts;
}
st->cur_dts += pkt->duration;
}
if (pc) {
pkt->flags = 0;
switch(st->codec.codec_type) {
case CODEC_TYPE_VIDEO:
if (pc->pict_type == FF_I_TYPE)
pkt->flags |= PKT_FLAG_KEY;
break;
case CODEC_TYPE_AUDIO:
pkt->flags |= PKT_FLAG_KEY;
break;
default:
break;
}
}
if(pkt->pts != AV_NOPTS_VALUE)
pkt->pts = av_rescale(pkt->pts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
if(pkt->dts != AV_NOPTS_VALUE)
pkt->dts = av_rescale(pkt->dts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
pkt->duration = av_rescale(pkt->duration, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
}
| 1threat
|
How to trigger expensive build steps only when required? : <p>I have a TeamCity project with the following build configurations:</p>
<ol>
<li>Gather dependencies (expensive)</li>
<li>Build</li>
<li>Test</li>
<li>Deploy</li>
</ol>
<p>Say I know whether I need to do it by changes to some file <code>deps.txt</code>.</p>
<p>Here's what I want to do:</p>
<ul>
<li>I want to trigger builds on all changes in version control.</li>
<li>If <code>deps.txt</code> has changed, I want to run builds 1, then 2, then 3, then 4.</li>
<li>If <code>deps.txt</code> has not changed, I want to run builds 2 then 3 then 4.</li>
</ul>
<p>I tried putting triggers on build configurations like this:</p>
<ol>
<li>VCS trigger on no checkins, unless <code>+:deps.txt</code></li>
<li>VCS tigger on all checkins, unless <code>-:deps.txt</code></li>
<li>Snapshot dependency on 2, trigger when 2 finishes building</li>
<li>Snapshot dependency on 3, trigger when 3 finishes building</li>
</ol>
<p>but if a commit includes changes deps.txt <em>and</em> other files, then configurations 1 and 2 trigger at the same time, meaning that configuration 2 will fail.</p>
<p>Is there an easy way to do this in TeamCity?</p>
| 0debug
|
Devices with Android + MIUI and setCustomSelectionActionModeCallback : <p>I'm trying to create custom selection menu but it does not work on a device with rom MIUI and Android 6. The result is common menu with "copy" and "select all" items. On other devices and simulators under clean Android it works just fine.
The code</p>
<pre><code> textViewTop.setCustomSelectionActionModeCallback(new android.view.ActionMode.Callback() {
@Override
public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
Log.d(LOG_TAG, "onCreateActionMode");
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
Log.d(LOG_TAG, "onPrepareActionMode");
menu.clear();
int quote_quick = R.drawable.ic_desktop_mac_black_24dp;
int quote_add = R.drawable.ic_computer_black_24dp;
int copy = R.drawable.ic_devices_other_black_24dp;
menu.add(Menu.NONE, QUOTE_START, 3, "").setIcon(quote_quick).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(Menu.NONE, QUOTE_ADD, 2, "").setIcon(quote_add).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(Menu.NONE, CUSTOM_COPY, 1, "").setIcon(copy).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
</code></pre>
| 0debug
|
Android getIntent() returns current activity : <p>I have a question about getIntent();
Somebody makes activity(Activity A) to call my Activity(Activity B). So it's different package name. The problem is that when I use getIntent(), the return of getIntent is Activity B. so intent.getExtras() is null.
What is problem? I think getIntent() should return Activity A.
It's good work to start from Activity A to B.</p>
<p>Activity A</p>
<pre><code>Intent intent = new Intent();
intent.setClassName(B Package, B Activity);
intent.putExtra("Test", test);
startActivityForResult(intent, REQUEST_OK);
</code></pre>
<hr>
<p>Activity B</p>
<pre><code>Intent intent = getIntent();
Log.d(TAG, "" +getIntent());
if(intent.getExtras() != null){
String name = intent.getStringExtra("Test");
}
</code></pre>
<p>Thanks.</p>
| 0debug
|
static void qerror_set_data(QError *qerr, const char *fmt, va_list *va)
{
QObject *obj;
obj = qobject_from_jsonv(fmt, va);
if (!obj) {
qerror_abort(qerr, "invalid format '%s'", fmt);
}
if (qobject_type(obj) != QTYPE_QDICT) {
qerror_abort(qerr, "error format is not a QDict '%s'", fmt);
}
qerr->error = qobject_to_qdict(obj);
obj = qdict_get(qerr->error, "class");
if (!obj) {
qerror_abort(qerr, "missing 'class' key in '%s'", fmt);
}
if (qobject_type(obj) != QTYPE_QSTRING) {
qerror_abort(qerr, "'class' key value should be a QString");
}
obj = qdict_get(qerr->error, "data");
if (!obj) {
qerror_abort(qerr, "missing 'data' key in '%s'", fmt);
}
if (qobject_type(obj) != QTYPE_QDICT) {
qerror_abort(qerr, "'data' key value should be a QDICT");
}
}
| 1threat
|
Why is the first element in python's sys.path an empty string? : <p>I noticed, when I launch <code>python</code> REPL and do:</p>
<pre><code>import sys
print(sys.path)
</code></pre>
<p>The first element of the list is an empty string. This only happens in the REPL. </p>
| 0debug
|
not able to insert empty integer value in microsoft sql server : INSERT INTO emp(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)
VALUES(7369,'SMITH','CLERK',7902,17-Dec-80,800,'',20)
when i run the sql command select * from emp
The COMM colums is 0 and not empty.
i want the column(COMM) as empty.
i have also set the columns as NULL.
if need more help will provide more code.
why it is inserted as zero and not as blank ?
if need more help will provide more code.
why it is inserted as zero and not as blank ?
if need more help will provide more code.
why it is inserted as zero and not as blank ?
if need more help will provide more code.
why it is inserted as zero and not as blank ?
if need more help will provide more code.
why it is inserted as zero and not as blank ?
if need more help will provide more code.
why it is inserted as zero and not as blank ?
if need more help will provide more code.
why it is inserted as zero and not as blank ?
| 0debug
|
How to round 0.40 to 1 using c# : How to round decimal **0.40** value to **1**, using c# math.round function?
math.round(0.40) gives 0 as answer
but what i want is 1. how can i git this?
thanks in advance
| 0debug
|
Getting an error in a program to encrypt text using Caesar Cipher (Python) : Caesar Cipher is a simple way of encryption that shifts a character a number of places in front of it. For example, ABC with a Rotation of 1 would be BCD. In this program, however, the list of all characters include special characters in a random order, i.e.
```1234567890-=qwertyuiopasdfghjklzxcvbnm,./~!@#$%^&*()_+|\\{}[]:;\'"QWERTYUIOPASDFGHJKLZXCVBNM```
Thus, it is more of a custom cipher but following the principle of Caesar Cipher, the code can be tested by using the 2 functions I have made (encode() and decode()) on the same text, and if the output given is the same as the input, it means that it works. I get an output for some rotation numbers, but some numbers, like 70, give me an error. The code I have written is:
```
characters = '`1234567890-=qwertyuiopasdfghjklzxcvbnm,./~!@#$%^&*()_+|\\{}[]:;\'"QWERTYUIOPASDFGHJKLZXCVBNM' # All characters in a string, no specific order
key_raw = 70 # One of the keys that gives me an error.
def encode(text, key): # Function that takes in two inputs: Text and key, which is the number of characters to shift forward
output, text = '', str(text)
limit = len(characters)
while key > limit:
key -= limit # This is my attempt to simplify the key
for i in text:
if i in characters:
output += characters[characters.index(i)+key] # If i is in characters, the rotated character is concatenated to the output
else:
output += i # Otherwise, it directly adds the text
return output
def decode(text, key): # Same thing, except key is subtracted from the index of i in key, as to decrypt it
output, text = '', str(text)
limit = len(characters)
while key > limit:
key -= limit
for i in text:
if i in characters:
output += characters[characters.index(i)-key]
else:
output += i
return output
print(encode('Why do I get String_Index_Out_Of_Range?', key_raw))
```
Please let me know where I made an error and add possible improvements, thank you!
| 0debug
|
static void v7m_push_stack(ARMCPU *cpu)
{
CPUARMState *env = &cpu->env;
uint32_t xpsr = xpsr_read(env);
if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) {
env->regs[13] -= 4;
xpsr |= XPSR_SPREALIGN;
}
v7m_push(env, xpsr);
v7m_push(env, env->regs[15]);
v7m_push(env, env->regs[14]);
v7m_push(env, env->regs[12]);
v7m_push(env, env->regs[3]);
v7m_push(env, env->regs[2]);
v7m_push(env, env->regs[1]);
v7m_push(env, env->regs[0]);
}
| 1threat
|
Why does this code produce a syntax error? : <p>I am having problems with this if statement</p>
<pre><code>while True:
try:
continue_shopping=int(input("press 0 to stop shopping and print your reciept or press 1 to continue shopping"))
if continue_shopping !=0 and continue_shopping !=1:
print(" make sure you enter 0 or 1")
if continue_shopping !=1
keep_searching = False
if (continue_shopping == 0):
fileOne.close()
fileTwo = open("receipt.csv" , "r")
reader = csv.reader(fileTwo)
for row in reader:
if row != None:
print(row)
elif continue_shopping==1:
search_user_input()
quantity()
quantity()
</code></pre>
<p>The fifth line produces a invalid syntax error the "if" is highlighted in red , I am unsure of why this is the case</p>
| 0debug
|
What does "tr[class^="row"]" mean in Javascript : <p>What does this <code>^</code> mean in the following code line: </p>
<pre><code>tr[class^="row"]
</code></pre>
<p>In the HTML how does it looks like? if used:</p>
<pre><code>var rows = document.querySelectorAll('tr[class^="row"]');
</code></pre>
| 0debug
|
static uint32_t slow_bar_readb(void *opaque, target_phys_addr_t addr)
{
AssignedDevRegion *d = opaque;
uint8_t *in = d->u.r_virtbase + addr;
uint32_t r;
r = *in;
DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
return r;
}
| 1threat
|
static void vnc_init_basic_info_from_server_addr(QIOChannelSocket *ioc,
VncBasicInfo *info,
Error **errp)
{
SocketAddress *addr = NULL;
addr = qio_channel_socket_get_local_address(ioc, errp);
if (!addr) {
vnc_init_basic_info(addr, info, errp);
qapi_free_SocketAddress(addr);
| 1threat
|
print_insn_sparc (bfd_vma memaddr, disassemble_info *info)
{
FILE *stream = info->stream;
bfd_byte buffer[4];
unsigned long insn;
sparc_opcode_hash *op;
static int opcodes_initialized = 0;
static unsigned long current_mach = 0;
bfd_vma (*getword) (const unsigned char *);
if (!opcodes_initialized
|| info->mach != current_mach)
{
int i;
current_arch_mask = compute_arch_mask (info->mach);
if (!opcodes_initialized)
sorted_opcodes =
malloc (sparc_num_opcodes * sizeof (sparc_opcode *));
for (i = 0; i < sparc_num_opcodes; ++i)
sorted_opcodes[i] = &sparc_opcodes[i];
qsort ((char *) sorted_opcodes, sparc_num_opcodes,
sizeof (sorted_opcodes[0]), compare_opcodes);
build_hash_table (sorted_opcodes, opcode_hash_table, sparc_num_opcodes);
current_mach = info->mach;
opcodes_initialized = 1;
}
{
int status =
(*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info);
if (status != 0)
{
(*info->memory_error_func) (status, memaddr, info);
return -1;
}
}
if (info->endian == BFD_ENDIAN_BIG || info->mach == bfd_mach_sparc_sparclite)
getword = bfd_getb32;
else
getword = bfd_getl32;
insn = getword (buffer);
info->insn_info_valid = 1;
info->insn_type = dis_nonbranch;
info->branch_delay_insns = 0;
info->target = 0;
for (op = opcode_hash_table[HASH_INSN (insn)]; op; op = op->next)
{
const sparc_opcode *opcode = op->opcode;
if (! (opcode->architecture & current_arch_mask))
continue;
if ((opcode->match & insn) == opcode->match
&& (opcode->lose & insn) == 0)
{
int imm_added_to_rs1 = 0;
int imm_ored_to_rs1 = 0;
int found_plus = 0;
if (opcode->match == 0x80102000)
imm_ored_to_rs1 = 1;
if (opcode->match == 0x80002000)
imm_added_to_rs1 = 1;
if (X_RS1 (insn) != X_RD (insn)
&& strchr (opcode->args, 'r') != NULL)
continue;
if (X_RS2 (insn) != X_RD (insn)
&& strchr (opcode->args, 'O') != NULL)
continue;
(*info->fprintf_func) (stream, "%s", opcode->name);
{
const char *s;
if (opcode->args[0] != ',')
(*info->fprintf_func) (stream, " ");
for (s = opcode->args; *s != '\0'; ++s)
{
while (*s == ',')
{
(*info->fprintf_func) (stream, ",");
++s;
switch (*s)
{
case 'a':
(*info->fprintf_func) (stream, "a");
++s;
continue;
case 'N':
(*info->fprintf_func) (stream, "pn");
++s;
continue;
case 'T':
(*info->fprintf_func) (stream, "pt");
++s;
continue;
default:
break;
}
}
(*info->fprintf_func) (stream, " ");
switch (*s)
{
case '+':
found_plus = 1;
default:
(*info->fprintf_func) (stream, "%c", *s);
break;
case '#':
(*info->fprintf_func) (stream, "0");
break;
#define reg(n) (*info->fprintf_func) (stream, "%%%s", reg_names[n])
case '1':
case 'r':
reg (X_RS1 (insn));
break;
case '2':
case 'O':
reg (X_RS2 (insn));
break;
case 'd':
reg (X_RD (insn));
break;
#undef reg
#define freg(n) (*info->fprintf_func) (stream, "%%%s", freg_names[n])
#define fregx(n) (*info->fprintf_func) (stream, "%%%s", freg_names[((n) & ~1) | (((n) & 1) << 5)])
case 'e':
freg (X_RS1 (insn));
break;
case 'v':
case 'V':
fregx (X_RS1 (insn));
break;
case 'f':
freg (X_RS2 (insn));
break;
case 'B':
case 'R':
fregx (X_RS2 (insn));
break;
case 'g':
freg (X_RD (insn));
break;
case 'H':
case 'J':
fregx (X_RD (insn));
break;
#undef freg
#undef fregx
#define creg(n) (*info->fprintf_func) (stream, "%%c%u", (unsigned int) (n))
case 'b':
creg (X_RS1 (insn));
break;
case 'c':
creg (X_RS2 (insn));
break;
case 'D':
creg (X_RD (insn));
break;
#undef creg
case 'h':
(*info->fprintf_func) (stream, "%%hi(%#x)",
((unsigned) 0xFFFFFFFF
& ((int) X_IMM22 (insn) << 10)));
break;
case 'i':
case 'I':
case 'j':
{
int imm;
if (*s == 'i')
imm = X_SIMM (insn, 13);
else if (*s == 'I')
imm = X_SIMM (insn, 11);
else
imm = X_SIMM (insn, 10);
if (found_plus)
imm_added_to_rs1 = 1;
if (imm <= 9)
(*info->fprintf_func) (stream, "%d", imm);
else
(*info->fprintf_func) (stream, "%#x", imm);
}
break;
case 'X':
case 'Y':
{
int imm = X_IMM (insn, *s == 'X' ? 5 : 6);
if (imm <= 9)
(info->fprintf_func) (stream, "%d", imm);
else
(info->fprintf_func) (stream, "%#x", (unsigned) imm);
}
break;
case '3':
(info->fprintf_func) (stream, "%ld", X_IMM (insn, 3));
break;
case 'K':
{
int mask = X_MEMBAR (insn);
int bit = 0x40, printed_one = 0;
const char *name;
if (mask == 0)
(info->fprintf_func) (stream, "0");
else
while (bit)
{
if (mask & bit)
{
if (printed_one)
(info->fprintf_func) (stream, "|");
name = sparc_decode_membar (bit);
(info->fprintf_func) (stream, "%s", name);
printed_one = 1;
}
bit >>= 1;
}
break;
}
case 'k':
info->target = memaddr + SEX (X_DISP16 (insn), 16) * 4;
(*info->print_address_func) (info->target, info);
break;
case 'G':
info->target = memaddr + SEX (X_DISP19 (insn), 19) * 4;
(*info->print_address_func) (info->target, info);
break;
case '6':
case '7':
case '8':
case '9':
(*info->fprintf_func) (stream, "%%fcc%c", *s - '6' + '0');
break;
case 'z':
(*info->fprintf_func) (stream, "%%icc");
break;
case 'Z':
(*info->fprintf_func) (stream, "%%xcc");
break;
case 'E':
(*info->fprintf_func) (stream, "%%ccr");
break;
case 's':
(*info->fprintf_func) (stream, "%%fprs");
break;
case 'o':
(*info->fprintf_func) (stream, "%%asi");
break;
case 'W':
(*info->fprintf_func) (stream, "%%tick");
break;
case 'P':
(*info->fprintf_func) (stream, "%%pc");
break;
case '?':
if (X_RS1 (insn) == 31)
(*info->fprintf_func) (stream, "%%ver");
else if ((unsigned) X_RS1 (insn) < 17)
(*info->fprintf_func) (stream, "%%%s",
v9_priv_reg_names[X_RS1 (insn)]);
else
(*info->fprintf_func) (stream, "%%reserved");
break;
case '!':
if ((unsigned) X_RD (insn) < 17)
(*info->fprintf_func) (stream, "%%%s",
v9_priv_reg_names[X_RD (insn)]);
else
(*info->fprintf_func) (stream, "%%reserved");
break;
case '$':
if ((unsigned) X_RS1 (insn) < 32)
(*info->fprintf_func) (stream, "%%%s",
v9_hpriv_reg_names[X_RS1 (insn)]);
else
(*info->fprintf_func) (stream, "%%reserved");
break;
case '%':
if ((unsigned) X_RD (insn) < 32)
(*info->fprintf_func) (stream, "%%%s",
v9_hpriv_reg_names[X_RD (insn)]);
else
(*info->fprintf_func) (stream, "%%reserved");
break;
case '/':
if (X_RS1 (insn) < 16 || X_RS1 (insn) > 25)
(*info->fprintf_func) (stream, "%%reserved");
else
(*info->fprintf_func) (stream, "%%%s",
v9a_asr_reg_names[X_RS1 (insn)-16]);
break;
case '_':
if (X_RD (insn) < 16 || X_RD (insn) > 25)
(*info->fprintf_func) (stream, "%%reserved");
else
(*info->fprintf_func) (stream, "%%%s",
v9a_asr_reg_names[X_RD (insn)-16]);
break;
case '*':
{
const char *name = sparc_decode_prefetch (X_RD (insn));
if (name)
(*info->fprintf_func) (stream, "%s", name);
else
(*info->fprintf_func) (stream, "%ld", X_RD (insn));
break;
}
case 'M':
(*info->fprintf_func) (stream, "%%asr%ld", X_RS1 (insn));
break;
case 'm':
(*info->fprintf_func) (stream, "%%asr%ld", X_RD (insn));
break;
case 'L':
info->target = memaddr + SEX (X_DISP30 (insn), 30) * 4;
(*info->print_address_func) (info->target, info);
break;
case 'n':
(*info->fprintf_func)
(stream, "%#x", SEX (X_DISP22 (insn), 22));
break;
case 'l':
info->target = memaddr + SEX (X_DISP22 (insn), 22) * 4;
(*info->print_address_func) (info->target, info);
break;
case 'A':
{
const char *name;
if ((info->mach == bfd_mach_sparc_v8plusa) ||
((info->mach >= bfd_mach_sparc_v9) &&
(info->mach <= bfd_mach_sparc_v9b)))
name = sparc_decode_asi_v9 (X_ASI (insn));
else
name = sparc_decode_asi_v8 (X_ASI (insn));
if (name)
(*info->fprintf_func) (stream, "%s", name);
else
(*info->fprintf_func) (stream, "(%ld)", X_ASI (insn));
break;
}
case 'C':
(*info->fprintf_func) (stream, "%%csr");
break;
case 'F':
(*info->fprintf_func) (stream, "%%fsr");
break;
case 'p':
(*info->fprintf_func) (stream, "%%psr");
break;
case 'q':
(*info->fprintf_func) (stream, "%%fq");
break;
case 'Q':
(*info->fprintf_func) (stream, "%%cq");
break;
case 't':
(*info->fprintf_func) (stream, "%%tbr");
break;
case 'w':
(*info->fprintf_func) (stream, "%%wim");
break;
case 'x':
(*info->fprintf_func) (stream, "%ld",
((X_LDST_I (insn) << 8)
+ X_ASI (insn)));
break;
case 'y':
(*info->fprintf_func) (stream, "%%y");
break;
case 'u':
case 'U':
{
int val = *s == 'U' ? X_RS1 (insn) : X_RD (insn);
const char *name = sparc_decode_sparclet_cpreg (val);
if (name)
(*info->fprintf_func) (stream, "%s", name);
else
(*info->fprintf_func) (stream, "%%cpreg(%d)", val);
break;
}
}
}
}
if (imm_ored_to_rs1 || imm_added_to_rs1)
{
unsigned long prev_insn;
int errcode;
if (memaddr >= 4)
errcode =
(*info->read_memory_func)
(memaddr - 4, buffer, sizeof (buffer), info);
else
errcode = 1;
prev_insn = getword (buffer);
if (errcode == 0)
{
if (is_delayed_branch (prev_insn))
{
if (memaddr >= 8)
errcode = (*info->read_memory_func)
(memaddr - 8, buffer, sizeof (buffer), info);
else
errcode = 1;
prev_insn = getword (buffer);
}
}
if (errcode == 0)
{
if ((prev_insn & 0xc1c00000) == 0x01000000
&& X_RD (prev_insn) == X_RS1 (insn))
{
(*info->fprintf_func) (stream, "\t! ");
info->target =
((unsigned) 0xFFFFFFFF
& ((int) X_IMM22 (prev_insn) << 10));
if (imm_added_to_rs1)
info->target += X_SIMM (insn, 13);
else
info->target |= X_SIMM (insn, 13);
(*info->print_address_func) (info->target, info);
info->insn_type = dis_dref;
info->data_size = 4;
}
}
}
if (opcode->flags & (F_UNBR|F_CONDBR|F_JSR))
{
if (opcode->flags & F_UNBR)
info->insn_type = dis_branch;
if (opcode->flags & F_CONDBR)
info->insn_type = dis_condbranch;
if (opcode->flags & F_JSR)
info->insn_type = dis_jsr;
if (opcode->flags & F_DELAYED)
info->branch_delay_insns = 1;
}
return sizeof (buffer);
}
}
info->insn_type = dis_noninsn;
(*info->fprintf_func) (stream, _("unknown"));
return sizeof (buffer);
}
| 1threat
|
what is the role of bins to plot an histogram? : I want to an histogram. When I plot it with `bins=80` or `auto`. My code works correctly. But when I try to plot it with `bins=100`. It does not work with giving me this error:
"{!r} is not a valid estimator for `bins`".format(bin_name))
ValueError: '100' is not a valid estimator for `bins`
This is my code:
import matplotlib.pyplot as plt
x= [81.70900202536467, 81.69066539803865, 81.9634647036723, 81.6886583191991, 81.70063595809025, 81.71279936786232, 81.6846428541525]
plt.hist(x,bins='100')
plt.hist(x)
plt.show()
What is the role of bins with histogram? how to choose the suitable bins value for my data?
| 0debug
|
How can I solve this error to call data frame in R? : <p>So when I run R and try to read a file, it gives me an error like this
<a href="https://i.stack.imgur.com/fmESI.jpg" rel="nofollow noreferrer">Error message</a></p>
<p>But I definitely have my file in my directory. As I can tell below photo.</p>
<p><a href="https://i.stack.imgur.com/voeCS.jpg" rel="nofollow noreferrer">working directory</a></p>
<p>How can I solve this problem??</p>
| 0debug
|
static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int predictor, int point_transform)
{
int i, mb_x, mb_y;
uint16_t (*buffer)[4];
int left[4], top[4], topleft[4];
const int linesize = s->linesize[0];
const int mask = (1 << s->bits) - 1;
int resync_mb_y = 0;
int resync_mb_x = 0;
s->restart_count = s->restart_interval;
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
(unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
buffer = s->ljpeg_buffer;
for (i = 0; i < 4; i++)
buffer[0][i] = 1 << (s->bits - 1);
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for (i = 0; i < 4; i++)
top[i] = left[i] = topleft[i] = buffer[0][i];
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int modified_predictor = predictor;
if (s->restart_interval && !s->restart_count){
s->restart_count = s->restart_interval;
resync_mb_x = mb_x;
resync_mb_y = mb_y;
for(i=0; i<4; i++)
top[i] = left[i]= topleft[i]= 1 << (s->bits - 1);
}
if (mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || !mb_x)
modified_predictor = 1;
for (i=0;i<nb_components;i++) {
int pred, dc;
topleft[i] = top[i];
top[i] = buffer[mb_x][i];
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
dc = mjpeg_decode_dc(s, s->dc_index[i]);
if(dc == 0xFFFF)
return -1;
left[i] = buffer[mb_x][i] =
mask & (pred + (dc << point_transform));
}
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16);
}
}
if (s->nb_components == 4) {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+3-c] = buffer[mb_x][i];
}
}
} else if (s->rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else if (s->pegasus_rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2]) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x+2-c] = buffer[mb_x][i];
}
}
}
}
return 0;
}
| 1threat
|
requestAnimationFrame is being called only once : <p>I'm trying to achieve a pretty basic animation using ThreeJS in my Ionic 2 application. Basically trying to rotate a cube. But the cube isn't rotating because requestAnimationFrame is being executed only once inside the render loop.</p>
<p>I'm able to see only this.
<a href="https://i.stack.imgur.com/GBi38.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GBi38.png" alt="enter image description here"></a></p>
<p>No rotating animation. I'm sharing my code below.</p>
<p><strong>home.html</strong></p>
<pre><code><ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<div #webgloutput></div>
</ion-content>
</code></pre>
<p><strong>home.ts</strong></p>
<pre><code>import { Component, ViewChild, ElementRef } from '@angular/core';
import { NavController } from 'ionic-angular';
import * as THREE from 'three';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild('webgloutput') webgloutput: ElementRef;
private renderer: any;
private scene: any;
private camera: any;
private cube: any;
constructor(public navCtrl: NavController) {
}
ngOnInit() {
this.initThree();
}
initThree() {
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
this.renderer = new THREE.WebGLRenderer();
this.renderer.setSize( window.innerWidth, window.innerHeight );
this.webgloutput.nativeElement.appendChild(this.renderer.domElement);
let geometry = new THREE.BoxGeometry(1, 1, 1);
let material = new THREE.MeshBasicMaterial({ color: 0x00ff00});
this.cube = new THREE.Mesh(geometry, material);
this.scene.add(this.cube);
this.camera.position.z = 5;
this.render();
}
render() {
console.log("render called");
requestAnimationFrame(() => this.render);
this.cube.rotation.x += 0.5;
this.cube.rotation.y += 0.5;
this.renderer.render(this.scene, this.camera);
}
}
</code></pre>
| 0debug
|
hi please help me. Not an allowed type in Turbo C++ : So I'm trying to make a grading system. I've already made a program that does it but I just recently found at that we need to use procedures and functions, this is what I've done so far.So what i want to do is take 1/3 of the value of outputgrade and add it with 2/3 of the value of outputgrade2, I tried midterm1=(outputgrade()*1/3)+(outputgrade2*2/3) but I receive an error which is "Not an allowed type". Please somebody help me on what to do.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
double AAO,Quizzes,Project,MajorExam,Midterm;
void inputprelim()
{
clrscr();
gotoxy(3,4);cout<<"Input Prelim Grade";
gotoxy(1,6);cout<<"Attendance/Ass./Oral: ";cin>>AAO;
gotoxy(1,7);cout<<"Project: ";cin>>Project;
gotoxy(1,8);cout<<"Quizzes: ";cin>>Quizzes;
gotoxy(1,9);cout<<"Major Exam: ";cin>>MajorExam;
gotoxy(1,11);cout<<"Prelim Grade: ";
}
int getgrade(double a, double b, double c, double d)
{
double result;
result=(a*0.10)+(b*0.20)+(c*0.30)+(d*0.40);
cout<<setprecision(1)<<result;
return result;
}
void outputgrade()
{
getgrade(AAO,Project,Quizzes,MajorExam);
getch();
}
void inputmidterm()
{
gotoxy(33,4);cout<<"Input Midterm Grade";
gotoxy(29,6);cout<<"Attendance/Ass./Oral: ";cin>>AAO;
gotoxy(29,7);cout<<"Project: ";cin>>Project;
gotoxy(29,8);cout<<"Quizzes: ";cin>>Quizzes;
gotoxy(29,9);cout<<"Major Exam: ";cin>>MajorExam;
gotoxy(29,11);cout<<"Temporary Midterm Grade: ";
gotoxy(29,12);cout<<"Final Midterm Grade: ";
}
void outputgrade2()
{
getgrade(AAO,Project,Quizzes,MajorExam);
getch();
}
void main()
{
inputprelim();
gotoxy(15,11);outputgrade();
inputmidterm();
gotoxy(54,11);outputgrade2();
gotoxy(55,11);
Midterm1=(outputgrade()*1/3)+(outputgrade2()*2/3);
}
| 0debug
|
Pyspark dataframe operator "IS NOT IN" : <p>I would like to rewrite this from R to Pyspark, any nice looking suggestions?</p>
<pre><code>array <- c(1,2,3)
dataset <- filter(!(column %in% array))
</code></pre>
| 0debug
|
How to manage installation from Unknown Sources in Android Oreo? : <p>In Android Oreo (8.0), several changes where made on how to allow the installation of apps from Unknown Sources (from the user's point of view) and to the process of getting permission to install them (from the developer's point of view).</p>
<p>Since I found it particularly hard to find all the steps necessary on the developer side, I thought it to be useful to ask here for the solution and answer the question myself, now that I found the answers, for future reference to those, who are facing the same obstacles.</p>
<p>The answer will include the following questions:</p>
<ol>
<li>How to check whether I'm allowed to request a package install?</li>
<li>What exact permission do I have to request?</li>
<li>How can I prompt the user to grant this permission?</li>
<li>How do I prompt the user to install a specified .apk?</li>
</ol>
<p>(If I still miss anything here, I'd be grateful for any additional answers or comments pointing that out.)</p>
| 0debug
|
Should `const` and `constexpr` variables in headers be `inline` to prevent ODR violations? : <p>Consider the following header and assume it is used in several TUs:</p>
<pre><code>static int x = 0;
struct A {
A() {
++x;
printf("%d\n", x);
}
};
</code></pre>
<p>As <a href="https://stackoverflow.com/questions/4276794/static-keyword-in-h-file-and-internal-linkage">this question</a> explains, this is an ODR violation and, therefore, UB.</p>
<p>Now, <a href="https://stackoverflow.com/questions/41133290/using-constants-in-header-file-with-odr-compliance">there is no ODR violation</a> if our <code>inline</code> function refers to a non-<code>volatile</code> <code>const</code> object and we do not odr-use it within that function (plus the other provisions), so this still works fine in a header:</p>
<pre><code>constexpr int x = 1;
struct A {
A() {
printf("%d\n", x);
}
};
</code></pre>
<p>But if we do happen to odr-use it, we are back at square one with UB:</p>
<pre><code>constexpr int x = 1;
struct A {
A() {
printf("%p\n", &x);
}
};
</code></pre>
<p>Thus, given we have now <code>inline</code> variables, should not the guideline be to mark all <code>namespace</code>-scoped variables as <code>inline</code> in headers to avoid all problems?</p>
<pre><code>constexpr inline int x = 1;
struct A {
A() {
printf("%p\n", &x);
}
};
</code></pre>
<p>This also seems easier to teach, because we can simply say "<code>inline</code>-everything in headers" (i.e. both function and variable definitions), as well as "never <code>static</code> in headers".</p>
<p>Is this reasoning correct? If yes, are there any disadvantages whatsoever of always marking <code>const</code> and <code>constexpr</code> variables in headers as <code>inline</code>?</p>
| 0debug
|
static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw,
int *order_p, int w, int filt)
{
int i, j, order = *order_p;
int *idx = tns->coef_idx[w][filt];
float *lpc = tns->coef[w][filt];
float temp[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f};
if (!order)
return;
for (i = 0; i < order; i++) {
idx[i] = quant_array_idx(coef_raw[i], tns_tmp2_map_0_4, 16);
lpc[i] = tns_tmp2_map_0_4[idx[i]];
}
for (i = order-1; i > -1; i--) {
lpc[i] = (fabs(lpc[i]) > 0.1f) ? lpc[i] : 0.0f;
if (lpc[i] != 0.0 ) {
order = i;
break;
}
}
out[0] = 1.0f;
for (i = 1; i <= order; i++) {
for (j = 1; j < i; j++) {
temp[j] = out[j] + lpc[i]*out[i-j];
}
for (j = 1; j <= i; j++) {
out[j] = temp[j];
}
out[i] = lpc[i-1];
}
*order_p = order;
memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float));
}
| 1threat
|
Xamarin SQLite "This is the 'bait'" : <p>I follow <a href="https://developer.xamarin.com/guides/android/application_fundamentals/data/part_3_using_sqlite_orm/" rel="noreferrer">this</a> guide trying to create a SQLite database to my proyect. But always got same error, doing the exactly steps of the article.</p>
<pre><code> System.Exception: This is the 'bait'. You probably need to add one of the SQLitePCLRaw.bundle_* nuget packages to your platform project.
</code></pre>
| 0debug
|
What regex pattern can I use to match this string? : <p>What regex pattern can I use to match the following:</p>
<p>Dxx-xxxx/xxx</p>
<p>So:
- Any string that starts with character 'D'
- Has any number of any character between the 'D' and the '-'
- Has any number of any character between the '-' and the '/'
- Has any number of any character after the '/'</p>
<p>Apologies if I haven't explained this very well!</p>
| 0debug
|
Is it possible to copy website? I need to take design from my friend's website but we want to try this way. Is it possible? : <p>I want to copy my friend's website but change language and some details. We are working on wordpress. Is it possible?</p>
| 0debug
|
Does retrieving a parcelable object through bundle always create new copy? : <p>I'm passing a parcelable object to a fragment by adding into a bundle while creating the fragment. In onc instance modification to this parcelled object reflects modification in original object and in another case it is not. I'm a little baffled by this behaviour.
Till now I have assumed retrieving a parcelled objects through a bundle always create new object[no sure whether it's shallow copy or deep copy]. </p>
<p>Someone please clarify parcelable behaviour. </p>
| 0debug
|
void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
{
g_free(s->tag);
g_free(s->ctx.fs_root);
| 1threat
|
static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice *vdev, int nr)
{
VFIOQuirk *quirk;
VFIOrtl8168Quirk *rtl;
if (!vfio_pci_is(vdev, PCI_VENDOR_ID_REALTEK, 0x8168) || nr != 2) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
quirk->mem = g_malloc0(sizeof(MemoryRegion) * 2);
quirk->nr_mem = 2;
quirk->data = rtl = g_malloc0(sizeof(*rtl));
rtl->vdev = vdev;
memory_region_init_io(&quirk->mem[0], OBJECT(vdev),
&vfio_rtl_address_quirk, rtl,
"vfio-rtl8168-window-address-quirk", 4);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
0x74, &quirk->mem[0], 1);
memory_region_init_io(&quirk->mem[1], OBJECT(vdev),
&vfio_rtl_data_quirk, rtl,
"vfio-rtl8168-window-data-quirk", 4);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
0x70, &quirk->mem[1], 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
trace_vfio_quirk_rtl8168_probe(vdev->vbasedev.name);
}
| 1threat
|
Create an application that loads a website? : <p>I have an existing MVC web application and I want to create a native application for Android, IOS, and PC that, when launched, navigates to a website but does not show typical browser features such as the URL bar, navigation buttons, bookmarks, etc.</p>
<p>Are there any tools that will allow me to do this for one or more of the targeted platforms?</p>
| 0debug
|
Remove specific variable from list R : <p>I want to remove a pre-defined variable from a list in R, for example: </p>
<pre><code>vertex <- c("A","B","C","D")
list_safe<-vertex
z<-sample(list_safe,1)
list_infected[z] <- z
list_safe_new<-list_safe[list_safe =! "z"]
</code></pre>
<p>Somehow, it does not remove z=C (for example) from the list_safe.
Can someone help me?</p>
| 0debug
|
How to detect AVPlayer actually started to play in swift : <p>Hello I have set my <code>UISlider</code>minimum value to 0.00. Then I set it's max value in this way.</p>
<pre><code>self.viewPlayer.layer.addSublayer(playerLayer)
let duration : CMTime = avPlayer.avPlayer.currentItem!.asset.duration
let seconds : Float64 = CMTimeGetSeconds(duration)
sliderBar.maximumValue=Float(seconds)
sliderBar!.isContinuous = false
sliderBar!.tintColor = UIColor.green
</code></pre>
<p>But I am getting this exception </p>
<pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to set a slider's minimumValue (0.000000) to be larger than the maximumValue (nan)'
enter code here
</code></pre>
<p>I know after <code>prepareForPlay()</code> to actual playing it takes some time to really play the video. So how can I detect when the player really started to play the video?
Please help me.
Thanks</p>
| 0debug
|
i am using Swift-SRWebClient to upload multiple images in single post but i am not able to do so with swift 2.2? using REST API : SRWebClient.POST("http://www.tiikoni.com/tis/upload/upload.php").data(messageData, fieldName:"photo", data: ["CreatedBy":"4","Name": "Test", "Description" :"Test","CategoryId": "0", "SendToSupplier":"0","DeliveryDate":"25/10/2016","FileExtension":"png"])
.send({(response:AnyObject!, status:Int) -> Void in
// process success response
},failure:{(error:NSError!) -> Void in
// process failure response
})
this method gives me error "Cannot invoke with an argument list of type .....
| 0debug
|
static uint64_t arm_thistimer_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
arm_mptimer_state *s = (arm_mptimer_state *)opaque;
int id = get_current_cpu(s);
return timerblock_read(&s->timerblock[id * 2], addr, size);
}
| 1threat
|
Extract substring from the first letter : <p>I need to extract substring from string but starting with the first letter</p>
<p><strong>example</strong> : </p>
<pre><code>string s1 = "12 x 13 ABC 12@ 15.8" substring = ABC 12@ 15.8
string s2 = "25 x 32 FER @23.8" substring = FER @23.8
</code></pre>
<p>I tried the index of for the letter A or F but it didn't work</p>
<p>thanks</p>
| 0debug
|
static void acpi_pcihp_update_hotplug_bus(AcpiPciHpState *s, int bsel)
{
BusChild *kid, *next;
PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel);
while (s->acpi_pcihp_pci_status[bsel].down) {
acpi_pcihp_eject_slot(s, bsel, s->acpi_pcihp_pci_status[bsel].down);
}
s->acpi_pcihp_pci_status[bsel].hotplug_enable = ~0;
s->acpi_pcihp_pci_status[bsel].device_present = 0;
if (!bus) {
return;
}
QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) {
DeviceState *qdev = kid->child;
PCIDevice *pdev = PCI_DEVICE(qdev);
int slot = PCI_SLOT(pdev->devfn);
if (acpi_pcihp_pc_no_hotplug(s, pdev)) {
s->acpi_pcihp_pci_status[bsel].hotplug_enable &= ~(1U << slot);
}
s->acpi_pcihp_pci_status[bsel].device_present |= (1U << slot);
}
}
| 1threat
|
void ff_snow_vertical_compose97i_sse2(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *b3, DWTELEM *b4, DWTELEM *b5, int width){
long i = width;
while(i & 0xF)
{
i--;
b4[i] -= (W_DM*(b3[i] + b5[i])+W_DO)>>W_DS;
b3[i] -= (W_CM*(b2[i] + b4[i])+W_CO)>>W_CS;
b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
}
asm volatile (
"jmp 2f \n\t"
"1: \n\t"
"mov %6, %%"REG_a" \n\t"
"mov %4, %%"REG_S" \n\t"
snow_vertical_compose_sse2_load(REG_S,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_add(REG_a,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_move("xmm0","xmm2","xmm4","xmm6","xmm1","xmm3","xmm5","xmm7")
snow_vertical_compose_sse2_r2r_add("xmm0","xmm2","xmm4","xmm6","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_r2r_add("xmm1","xmm3","xmm5","xmm7","xmm0","xmm2","xmm4","xmm6")
"pcmpeqd %%xmm1, %%xmm1 \n\t"
"pslld $31, %%xmm1 \n\t"
"psrld $29, %%xmm1 \n\t"
"mov %5, %%"REG_a" \n\t"
snow_vertical_compose_sse2_r2r_add("xmm1","xmm1","xmm1","xmm1","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_sra("3","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_load(REG_a,"xmm1","xmm3","xmm5","xmm7")
snow_vertical_compose_sse2_sub("xmm0","xmm2","xmm4","xmm6","xmm1","xmm3","xmm5","xmm7")
snow_vertical_compose_sse2_store(REG_a,"xmm1","xmm3","xmm5","xmm7")
"mov %3, %%"REG_c" \n\t"
snow_vertical_compose_sse2_load(REG_S,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_add(REG_c,"xmm1","xmm3","xmm5","xmm7")
snow_vertical_compose_sse2_sub("xmm1","xmm3","xmm5","xmm7","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_store(REG_S,"xmm0","xmm2","xmm4","xmm6")
"mov %2, %%"REG_a" \n\t"
snow_vertical_compose_sse2_add(REG_a,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_sra("2","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_add(REG_c,"xmm0","xmm2","xmm4","xmm6")
"pcmpeqd %%xmm1, %%xmm1 \n\t"
"pslld $31, %%xmm1 \n\t"
"psrld $30, %%xmm1 \n\t"
"mov %1, %%"REG_S" \n\t"
snow_vertical_compose_sse2_r2r_add("xmm1","xmm1","xmm1","xmm1","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_sra("2","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_add(REG_c,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_store(REG_c,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_add(REG_S,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_move("xmm0","xmm2","xmm4","xmm6","xmm1","xmm3","xmm5","xmm7")
snow_vertical_compose_sse2_sra("1","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_r2r_add("xmm1","xmm3","xmm5","xmm7","xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_add(REG_a,"xmm0","xmm2","xmm4","xmm6")
snow_vertical_compose_sse2_store(REG_a,"xmm0","xmm2","xmm4","xmm6")
"2: \n\t"
"sub $16, %%"REG_d" \n\t"
"jge 1b \n\t"
:"+d"(i)
:
"m"(b0),"m"(b1),"m"(b2),"m"(b3),"m"(b4),"m"(b5):
"%"REG_a"","%"REG_S"","%"REG_c"");
}
| 1threat
|
What causes this Android APK Upload error: "Non-upgradable APK" : <p>I have an Android APK in the Google Play store with an Target SDK of 23.</p>
<p>I have released a new version (same target SDK) and Google shows me this error:</p>
<p>If I proceed (I learnt the hard way) then none of the current users can upgrade to this version. I had to restore the code, increment the build number and rebuild the APK to "rollback" to a usable version.</p>
<p>However, I cannot work out WHY google is showing me this error. Note, the "0 Supported Android Devices" is a red-herring - it is a known issue in Google Play in the last 24 hours - if you publish the APK the real number of devices is shown. </p>
<p>Please give me some leads on what the difference is or what causes this error:</p>
<p><strong>Non-upgradable APK</strong>
WARNING
None of the users of this APK will be able to upgrade to any of the new APKs added in this release.
TIP
Ensure that all your new APKs are added to this release.
<a href="https://i.stack.imgur.com/9LSP8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9LSP8.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/NREGb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NREGb.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/1NIzC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1NIzC.png" alt="enter image description here"></a></p>
| 0debug
|
NumberFormatException and how do i fix it? : When I enter jTextField2 before I enter jTextField1 I get the error stacktrace:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "Enter"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at suvatcalc.CalculatorFrame.jTextField2KeyReleased(CalculatorFrame.java:263)
at suvatcalc.CalculatorFrame.access$200(CalculatorFrame.java:14)
at suvatcalc.CalculatorFrame$3.keyReleased(CalculatorFrame.java:78)
at java.awt.Component.processKeyEvent(Component.java:6500)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2832)
at java.awt.Component.processEvent(Component.java:6316)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:835)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1103)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:974)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:800)
at java.awt.Component.dispatchEventImpl(Component.java:4760)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Here is the code:
private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
String displacementString = jTextField1.getText();
displacement = Double.parseDouble(displacementString);
System.out.println(displacement);
}
}
private void jTextField2KeyReleased(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
String initialVelocityString = jTextField1.getText();
initialVelocity = Double.parseDouble(initialVelocityString);
System.out.println(initialVelocity);
}
}
I'm not quite sure what the problem is. The program requires me to enter the text boxes only in order which I assume is a result of the way I wrote the program.
| 0debug
|
Query returns no results in xQuery : I tried to query an XML file with xQuery in BaseX. Unfortunately the query returns no results. I think this is caused by incorrect declarations of the namespaces in xQuery's prolog. Please see the code below for the namespaces used in the original XML.
Can somebody please tell me which statements I should use to list all product titles (< dcterms:title>)?
<page xmlns="http://www.somewebsite.nl/Productoverzicht"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:overheid="http://standaarden.overheid.nl/owms/terms/"
xmlns:overheidproduct="http://standaarden.overheid.nl/product/terms/"
xmlns:overheidsc="http://standaarden.overheid.nl/sc/terms/"
xsi:schemaLocation="http://www.somewebsite.nl/Productoverzicht
http://www.somewebsite.nl/xsd/productoverzicht6.2.xsd
http://standaarden.overheid.nl/product/terms/
http://standaarden.overheid.nl/sc/4.0/xsd/sc.xsd">
| 0debug
|
static void pci_bridge_region_del(PCIBridge *br, PCIBridgeWindows *w)
{
PCIDevice *pd = PCI_DEVICE(br);
PCIBus *parent = pd->bus;
memory_region_del_subregion(parent->address_space_io, &w->alias_io);
memory_region_del_subregion(parent->address_space_mem, &w->alias_mem);
memory_region_del_subregion(parent->address_space_mem, &w->alias_pref_mem);
pci_unregister_vga(pd);
}
| 1threat
|
static void pxa2xx_gpio_set(void *opaque, int line, int level)
{
PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;
CPUState *cpu = CPU(s->cpu);
int bank;
uint32_t mask;
if (line >= s->lines) {
printf("%s: No GPIO pin %i\n", __FUNCTION__, line);
return;
}
bank = line >> 5;
mask = 1U << (line & 31);
if (level) {
s->status[bank] |= s->rising[bank] & mask &
~s->ilevel[bank] & ~s->dir[bank];
s->ilevel[bank] |= mask;
} else {
s->status[bank] |= s->falling[bank] & mask &
s->ilevel[bank] & ~s->dir[bank];
s->ilevel[bank] &= ~mask;
}
if (s->status[bank] & mask)
pxa2xx_gpio_irq_update(s);
if (cpu->halted && (mask & ~s->dir[bank] & pxa2xx_gpio_wake[bank])) {
cpu_interrupt(cpu, CPU_INTERRUPT_EXITTB);
}
}
| 1threat
|
static void virtio_queue_host_notifier_read(EventNotifier *n)
{
VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
if (event_notifier_test_and_clear(n)) {
virtio_queue_notify_vq(vq);
}
}
| 1threat
|
Passing an event object to enzyme .simulate : <p>I am using Jest and Enzyme to test a React checkbox component.</p>
<p>This is my test:</p>
<pre><code>it('triggers checkbox onChange event', () => {
const configs = {
default: true,
label: 'My Label',
element: 'myElement',
}
const checkbox = shallow(
<CheckBox
configs={configs}
/>
)
checkbox.find('input').simulate('click')
})
</code></pre>
<p>I get this error however when running the test:</p>
<pre><code>TypeError: Cannot read property 'target' of undefined
</code></pre>
<p>This is the input for my component:</p>
<pre><code><div className="toggle-btn sm">
<input
id={this.props.configs.element}
className="toggle-input round"
type="checkbox"
defaultChecked={ this.props.defaultChecked }
onClick={ e => this.onChange(e.target) }
>
</input>
</div>
</code></pre>
<p>I <em>think</em> that <a href="https://github.com/airbnb/enzyme/issues/592#issuecomment-246259252" rel="noreferrer">I need to pass an event as the second object to <code>simulate</code></a> but I am not sure how to do this.</p>
<p>Thanks</p>
| 0debug
|
static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int i, clut_id;
int version;
DVBSubCLUT *clut;
int entry_id, depth , full_range;
int y, cr, cb, alpha;
int r, g, b, r_add, g_add, b_add;
av_dlog(avctx, "DVB clut packet:\n");
for (i=0; i < buf_size; i++) {
av_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
av_dlog(avctx, "\n");
}
if (i % 16)
av_dlog(avctx, "\n");
clut_id = *buf++;
version = ((*buf)>>4)&15;
buf += 1;
clut = get_clut(ctx, clut_id);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = clut_id;
clut->version = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->version != version) {
clut->version = version;
while (buf + 4 < buf_end) {
entry_id = *buf++;
depth = (*buf) & 0xe0;
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
return 0;
}
full_range = (*buf++) & 1;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
buf += 2;
}
if (y == 0)
alpha = 0xff;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
av_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
}
return 0;
}
| 1threat
|
static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
{
VirtIOBlock *s = VIRTIO_BLK(vdev);
VirtIOBlockReq *req = s->rq;
while (req) {
qemu_put_sbyte(f, 1);
qemu_put_buffer(f, (unsigned char *)req->elem,
sizeof(VirtQueueElement));
req = req->next;
}
qemu_put_sbyte(f, 0);
}
| 1threat
|
Java Scanner utility wont allow user to re-enter input in a loop : <p>just trying to wrap my head around Java coding with a few practice programs and am experimenting with loops and the scanner utility and just ran into a problem when trying to use the scanner to check if the right input was entered and getting the program to loop until the right input was entered.</p>
<pre><code>import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int numbOne;
boolean checker;
System.out.println("please enter an Interger");
do{
if(s.hasNextInt()){
numbOne = s.nextInt();
System.out.println("Yay it worked!!!");
checker = true;
}
else{
System.out.println("I told you to enter an integer you idiot\nTRY AGAIN!!!!!!");
checker = false;
}
}
while(checker == false);
}
}
</code></pre>
<p>Basically what is supposed to happen is that once the program enters the loop it asks the user to input an integer, if the user inputs an integer it displays the message "Yay it worked!!!" and breaks out of the loop, however if the user inputs a string or any other value then the code loops around and should ask for the input again.</p>
<p>However the problem I am having is that the program only asks for the input once and if the wrong input is entered then the program just keeps looping the else statement over and over again without asking the user for the input again.</p>
<p>Any idea what I have done wrong?</p>
| 0debug
|
Multiple databases in docker and docker-compose : <p>I have a project consisting of two main java apps that use eight postgres databases, so is there a way in docker-compose to build eight different databases so that each one has a different owner and password? Can I even do that in docker-compose?</p>
<p><strong>example</strong>:</p>
<pre><code>services:
postgresql:
build: db/.
ports:
- "5432:5432"
environment:
- POSTGRES_DB=database1
- POSTGRES_USER=database1
- POSTGRES_PASSWORD=database1
</code></pre>
<p>I know I can put all the .sql files in the docker-entrypoint-initdb.d and postgres will make them automatically, but how do I declare what .sql file goes in what database?</p>
<p>Tnx,
Tom</p>
| 0debug
|
static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
const QDict *params)
{
QObject *data = NULL;
cmd->mhandler.cmd_new(mon, params, &data);
if (data)
cmd->user_print(mon, data);
qobject_decref(data);
}
| 1threat
|
Does somebody know what's $#? : I have to change a bash script into a powershell script, but I dont really get the condition in the if-statement.
if [ $# -eq 0 ]
then
name='plmapp-all'
else
name="$1"
Does somebody know whats $# and how this statement would look like in powershell?
| 0debug
|
Pythonic way for calculating length of lists in pandas dataframe column : <p>I have a dataframe like this:</p>
<pre><code> CreationDate
2013-12-22 15:25:02 [ubuntu, mac-osx, syslinux]
2009-12-14 14:29:32 [ubuntu, mod-rewrite, laconica, apache-2.2]
2013-12-22 15:42:00 [ubuntu, nat, squid, mikrotik]
</code></pre>
<p>I am calculation length of lists in the <code>CreationDate</code> column and making a new <code>Length</code> column like this:</p>
<pre><code>df['Length'] = df.CreationDate.apply(lambda x: len(x))
</code></pre>
<p>Which gives me this:</p>
<pre><code> CreationDate Length
2013-12-22 15:25:02 [ubuntu, mac-osx, syslinux] 3
2009-12-14 14:29:32 [ubuntu, mod-rewrite, laconica, apache-2.2] 4
2013-12-22 15:42:00 [ubuntu, nat, squid, mikrotik] 4
</code></pre>
<p>Is there a more pythonic way to do this?</p>
| 0debug
|
void hmp_delvm(Monitor *mon, const QDict *qdict)
{
BlockDriverState *bs;
Error *err;
const char *name = qdict_get_str(qdict, "name");
if (!find_vmstate_bs()) {
monitor_printf(mon, "No block device supports snapshots\n");
return;
}
if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {
monitor_printf(mon,
"Error while deleting snapshot on device '%s': %s\n",
bdrv_get_device_name(bs), error_get_pretty(err));
error_free(err);
}
}
| 1threat
|
static int onenand_initfn(SysBusDevice *sbd)
{
DeviceState *dev = DEVICE(sbd);
OneNANDState *s = ONE_NAND(dev);
uint32_t size = 1 << (24 + ((s->id.dev >> 4) & 7));
void *ram;
s->base = (hwaddr)-1;
s->rdy = NULL;
s->blocks = size >> BLOCK_SHIFT;
s->secs = size >> 9;
s->blockwp = g_malloc(s->blocks);
s->density_mask = (s->id.dev & 0x08)
? (1 << (6 + ((s->id.dev >> 4) & 7))) : 0;
memory_region_init_io(&s->iomem, OBJECT(s), &onenand_ops, s, "onenand",
0x10000 << s->shift);
if (!s->bdrv) {
s->image = memset(g_malloc(size + (size >> 5)),
0xff, size + (size >> 5));
} else {
if (bdrv_is_read_only(s->bdrv)) {
error_report("Can't use a read-only drive");
return -1;
}
s->bdrv_cur = s->bdrv;
}
s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT),
0xff, (64 + 2) << PAGE_SHIFT);
memory_region_init_ram(&s->ram, OBJECT(s), "onenand.ram",
0xc000 << s->shift, &error_abort);
vmstate_register_ram_global(&s->ram);
ram = memory_region_get_ram_ptr(&s->ram);
s->boot[0] = ram + (0x0000 << s->shift);
s->boot[1] = ram + (0x8000 << s->shift);
s->data[0][0] = ram + ((0x0200 + (0 << (PAGE_SHIFT - 1))) << s->shift);
s->data[0][1] = ram + ((0x8010 + (0 << (PAGE_SHIFT - 6))) << s->shift);
s->data[1][0] = ram + ((0x0200 + (1 << (PAGE_SHIFT - 1))) << s->shift);
s->data[1][1] = ram + ((0x8010 + (1 << (PAGE_SHIFT - 6))) << s->shift);
onenand_mem_setup(s);
sysbus_init_irq(sbd, &s->intr);
sysbus_init_mmio(sbd, &s->container);
vmstate_register(dev,
((s->shift & 0x7f) << 24)
| ((s->id.man & 0xff) << 16)
| ((s->id.dev & 0xff) << 8)
| (s->id.ver & 0xff),
&vmstate_onenand, s);
return 0;
}
| 1threat
|
.prob() does not change the checkbox status from inside each() loop : I'm working on a project where I want to check checkboxes based on matching a regEx Pattern. [MY_JSFIDDLE][1]
I come across a very strange behavior:
function checkRegEx() {
$.each(myjson, function (i, v) {
var feedname = this.name;
var regExPat1 = document.getElementById('regExField').value;
var regExPat = new RegExp(regExPat1, 'gi');
var matched_bool = regExPat.test(feedname);
//console.log(matched_bool==true);
if(matched_bool==true) {
$("#"+feedname).prop('checked',true);
//$("#"+feedname).click(); // THIS WORKS STRANGELY
console.log($("#"+feedname).prop('checked'));
//console.log("eval TRUE #" + feedname)
} else {
$("#"+feedname).prop('checked', false);
//console.log("eval FALSEE #" + feedname)
};
});
document.getElementById("regExField").focus();
};
I can change and read out the status of the checkbox but it won't affect the GUI.
When I use `$("#"+feedname).click();` it works as I would expect. So I'm calling the ID right. I'm working on the latest Chrome. Strangely I found another [jsfiddle][2]. Here the `prop` method works for me. So it can't be a browser issue.
(im aware that jsfiddle uses jquery_edge, that is not the reason why it works there and not in mine- I tested different jquery versions in both jsfiddles)
Any advice. Can't see what I'm doing wrong here.
[1]: https://jsfiddle.net/masterlup/00e3k7y5/
[2]: http://jsfiddle.net/dimodi/L9x5uhae/
| 0debug
|
static void pc_init1(QEMUMachineInitArgs *args,
int pci_enabled,
int kvmclock_enabled)
{
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
qemu_irq *cpu_irq;
qemu_irq *gsi;
qemu_irq *i8259;
qemu_irq *smi_irq;
GSIState *gsi_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
ISADevice *floppy;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
DeviceState *icc_bridge;
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
object_property_add_child(qdev_get_machine(), "icc-bridge",
OBJECT(icc_bridge), NULL);
pc_cpus_init(args->cpu_model, icc_bridge);
if (kvm_enabled() && kvmclock_enabled) {
kvmclock_create();
}
if (args->ram_size >= 0xe0000000) {
above_4g_mem_size = args->ram_size - 0xe0000000;
below_4g_mem_size = 0xe0000000;
} else {
above_4g_mem_size = 0;
below_4g_mem_size = args->ram_size;
}
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = system_memory;
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
guest_info->has_acpi_build = has_acpi_build;
guest_info->has_pci_info = has_pci_info;
guest_info->isapc_ram_fw = !pci_enabled;
if (!xen_enabled()) {
fw_cfg = pc_memory_init(system_memory,
args->kernel_filename, args->kernel_cmdline,
args->initrd_filename,
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
kvm_pc_setup_irq_routing(pci_enabled);
gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, args->ram_size,
below_4g_mem_size,
0x100000000ULL - below_4g_mem_size,
above_4g_mem_size,
pci_memory, ram_memory);
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, system_io);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, gsi);
if (kvm_irqchip_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
cpu_irq = pc_allocate_cpu_irq();
i8259 = i8259_init(isa_bus, cpu_irq[0]);
}
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
if (pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
qdev_init_nofail(icc_bridge);
pc_register_ferr_irq(gsi[13]);
pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled());
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, MAX_IDE_BUS);
if (pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
idebus[i] = qdev_get_child_bus(DEVICE(dev), "ide.0");
}
}
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, args->boot_order,
floppy, idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled(false)) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
if (pci_enabled && acpi_enabled) {
i2c_bus *smbus;
smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
gsi[9], *smi_irq,
kvm_enabled(), fw_cfg);
smbus_eeprom_init(smbus, 8, NULL, 0);
}
if (pci_enabled) {
pc_pci_device_init(pci_bus);
}
if (has_pvpanic) {
pvpanic_init(isa_bus);
}
}
| 1threat
|
Search box label should change by drop down list : I am trying to do change search box label as per drop down list.
like ...
[![
][1]][1]
[1]: http://i.stack.imgur.com/7yeGK.png
then the search box should be like Search Company Admin when is elect company admin tag.
| 0debug
|
Javascript variables and parameters : <p>I have a question as to why this is not working. Noob question, probably.</p>
<pre><code>var itemCheck = {
darkBerries: 0
}
var id = darkBerries;
itemcheck . id ++;
</code></pre>
<p>Thank you.</p>
| 0debug
|
cryptodev_builtin_get_aes_algo(uint32_t key_len, Error **errp)
{
int algo;
if (key_len == 128 / 8) {
algo = QCRYPTO_CIPHER_ALG_AES_128;
} else if (key_len == 192 / 8) {
algo = QCRYPTO_CIPHER_ALG_AES_192;
} else if (key_len == 256 / 8) {
algo = QCRYPTO_CIPHER_ALG_AES_256;
} else {
error_setg(errp, "Unsupported key length :%u", key_len);
return -1;
}
return algo;
}
| 1threat
|
how to use Socks4/5 Proxy Handlers in Netty Client (4.1) : <p>I need to configure socks proxy in Netty client (to request different sites via socks4 or 5 proxies).
Tried a lot of proxies from free socks lists (like www.socks-proxy.net, <a href="http://sockslist.net/" rel="noreferrer">http://sockslist.net/</a> etc) but with no luck:</p>
<pre><code>@Test
public void testProxy() throws Exception {
final String ua = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
final String host = "www.main.de";
final int port = 80;
Bootstrap b = new Bootstrap();
b.group(new NioEventLoopGroup())
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast(new HttpClientCodec());
p.addLast(new HttpContentDecompressor());
p.addLast(new HttpObjectAggregator(10_485_760));
p.addLast(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
HttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/");
request.headers().set(HOST, host + ":" + port);
request.headers().set(USER_AGENT, ua);
request.headers().set(CONNECTION, CLOSE);
ctx.writeAndFlush(request);
System.out.println("!sent");
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
System.out.println("!answer");
if (msg instanceof FullHttpResponse) {
FullHttpResponse httpResp = (FullHttpResponse) msg;
ByteBuf content = httpResp.content();
String strContent = content.toString(UTF_8);
System.out.println("body: " + strContent);
finish.countDown();
return;
}
super.channelRead(ctx, msg);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace(System.err);
ctx.close();
finish.countDown();
}
});
p.addLast(new Socks4ProxyHandler(new InetSocketAddress("149.202.68.167", 37678)));
}
});
b.connect(host, port).awaitUninterruptibly();
System.out.println("!connected");
finish.await(1, MINUTES);
}
</code></pre>
<p>The connection hangs, resets or getting some strange exceptions.
What's wrong?
Proxy support added to Netty since 4.1 (now there is a 4.1CR, tried it and 4.1b7-8 before)</p>
| 0debug
|
int mpeg4_decode_video_packet_header(MpegEncContext *s)
{
int mb_num_bits= av_log2(s->mb_num - 1) + 1;
int header_extension=0, mb_num, len;
if( get_bits_count(&s->gb) > s->gb.size_in_bits-20) return -1;
for(len=0; len<32; len++){
if(get_bits1(&s->gb)) break;
}
if(len!=ff_mpeg4_get_video_packet_prefix_length(s)){
av_log(s->avctx, AV_LOG_ERROR, "marker does not match f_code\n");
return -1;
}
if(s->shape != RECT_SHAPE){
header_extension= get_bits1(&s->gb);
}
mb_num= get_bits(&s->gb, mb_num_bits);
if(mb_num>=s->mb_num){
av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
return -1;
}
s->mb_x= mb_num % s->mb_width;
s->mb_y= mb_num / s->mb_width;
if(s->shape != BIN_ONLY_SHAPE){
int qscale= get_bits(&s->gb, s->quant_precision);
if(qscale)
s->chroma_qscale=s->qscale= qscale;
}
if(s->shape == RECT_SHAPE){
header_extension= get_bits1(&s->gb);
}
if(header_extension){
int time_incr=0;
while (get_bits1(&s->gb) != 0)
time_incr++;
check_marker(&s->gb, "before time_increment in video packed header");
skip_bits(&s->gb, s->time_increment_bits);
check_marker(&s->gb, "before vop_coding_type in video packed header");
skip_bits(&s->gb, 2);
if(s->shape != BIN_ONLY_SHAPE){
skip_bits(&s->gb, 3);
if(s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
mpeg4_decode_sprite_trajectory(s, &s->gb);
av_log(s->avctx, AV_LOG_ERROR, "untested\n");
}
if (s->pict_type != AV_PICTURE_TYPE_I) {
int f_code = get_bits(&s->gb, 3);
if(f_code==0){
av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (f_code=0)\n");
}
}
if (s->pict_type == AV_PICTURE_TYPE_B) {
int b_code = get_bits(&s->gb, 3);
if(b_code==0){
av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (b_code=0)\n");
}
}
}
}
return 0;
}
| 1threat
|
Can an algorithm for this be done in one line? : <p>I have 3 variables: <code>total</code>, <code>paid</code>, and <code>payment</code></p>
<p>Lets give an example to simplify the problem:</p>
<blockquote>
<pre><code>total = 100
paid = 10
</code></pre>
<p>If a new <code>payment</code> comes in which value is <code>200</code>, <code>paid</code> should now
become <code>100</code> <br> If a new <code>payment</code> comes in which value is <code>50</code>,
<code>paid</code> should now become <code>60</code> <br> If a new <code>payment</code> comes in which
value is <code>90</code>, <code>paid</code> should now become <code>100</code></p>
</blockquote>
<p>I think you get what im going for.</p>
<p>Can <code>paid</code> be calculated in one line, without using <code>if</code> or the <code>?</code> operator?</p>
| 0debug
|
static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
register int t1,t2,t3,t4;
DCTELEM *src, *dst;
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
src = block;
dst = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[0] + src[2]) + 4;
t2 = 17 * (src[0] - src[2]) + 4;
t3 = 22 * src[1] + 10 * src[3];
t4 = 22 * src[3] - 10 * src[1];
dst[0] = (t1 + t3) >> 3;
dst[1] = (t2 - t4) >> 3;
dst[2] = (t2 + t4) >> 3;
dst[3] = (t1 - t3) >> 3;
src += 8;
dst += 8;
}
src = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[ 0] + src[16]) + 64;
t2 = 17 * (src[ 0] - src[16]) + 64;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
src ++;
dest++;
}
}
| 1threat
|
static int dca_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int i;
int16_t *samples = data;
DCAContext *s = avctx->priv_data;
int channels;
s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE);
if (s->dca_buffer_size == -1) {
av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
}
init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
if (dca_parse_frame_header(s) < 0) {
*data_size=0;
return buf_size;
}
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate;
channels = s->prim_channels + !!s->lfe;
if (s->amode<16) {
avctx->channel_layout = dca_core_channel_layout[s->amode];
if (s->lfe) {
avctx->channel_layout |= CH_LOW_FREQUENCY;
s->channel_order_tab = dca_channel_reorder_lfe[s->amode];
} else
s->channel_order_tab = dca_channel_reorder_nolfe[s->amode];
if(avctx->request_channels == 2 && s->prim_channels > 2) {
channels = 2;
s->output = DCA_STEREO;
avctx->channel_layout = CH_LAYOUT_STEREO;
}
} else {
av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode);
}
if (!avctx->channels)
avctx->channels = channels;
if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)
*data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels;
for (i = 0; i < (s->sample_blocks / 8); i++) {
dca_decode_block(s);
s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
samples += 256 * channels;
}
return buf_size;
}
| 1threat
|
`docker-credential-gcloud` not in system PATH : <p>After the latest updates to gcloud and docker I'm unable to access images on my google container repository. Locally when I run: <code>gcloud auth configure-docker</code> as per the instructions after updating gcloud, I get the following message:</p>
<pre><code>WARNING: `docker-credential-gcloud` not in system PATH.
gcloud's Docker credential helper can be configured but it will not work until this is corrected.
gcloud credential helpers already registered correctly.
</code></pre>
<p>Running <code>which docker-credential-gcloud</code> returns <code>docker-credential-gcloud not found</code>.</p>
<p>I have no other gcloud-related path issues and for the life of me can't figure out how to install/add docker-credential-gcloud to path. Here's what I have installed (shown via <code>gcloud version</code>):</p>
<pre><code>Google Cloud SDK 197.0.0
beta 2017.09.15
bq 2.0.31
container-builder-local
core 2018.04.06
docker-credential-gcr
gsutil 4.30
</code></pre>
<p>I also have Docker CE Version 18.03.0-ce-mac60 (23751).</p>
<p>Here's my $PATH:<code>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</code></p>
<p>I also ran <code>source /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc</code> on original gcloud install.</p>
| 0debug
|
Can switch statements in c# only take integer values? : <p>So, I am a beginner programmer in C#. I was trying to learn to use switch statements in C#. Having coming from python, I had no idea what they were. Anyway, my problem is that when I try to use a switch statement, they say that they cannot convert the string to an int. I don't understand why this is. Can C# only handle switch statements where the case values are ints?</p>
<p>Would be great if someone can provide some insight. </p>
<p>Error given is: cannot implicitly convert string to int</p>
| 0debug
|
I have two tables i wanto retrive the different results from same column in SQL : I have listed the actual table.from that i want the result as expected one.[enter image description here][1]
[1]: https://i.stack.imgur.com/p53W1.jpg
| 0debug
|
void pc_guest_info_init(PCMachineState *pcms)
{
int i, j;
pcms->apic_xrupt_override = kvm_allows_irq0_override();
pcms->numa_nodes = nb_numa_nodes;
pcms->node_mem = g_malloc0(pcms->numa_nodes *
sizeof *pcms->node_mem);
for (i = 0; i < nb_numa_nodes; i++) {
pcms->node_mem[i] = numa_info[i].node_mem;
}
pcms->node_cpu = g_malloc0(pcms->apic_id_limit *
sizeof *pcms->node_cpu);
for (i = 0; i < max_cpus; i++) {
unsigned int apic_id = x86_cpu_apic_id_from_index(i);
assert(apic_id < pcms->apic_id_limit);
for (j = 0; j < nb_numa_nodes; j++) {
if (test_bit(i, numa_info[j].node_cpu)) {
pcms->node_cpu[apic_id] = j;
break;
}
}
}
pcms->machine_done.notify = pc_machine_done;
qemu_add_machine_init_done_notifier(&pcms->machine_done);
}
| 1threat
|
static void dump_json_image_info(ImageInfo *info)
{
QString *str;
QObject *obj;
Visitor *v = qmp_output_visitor_new(&obj);
visit_type_ImageInfo(v, NULL, &info, &error_abort);
visit_complete(v, &obj);
str = qobject_to_json_pretty(obj);
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_decref(obj);
visit_free(v);
QDECREF(str);
}
| 1threat
|
static void tci_out_label(TCGContext *s, TCGLabel *label)
{
if (label->has_value) {
tcg_out_i(s, label->u.value);
assert(label->u.value);
} else {
tcg_out_reloc(s, s->code_ptr, sizeof(tcg_target_ulong), label, 0);
s->code_ptr += sizeof(tcg_target_ulong);
}
}
| 1threat
|
qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
QEMUIOVector hd_qiov;
struct iovec iov;
z_stream strm;
int ret, out_len;
uint8_t *buf, *out_buf;
uint64_t cluster_offset;
buf = qemu_blockalign(bs, s->cluster_size);
if (bytes != s->cluster_size) {
if (bytes > s->cluster_size ||
offset + bytes != bs->total_sectors << BDRV_SECTOR_BITS)
{
qemu_vfree(buf);
return -EINVAL;
}
memset(buf + bytes, 0, s->cluster_size - bytes);
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
out_buf = g_malloc(s->cluster_size);
memset(&strm, 0, sizeof(strm));
ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
Z_DEFLATED, -12,
9, Z_DEFAULT_STRATEGY);
if (ret != 0) {
ret = -EINVAL;
goto fail;
}
strm.avail_in = s->cluster_size;
strm.next_in = (uint8_t *)buf;
strm.avail_out = s->cluster_size;
strm.next_out = out_buf;
ret = deflate(&strm, Z_FINISH);
if (ret != Z_STREAM_END && ret != Z_OK) {
deflateEnd(&strm);
ret = -EINVAL;
goto fail;
}
out_len = strm.next_out - out_buf;
deflateEnd(&strm);
if (ret != Z_STREAM_END || out_len >= s->cluster_size) {
ret = qcow_co_writev(bs, offset >> BDRV_SECTOR_BITS,
bytes >> BDRV_SECTOR_BITS, qiov);
if (ret < 0) {
goto fail;
}
goto success;
}
qemu_co_mutex_lock(&s->lock);
cluster_offset = get_cluster_offset(bs, offset, 2, out_len, 0, 0);
qemu_co_mutex_unlock(&s->lock);
if (cluster_offset == 0) {
ret = -EIO;
goto fail;
}
cluster_offset &= s->cluster_offset_mask;
iov = (struct iovec) {
.iov_base = out_buf,
.iov_len = out_len,
};
qemu_iovec_init_external(&hd_qiov, &iov, 1);
ret = bdrv_co_pwritev(bs->file, cluster_offset, out_len, &hd_qiov, 0);
if (ret < 0) {
goto fail;
}
success:
ret = 0;
fail:
qemu_vfree(buf);
g_free(out_buf);
return ret;
}
| 1threat
|
Sending and Receiving Emoticons in Smack : How can I send and receive emoticons over android application using `smack` library and `OpenFire` sever in Chat Application ?
| 0debug
|
Running JavaFX application with JDK 11+ : <p>If I understand Oracle's announcments JavaFX won't be included to the JDK beginning with JDK 11 and will be only available as OpenJFX.</p>
<p>What steps do I have to make as an software developer to allow my JavaFX application to be run with JDK 11+? Is there any good adivce? Will be OpenJDK available via Gradle?</p>
| 0debug
|
Save as UTF 8 IN My eclipse Screen Other Wise The Programe is Not Run Whay This is happened : Sometime i will See a Pop Appear in Eclipse and not run my code . i wanted to know i fixed this error.[how i get rid of this error ][1]
[1]: https://i.stack.imgur.com/JWetZ.png
| 0debug
|
static int read_bfraction(VC1Context *v, GetBitContext* gb) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
return 0;
}
| 1threat
|
def max_subarray_product(arr):
n = len(arr)
max_ending_here = 1
min_ending_here = 1
max_so_far = 0
flag = 0
for i in range(0, n):
if arr[i] > 0:
max_ending_here = max_ending_here * arr[i]
min_ending_here = min (min_ending_here * arr[i], 1)
flag = 1
elif arr[i] == 0:
max_ending_here = 1
min_ending_here = 1
else:
temp = max_ending_here
max_ending_here = max (min_ending_here * arr[i], 1)
min_ending_here = temp * arr[i]
if (max_so_far < max_ending_here):
max_so_far = max_ending_here
if flag == 0 and max_so_far == 0:
return 0
return max_so_far
| 0debug
|
No executables found matching command 'dotnet-aspnet-codegenerator'" : <p>When trying to add a Controller in an ASP.NET Core project using Visual Studio 15 Enterprise with Update 3, I get the error below: </p>
<p><code>"The was an error running the selected code generator: No executables found matching command 'dotnet-aspnet-codegenerator'"</code></p>
| 0debug
|
Listview duplicate action in android : I have list. a row is content image and text and icon, The icon use to make the row is important. when i click on icon the color of icon is change. All is work probably but when i click on one icon more than one of icon is affect.
I see more post here put not fix the problem, I use view holder class also not fix, can Any body help me
this class to save elements
public class ItemsList{
private String imgUrl , comName ;
private int isStr ;
public ItemsList(){
}
public ItemsList(String imgUrl,String comName,int isStr) {
this.imgUrl = imgUrl;
this.comName = comName;
this.isStr = isStr;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getComName() {
return comName;
}
public void setComName(String comName) {
this.comName = comName;
}
public int getIsStr() {
return isStr;
}
public void setIsStr(int isStr) {
this.isStr = isStr;
}
}
this is my view holder class
public class ViewHolder {
public NetworkImageView imgInv;
public TextView comName;
public ImageView isStr;
}
and this is my adapter
public class ListAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
private List<ItemsList> itemsList;
ImageLoader imageLoader = AppController.getmInstance().getmImageLoader();
public ListAdapter(Activity activity, List<ItemsList> itemsList) {
this.activity = activity;
this.itemsList= itemsList;
}
@Override
public int getCount() {
return itemsList.size();
}
@Override
public Object getItem(int position) {
return itemsList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View view, ViewGroup viewGroup) {
if(inflater == null){
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
final ViewHolder viHold ;
final ItemsList it;
if(view == null){
view = inflater.inflate(R.layout.tst_list_row,null);
viHold = new ViewHolder();
viHold.comName = view.findViewById(R.id.com_name);
viHold.imgInv = view.findViewById(R.id.tst_img);
viHold.isStr = view.findViewById(R.id.img_str);
view.setTag(viHold);
}else{
viHold = (ViewHolderInv) view.getTag();
}
if(imageLoader == null){
imageLoader = AppControllerProf.getmInstance().getmImageLoader();
}
it = itemsList.get(position);
viHold.comName.setText(it.getComName());
viHold.imgInv.setImageUrl(Constant.URL_INV_IMG+it.getImgUrl(),imageLoader);
// is Stars
if (it.getIsStr() == 1) {
viHold.isStr.setImageResource(R.drawable.ic_star);
} else {
viHold.isStr.setImageResource(R.drawable.ic_star_border);
}
viHold.isStr.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (it.getIsStr() == 1) {
viHold.isStr.setImageDrawable(null);
viHold.isStr.setImageResource(R.drawable.ic_star_border);
it.setIsStr(0);
} else {
viHold.isStr.setImageDrawable(null);
viHold.isStr.setBackgroundResource(R.drawable.ic_star);
it.setIsStr(1);
}
}
});
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
return view;
}
}
| 0debug
|
java main method wont compile because it cannot find a symbol to create an object : <p>im relatively new to java since im attending my first year at university.
currently we are doing OOP in class and i have the following problem:</p>
<p>i am creating a "Train", but when i try to compile it , it gives the following error:
<a href="https://i.gyazo.com/2d4f3ccc68f45419a9439ab9adb1a499.png[1]" rel="nofollow noreferrer">https://i.gyazo.com/2d4f3ccc68f45419a9439ab9adb1a499.png[1]</a></p>
<p>which is really confusing to me because i have tried to run the main method in eclipse's console and it ran just fine.</p>
<p>my waggon class:</p>
<pre><code> package sheet08;
//a)
public class Waggon {
private int SitzGesamt, SitzReserviert, SitzFrei ;
private int Klasse;
private String Doppelwagen;
private int WCbesetzt, WCfrei , WCdefekt;
private String WaggonHinten;
//b)
//Getter & Setter
public int getSitzGesamt() {
return SitzGesamt;
}
public void setSitzGesamt(int sitzGesamt) {
SitzGesamt = sitzGesamt;
}
public int getSitzReserviert() {
return SitzReserviert;
}
public void setSitzReserviert(int sitzReserviert) {
SitzReserviert = sitzReserviert;
}
public int getSitzFrei() {
return SitzFrei;
}
public void setSitzFrei(int sitzFrei) {
SitzFrei = sitzFrei;
}
public int getKlasse() {
return Klasse;
}
public void setKlasse(int klasse) {
Klasse = klasse;
}
public String getDoppelwagen() {
return Doppelwagen;
}
public void setDoppelwagen(String doppelwagen) {
Doppelwagen = doppelwagen;
}
public int getWCbesetzt() {
return WCbesetzt;
}
public void setWCbesetzt(int wCbesetzt) {
WCbesetzt = wCbesetzt;
}
public int getWCfrei() {
return WCfrei;
}
public void setWCfrei(int wCfrei) {
WCfrei = wCfrei;
}
public int getWCdefekt() {
return WCdefekt;
}
public void setWCdefekt(int wCdefekt) {
WCdefekt = wCdefekt;
}
public String getWaggonHinten() {
return WaggonHinten;
}
public void setWaggonHinten(String waggonHinten) {
WaggonHinten = waggonHinten;
}
//default Constructor
public Waggon() {
}
//Constructor
public Waggon(int sitzGesamt, int sitzReserviert, int sitzFrei, int klasse, String doppelwagen, int wCbesetzt,
int wCfrei, int wCdefekt, String waggonHinten) {
super();
SitzGesamt = sitzGesamt;
SitzReserviert = sitzReserviert;
SitzFrei = sitzFrei;
Klasse = klasse;
Doppelwagen = doppelwagen;
WCbesetzt = wCbesetzt;
WCfrei = wCfrei;
WCdefekt = wCdefekt;
WaggonHinten = waggonHinten;
}
// e)
public String toString(){
String strSitzGesamt = String.valueOf(SitzGesamt);
String strSitzReserviert = String.valueOf(SitzReserviert);
String strSitzFrei = String.valueOf(SitzFrei);
String strKlasse = String.valueOf(Klasse);
String strWCbesetzt = String.valueOf(WCbesetzt);
String strWCfrei = String.valueOf(WCfrei);
String strWCdefekt = String.valueOf(WCdefekt);
return strSitzGesamt + "-" + strSitzReserviert + "-" + strSitzFrei + "-" + strKlasse + "-" + Doppelwagen + "-" + strWCbesetzt + "-" +
strWCfrei + "-" + strWCdefekt + WaggonHinten;
}
}
</code></pre>
<p>my "Train" class:</p>
<pre><code> package sheet08;
public class Train {
int Baureihe;
String Antriebsart;
int PS;
int Höchstgeschwindigkeit;
int WaggonDahinter;
//Getter&Setter
public int getBaureihe() {
return Baureihe;
}
public void setBaureihe(int baureihe) {
Baureihe = baureihe; //this.baurihe = baureihe
}
public String getAntriebsart() {
return Antriebsart;
}
public void setAntriebsart(String antriebsart) {
Antriebsart = antriebsart;
}
public int getPS() {
return PS;
}
public void setPS(int pS) {
PS = pS;
}
public int getHöchstgeschwindigkeit() {
return Höchstgeschwindigkeit;
}
public void setHöchstgeschwindigkeit(int höchstgeschwindigkeit) {
Höchstgeschwindigkeit = höchstgeschwindigkeit;
}
public int getWaggonDahinter() {
return WaggonDahinter;
}
public void setWaggonDahinter(int waggonDahinter) {
WaggonDahinter = waggonDahinter;
}
//default Constructor
public Train() {
}
//Constructor
public Train(int baureihe, String antriebsart, int pS, int höchstgeschwindigkeit, int waggonDahinter) {
super();
Baureihe = baureihe;
Antriebsart = antriebsart;
PS = pS;
Höchstgeschwindigkeit = höchstgeschwindigkeit;
}
//e)
public String toString(){
String strBaureihe = String.valueOf(Baureihe);
String strPS = String.valueOf(PS);
String strHöchstgeschwindigkeit = String.valueOf(Höchstgeschwindigkeit);
return strBaureihe + "-" + Antriebsart + "-" + strPS + "-" + strHöchstgeschwindigkeit;
}
}
</code></pre>
<p>and the main method itself :</p>
<pre><code>package sheet08;
import java.util.Random;
public class Test {
public static void main( String[] args ) {
Random WCkaputt = new Random();
int WCdefekt = WCkaputt.nextInt(100)+1;
System.out.println("Die Toilette ist zu " + WCdefekt + " % kaputt");
Train t1 = new Train (412, "elektrisch", 13500, 250, 1);
Waggon w1 = new Waggon(50, 24, 3, 1, "doppelstock", 0, 0, 0, "1 Waggon dahinter"); //keine Angabe über die WC-Anzahl
Waggon w2 = new Waggon(100, 12, 64, 2, "doppelstock", 0, 0, 0, "1 Waggon dahinter");
Waggon w3 = new Waggon(100, 32, 11, 2, "doppelstock", 0, 0, 0, "1 Waggon dahinter");
Waggon w4 = new Waggon(50, 17, 3, 1, "doppelstock", 0, 0, 0, " kein Waggon dahinter");
System.out.println(t1);
System.out.println(w1);
System.out.println(w2);
System.out.println(w3);
System.out.println(w4);
//cannot find symbol Train & Waggon
//Variable als Train1 im typ train abspeichern
}
}
</code></pre>
<p>i compiled both the waggon and train class, got no errors there and i simply cant figure out why my main method doesnt find the symbol.
id appreciate any tips as im stuck at this error since yesterday!</p>
| 0debug
|
I want to store an array of objects : I want to store an array of objects
items=[
{"122":{
name:"abc",
"price":"12"
},
{"1225656":{
name:"bc",
"price":"35"
}
}
]
| 0debug
|
Remove Webpack bootstrap from output file : <p>Well, I know Webpack allow us to import packages with <code>require</code> and that's the infrastructure from Webpack. </p>
<p>But, isn't it useless when you don't use <code>require</code> in the entry file?</p>
<p>I have this <code>test.js</code> entry:</p>
<pre><code>console.log('Test');
</code></pre>
<p>and the output</p>
<pre><code>/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */,
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(2);
/***/ }),
/* 2 */
/***/ (function(module, exports) {
console.log('Test');
/***/ })
/******/ ]);
</code></pre>
<p>This is useless code that also prevents me from using global variables!</p>
<p>At least to me, it is! and that's why I would like to know if there are any plugin or workaround to remove it?</p>
| 0debug
|
static bool check_irqchip_in_kernel(void)
{
if (kvm_irqchip_in_kernel()) {
return true;
}
error_report("pci-assign: error: requires KVM with in-kernel irqchip "
"enabled");
return false;
}
| 1threat
|
Using visitor pattern instead of casting : <p>I make regular use of the visitor pattern in my code. When a class hierarchy has a visitor implemented, I use it as an alternative to <code>instanceof</code> and casting. However it leads to some pretty awkward code which I'd like to improve.</p>
<p>Consider the contrived case:</p>
<pre><code>interface Animal {
void accept(AnimalVisitor visitor);
}
class Dog implements Animal {
void accept(AnimalVisitor visitor) {
visitor.visit(this);
}
}
class Cat implements Animal {
void accept(AnimalVisitor visitor) {
visitor.visit(this);
}
}
interface AnimalVisitor {
default void visit(Cat cat) {};
default void visit(Dog dog) {};
}
</code></pre>
<p>In the majority of cases, to do something specific to dogs only (for example) I implement a visitor that implements the logic in its <code>visit</code> method - just as the pattern intends.</p>
<p>There are case, however, in which I want to return an optional dog from the visitor to use outside.</p>
<p>In these case I end up with some pretty ugly code:</p>
<pre><code>List<Dog> dogs = new ArrayList<>();
animal.accept(new AnimalVisitor() {
void visit(Dog dog) {
dogs.add(dog);
}
}
Optional<Dog> possibleDog = dogs.stream().findAny();
</code></pre>
<p>I can't assign <code>possibleDog</code> directly inside the visitor because it's not a final variable, hence the list. </p>
<p>This is pretty ugly and inefficient just to get around requirement for effective finality. I'd be interested in ideas of alternatives. </p>
<p>Alternatives I've considered:</p>
<p>Turning the visitor into a generic which can be given a return value</p>
<pre><code>interface Animal {
<T> T accept(AnimalVisitor<T> visitor);
}
interface AnimalVisitor <T> {
default Optional<T> visit(Dog dog) { return Optional.empty(); }
default Optional<T> visit(Cat cat) { return Optional.empty(); }
}
</code></pre>
<p>Creating an abstract visitor that contains most of the code and can be trivial extended to set the optional directly</p>
<pre><code>abstract class AnimalCollector implements AnimalVisitor <T> {
private Optional<T> result = Optional.empty;
protected void setResult(T value) {
assert !result.isPresent();
result = Optional.of(value);
}
public Optional<T> asOptional() {
return result;
}
}
</code></pre>
<p>Use a stream builder instead of a list</p>
<pre><code>Stream.Builder<Dog> dogs = Stream.builder();
animal.accept(new AnimalVisitor() {
void visit(Dog dog) {
dogs.accept(dog);
}
}
Optional<Dog> possibleDog = dogs.build().findAny();
</code></pre>
<p>But I don't find these particularly elegant. They involve a lot of boilerplate just to implement basic <code>asA</code> logic. I tend to use the second solution in my code to keep the usage clean. Is there a simpler solution I'm missing?</p>
<p>Just to be clear, I'm not that interested in answers with some variant of "use instanceof and casts". I realise it would work in this trivial case but the situations I'm considering have quite complex use of visitors that include visiting composites and delegates which make casting impractical. </p>
| 0debug
|
How to display date in Month and year format in R : I have a date variable which has date in "Fri Nov 27 20:17:01 IST 2015" format. I need to display it as NOv 2015. How can i do that in R? Please help
| 0debug
|
Kotlin complier error: expecting member declaration : I'm new to android studio and java. Trying to write a log in, can someone help me understand what's going on with the code? Thank you very much
[enter image description here][1]
[enter image description here][2]
[1]: https://i.stack.imgur.com/ZP9Lm.png
[2]: https://i.stack.imgur.com/xG46i.png
| 0debug
|
int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
{
int list, index, pic_structure;
print_short_term(h);
print_long_term(h);
h264_initialise_ref_list(h, sl);
for (list = 0; list < sl->list_count; list++) {
int pred = sl->curr_pic_num;
for (index = 0; index < sl->nb_ref_modifications[list]; index++) {
unsigned int modification_of_pic_nums_idc = sl->ref_modifications[list][index].op;
unsigned int val = sl->ref_modifications[list][index].val;
unsigned int pic_id;
int i;
H264Picture *ref = NULL;
switch (modification_of_pic_nums_idc) {
case 0:
case 1: {
const unsigned int abs_diff_pic_num = val + 1;
int frame_num;
if (abs_diff_pic_num > sl->max_pic_num) {
av_log(h->avctx, AV_LOG_ERROR,
"abs_diff_pic_num overflow\n");
return AVERROR_INVALIDDATA;
}
if (modification_of_pic_nums_idc == 0)
pred -= abs_diff_pic_num;
else
pred += abs_diff_pic_num;
pred &= sl->max_pic_num - 1;
frame_num = pic_num_extract(h, pred, &pic_structure);
for (i = h->short_ref_count - 1; i >= 0; i--) {
ref = h->short_ref[i];
assert(ref->reference);
assert(!ref->long_ref);
if (ref->frame_num == frame_num &&
(ref->reference & pic_structure))
break;
}
if (i >= 0)
ref->pic_id = pred;
break;
}
case 2: {
int long_idx;
pic_id = val;
long_idx = pic_num_extract(h, pic_id, &pic_structure);
if (long_idx > 31U) {
av_log(h->avctx, AV_LOG_ERROR,
"long_term_pic_idx overflow\n");
return AVERROR_INVALIDDATA;
}
ref = h->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & pic_structure)) {
ref->pic_id = pic_id;
assert(ref->long_ref);
i = 0;
} else {
i = -1;
}
break;
}
default:
av_assert1(0);
}
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"reference picture missing during reorder\n");
memset(&sl->ref_list[list][index], 0, sizeof(sl->ref_list[0][0]));
} else {
for (i = index; i + 1 < sl->ref_count[list]; i++) {
if (sl->ref_list[list][i].parent &&
ref->long_ref == sl->ref_list[list][i].parent->long_ref &&
ref->pic_id == sl->ref_list[list][i].pic_id)
break;
}
for (; i > index; i--) {
sl->ref_list[list][i] = sl->ref_list[list][i - 1];
}
ref_from_h264pic(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) {
pic_as_field(&sl->ref_list[list][index], pic_structure);
}
}
}
}
for (list = 0; list < sl->list_count; list++) {
for (index = 0; index < sl->ref_count[list]; index++) {
if ( !sl->ref_list[list][index].parent
|| (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) {
int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref[list].poc);
for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
if (h->default_ref[list].parent
&& !(!FIELD_PICTURE(h) && (h->default_ref[list].reference&3) != 3))
sl->ref_list[list][index] = h->default_ref[list];
else
return -1;
}
av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f->buf[0]) > 0);
}
}
if (FRAME_MBAFF(h))
h264_fill_mbaff_ref_list(sl);
return 0;
}
| 1threat
|
Why does `std::make_shared` perform two separate allocations with `-fno-rtti`? : <pre><code>#include <memory>
struct foo { };
int main() { std::make_shared<foo>(); }
</code></pre>
<p>The asssembly generated by both <code>g++7</code> and <code>clang++5</code> with <code>-fno-exceptions -Ofast</code> for the code above:</p>
<ul>
<li><p>Contains a single call to <code>operator new</code> if <code>-fno-rtti</code> is <strong>not</strong> passed.</p></li>
<li><p>Contains <strong>two separate calls</strong> to <code>operator new</code> if <code>-fno-rtti</code> is <strong>passed</strong>.</p></li>
</ul>
<p>This can be easily verified <a href="https://godbolt.org/g/z52YT0" rel="noreferrer">on <strong>gcc.godbolt.org</strong></a> <em>(<a href="https://godbolt.org/g/wikZOd" rel="noreferrer"><code>clang++5</code> version</a>)</em>:</p>
<p><a href="https://i.stack.imgur.com/PXa2K.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PXa2K.png" alt="screenshot of the above godbolt link with highlighed operator new calls"></a></p>
<p>Why is this happening? Why does disabling RTTI prevent <code>make_shared</code> from unifying the <em>object</em> and <em>control block</em> allocations?</p>
| 0debug
|
vue.js, simple v-for / v-bind to add index to class name : <p>I can't seem to find the syntax to loop through my items and give each 'li' a class corresponding to the index. How is this done? </p>
<pre><code><li v-for="(item, idx) in items class="idx"">
</li>
</code></pre>
| 0debug
|
Python code that search for text and copy it to the next line : <p>I python code to read lines in a text file and to copy text between specific characters. For example, text between _ _.</p>
<pre><code>Input
./2425/1/115_Lube_45484.jpg 45484
./2425/1/114_Spencerian_73323.jpg 73323
Output
./2425/1/115_Lube_45484.jpg 45484
Lube
./2425/1/114_Spencerian_73323.jpg 73323
Spencerian
</code></pre>
<p>Any suggestions?</p>
| 0debug
|
Spurious requests, certificate auditors? : <p>In the last few days I've seen lots of POST requests to many of the domains I own hitting the following paths:</p>
<pre><code>/ct/v1/sct-gossip
/ct/v1/sct-feedback
/.well-known/ct/v1/sct-feedback
/.well-known/ct/v1/sth-pollination
/.well-known/ct/v1/collected-sct-feedback
/.well-known/ct/v1/sct-gossip
/topleveldir/subdir/research-feedback
</code></pre>
<p>Is this someone trying to do something dubious?</p>
<p>I found the following document which suggests this might be something to do with certificate auditors although I am not sure what! All of my websites are fronted by Cloudflare which provides the SSL certs so I would really expect Cloudflare to handle any such requests.</p>
<p><a href="https://tools.ietf.org/html/draft-ietf-trans-gossip-00" rel="noreferrer">https://tools.ietf.org/html/draft-ietf-trans-gossip-00</a></p>
<p>Any thoughts would be appreciated :-)</p>
| 0debug
|
Install latest nodejs version in ubuntu 14.04 : <p>This is the way I installed <a href="https://nodejs.org/en/">nodejs</a> in ubuntu 14.04 LTS:</p>
<pre><code>sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get install nodejs
</code></pre>
<p>When I checked the node version with this:</p>
<pre><code>node -v
</code></pre>
<p>I get this</p>
<pre><code>v0.10.37
</code></pre>
<p>But the latest version is 4.2.6 and 5.5.0. How can I get the latest or update version?</p>
| 0debug
|
Where is the mistake in this code? : <p>I'm a noobie in php, so I got this code from my teacher and I can't get the answer. Can somebody explain me where is the mistake is this code?</p>
<pre><code><?php
function XXX($array, $val) {
foreach ($array as $key => $value) {
if ($value == $val) {
unset($value);
return $key;
break;
}
}
return FALSE;
}
</code></pre>
| 0debug
|
VB.Net Selenium Implicit Wait Timeout not working : Was trying to block execution for 10 seconds properly with VB.Net Selenium, so found out about Implicit Wait on SO, and found this example.
driver.Manage.Timeouts.ImplicitWait = TimeSpan.FromSeconds(10)
Debug.WriteLine(driver.PageSource)
The problem is, I set a breakpoint on both lines and Debug.WriteLine is called nearly instantly. I've read on here I shouldn't use Thread.Sleep here, so why is the timeout not having the desired effect?
Thanks!
| 0debug
|
C# - DrawBorder - Bottom and Right side not visible : <p>I want to add a different bordercolor for every side of the element,
yet it's working pretty okay, the only problem I got is that my right side and bottom side of the border isn't visible.</p>
<pre><code> public static void DrawBorder
(
Graphics graphics, Rectangle bounds,
Color leftColor, int leftWidth, ButtonBorderStyle leftStyle,
Color topColor, int topWidth, ButtonBorderStyle topStyle,
Color rightColor, int rightWidth, ButtonBorderStyle rightStyle,
Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle
){}
Color leftColor = Color.FromArgb(65,0,0,0), rightColor = Color.FromArgb(150, 0, 0, 0), topColor = Color.FromArgb(65, 0, 0, 0), bottomColor = Color.FromArgb(150, 0, 0, 0);
int leftWidth = 3, rightWidth = 3, topWidth = 3, bottomWidth = 3;
ButtonBorderStyle leftStyle = ButtonBorderStyle.Solid, rightStyle = ButtonBorderStyle.Solid, topStyle = ButtonBorderStyle.Solid, bottomStyle = ButtonBorderStyle.Solid;
private void Paint_(object sender, PaintEventArgs e)
{
Rectangle borderRectangle = this.ClientRectangle;
borderRectangle.Inflate(0, 0);
ControlPaint.DrawBorder(e.Graphics, borderRectangle,
leftColor, leftWidth, leftStyle,
topColor, topWidth, topStyle,
rightColor, rightWidth, rightStyle,
bottomColor, bottomWidth, bottomStyle);
}
</code></pre>
<p>I'm using the "Paint_" function for every element you see here, so it's the same problem on every of these.
<a href="https://i.stack.imgur.com/X55N4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X55N4.png" alt="Missing right and bottom border"></a>
I'm pretty new to any of the "Draw" stuff, so I don't know anything which could be the problem.</p>
| 0debug
|
I cannot get the sum to calculate. I'm not even sure my logic is correct. : I believe I may need to use for instead of while, I am unsure on how fix this. When I try to research this all I can find is in relation to "sum of arrays" My sum keeps coming out to equal 10 although I have declared the values. Can someone help? Thanks
public class OnlinePurchases {
public static void main(String[] args) {
// TODO code application logic here
String sName = " ";
int nChoices = 0;
int nChoice1 = 249;
int nChoice2 = 39;
int nChoice3 = 1149;
int nChoice4 = 349;
int nChoice5 = 49;
int nChoice6 = 119;
int nChoice7 = 899;
int nChoice8 = 299;
int nChoice9 = 399;
int nSum = 0;
final int SENTINEL = 10;
int nCount = 0;
Scanner input = new Scanner(System.in) ;
System.out.print("Please enter your name : ");
sName = input.nextLine();
System.out.println("BEST PURCHASE PRODUCTS \n" );
System.out.println("1. Smartphone $249");
System.out.println("2. Smartphone case $39");
System.out.println("3. PC Laptop $1149 ");
System.out.println("4. Tablet $349");
System.out.println("5. Tablet case $49");
System.out.println("6. eReader $119");
System.out.println("7. PC Desktop $899");
System.out.println("8. LED Monitor $299" );
System.out.println("9. Laser Printer $399" );
System.out.println("10. Complete my order");
System.out.println("");
System.out.print("Please select an item from the menu above : ");
nChoices = input.nextInt();
while(nChoices != SENTINEL) {
System.out.print("Please select another item from the menu above : ");
nCount++;
nChoices = input.nextInt();
if(nChoices == 1){
nChoices = nChoice1 ;
}
else if(nChoices == 2){
nChoices = nChoice2;
}
else if(nChoices == 3){
nChoices = nChoice3;
}
else if(nChoices == 4){
nChoices = nChoice4;
}
else if(nChoices == 5){
nChoices = nChoice5 ;
}
}
nSum = nSum + nChoices;
System.out.println("Price of Items Ordered : " + nSum );
System.out.println("Total Items Ordered : " + nCount );
}
}
| 0debug
|
static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){
int i;
for(i=0; i<128; i++){
int level= i-64;
int run;
for(run=0; run<64; run++){
int len, bits, code;
int alevel= FFABS(level);
int sign= (level>>31)&1;
if (alevel > rl->max_level[0][run])
code= 111;
else
code= rl->index_run[0][run] + alevel - 1;
if (code < 111 ) {
len= rl->table_vlc[code][1]+1;
bits= (rl->table_vlc[code][0]<<1) + sign;
} else {
len= rl->table_vlc[111][1]+6;
bits= rl->table_vlc[111][0]<<6;
bits|= run;
if (alevel < 128) {
bits<<=8; len+=8;
bits|= level & 0xff;
} else {
bits<<=16; len+=16;
bits|= level & 0xff;
if (level < 0) {
bits|= 0x8001 + level + 255;
} else {
bits|= level & 0xffff;
}
}
}
uni_ac_vlc_len [UNI_AC_ENC_INDEX(run, i)]= len;
}
}
}
| 1threat
|
How do you declare a object that can be accessed through multiple header files? : <p>I'm working on a project and I am cleaning my code and Re-doing the code so it's more readable and easy to tweak. I'm having one issue though when I create an object in a header file the complier throws me an error saying its already defined; int assumed. LNK-2005. </p>
<p>I tried creating the objects as 'extern' so I could access the objects from all files that include the file with the specified objects.</p>
<pre><code>// HeaderA.h
#include <Windows.h>
struct ProcessInfo
{
int ProcID;
HANDLE Handle;
};
</code></pre>
<p>This is header B below</p>
<pre><code>// Header B starts here
// HeaderB.h
#include "HeaderA.h"
{
ProcessInfo pi;
pi.ProcID = 10;
struct Player
{
int health = 0;
float x, y, z;
int score = 0;
}
}
</code></pre>
<p>Header C
This file should be able to use Header B's object 'pi'</p>
<pre><code>//HeaderC.h
#include "HeaderB.h"
// creating object from headerB
Player player;
// is there a way so I can use the object declared in HeaderB in HeaderC?
// like so
pi.ProcID = 45;
</code></pre>
<p>I expected to be able to use the object created in header B through multiple files like HeaderB-HeaderZ. (A-Z; Multiple Headers) But when compiling I get the error "LNK2005 already defined".</p>
| 0debug
|
I want to incude a certain div from another url into my site : i have this
<div>
<object type="text/html" data="https://www.urlIWantTheDivFrom.com"
width="800px" height="600px" >
</object>
</div>
However this gives me the whole webpage. I want to copy a certain div. I also tried some js however i cannot find out how to copy the exact div as well
document.getElementById("div").innerHTML='<object type="text/html" data="https://www.urlIWantTheDivFrom.com" ></object>';
| 0debug
|
Docker: Using --password via the CLI is insecure. Use --password-stdin : <p>I have this error when I login during a CI process: </p>
<pre><code>WARNING! Using --password via the CLI is insecure. Use --password-stdin.
</code></pre>
<p>Should I just replace "--password" with "--password-stdin'?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.