problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to make array in JSON ? : Here, I want to a make array of requests in the below code so, I want to store multiple images in that requests until the for loops terminate. How could I do that ?
> Blockquote
for($i = 0; $i < 5; $i++)
{
$imageName = __DIR__.'/uploads/'.$i.time().'.png';
$data= file_get_contents($imageName);
$base64 = base64_encode($data);
$type = 'TEXT_DETECTION';
$request_json[] = '
{
"requests": [
{
"image": {
"content":"' . $base64 . '"
},
"features": [
{
"type": "' . $type . '",
"maxResults": 200
}
]
}
]
}';
}
Please Help me.
Thanks in Advance.
| 0debug
|
Unable to merge dex error : <p>This is my app build.gradle file
<a href="https://i.stack.imgur.com/kKH77.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kKH77.png" alt="enter image description here"></a></p>
<p>It shows error in the appcompat dependecy file. I tried clean project and build project and so many ways but still the error shows. This is my error when i run project.</p>
<p>**Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.</p>
<blockquote>
<p>java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex**</p>
</blockquote>
| 0debug
|
Remove Daemonset pod from a node : <p>I have a running <code>DaemonSet</code> which is running on all nodes. I want to remove it from a node in order to completely drain it, as <code>kubectl drain</code> doesn't get rid of them. Without deleting my <code>DaemonSet</code>, what's a good way to temporarily remove those pods from the node? I've tried draining it and deleting the <code>DaemonSet</code> pods, but the <code>DaemonSet</code> will still reschedule them, disregarding that the node is set as <code>Unschedulable: true</code>.</p>
| 0debug
|
Prevent bootstrap form to submut with "Enter" : I can not prevent the form to submit if the user press `ENTER` on an input. I found [that way](https://stackoverflow.com/questions/895171/prevent-users-from-submitting-a-form-by-hitting-enter) but I have some taginputs that need to trigger the `ENTER` key to allow free values.
Here is a snippet with the code.
**Q: How can I prevent the `ENTER` key to submit my form without broke the taginputs ?**
**Q+ : can someone explain me why `$event.keyCode == 13` in my `preventSubmitOnKey` function, whereas it is `undefined` in my `submitForm` function ?**
Thanks a lot in advance!
<!-- begin snippet: js hide: true console: true babel: false -->
<!-- language: lang-js -->
$(document).ready(function() {
// I can not use that
//$('#myForm').on('keydown', preventSubmitOnKey);
$('#myForm').on('submit', submitForm);
});
function preventSubmitOnKey($event) {
console.log('key pressed!', $event.keyCode); // show 13 on 'ENTER'
if ($event.keyCode == 13) {
$event.preventDefault();
}
}
function submitForm($event) {
let invalidForm = false;
$event.preventDefault(); // Don't refresh the page
console.log('key', $event.charCode, $event.keyCode); // show 'undefined' ..
let key = $event.charCode || $event.keyCode || 0;
if (key == 13) {
$event.stopPropagation();
return;
}
const $form = $(this);
$form.addClass('was-validated');
if (!this.checkValidity()) {
$event.stopPropagation();
return;
}
// some other process...
const data = {
client: $form.find('#clientList').val(),
firstname: $form.find('#contactFirstname').val(),
lastname: $form.find('#contactLastname').val(),
}
console.log('Submitting', data);
// call my own API
}
<!-- language: lang-css -->
/**
* up/down arrow devant les collapse
*/
[data-toggle="collapse"] .fas:before {
content: "\f139";
margin-right: 5px;
}
[data-toggle="collapse"].collapsed .fas:before {
content: "\f13a";
}
/**
* Override Bootstrap CSS : ".btn" et "button"
* -> text-align: center;
*/
legend>[data-toggle="collapse"] {
text-align: left;
width: 100%;
}
<!-- language: lang-html -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/css/all.min.css" integrity="sha256-4w9DunooKSr3MFXHXWyFER38WmPdm361bQS/2KUWZbU=" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js" integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm" crossorigin="anonymous"></script>
<form id="myForm" novalidate="novalidate">
<fieldsed class="contactInfo">
<legend>
<button class="btn actilan-test" type="button" data-toggle="collapse" data-target="#contactCollapse" aria-expanded="true" aria-controls="contactCollapse"><i class="fas" aria-hidden="true"></i>Contact</button>
</legend>
<div class="collapse show" id="contactCollapse" data-parent="#myForm">
<div class="input-group input-group-sm mb-1">
<div class="input-group-prepend"><span class="input-group-text" id="clientListLabel">Client</span></div>
<select class="custom-select" id="clientList" name="client" aria-describedby="clientListLabel">
<option value="1">One</option>
<option value="2" selected="selected">Two</option>
</select>
<div class="input-group-append">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="dropdownMenuButton">Mode</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<button class="dropdown-item" type="button" id="btnAuto" disabled="disabled">Auto</button>
<button class="dropdown-item" type="button" id="btnManuel">Manuel</button>
</div>
</div>
</div>
<div class="input-group input-group-sm mb-1">
<div class="input-group-prepend"><span class="input-group-text" id="contactFullnameLabel">Nom et Prénom</span></div>
<input class="form-control" type="text" id="contactFirstname" name="contactFirstname" aria-label="Contact firstname" aria-describedby="contactFullnameLabel" placeholder="Prénom" required="required">
<input class="form-control" type="text" id="contactLastname" name="contactLastname" aria-label="Contact lastname" aria-describedby="contactFullnameLabel" placeholder="Nom" required="required">
<div class="input-group-append">
<button class="btn btn-danger" type="button" id="btnCancelContact"><i class="fas fa-user-minus"></i></button>
</div>
<div class="invalid-feedback">Ce champ doit contenir une valeur</div>
</div>
</div>
</fieldsed>
<button class="btn btn-success mb-3" type="submit" id="btnSubmit" value="Submit!">Envoyer</button>
</form>
<!-- end snippet -->
| 0debug
|
static void musicpal_init(MachineState *machine)
{
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
ARMCPU *cpu;
qemu_irq pic[32];
DeviceState *dev;
DeviceState *i2c_dev;
DeviceState *lcd_dev;
DeviceState *key_dev;
DeviceState *wm8750_dev;
SysBusDevice *s;
I2CBus *i2c;
int i;
unsigned long flash_size;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
if (!cpu_model) {
cpu_model = "arm926";
}
cpu = cpu_arm_init(cpu_model);
if (!cpu) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
memory_region_init_ram(ram, NULL, "musicpal.ram", MP_RAM_DEFAULT_SIZE,
&error_abort);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space_mem, 0, ram);
memory_region_init_ram(sram, NULL, "musicpal.sram", MP_SRAM_SIZE,
&error_abort);
vmstate_register_ram_global(sram);
memory_region_add_subregion(address_space_mem, MP_SRAM_BASE, sram);
dev = sysbus_create_simple(TYPE_MV88W8618_PIC, MP_PIC_BASE,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
sysbus_create_varargs(TYPE_MV88W8618_PIT, MP_PIT_BASE, pic[MP_TIMER1_IRQ],
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
pic[MP_TIMER4_IRQ], NULL);
if (serial_hds[0]) {
serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ],
1825000, serial_hds[0], DEVICE_NATIVE_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ],
1825000, serial_hds[1], DEVICE_NATIVE_ENDIAN);
}
dinfo = drive_get(IF_PFLASH, 0, 0);
if (dinfo) {
BlockDriverState *bs = blk_bs(blk_by_legacy_dinfo(dinfo));
flash_size = bdrv_getlength(bs);
if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
flash_size != 32*1024*1024) {
fprintf(stderr, "Invalid flash image size\n");
exit(1);
}
#ifdef TARGET_WORDS_BIGENDIAN
pflash_cfi02_register(0x100000000ULL-MP_FLASH_SIZE_MAX, NULL,
"musicpal.flash", flash_size,
bs, 0x10000, (flash_size + 0xffff) >> 16,
MP_FLASH_SIZE_MAX / flash_size,
2, 0x00BF, 0x236D, 0x0000, 0x0000,
0x5555, 0x2AAA, 1);
#else
pflash_cfi02_register(0x100000000ULL-MP_FLASH_SIZE_MAX, NULL,
"musicpal.flash", flash_size,
bs, 0x10000, (flash_size + 0xffff) >> 16,
MP_FLASH_SIZE_MAX / flash_size,
2, 0x00BF, 0x236D, 0x0000, 0x0000,
0x5555, 0x2AAA, 0);
#endif
}
sysbus_create_simple(TYPE_MV88W8618_FLASHCFG, MP_FLASHCFG_BASE, NULL);
qemu_check_nic_model(&nd_table[0], "mv88w8618");
dev = qdev_create(NULL, TYPE_MV88W8618_ETH);
qdev_set_nic_properties(dev, &nd_table[0]);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MP_ETH_BASE);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[MP_ETH_IRQ]);
sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
sysbus_create_simple(TYPE_MUSICPAL_MISC, MP_MISC_BASE, NULL);
dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE,
pic[MP_GPIO_IRQ]);
i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c");
lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL);
key_dev = sysbus_create_simple(TYPE_MUSICPAL_KEY, -1, NULL);
qdev_connect_gpio_out(i2c_dev, 0,
qdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT));
qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0));
qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1));
for (i = 0; i < 3; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(lcd_dev, i));
}
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 8));
}
for (i = 4; i < 8; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
}
wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
dev = qdev_create(NULL, "mv88w8618_audio");
s = SYS_BUS_DEVICE(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
qdev_init_nofail(dev);
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE;
musicpal_binfo.kernel_filename = kernel_filename;
musicpal_binfo.kernel_cmdline = kernel_cmdline;
musicpal_binfo.initrd_filename = initrd_filename;
arm_load_kernel(cpu, &musicpal_binfo);
}
| 1threat
|
Is there a way to check if any 4 strings out of 5 strings are equal? : I have 5 strings. 4 are the same, lets say they're all 'K' and one is different, 'J'. Is there a way to compare all of them and check if at least 4 out of the 5 are equal.
```
rc1 = 'K'
rc2 = 'J'
rc3 = 'K'
rc4 = 'K'
rc5 = 'K'
if four are the same from rc1, rc2, rc3, rc4 or rc5:
print error
```
| 0debug
|
How to replace the bytes in a given binary file?. : Ex: my binary file test.bin having 11 22 33 44 55 66 ...
I want to modify the 3rd position with 'AA' and finally my test.bin file should be like 11 22 33 ***AA*** 55 66 ....
Can you please anyone answer this?
Thanks in advance..
| 0debug
|
How to fix Binding element 'children' implicitly has an 'any' type.ts(7031)? : <p>I'm missing something here with the validation how to add types validation? Having error "element 'children' implicitly has an 'any' type".</p>
<pre><code>import * as React from 'react';
import Button from './Styles';
const Button1 = ({ children, ...props }) => (
<Button {...props}>{children}</Button>
);
Button1.propTypes = {};
export default Button1;
</code></pre>
| 0debug
|
Activity indicator dynamically changing color ios swift : <p>Help me to resolve the issue or any third party available for activity indicator.</p>
<blockquote>
<p><strong>Activity indicator changing the color after we got the result</strong></p>
</blockquote>
<p>Anyone did this before?</p>
| 0debug
|
React performance implications of long key value on component : <p>How does length of a string applied to some component collection created from some set of data like this:</p>
<pre><code>{this.state.list.map(item => {
const url = item.url;
return (
<ListItemComponent url={url} key={url}/>
);
})}
</code></pre>
<p><strong>Are there some restrictions? What are performance implications of having long key values?</strong></p>
<p><em>Background. Sometimes we need to create list of items that are very long (like urls with lots of parameters encoded) and only suitable/unique thing to use as natural key is this very long thing.</em></p>
| 0debug
|
I am trying to insert unicode data in table from Stored Proc.I know we can use N to insert unicode data but it's not working in my case : It is working when I tried in this way..
**declare @test nvarchar(max)=N'ಕ್ಲೀನಿಂಗ್ ಒಫ್ ಸಿಲ್ವರ್ ಪಾತ್ರೆ /ಆರ್ಟಿಕಲ್ಸ್ ಆನ್ ಅಕೌಂಟ'
Select @test**
>>>ಕ್ಲೀನಿಂಗ್ ಒಫ್ ಸಿಲ್ವರ್ ಪಾತ್ರೆ /ಆರ್ಟಿಕಲ್ಸ್ ಆನ್ ಅಕೌಂಟ್ ಒಫ್ ಮಹಾಮಾಯಿ ದೇವಸ್ಥಾನ ರಥೋತ್ಸವ
But I want to insert in this way...
**declare @test nvarchar(max)='ಕ್ಲೀನಿಂಗ್ ಒಫ್ ಸಿಲ್ವರ್ ಪಾತ್ರೆ /ಆರ್ಟಿಕಲ್ಸ್ ಆನ್ ಅಕೌಂಟ್ '
Select N''+@test**
>>>????????? ??? ??????? ?????? /?????????? ??? ?????? ??? ??????? ???????? ???????
I got this...
| 0debug
|
static void sigp_stop(CPUState *cs, run_on_cpu_data arg)
{
S390CPU *cpu = S390_CPU(cs);
SigpInfo *si = arg.host_ptr;
if (s390_cpu_get_state(cpu) != CPU_STATE_OPERATING) {
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
return;
}
if (cs->halted) {
s390_cpu_set_state(CPU_STATE_STOPPED, cpu);
} else {
cpu->env.sigp_order = SIGP_STOP;
cpu_inject_stop(cpu);
}
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
| 1threat
|
Block scope in js : <p>I was playing aroun and found interessting thing</p>
<pre><code>var x = "x";
function a (){
var x = "y";
if(1){
var x = "g";
alert(x);
}
alert(x)
}
a()
</code></pre>
<p>why does this output "g" , "g" insted of "g" , "y" ? The if creates another block scope and x is local variable inside it which means when i get out of the if block , the outer x ( which equals "y" ) should be printed.</p>
| 0debug
|
In Flask, What is request.args and how is it used? : <p>I'm new in Flask. I can't understand how <code>request.args</code> is used. I read somewhere that it is used to return values of query string[correct me if I'm wrong]. And how many parameters <code>request.args.get()</code> takes.
I know that when I have to store submitted form data, I can use</p>
<pre><code>fname = request.form.get("firstname")
</code></pre>
<p>Here, only one parameter is passed.</p>
<p>Consider this code. Pagination has also been done in this code.</p>
<pre><code>@app.route("/")
def home():
cnx = db_connect()
cur = cnx.cursor()
output = []
page = request.args.get('page', 1)
try:
page = int(page)
skip = (page-1)*4
except:
abort(404)
stmt_select = "select * from posts limit %s, 4;"
values=[skip]
cur.execute(stmt_select,values)
x=cur.fetchall()
for row in reversed(x):
data = {
"uid":row[0],
"pid":row[1],
"subject":row[2],
"post_content":row[3],
"date":datetime.fromtimestamp(row[4]),
}
output.append(data)
next = page + 1
previous = page-1
if previous<1:
previous=1
return render_template("home.html", persons=output, next=next, previous=previous)
</code></pre>
<p>Here, <code>request.args.get()</code> takes two parameters. Please explain why it takes two parameters and what is the use of it.</p>
| 0debug
|
static int print_int32(DeviceState *dev, Property *prop, char *dest, size_t len)
{
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
return snprintf(dest, len, "%" PRId32, *ptr);
}
| 1threat
|
How to get correlation matrix values pyspark : <p>I have a correlation matrix calculated as follow on pyspark 2.2:</p>
<pre><code>from pyspark.ml.linalg import Vectors
from pyspark.ml.stat import Correlation
from pyspark.ml.linalg import Vectors
from pyspark.ml.feature import VectorAssembler
datos = sql("""select * from proceso_riesgos.jdgc_bd_train_mn_ingresos""")
Variables_corr= ['ingreso_final_mix','ingreso_final_promedio',
'ingreso_final_mediana','ingreso_final_trimedia','ingresos_serv_q1',
'ingresos_serv_q2','ingresos_serv_q3','prom_ingresos_serv','y_correc']
assembler = VectorAssembler(
inputCols=Variables_corr,
outputCol="features")
datos1=datos.select(Variables_corr).filter("y_correc is not null")
output = assembler.transform(datos)
r1 = Correlation.corr(output, "features")
</code></pre>
<p>the result is a data frame with a variable called "pearson(features): matrix":</p>
<pre><code>Row(pearson(features)=DenseMatrix(20, 20, [1.0, 0.9428, 0.8908, 0.913,
0.567, 0.5832, 0.6148, 0.6488, ..., -0.589, -0.6145, -0.5906, -0.5534,
-0.5346, -0.0797, -0.617, 1.0], False))]
</code></pre>
<p>I need to take those values and export it to an excel, or to be able to manipulate the result.
A list could be desiderable.</p>
<p>Thanks for help!!</p>
| 0debug
|
code 7: How to replace an image by another by clicking a button? : I started Xcoding a few days ago and get stopped by the following problem: image does not change by clicking. The former image disappears.
Thanks for any help, Peter
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIImageView *imgView;
- (IBAction)changeImage:(id)sender;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize imgView;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)changeImage:(id)sender {
UIImage *img = [UIImage imageNamed:@"animal_3.png"];
[imgView setImage: img];}
@end
| 0debug
|
How to add a list to the first position of a list in Python : <p>I want to add a list to the first position of a list.
I have used <code>insert(0, [])</code> but it didn't work.</p>
<p>For exemple, </p>
<pre><code>my_array = [['a1', 'a2', 'a3'],
['a4', 'a5', 'a6'],
['a7', 'a8', 'a9'],
['a10', 'a11', 'a12', 'a13', 'a14']].
</code></pre>
<p>and i want to add <code>[ 1, 2, 3]</code> to the first position of my_array.
Thanks for the help.</p>
| 0debug
|
static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg)
{
S390CPU *cpu = S390_CPU(cs);
S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
SigpInfo *si = arg.host_ptr;
cpu_synchronize_state(cs);
scc->cpu_reset(cs);
cpu_synchronize_post_reset(cs);
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
| 1threat
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
document.write('<script src="evil.js"></script>');
| 1threat
|
What is command to find detailed information about Kubernetes master(s) using kubectl? : <p>Let say I want to find the kubelet and apiserver version of my k8s master(s), what's the best way to do it?</p>
<p>I am aware of the following commands:</p>
<pre><code>kubectl cluster-info
</code></pre>
<p>which only shows the endpoints.</p>
<pre><code>kubectl get nodes; kubectl describe node <node>;
</code></pre>
<p>which shows very detail information but only the nodes and not master.</p>
<p>There's also</p>
<pre><code>kubectl version
</code></pre>
<p>but that only shows the kubectl version and not the kubelet or apiserver version.</p>
<p>What other commands can I use to identify the properties of my cluster?</p>
| 0debug
|
Parsing an editText value as a double on Android? : So I'm working on an app to calculate forces for me. It works fine until I try to parse the editText boxes as doubles. Here's the code (the button click for calculating is 'calc_Click'):
package com.hoodeddeath.myapplication;
import android.animation.TypeConverter;
import android.provider.SyncStateContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class GravityActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gravity);
}
public void calc_Click (View v){
double G = 6.67*(Math.pow(10,-11));
double TWO = 2;
double mOne = Double.parseDouble(findViewById(R.id.finalForceLabel).toString());
double aOne = Double.parseDouble(findViewById(R.id.ampOne).toString());
double mTwo = Double.parseDouble(findViewById(R.id.massTwo).toString());
double aTwo = Double.parseDouble(findViewById(R.id.ampTwo).toString());
double dist = Double.parseDouble(findViewById(R.id.distance).toString());
double aThree = Double.parseDouble(findViewById(R.id.ampThree).toString());
mOne = mOne * aOne;
mTwo = mTwo * aTwo;
dist = dist * aThree;
dist = Math.pow(dist, TWO);
double total = (G * mOne * mTwo) / dist;
TextView a = (TextView)findViewById(R.id.finalForceLabel);
a.setText(total.toString());
}
public double main(String args) {
double aDouble = Double.parseDouble(args);
return aDouble;
}
}
Sorry that I'm such a beginner.
| 0debug
|
can anyone tell me how to parse this json reponse? I need to extract "last name" from the services. Sory I am a swift newb : {
"Entity": {
"ID": 1,
"UserTypeID": 1,
"Code": "lPEq”,
"Services": [
{
"ID": 118,
"Code": "1",
"Parent_ID": null,
"Name": “Alex”,
"lastName": “John”,
}
{
"ID": 119,
"Code": “2”,
"Parent_ID": null,
"Name": “Christy”,
"lastName": “Noel”,
}
]
}
}
> > I have the following JSON, from which I'm failing to "last name" that is available in services.
I tried few codes but failed in parsing
| 0debug
|
How to access Sql server online database with my C# windows application : <p>I have windows application using C#, i want to store the data in local SQL SERVER database and as well as online SQL SERVER Database. </p>
| 0debug
|
Angularjs add a viariable to an object in a jsonarray : I'm looking for a solution to add a viariable to an object in a jsonarray.
my json file:
[
{
"BasketDetail_ID": "91",
"Pos": "1",
"BasketBasket_ID": "17",
},
{
"BasketDetail_ID": "92",
"Pos": "2",
"BasketBasket_ID": "17",
},
{
"BasketDetail_ID": "93",
"Pos": "3",
"BasketBasket_ID": "17",
},
{
"BasketDetail_ID": "94",
"Pos": "4",
"BasketBasket_ID": "17",
},
{
"BasketDetail_ID": "95",
"Pos": "5",
"BasketBasket_ID": "17",
},
{
"BasketDetail_ID": "96",
"Pos": "6",
"BasketBasket_ID": "17",
},
{
"BasketDetail_ID": "97",
"Pos": "7",
"BasketBasket_ID": "17",
},
{
"BasketDetail_ID": "98",
"Pos": "8",
"BasketBasket_ID": "17",
}
]
My objects do not have names.
I tried to make a push for each object:
var length = basketDetails.length;
for (var i = 0; i < length; i++) {
$scope.basketDetails[i].push({'detailTotalPrice': $scope.detailTotalPrice});
}
Here I always get an error:
$scope.basketDetails[i].add is not a function
the updated json should look like:
[
{
"BasketDetail_ID": "91",
"Pos": "1",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
},
{
"BasketDetail_ID": "92",
"Pos": "2",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
},
{
"BasketDetail_ID": "93",
"Pos": "3",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
},
{
"BasketDetail_ID": "94",
"Pos": "4",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
},
{
"BasketDetail_ID": "95",
"Pos": "5",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
},
{
"BasketDetail_ID": "96",
"Pos": "6",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
},
{
"BasketDetail_ID": "97",
"Pos": "7",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
},
{
"BasketDetail_ID": "98",
"Pos": "8",
"BasketBasket_ID": "17",
"detailTotalPrice": "100",
}
]
have somebody an idea to fix this problem?
| 0debug
|
is there a command such as "sed" in bash scripts in c++? : Currently ım trying to convert my bash script to c++ executable
but ı stuck in "sed" command
here is my bash script:
unset WIFIMAC
unset BTMAC
# Skip processing if MAC addresses are already written
if [ -f /data/.mac.info -a -f /data/.bt.info ]; then
echo "MAC addresses already found."
fi
# Wait until Samsung's RIL announces MAC addresses
until [ $(expr length "$WIFIMAC") == 17 ]; do
WIFIMAC=`getprop ril.wifi_macaddr`
sleep 1
done
until [ $(expr length "$BTMAC") == 12 ]; do
BTMAC=`getprop ril.bt_macaddr`
sleep 1
done
# Set WiFi MAC address
echo $WIFIMAC >/data/.mac.info
# Convert BT MAC address to proper format
echo $BTMAC | sed 's!^M$!!;s!\-!!g;s!\.!!g;s!\(..\)!\1:!g;s!:$!!' >/data/.bt.info
exit
here ım trying it to convert to c++
*** ı put comments into next of bash commands ***
# This script will read the MAC addresses from Samsung's RIL.
unset WIFIMAC ---> char wifimac....
unset BTMAC ---> char btmac...
# Skip processing if MAC addresses are already written
if [ -f /data/.mac.info -a -f /data/.bt.info ]; then ----> create file_exist(); function with fd = open... and put a smiply if return block
echo "MAC addresses already found."
fi
# Wait until Samsung's RIL announces MAC addresses
until [ $(expr length "$WIFIMAC") == 17 ]; do -----> while strlen(wifimac) == 17 blah blah blah....
WIFIMAC=`getprop ril.wifi_macaddr` -----> property_get function in cutils.h
sleep 1 -----> mdelay(1) if ım not wrong huh?.....
done
until [ $(expr length "$BTMAC") == 12 ]; do
BTMAC=`getprop ril.bt_macaddr` -----> SAME COMMANDS ABOVE
sleep 1
done
# Set WiFi MAC address
echo $WIFIMAC >/data/.mac.info -----> create write_string_to_path(); function with write(fd, ...)
# Convert BT MAC address to proper format
echo $BTMAC | sed 's!^M$!!;s!\-!!g;s!\.!!g;s!\(..\)!\1:!g;s!:$!!' >/data/.bt.info -----> ********HERE İS THE F*CKİNG COMMAND "sed" *********
I KNOW A LİTTLE BİT ABOUT SED
BUT I DONT KNOW WHAT İS İT DOİNG HERE
THUS I DONT KNOW WHİCH COMMAND İN C++ DO THE SAME THİNG
exit
can any one help me please?
thanx
regards
| 0debug
|
static void migrate_finish_set_state(MigrationState *s, int new_state)
{
if (atomic_cmpxchg(&s->state, MIG_STATE_ACTIVE, new_state) == new_state) {
trace_migrate_set_state(new_state);
}
}
| 1threat
|
How do you share gRPC proto definitions between services : <p>I am specifying a number of independent <strong>gRPC</strong> services that will all be hosted out of the same server process. Each service is defined in its own protobuf file. These are then run through the <strong>gRPC</strong> tools to give me the target language (c# in my case) in which I can then implement my server and client.</p>
<p>Each of those separate APIs uses a number of common elements, things like error response enumerations, the <em>Empty</em> message type (which seems to be available in the <strong>gRPC</strong> <em>WellKnownTypes</em>; but I cannot see how I include that either so I defined my own).</p>
<p>At the moment I end up with each proto building duplicate enums and classes into their own namespace. Though I know I can share the definitions in a common proto file and include that; I do not see how to end up with only a single code gen of these into a common namespace. Though this works it would be neater to keep it to one set; it may also have issues later in conversion and equivalence if doing things like aggregating errors across services.</p>
<p>I assume I am missing something as my reading of things such as the <em>WellKnownTypes</em> namespace suggests that this should be possible but, as mentioned before, I don't see how I refer to that in the Proto either.</p>
<p>SO seems pretty light on <strong>gRPC</strong> for the moment so my searches are not turning up much, and I am new to this so any pointers?</p>
| 0debug
|
MySQL Workbench: Reconnecting to database when "MySQL server has gone away"? : <p>I have a lot of tabs and queries open in MySQL workbench. I left it open before I went to sleep, but this morning I am getting an error <code>MySQL server has gone away</code> when trying to run queries.</p>
<p>The database is up, and I am able to connect to it if I open a new connection on MySQL workbench, but the current connection is dead. How do I reconnect?</p>
<p>I don't want to open a new connection as I would have to copy my queries and tabs over.</p>
| 0debug
|
array.sort()-Methode isn't working as it should : i want to display a Array of names in a table. ist like a timetable and i have a sort-button because if i want to add a new Student, the Student should be classified at the right place.
My Array contains this values
- Benj
- Zebra
- Yves
- Anna
but if i press the sort button the output is like this
- Zebra
- Yves
- Anna
- Benj
That dosent make sense ist not ascending and not descending
Here is the code
function sort(){
students.sort();
for(var i = 0;i<students.length+1;i++){
if(i!=0){
alert(students[i-1].innerHTML);
<!--table.rows[i].cells[0].innerHTML = students[i-1].innerHTML;-->
}
}
}
| 0debug
|
static void qmp_input_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
QInt *qint;
QFloat *qfloat;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (qint) {
*obj = qint_get_int(qobject_to_qint(qobj));
return;
}
qfloat = qobject_to_qfloat(qobj);
if (qfloat) {
*obj = qfloat_get_double(qobject_to_qfloat(qobj));
return;
}
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
}
| 1threat
|
static int nsv_read_close(AVFormatContext *s)
{
NSVContext *nsv = s->priv_data;
av_freep(&nsv->nsvs_file_offset);
av_freep(&nsv->nsvs_timestamps);
#if 0
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
NSVStream *ast = st->priv_data;
if(ast){
av_free(ast->index_entries);
av_free(ast);
}
av_free(st->codec->palctrl);
}
#endif
return 0;
}
| 1threat
|
Renaming a List Of Files #1 by another List Of Files #2 : **Renaming a list of files (in one folder) contained in a text file (e.g. MyList1.txt) by another list of files contained in another text file (e.g. MyList2.txt)**
I would like to use a DOS batch (not powershell, script, etc,) who rename a list of files in one folder, contain in a text file, by another list of files contain in another text file.<br/>
**Suppose I have a list of files inside a text file:**<br/>
These files are in one folder (for example ***D:\Librarian***)<br/>
***D:\Test\MyList1.txt***<br/>
Inside this file:<br/>
Directory.zip <br/>
Subject.zip<br/>
Penny.zip<br/>
Car.zip<br/>
Auto.zip<br/>
One_Upon_A_time.zip<br/>
All is relative.zip<br/>
Zen of graphics programming – Corilolis.zip<br/>
PC Magazine – July 1999 No.22.zip<br/>
Bytes is over with quantum.zip<br/>
And I want to replace them by:<br/>
***D:\Test\MyList2.txt***<br/>
Inside this file:<br/>
Patatoes.zip<br/>
Chips.zip<br/>
Hot Dogs Sweet.zip<br/>
Ice Cream_Very – Good.zip<br/>
We must eat to live.zip<br/>
Ketchup on potatoes is a muxt.zip<br/>
The Magazine are owned by few guys.zip<br/>
Desert are not necessary_in life.zip<br/>
Sugar_is_a_legal_drug.zip<br/>
People-who_don’t-like_pizzas_don’t like bread.zip<br/>
**So**<br/>
Directory.zip will come Patatoes.zip<br/>
Subject.zip will come Chips.zip<br/>
Penny.zip will come Hot Dogs Sweet.zip<br/>
Etc.<br/>
Both MyList1.txt and MyList2.txt have same number of lines (same number of filenames)<br/>
| 0debug
|
How to split 2 items of an array and join into one item?(python) : I've made a python program with array that has 2 items. I want to split and join those 2 items into one item. So the result should be 'first item, second item'. It gives that error AttributeError: 'list' object has no attribute 'split'. I attached the code. I will appreciate any help.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
items_in_cart=['first item','second item']
a,b=items_in_cart.split(", ")
items_in_cart=a+b
print(items_in_cart)
<!-- end snippet -->
| 0debug
|
Continuously getting the java: invalid source release: 1.9 error when compiling : <p>I have attempted to fix this problem using the various forums on this site, but nothing has helped. I tried similar techniques as used to fix other people's 1.8 errors, but nothing has worked. I have my java class file under my source folder and no imports, I just simply want a basic output message to make sure intelliJ is working as it should. Can anyone offer any advice?</p>
| 0debug
|
Regxp to strip out everything except numbers and slashes : <p>Could someone write me a regular expression that would strip out everything except numbers and slashes?</p>
<p>For example I have the following:</p>
<pre><code>[u'Posted by Kendra E. on 3/17/2016', u'Posted by Jasmine B. on 3/16/2016', u'Posted by Chris H. on 3/17/2016', u'Posted by Katie S. on 3/17/2016', u'Posted by Samidha K. on 3/17/2016', u'Posted by Melissa W. on 3/20/2016', u'Posted by Travis S. on 3/18/2016', u'Posted by Lilla L. on 3/16/2016']
</code></pre>
<p>And I want to make it</p>
<pre><code>['3/17/2016', '3/16/2016', '3/17/2016'...]
</code></pre>
<p>Is this possible?</p>
<p>Thanks,
Ben</p>
| 0debug
|
Problem with Python Task that contains variable count : <p>CAN YOU HELP ME WITH THIS PYTHON TASK====1.based on the variable: str1="one two three twenty one thirty one fifty one" and the help of one or more string management methods, you are asked to check if it contains more than twice the string 'one'. If yes, then the program should say "More than Two". IF not , then the program should say "There are fewer than two" </p>
| 0debug
|
int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
int mb_x, int mb_y)
{
MotionEstContext * const c= &s->me;
int mx, my, dmin;
int P[10][2];
const int shift= 1+s->quarter_sample;
const int xy= mb_x + mb_y*s->mb_stride;
init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
assert(s->quarter_sample==0 || s->quarter_sample==1);
c->pre_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_pre_cmp);
c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
get_limits(s, 16*mb_x, 16*mb_y);
c->skip=0;
P_LEFT[0] = s->p_mv_table[xy + 1][0];
P_LEFT[1] = s->p_mv_table[xy + 1][1];
if(P_LEFT[0] < (c->xmin<<shift)) P_LEFT[0] = (c->xmin<<shift);
if (s->first_slice_line) {
c->pred_x= P_LEFT[0];
c->pred_y= P_LEFT[1];
P_TOP[0]= P_TOPRIGHT[0]= P_MEDIAN[0]=
P_TOP[1]= P_TOPRIGHT[1]= P_MEDIAN[1]= 0;
} else {
P_TOP[0] = s->p_mv_table[xy + s->mb_stride ][0];
P_TOP[1] = s->p_mv_table[xy + s->mb_stride ][1];
P_TOPRIGHT[0] = s->p_mv_table[xy + s->mb_stride - 1][0];
P_TOPRIGHT[1] = s->p_mv_table[xy + s->mb_stride - 1][1];
if(P_TOP[1] < (c->ymin<<shift)) P_TOP[1] = (c->ymin<<shift);
if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift);
if(P_TOPRIGHT[1] < (c->ymin<<shift)) P_TOPRIGHT[1]= (c->ymin<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
c->pred_x = P_MEDIAN[0];
c->pred_y = P_MEDIAN[1];
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);
s->p_mv_table[xy][0] = mx<<shift;
s->p_mv_table[xy][1] = my<<shift;
return dmin;
}
| 1threat
|
document.write('<script src="evil.js"></script>');
| 1threat
|
static void ff_mpeg4_init_direct_mv(MpegEncContext *s){
static const int tab_size = sizeof(s->direct_scale_mv[0])/sizeof(int16_t);
static const int tab_bias = (tab_size/2);
int i;
for(i=0; i<tab_size; i++){
s->direct_scale_mv[0][i] = (i-tab_bias)*s->pb_time/s->pp_time;
s->direct_scale_mv[1][i] = (i-tab_bias)*(s->pb_time-s->pp_time)/s->pp_time;
}
}
| 1threat
|
static inline int round_sample(int64_t *sum)
{
int sum1;
sum1 = (int)((*sum) >> OUT_SHIFT);
*sum &= (1<<OUT_SHIFT)-1;
return av_clip(sum1, OUT_MIN, OUT_MAX);
}
| 1threat
|
void helper_movl_drN_T0(CPUX86State *env, int reg, target_ulong t0)
{
#ifndef CONFIG_USER_ONLY
if (reg < 4) {
if (hw_breakpoint_enabled(env->dr[7], reg)
&& hw_breakpoint_type(env->dr[7], reg) != DR7_TYPE_IO_RW) {
hw_breakpoint_remove(env, reg);
env->dr[reg] = t0;
hw_breakpoint_insert(env, reg);
} else {
env->dr[reg] = t0;
}
} else if (reg == 7) {
cpu_x86_update_dr7(env, t0);
} else {
env->dr[reg] = t0;
}
#endif
}
| 1threat
|
Python - merge two CSV files and KEEP duplicates : I am trying to merge two csv files and keep duplicate records. Each file may have a matching record, one file may have duplicate records (same student ID with different test scores), and one file may not have a matching student record in the other file. The code below works as expected however if a duplicate record exists only the second record is being written to the merged file. I've looked through many threads and all address removing duplicates but I need to keep duplicate records.
`
import csv
from collections import OrderedDict
import os
cd = os.path.dirname(os.path.abspath(__file__))
fafile = os.path.join(cd, 'MJB_FAScores.csv')
testscores = os.path.join(cd, 'MJB_TestScores.csv')
filenames = fafile, testscores
data = OrderedDict()
fieldnames = []
for filename in filenames:
with open(filename, 'r') as fp:
reader = csv.DictReader(fp)
fieldnames.extend(reader.fieldnames)
for row in reader:
data.setdefault(row['Student_Number'], {}).update(row)
fieldnames = list(OrderedDict.fromkeys(fieldnames))
with open('merged.csv', 'w', newline='') as fp:
writer = csv.writer(fp)
writer.writerow(fieldnames)
for row in data.values():
writer.writerow([row.get(fields, '') for fields in fieldnames])
fafile=
Student_Number Name Grade Teacher FA1 FA2 FA3
65731 Ball, Peggy 4 Bauman, Edyn 56 45 98
65731 Ball, Peggy 4 Bauman, Edyn 32 323 232
85250 Ball, Jonathan 3 Clarke, Mary 65 77 45
981235 Ball, David 5 Longo, Noel 56 89 23
91851 Ball, Jeff 0 Delaney, Mary 83 45 42
543 MAX 2 Phil 77 77 77
543 MAX 2 Annie 88 888 88
9844 Lisa 1 Smith, Jennifer 43 44 55
testscores=
Student_Number Name Grade Teacher MAP Reading MAP Math FP Level DSA LN DSA WW DSA SJ DSA DC
65731 Ball, Peggy 4 Bauman, Edyn 175 221 A 54 23 78 99
72941 Ball, Amanda 4 Bauman, Edyn 201 235 J 65 34 65
85250 Ball, Jonathan 3 Clarke, Mary 189 201 L 34 54
981235 Ball, David 5 Longo, Noel 225 231 D 23 55
91851 Ball, Jeff 0 Delaney, Mary 198 175 C
65731 Ball, Peggy 4 Bauman, Edyn 200 76 Y 54 23 78 99
543 MAX 2 Phil 111 111 Z 33 44 55 66
543 MAX 2 Annie 222 222 A 44 55 66 77
Current output:
Student_Number Name Grade Teacher FA1 FA2 FA3 MAP Reading MAP Math FP Level DSA LN DSA WW DSA SJ DSA DC
65731 Ball, Peggy 4 Bauman, Edyn 32 323 232 200 76 Y 54 23 78 99
85250 Ball, Jonathan 3 Clarke, Mary 65 77 45 189 201 L 34 54
981235 Ball, David 5 Longo, Noel 56 89 23 225 231 D 23 55
91851 Ball, Jeff 0 Delaney, Mary 83 45 42 198 175 C
543 MAX 2 Annie 88 888 88 222 222 A 44 55 66 77
72941 Ball, Amanda 4 Bauman, Edyn 201 235 J 65 34 65
9844 Lisa 1 Smith, Jennifer 43 44 55
Desired output:
Student_Number Name Grade Teacher FA1 FA2 FA3 MAP Reading MAP Math FP Level DSA LN DSA WW DSA SJ DSA DC
65731 Ball, Peggy 4 Bauman, Edyn 32 323 232 200 76 Y 54 23 78 99
65731 Ball, Peggy 4 Bauman, Edyn 56 45 98 175 221 A 54 23 78 99
85250 Ball, Jonathan 3 Clarke, Mary 65 77 45 189 201 L 34 54
981235 Ball, David 5 Longo, Noel 56 89 23 225 231 D 23 55
91851 Ball, Jeff 0 Delaney, Mary 83 45 42 198 175 C
543 MAX 2 Annie 88 888 88 222 222 A 44 55 66 77
543 MAX 2 Phil 77 77 77 111 111 Z 33 44 55 66
72941 Ball, Amanda 4 Bauman, Edyn 201 235 J 65 34 65
9844 Lisa 1 Smith, Jennifer 43 44 55
| 0debug
|
static char *qemu_rbd_next_tok(int max_len,
char *src, char delim,
const char *name,
char **p, Error **errp)
{
int l;
char *end;
*p = NULL;
if (delim != '\0') {
for (end = src; *end; ++end) {
if (*end == delim) {
break;
}
if (*end == '\\' && end[1] != '\0') {
end++;
}
}
if (*end == delim) {
*p = end + 1;
*end = '\0';
}
}
l = strlen(src);
if (l >= max_len) {
error_setg(errp, "%s too long", name);
return NULL;
} else if (l == 0) {
error_setg(errp, "%s too short", name);
return NULL;
}
return src;
}
| 1threat
|
Hi, How to do get mysql script convert mssql script ? : Thanks For you reply,
view_taksitmus CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`
SQL SECURITY DEFINER VIEW `view_taksitmus`
AS (select `t`.`taksitid` AS `taksitid`,`t`.`policeid` AS `policeid`,`t`.`vade` AS `vade`,
`t`.`tutar` AS `tutar`,
if(isnull(sum(`tm`.`tutar`)),0,sum(`tm`.`tutar`)) AS `odenen`,
if(isnull(sum(`tm`.`tutar`)),`t`.`tutar`,(`t`.`tutar` - sum(`tm`.`tutar`))) AS `kalan`,
`p`.`policeno` AS `policeno`,`p`.`zeyilno` AS `zeyilno`,`p`.`yenilemeno` AS `yenilemeno`,`p`.`plaka` AS `plaka`,`p`.`doviz` AS `doviz`,`p`.`kur` AS `kur` from ((`ins_taksitmus` `t` left join `ins_takmak` `tm` on((`t`.`taksitid` = `tm`.`taksitid`))) left join `view_police` `p` on((`t`.`policeid` = `p`.`policeid`))))
| 0debug
|
Check whether cell at indexPath is visible on screen UICollectionView : <p>I have a <code>CollectionView</code> which displays images to the user. I download these in the background, and when the download is complete I call the following func to update the <code>collectionViewCell</code> and display the image. </p>
<pre><code>func handlePhotoDownloadCompletion(notification : NSNotification) {
let userInfo:Dictionary<String,String!> = notification.userInfo as! Dictionary<String,String!>
let id = userInfo["id"]
let index = users_cities.indexOf({$0.id == id})
if index != nil {
let indexPath = NSIndexPath(forRow: index!, inSection: 0)
let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
if (users_cities[index!].image != nil) {
cell.backgroundImageView.image = users_cities[index!].image!
}
}
}
</code></pre>
<p>This works great if the cell is currently visible on screen, however if it is not I get a
<code>fatal error: unexpectedly found nil while unwrapping an Optional value</code> error on the following line : </p>
<pre><code> let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
</code></pre>
<p>Now this function does not even need to be called if the collectionViewCell is not yet visible, because in this case the image will be set in the <code>cellForItemAtIndexPath</code> method anyway.</p>
<p>Hence my question, how can I alter this function to check whether the cell we are dealing with is currently visible or not. I know of the <code>collectionView.visibleCells()</code> however, I am not sure how to apply it here. </p>
| 0debug
|
How to convert a particular column in table from hex to decimal in sql : <p>I have a query of 15 columns and one of them has a hexadecimal value, i wanted to convert it to decimal or int. How can i do it</p>
| 0debug
|
how to sole application.yml with Spring boot (while parsing a block mapping) : i want to solve while parsing a block mapping error for use Spring boot with Eureka server configuration
`while parsing a block mapping
in 'reader', line 5, column 3:
application:
^
expected <block end>, but found '<block mapping start>'
in 'reader', line 15, column 4:
hikari:`
^[image in application.yml][1]
[1]: https://i.stack.imgur.com/9crs8.jpg
| 0debug
|
Python anaconda access denied : <p>I'm trying to update tensorflow.</p>
<pre><code>pip install --upgrade tensorflow-gpu
</code></pre>
<p>It first checks for the packages and creates the following error</p>
<pre><code>Installing collected packages: markdown, werkzeug, numpy, tensorflow-gpu, setuptools
Found existing installation: Markdown 2.2.0
Uninstalling Markdown-2.2.0:
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\anaconda3\\lib\\site-packages\\markdown-2.2.0.dist-info\\description.rst'
</code></pre>
<p>I'm not very experienced with Windows, I did all my work on Linux so far, so what do I do here?</p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
why i the pointer is not a structure or union? : <pre><code>#include <stdio.h>
struct m_tag {
short m_tag_id;
short m_tag_len;
int m_tag_cookie;
};
struct packet_tags {
struct m_tag *slh_first;
}tags;
#define SFIRST(head) ((head).slh_first)
int main(void) {
printf("%p\n", SFIRST(&tags));
return 0;
}
</code></pre>
<p>In function 'main':
error: request for member 'slh_first' in something not a structure or union </p>
<p>what is the problem with this code?</p>
| 0debug
|
how to make smooth grayscale on hover using CSS : <p>I have logo in my website, it is grayscaled on hover i want it to be colored smoothly. it is working but not smoothly. i am using CSS transition.</p>
<p>This is my code</p>
<pre><code><img alt="TT ltd logo" src="./img/tt-logo.png" class="tt-logo" />
<style>
img.tt-logo {
filter: grayscale(1);
transition: grayscale 0.5s;
}
img.tt-logo:hover {
filter: grayscale(0);
}
</style>
</code></pre>
| 0debug
|
Property 'dataset' does not exist on type 'EventTarget' : <p>When trying to access the dataset on a button after a click, I get this^ error.</p>
<pre><code>linkProvider = (ev: React.SyntheticEvent<EventTarget>) => {
console.debug('ev.target', ev.target.dataset['ix']) // error
}
// in render
providers.map((provider, ix) => (
<button key={provider} data-ix={ix} onClick={this.linkProvider}>{provider}</button>
))
</code></pre>
<p>Any ideas how to make it work?</p>
| 0debug
|
Statistical Profiling in Python : <p>I would like to know that the Python interpreter is doing in my production environments.</p>
<p>Some time ago I wrote a simple tool called <a href="https://github.com/guettli/live-trace" rel="noreferrer">live-trace</a> which runs a daemon thread which collects stacktraces every N milliseconds. </p>
<p>But signal handling in the interpreter itself has one disadvantage:</p>
<blockquote>
<p>Although Python signal handlers are called asynchronously as far as the Python user is concerned, they can only occur between the “atomic” instructions of the Python interpreter. This means that signals arriving during long calculations implemented purely in C (such as regular expression matches on large bodies of text) may be delayed for an arbitrary amount of time.</p>
</blockquote>
<p>Source: <a href="https://docs.python.org/2/library/signal.html" rel="noreferrer">https://docs.python.org/2/library/signal.html</a></p>
<p>How could I work around above constraint and get a stacktrace, even if the interpreter is in some C code for several seconds?</p>
<p>Related: <a href="https://github.com/23andMe/djdt-flamegraph/issues/5" rel="noreferrer">https://github.com/23andMe/djdt-flamegraph/issues/5</a></p>
| 0debug
|
Get header data from a request response in swift : <p>I want to get X-Dem-Auth in a header request with swift to stock that in my app.</p>
<p>See the response :</p>
<pre><code>headers {
"Content-Length" = 95;
"Content-Type" = "application/json; charset=utf-8";
Date = "Fri, 15 Apr 2016 08:01:58 GMT";
Server = "Apache/2.4.18 (Unix)";
"X-Dem-Auth" = null;
"X-Powered-By" = Express;
</code></pre>
| 0debug
|
How to print all combinations? : <p>I've just started studying C++. I have to create an array with 1000 names. My idea was to first create an array with 10 names and then to permutate the names in order to produce 1000. However, I don't know how to create the first array (i suppose it is an array of strings, but I do not know if my syntax is correct), and I don't know how to further permutate the names to form a bigger array. Could anyone help me?</p>
| 0debug
|
What is a vertical bar in jade? : <p>To convert HTML to jade is use this <a href="http://html2jade.aaron-powell.com/" rel="noreferrer">jade converter</a>.</p>
<p>When I enter the following HTML,</p>
<pre><code><!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
</head>
<body>
<div class="container">
<div class="header">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</body>
</html>
</code></pre>
<p>the output is as follows:</p>
<pre><code>doctype html.no-js
head
meta(charset='utf-8')
|
body
.container
.header
ul.nav.nav-pills.pull-right
li.active
a(href='#') Home
|
li
a(href='#') About
|
li
a(href='#') Contact
</code></pre>
<p>What is the purpose of the vertical bars (<code>|</code>) ?</p>
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
i want to print value of second column in next columns where value of first column is repeated using linux command : my sample file is:
$ cat diskcheck.out
hxcsvc-a02 sd2
hxcslc-a01 sd23
hxcslc-a02 sd14
hxcslc-a02 sd17
hxcslc-a02 sd18
hxcslc-a02 sd19
hxcslc-a03 sd11
hxcslc-a07 sd3
hxcslc-a09 sd2
Expected Output:
hxcsvc-a02 sd2
hxcslc-a01 sd23
hxcslc-a02 sd14 sd17 sd18 sd19
hxcslc-a03 sd11
hxcslc-a07 sd3
hxcslc-a09 sd2
| 0debug
|
static int qemu_rbd_snap_rollback(BlockDriverState *bs,
const char *snapshot_name)
{
BDRVRBDState *s = bs->opaque;
int r;
r = rbd_snap_rollback(s->image, snapshot_name);
return r;
}
| 1threat
|
How much of this business logic belongs in Vuex? : <p>I have a simple app which pulls products from an API and displays them on-page, like this:</p>
<p><a href="https://i.stack.imgur.com/QcYeG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QcYeG.png" alt="enter image description here"></a></p>
<p>I've added Vuex to the app so that the search results as well as the product search array doesn't disappear when the router moves the user to a specific product page.</p>
<p>The search itself consists of the following steps:</p>
<ul>
<li>show loading spinner (update the <code>store</code> object)</li>
<li>dispatch an action to access the API</li>
<li>update the <code>store</code> object with products, spinner</li>
<li>decide if the product list is exhausted</li>
<li>hide loading spinner</li>
</ul>
<p>You get the idea.</p>
<p>With all of the variables stored in Vuex, it stands to reason all of the business logic should belong there as well, but should it really?</p>
<p>I'm talking specifically about accessing store params such as <code>productsExhausted</code> (when there are no more products to display) or <code>productPage</code> (which increments every time the infinite scroller module is triggered) etc.</p>
<p><strong>How much logic - and what kind - belongs in Vuex? How much does not?</strong></p>
<p>I was under the impression that Vuex is used for storage only but since all of the data is located there, fetching it all back to the Vue app only to send it all back seems like an overly verbose way to address the problem.</p>
| 0debug
|
WHMCS with django 1.9 python? : <p>I just want to know if it's possible to use WHMCS with Django framework ?</p>
<p>Thank in advance !</p>
| 0debug
|
Parentheses in Ruby will make program slower? : I'm just wondering if using parentheses in Ruby makes program slower?
I know It's common to omit them but for me using parentheses increase readability. :)
| 0debug
|
pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off,
BlockDriverState *bs, uint32_t sector_len,
int nb_blocs, int width,
uint16_t id0, uint16_t id1,
uint16_t id2, uint16_t id3)
{
pflash_t *pfl;
target_phys_addr_t total_len;
total_len = sector_len * nb_blocs;
#if 0
if (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) &&
total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024))
return NULL;
#endif
pfl = qemu_mallocz(sizeof(pflash_t));
pfl->storage = qemu_get_ram_ptr(off);
pfl->fl_mem = cpu_register_io_memory(
pflash_read_ops, pflash_write_ops, pfl);
pfl->off = off;
cpu_register_physical_memory(base, total_len,
off | pfl->fl_mem | IO_MEM_ROMD);
pfl->bs = bs;
if (pfl->bs) {
bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);
}
#if 0
pfl->ro = 1;
#else
pfl->ro = 0;
#endif
pfl->timer = qemu_new_timer(vm_clock, pflash_timer, pfl);
pfl->base = base;
pfl->sector_len = sector_len;
pfl->total_len = total_len;
pfl->width = width;
pfl->wcycle = 0;
pfl->cmd = 0;
pfl->status = 0;
pfl->ident[0] = id0;
pfl->ident[1] = id1;
pfl->ident[2] = id2;
pfl->ident[3] = id3;
pfl->cfi_len = 0x52;
pfl->cfi_table[0x10] = 'Q';
pfl->cfi_table[0x11] = 'R';
pfl->cfi_table[0x12] = 'Y';
pfl->cfi_table[0x13] = 0x01;
pfl->cfi_table[0x14] = 0x00;
pfl->cfi_table[0x15] = 0x31;
pfl->cfi_table[0x16] = 0x00;
pfl->cfi_table[0x17] = 0x00;
pfl->cfi_table[0x18] = 0x00;
pfl->cfi_table[0x19] = 0x00;
pfl->cfi_table[0x1A] = 0x00;
pfl->cfi_table[0x1B] = 0x45;
pfl->cfi_table[0x1C] = 0x55;
pfl->cfi_table[0x1D] = 0x00;
pfl->cfi_table[0x1E] = 0x00;
pfl->cfi_table[0x1F] = 0x07;
pfl->cfi_table[0x20] = 0x07;
pfl->cfi_table[0x21] = 0x0a;
pfl->cfi_table[0x22] = 0x00;
pfl->cfi_table[0x23] = 0x04;
pfl->cfi_table[0x24] = 0x04;
pfl->cfi_table[0x25] = 0x04;
pfl->cfi_table[0x26] = 0x00;
pfl->cfi_table[0x27] = ctz32(total_len);
pfl->cfi_table[0x28] = 0x02;
pfl->cfi_table[0x29] = 0x00;
pfl->cfi_table[0x2A] = 0x0B;
pfl->cfi_table[0x2B] = 0x00;
pfl->cfi_table[0x2C] = 0x01;
pfl->cfi_table[0x2D] = nb_blocs - 1;
pfl->cfi_table[0x2E] = (nb_blocs - 1) >> 8;
pfl->cfi_table[0x2F] = sector_len >> 8;
pfl->cfi_table[0x30] = sector_len >> 16;
pfl->cfi_table[0x31] = 'P';
pfl->cfi_table[0x32] = 'R';
pfl->cfi_table[0x33] = 'I';
pfl->cfi_table[0x34] = '1';
pfl->cfi_table[0x35] = '1';
pfl->cfi_table[0x36] = 0x00;
pfl->cfi_table[0x37] = 0x00;
pfl->cfi_table[0x38] = 0x00;
pfl->cfi_table[0x39] = 0x00;
pfl->cfi_table[0x3a] = 0x00;
pfl->cfi_table[0x3b] = 0x00;
pfl->cfi_table[0x3c] = 0x00;
return pfl;
}
| 1threat
|
Android Center Align Images :
I have a very simple html here. It's an email header. My problem is, it displays perfectly on iOS but Android center aligns the logo and the button, when I run an actual email test. Browsers displays it well. It's just email clients where it change. The logo is suppose to be left aligned and the orange button, right aligned. Please help. Code in the fiddle bellow
| 0debug
|
what's the real purpose of 'ref' attribute? : <p>I'm really confused with the "ref" attribute of the input element. I've never heard it based on my knowledge and can't find some meaningful materials about it.The code is in vue.js offical documents.</p>
<pre><code><currency-input v-model="price"></currency-input>
</code></pre>
<p>This is code about the component:</p>
<pre><code>Vue.component('currency-input', {
template: `
<span>
$
<input
ref="input"
v-bind:value="value"
v-on:input="updateValue($event.target.value)">
</span>
`,
props: ['value'],
</code></pre>
<p>what's the meaning of the value of ref attribute that equals to input?</p>
| 0debug
|
Android Studio how to make mainactivity as home fragment? : I have a mainactivity and other fragments which open a webview when user clicks on them on navigationviewer. I added Home fragment to navigation view but I don't know how to make it default so that if user opens the app, default home fragment opens up. Do I have to make another java class or use MainActivity.java as home? If yes, how do I use MainActivity.java as home fragment? And if user clicks other fragment to open a webview and presses the backbutton, how to make it go back to the default home fragment? At the moment, if I press the backbutton, it literally destroys app and goes back to Phone background.
| 0debug
|
Android which library should i use in non blocking socket programming : <p>I want to write and read data from multiple <code>sockets</code>.so i don't want to make it blocking <code>UI thread</code>.I know i can use <code>thread</code> for each connection.but before proceeding wanted to check if any good <code>3rd party library</code> is there which is useful in these kind of Application. </p>
| 0debug
|
Does Delphi threadvar work for Parallel.For? : <p>from <a href="http://www.delphibasics.co.uk/RTL.asp?Name=ThreadVar">here</a> it says </p>
<blockquote>
<p>"The ThreadVar keyword starts a set of variable definitions that are
used by threads. Each thread is given a separate instance of each
variable, thereby avoiding data conflicts, and preserving thread
independence. "</p>
</blockquote>
<p>So can I use in Parallel.For like this?</p>
<pre><code>threadvar
threadID: integer;
procedure TForm5.Button1Click(Sender: TObject);
var
Tot: Integer;
begin
TParallel.For(1, Max, procedure (I: Integer)
begin
threadID := i; // each thread gets its own threadID?
if IsPrime (threadID) then
TInterlocked.Increment (Tot);
end);
end;
</code></pre>
| 0debug
|
static av_cold int MPA_encode_init(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int freq = avctx->sample_rate;
int bitrate = avctx->bit_rate;
int channels = avctx->channels;
int i, v, table;
float a;
if (channels <= 0 || channels > 2){
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels);
return AVERROR(EINVAL);
}
bitrate = bitrate / 1000;
s->nb_channels = channels;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->delay = 512 - 32 + 1;
s->lsf = 0;
for(i=0;i<3;i++) {
if (avpriv_mpa_freq_tab[i] == freq)
break;
if ((avpriv_mpa_freq_tab[i] / 2) == freq) {
s->lsf = 1;
break;
}
}
if (i == 3){
av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", freq);
return AVERROR(EINVAL);
}
s->freq_index = i;
for(i=0;i<15;i++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
if (i == 15){
av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate);
return AVERROR(EINVAL);
}
s->bitrate_index = i;
a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0);
s->frame_size = ((int)a) * 8;
s->frame_frac = 0;
s->frame_frac_incr = (int)((a - floor(a)) * 65536.0);
table = ff_mpa_l2_select_table(bitrate, s->nb_channels, freq, s->lsf);
s->sblimit = ff_mpa_sblimit_table[table];
s->alloc_table = ff_mpa_alloc_tables[table];
av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
bitrate, freq, s->frame_size, table, s->frame_frac_incr);
for(i=0;i<s->nb_channels;i++)
s->samples_offset[i] = 0;
for(i=0;i<257;i++) {
int v;
v = ff_mpa_enwindow[i];
#if WFRAC_BITS != 16
v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
#endif
s->filter_bank[i] = v;
if ((i & 63) != 0)
v = -v;
if (i != 0)
s->filter_bank[512 - i] = v;
}
for(i=0;i<64;i++) {
v = (int)(exp2((3 - i) / 3.0) * (1 << 20));
if (v <= 0)
v = 1;
s->scale_factor_table[i] = v;
#if USE_FLOATS
s->scale_factor_inv_table[i] = exp2(-(3 - i) / 3.0) / (float)(1 << 20);
#else
#define P 15
s->scale_factor_shift[i] = 21 - P - (i / 3);
s->scale_factor_mult[i] = (1 << P) * exp2((i % 3) / 3.0);
#endif
}
for(i=0;i<128;i++) {
v = i - 64;
if (v <= -3)
v = 0;
else if (v < 0)
v = 1;
else if (v == 0)
v = 2;
else if (v < 3)
v = 3;
else
v = 4;
s->scale_diff_table[i] = v;
}
for(i=0;i<17;i++) {
v = ff_mpa_quant_bits[i];
if (v < 0)
v = -v;
else
v = v * 3;
s->total_quant_bits[i] = 12 * v;
}
return 0;
}
| 1threat
|
void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
{
BlockDriverState *bs;
QObject *obj;
Visitor *v = qmp_output_visitor_new(&obj);
QDict *qdict;
Error *local_err = NULL;
visit_type_BlockdevOptions(v, NULL, &options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto fail;
}
visit_complete(v, &obj);
qdict = qobject_to_qdict(obj);
qdict_flatten(qdict);
if (!qdict_get_try_str(qdict, "node-name")) {
error_setg(errp, "'node-name' must be specified for the root node");
goto fail;
}
bs = bds_tree_init(qdict, errp);
if (!bs) {
goto fail;
}
QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
if (bs && bdrv_key_required(bs)) {
QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);
bdrv_unref(bs);
error_setg(errp, "blockdev-add doesn't support encrypted devices");
goto fail;
}
fail:
visit_free(v);
}
| 1threat
|
static void create_flash(const VirtBoardInfo *vbi)
{
hwaddr flashsize = vbi->memmap[VIRT_FLASH].size / 2;
hwaddr flashbase = vbi->memmap[VIRT_FLASH].base;
char *nodename;
if (bios_name) {
char *fn;
int image_size;
if (drive_get(IF_PFLASH, 0, 0)) {
error_report("The contents of the first flash device may be "
"specified with -bios or with -drive if=pflash... "
"but you cannot use both options at once");
exit(1);
}
fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (!fn) {
error_report("Could not find ROM image '%s'", bios_name);
exit(1);
}
image_size = load_image_targphys(fn, flashbase, flashsize);
g_free(fn);
if (image_size < 0) {
error_report("Could not load ROM image '%s'", bios_name);
exit(1);
}
g_free(fn);
}
create_one_flash("virt.flash0", flashbase, flashsize);
create_one_flash("virt.flash1", flashbase + flashsize, flashsize);
nodename = g_strdup_printf("/flash@%" PRIx64, flashbase);
qemu_fdt_add_subnode(vbi->fdt, nodename);
qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", "cfi-flash");
qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
2, flashbase, 2, flashsize,
2, flashbase + flashsize, 2, flashsize);
qemu_fdt_setprop_cell(vbi->fdt, nodename, "bank-width", 4);
g_free(nodename);
}
| 1threat
|
Split a sentence into an array of string without knowing the size : 1.How to Split a sentence into an array of string[words] when i am taking the sentence from the user and i don't know the number of words in the sentence.
Example-
Sentence:"why are you here?"
str[0]="why"
str[1]="are"
str[2]="you"
str[3]="here?"
2.How to compare "here" and "here?" ?
| 0debug
|
How can I implement a rotative banner for my android app? : on my login activity I would like to have a banner (3 actually) which would switch by certain time... Just like news on a website. With an arrow to pass to the next one, but mainly that passes automaticaly
An example of what I want:
[these images on Tinder login screen switch when I swipe or just wait][1]
[1]: https://i.stack.imgur.com/RZXZF.jpg
How do I do something like this on Android Studio? Is there a way to do it natively? or at leats there is a external resource for that?
| 0debug
|
int bdrv_key_required(BlockDriverState *bs)
{
BlockDriverState *backing_hd = bs->backing_hd;
if (backing_hd && backing_hd->encrypted && !backing_hd->valid_key)
return 1;
return (bs->encrypted && !bs->valid_key);
}
| 1threat
|
static int ehci_execute(EHCIPacket *p, const char *action)
{
USBEndpoint *ep;
int ret;
int endp;
if (!(p->qtd.token & QTD_TOKEN_ACTIVE)) {
fprintf(stderr, "Attempting to execute inactive qtd\n");
return USB_RET_PROCERR;
}
p->tbytes = (p->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;
if (p->tbytes > BUFF_SIZE) {
ehci_trace_guest_bug(p->queue->ehci,
"guest requested more bytes than allowed");
return USB_RET_PROCERR;
}
p->pid = (p->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;
switch (p->pid) {
case 0:
p->pid = USB_TOKEN_OUT;
break;
case 1:
p->pid = USB_TOKEN_IN;
break;
case 2:
p->pid = USB_TOKEN_SETUP;
break;
default:
fprintf(stderr, "bad token\n");
break;
}
if (ehci_init_transfer(p) != 0) {
return USB_RET_PROCERR;
}
endp = get_field(p->queue->qh.epchar, QH_EPCHAR_EP);
ep = usb_ep_get(p->queue->dev, p->pid, endp);
usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr);
usb_packet_map(&p->packet, &p->sgl);
trace_usb_ehci_packet_action(p->queue, p, action);
ret = usb_handle_packet(p->queue->dev, &p->packet);
DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "
"(total %d) endp %x ret %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->pid,
q->packet.iov.size, q->tbytes, endp, ret);
if (ret > BUFF_SIZE) {
fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n");
return USB_RET_PROCERR;
}
return ret;
}
| 1threat
|
How to select the last blcok element in a repeated html in webdriver : This is the html code. I want to select export csv of the last block. which is present in a drop down tringle mark whose xpath is
".//*[@id='table-view-views']/div/div[1]/ul/li[12]/a/span"
Highlighted mark having same **div** and **ul** tags but diffrent **li** tag. so I want to select last block element through csspath.
Can anybody help.
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/oFAZC.png
| 0debug
|
static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
{
SCSIDevice *d = virtio_scsi_device_find(s, req->req.tmf.lun);
SCSIRequest *r, *next;
BusChild *kid;
int target;
int ret = 0;
if (s->dataplane_started && bdrv_get_aio_context(d->conf.bs) != s->ctx) {
aio_context_acquire(s->ctx);
bdrv_set_aio_context(d->conf.bs, s->ctx);
aio_context_release(s->ctx);
}
req->resp.tmf.response = VIRTIO_SCSI_S_OK;
virtio_tswap32s(VIRTIO_DEVICE(s), &req->req.tmf.subtype);
switch (req->req.tmf.subtype) {
case VIRTIO_SCSI_T_TMF_ABORT_TASK:
case VIRTIO_SCSI_T_TMF_QUERY_TASK:
if (!d) {
goto fail;
}
if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) {
goto incorrect_lun;
}
QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) {
VirtIOSCSIReq *cmd_req = r->hba_private;
if (cmd_req && cmd_req->req.cmd.tag == req->req.tmf.tag) {
break;
}
}
if (r) {
assert(r->hba_private);
if (req->req.tmf.subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK) {
req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED;
} else {
VirtIOSCSICancelNotifier *notifier;
req->remaining = 1;
notifier = g_slice_new(VirtIOSCSICancelNotifier);
notifier->tmf_req = req;
notifier->notifier.notify = virtio_scsi_cancel_notify;
scsi_req_cancel_async(r, ¬ifier->notifier);
ret = -EINPROGRESS;
}
}
break;
case VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET:
if (!d) {
goto fail;
}
if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) {
goto incorrect_lun;
}
s->resetting++;
qdev_reset_all(&d->qdev);
s->resetting--;
break;
case VIRTIO_SCSI_T_TMF_ABORT_TASK_SET:
case VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET:
case VIRTIO_SCSI_T_TMF_QUERY_TASK_SET:
if (!d) {
goto fail;
}
if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) {
goto incorrect_lun;
}
req->remaining = 1;
QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) {
if (r->hba_private) {
if (req->req.tmf.subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK_SET) {
req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED;
break;
} else {
VirtIOSCSICancelNotifier *notifier;
req->remaining++;
notifier = g_slice_new(VirtIOSCSICancelNotifier);
notifier->notifier.notify = virtio_scsi_cancel_notify;
notifier->tmf_req = req;
scsi_req_cancel_async(r, ¬ifier->notifier);
}
}
}
if (--req->remaining > 0) {
ret = -EINPROGRESS;
}
break;
case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET:
target = req->req.tmf.lun[1];
s->resetting++;
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
d = DO_UPCAST(SCSIDevice, qdev, kid->child);
if (d->channel == 0 && d->id == target) {
qdev_reset_all(&d->qdev);
}
}
s->resetting--;
break;
case VIRTIO_SCSI_T_TMF_CLEAR_ACA:
default:
req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_REJECTED;
break;
}
return ret;
incorrect_lun:
req->resp.tmf.response = VIRTIO_SCSI_S_INCORRECT_LUN;
return ret;
fail:
req->resp.tmf.response = VIRTIO_SCSI_S_BAD_TARGET;
return ret;
}
| 1threat
|
Allow user to name and select location of exported table : <p>I've got a table called 'resultsHt'. I'd like to prompt the user to select a filename and directory for it to output to. I've had a look round and can't spot an easy way to do it that works on mac and windows. I'd be grateful for your help!</p>
| 0debug
|
static int decode_update_thread_context(AVCodecContext *dst,
const AVCodecContext *src)
{
H264Context *h = dst->priv_data, *h1 = src->priv_data;
int inited = h->context_initialized, err = 0;
int context_reinitialized = 0;
int i, ret;
if (dst == src || !h1->context_initialized)
return 0;
if (inited &&
(h->width != h1->width ||
h->height != h1->height ||
h->mb_width != h1->mb_width ||
h->mb_height != h1->mb_height ||
h->sps.bit_depth_luma != h1->sps.bit_depth_luma ||
h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
h->sps.colorspace != h1->sps.colorspace)) {
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
av_freep(&h->bipred_scratchpad);
h->width = h1->width;
h->height = h1->height;
h->mb_height = h1->mb_height;
h->mb_width = h1->mb_width;
h->mb_num = h1->mb_num;
h->mb_stride = h1->mb_stride;
h->b_stride = h1->b_stride;
if ((err = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
return err;
}
context_reinitialized = 1;
h->linesize = h1->linesize;
h->uvlinesize = h1->uvlinesize;
memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
}
if (!inited) {
for (i = 0; i < MAX_SPS_COUNT; i++)
av_freep(h->sps_buffers + i);
for (i = 0; i < MAX_PPS_COUNT; i++)
av_freep(h->pps_buffers + i);
memcpy(h, h1, sizeof(*h1));
memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
memset(&h->er, 0, sizeof(h->er));
memset(&h->me, 0, sizeof(h->me));
memset(&h->mb, 0, sizeof(h->mb));
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
h->context_initialized = 0;
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
avcodec_get_frame_defaults(&h->cur_pic.f);
h->cur_pic.tf.f = &h->cur_pic.f;
h->avctx = dst;
h->DPB = NULL;
h->qscale_table_pool = NULL;
h->mb_type_pool = NULL;
h->ref_index_pool = NULL;
h->motion_val_pool = NULL;
ret = ff_h264_alloc_tables(h);
if (ret < 0) {
av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n");
return ret;
}
ret = context_init(h);
if (ret < 0) {
av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
return ret;
}
for (i = 0; i < 2; i++) {
h->rbsp_buffer[i] = NULL;
h->rbsp_buffer_size[i] = 0;
}
h->bipred_scratchpad = NULL;
h->edge_emu_buffer = NULL;
h->thread_context[0] = h;
h->context_initialized = 1;
}
h->avctx->coded_height = h1->avctx->coded_height;
h->avctx->coded_width = h1->avctx->coded_width;
h->avctx->width = h1->avctx->width;
h->avctx->height = h1->avctx->height;
h->coded_picture_number = h1->coded_picture_number;
h->first_field = h1->first_field;
h->picture_structure = h1->picture_structure;
h->qscale = h1->qscale;
h->droppable = h1->droppable;
h->data_partitioning = h1->data_partitioning;
h->low_delay = h1->low_delay;
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
unref_picture(h, &h->DPB[i]);
if (h1->DPB[i].f.data[0] &&
(ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
return ret;
}
h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
unref_picture(h, &h->cur_pic);
if ((ret = ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)
return ret;
h->workaround_bugs = h1->workaround_bugs;
h->low_delay = h1->low_delay;
h->droppable = h1->droppable;
err = alloc_scratch_buffers(h, h1->linesize);
if (err < 0)
return err;
h->is_avc = h1->is_avc;
if ((ret = copy_parameter_set((void **)h->sps_buffers,
(void **)h1->sps_buffers,
MAX_SPS_COUNT, sizeof(SPS))) < 0)
return ret;
h->sps = h1->sps;
if ((ret = copy_parameter_set((void **)h->pps_buffers,
(void **)h1->pps_buffers,
MAX_PPS_COUNT, sizeof(PPS))) < 0)
return ret;
h->pps = h1->pps;
copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
for (i = 0; i < 6; i++)
h->dequant4_coeff[i] = h->dequant4_buffer[0] +
(h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
for (i = 0; i < 6; i++)
h->dequant8_coeff[i] = h->dequant8_buffer[0] +
(h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
h->dequant_coeff_pps = h1->dequant_coeff_pps;
copy_fields(h, h1, poc_lsb, redundant_pic_count);
copy_fields(h, h1, short_ref, cabac_init_idc);
copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
copy_picture_range(h->delayed_pic, h1->delayed_pic,
MAX_DELAYED_PIC_COUNT + 2, h, h1);
h->last_slice_type = h1->last_slice_type;
if (context_reinitialized)
h264_set_parameter_from_sps(h);
if (!h->cur_pic_ptr)
return 0;
if (!h->droppable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb;
}
h->prev_frame_num_offset = h->frame_num_offset;
h->prev_frame_num = h->frame_num;
h->outputed_poc = h->next_outputed_poc;
h->recovery_frame = h1->recovery_frame;
h->frame_recovered = h1->frame_recovered;
return err;
}
| 1threat
|
static void init_timetables( FM_OPL *OPL , int ARRATE , int DRRATE )
{
int i;
double rate;
for (i = 0;i < 4;i++) OPL->AR_TABLE[i] = OPL->DR_TABLE[i] = 0;
for (i = 4;i <= 60;i++){
rate = OPL->freqbase;
if( i < 60 ) rate *= 1.0+(i&3)*0.25;
rate *= 1<<((i>>2)-1);
rate *= (double)(EG_ENT<<ENV_BITS);
OPL->AR_TABLE[i] = rate / ARRATE;
OPL->DR_TABLE[i] = rate / DRRATE;
}
for (i = 60;i < 76;i++)
{
OPL->AR_TABLE[i] = EG_AED-1;
OPL->DR_TABLE[i] = OPL->DR_TABLE[60];
}
#if 0
for (i = 0;i < 64 ;i++){
LOG(LOG_WAR,("rate %2d , ar %f ms , dr %f ms \n",i,
((double)(EG_ENT<<ENV_BITS) / OPL->AR_TABLE[i]) * (1000.0 / OPL->rate),
((double)(EG_ENT<<ENV_BITS) / OPL->DR_TABLE[i]) * (1000.0 / OPL->rate) ));
}
#endif
}
| 1threat
|
Throws Exception catch childException... why not? : Say I have a method doSomething() which throws a checked exception, then in my main method I enclose doSomething() in a try catch.
Question:
Say I "throws Exception" in doSomething(). Why can't I "catch (ChildException e)" in my main method?
I know I can't and that I must catch Exception, but I don't understand why.
ChildException extends Exception.
If I throws ChildException and catch Exception then there's no problem understandably so. Why not the other way round?
| 0debug
|
void qemu_clock_register_reset_notifier(QEMUClockType type,
Notifier *notifier)
{
QEMUClock *clock = qemu_clock_ptr(type);
notifier_list_add(&clock->reset_notifiers, notifier);
}
| 1threat
|
Display new line in mail body : <p>I want to insert new line in mail body paragraphs .I have searched all the other same questions but none of them seems to work </p>
<pre><code>$body = "Dear $surname $name \r\n
Thank you for your Pre-registration for Global .\r\n
Please print the attached e-ticket with your personal barcode and bring it to the reception of the exhibition.\r\n
This barcode includes data about you which is required during registration. Having this barcode will considerably speed up the registration process
Organizing committee.\r\n".
$body = "Print e-ticket
($imageurl) .\r\n".
</code></pre>
<p>This method displays all in one line
How to change it to display it properly ?
Thank you</p>
| 0debug
|
GKE & Stackdriver: Java logback logging format? : <p>I have a project running Java in a docker image on Kubernetes. Logs are automatically ingested by the fluentd agent and end up in Stackdriver.</p>
<p>However, the format of the logs is wrong: Multiline logs get put into separate log lines in Stackdriver, and all logs have "INFO" log level, even though they are really warning, or error.</p>
<p>I have been searching for information on how to configure logback to output the correct format for this to work properly, but I can find no such guide in the google Stackdriver or GKE documentation.</p>
<p>My guess is that I should be outputting JSON of some form, but where do I find information on the format, or even a guide on how to properly set up this pipeline.</p>
<p>Thanks!</p>
| 0debug
|
How to create a self-referential Python 3 Enum? : <p>Can I create an enum class <code>RockPaperScissors</code> such that <code>ROCK.value == "rock"</code> and <code>ROCK.beats == SCISSORS</code>, where <code>ROCK</code> and <code>SCISSORS</code> are both constants in <code>RockPaperScissors</code>?</p>
| 0debug
|
How import object from external JS file in React JS using web pack : <p>I am building on my knowledge of React JS and I would like to import/include some external JS files that hold nothing more than an objects / object arrays. I've done this in jQuery, Vanilla JS and even in Angular JS. Sweet!!! </p>
<p>How can I achieve the same thing in React JS.</p>
<p>I have the following as my index.html:</p>
<pre><code><!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello React</title>
</head>
<body>
<div id="hello"></div>
<div id="world"></div>
<div id="caseListing"></div>
<script src="js/bundle.js"></script>
</body>
</html>
</code></pre>
<p>and my main.js (entry file) as the following:</p>
<pre><code>import Hello from './jsx/hello.jsx';
import World from './jsx/world.jsx';
var $ = require('./lib/jquery.js');
window.jQuery = $;
window.$ = $;
var Jobs = require('./data/jobs.js');
console.log('Jobs:', Jobs);
</code></pre>
<p>Here, I have Jobs.js as:</p>
<pre><code>var Jobs = (function () {
"use strict";
return {
"jobs": [
{
"jobType": "Web developer",
"desc": "Creates website"
},
{
"jobType": "Bin Man",
"desc": "Collects bins"
}
]
};
}());
</code></pre>
<p>And just for good measure, my webpack.config.js looks like this:</p>
<pre><code>var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'./js/main.js'
],
output: {
path: __dirname,
filename: 'js/bundle.js'
},
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
'es2015',
'react'
]
}
}
]
}
};
</code></pre>
<p>All help will be appreciated. :)</p>
| 0debug
|
static always_inline void gen_qemu_stf (TCGv t0, TCGv t1, int flags)
{
TCGv tmp = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_helper_1_1(helper_f_to_memory, tmp, t0);
tcg_gen_qemu_st32(tmp, t1, flags);
tcg_temp_free(tmp);
}
| 1threat
|
static void opt_qsquish(const char *arg)
{
video_qsquish = atof(arg);
if (video_qsquish < 0.0 ||
video_qsquish > 99.0) {
fprintf(stderr, "qsquish must be >= 0.0 and <= 99.0\n");
exit(1);
}
}
| 1threat
|
static int decode_slice(MpegEncContext *s)
{
const int part_mask = s->partitioned_frame
? (ER_AC_END | ER_AC_ERROR) : 0x7F;
const int mb_size = 16;
int ret;
s->last_resync_gb = s->gb;
s->first_slice_line = 1;
s->resync_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y;
ff_set_qscale(s, s->qscale);
if (s->avctx->hwaccel) {
const uint8_t *start = s->gb.buffer + get_bits_count(&s->gb) / 8;
const uint8_t *end = ff_h263_find_resync_marker(start + 1,
s->gb.buffer_end);
skip_bits_long(&s->gb, 8 * (end - start));
return s->avctx->hwaccel->decode_slice(s->avctx, start, end - start);
}
if (s->partitioned_frame) {
const int qscale = s->qscale;
if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4)
if ((ret = ff_mpeg4_decode_partitions(s->avctx->priv_data)) < 0)
return ret;
s->first_slice_line = 1;
s->mb_x = s->resync_mb_x;
s->mb_y = s->resync_mb_y;
ff_set_qscale(s, qscale);
}
for (; s->mb_y < s->mb_height; s->mb_y++) {
if (s->msmpeg4_version) {
if (s->resync_mb_y + s->slice_height == s->mb_y) {
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x - 1, s->mb_y, ER_MB_END);
return 0;
}
}
if (s->msmpeg4_version == 1) {
s->last_dc[0] =
s->last_dc[1] =
s->last_dc[2] = 128;
}
ff_init_block_index(s);
for (; s->mb_x < s->mb_width; s->mb_x++) {
int ret;
ff_update_block_index(s);
if (s->resync_mb_x == s->mb_x && s->resync_mb_y + 1 == s->mb_y)
s->first_slice_line = 0;
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
ff_dlog(s, "%d %d %06X\n",
ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
ret = s->decode_mb(s, s->block);
if (s->pict_type != AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
if (ret < 0) {
const int xy = s->mb_x + s->mb_y * s->mb_stride;
if (ret == SLICE_END) {
ff_mpv_decode_mb(s, s->block);
if (s->loop_filter)
ff_h263_loop_filter(s);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x, s->mb_y, ER_MB_END & part_mask);
s->padding_bug_score--;
if (++s->mb_x >= s->mb_width) {
s->mb_x = 0;
ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size);
ff_mpv_report_decode_progress(s);
s->mb_y++;
}
return 0;
} else if (ret == SLICE_NOEND) {
av_log(s->avctx, AV_LOG_ERROR,
"Slice mismatch at MB: %d\n", xy);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x + 1, s->mb_y,
ER_MB_END & part_mask);
return AVERROR_INVALIDDATA;
}
av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
return AVERROR_INVALIDDATA;
}
ff_mpv_decode_mb(s, s->block);
if (s->loop_filter)
ff_h263_loop_filter(s);
}
ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size);
ff_mpv_report_decode_progress(s);
s->mb_x = 0;
}
assert(s->mb_x == 0 && s->mb_y == s->mb_height);
if (s->codec_id == AV_CODEC_ID_MPEG4 &&
(s->workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&s->gb) >= 48 &&
show_bits(&s->gb, 24) == 0x4010 &&
!s->data_partitioning)
s->padding_bug_score += 32;
if (s->codec_id == AV_CODEC_ID_MPEG4 &&
(s->workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&s->gb) >= 0 &&
get_bits_left(&s->gb) < 48 &&
!s->data_partitioning) {
const int bits_count = get_bits_count(&s->gb);
const int bits_left = s->gb.size_in_bits - bits_count;
if (bits_left == 0) {
s->padding_bug_score += 16;
} else if (bits_left != 1) {
int v = show_bits(&s->gb, 8);
v |= 0x7F >> (7 - (bits_count & 7));
if (v == 0x7F && bits_left <= 8)
s->padding_bug_score--;
else if (v == 0x7F && ((get_bits_count(&s->gb) + 8) & 8) &&
bits_left <= 16)
s->padding_bug_score += 4;
else
s->padding_bug_score++;
}
}
if (s->workaround_bugs & FF_BUG_AUTODETECT) {
if (s->codec_id == AV_CODEC_ID_H263 ||
(s->padding_bug_score > -2 && !s->data_partitioning))
s->workaround_bugs |= FF_BUG_NO_PADDING;
else
s->workaround_bugs &= ~FF_BUG_NO_PADDING;
}
if (s->msmpeg4_version || (s->workaround_bugs & FF_BUG_NO_PADDING)) {
int left = get_bits_left(&s->gb);
int max_extra = 7;
if (s->msmpeg4_version && s->pict_type == AV_PICTURE_TYPE_I)
max_extra += 17;
if ((s->workaround_bugs & FF_BUG_NO_PADDING) &&
(s->avctx->err_recognition & AV_EF_BUFFER))
max_extra += 48;
else if ((s->workaround_bugs & FF_BUG_NO_PADDING))
max_extra += 256 * 256 * 256 * 64;
if (left > max_extra)
av_log(s->avctx, AV_LOG_ERROR,
"discarding %d junk bits at end, next would be %X\n",
left, show_bits(&s->gb, 24));
else if (left < 0)
av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
else
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x - 1, s->mb_y, ER_MB_END);
return 0;
}
av_log(s->avctx, AV_LOG_ERROR,
"slice end not reached but screenspace end (%d left %06X, score= %d)\n",
get_bits_left(&s->gb), show_bits(&s->gb, 24), s->padding_bug_score);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y,
ER_MB_END & part_mask);
return AVERROR_INVALIDDATA;
}
| 1threat
|
static NVDIMMDevice *nvdimm_get_device_by_handle(uint32_t handle)
{
NVDIMMDevice *nvdimm = NULL;
GSList *list, *device_list = nvdimm_get_plugged_device_list();
for (list = device_list; list; list = list->next) {
NVDIMMDevice *nvd = list->data;
int slot = object_property_get_int(OBJECT(nvd), PC_DIMM_SLOT_PROP,
NULL);
if (nvdimm_slot_to_handle(slot) == handle) {
nvdimm = nvd;
break;
}
}
g_slist_free(device_list);
return nvdimm;
}
| 1threat
|
Does anyone know why the getAllLoyaltyCards method is returning a hex value and not the items of the list : I have no idea why this is returning a hex value, and i am only a beginner at Java.
public class LoyaltyCardList
{
private ArrayList <LoyaltyCard> LoyaltyCards;
/**
*
*/
public LoyaltyCardList()
{
LoyaltyCards = new ArrayList <LoyaltyCard> ();
}
/**
*
*/
public void addLoyaltyCard(LoyaltyCard newLoyaltyCard)
{
LoyaltyCards.add(newLoyaltyCard);
}
public void getAllLoyaltyCards()
{
for ( LoyaltyCard loyaltyCard : LoyaltyCards)
{
System.out.println(LoyaltyCards);
}
}
| 0debug
|
Make this bootstrap nav submenu always open : i have a code to make bs nav, but i dont understand how to make submenu always open without clicking menu name.
this is the code :
jsfiddle.net/6hrmodok/2/
and please answer this question with the new code. thankyou
| 0debug
|
static void aux_slave_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_MISC, k->categories);
k->bus_type = TYPE_AUX_BUS;
}
| 1threat
|
How to execute update ($set) queries in MongoDB Compass tool? : <p>I'm new to MongoDB Compass tool and am trying to update a field in my collection. Please can someone suggest where the update query must be written. Could find no options or panes in the tool to write custom queries be it selection / updation for that matter.</p>
<p>In the Default Window only the selection/projection/restriction options are found.
Any help is much appreciated.</p>
| 0debug
|
i want to make a calculator whose calculation is done on second page and displayed on third page values are taken from first page : //This is mainactivity.java
package com.example.bhask.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
EditText et1,et2;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=(EditText)findViewById(R.id.et1);
et2=(EditText)findViewById(R.id.et2);
btn=(Button)findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String v1=et1.getText().toString();
String v2=et2.getText().toString();
int val1=Integer.parseInt(v1);
int val2=Integer.parseInt(v2);
int sum =val1+val2;
Intent i=new Intent(MainActivity.this,Main2Activity.class);
i.putExtra("val1","Num1 is"+val1);
i.putExtra("val2","Num2 is: "+val2);
startActivity(i);
}
});
}
}
//This is main2.activty.java
package com.example.bhask.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Main2Activity extends AppCompatActivity {
Button btn1,btn2,btn3,btn4;
static int ans;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
btn1=(Button)findViewById(R.id.btn1);
Intent i=getIntent();
final int val1 = i.getIntExtra("val1",0);
final int val2 = i.getIntExtra("val2",0);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int ans=val1+val2;
Intent i1=new Intent(Main2Activity.this,Main3Activity.class);
i1.putExtra("ans","Add is "+ans);
startActivity(i1);
finish();
}
});
}
}
//This is main3activity.java
package com.example.bhask.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class Main3Activity extends AppCompatActivity {
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
Toast.makeText(getApplicationContext(),"Here",Toast.LENGTH_LONG).show();
tv=(TextView)findViewById(R.id.tv);
Intent i2=getIntent();
String data=i2.getStringExtra("ans");
tv.setText(data);
}
}
| 0debug
|
static void test_flush_event_notifier(void)
{
EventNotifierTestData data = { .n = 0, .active = 10, .auto_set = true };
event_notifier_init(&data.e, false);
aio_set_event_notifier(ctx, &data.e, event_ready_cb);
g_assert(!aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 0);
g_assert_cmpint(data.active, ==, 10);
event_notifier_set(&data.e);
g_assert(aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 1);
g_assert_cmpint(data.active, ==, 9);
g_assert(aio_poll(ctx, false));
wait_until_inactive(&data);
g_assert_cmpint(data.n, ==, 10);
g_assert_cmpint(data.active, ==, 0);
g_assert(!aio_poll(ctx, false));
aio_set_event_notifier(ctx, &data.e, NULL);
g_assert(!aio_poll(ctx, false));
event_notifier_cleanup(&data.e);
}
| 1threat
|
my JavaScript using jQuery is not working : <p>I have a small program html and js program</p>
<p>HTML:</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="temp.js"></script>
</head>
<body>
<div id='display'></div>
<input type="button" id="creation" value="Create"/>
</body>
</code></pre>
<p>temp.js</p>
<pre><code>$(document).ready(function() {
$('#creation').click(function() {
alert("hi");
});
});
</code></pre>
<p>Can any one help me find the mistake in this above programs. when i click the create button it should alert me "hi". appreciate your help</p>
| 0debug
|
static void unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
{
int i, j, k;
int coding_mode;
int motion_x[6];
int motion_y[6];
int last_motion_x = 0;
int last_motion_y = 0;
int prior_last_motion_x = 0;
int prior_last_motion_y = 0;
int current_macroblock;
int current_fragment;
debug_vp3(" vp3: unpacking motion vectors\n");
if (s->keyframe) {
debug_vp3(" keyframe-- there are no motion vectors\n");
} else {
memset(motion_x, 0, 6 * sizeof(int));
memset(motion_y, 0, 6 * sizeof(int));
coding_mode = get_bits(gb, 1);
debug_vectors(" using %s scheme for unpacking motion vectors\n",
(coding_mode == 0) ? "VLC" : "fixed-length");
for (i = 0; i < s->u_superblock_start; i++) {
for (j = 0; j < 4; j++) {
current_macroblock = s->superblock_macroblocks[i * 4 + j];
if ((current_macroblock == -1) ||
(!s->macroblock_coded[current_macroblock]))
continue;
current_fragment = s->macroblock_fragments[current_macroblock * 6];
switch (s->all_fragments[current_fragment].coding_method) {
case MODE_INTER_PLUS_MV:
case MODE_GOLDEN_MV:
if (coding_mode == 0) {
motion_x[0] = get_motion_vector_vlc(gb);
motion_y[0] = get_motion_vector_vlc(gb);
} else {
motion_x[0] = get_motion_vector_fixed(gb);
motion_y[0] = get_motion_vector_fixed(gb);
}
for (k = 1; k < 6; k++) {
motion_x[k] = motion_x[0];
motion_y[k] = motion_y[0];
}
if (s->all_fragments[current_fragment].coding_method ==
MODE_INTER_PLUS_MV) {
prior_last_motion_x = last_motion_x;
prior_last_motion_y = last_motion_y;
last_motion_x = motion_x[0];
last_motion_y = motion_y[0];
}
break;
case MODE_INTER_FOURMV:
motion_x[4] = motion_y[4] = 0;
for (k = 0; k < 4; k++) {
if (coding_mode == 0) {
motion_x[k] = get_motion_vector_vlc(gb);
motion_y[k] = get_motion_vector_vlc(gb);
} else {
motion_x[k] = get_motion_vector_fixed(gb);
motion_y[k] = get_motion_vector_fixed(gb);
}
motion_x[4] += motion_x[k];
motion_y[4] += motion_y[k];
}
if (motion_x[4] >= 0)
motion_x[4] = (motion_x[4] + 2) / 4;
else
motion_x[4] = (motion_x[4] - 2) / 4;
motion_x[5] = motion_x[4];
if (motion_y[4] >= 0)
motion_y[4] = (motion_y[4] + 2) / 4;
else
motion_y[4] = (motion_y[4] - 2) / 4;
motion_y[5] = motion_y[4];
prior_last_motion_x = last_motion_x;
prior_last_motion_y = last_motion_y;
last_motion_x = motion_x[3];
last_motion_y = motion_y[3];
break;
case MODE_INTER_LAST_MV:
motion_x[0] = last_motion_x;
motion_y[0] = last_motion_y;
for (k = 1; k < 6; k++) {
motion_x[k] = motion_x[0];
motion_y[k] = motion_y[0];
}
break;
case MODE_INTER_PRIOR_LAST:
motion_x[0] = prior_last_motion_x;
motion_y[0] = prior_last_motion_y;
for (k = 1; k < 6; k++) {
motion_x[k] = motion_x[0];
motion_y[k] = motion_y[0];
}
prior_last_motion_x = last_motion_x;
prior_last_motion_y = last_motion_y;
last_motion_x = motion_x[0];
last_motion_y = motion_y[0];
break;
default:
memset(motion_x, 0, 6 * sizeof(int));
memset(motion_y, 0, 6 * sizeof(int));
break;
}
debug_vectors(" vectors for macroblock starting @ fragment %d (coding method %d):\n",
current_fragment,
s->all_fragments[current_fragment].coding_method);
for (k = 0; k < 6; k++) {
current_fragment =
s->macroblock_fragments[current_macroblock * 6 + k];
s->all_fragments[current_fragment].motion_halfpel_index =
adjust_vector(&motion_x[k], &motion_y[k],
((k == 4) || (k == 5)));
s->all_fragments[current_fragment].motion_x = motion_x[k];
s->all_fragments[current_fragment].motion_y = motion_y[k];
debug_vectors(" vector %d: fragment %d = (%d, %d), index %d\n",
k, current_fragment, motion_x[k], motion_y[k],
s->all_fragments[current_fragment].motion_halfpel_index);
}
}
}
}
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.