problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to change Material UI input underline colour? : <p>I have a Material UI <code>Select</code> component that is on a dark background, so for just this one component I'd like to change it so that the text and line colours are all white. The rest of the <code>Select</code> instances should remain unchanged.</p>
<p>While I can get the text and icon to change colour, I can't seem to figure out how to use the <code>classes</code> prop to set the underline colour. My attempts also seem to make the open icon wrap to the next line too. Here's an example demonstrating the problem:</p>
<p><a href="https://codesandbox.io/s/m535jo44k9" rel="noreferrer"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit Material demo"></a></p>
<p>I've set my style like this:</p>
<pre><code>const styles = theme => ({
underline: {
borderBottom: '2px solid white',
'&:after': {
// The MUI source seems to use this but it doesn't work
borderBottom: '2px solid white',
},
}
};
</code></pre>
<p>Then I'm setting it like this:</p>
<pre><code><Select
classes={{
underline: classes.underline, // Does it go here?
}}
inputProps={{
classes: {
underline: classes.underline, // Or does it go here?
},
}}
>
</code></pre>
<p>This method does work for the text (not shown above, but in the linked example), it's just the underline colour that I can't get to change. What am I missing?</p>
| 0debug
|
static void vnc_resize(VncState *vs)
{
DisplayState *ds = vs->ds;
int size_changed;
vs->old_data = qemu_realloc(vs->old_data, ds_get_linesize(ds) * ds_get_height(ds));
if (vs->old_data == NULL) {
fprintf(stderr, "vnc: memory allocation failed\n");
exit(1);
}
if (ds_get_bytes_per_pixel(ds) != vs->serverds.pf.bytes_per_pixel)
console_color_init(ds);
vnc_colordepth(vs);
size_changed = ds_get_width(ds) != vs->serverds.width ||
ds_get_height(ds) != vs->serverds.height;
vs->serverds = *(ds->surface);
if (size_changed) {
if (vs->csock != -1 && vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
vnc_write_u8(vs, 0);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1);
vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds),
VNC_ENCODING_DESKTOPRESIZE);
vnc_flush(vs);
}
}
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
memset(vs->old_data, 42, ds_get_linesize(vs->ds) * ds_get_height(vs->ds));
}
| 1threat
|
Conditional Access expression cannot be assigned - C# null-propagation += events : <p>One of my favorite C# features added is the "<a href="https://msdn.microsoft.com/en-us/magazine/dn802602.aspx" rel="noreferrer">null-propagation</a>" in CS6.</p>
<p>This has cleaned up so much code for many of us.</p>
<p>I came across a situation where this doesn't appear to be possible. I am not sure why as I though the null-propagation was just some compiler magic that does some null checks for us, allowing us to maintain cleaner code.</p>
<p>In the case of hooking into events..</p>
<pre><code> public override void OnApplyTemplate()
{
_eventStatus = base.GetTemplateChild(PART_EventStatus) as ContentControl;
// This not permitted and will not compile
_eventStatus?.IsMouseDirectlyOverChanged += EventStatusOnIsMouseDirectlyOverChanged;
// but this will work
if(_eventStatus != null) _eventStatus.IsMouseDirectlyOverChanged += EventStatusOnIsMouseDirectlyOverChanged;
base.OnApplyTemplate();
}
private void EventStatusOnIsMouseDirectlyOverChanged(object sender, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
throw new NotImplementedException();
}
</code></pre>
<p>Compile output shows:</p>
<pre><code> error CS0079: The event 'UIElement.IsMouseDirectlyOverChanged' can only appear on the left hand side of += or -=
</code></pre>
<p><a href="https://i.stack.imgur.com/iPdzZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iPdzZ.png" alt="Resharper Complaint"></a></p>
<p>So, my question is - what and I misunderstanding about null-propagation? Why is this not a permitted syntax? </p>
| 0debug
|
static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
{
const char *p;
int ch, reg_size, type;
char buf[4096];
uint8_t mem_buf[4096];
uint32_t *registers;
target_ulong addr, len;
#ifdef DEBUG_GDB
printf("command='%s'\n", line_buf);
#endif
p = line_buf;
ch = *p++;
switch(ch) {
case '?':
snprintf(buf, sizeof(buf), "S%02x", SIGTRAP);
put_packet(s, buf);
case 'c':
if (*p != '\0') {
addr = strtoull(p, (char **)&p, 16);
#if defined(TARGET_I386)
env->eip = addr;
#elif defined (TARGET_PPC)
env->nip = addr;
#elif defined (TARGET_SPARC)
env->pc = addr;
env->npc = addr + 4;
#elif defined (TARGET_ARM)
env->regs[15] = addr;
#elif defined (TARGET_SH4)
env->pc = addr;
#elif defined (TARGET_MIPS)
env->PC[env->current_tc] = addr;
#elif defined (TARGET_CRIS)
env->pc = addr;
#endif
}
return RS_IDLE;
case 's':
if (*p != '\0') {
addr = strtoull(p, (char **)&p, 16);
#if defined(TARGET_I386)
env->eip = addr;
#elif defined (TARGET_PPC)
env->nip = addr;
#elif defined (TARGET_SPARC)
env->pc = addr;
env->npc = addr + 4;
#elif defined (TARGET_ARM)
env->regs[15] = addr;
#elif defined (TARGET_SH4)
env->pc = addr;
#elif defined (TARGET_MIPS)
env->PC[env->current_tc] = addr;
#elif defined (TARGET_CRIS)
env->pc = addr;
#endif
}
cpu_single_step(env, sstep_flags);
return RS_IDLE;
case 'F':
{
target_ulong ret;
target_ulong err;
ret = strtoull(p, (char **)&p, 16);
if (*p == ',') {
p++;
err = strtoull(p, (char **)&p, 16);
} else {
err = 0;
}
if (*p == ',')
p++;
type = *p;
if (gdb_current_syscall_cb)
gdb_current_syscall_cb(s->env, ret, err);
if (type == 'C') {
put_packet(s, "T02");
} else {
}
}
case 'g':
reg_size = cpu_gdb_read_registers(env, mem_buf);
memtohex(buf, mem_buf, reg_size);
put_packet(s, buf);
case 'G':
registers = (void *)mem_buf;
len = strlen(p) / 2;
hextomem((uint8_t *)registers, p, len);
cpu_gdb_write_registers(env, mem_buf, len);
case 'm':
addr = strtoull(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoull(p, NULL, 16);
if (cpu_memory_rw_debug(env, addr, mem_buf, len, 0) != 0) {
put_packet (s, "E14");
} else {
memtohex(buf, mem_buf, len);
put_packet(s, buf);
}
case 'M':
addr = strtoull(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoull(p, (char **)&p, 16);
if (*p == ':')
p++;
hextomem(mem_buf, p, len);
if (cpu_memory_rw_debug(env, addr, mem_buf, len, 1) != 0)
put_packet(s, "E14");
else
case 'Z':
type = strtoul(p, (char **)&p, 16);
if (*p == ',')
p++;
addr = strtoull(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoull(p, (char **)&p, 16);
if (type == 0 || type == 1) {
if (cpu_breakpoint_insert(env, addr) < 0)
goto breakpoint_error;
#ifndef CONFIG_USER_ONLY
} else if (type == 2) {
if (cpu_watchpoint_insert(env, addr) < 0)
goto breakpoint_error;
#endif
} else {
breakpoint_error:
put_packet(s, "E22");
}
case 'z':
type = strtoul(p, (char **)&p, 16);
if (*p == ',')
p++;
addr = strtoull(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoull(p, (char **)&p, 16);
if (type == 0 || type == 1) {
cpu_breakpoint_remove(env, addr);
#ifndef CONFIG_USER_ONLY
} else if (type == 2) {
cpu_watchpoint_remove(env, addr);
#endif
} else {
goto breakpoint_error;
}
case 'q':
case 'Q':
if (!strcmp(p,"qemu.sstepbits")) {
sprintf(buf,"ENABLE=%x,NOIRQ=%x,NOTIMER=%x",
SSTEP_ENABLE,
SSTEP_NOIRQ,
SSTEP_NOTIMER);
put_packet(s, buf);
} else if (strncmp(p,"qemu.sstep",10) == 0) {
p += 10;
if (*p != '=') {
sprintf(buf,"0x%x", sstep_flags);
put_packet(s, buf);
}
p++;
type = strtoul(p, (char **)&p, 16);
sstep_flags = type;
}
#ifdef CONFIG_LINUX_USER
else if (strncmp(p, "Offsets", 7) == 0) {
TaskState *ts = env->opaque;
sprintf(buf,
"Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx
";Bss=" TARGET_ABI_FMT_lx,
ts->info->code_offset,
ts->info->data_offset,
ts->info->data_offset);
put_packet(s, buf);
}
#endif
default:
buf[0] = '\0';
put_packet(s, buf);
}
return RS_IDLE;
}
| 1threat
|
how i make mean and mod function in php and fill the null places : **bellow is my arrry** i want to find **mean and mod**
if the value is numeric then mean function run and found mean and put the result in nul space
and as well as if the value is string type then find the mod(most repeated value) and put this value in null space...
please tell how i do that in php
**how i make two function for find mean and mod and how i judge the value are numeric and string then apply function and fill the blank spaces**
Array
[1] => Array
(
[1] => 4
[2] => 2
[3] => 3
[4] =>
)
[2] => Array
(
[1] => one
[2] => two
[3] => two
[4] =>
)
[3] => Array
(
[1] => 8
[2] =>
[3] => 8
[4] => 5
)
}
please help me
| 0debug
|
Why does reading a file take so much time? : I'm working on a project which requires sensor data from a temperature sensor. While accessing the file using open() and then read(), we found that it took too long. We have isolated problem to read() taking the most time (approximately 1 second). Is there a faster alternative to read() or am I using it incorrectly? Code:
```
import time, os, socket
#External thermometer address: 28-031897792ede
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
temp_sensor = '/sys/bus/w1/devices/28-031897792ede/w1_slave'
def temp_raw():
f = open(temp_sensor, 'r')
lines = f.read()
f.close()
return lines
def read_temp():
lines = temp_raw()
while lines[0].strip()[-3:] != 'YES':
lines = temp_raw()
temp_output = lines[1].find('t=')
if temp_output != -1:
temp_string = lines [1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
return round(temp_c, 1)
while True:
temp_raw()
```
| 0debug
|
static inline int valid_flags(int flag)
{
if (flag & O_NOCTTY || flag & O_NONBLOCK || flag & O_ASYNC ||
flag & O_CLOEXEC)
return 0;
else
return 1;
}
| 1threat
|
static void armv7m_nvic_init(SysBusDevice *dev)
{
nvic_state *s= FROM_SYSBUSGIC(nvic_state, dev);
CPUState *env;
env = qdev_get_prop_ptr(&dev->qdev, "cpu");
gic_init(&s->gic);
cpu_register_physical_memory(0xe000e000, 0x1000, s->gic.iomemtype);
s->systick.timer = qemu_new_timer(vm_clock, systick_timer_tick, s);
if (env->v7m.nvic)
hw_error("CPU can only have one NVIC\n");
env->v7m.nvic = s;
register_savevm("armv7m_nvic", -1, 1, nvic_save, nvic_load, s);
}
| 1threat
|
i have 2 spinner values and button to send this values from acvitity to another .. need to send multi values and use them in the other activity : i have 2 spinner in [Blankfragment.java]
.. and i want to send the key of ( intent.putExtra(Category1) or intent.putExtra(Category2) )
and receive them in the same activity[aaa.java]..
by (getIntent().getStringExtra("Category1"); or getIntent().getStringExtra("Category2");) in switch case or if statment...
but i cant do this because i can't use more than one getStringExtra in aaa.java
please help me
````````this is code of [Blankfragment.java]``````
int spinner_pos = spinner.getSelectedItemPosition();
int spinner2_pos = spinner2.getSelectedItemPosition();
if (spinner_pos == 0 && spinner2_pos == 0) {
Intent intent = new Intent(getActivity(), aaa.class);
String a1 = null;
intent.putExtra("Category1", a1 );
startActivity(intent);
}
else if (spinner_pos == 0 && spinner2_pos == 1) {
Intent intent = new Intent(getActivity(), aaa.class);
String a2 = null;
intent.putExtra("Category2", a2);
startActivity(intent);
}
````````this is code of [aaa.java]``````````````
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_aaa);
.
..
...
//need to use
getIntent().getStringExtra("Category1"); .. // for if -> "01"
and
getIntent().getStringExtra("Category2"); .. // for else if -> "02"
//in this if statment
if(// write something) {
loadListWorkers("01");
}
else if (//write something) {
loadListWorkers("02");
}
}
private void loadListWorkers(String placeId) {
adapter = new FirebaseRecyclerAdapter<workers, WorkerViewHolder>
( workers.class
, R.layout.vh_worker_item
, WorkerViewHolder.class
, workerList.orderByChild("Worker_place_ID").equalTo(placeId)
)
...
.....
.......
.........
| 0debug
|
Life-cycle methods for services in angular2 : <p>Is it possible to have life-cycle hooks for a service that is annotated with <code>@Injectable()</code>?</p>
<p>I'd have expected the life-cycle hooks to be called on a service like this, but I was proven wrong, it seems to be working on <code>@Component</code> only. Is there a way to get informed in a service when dependency injection creates / destroys a service?</p>
<pre><code>import {Component, Injectable, OnInit, OnDestroy} from 'angular2/core';
@Injectable()
export class SampleService implements OnInit, OnDestroy {
ngOnInit() {
console.log("OnInit")
}
ngOnDestroy() {
console.log("OnDestroy")
}
}
@Component({
selector: "sample",
template: "<div>Sample Component</div>",
providers: [ SampleService ]
})
export class SampleComponent {
constructor() { private _sampleService: SampleService }
}
</code></pre>
| 0debug
|
PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
hwaddr base, qemu_irq irq)
{
PXA2xxLCDState *s;
DisplaySurface *surface;
s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));
s->invalidated = 1;
s->irq = irq;
s->sysmem = sysmem;
pxa2xx_lcdc_orientation(s, graphic_rotate);
memory_region_init_io(&s->iomem, NULL, &pxa2xx_lcdc_ops, s,
"pxa2xx-lcd-controller", 0x00100000);
memory_region_add_subregion(sysmem, base, &s->iomem);
s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s);
surface = qemu_console_surface(s->con);
switch (surface_bits_per_pixel(surface)) {
case 0:
s->dest_width = 0;
break;
case 8:
s->line_fn[0] = pxa2xx_draw_fn_8;
s->line_fn[1] = pxa2xx_draw_fn_8t;
s->dest_width = 1;
break;
case 15:
s->line_fn[0] = pxa2xx_draw_fn_15;
s->line_fn[1] = pxa2xx_draw_fn_15t;
s->dest_width = 2;
break;
case 16:
s->line_fn[0] = pxa2xx_draw_fn_16;
s->line_fn[1] = pxa2xx_draw_fn_16t;
s->dest_width = 2;
break;
case 24:
s->line_fn[0] = pxa2xx_draw_fn_24;
s->line_fn[1] = pxa2xx_draw_fn_24t;
s->dest_width = 3;
break;
case 32:
s->line_fn[0] = pxa2xx_draw_fn_32;
s->line_fn[1] = pxa2xx_draw_fn_32t;
s->dest_width = 4;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);
return s;
}
| 1threat
|
python Selenium can not get class : This is my html
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
div class="span5 offset1">
<h4>Original Text</h4>
<p>
looked
</p>
</div>
<div class="span5">
<h4>Analysis Result</h4>
<p>
look
</p>
</div>
<!-- end snippet -->
array = []
myText = ["looked","gone"] . ## I post this array to website
for a in range(0,len(myText)):
x=driver.find_element_by_class_name('span5')
array.append(x.text)
print b -> [u'Original Text\nlooked', u'Original Text\ngone']
How can I get only 'looked' and 'gone' part
| 0debug
|
Sending Email from JavaScript with SMTP Server : <p>I'm trying to send an Email within my JavaScript automatically if an if statement turns into an else. I have an SMTP-Server, but I really dont know how to implement that. Already tried everything I found. I dont want to use node.js, ajax or something else.</p>
| 0debug
|
Looking for assistance with a coding issue I'm having : <p>Hello I'm new to android studio and was hoping one of you guys/gals can help me with a reason why my code is making the app crash? The code is for a simple math puzzle where you have to input the right numbers to get an answer.
Code:</p>
<pre><code>import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class Puzzle extends AppCompatActivity {
//get the info
EditText input01 = ( EditText ) findViewById ( R.id.input1 );
EditText input02 = ( EditText ) findViewById ( R.id.input2 );
EditText input03 = ( EditText ) findViewById ( R.id.input3 );
EditText input04 = ( EditText ) findViewById ( R.id.input4 );
EditText input05 = ( EditText ) findViewById ( R.id.input5 );
EditText input06 = ( EditText ) findViewById ( R.id.input6 );
EditText input07 = ( EditText ) findViewById ( R.id.input7 );
EditText input08 = ( EditText ) findViewById ( R.id.input8 );
EditText input09 = ( EditText ) findViewById ( R.id.input9 );
//process data
int ans01 = Integer.valueOf ( input01.getText().toString() );
int ans02 = Integer.valueOf ( input02.getText().toString() );
int ans03 = Integer.valueOf ( input03.getText().toString() );
int ans04 = Integer.valueOf ( input04.getText().toString() );
int ans05 = Integer.valueOf ( input05.getText().toString() );
int ans06 = Integer.valueOf ( input06.getText().toString() );
int ans07 = Integer.valueOf ( input07.getText().toString() );
int ans08 = Integer.valueOf ( input08.getText().toString() );
int ans09 = Integer.valueOf ( input09.getText().toString() );
//button creater
Button check = ( Button ) findViewById(R.id.check);
Button reset = ( Button ) findViewById(R.id.Reset);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_puzzle);
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
reset.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick ( View view ) {
input01.setText ( "" );
input02.setText ( "" );
input03.setText ( "" );
input04.setText ( "" );
input05.setText ( "" );
input06.setText ( "" );
input07.setText ( "" );
input08.setText ( "" );
input09.setText ( "" );
}
}
);
// this is where the code starts crashing the app.
check.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
// I want an if statement that checks the values of the inputed numbers
if ( ans01 + ans02 + ans03 = 14) {
input01.setTextColor(Color.GREEN);
input02.setTextColor(Color.RED);
}
}enter code here
}
);
}
}
</code></pre>
<p>Any help would be appreciated. </p>
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
Rename shadow jar produced by shadow plugin to original artifact name : <p>I am using gradle shadow plugin to build my uber jar.</p>
<p>build.grade file looks like:</p>
<pre><code>buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile "com.amazonaws:aws-lambda-java-events:1.3.0"
}
assemble.dependsOn(shadowJar)
</code></pre>
<p>It produces following jars in build/libs folder.</p>
<pre><code>myProject-1.0.0-SNAPSHOT.jar
myProject-1.0.0-SNAPSHOT-all.jar '//uber jar
</code></pre>
<p>I want to replace original jar with uber jar. How do i do this?</p>
| 0debug
|
If vs if then statements : <p>What is the difference between an if and an if then statement? For example, what's the difference between:</p>
<pre><code>if (condition)
puts "Condition is true"
end
</code></pre>
<p>and:</p>
<pre><code>if (condition) then
puts "Condition is true"
end
</code></pre>
| 0debug
|
counting through an array of hashes in ruby : so today I am trying to work through some exercises in ruby, and I am a bit stuck. Ruby is extremely new to me so it is just the syntax I am feeling stuck with. Anyways onto the problem.I have this data set which is an array of hashes that looks like this
[
{"name": "John doe","job": "construction"},
{"name": "mary","job": "cook"}...]
I am supposed to loop through this large array of hashes, and count how many people there are with the same name, so if there are 5 marys, i should have 5
any help would be greatly appreciated
| 0debug
|
I have two lists, I want to know if a date in one list is between two dates in another. How should I do this? : <p>I have a list A that looks like this:</p>
<pre><code>[((5.8, datetime.datetime(2016, 3, 5, 2, 8, 47))]
</code></pre>
<p>I have another list B that looks like this:</p>
<pre><code>[((date1, datetime.datetime(2016, 2, 8, 1, 34)),
(date2, datetime.datetime(2016, 5, 2, 1, 42)),
(date3, datetime.datetime(2016, 10, 2, 11, 23))]
</code></pre>
<p>I want to know if the date in list A is between any consecutive dates in list B. In other words the output using the lists here would be:</p>
<pre><code>[(5.8, date2)]
</code></pre>
<p>This is because the date in list A is between the first and second dates of list B. So I output the important value from list A (5.8) and (date2). I would not use date1 or date3 because I want to make sure that the date from list 1 is in between two of the dates, and I use the latter date of the two dates as an output.</p>
| 0debug
|
static void gen_callwi(DisasContext *dc, int callinc, uint32_t dest, int slot)
{
TCGv_i32 tmp = tcg_const_i32(dest);
if (((dc->pc ^ dest) & TARGET_PAGE_MASK) != 0) {
slot = -1;
}
gen_callw_slot(dc, callinc, tmp, slot);
tcg_temp_free(tmp);
}
| 1threat
|
invalid syntax when trying to install pip : <p>i'm trying to install this package called 'exceptions' in command prompt for Python, yet all i get is "invalid syntax". what seems to be the issue? i tried things like </p>
<pre><code>pip18 install exceptions (i'm using version 18 of pip)
pip -m install exceptions
</code></pre>
<p><a href="https://i.stack.imgur.com/OB4gN.png" rel="nofollow noreferrer">enter image description here</a></p>
<p><a href="https://i.stack.imgur.com/bbwFA.png" rel="nofollow noreferrer">enter image description here</a></p>
| 0debug
|
R How to apply a plot function to specifics columns of multiple data frames? : Hi i have two data frame Fichier1 and Fichier2 which i got by using this code:
temp = list.files(pattern="*.csv")
list2env(
lapply(setNames(temp, make.names(gsub("*.csv$", "", temp))),
read.csv), envir = .GlobalEnv)
Now i want to plot specifics columns of my two data frames using lapply again but i can't see how to do it.
| 0debug
|
How to turn a PHP array into a multidimensional associative array : <p>I have an array that looks like this:</p>
<pre><code>Array (
[0]=> 467:tv:59.99
[1]=> 387:radio:8.99
[2]=> 098:toaster:6.99
[3]=> 732:laptop:109.99)
</code></pre>
<p>I want to create an associative array (add a key to every value). Each value is separated by a colon. For example, at index zero, the key and value pairs would be:</p>
<pre><code>[0] =>
id => 467
product => tv
price => 59.99
</code></pre>
<p>I was thinking of using a for each loop to loop through the array and split each index into a smaller chunk where the colons are. Additionally, would I use the list() function here?</p>
<p>I'm a little stuck on how to begin this process tbh so any tips and advice would be appreciated.</p>
| 0debug
|
what does it mean by $this->get_soap_provider_options()['location'] : I found a php library on which a line is:
$this->get_soap_provider_options()['location'];
But this is producing error:
Parse error: syntax error, unexpected '[' in ...path to file.. at line...
I think this line of code is for php 5.4 or higher. How can I write this line for older version of php?
i.e: I could not understand why `['location']` is written after function agrument `get_soap_provider_options()`.
| 0debug
|
static void init_quantized_coeffs_elem0 (int8_t *quantized_coeffs, GetBitContext *gb, int length)
{
int i, k, run, level, diff;
if (BITS_LEFT(length,gb) < 16)
return;
level = qdm2_get_vlc(gb, &vlc_tab_level, 0, 2);
quantized_coeffs[0] = level;
for (i = 0; i < 7; ) {
if (BITS_LEFT(length,gb) < 16)
break;
run = qdm2_get_vlc(gb, &vlc_tab_run, 0, 1) + 1;
if (BITS_LEFT(length,gb) < 16)
break;
diff = qdm2_get_se_vlc(&vlc_tab_diff, gb, 2);
for (k = 1; k <= run; k++)
quantized_coeffs[i + k] = (level + ((k * diff) / run));
level += diff;
i += run;
}
}
| 1threat
|
How to return a pointer to an object? : <p>I have created two classes one called Pair(as data members has a dynamically allocated array of chars for KEY and double for value) and the other Collection(which is a collection of Pairs, as data members it has a dynamically allocated array of pairs, and a int variable for the sizeOfPairs). The Collection class should have a method that should return a pointer to the first objects with the provided key, if such object does not exist returns NULL pointer. This is how far I got with that method, but I get an error(error: indirection requires pointer operand ('Pair' invalid)) for the 4th line. Is the way I am returning a pointer to an object correct?</p>
<pre><code>Pair *find(const char *key){
for(int i = 0; i < sizeOfPair; ++i){
if(pair[i].getKey() == key){
return *pair[i];
}else{
return NULL;
}
}
}
</code></pre>
| 0debug
|
static void scsi_write_complete(void * opaque, int ret)
{
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
if (r->req.aiocb != NULL) {
r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct);
}
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
goto done;
}
}
n = r->qiov.size / 512;
r->sector += n;
r->sector_count -= n;
if (r->sector_count == 0) {
scsi_req_complete(&r->req, GOOD);
} else {
scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);
DPRINTF("Write complete tag=0x%x more=%d\n", r->req.tag, r->qiov.size);
scsi_req_data(&r->req, r->qiov.size);
}
done:
if (!r->req.io_canceled) {
scsi_req_unref(&r->req);
}
}
| 1threat
|
Aml *aml_index(Aml *arg1, Aml *idx)
{
Aml *var = aml_opcode(0x88 );
aml_append(var, arg1);
aml_append(var, idx);
build_append_byte(var->buf, 0x00 );
return var;
}
| 1threat
|
How to access camera frames in flutter quickly : <p>I would like to implement near real-time OCR on the camera feed of my flutter app. To do this I would like to access the camera data in a speedy manner.
As far as I can tell I have two options, and have hit roadblocks with both:</p>
<ol>
<li><p>Take a screenshot of the <code>CameraPreview</code> by putting a <code>RepaintBoundary</code> around it and creating a <code>RenderRepaintBoundary</code>, and calling <code>boundary.toImage()</code>. The problem with this method is that the .toImage method only seems to capture the painted widgets in the boundary and not the data from the camera preview. Simmilar to the issue described here: <a href="https://github.com/flutter/flutter/issues/17687" rel="noreferrer">https://github.com/flutter/flutter/issues/17687</a></p></li>
<li><p>Capture an image with <code>controller.takePicture(filePath)</code> from Camera 0.2.1, similar to the example docs. The problem here is that it takes super long before the image becomes available (2-3 seconds). I guess that this is because the file is saved to the disc on capture and then needs to be read from the file again.</p></li>
</ol>
<p>Is there any way that one can directly access the picture information after capture, to do things like pre-process and OCR?</p>
| 0debug
|
void *HELPER(lookup_tb_ptr)(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
TranslationBlock *tb;
target_ulong cs_base, pc;
uint32_t flags, hash;
cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
hash = tb_jmp_cache_hash_func(pc);
tb = atomic_rcu_read(&cpu->tb_jmp_cache[hash]);
if (unlikely(!(tb
&& tb->pc == pc
&& tb->cs_base == cs_base
&& tb->flags == flags
&& tb->trace_vcpu_dstate == *cpu->trace_dstate))) {
tb = tb_htable_lookup(cpu, pc, cs_base, flags);
if (!tb) {
return tcg_ctx.code_gen_epilogue;
}
atomic_set(&cpu->tb_jmp_cache[hash], tb);
}
qemu_log_mask_and_addr(CPU_LOG_EXEC, pc,
"Chain %p [%d: " TARGET_FMT_lx "] %s\n",
tb->tc_ptr, cpu->cpu_index, pc,
lookup_symbol(pc));
return tb->tc_ptr;
}
| 1threat
|
Is there a way to group by multiple criteria and then count data in excel? : Pickup Received BUILDING ROOM
7/12/2018 50 0G39
7/12/2018 50 0G39
9/13/2018 101 0275B
9/13/2018 101 0275B
9/13/2018 101 0275B
8/10/2018 1000 206
8/10/2018 1000 206
8/22/2018 1000 208
I am looking to count data based off of a group of multiple criteria. I would like to group matching building and rooms with the same date and count them as one. My goal is to determine the number of pickups (where same date, building, and room is one trip).
Ex.
Pickup Received BUILDING ROOM
7/12/2018 50 0G39
7/12/2018 50 0G39
This is one
9/13/2018 101 0275B
9/13/2018 101 0275B
9/13/2018 101 0275B
This is one
8/10/2018 1000 206
8/10/2018 1000 206
This is one
8/22/2018 1000 208
This is one.
Is this possible with excel?
Thanks in advanced.
| 0debug
|
What is the default variable initializer in Tensorflow? : <p>What is the default method of variable initialization used when <code>tf.get_variable()</code> is called without any specification for the initializer? The Docs just says 'None'.</p>
| 0debug
|
static av_cold int dfa_decode_init(AVCodecContext *avctx)
{
DfaContext *s = avctx->priv_data;
int ret;
avctx->pix_fmt = PIX_FMT_PAL8;
if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
return ret;
s->frame_buf = av_mallocz(avctx->width * avctx->height + AV_LZO_OUTPUT_PADDING);
if (!s->frame_buf)
return AVERROR(ENOMEM);
return 0;
}
| 1threat
|
void sp804_init(uint32_t base, qemu_irq irq)
{
int iomemtype;
sp804_state *s;
qemu_irq *qi;
s = (sp804_state *)qemu_mallocz(sizeof(sp804_state));
qi = qemu_allocate_irqs(sp804_set_irq, s, 2);
s->base = base;
s->irq = irq;
s->timer[0] = arm_timer_init(1000000, qi[0]);
s->timer[1] = arm_timer_init(1000000, qi[1]);
iomemtype = cpu_register_io_memory(0, sp804_readfn,
sp804_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
}
| 1threat
|
Rails home View Rendering twice : <pre><code>Rendering home/index.html.erb within layouts/home
Rendered home/index.html.erb within layouts/home (0.9ms)
</code></pre>
<p>this is how my views are rendering, this is heppening only on my home page,
unable to figure out what is the issue.</p>
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
static void guest_phys_blocks_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
GuestPhysListener *g;
uint64_t section_size;
hwaddr target_start, target_end;
uint8_t *host_addr;
GuestPhysBlock *predecessor;
if (!memory_region_is_ram(section->mr) ||
memory_region_is_skip_dump(section->mr)) {
return;
}
g = container_of(listener, GuestPhysListener, listener);
section_size = int128_get64(section->size);
target_start = section->offset_within_address_space;
target_end = target_start + section_size;
host_addr = memory_region_get_ram_ptr(section->mr) +
section->offset_within_region;
predecessor = NULL;
if (!QTAILQ_EMPTY(&g->list->head)) {
hwaddr predecessor_size;
predecessor = QTAILQ_LAST(&g->list->head, GuestPhysBlockHead);
predecessor_size = predecessor->target_end - predecessor->target_start;
g_assert(predecessor->target_end <= target_start);
if (predecessor->target_end < target_start ||
predecessor->host_addr + predecessor_size != host_addr) {
predecessor = NULL;
}
}
if (predecessor == NULL) {
GuestPhysBlock *block = g_malloc0(sizeof *block);
block->target_start = target_start;
block->target_end = target_end;
block->host_addr = host_addr;
block->mr = section->mr;
memory_region_ref(section->mr);
QTAILQ_INSERT_TAIL(&g->list->head, block, next);
++g->list->num;
} else {
predecessor->target_end = target_end;
}
#ifdef DEBUG_GUEST_PHYS_REGION_ADD
fprintf(stderr, "%s: target_start=" TARGET_FMT_plx " target_end="
TARGET_FMT_plx ": %s (count: %u)\n", __FUNCTION__, target_start,
target_end, predecessor ? "joined" : "added", g->list->num);
#endif
}
| 1threat
|
static int film_read_header(AVFormatContext *s)
{
FilmDemuxContext *film = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
unsigned char scratch[256];
int i;
unsigned int data_offset;
unsigned int audio_frame_counter;
film->sample_table = NULL;
film->stereo_buffer = NULL;
film->stereo_buffer_size = 0;
if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
data_offset = AV_RB32(&scratch[4]);
film->version = AV_RB32(&scratch[8]);
if (film->version == 0) {
if (avio_read(pb, scratch, 20) != 20)
return AVERROR(EIO);
film->audio_type = AV_CODEC_ID_PCM_S8;
film->audio_samplerate = 22050;
film->audio_channels = 1;
film->audio_bits = 8;
} else {
if (avio_read(pb, scratch, 32) != 32)
return AVERROR(EIO);
film->audio_samplerate = AV_RB16(&scratch[24]);
film->audio_channels = scratch[21];
if (!film->audio_channels || film->audio_channels > 2) {
av_log(s, AV_LOG_ERROR,
"Invalid number of channels: %d\n", film->audio_channels);
return AVERROR_INVALIDDATA;
}
film->audio_bits = scratch[22];
if (scratch[23] == 2)
film->audio_type = AV_CODEC_ID_ADPCM_ADX;
else if (film->audio_channels > 0) {
if (film->audio_bits == 8)
film->audio_type = AV_CODEC_ID_PCM_S8;
else if (film->audio_bits == 16)
film->audio_type = AV_CODEC_ID_PCM_S16BE;
else
film->audio_type = AV_CODEC_ID_NONE;
} else
film->audio_type = AV_CODEC_ID_NONE;
}
if (AV_RB32(&scratch[0]) != FDSC_TAG)
return AVERROR_INVALIDDATA;
if (AV_RB32(&scratch[8]) == CVID_TAG) {
film->video_type = AV_CODEC_ID_CINEPAK;
} else if (AV_RB32(&scratch[8]) == RAW_TAG) {
film->video_type = AV_CODEC_ID_RAWVIDEO;
} else {
film->video_type = AV_CODEC_ID_NONE;
}
if (film->video_type) {
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
film->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = film->video_type;
st->codec->codec_tag = 0;
st->codec->width = AV_RB32(&scratch[16]);
st->codec->height = AV_RB32(&scratch[12]);
if (film->video_type == AV_CODEC_ID_RAWVIDEO) {
if (scratch[20] == 24) {
st->codec->pix_fmt = AV_PIX_FMT_RGB24;
} else {
av_log(s, AV_LOG_ERROR, "raw video is using unhandled %dbpp\n", scratch[20]);
return -1;
}
}
}
if (film->audio_type) {
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
film->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = film->audio_type;
st->codec->codec_tag = 1;
st->codec->channels = film->audio_channels;
st->codec->sample_rate = film->audio_samplerate;
if (film->audio_type == AV_CODEC_ID_ADPCM_ADX) {
st->codec->bits_per_coded_sample = 18 * 8 / 32;
st->codec->block_align = st->codec->channels * 18;
st->need_parsing = AVSTREAM_PARSE_FULL;
} else {
st->codec->bits_per_coded_sample = film->audio_bits;
st->codec->block_align = st->codec->channels *
st->codec->bits_per_coded_sample / 8;
}
st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec->bits_per_coded_sample;
}
if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
if (AV_RB32(&scratch[0]) != STAB_TAG)
return AVERROR_INVALIDDATA;
film->base_clock = AV_RB32(&scratch[8]);
film->sample_count = AV_RB32(&scratch[12]);
if(film->sample_count >= UINT_MAX / sizeof(film_sample))
return -1;
film->sample_table = av_malloc(film->sample_count * sizeof(film_sample));
if (!film->sample_table)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
avpriv_set_pts_info(st, 33, 1, film->base_clock);
else
avpriv_set_pts_info(st, 64, 1, film->audio_samplerate);
}
audio_frame_counter = 0;
for (i = 0; i < film->sample_count; i++) {
if (avio_read(pb, scratch, 16) != 16) {
av_free(film->sample_table);
return AVERROR(EIO);
}
film->sample_table[i].sample_offset =
data_offset + AV_RB32(&scratch[0]);
film->sample_table[i].sample_size = AV_RB32(&scratch[4]);
if (film->sample_table[i].sample_size > INT_MAX / 4)
return AVERROR_INVALIDDATA;
if (AV_RB32(&scratch[8]) == 0xFFFFFFFF) {
film->sample_table[i].stream = film->audio_stream_index;
film->sample_table[i].pts = audio_frame_counter;
if (film->audio_type == AV_CODEC_ID_ADPCM_ADX)
audio_frame_counter += (film->sample_table[i].sample_size * 32 /
(18 * film->audio_channels));
else if (film->audio_type != AV_CODEC_ID_NONE)
audio_frame_counter += (film->sample_table[i].sample_size /
(film->audio_channels * film->audio_bits / 8));
} else {
film->sample_table[i].stream = film->video_stream_index;
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1;
}
}
film->current_sample = 0;
return 0;
}
| 1threat
|
Changing Git remote URL updates fetch but not push : <p>I am attempting to change the remote URL of my origin branch in Git. All I want to change is the SSH port. First, listing my remote origins gives me this:</p>
<pre><code>git remote -v
origin user@example.com:package/name.git (fetch)
origin user@example.com:package/name.git (push)
</code></pre>
<p>Then, I run the <code>set-url</code> command to change my origin URL:</p>
<pre><code>git remote set-url origin ssh://user@example.com:XX/package/name.git (XX is my port #)
</code></pre>
<p>Now, I can fetch without issue, but pushing my branch to origin doesn't work, because the push URL didn't change. Listing my remotes again I get this:</p>
<pre><code>git remote -v
origin ssh://user@example.com:XX/package/name.git (fetch)
origin user@example.com:package/name.git (push)
</code></pre>
<p><strong>Why did my <code>set-url</code> command only change the fetch URL?</strong></p>
| 0debug
|
Binary string isn't converting to decimal properly on my arduino : Basically I want to convert the binary string I store from my two interrupts (ISR_INT1, ISR_INT0) into a decimal. I've tested this using gcc on my mac and it works correctly giving me the correct decimal. Testing on my Arduino I get a totally different decimal. I know the arduino only goes up to 16 bit int so I used a long instead see below. Any help or suggestions are greatly appreciated.
#Here is my Arduino Sketch
#define MAX_BITS 100 // max number of bits
#define WEIGAND_WAIT_TIME 3000 // time to wait for another weigand pulse.
unsigned char databits[MAX_BITS]; // stores all of the data bits
unsigned char bitCount; // number of bits currently captured
unsigned char flagDone; // goes low when data is currently being captured
unsigned int weigand_counter; // countdown until we assume there are no more bits
unsigned long facilityCode = 0; // decoded facility code
unsigned long cardCode = 0; // decoded card code
String fullCard; // binary value full card number
int LED_GREEN = 11;
int LED_RED = 12;
int BEEP_BEEP = 10;
// interrupt that happens when INTO goes low (0 bit)
void ISR_INT0() {
fullCard += 0;
bitCount++;
flagDone = 0;
weigand_counter = WEIGAND_WAIT_TIME;
}
// interrupt that happens when INT1 goes low (1 bit)
void ISR_INT1() {
fullCard += 1;
databits[bitCount] = 1;
bitCount++;
flagDone = 0;
weigand_counter = WEIGAND_WAIT_TIME;
}
void setup() {
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(BEEP_BEEP, OUTPUT);
digitalWrite(LED_RED, HIGH); // High = Off
digitalWrite(BEEP_BEEP, HIGH); // High = off
digitalWrite(LED_GREEN, LOW); // Low = On
pinMode(2, INPUT); // DATA0 (INT0)
pinMode(3, INPUT); // DATA1 (INT1)
Serial.begin(9600);
Serial.println("Snow RFID Reader PUT HID CARD ");
// binds the ISR functions to the falling edge of INTO and INT1
attachInterrupt(0, ISR_INT0, FALLING);
attachInterrupt(1, ISR_INT1, FALLING);
weigand_counter = WEIGAND_WAIT_TIME;
}
void loop()
{
// This waits to make sure that there have been no more data pulses before processing data
if (!flagDone) {
if (--weigand_counter == 0)
flagDone = 1;
}
// if we have bits and we the weigand counter went out
if (bitCount > 0 && flagDone) {
unsigned char i;
Serial.print(" ");
Serial.print("Read ");
Serial.print(bitCount);
Serial.print(" bits. ");
//int temp_l = fullCard.length() + 1;
//char temp[temp_l];
//fullCard.toCharArray(temp, temp_l);
Serial.print(fullCard);
**// THIS IS WHERE IT I TRY TO CONVERT MY BINARY STRING INTO A DECIMAL**
long fullCardInt = bin2dec(const_cast<char*>(fullCard.c_str()));
Serial.print(fullCardInt);
if (bitCount == 35) {
// 35 bit HID Corporate 1000 format
// facility code = bits 2 to 14
for (i = 2; i < 14; i++) {
facilityCode <<= 1;
facilityCode |= databits[i];
}
// card code = bits 15 to 34
for (i = 14; i < 34; i++) {
cardCode <<= 1;
cardCode |= databits[i];
}
printBits();
}
else if (bitCount == 26) {
// standard 26 bit format
// facility code = bits 2 to 9
for (i = 1; i < 9; i++) {
facilityCode <<= 1;
facilityCode |= databits[i];
}
// card code = bits 10 to 23
for (i = 9; i < 25; i++) {
cardCode <<= 1;
cardCode |= databits[i];
}
printBits();
}
else {
Serial.println("Unable to decode.");
}
// cleanup and get ready for the next card
bitCount = 0;
facilityCode = 0;
cardCode = 0;
for (i = 0; i < MAX_BITS; i++)
{
databits[i] = 0;
}
}
}
void printBits() {
Serial.print("FC = ");
Serial.print(facilityCode);
Serial.print(", CC = ");
Serial.println(cardCode);
digitalWrite(LED_RED, LOW); // Red
if (cardCode == 12345) {
digitalWrite(LED_GREEN, HIGH);
}
delay(500);
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, LOW);
digitalWrite(BEEP_BEEP, LOW);
delay(500);
digitalWrite(BEEP_BEEP, HIGH);
delay(500);
digitalWrite(BEEP_BEEP, LOW);
delay(500);
digitalWrite(BEEP_BEEP, HIGH);
}
long bin2dec(const char *bin)
{
int result = 0;
for (; *bin; bin++)
{
if ((*bin != '0') && (*bin != '1'))
return -1;
result = result * 2 + (*bin - '0');
//if(result<=0) return -1;
}
return result;
}
#This is what my serial terminal for my arduino reads out
Snow RFID Reader PUT HID CARD
// bits read Binary string Incorrect decimal
Read 26 bits. 00001000000100000101010011 16723 FC = 16, CC = 8361
#Here is my Test.cpp script
//THIS WORKS AND GIVES ME THE CORRECT DECIMAL
#include <stdio.h>
int bin2dec(const char *bin)
{
int result=0;
for(;*bin;bin++)
{
if((*bin!='0')&&(*bin!='1'))
return -1;
result=result*2+(*bin-'0');
//if(result<=0) return -1;
}
return result;
}
int main ( void )
{
printf("%d\n",bin2dec("00001000000100000101010011"));
return(0);
}
#This is what my test cpp script gives me which is correct.
S:g$ g++ main.cpp -o SnowTest
S:g$ ./SnowTest
2113875
| 0debug
|
Dependencies conflict issue in android studio's build.gradle file : <p>I am having a problem in placing the right dependencies in build.gradle file.
I have posted the screenshot of the issue. PLEASE HELP!!!!!!!!!!!
<a href="https://i.stack.imgur.com/Fe77z.png" rel="nofollow noreferrer">Screenshot is here</a></p>
| 0debug
|
How to turn on speaker for incoming call programmatically in Android L? : <p>I want to accept an incoming call using answering phone's GUI (Phone's GUI) of my phone in Android 5.0. I found a way that needs to make an activity which use to send some action to open the Phone's GUI. I was successful to turn on the Phone's GUI for an incoming call. The issue is how can I turn on the speaker for the Phone's GUI. I tried the code but it does not turn on. Could you help me to solve that issue in Android L</p>
<pre><code>audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
if (!audioManager.isSpeakerphoneOn())
audioManager.setSpeakerphoneOn(true);
audioManager.setMode(AudioManager.MODE_NORMAL);
</code></pre>
<p>Manifest</p>
<pre><code><uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
</code></pre>
<p>Besides, do we have more shoter way to open accept a incoming call using answering phone's intent. My way is so long because it use an Activity. </p>
<p>This is my full class code</p>
<pre><code>public class AcceptCallActivity extends Activity {
private static final String MANUFACTURER_HTC = "HTC";
private KeyguardManager keyguardManager;
private AudioManager audioManager;
private CallStateReceiver callStateReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
}
@Override
protected void onResume() {
super.onResume();
registerCallStateReceiver();
updateWindowFlags();
acceptCall();
}
@Override
protected void onPause() {
super.onPause();
if (callStateReceiver != null) {
unregisterReceiver(callStateReceiver);
callStateReceiver = null;
}
}
private void registerCallStateReceiver() {
callStateReceiver = new CallStateReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
registerReceiver(callStateReceiver, intentFilter);
}
private void updateWindowFlags() {
if (keyguardManager.inKeyguardRestrictedInputMode()) {
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
} else {
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
}
private void acceptCall() {
// for HTC devices we need to broadcast a connected headset
boolean broadcastConnected = MANUFACTURER_HTC.equalsIgnoreCase(Build.MANUFACTURER)
&& !audioManager.isWiredHeadsetOn();
if (broadcastConnected) {
broadcastHeadsetConnected(false);
}
try {
try {
Log.d("AnswerCall","execute input keycode headset hook");
//Turn on speaker
audioManager.setMode(AudioManager.MODE_IN_CALL);
if (!audioManager.isSpeakerphoneOn())
audioManager.setSpeakerphoneOn(true);
audioManager.setMode(AudioManager.MODE_NORMAL);
Runtime.getRuntime().exec("input keyevent " +
Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK));
} catch (IOException e) {
// Runtime.exec(String) had an I/O problem, try to fall back
Log.d("AnswerCall","send keycode headset hook intents");
String enforcedPerm = "android.permission.CALL_PRIVILEGED";
Intent btnDown = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK));
Intent btnUp = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK));
sendOrderedBroadcast(btnDown, enforcedPerm);
sendOrderedBroadcast(btnUp, enforcedPerm);
}
} finally {
if (broadcastConnected) {
broadcastHeadsetConnected(false);
}
}
}
private void broadcastHeadsetConnected(boolean connected) {
Intent i = new Intent(Intent.ACTION_HEADSET_PLUG);
i.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
i.putExtra("state", connected ? 1 : 0);
i.putExtra("name", "mysms");
try {
sendOrderedBroadcast(i, null);
} catch (Exception e) {
}
}
private class CallStateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
finish();
}
}
}
</code></pre>
| 0debug
|
char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms)
{
snprintf(buf, buf_size, "%s%s%s%s%s",
perms & AV_PERM_READ ? "r" : "",
perms & AV_PERM_WRITE ? "w" : "",
perms & AV_PERM_PRESERVE ? "p" : "",
perms & AV_PERM_REUSE ? "u" : "",
perms & AV_PERM_REUSE2 ? "U" : "");
return buf;
}
| 1threat
|
I do not understand how a pointer variable works when passed into a function : <p>I don't understand how a pointer variables works when passed into a function. Could you please give a brief description. Also, I don't understand how pointer return functions works.I feel like if I get a better intuition of both, I'm able to apply it when I need it.</p>
| 0debug
|
C Logical in If's And & Or with a numerical value : <p>I am making a project for my school about digital locks and using an accelerometer. But the buzzer won't buzz with my code. I think I have some issues in logical operations in if's. </p>
<pre><code>void loop() {
recordAccelRegisters();
if((gForceX || gForceY || gForceZ) > 1) {
tone(2, 2000);
delay(1000);
noTone(2);
}
Serial.print(gForceX);
Serial.print(" ");
Serial.print(gForceY);
Serial.print(" ");
Serial.print(gForceZ);
Serial.println();
delay(100);
</code></pre>
| 0debug
|
Generating A List of Possible Moves : I am trying to generate a list of possible moves for a checkers-like game. For example, at the start of the game the board would look like [[1,1,1], [0,0,0], [2,2,2]]. My function would take the color (one for white, or two for black) and move the pieces either one space forward, or one space diagonal to capture another piece. So the first possible list of moves with white going first would be [[0,1,1], [1,0,0], [2,2,2], [1,0,1], [0,1,0, [2,2,2] etc. etc.
So far I have:
def generateMoves(color, board):
newboard = []
subboard = []
board = [[1, 1, 1], [0, 0, 0], [2, 2, 2]]
x = 0
for i in board:
while x < len(board):
subboard.append(board[x])
newboard.append(subboard)
x += 1
return newboard
but I can't figure out what modifications I need to make to it to calculate the new list of possible moves.
| 0debug
|
Why does my UIApplicationDelegate receive applicationDidBecomeActive when pulling down notification center? : <p>I've built a bare application with no functionality in XCode, and put logging statements in the applicationDidBecomeActive and applicationWillResignActive methods.</p>
<p>When I swipe down to show the notification center, I see the following:</p>
<p>2018-01-03 10:18:16.867028+0000 BareProject[1165:2053601] Resigning active</p>
<p>2018-01-03 10:18:17.510713+0000 BareProject[1165:2053601] Active</p>
<p>2018-01-03 10:18:17.634805+0000 BareProject[1165:2053601] Resigning active</p>
<p>Is this intended? My code does quite a lot of work when becoming active, only to have the rug pulled out from it again about 120ms later, and it seems that the documentation says I should be using applicationDidBecomeActive to restart tasks:
<a href="https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622956-applicationdidbecomeactive?language=objc" rel="noreferrer">https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622956-applicationdidbecomeactive?language=objc</a></p>
<p>I tried this on ios 10.3 and this behavior does not exist.</p>
| 0debug
|
def lps(str):
n = len(str)
L = [[0 for x in range(n)] for x in range(n)]
for i in range(n):
L[i][i] = 1
for cl in range(2, n+1):
for i in range(n-cl+1):
j = i+cl-1
if str[i] == str[j] and cl == 2:
L[i][j] = 2
elif str[i] == str[j]:
L[i][j] = L[i+1][j-1] + 2
else:
L[i][j] = max(L[i][j-1], L[i+1][j]);
return L[0][n-1]
| 0debug
|
static inline void helper_ret_protected(int shift, int is_iret, int addend)
{
uint32_t sp, new_cs, new_eip, new_eflags, new_esp, new_ss;
uint32_t new_es, new_ds, new_fs, new_gs;
uint32_t e1, e2, ss_e1, ss_e2;
int cpl, dpl, rpl, eflags_mask;
uint8_t *ssp;
sp = ESP;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (shift == 1) {
if (is_iret)
new_eflags = ldl_kernel(ssp + 8);
new_cs = ldl_kernel(ssp + 4) & 0xffff;
new_eip = ldl_kernel(ssp);
if (is_iret && (new_eflags & VM_MASK))
goto return_to_vm86;
} else {
if (is_iret)
new_eflags = lduw_kernel(ssp + 4);
new_cs = lduw_kernel(ssp + 2);
new_eip = lduw_kernel(ssp);
}
if ((new_cs & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (load_segment(&e1, &e2, new_cs) != 0)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (!(e2 & DESC_S_MASK) ||
!(e2 & DESC_CS_MASK))
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
cpl = env->hflags & HF_CPL_MASK;
rpl = new_cs & 3;
if (rpl < cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (e2 & DESC_CS_MASK) {
if (dpl > rpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
} else {
if (dpl != rpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
}
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
if (rpl == cpl) {
cpu_x86_load_seg_cache(env, R_CS, new_cs,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
new_esp = sp + (4 << shift) + ((2 * is_iret) << shift) + addend;
} else {
ssp += (4 << shift) + ((2 * is_iret) << shift) + addend;
if (shift == 1) {
new_esp = ldl_kernel(ssp);
new_ss = ldl_kernel(ssp + 4) & 0xffff;
} else {
new_esp = lduw_kernel(ssp);
new_ss = lduw_kernel(ssp + 2);
}
if ((new_ss & 3) != rpl)
raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
if (load_segment(&ss_e1, &ss_e2, new_ss) != 0)
raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
if (!(ss_e2 & DESC_S_MASK) ||
(ss_e2 & DESC_CS_MASK) ||
!(ss_e2 & DESC_W_MASK))
raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;
if (dpl != rpl)
raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
if (!(ss_e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_ss & 0xfffc);
cpu_x86_load_seg_cache(env, R_CS, new_cs,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
cpu_x86_load_seg_cache(env, R_SS, new_ss,
get_seg_base(ss_e1, ss_e2),
get_seg_limit(ss_e1, ss_e2),
ss_e2);
cpu_x86_set_cpl(env, rpl);
}
if (env->segs[R_SS].flags & DESC_B_MASK)
ESP = new_esp;
else
ESP = (ESP & 0xffff0000) |
(new_esp & 0xffff);
env->eip = new_eip;
if (is_iret) {
if (cpl == 0)
eflags_mask = FL_UPDATE_CPL0_MASK;
else
eflags_mask = FL_UPDATE_MASK32;
if (shift == 0)
eflags_mask &= 0xffff;
load_eflags(new_eflags, eflags_mask);
}
return;
return_to_vm86:
new_esp = ldl_kernel(ssp + 12);
new_ss = ldl_kernel(ssp + 16);
new_es = ldl_kernel(ssp + 20);
new_ds = ldl_kernel(ssp + 24);
new_fs = ldl_kernel(ssp + 28);
new_gs = ldl_kernel(ssp + 32);
load_eflags(new_eflags, FL_UPDATE_CPL0_MASK | VM_MASK | VIF_MASK | VIP_MASK);
load_seg_vm(R_CS, new_cs);
cpu_x86_set_cpl(env, 3);
load_seg_vm(R_SS, new_ss);
load_seg_vm(R_ES, new_es);
load_seg_vm(R_DS, new_ds);
load_seg_vm(R_FS, new_fs);
load_seg_vm(R_GS, new_gs);
env->eip = new_eip;
ESP = new_esp;
}
| 1threat
|
Random Forest Feature Importance Chart using Python : <p>I am working with RandomForestRegressor in python and I want to create a chart that will illustrate the ranking of feature importance. This is the code I used:</p>
<pre><code>from sklearn.ensemble import RandomForestRegressor
MT= pd.read_csv("MT_reduced.csv")
df = MT.reset_index(drop = False)
columns2 = df.columns.tolist()
# Filter the columns to remove ones we don't want.
columns2 = [c for c in columns2 if c not in["Violent_crime_rate","Change_Property_crime_rate","State","Year"]]
# Store the variable we'll be predicting on.
target = "Property_crime_rate"
# Let’s randomly split our data with 80% as the train set and 20% as the test set:
# Generate the training set. Set random_state to be able to replicate results.
train2 = df.sample(frac=0.8, random_state=1)
#exclude all obs with matching index
test2 = df.loc[~df.index.isin(train2.index)]
print(train2.shape) #need to have same number of features only difference should be obs
print(test2.shape)
# Initialize the model with some parameters.
model = RandomForestRegressor(n_estimators=100, min_samples_leaf=8, random_state=1)
#n_estimators= number of trees in forrest
#min_samples_leaf= min number of samples at each leaf
# Fit the model to the data.
model.fit(train2[columns2], train2[target])
# Make predictions.
predictions_rf = model.predict(test2[columns2])
# Compute the error.
mean_squared_error(predictions_rf, test2[target])#650.4928
</code></pre>
<h1>Feature Importance</h1>
<pre><code>features=df.columns[[3,4,6,8,9,10]]
importances = model.feature_importances_
indices = np.argsort(importances)
plt.figure(1)
plt.title('Feature Importances')
plt.barh(range(len(indices)), importances[indices], color='b', align='center')
plt.yticks(range(len(indices)), features[indices])
plt.xlabel('Relative Importance')
</code></pre>
<p>This feature importance code was altered from an example found on <a href="http://www.agcross.com/2015/02/random-forests-in-python-with-scikit-learn/" rel="noreferrer">http://www.agcross.com/2015/02/random-forests-in-python-with-scikit-learn/</a></p>
<p>I receive the following error when I attempt to replicate the code with my data:</p>
<pre><code> IndexError: index 6 is out of bounds for axis 1 with size 6
</code></pre>
<p>Also, only one feature shows up on my chart with 100% importance where there are no labels.</p>
<p>Any help solving this issue so I can create this chart will be greatly appreciated.</p>
| 0debug
|
void qmp_nbd_server_start(SocketAddress *addr,
bool has_tls_creds, const char *tls_creds,
Error **errp)
{
if (nbd_server) {
error_setg(errp, "NBD server already running");
return;
}
nbd_server = g_new0(NBDServerData, 1);
nbd_server->watch = -1;
nbd_server->listen_ioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(nbd_server->listen_ioc),
"nbd-listener");
if (qio_channel_socket_listen_sync(
nbd_server->listen_ioc, addr, errp) < 0) {
goto error;
}
if (has_tls_creds) {
nbd_server->tlscreds = nbd_get_tls_creds(tls_creds, errp);
if (!nbd_server->tlscreds) {
goto error;
}
if (addr->type != SOCKET_ADDRESS_KIND_INET) {
error_setg(errp, "TLS is only supported with IPv4/IPv6");
goto error;
}
}
nbd_server->watch = qio_channel_add_watch(
QIO_CHANNEL(nbd_server->listen_ioc),
G_IO_IN,
nbd_accept,
NULL,
NULL);
return;
error:
nbd_server_free(nbd_server);
nbd_server = NULL;
}
| 1threat
|
static int mode_sense_page(SCSIRequest *req, int page, uint8_t *p)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
BlockDriverState *bdrv = s->bs;
int cylinders, heads, secs;
switch (page) {
case 4:
p[0] = 4;
p[1] = 0x16;
bdrv_get_geometry_hint(bdrv, &cylinders, &heads, &secs);
p[2] = (cylinders >> 16) & 0xff;
p[3] = (cylinders >> 8) & 0xff;
p[4] = cylinders & 0xff;
p[5] = heads & 0xff;
p[6] = (cylinders >> 16) & 0xff;
p[7] = (cylinders >> 8) & 0xff;
p[8] = cylinders & 0xff;
p[9] = (cylinders >> 16) & 0xff;
p[10] = (cylinders >> 8) & 0xff;
p[11] = cylinders & 0xff;
p[12] = 0;
p[13] = 200;
p[14] = 0xff;
p[15] = 0xff;
p[16] = 0xff;
p[20] = (5400 >> 8) & 0xff;
p[21] = 5400 & 0xff;
return 0x16;
case 5:
p[0] = 5;
p[1] = 0x1e;
p[2] = 5000 >> 8;
p[3] = 5000 & 0xff;
bdrv_get_geometry_hint(bdrv, &cylinders, &heads, &secs);
p[4] = heads & 0xff;
p[5] = secs & 0xff;
p[6] = s->cluster_size * 2;
p[8] = (cylinders >> 8) & 0xff;
p[9] = cylinders & 0xff;
p[10] = (cylinders >> 8) & 0xff;
p[11] = cylinders & 0xff;
p[12] = (cylinders >> 8) & 0xff;
p[13] = cylinders & 0xff;
p[14] = 0;
p[15] = 1;
p[16] = 1;
p[17] = 0;
p[18] = 1;
p[19] = 1;
p[20] = 1;
p[28] = (5400 >> 8) & 0xff;
p[29] = 5400 & 0xff;
return 0x1e;
case 8:
p[0] = 8;
p[1] = 0x12;
if (bdrv_enable_write_cache(s->bs)) {
p[2] = 4;
}
return 20;
case 0x2a:
if (bdrv_get_type_hint(bdrv) != BDRV_TYPE_CDROM)
return 0;
p[0] = 0x2a;
p[1] = 0x14;
p[2] = 3;
p[3] = 0;
p[4] = 0x7f;
p[5] = 0xff;
p[6] = 0x2d | (bdrv_is_locked(s->bs)? 2 : 0);
p[7] = 0;
p[8] = (50 * 176) >> 8;
p[9] = (50 * 176) & 0xff;
p[10] = 0 >> 8;
p[11] = 0 & 0xff;
p[12] = 2048 >> 8;
p[13] = 2048 & 0xff;
p[14] = (16 * 176) >> 8;
p[15] = (16 * 176) & 0xff;
p[18] = (16 * 176) >> 8;
p[19] = (16 * 176) & 0xff;
p[20] = (16 * 176) >> 8; current
p[21] = (16 * 176) & 0xff;
return 22;
default:
return 0;
}
}
| 1threat
|
void bdrv_set_io_limits(BlockDriverState *bs,
ThrottleConfig *cfg)
{
int i;
throttle_config(&bs->throttle_state, cfg);
for (i = 0; i < 2; i++) {
qemu_co_enter_next(&bs->throttled_reqs[i]);
}
}
| 1threat
|
split html text by some special tags : <p>I have description with html format. But it need to display in one line. And at the end of line, we need to display '...' when it's too long. I tried to use css, some thing like :</p>
<blockquote>
<p>overflow: hidden; text-overflow: ellipsis; white-space: nowrap;</p>
</blockquote>
<p>It worked. but when I put some html tags such as p, div. It can not work any more. It displayed more than one line :(.
I tried to use javascript also, split html text by regex pattern, I used this pattern /</?[^>]+>/g, but it also remove some tags: b..., but I don't want it. i just want to remove div, br, p, table...
So could you give me some idea. Thanks.</p>
| 0debug
|
Currently very confused on the "working of classes" in c++, could anybody provide a intuitive explanation with examples? : <p>I'm new to programming and just started to learn the bare minimum in terms of c++, could anybody give a heads up and provide a intuitive and easy to understand explanation on "working classes" in c++ and the methods to use them in a program and incorporating "function" in the classes.<br>
any links to useful study material are also helpful and appreciated.</p>
| 0debug
|
static int a64_write_header(AVFormatContext *s)
{
AVCodecContext *avctx = s->streams[0]->codec;
uint8_t header[5] = {
0x00,
0x40,
0x00,
0x00,
0x00
};
if (avctx->extradata_size < 4) {
av_log(s, AV_LOG_ERROR, "Missing extradata\n");
return AVERROR(EINVAL);
}
switch (avctx->codec->id) {
case AV_CODEC_ID_A64_MULTI:
header[2] = 0x00;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 2;
break;
case AV_CODEC_ID_A64_MULTI5:
header[2] = 0x01;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 3;
break;
default:
return AVERROR(EINVAL);
}
avio_write(s->pb, header, 2);
return 0;
}
| 1threat
|
static uint64_t openpic_src_read(void *opaque, uint64_t addr, unsigned len)
{
OpenPICState *opp = opaque;
uint32_t retval;
int idx;
DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF) {
return retval;
}
addr = addr & 0xFFF0;
idx = addr >> 5;
if (addr & 0x10) {
retval = read_IRQreg_idr(opp, idx);
} else {
retval = read_IRQreg_ivpr(opp, idx);
}
DPRINTF("%s: => 0x%08x\n", __func__, retval);
return retval;
}
| 1threat
|
How to open the ImagePicker in SwiftUI? : <p>I need to open the ImagePicker in my app using SwiftUI, how can I do that?</p>
<p>I thought about using the UIImagePickerController, but I don't know how to do that in SwiftUI.</p>
| 0debug
|
Typescript: What's the difference between an optional field and a union with undefined? : <p>I want to define an interface with optional fields. I thought the following were synonymous.</p>
<p><code>(A)</code>:</p>
<pre><code>interface State {
userDetails: undefined | string | DataStructure | Error;
}
</code></pre>
<p><code>(B)</code>:</p>
<pre><code>interface State {
userDetails?: string | DataStructure | Error;
}
</code></pre>
<p>But when I go to initialise the state, <code>(A)</code> forces me to explicitly set the field as undefined, like so: </p>
<pre><code>static readonly initialAppState: AppState = {
userDetails: undefined
};
</code></pre>
<p>But with <code>(B)</code> I can just omit the field completely:</p>
<pre><code>static readonly initialAppState: AppState = { };
</code></pre>
<p>If I try to omit the field when using definition <code>(A)</code> Typescript will complain saying:</p>
<pre><code>Property 'userDetails' is missing in type
</code></pre>
<p>Why do I have to set the field explicitly when using definition <code>(A)</code>?
What's the difference between the two definitions that forces this different requirement when initialising?</p>
<p>Typesript version: 2.3.4</p>
| 0debug
|
static void kbd_write_command(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
KBDState *s = opaque;
DPRINTF("kbd: write cmd=0x%02" PRIx64 "\n", val);
if((val & KBD_CCMD_PULSE_BITS_3_0) == KBD_CCMD_PULSE_BITS_3_0) {
if(!(val & 1))
val = KBD_CCMD_RESET;
else
val = KBD_CCMD_NO_OP;
}
switch(val) {
case KBD_CCMD_READ_MODE:
kbd_queue(s, s->mode, 0);
break;
case KBD_CCMD_WRITE_MODE:
case KBD_CCMD_WRITE_OBUF:
case KBD_CCMD_WRITE_AUX_OBUF:
case KBD_CCMD_WRITE_MOUSE:
case KBD_CCMD_WRITE_OUTPORT:
s->write_cmd = val;
break;
case KBD_CCMD_MOUSE_DISABLE:
s->mode |= KBD_MODE_DISABLE_MOUSE;
break;
case KBD_CCMD_MOUSE_ENABLE:
s->mode &= ~KBD_MODE_DISABLE_MOUSE;
break;
case KBD_CCMD_TEST_MOUSE:
kbd_queue(s, 0x00, 0);
break;
case KBD_CCMD_SELF_TEST:
s->status |= KBD_STAT_SELFTEST;
kbd_queue(s, 0x55, 0);
break;
case KBD_CCMD_KBD_TEST:
kbd_queue(s, 0x00, 0);
break;
case KBD_CCMD_KBD_DISABLE:
s->mode |= KBD_MODE_DISABLE_KBD;
kbd_update_irq(s);
break;
case KBD_CCMD_KBD_ENABLE:
s->mode &= ~KBD_MODE_DISABLE_KBD;
kbd_update_irq(s);
break;
case KBD_CCMD_READ_INPORT:
kbd_queue(s, 0x80, 0);
break;
case KBD_CCMD_READ_OUTPORT:
kbd_queue(s, s->outport, 0);
break;
case KBD_CCMD_ENABLE_A20:
if (s->a20_out) {
qemu_irq_raise(*s->a20_out);
}
s->outport |= KBD_OUT_A20;
break;
case KBD_CCMD_DISABLE_A20:
if (s->a20_out) {
qemu_irq_lower(*s->a20_out);
}
s->outport &= ~KBD_OUT_A20;
break;
case KBD_CCMD_RESET:
qemu_system_reset_request();
break;
case KBD_CCMD_NO_OP:
break;
default:
fprintf(stderr, "qemu: unsupported keyboard cmd=0x%02x\n", (int)val);
break;
}
}
| 1threat
|
Change input border color if text is typed : <p>I think that Title of my question explains very well what i need. For example my code is</p>
<pre><code><head>
<style>
input{ border: 5px solid red;}
</style>
</head>
<div class="in">
<input class="input" type="text" name="text" method="post">
</div>
</code></pre>
<p>Now border is Red. I need to make it black if i will write text in it. Thanks</p>
| 0debug
|
Translate CSS to Javascript : <p>I current have this code:</p>
<pre><code>.mr15 > *
margin-right: 15px
&:last-child
margin-right: 0
</code></pre>
<p>How can I translate it to Javascript? And should I use JQuery or pure Javascript for this case? Thank you.</p>
| 0debug
|
static int init_report(const char *env)
{
const char *filename_template = "%p-%t.log";
char *key, *val;
int ret, count = 0;
time_t now;
struct tm *tm;
AVBPrint filename;
if (report_file)
return 0;
time(&now);
tm = localtime(&now);
while (env && *env) {
if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) {
if (count)
av_log(NULL, AV_LOG_ERROR,
"Failed to parse FFREPORT environment variable: %s\n",
av_err2str(ret));
break;
}
if (*env)
env++;
count++;
if (!strcmp(key, "file")) {
filename_template = val;
val = NULL;
} else {
av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key);
}
av_free(val);
av_free(key);
}
av_bprint_init(&filename, 0, 1);
expand_filename_template(&filename, filename_template, tm);
if (!av_bprint_is_complete(&filename)) {
av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n");
return AVERROR(ENOMEM);
}
report_file = fopen(filename.str, "w");
if (!report_file) {
av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
filename.str, strerror(errno));
return AVERROR(errno);
}
av_log_set_callback(log_callback_report);
av_log(NULL, AV_LOG_INFO,
"%s started on %04d-%02d-%02d at %02d:%02d:%02d\n"
"Report written to \"%s\"\n",
program_name,
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec,
filename.str);
av_log_set_level(FFMAX(av_log_get_level(), AV_LOG_VERBOSE));
av_bprint_finalize(&filename, NULL);
return 0;
}
| 1threat
|
Expand columns to see full jobname in Slurm : <p>Is it possible to expand the number of characters used in the <code>JobName</code> column of the command <code>sacct</code> in SLURM? </p>
<p>For example, I currently have:</p>
<pre><code> JobID JobName Elapsed NCPUS NTasks State
------------ ---------- ---------- ---------- -------- ----------
12345 lengthy_na+ 00:00:01 4 1 FAILED
</code></pre>
<p>and I would like:</p>
<pre><code> JobID JobName Elapsed NCPUS NTasks State
------------ ---------- ---------- ---------- -------- ----------
12345 lengthy_name 00:00:01 4 1 FAILED
</code></pre>
| 0debug
|
Linq methods for IAsyncEnumerable : <p>When working with an <code>IEnumerable<T></code> there are the build-in extension methods from the <code>System.Linq</code> namespace such as <code>Skip</code>, <code>Where</code> and <code>Select</code> to work with. </p>
<p>When Microsoft added <code>IAsyncEnumerable</code> in C#8 did they also add new Linq methods to support this?</p>
<p>I could of course implement these methods myself, or maybe find some package which does that, but I'd prefer to use a language-standard method if it exists.</p>
| 0debug
|
Spring Boot Executable Jar with Classpath : <p>I am building a software system to interact with an enterprise software system, using Spring Boot. My system depends on some jars and *.ini files from that enterprise system, so I cannot pack all dependencies in Maven. I would like to be able to run Spring Boot as Executable Jar with embedded Tomcat. I would also like to be able to set the classpath via the command line. So something like:</p>
<pre><code>java -classpath /home/sleeper/thirdparty/lib -jar MyApp.jar
</code></pre>
<p>However, -classpath and -jar cannot co-exist. I have tried "-Dloader.path". It was able to load all the jar files under the folder, but not other things, like *.ini files in the folder.</p>
<p>So is there a way we can make -classpath to work with an Spring executable jar with embedded Tomcat?</p>
<p>Thank you in advance for all the help.</p>
| 0debug
|
static uint64_t l2x0_priv_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
uint32_t cache_data;
l2x0_state *s = (l2x0_state *)opaque;
offset &= 0xfff;
if (offset >= 0x730 && offset < 0x800) {
return 0;
}
switch (offset) {
case 0:
return CACHE_ID;
case 0x4:
cache_data = (s->aux_ctrl & (7 << 17)) >> 15;
cache_data |= (s->aux_ctrl & (1 << 16)) >> 16;
return s->cache_type |= (cache_data << 18) | (cache_data << 6);
case 0x100:
return s->ctrl;
case 0x104:
return s->aux_ctrl;
case 0x108:
return s->tag_ctrl;
case 0x10C:
return s->data_ctrl;
case 0xC00:
return s->filter_start;
case 0xC04:
return s->filter_end;
case 0xF40:
return 0;
case 0xF60:
return 0;
case 0xF80:
return 0;
default:
fprintf(stderr, "l2x0_priv_read: Bad offset %x\n", (int)offset);
break;
}
return 0;
}
| 1threat
|
I'm new to this and i need help please <3 : <p>So basically when i run a command, the bot spams its response.</p>
<pre><code> bot.on('message', message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'embed':
const embed = new Discord.RichEmbed()
.setTitle('User Information')
.addField('Player Name', message.author.username)
.addField('Version', version)
.addField('Current Server', message.guild.name)
.setThumbnail(message.author.avatarURL)
.setFooter('Made By NotBanEvading')
message.channel.sendEmbed(embed);
break;
}
})
</code></pre>
<p><a href="https://gyazo.com/a1c71fc097e1253bc036d1ef293f034e" rel="nofollow noreferrer">https://gyazo.com/a1c71fc097e1253bc036d1ef293f034e</a></p>
| 0debug
|
How to print path to the current Zone in zone.js : <p>I'm experimenting with zones (<a href="https://github.com/angular/zone.js/" rel="noreferrer">zone.js</a>) and I realized I don't know what's the best way to print all the zones from root to the current zone that threw an error.</p>
<p>For example this code uses two nested callbacks with <code>setTimeout()</code> and then calls a function called <code>failedFunc()</code> that throws an error:</p>
<pre><code>require('zone.js');
function failedFunc() {
throw new Error("it's broken");
}
let rootZone = Zone.current;
function func1() {
let zoneA = rootZone.fork({name: 'zoneA'});
zoneA.run(() => {
setTimeout(() => func2());
});
}
function func2() {
let zoneB = Zone.current.fork({name: 'zoneB'});
zoneB.run(() => {
setTimeout(() => failedFunc());
});
}
func1();
</code></pre>
<p>When I run this example it gives the following output:</p>
<pre><code>/.../zone-test/node_modules/zone.js/dist/zone-node.js:170
throw error;
^
Error: it's broken
at new Error (native)
at failedFunc (/.../zone-test/zone_02.js:12:9) [zoneB]
at Timeout.setTimeout (/.../zone-test/zone_02.js:28:22) [zoneB]
at Zone.runTask (/.../zone-test/node_modules/zone.js/dist/zone-node.js:166:47) [<root> => zoneB]
at Timeout.ZoneTask.invoke (/.../zone-test/node_modules/zone.js/dist/zone-node.js:416:38) [<root>]
at Timeout.data.args.(anonymous function) [as _onTimeout] (/.../zone-test/node_modules/zone.js/dist/zone-node.js:1590:25) [<root>]
at ontimeout (timers.js:365:14) [<root>]
at tryOnTimeout (timers.js:237:5) [<root>]
at Timer.listOnTimeout (timers.js:207:5) [<root>]
</code></pre>
<p>The correct path for the zone that threw the error is <code><root></code> => <code>zoneA</code> => <code>zoneB</code>.</p>
<p>However it's not obvious from the output. There's just <code>[root]</code> and <code>zoneB</code> and it doesn't mention the <code>zoneA</code> which is confusing. I guess this is because the <code>zone.js</code>'s monkey patch only adds zone info to the lines in the call stack. So when I'm using <code>setTimeout()</code> than creating <code>zoneA</code> doesn't correspond to any line in the output and that's why I don't see it anywhere.</p>
<p>Nonetheless, I can print the path to the current zone by iterating all it's parents but this means I need to know where the error first happened and add the following code to it (which would be very tedious in practice):</p>
<pre><code>function failedFunc() {
let zone = Zone.current;
let zones = [];
while (zone) {
zones.push(zone.name);
zone = zone.parent;
}
console.log(zones);
throw new Error("it's broken");
}
// ...
</code></pre>
<p>Now when I run this I'll get what I need:</p>
<pre><code>[ 'zoneB', 'zoneA', '<root>' ]
/.../zone-test/node_modules/zone.js/dist/zone-node.js:170
throw error;
^
Error: it's broken
at new Error (native)
</code></pre>
<p>So I'm wondering how to use zone.js in practice and in a way that it's easier than this.</p>
| 0debug
|
i tried a program to remove common alphabets from character array in c language : void main()
{
int i, j, k,flag=1;
char key[10], keyword[10];
gets(key);
i=0;
j=0;
while(key[i]!='\0') {
k=0;
while(keyword[k]!='\0') {
if(key[i]==keyword[k]) {
i++;
flag=0;
break;
}
k++;
}
if(flag==1) {
keyword[j]=key[i];
j++;
i++;
}
flag=1;
}
}
Here i tried to copy unique alphabets from array to another array ..means duplicate alphabet should not copied in another array..it shows right output but along with that it shows some garbage values like smiley or something till the length of original input array(i.e.key[])
| 0debug
|
Difference between ObjC and Swift user desired function? : I am trying to dump the class and method names used in the iOS application. I found that in ObjC if I call the user defined function on button click. I am able to see both user defined functions and other functions used in the class;whereas, in swift I am only able to dump the class and button method name not user defined function.
Can anyone tell me what could be the reason of this? Is there any difference in the implementation of functions is objc and swift?
Thanks
| 0debug
|
static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
{
CPUX86State *env = &cpu->env;
FeatureWord w;
GList *l;
Error *local_err = NULL;
if (cpu->max_features) {
for (w = 0; w < FEATURE_WORDS; w++) {
env->features[w] =
x86_cpu_get_supported_feature_word(w, cpu->migratable);
}
}
for (l = plus_features; l; l = l->next) {
const char *prop = l->data;
object_property_set_bool(OBJECT(cpu), true, prop, &local_err);
if (local_err) {
goto out;
}
}
for (l = minus_features; l; l = l->next) {
const char *prop = l->data;
object_property_set_bool(OBJECT(cpu), false, prop, &local_err);
if (local_err) {
goto out;
}
}
if (!kvm_enabled() || !cpu->expose_kvm) {
env->features[FEAT_KVM] = 0;
}
x86_cpu_enable_xsave_components(cpu);
x86_cpu_adjust_feat_level(cpu, FEAT_7_0_EBX);
if (cpu->full_cpuid_auto_level) {
x86_cpu_adjust_feat_level(cpu, FEAT_1_EDX);
x86_cpu_adjust_feat_level(cpu, FEAT_1_ECX);
x86_cpu_adjust_feat_level(cpu, FEAT_6_EAX);
x86_cpu_adjust_feat_level(cpu, FEAT_7_0_ECX);
x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_EDX);
x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_ECX);
x86_cpu_adjust_feat_level(cpu, FEAT_8000_0007_EDX);
x86_cpu_adjust_feat_level(cpu, FEAT_C000_0001_EDX);
x86_cpu_adjust_feat_level(cpu, FEAT_SVM);
x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE);
if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) {
x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A);
}
}
if (env->cpuid_level == UINT32_MAX) {
env->cpuid_level = env->cpuid_min_level;
}
if (env->cpuid_xlevel == UINT32_MAX) {
env->cpuid_xlevel = env->cpuid_min_xlevel;
}
if (env->cpuid_xlevel2 == UINT32_MAX) {
env->cpuid_xlevel2 = env->cpuid_min_xlevel2;
}
out:
if (local_err != NULL) {
error_propagate(errp, local_err);
}
}
| 1threat
|
how create a neo4j data model from the relationla data format? : I've following row column data.
[Space Mood detail][1]
[1]: https://i.stack.imgur.com/HrBbn.png
How can I model this into neo4j ?
| 0debug
|
static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 3%1, %%mm3\n\t"
"punpckldq 6%1, %%mm0\n\t"
"punpckldq 9%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 12;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int r= *s++;
const int g= *s++;
const int b= *s++;
*d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
}
}
| 1threat
|
static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off)
{
seekdir(fs->dir, off);
}
| 1threat
|
static void hybrid6_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int len)
{
int i, j, ssb;
int N = 8;
float temp[8][2];
for (i = 0; i < len; i++, in++) {
for (ssb = 0; ssb < N; ssb++) {
float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1];
for (j = 0; j < 6; j++) {
float in0_re = in[j][0];
float in0_im = in[j][1];
float in1_re = in[12-j][0];
float in1_im = in[12-j][1];
sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im);
sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re);
}
temp[ssb][0] = sum_re;
temp[ssb][1] = sum_im;
}
out[0][i][0] = temp[6][0];
out[0][i][1] = temp[6][1];
out[1][i][0] = temp[7][0];
out[1][i][1] = temp[7][1];
out[2][i][0] = temp[0][0];
out[2][i][1] = temp[0][1];
out[3][i][0] = temp[1][0];
out[3][i][1] = temp[1][1];
out[4][i][0] = temp[2][0] + temp[5][0];
out[4][i][1] = temp[2][1] + temp[5][1];
out[5][i][0] = temp[3][0] + temp[4][0];
out[5][i][1] = temp[3][1] + temp[4][1];
}
}
| 1threat
|
Hibernate multiple connections dynamically changing : <p>I know there are similar questions about this scenario, however none of them I have found matches my case and I'll like to have a solution that doesn't impact performance. I have to do multiple connections to different databases (all postgresql) and the problem is that the databases can be many as they are continuously being created. </p>
<p>At the moment I will only have one known database which will be used to store the connection strings from the other databases. These databases can be 1, 2, 5, 10 or N, the tricky part is that from my end I'll never know how many they will be and what their location and credentials will be (all stored on my central DB). The use case works in a way where in order to do an operation on one of these databases, I have to first fetch from the central database the location for the DB we need and then perform the operation. </p>
<p>At the moment, I have been able to perform the operation by sing SessionFactory, but the operation is too slow even for a simple select/update, and my concern is that when multiple requests are made, we might get from Hibernate an Out of Memory Exception.</p>
<p>Any ideas on what would be the best approach for this case?</p>
| 0debug
|
Chart.js: Bar Chart Click Events : <p>I've just started working with Chart.js, and I am getting very frustrated very quickly. I have my stacked bar chart working, but I can't get the click "events" to work.</p>
<p>I have found a <a href="https://github.com/chartjs/Chart.js/issues/577#issuecomment-55897221">comment on GitHub by <code>nnnick</code></a> from Chart.js stating to use the function <code>getBarsAtEvent</code>, even though this function cannot be found in the <a href="http://www.chartjs.org/docs/#bar-chart-chart-options">Chart.js documentation</a> at all (go ahead, do a search for it). The documentation does mention the <code>getElementsAtEvent</code> function of the <code>chart</code> reference, but that is for Line Charts only.</p>
<p>I set an event listener (the right way) on my canvas element:</p>
<pre><code>canv.addEventListener('click', handleClick, false);
</code></pre>
<p>...yet in my <code>handleClick</code> function, <code>chart.getBarsAtEvent</code> is undefined!</p>
<p>Now, in the Chart.js document, there is a statement about a different way to register the click event for the bar chart. It is much different than <code>nnnick</code>'s comment on GitHub from 2 years ago.</p>
<p>In the <a href="http://www.chartjs.org/docs/#getting-started-global-chart-configuration">Global Chart Defaults</a> you can set an <code>onClick</code> function for your chart. I added an <code>onClick</code> function to my chart configuration, and it did nothing...</p>
<p>So, how the heck do I get the on-click-callback to work for my bar chart?!</p>
<p>Any help would be greatly appreciated. Thanks!</p>
<p><strong>P.S.:</strong> I am not using the master build from GitHub. I tried, but it kept screaming that <code>require is undefined</code> and I was not ready to include CommonJS just so that I could use this chart library. I would rather write my own dang charts. Instead, I downloaded and am using the <a href="https://raw.githubusercontent.com/nnnick/Chart.js/v2.0-dev/dist/Chart.js"><strong>Standard Build</strong></a> version that I downloaded straight from the link at the top of the <a href="http://www.chartjs.org/docs/">documentation page</a>.</p>
<p><strong>EXAMPLE:</strong> Here is an example of the configuration I am using:</p>
<pre><code>var chart_config = {
type: 'bar',
data: {
labels: ['One', 'Two', 'Three'],
datasets: [
{
label: 'Dataset 1',
backgroundColor: '#848484',
data: [4, 2, 6]
},
{
label: 'Dataset 2',
backgroundColor: '#848484',
data: [1, 6, 3]
},
{
label: 'Dataset 3',
backgroundColor: '#848484',
data: [7, 5, 2]
}
]
},
options: {
title: {
display: false,
text: 'Stacked Bars'
},
tooltips: {
mode: 'label'
},
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [
{
stacked: true
}
],
yAxes: [
{
stacked: true
}
]
},
onClick: handleClick
}
};
</code></pre>
| 0debug
|
how to fix qr scanner is not scanning qr codes : Hello guys can someone help me.
Im trying to create an android app that can scan qr codes. But the problem is, it only autofocus on the qr code but not returning any results. Is there a way to fix this?
Im using zxing libraries
| 0debug
|
Looking for a regex that matches apostrophe within string and not outside : I'm looking for a python regex that can match `'didn't'` returning only `'t` and not `'d` and `t'`
| 0debug
|
static void gen_b(DisasContext *ctx)
{
target_ulong li, target;
ctx->exception = POWERPC_EXCP_BRANCH;
#if defined(TARGET_PPC64)
if (ctx->sf_mode)
li = ((int64_t)LI(ctx->opcode) << 38) >> 38;
else
#endif
li = ((int32_t)LI(ctx->opcode) << 6) >> 6;
if (likely(AA(ctx->opcode) == 0))
target = ctx->nip + li - 4;
else
target = li;
if (LK(ctx->opcode))
gen_setlr(ctx, ctx->nip);
gen_goto_tb(ctx, 0, target);
}
| 1threat
|
how to get a free search API for meta search engine in C# : <p>I want to write a meta search engine in C# for that I Need search API from 2 search engines,I have already got google's API,I wanted to use Bing API but it seems that they don't support this service anymore.do yo know any other search engines that I could get its search API for free?</p>
| 0debug
|
Firebase Token Authentication error : <p>I am using firebase storage to upload files , but when I upload I am getting this error</p>
<pre><code>E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.android.gms.internal.zzand: Please sign in before trying to get a token.
</code></pre>
<p>I googled it but couldn't get answer for it!
I have signed in, in firebase.</p>
| 0debug
|
void av_set_cpu_flags_mask(int mask)
{
cpu_flags = get_cpu_flags() & mask;
}
| 1threat
|
ITMS-90682: "Invalid Bundle. : <p>Today I update my Xcode vision to 8.0. When I submit a app.ipa file to Apple store,i get an error feedback that ITMS-90682: "Invalid Bundle. The asset catalog at '$path' can't contain 16-bit or P3 assets if the app is targeting iOS releases earlier than iOS 9.3."].</p>
<p>I search the answer on the Internet and get a similar answer,but it not fit.</p>
<p>Because their question is not completely the same as mine.Their question contain 'Payload/****.app/Assets.car' ,but mine contain '$path'.</p>
<p>Their method is as follows:</p>
<p>First step : modify the file' name of app.ipa to app.zip </p>
<p>Second step : decompressing app.zip</p>
<p>Third step : undo command line and $ cd app.app file</p>
<p>Forth step: $ find . -name 'Assets.car'</p>
<p>Fifth step : $ sudo xcrun --sdk iphoneos assetutil --info /path/to/a/Assets.car > /tmp/Assets.json</p>
<p>Sixth step : open /tmp/Assets.json</p>
<p>Seventh step : search "P3" and "16-bit" in file named "Assets.json"</p>
<p>Eighth step : record the "Name"</p>
<p>Ninth step : open Xcode and find out the image that names have been record in eighth step. change the image form to 8 and sRGB </p>
<p>These are not use for mine ,because the different is "$path".i can't get the name of imaged which form is P3 or 16-bit in my project because i can't get a right method to get a property Assets.json file on fifth step. </p>
| 0debug
|
static ssize_t nic_receive(VLANClientState *nc, const uint8_t * buf, size_t size)
{
EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
uint16_t rfd_status = 0xa000;
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
if (s->configuration[20] & BIT(6)) {
missing("Multiple IA bit");
return -1;
}
if (s->configuration[8] & 0x80) {
logout("%p received while CSMA is disabled\n", s);
return -1;
} else if (size < 64 && (s->configuration[7] & BIT(0))) {
logout("%p received short frame (%zu byte)\n", s, size);
s->statistics.rx_short_frame_errors++;
#if 0
return -1;
#endif
} else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & BIT(3))) {
logout("%p received long frame (%zu byte), ignored\n", s, size);
return -1;
} else if (memcmp(buf, s->conf.macaddr.a, 6) == 0) {
TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size));
} else if (memcmp(buf, broadcast_macaddr, 6) == 0) {
TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size));
rfd_status |= 0x0002;
} else if (buf[0] & 0x01) {
TRACE(RXTX, logout("%p received multicast, len=%zu,%s\n", s, size, nic_dump(buf, size)));
if (s->configuration[21] & BIT(3)) {
} else {
unsigned mcast_idx = compute_mcast_idx(buf);
assert(mcast_idx < 64);
if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) {
} else if (s->configuration[15] & BIT(0)) {
rfd_status |= 0x0004;
} else {
TRACE(RXTX, logout("%p multicast ignored\n", s));
return -1;
}
}
rfd_status |= 0x0002;
} else if (s->configuration[15] & BIT(0)) {
TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size));
rfd_status |= 0x0004;
} else {
TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size,
nic_dump(buf, size)));
return size;
}
if (get_ru_state(s) != ru_ready) {
logout("no resources, state=%u\n", get_ru_state(s));
eepro100_rnr_interrupt(s);
s->statistics.rx_resource_errors++;
#if 0
assert(!"no resources");
#endif
return -1;
}
eepro100_rx_t rx;
cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx,
offsetof(eepro100_rx_t, packet));
uint16_t rfd_command = le16_to_cpu(rx.command);
uint16_t rfd_size = le16_to_cpu(rx.size);
if (size > rfd_size) {
logout("Receive buffer (%" PRId16 " bytes) too small for data "
"(%zu bytes); data truncated\n", rfd_size, size);
size = rfd_size;
}
if (size < 64) {
rfd_status |= 0x0080;
}
TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
rfd_command, rx.link, rx.rx_buf_addr, rfd_size));
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status),
rfd_status);
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size);
#if 0
eepro100_er_interrupt(s);
#endif
if (s->configuration[18] & BIT(2)) {
missing("Receive CRC Transfer");
return -1;
}
#if 0
assert(!(s->configuration[17] & BIT(0)));
#endif
cpu_physical_memory_write(s->ru_base + s->ru_offset +
offsetof(eepro100_rx_t, packet), buf, size);
s->statistics.rx_good_frames++;
eepro100_fr_interrupt(s);
s->ru_offset = le32_to_cpu(rx.link);
if (rfd_command & COMMAND_EL) {
logout("receive: Running out of frames\n");
set_ru_state(s, ru_suspended);
}
if (rfd_command & COMMAND_S) {
set_ru_state(s, ru_suspended);
}
return size;
}
| 1threat
|
Android keyboard language matching person : Since I am living abroad I often find myself writing to people in different languages. Every time I have to switch to the correct language to avoid false autocorrection. However the language only depends on the person I am talking to, that is I will always talk in italian to `a`, `b` and `c`; in english to `l` and `m`; in french with `x`. Is there a keyboard that keeps track of that?
| 0debug
|
The Button Next and Previous in My project is not working as expected, Fault is in my Coding but not understanding : My project on Android is to make a table generator
It works fine until the next and previous Button
like If i input 5 to generate table of 5 , it worked fine
but when i click next the table change to 6 but then no increment
and on previous the table directly shown is of 4 instead of 5 and then no more decrements.
Help needed to solve this problem
Thanks in Advance
| 0debug
|
static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
const float *coefs, const FFPsyWindowInfo *wi)
{
AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
AacPsyChannel *pch = &pctx->ch[channel];
int i, w, g;
float desired_bits, desired_pe, delta_pe, reduction= NAN, spread_en[128] = {0};
float a = 0.0f, active_lines = 0.0f, norm_fac = 0.0f;
float pe = pctx->chan_bitrate > 32000 ? 0.0f : FFMAX(50.0f, 100.0f - pctx->chan_bitrate * 100.0f / 32000.0f);
const int num_bands = ctx->num_bands[wi->num_windows == 8];
const uint8_t *band_sizes = ctx->bands[wi->num_windows == 8];
AacPsyCoeffs *coeffs = pctx->psy_coef[wi->num_windows == 8];
const float avoid_hole_thr = wi->num_windows == 8 ? PSY_3GPP_AH_THR_SHORT : PSY_3GPP_AH_THR_LONG;
calc_thr_3gpp(wi, num_bands, pch, band_sizes, coefs);
for (w = 0; w < wi->num_windows*16; w += 16) {
AacPsyBand *bands = &pch->band[w];
spread_en[0] = bands[0].energy;
for (g = 1; g < num_bands; g++) {
bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]);
spread_en[w+g] = FFMAX(bands[g].energy, spread_en[w+g-1] * coeffs[g].spread_hi[1]);
}
for (g = num_bands - 2; g >= 0; g--) {
bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]);
spread_en[w+g] = FFMAX(spread_en[w+g], spread_en[w+g+1] * coeffs[g].spread_low[1]);
}
for (g = 0; g < num_bands; g++) {
AacPsyBand *band = &bands[g];
band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);
if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w)))
band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr,
PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
pe += calc_pe_3gpp(band);
a += band->pe_const;
active_lines += band->active_lines;
if (spread_en[w+g] * avoid_hole_thr > band->energy || coeffs[g].min_snr > 1.0f)
band->avoid_holes = PSY_3GPP_AH_NONE;
else
band->avoid_holes = PSY_3GPP_AH_INACTIVE;
}
}
ctx->ch[channel].entropy = pe;
desired_bits = calc_bit_demand(pctx, pe, ctx->bitres.bits, ctx->bitres.size, wi->num_windows == 8);
desired_pe = PSY_3GPP_BITS_TO_PE(desired_bits);
if (ctx->bitres.bits > 0)
desired_pe *= av_clipf(pctx->pe.previous / PSY_3GPP_BITS_TO_PE(ctx->bitres.bits),
0.85f, 1.15f);
pctx->pe.previous = PSY_3GPP_BITS_TO_PE(desired_bits);
if (desired_pe < pe) {
for (w = 0; w < wi->num_windows*16; w += 16) {
reduction = calc_reduction_3gpp(a, desired_pe, pe, active_lines);
pe = 0.0f;
a = 0.0f;
active_lines = 0.0f;
for (g = 0; g < num_bands; g++) {
AacPsyBand *band = &pch->band[w+g];
band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction);
pe += calc_pe_3gpp(band);
a += band->pe_const;
active_lines += band->active_lines;
}
}
for (i = 0; i < 2; i++) {
float pe_no_ah = 0.0f, desired_pe_no_ah;
active_lines = a = 0.0f;
for (w = 0; w < wi->num_windows*16; w += 16) {
for (g = 0; g < num_bands; g++) {
AacPsyBand *band = &pch->band[w+g];
if (band->avoid_holes != PSY_3GPP_AH_ACTIVE) {
pe_no_ah += band->pe;
a += band->pe_const;
active_lines += band->active_lines;
}
}
}
desired_pe_no_ah = FFMAX(desired_pe - (pe - pe_no_ah), 0.0f);
if (active_lines > 0.0f)
reduction += calc_reduction_3gpp(a, desired_pe_no_ah, pe_no_ah, active_lines);
pe = 0.0f;
for (w = 0; w < wi->num_windows*16; w += 16) {
for (g = 0; g < num_bands; g++) {
AacPsyBand *band = &pch->band[w+g];
if (active_lines > 0.0f)
band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction);
pe += calc_pe_3gpp(band);
band->norm_fac = band->active_lines / band->thr;
norm_fac += band->norm_fac;
}
}
delta_pe = desired_pe - pe;
if (fabs(delta_pe) > 0.05f * desired_pe)
break;
}
if (pe < 1.15f * desired_pe) {
norm_fac = 1.0f / norm_fac;
for (w = 0; w < wi->num_windows*16; w += 16) {
for (g = 0; g < num_bands; g++) {
AacPsyBand *band = &pch->band[w+g];
if (band->active_lines > 0.5f) {
float delta_sfb_pe = band->norm_fac * norm_fac * delta_pe;
float thr = band->thr;
thr *= exp2f(delta_sfb_pe / band->active_lines);
if (thr > coeffs[g].min_snr * band->energy && band->avoid_holes == PSY_3GPP_AH_INACTIVE)
thr = FFMAX(band->thr, coeffs[g].min_snr * band->energy);
band->thr = thr;
}
}
}
} else {
g = num_bands;
while (pe > desired_pe && g--) {
for (w = 0; w < wi->num_windows*16; w+= 16) {
AacPsyBand *band = &pch->band[w+g];
if (band->avoid_holes != PSY_3GPP_AH_NONE && coeffs[g].min_snr < PSY_SNR_1DB) {
coeffs[g].min_snr = PSY_SNR_1DB;
band->thr = band->energy * PSY_SNR_1DB;
pe += band->active_lines * 1.5f - band->pe;
}
}
}
}
}
for (w = 0; w < wi->num_windows*16; w += 16) {
for (g = 0; g < num_bands; g++) {
AacPsyBand *band = &pch->band[w+g];
FFPsyBand *psy_band = &ctx->ch[channel].psy_bands[w+g];
psy_band->threshold = band->thr;
psy_band->energy = band->energy;
}
}
memcpy(pch->prev_band, pch->band, sizeof(pch->band));
}
| 1threat
|
static int con_init(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
char *type, *dom;
int ret = 0;
dom = xs_get_domain_path(xenstore, con->xendev.dom);
snprintf(con->console, sizeof(con->console), "%s/console", dom);
free(dom);
type = xenstore_read_str(con->console, "type");
if (!type || strcmp(type, "ioemu") != 0) {
xen_be_printf(xendev, 1, "not for me (type=%s)\n", type);
ret = -1;
goto out;
}
if (!serial_hds[con->xendev.dev])
xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n",
con->xendev.dev);
else
con->chr = serial_hds[con->xendev.dev];
out:
qemu_free(type);
return ret;
}
| 1threat
|
Why does method inheritance kill additional arguments? : <p>I want to set some flags in my generic (<em>before</em> calling <code>UseMethod()</code>, I know that much :)), and then use and/or update these flags in the methods.</p>
<p>Like so:</p>
<pre><code>g <- function(x) {
y <- 10
UseMethod("g")
}
g.default <- function(x) {
c(x = x, y = y)
}
g.a <- function(x) {
y <- 5 # update y from generic here
NextMethod()
}
</code></pre>
<p>This works when jumping directly to the default method:</p>
<pre><code>g(structure(.Data = 1, class = "c")) # here y is never updated
# x y
# 1 10
</code></pre>
<p>But when I go through <code>NextMethod()</code>, <code>y</code> mysteriously disappears:</p>
<pre><code>g(structure(.Data = 1, class = "a")) # here y is updated, but cannot be found
# Error in g.default(structure(.Data = 1, class = "a")) :
# object 'y' not found
</code></pre>
<p>I <em>have</em> figured out how to fix this, by just passing around <code>y</code> a lot:</p>
<pre><code>f <- function(x, ...) {
y <- 10
UseMethod("f")
}
f.default <- function(x, ..., y = 3) {
c(x = x, y = y)
}
f.a <- function(x, ...) {
y <- 5
NextMethod(y = y)
}
</code></pre>
<p>which yields</p>
<pre><code>f(structure(.Data = 1, class = "c"))
# x y
# 1 3
f(structure(.Data = 1, class = "a"))
# x y
# 1 5
</code></pre>
<p>My question is: <strong><em>Why</em> does <code>NextMethod()</code> in the above <code>g().*</code>-example kill the additional <code>y</code> argument</strong>?</p>
<p>I thought the whole point of <code>UseMethod()</code> and <code>NextMethod()</code> was to pass on any and all objects from call to call, <em>without</em> having to manually pass them on:</p>
<blockquote>
<p>NextMethod works by creating a special call frame for the next method. If no new arguments are supplied, the arguments will be the same in number, order and name as those to the current method but their values will be promises to evaluate their name in the current method and environment.</p>
<ul>
<li><a href="https://www.rdocumentation.org/packages/base/versions/3.4.3/topics/UseMethod" rel="noreferrer"><code>help("UseMethod")</code></a></li>
</ul>
</blockquote>
<p>I'm particularly confused that <code>UseMethod()</code> does seem to pass on <code>y</code>, but <code>NextMethod()</code> doesn't. </p>
| 0debug
|
aio_read_f(int argc, char **argv)
{
int nr_iov, c;
struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));
BlockDriverAIOCB *acb;
while ((c = getopt(argc, argv, "CP:qv")) != EOF) {
switch (c) {
case 'C':
ctx->Cflag = 1;
break;
case 'P':
ctx->Pflag = 1;
ctx->pattern = atoi(optarg);
break;
case 'q':
ctx->qflag = 1;
break;
case 'v':
ctx->vflag = 1;
break;
default:
free(ctx);
return command_usage(&aio_read_cmd);
}
}
if (optind > argc - 2) {
free(ctx);
return command_usage(&aio_read_cmd);
}
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
free(ctx);
return 0;
}
optind++;
if (ctx->offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)ctx->offset);
free(ctx);
return 0;
}
nr_iov = argc - optind;
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab);
gettimeofday(&ctx->t1, NULL);
acb = bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov,
ctx->qiov.size >> 9, aio_read_done, ctx);
if (!acb) {
free(ctx->buf);
free(ctx);
return -EIO;
}
return 0;
}
| 1threat
|
static int vda_h264_end_frame(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
VDAContext *vda = avctx->internal->hwaccel_priv_data;
AVVDAContext *vda_ctx = avctx->hwaccel_context;
AVFrame *frame = h->cur_pic_ptr->f;
uint32_t flush_flags = 1 << 0;
CFDataRef coded_frame;
OSStatus status;
if (!vda->bitstream_size)
return AVERROR_INVALIDDATA;
coded_frame = CFDataCreate(kCFAllocatorDefault,
vda->bitstream,
vda->bitstream_size);
status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, NULL);
if (status == kVDADecoderNoErr)
status = VDADecoderFlush(vda_ctx->decoder, flush_flags);
CFRelease(coded_frame);
if (!vda->frame)
return AVERROR_UNKNOWN;
if (status != kVDADecoderNoErr) {
av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
return AVERROR_UNKNOWN;
}
av_buffer_unref(&frame->buf[0]);
frame->buf[0] = av_buffer_create((uint8_t*)vda->frame,
sizeof(vda->frame),
release_buffer, NULL,
AV_BUFFER_FLAG_READONLY);
if (!frame->buf)
return AVERROR(ENOMEM);
frame->data[3] = (uint8_t*)vda->frame;
vda->frame = NULL;
return 0;
}
| 1threat
|
static void jpeg_term_destination(j_compress_ptr cinfo)
{
VncState *vs = cinfo->client_data;
Buffer *buffer = &vs->tight_jpeg;
buffer->offset = buffer->capacity - cinfo->dest->free_in_buffer;
}
| 1threat
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
count word strings on external website : <p>I am looking for a way to count word strings on a 3rd party site and then report it into an html generated page on a daily schedule.</p>
<p>So goes to www.bbc.co.uk - counts the incidents of the word "balloon" and reports this back into the page.</p>
<p>I'm not a coder really, html and css fine, some minor PHP, but everything else eludes me (probably why I've gone into digital marketing away from web dev over the years)</p>
<p>cheers for any help given</p>
| 0debug
|
static void tcg_out_jxx(TCGContext *s, int opc, int label_index, int small)
{
int32_t val, val1;
TCGLabel *l = &s->labels[label_index];
if (l->has_value) {
val = tcg_pcrel_diff(s, l->u.value_ptr);
val1 = val - 2;
if ((int8_t)val1 == val1) {
if (opc == -1) {
tcg_out8(s, OPC_JMP_short);
} else {
tcg_out8(s, OPC_JCC_short + opc);
}
tcg_out8(s, val1);
} else {
if (small) {
tcg_abort();
}
if (opc == -1) {
tcg_out8(s, OPC_JMP_long);
tcg_out32(s, val - 5);
} else {
tcg_out_opc(s, OPC_JCC_long + opc, 0, 0, 0);
tcg_out32(s, val - 6);
}
}
} else if (small) {
if (opc == -1) {
tcg_out8(s, OPC_JMP_short);
} else {
tcg_out8(s, OPC_JCC_short + opc);
}
tcg_out_reloc(s, s->code_ptr, R_386_PC8, label_index, -1);
s->code_ptr += 1;
} else {
if (opc == -1) {
tcg_out8(s, OPC_JMP_long);
} else {
tcg_out_opc(s, OPC_JCC_long + opc, 0, 0, 0);
}
tcg_out_reloc(s, s->code_ptr, R_386_PC32, label_index, -4);
s->code_ptr += 4;
}
}
| 1threat
|
jenkins escape sed command : <p>Can someone escape this sed shell command in Jenkins groovy script for me?</p>
<p>So hard.</p>
<pre><code>sh ("""
sed "s/(AssemblyInformationalVersion\(\")(.*)(\")/\1${productVersion}\3/g"
AssemblyInfoGlobal/AssemblyInfoGlobal.cs -r
""")
</code></pre>
| 0debug
|
Should I prefer MonadUnliftIO or MonadMask for bracketting like functions? : <p>I'm currently building a new API, and one of the functions it currently provides is:</p>
<pre><code>inSpan :: Tracer -> Text -> IO a -> IO a
</code></pre>
<p>I'm looking to move that <code>Tracer</code> into a monad, giving me a signature more like</p>
<pre><code>inSpan :: MonadTracer m => Text -> m a -> m a
</code></pre>
<p>The implementation of <code>inSpan</code> uses <code>bracket</code>, which means I have two main options:</p>
<pre><code>class MonadUnliftIO m => MonadTracer m
</code></pre>
<p>or</p>
<pre><code>class MonadMask m => MonadTracer m
</code></pre>
<p>But which should I prefer? Note that I'm in control of all the types I've mentioned, which makes me slightly lean towards <code>MonadMask</code> as it doesn't enforce <code>IO</code> at the bottom (that is, we could perhaps have a pure <code>MonadTracer</code> instance).</p>
<p>Is there anything else I should consider?</p>
| 0debug
|
Why does Typescript ignore my tsconfig.json inside Visual Studio Code? : <p>I got my project setup like this</p>
<pre><code>project/
|
+---src/
| |
| +---app/
| |
| sample.ts
|
+---typings/
+---tsconfig.json
</code></pre>
<p>and here's my <code>tsconfig.json</code></p>
<pre><code>{
"compilerOptions": {
"rootDir": "src",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"sourceMap": true,
"noImplicitAny": false,
"outDir": "dist"
},
"exclude": [
"node_modules",
"src/assets",
"src/lib"
]
}
</code></pre>
<p>What I'm wondering is, why does VSC indicate errors such as</p>
<p><a href="https://i.stack.imgur.com/m10Sk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m10Sk.png" alt="Error Highlighting in VSC"></a></p>
<p>when clearly there is no error at all (<code>"experimentalDecorators": true</code> is set in <code>tsconfig.json</code>), and the app transpiles just fine? And it's not just decorators, <code>Promise</code> and the like is highlighted as well (I made sure to have <code>tsconfig.json</code> in the same folder as <code>typings</code> and I got the typings for <code>es6-shim</code> installed).</p>
<p>Not sure if it matters, but I'm on <code>typescript@2.0.0-dev.20160707</code> at the moment. </p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.