problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Referring to resources named with variables in Terraform : <p>I'm trying to create a module in Terraform that can be instantiated multiple times with different variable inputs. Within the module, how do I reference resources when their names depend on an input variable? I'm trying to do it via the bracket syntax (<code>"${aws_ecs_task_definition[var.name].arn}"</code>) but I just guessed at that.</p>
<p>(Caveat: I might be going about this in completely the wrong way)</p>
<p>Here's my module's (simplified) <code>main.tf</code> file:</p>
<pre><code>variable "name" {}
resource "aws_ecs_service" "${var.name}" {
name = "${var.name}_service"
cluster = ""
task_definition = "${aws_ecs_task_definition[var.name].arn}"
desired_count = 1
}
resource "aws_ecs_task_definition" "${var.name}" {
family = "ecs-family-${var.name}"
container_definitions = "${template_file[var.name].rendered}"
}
resource "template_file" "${var.name}_task" {
template = "${file("task-definition.json")}"
vars {
name = "${var.name}"
}
}
</code></pre>
<p>I'm getting the following error:</p>
<pre><code>Error loading Terraform: Error downloading modules: module foo: Error loading .terraform/modules/af13a92c4edda294822b341862422ba5/main.tf: Error reading config for aws_ecs_service[${var.name}]: parse error: syntax error
</code></pre>
| 0debug |
Script dont fuction properly : I have an script that reads the file and compares the string by a pattern, if it returns false it will delete the line on the .txt file.
This is my code
```
const readline = require('readline');
const lineReplace = require('line-replace')
const fs = require('fs');
const inputFileName = './outputfinal.txt';
const readInterface = readline.createInterface({
input: fs.createReadStream(inputFileName),
});
let testResults = [];
readInterface.on('line', line => {
testResult = test(line);
console.log(`Test result (line #${testResults.length+1}): `, testResult);
testResults.push({ input: line, testResult } );
if (testResult == false){
console.log(`Line #${testResults.length} will get deleted from this list`);
lineReplace({
file: './outputfinal.txt',
line: testResults.length,
text: '',
addNewLine: false,
callback: onReplace
});
function onReplace({file, line, text, replacedText}) {
};
};
});
// You can do whatever with the test results here.
//readInterface.on('close', () => {
// console.log("Test results:", testResults);
//});
function test(str){
let regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; // email regex
str = str.split(",");
// string should be of length 3 with str[1] number of length 7
if(str && str.length === 3 && Number(str[1]) && str[1] ) {
let temp = str[0].split("-");
// check for 85aecb80-ac00-40e3-813c-5ad62ee93f42 separately.
if(temp && temp.length === 5 && /[a-zA-Z\d]{8}/.test(temp[0]) && /[a-zA-Z\d]{4}/.test(temp[1]) && /[a-zA-Z\d]{4}/.test(temp[2]) && /[a-zA-Z\d]{4}/.test(temp[3]) && /[a-zA-Z\d]{12}/.test(temp[4])){
// email regex
if(regex.test(str[2])) {
return true;
} else {
return false;
}
} else {
return false
}
} else {
return false;
}
}
```
But isn't working, returns error no such file or directory, I dont think that is the correct way to do a line remover script | 0debug |
int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb)
{
CPUS390XState *env = &cpu->env;
uint64_t addr;
int lowcore;
IOIntCode int_code;
hwaddr len;
int ret;
uint8_t ar;
trace_ioinst("tpi");
addr = decode_basedisp_s(env, ipb, &ar);
if (addr & 3) {
program_interrupt(env, PGM_SPECIFICATION, 2);
return -EIO;
}
lowcore = addr ? 0 : 1;
len = lowcore ? 8 : 12 ;
ret = css_do_tpi(&int_code, lowcore);
if (ret == 1) {
s390_cpu_virt_mem_write(cpu, lowcore ? 184 : addr, ar, &int_code, len);
}
return ret;
}
| 1threat |
Using ternary operator in c++ returns false condition always : <p>I am using a statement with ternary operator which is always returning the other value. </p>
<pre><code>BSTR pVal = L"Yes";
bool val = pVal == L"Yes" ? true : false;
</code></pre>
<p>this statement returns </p>
<pre><code> val = false;
</code></pre>
<p>I expect it to return true here. Am i making it wrong?</p>
| 0debug |
Making a simple page responsive through CSS : <p>I am using a simple half bootstrap / half designed by somebody login template. Now it opens just as it should through the web browser:</p>
<p><a href="https://i.stack.imgur.com/lKZNP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lKZNP.jpg" alt="enter image description here"></a></p>
<p>But when I open it through my mobile device it loads this way:</p>
<p><a href="https://i.stack.imgur.com/Jhvsl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jhvsl.png" alt="enter image description here"></a></p>
<p>And I want it to open in a close-up way like that:</p>
<p><a href="https://i.stack.imgur.com/D0YbC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D0YbC.png" alt="enter image description here"></a></p>
<p>Now here are my html and css:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
background: #eee !important;
}
.form-signin {
max-width: 380px;
padding: 15px 35px 30px;
margin: 20px auto;
background-color: #fff;
border: 1px round rgba(0, 0, 0, 0.1);
}
.form-signin .checkbox {
margin-bottom: 30px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 20px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.form-signin-heading {
color: #777;
}
.social-box{
margin: 0 auto;
padding: 20px 38px 0 38px;
}
.social-box a{
font-weight:bold;
font-size:18px;
padding:8px;
}
.social-box a i{
font-weight:bold;
font-size:20px;
}
.newborder {
border-bottom: 1px #ccc solid;
margin-top: 30px;
margin-bottom: 30px;
}
.omb_loginOr {
position: relative;
font-size: 1.5em;
color: #aaa;
margin-top: 1.5em;
margin-bottom: 2.2em;
padding-top: 0.5em;
padding-bottom: 0.5em;
}
.omb_loginOr .omb_hrOr {
background-color: #cdcdcd;
height: 1px;
margin-top: 0 !important;
margin-bottom: 0 !important;
}
.omb_loginOr .omb_spanOr {
display: block;
position: absolute;
left: 50%;
top: -0.3em;
margin-left: -1.5em;
background-color: white;
width: 3em;
text-align: center;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Bootstrap Snippet: Login Form</title>
<link rel="stylesheet" href="css/lstyle.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<div class="form-signin">
<form>
<h2 class="form-signin-heading text-center"><i class="fa fa-tint fa-fw"></i>Hello</h2>
<div class="social-box">
<div class="row mg-btm">
<div class="col-md-12">
<a href="#" class="btn btn-primary btn-block">
<i class="fa fa-facebook fa-fw"></i> Log in
</a>
</div>
</div>
</div>
<div class="newborder"></div>
<input type="text" class="form-control" name="username" placeholder="E-mail" required="" autofocus="" />
<input type="password" class="form-control" name="password" placeholder="Password" required=""/>
<label class="checkbox text-right">
<input type="checkbox" value="remember-me" id="rememberMe" name="rememberMe"> Remember me
</label>
<button class="btn btn-lg btn-info btn-block" type="submit">Log in</button>
</form>
<div class="row omb_loginOr ">
<hr class="omb_hrOr">
<span class="omb_spanOr">or</span>
</div>
<form>
<div class="alert alert-info"><p>No registration?</p></div>
<input type="text" class="form-control" name="username" placeholder="E-mail" required="" autofocus="" />
<input type="password" class="form-control" name="password" placeholder="Password required=""/>
<button class="btn btn-lg btn-info btn-block" type="submit">Register me & log in</button>
</form>
</div>
</div>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>Huge thanks in advance!</p>
| 0debug |
static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
{
XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
MemoryRegion *system_memory = get_system_memory();
uint8_t i;
const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
qemu_irq gic_spi[GIC_NUM_SPI_INTR];
Error *err = NULL;
for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) {
char *ocm_name = g_strdup_printf("zynqmp.ocm_ram_bank_%d", i);
memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name,
XLNX_ZYNQMP_OCM_RAM_SIZE, &error_abort);
vmstate_register_ram_global(&s->ocm_ram[i]);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_OCM_RAM_0_ADDRESS +
i * XLNX_ZYNQMP_OCM_RAM_SIZE,
&s->ocm_ram[i]);
g_free(ocm_name);
}
qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32);
qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2);
qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", XLNX_ZYNQMP_NUM_APU_CPUS);
object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS);
for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) {
SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic);
const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i];
MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index);
uint32_t addr = r->address;
int j;
sysbus_mmio_map(gic, r->region_index, addr);
for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) {
MemoryRegion *alias = &s->gic_mr[i][j];
addr += XLNX_ZYNQMP_GIC_REGION_SIZE;
memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr,
0, XLNX_ZYNQMP_GIC_REGION_SIZE);
memory_region_add_subregion(system_memory, addr, alias);
}
}
for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) {
qemu_irq irq;
char *name;
object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,
"psci-conduit", &error_abort);
name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));
if (strcmp(name, boot_cpu)) {
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->apu_cpu[i];
}
g_free(name);
object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR,
"reset-cbar", &error_abort);
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i,
qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
ARM_CPU_IRQ));
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 0, irq);
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 1, irq);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_RPU_CPUS; i++) {
char *name;
name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));
if (strcmp(name, boot_cpu)) {
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->rpu_cpu[i];
}
g_free(name);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs",
&error_abort);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(errp, err);
return;
}
}
if (!s->boot_cpu_ptr) {
error_setg(errp, "ZynqMP Boot cpu %s not found\n", boot_cpu);
return;
}
for (i = 0; i < GIC_NUM_SPI_INTR; i++) {
gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
NICInfo *nd = &nd_table[i];
if (nd->used) {
qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
qdev_set_nic_properties(DEVICE(&s->gem[i]), nd);
}
object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,
gic_spi[gem_intr[i]]);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
gic_spi[uart_intr[i]]);
}
object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports",
&error_abort);
object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
}
| 1threat |
static void parse_header_digest(struct iscsi_context *iscsi, const char *target)
{
QemuOptsList *list;
QemuOpts *opts;
const char *digest = NULL;
list = qemu_find_opts("iscsi");
if (!list) {
return;
}
opts = qemu_opts_find(list, target);
if (opts == NULL) {
opts = QTAILQ_FIRST(&list->head);
if (!opts) {
return;
}
}
digest = qemu_opt_get(opts, "header-digest");
if (!digest) {
return;
}
if (!strcmp(digest, "CRC32C")) {
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C);
} else if (!strcmp(digest, "NONE")) {
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE);
} else if (!strcmp(digest, "CRC32C-NONE")) {
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C_NONE);
} else if (!strcmp(digest, "NONE-CRC32C")) {
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
} else {
error_report("Invalid header-digest setting : %s", digest);
}
}
| 1threat |
Change color of external viewcontroller (swift) : I have a view controller and a container view in it. Unfortunately however, I am unable to change the color of the child view controller represented in the container view from the parent class. Changing the background color of the container view, which is the only thing I am able to reach from my parent view controller, does not change the background color of the referenced child, but only the invisible container view holding it.
Therefore, I have tested a method where I call a function from within the class of the child from the parent as shown below:
@IBAction func changeToRed(sender: viewController) {
self.view.backgroundColor = UIColor(red: 230/255, green: 80/255, blue: 30/255, alpha: 1.0)
}
(This is in the child view controller)
otherView().changeToRed(sender: self)
(This in the parent view controller)
This technique does not work. I have already tried it with a regular function and with random trial and error in the parent view controller. Is there anything obvious I am doing wrong? Or is there a potentially a different technique to do this? Thank you in advance!
| 0debug |
Is key-value pair available in Typescript? : <p>Is key,value pair available in typescript? If yes how to do that. Can anyone provide sample example links.</p>
| 0debug |
Could sqlite be used to Register, Login and logout in android application or use sharedpreferences? : I'm in the process of developing a application and I wanted to know if its better to use sharedpreferences to create a login, register and also logout functionality in android studio app instead of using Sqlite?
New to android development please help me out. Thank you | 0debug |
def is_woodall(x):
if (x % 2 == 0):
return False
if (x == 1):
return True
x = x + 1
p = 0
while (x % 2 == 0):
x = x/2
p = p + 1
if (p == x):
return True
return False | 0debug |
python code for user input : I'm creating an assignment for school
First create the pseudocode, etc
Then write a compare function that returns 1 if a > b , 0 if a == b , and -1 if a < b
I've written that part
def compare(a, b):
return (a > b) - (a < b)
BUT then I have to prompt the user to input the numbers for comparison. I have no idea how to write the user input prompt. If anyone can help me that would be greatly appreciated! | 0debug |
What is the problem in this code this is showing (";" expected) error. PS: i m a beginner : <pre><code>import java.util.*;
class Main
{ public static void main(String args[]){
int n = 3;
if (n%2==0){
if (2<=n<=5){
System.out.println("Not Weird");
}
elseif (6<=n<=20){
System.out.println("Weird");
}
elseif(n>20){
System.out.println("Not Weird");
}
}
else{
System.out.println("Weird");
}
}
}
</code></pre>
<p>// this code is showing ";" expected can somebody plz point out the mistake for me
// i m a beginner
// this code compare a no and checks whether it is odd or even </p>
| 0debug |
UseJwtBearerAuthentication does not get User.Identity.Name populated : <p>I am trying to use <code>JWT</code> for authentication mechanism in <code>ASP.NET Core Web API</code> project. Suppose this project has not <code>MVC</code> part and does not use cookie authentication. I have created my code based on <a href="https://goblincoding.com/2016/07/03/issuing-and-authenticating-jwt-tokens-in-asp-net-core-webapi-part-i/" rel="noreferrer">this guide</a>. </p>
<p>Login works good and protection with <code>[Authorize]</code> attribute works ok but <code>User.Identity.Name</code> is <code>null</code>. How can I fix this?</p>
<p>My code:</p>
<pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
var jwtAppSettingOptions = Configuration.GetSection(nameof(JwtIssuerOptions));
var tokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)],
ValidateAudience = true,
ValidAudience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)],
ValidateIssuerSigningKey = true,
IssuerSigningKey = _signingKey,
RequireExpirationTime = true,
ValidateLifetime = true,
ClockSkew = TimeSpan.Zero
};
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
TokenValidationParameters = tokenValidationParameters,
AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
</code></pre>
<hr>
<pre><code> [HttpPost]
[AllowAnonymous]
[Route("Login")]
public async Task<IActionResult> Login([FromForm] ApplicationUser applicationUser)
{
//assume user/pass are checked and are ok
_logger.LogInformation(1, "API User logged in.");
var user = await _userManager.FindByNameAsync(applicationUser.UserName);
var roles = await _userManager.GetRolesAsync(user);
var claims = new List<Claim>
{
new Claim(JwtRegisteredClaimNames.Sub, applicationUser.UserName),
new Claim(ClaimTypes.NameIdentifier, applicationUser.UserName),
new Claim(JwtRegisteredClaimNames.Jti, await _jwtOptions.JtiGenerator()),
new Claim(JwtRegisteredClaimNames.Iat,
ToUnixEpochDate(_jwtOptions.IssuedAt).ToString(),
ClaimValueTypes.Integer64),
new Claim("Claim", "Value")
};
if (roles != null)
foreach (var role in roles)
claims.Add(new Claim("role", role));
// Create the JWT security token and encode it.
var jwt = new JwtSecurityToken(
issuer: _jwtOptions.Issuer,
audience: _jwtOptions.Audience,
claims: claims,
notBefore: _jwtOptions.NotBefore,
expires: _jwtOptions.Expiration,
signingCredentials: _jwtOptions.SigningCredentials);
var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt);
// Serialize and return the response
var response = new
{
access_token = encodedJwt,
expires_in = (int)_jwtOptions.ValidFor.TotalSeconds
};
var json = JsonConvert.SerializeObject(response, _serializerSettings);
return new OkObjectResult(json);
}
</code></pre>
| 0debug |
Error: npm is known not to run on Node.js V4.2.6 : <p>how can I solve the following error? I use Ubuntu 16.
When I run any npm command such as "npm run dev" I get this error:</p>
<blockquote>
<p>ERROR: npm is known not to run on Node.js v4.2.6 Node.js 4 is
supported but the specific version you're running has a bug known to
break npm. Please update to at least ${rel.min} to use this version of
npm. You can find the latest release of Node.js at <a href="https://nodejs.org/" rel="noreferrer">https://nodejs.org/</a></p>
</blockquote>
| 0debug |
Setting build args for dockerfile agent using a Jenkins declarative pipeline : <p>I'm using the declarative pipeline syntax to do some CI work inside a docker container.</p>
<p>I've noticed that the Docker plugin for Jenkins runs a container using the user id and group id of the jenkins user in the host (ie if the jenkins user has user id 100 and group id 111 it would run the pipeline creating a container with the command <code>docker run -u 100:111 ...</code>).</p>
<p>I had some problems with this, as the container will run with a non existing user (particularly I ran into some issues with the user not having a home dir). So I thought of creating a Dockerfile that will receive the user id and group id as build arguments and creater a proper jenkins user inside the container. The Dockerfile looks like this:</p>
<pre><code>FROM ubuntu:trusty
ARG user_id
ARG group_id
# Add jenkins user
RUN groupadd -g ${group_id} jenkins
RUN useradd jenkins -u ${user_id} -g jenkins --shell /bin/bash --create-home
USER jenkins
...
</code></pre>
<p>The dockerfile agent has an <code>additionalBuildArgs</code> property, so I can read the user id and group id of the jenkins user in the host and send those as build aguments, but the problem I have now is that it seems that there is no way of executing those commands in a declarative pipeline before specifying the agent. I want my Jenkinsfile to be something like this:</p>
<pre><code>// THIS WON'T WORK
def user_id = sh(returnStdout: true, script: 'id -u').trim()
def group_id = sh(returnStdout: true, script: 'id -g').trim()
pipeline {
agent {
dockerfile {
additionalBuildArgs "--build-arg user_id=${user_id} --build-arg group_id=${group_id}"
}
}
stages {
stage('Foo') {
steps {
...
}
}
stage('Bar') {
steps {
...
}
}
stage('Baz') {
steps {
..
}
}
...
}
}
</code></pre>
<p>I there is any way to achieve this? I've also tried wrapping the pipeline directive inside a node, but the pipeline needs to be at the root of the file.</p>
| 0debug |
How to array data extracted from this object <div class="gwt-Label">Some Data</div>? : How to array data extracted from this object <div class="gwt-Label">Some Data</div> ?
<div class=“gwt-Label”>Some Data</div>?
Since @BrockAdams provided excellent answer and solution for the general problem of data extraction from DIV object, described by class name only (no id) and since the web page is made of 100+ DIV objects, described by the same class name, mainly "gwt-Label"
https://stackoverflow.com/questions/47973438/how-to-extract-the-text-from-a-dynamic-div-by-class-name-using-a-userscript/47973580#47973580
I am looking for a solution to limit the output to the console from 100+ lines to just few by modifying the code by @BrockAdams below
waitForKeyElements (".gwt-Label", printNodeText);
function printNodeText (jNode) {
console.log ("gwt-Label value: ", jNode.text ().trim () );
}
Since output I read in the console is 100+ lines long but all I need are just few selected lines by array index.
Do you know how to manipulate jNode to save output to array first and have only selected array elements to be reread and send to console ?
I would prefer pseudocode like this
jNode.text ().trim ()[0]
jNode.text ().trim ()[5]
run as script in Greasemonkey or Tampermonkey
And what's more, I need to loop the script over numerical query string setting dynamic @match url in the script
thank you
jack
| 0debug |
Scope Issue: Access array in if statement (PHP) : I have an admin panel for an application. For this admin panel, the admin has the option to select a user from a dropdown list. When the user is selected, I use an AJAX call to grab the users data and store it in a variable called **$result**. Now when I try to access **$result** outside of the if statement in my HTML file, it is not recognized. What are the possible ways I can access this variable?
HTML file (AJAX call)
$(document).ready(function(){
$('#user').change(function() {
var user_id = $(this).val();
$.ajax({
url: 'adminNew.php',
method:'POST',
data: {user_id : user_id},
success: function(data) {
alert(user_id);
}
});
});
});
Php file (if statement)
if (isset($_POST["user_id"])) {
if ($_POST["user_id"] != '') {
$sql = "SELECT * FROM user_data WHERE user_id ='".$_POST["user_id"]."'";
}
$result = mysqli_query($connect, $sql);
}
HTML file (table)
<tr>
<tbody id="expBody">
<?php
if ($result != ''){
while($row1 = mysqli_fetch_array($result)) {
echo '
<tr id = '.$row1["id"].'>
<td> '.$row1['user_id'].'</td>
<td> '.$row1['name'].'</td>
<td> '.$row1['email'].'</td>
<td> '.$row1['city'].'</td>
<td> '.$row1['state'].'</td>
<td> '.$row1['zip'].'</td>
';
}
}
?>
</tbody>
</tr>
| 0debug |
how to get names of instances/objects in ruby : I want to store only names of instances in array by a class method, when i try it returns to me whole instance when i put object_id it returns to me integer identifier of my object, i just want name of instance in array and later with that array to sort object by its last_name thanks,this is what i tryed :
class Person
attr_accessor :name, :years, :height, :work, :last_name
@@people=[]
def initialize(name)
@name=name
@@people << self.object_id #WHAT TO TYPE HERE???
end
def <=> (other_person) # to compare two people, use last names
self.last_name <=> other_person.last_name
end
def self.number_of_instances
return @@people
end
end
mike=Person.new("michael")
mike.years=45
mike.height=141
mike.work="singer"
mike.last_name="zux"
bob=Person.new("boby")
bob.years=29
bob.height=150
bob.work="soldier"
bob.last_name="awax"
steven=Person.new("stephan")
steven.years=24
steven.height=179
steven.work="painter"
steven.last_name="sigal"
elena=Person.new("eli")
elena.years=20
elena.height=171
elena.work="menager"
elena.last_name="betany"
a= Person.number_of_instances
p a
q= a.sort!{|first,second| first<=>second }
p q
| 0debug |
static void pic_common_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_pic_common;
dc->no_user = 1;
dc->props = pic_properties_common;
dc->realize = pic_common_realize;
}
| 1threat |
PHP oop about class : HI i want to make a code like this .. Can you give me an example on how to implement this ?
$theclassvariable = new Myclass();
$theclassvariable->firstMethod()->secondMethod($param,$param);
thank you so much
| 0debug |
static bool s390_cpu_has_work(CPUState *cs)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
return (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
(env->psw.mask & PSW_MASK_EXT);
}
| 1threat |
Vacation calculator in Excel : I post my question in the following screenshot. Any reply and alternative suggestion is welcome.
With so thanks,
Dio
[The Question Screenshot][1]
[1]: http://i.stack.imgur.com/25oEG.jpg | 0debug |
Cant install BeautifulSoup Python? : Ok, Python is possibly the most tedious language I have dealt with at this point.
[enter image description here][1]
I have no idea what the hell is happening. I have tried so damn much but I just cant get this to install. I've been struggling for a few hours now.
It installs in the terminal with: `pip install --user BeautifulSoup` but dammit, it doesn't work in PyCharm.
what can I do?
[1]: https://i.stack.imgur.com/DHknF.png | 0debug |
How to recover a files which are encrypted by ransomware : <p>As I'm using a windows 7.We are configured public ip to access our apache server. After a Remote desktop connection via <strong>Anydesk</strong> Ended. All the Files in System are encrypted with <strong>.deep</strong> extension. Every Folder Contains Text files that has id and <strong>mrdeep@protonmail.com</strong> and bitcoin donate information and also system already has K7 <strong>AntiSecurity</strong>(Licensed but about to end).But after affected, K7 automatically vanished. Hence can anyone help me to recover those files and also guide me to escape from such viruses in future..</p>
| 0debug |
React Native "dropped so far" perf monitor count constantly increases : <p>I originally noticed this issue in my completed app, but have installed the default react-native app to test, and I'm seeing the "dropped so far" number in the perf monitor constantly creep up even though nothing is happening.</p>
<p>Is this number supposed to increase constantly?</p>
<p><a href="https://i.stack.imgur.com/oH9tT.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/oH9tT.gif" alt="dropped so far"></a></p>
| 0debug |
Buttons in HTML/Javascript : <p>My button creates text in one line. So if I click it multiple times it will just display the text in one long line. I have come to ask if there is a way to replace the text created by the click when you press the button again. so that every time you press the button, it doesn't just add it to one long line, but instead displays only the text from that click.</p>
| 0debug |
how to access MySQL database remotely from : <p>I am making database connection remotely but i am getting "<strong>communication link failure</strong>" my code is:</p>
<pre><code>Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://49.58.100.100:3306/abc", "abc1","abc");
System.out.println(con);
</code></pre>
| 0debug |
How to print patterns in python : I want to print a pattern from a group of numbers which denotes the direction of flow?
0 - north
1 - north east
2 - east
3 - south east
4 - south
5 - south west
6 - west
7 - north west
if 424222006 is the given number, then according to direction i have to print as shown below
The required output should be according to directions.
0 * * 0 0
0 0 * * 0
* 0 0 0 0
Can someone please help me with this | 0debug |
Convert casual string to int in C : <p>As the title I need to convert a casual string (like "elephant") to a int type. I already know about <em>atoi</em> and <em>strtol</em> function of <em>stdlib.h</em> library. However this ones do not work on casual string (the return value is always 0). Does a function like this exist yet?</p>
| 0debug |
static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
{
GetBitContext *gb = &ctx->gb;
*bd->shift_lsbs = 0;
if (get_bits1(gb)) {
if (read_var_block_data(ctx, bd))
return -1;
} else {
read_const_block_data(ctx, bd);
}
return 0;
}
| 1threat |
static int virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
{
int n;
if (!proxy->ioeventfd_started) {
return 0;
}
for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
if (!virtio_queue_get_num(proxy->vdev, n)) {
continue;
}
virtio_pci_set_host_notifier_fd_handler(proxy, n, false);
virtio_pci_set_host_notifier_internal(proxy, n, false);
}
proxy->ioeventfd_started = false;
return 0;
}
| 1threat |
How can I allocate a pointer in c++? : <p>Hello so I have a question about pointers. How would I allocate memory for a pointer in c++? Can I use the <code>new</code> keyword like I would with allocating a type? Also what is the advantage of using pointers in c++ instead of just passing through a variable? Does it increase the efficiency of a program?</p>
| 0debug |
behavior of javascript 'this' keyword in closure : <p>Consider a simple pattern where we call setTimeout within a loop to print the loop counter: </p>
<pre><code>function g(i){
return function()
{
console.log(i);
}
}
for(i=0;i<4;i++)
{
setTimeout(g(i),3000);
}
</code></pre>
<p>This returns the expected result:</p>
<pre><code>0
1
2
3
</code></pre>
<p>According to my understanding, this function should do the same thing</p>
<pre><code>function f(i){
this.n = i;
return function()
{
console.log(this.n);
}
}
for(i=0;i<4;i++)
{
setTimeout(f(i),3000);
}
</code></pre>
<p>Instead, I get varying results, in NodeJS:</p>
<pre><code>undefined
undefined
undefined
undefined
</code></pre>
<p>And in Google Chrome: </p>
<pre><code>3
3
3
3
</code></pre>
<p>Neither of these results make sense to me, so I was hoping someone else can explain this to me.</p>
| 0debug |
static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)
{
const char *rc_desc;
mfxU16 rc_mode;
int want_la = q->la_depth >= 0;
int want_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE);
int want_vcm = q->vcm;
if (want_la && !QSV_HAVE_LA) {
av_log(avctx, AV_LOG_ERROR,
"Lookahead ratecontrol mode requested, but is not supported by this SDK version\n");
return AVERROR(ENOSYS);
}
if (want_vcm && !QSV_HAVE_VCM) {
av_log(avctx, AV_LOG_ERROR,
"VCM ratecontrol mode requested, but is not supported by this SDK version\n");
return AVERROR(ENOSYS);
}
if (want_la + want_qscale + want_vcm > 1) {
av_log(avctx, AV_LOG_ERROR,
"More than one of: { constant qscale, lookahead, VCM } requested, "
"only one of them can be used at a time.\n");
return AVERROR(EINVAL);
}
if (want_qscale) {
rc_mode = MFX_RATECONTROL_CQP;
rc_desc = "constant quantization parameter (CQP)";
}
#if QSV_HAVE_VCM
else if (want_vcm) {
rc_mode = MFX_RATECONTROL_VCM;
rc_desc = "video conferencing mode (VCM)";
}
#endif
#if QSV_HAVE_LA
else if (want_la) {
rc_mode = MFX_RATECONTROL_LA;
rc_desc = "VBR with lookahead (LA)";
#if QSV_HAVE_ICQ
if (avctx->global_quality > 0) {
rc_mode = MFX_RATECONTROL_LA_ICQ;
rc_desc = "intelligent constant quality with lookahead (LA_ICQ)";
}
#endif
}
#endif
#if QSV_HAVE_ICQ
else if (avctx->global_quality > 0) {
rc_mode = MFX_RATECONTROL_ICQ;
rc_desc = "intelligent constant quality (ICQ)";
}
#endif
else if (avctx->rc_max_rate == avctx->bit_rate) {
rc_mode = MFX_RATECONTROL_CBR;
rc_desc = "constant bitrate (CBR)";
} else if (!avctx->rc_max_rate) {
rc_mode = MFX_RATECONTROL_AVBR;
rc_desc = "average variable bitrate (AVBR)";
} else {
rc_mode = MFX_RATECONTROL_VBR;
rc_desc = "variable bitrate (VBR)";
}
q->param.mfx.RateControlMethod = rc_mode;
av_log(avctx, AV_LOG_VERBOSE, "Using the %s ratecontrol method\n", rc_desc);
return 0;
}
| 1threat |
static QObject *parse_literal(JSONParserContext *ctxt, QList **tokens)
{
QObject *token, *obj;
QList *working = qlist_copy(*tokens);
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
switch (token_get_type(token)) {
case JSON_STRING:
obj = QOBJECT(qstring_from_escaped_str(ctxt, token));
break;
case JSON_INTEGER:
obj = QOBJECT(qint_from_int(strtoll(token_get_value(token), NULL, 10)));
break;
case JSON_FLOAT:
obj = QOBJECT(qfloat_from_double(strtod(token_get_value(token), NULL)));
break;
default:
goto out;
}
qobject_decref(token);
QDECREF(*tokens);
*tokens = working;
return obj;
out:
qobject_decref(token);
QDECREF(working);
return NULL;
}
| 1threat |
static void assign_failed_examine(AssignedDevice *dev)
{
char name[PATH_MAX], dir[PATH_MAX], driver[PATH_MAX] = {}, *ns;
uint16_t vendor_id, device_id;
int r;
snprintf(dir, sizeof(dir), "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/",
dev->host.domain, dev->host.bus, dev->host.slot,
dev->host.function);
snprintf(name, sizeof(name), "%sdriver", dir);
r = readlink(name, driver, sizeof(driver));
if ((r <= 0) || r >= sizeof(driver)) {
goto fail;
}
ns = strrchr(driver, '/');
if (!ns) {
goto fail;
}
ns++;
if (get_real_vendor_id(dir, &vendor_id) ||
get_real_device_id(dir, &device_id)) {
goto fail;
}
error_printf("*** The driver '%s' is occupying your device "
"%04x:%02x:%02x.%x.\n"
"***\n"
"*** You can try the following commands to free it:\n"
"***\n"
"*** $ echo \"%04x %04x\" > /sys/bus/pci/drivers/pci-stub/new_id\n"
"*** $ echo \"%04x:%02x:%02x.%x\" > /sys/bus/pci/drivers/%s/unbind\n"
"*** $ echo \"%04x:%02x:%02x.%x\" > /sys/bus/pci/drivers/"
"pci-stub/bind\n"
"*** $ echo \"%04x %04x\" > /sys/bus/pci/drivers/pci-stub/remove_id\n"
"***",
ns, dev->host.domain, dev->host.bus, dev->host.slot,
dev->host.function, vendor_id, device_id,
dev->host.domain, dev->host.bus, dev->host.slot, dev->host.function,
ns, dev->host.domain, dev->host.bus, dev->host.slot,
dev->host.function, vendor_id, device_id);
return;
fail:
error_report("Couldn't find out why.");
} | 1threat |
How to get exact output? : <p>I wrote a program to get words from user and get plural of those words as output. Now I couldn't do following two things</p>
<p>1 - How to restrict only string input i.e if user input integer then program must throw error.</p>
<p>2 - Input - cat mat bat output-> cats mats bats
input - cat, mat, bat output -> cat,s mat,s bat,s ( I want to avoid this i.e when user separates the words by comma then i should get bats not bat,s)</p>
<p>please guide me here and please watch out for indentation. </p>
<p>Thank you</p>
<pre><code>`(def plural(user_input):
# creating list
List_of_word_ends = ['o','ch', 's', 'sh', 'x', 'z']
words = user_input.split()
ws = "";
# setting loop to for words
for word in words:
if len(word)>0 :
if word.endswith("y"):
word = word[:-1]
word += "ies"
else:
isSomeEs = False;
for suffix in List_of_word_ends:
if word.endswith(suffix):
word += "es"
isSomeEs = True;
break
if not isSomeEs:
word += "s"
ws += word+" "
print ws
# taking input from user
singular = raw_input("Please enter the words whose plural you want:")
# returns a list of words
x = singular.split(" ")
x = singular.split(",")
#calculate the length of object
y = len(x)
print "The no. of words you entered is :", y
#function call
plural(singular))`
</code></pre>
| 0debug |
Python listens for MacOS global events : Python listens for MacOS global events
from AppKit import *
from PyObjCTools import AppHelper
import CoreFoundation
def handler(event):
NSLog(event)
print(event)
NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSLeftMouseDownMask, handler)
AppHelper.runConsoleEventLoop()
But, this just runs forever, does not respond to mouse events, what's wrong with that? | 0debug |
int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
BlockDriver *drv)
{
int ret, open_flags;
char tmp_filename[PATH_MAX];
char backing_filename[PATH_MAX];
bs->read_only = 0;
bs->is_temporary = 0;
bs->encrypted = 0;
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
bs1 = bdrv_new("");
if (!bs1) {
return -ENOMEM;
}
if (bdrv_open(bs1, filename, 0) < 0) {
bdrv_delete(bs1);
return -1;
}
total_size = bdrv_getlength(bs1) >> SECTOR_BITS;
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
realpath(filename, backing_filename);
if (bdrv_create(&bdrv_qcow2, tmp_filename,
total_size, backing_filename, 0) < 0) {
return -1;
}
filename = tmp_filename;
bs->is_temporary = 1;
}
pstrcpy(bs->filename, sizeof(bs->filename), filename);
if (flags & BDRV_O_FILE) {
drv = find_protocol(filename);
if (!drv)
return -ENOENT;
} else {
if (!drv) {
drv = find_image_format(filename);
if (!drv)
return -1;
}
}
bs->drv = drv;
bs->opaque = qemu_mallocz(drv->instance_size);
bs->total_sectors = 0;
if (bs->opaque == NULL && drv->instance_size > 0)
return -1;
if (!(flags & BDRV_O_FILE))
open_flags = BDRV_O_RDWR | (flags & BDRV_O_DIRECT);
else
open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
ret = drv->bdrv_open(bs, filename, open_flags);
if (ret == -EACCES && !(flags & BDRV_O_FILE)) {
ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY);
bs->read_only = 1;
}
if (ret < 0) {
qemu_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
}
if (drv->bdrv_getlength) {
bs->total_sectors = bdrv_getlength(bs) >> SECTOR_BITS;
}
#ifndef _WIN32
if (bs->is_temporary) {
unlink(filename);
}
#endif
if (bs->backing_file[0] != '\0') {
bs->backing_hd = bdrv_new("");
if (!bs->backing_hd) {
fail:
bdrv_close(bs);
return -ENOMEM;
}
path_combine(backing_filename, sizeof(backing_filename),
filename, bs->backing_file);
if (bdrv_open(bs->backing_hd, backing_filename, 0) < 0)
goto fail;
}
bs->media_changed = 1;
if (bs->change_cb)
bs->change_cb(bs->change_opaque);
return 0;
} | 1threat |
Why do i have this no default constructor error?,intent service error : i am trying to get the coordinates of a location through an app,however in the the manifest file,the *GPSTracker* is underlined red,saying there no default constructor,i was wondering what is the problem,thank you.Below is the tracker file code
public class GPSTracker extends Service implements LocationListener {
private final Context mContext;
boolean isGPSEnabled = false; // flag for GPS status
boolean isNetworkEnabled = false; // flag for network status
boolean canGetLocation = false; // flag for GPS status
Location location; // location
double latitude; // latitude
double longitude; // longitude
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1;
protected LocationManager locationManager;
public GPSTracker(Context context) {
this.mContext = context;
getLocation();
}
public Location getLocation() {
try {
locationManager =
(LocationManager)mContext.getSystemService(LOCATION_SERVICE);
isGPSEnabled =
locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
isNetworkEnabled =
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
} else {
this.canGetLocation = true;
if (isNetworkEnabled) {
if (ActivityCompat.checkSelfPermission(mContext,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(mContext,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
| 0debug |
Static SQL query replace to dynamic : I have following query:
http://www.sqlfiddle.com/#!9/752e34/3
Now I'm looking for a solution to add a new row into tbl_tag without change the above query.
It would be great to get an idea or help.
Thanks
| 0debug |
Is there a way to replace a string in a text without spaces? : <p>Is there a way to replace something like this:</p>
<pre><code>testHoraciotestHellotest
</code></pre>
<p>And replace the 'test' word via javascript, I've tried with the <code>.replace()</code> function but it didn't work</p>
| 0debug |
static int oss_poll_in (HWVoiceIn *hw)
{
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
return qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);
}
| 1threat |
change the shape of a button : <p>i want to change the shape of the button but the text inside of it also changes</p>
<p>i've trid to to put a span inside of it but it didn't work</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>
.btn {
border-radius: 0px;
border: none;
padding: 0.66em 4em;
color: rgb(68, 114, 241);
cursor: pointer;
background-color: #FFF;
border: 1px solid rgb(45, 110, 206);
font-size: 1em;
transform: skewX(-18deg);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <button class="btn">click me</button></code></pre>
</div>
</div>
</p>
| 0debug |
how to add two array values into one array in javascript : <pre><code>var period = ['1', '2', '3', '4'];
var marks = ['20', '15', '00', '20'];
</code></pre>
<p>i want result that is array in javascript
// returns</p>
<pre><code>data = [{"period": "1", "marks": 20},
{"period": "2", "marks": 15},
{"period": "3", "marks": 00},
{"period": "4", "marks": 20}];
</code></pre>
<p>I want to merge these arrays which are period and marks in to array called data
thank you in advance</p>
| 0debug |
Why vertical alignment is applied to outer text? : <p>Whey the <code>vertical-align: middle</code> is applied to outer text and not to the text inside <code>div.code</code></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.code {
display: inline-flex;
border: 3px solid black;
height: 2.2rem;
text-align: center;
vertical-align: middle;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
code
<div class="code">380805</div>
</div></code></pre>
</div>
</div>
</p>
| 0debug |
static int dnxhd_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
DNXHDContext *ctx = avctx->priv_data;
ThreadFrame frame = { .f = data };
AVFrame *picture = data;
int first_field = 1;
int ret;
ff_dlog(avctx, "frame size %d\n", buf_size);
decode_coding_unit:
if ((ret = dnxhd_decode_header(ctx, picture, buf, buf_size, first_field)) < 0)
return ret;
if ((avctx->width || avctx->height) &&
(ctx->width != avctx->width || ctx->height != avctx->height)) {
av_log(avctx, AV_LOG_WARNING, "frame size changed: %dx%d -> %dx%d\n",
avctx->width, avctx->height, ctx->width, ctx->height);
first_field = 1;
}
if (avctx->pix_fmt != AV_PIX_FMT_NONE && avctx->pix_fmt != ctx->pix_fmt) {
av_log(avctx, AV_LOG_WARNING, "pix_fmt changed: %s -> %s\n",
av_get_pix_fmt_name(avctx->pix_fmt), av_get_pix_fmt_name(ctx->pix_fmt));
first_field = 1;
}
avctx->pix_fmt = ctx->pix_fmt;
ret = ff_set_dimensions(avctx, ctx->width, ctx->height);
if (ret < 0)
return ret;
if (first_field) {
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
picture->pict_type = AV_PICTURE_TYPE_I;
picture->key_frame = 1;
}
ctx->buf_size = buf_size - 0x280;
ctx->buf = buf + 0x280;
avctx->execute2(avctx, dnxhd_decode_row, picture, NULL, ctx->mb_height);
if (first_field && picture->interlaced_frame) {
buf += ctx->cid_table->coding_unit_size;
buf_size -= ctx->cid_table->coding_unit_size;
first_field = 0;
goto decode_coding_unit;
}
*got_frame = 1;
return avpkt->size;
}
| 1threat |
static inline void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm2 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"pand %%mm2, %%mm0 \n\t"
"pand %%mm2, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++)
dst[i]= src[2*i];
#endif
}
| 1threat |
Pythonic way to get the max difference between any 2 consecutive elements of a list : <p>I have a list which stores scores of a game which is played in rounds. At each index, the score is stored such that it's equal to the total score scored up to and including that round.</p>
<ul>
<li>round 1 - 5 points are scored in this round</li>
<li>round 2 - 3 points are scored in this round</li>
<li>round 3 - 7 points are scored in this round</li>
<li>round 4 - 4 points are scored in this round</li>
</ul>
<p>This will result in</p>
<pre><code>total_score = [5, 8, 15, 19]
</code></pre>
<p>How can I convert this neatly into a list which has the score of each round at each index, instead of the total score up to that round.</p>
<p>So I want to turn the above list into:</p>
<pre><code>round_scores = [5, 3, 7, 4]
</code></pre>
<p>It's not particularly hard to do with just iterating over it and subtracting the score at the previous index from the score at the current index. But is there a neater way to do this? Maybe a one liner list comprehension? I'm fairly new to Python but I've seen some magic being done in a single line in other answers.</p>
| 0debug |
START_TEST(qstring_append_chr_test)
{
int i;
QString *qstring;
const char *str = "qstring append char unit-test";
qstring = qstring_new();
for (i = 0; str[i]; i++)
qstring_append_chr(qstring, str[i]);
fail_unless(strcmp(str, qstring_get_str(qstring)) == 0);
QDECREF(qstring);
}
| 1threat |
How to fix this matlab error? : I got this error when I tried to capture image using my pc webcam. I am new to matlab. How can I fix this error?
This is my code,
obj =imaq.VideoDevice('dcam', 1, 'YUYV_320x240','ROI', [1 1 320 240]); set(obj,'ReturnedColorSpace', 'rgb'); figure('menubar','none','tag','webcam');
>> imaqhwinfo
ans =
InstalledAdaptors: {'dcam'}
MATLABVersion: '8.6 (R2015b)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '4.10 (R2015b)'
>> webcamlist
ans =
'Integrated Webcam'
| 0debug |
How to detect division by zero using std::error_code : <p>I want to detect division by zero using std::error_code. Without the use of exceptions. How can I do that? Write some simple examples.</p>
| 0debug |
int av_expr_parse(AVExpr **expr, const char *s,
const char * const *const_names,
const char * const *func1_names, double (* const *funcs1)(void *, double),
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
int log_offset, void *log_ctx)
{
Parser p;
AVExpr *e = NULL;
char *w = av_malloc(strlen(s) + 1);
char *wp = w;
const char *s0 = s;
int ret = 0;
if (!w)
return AVERROR(ENOMEM);
while (*s)
if (!isspace(*s++)) *wp++ = s[-1];
*wp++ = 0;
p.class = &class;
p.stack_index=100;
p.s= w;
p.const_names = const_names;
p.funcs1 = funcs1;
p.func1_names = func1_names;
p.funcs2 = funcs2;
p.func2_names = func2_names;
p.log_offset = log_offset;
p.log_ctx = log_ctx;
if ((ret = parse_expr(&e, &p)) < 0)
goto end;
if (*p.s) {
av_log(&p, AV_LOG_ERROR, "Invalid chars '%s' at the end of expression '%s'\n", p.s, s0);
ret = AVERROR(EINVAL);
goto end;
}
if (!verify_expr(e)) {
av_expr_free(e);
ret = AVERROR(EINVAL);
goto end;
}
*expr = e;
end:
av_free(w);
return ret;
}
| 1threat |
inject() must be called from an injection context : <p>I am trying to export my Angular app as an npm module to be consumed by other applications, but am running into some difficulties. I have not been able to find this error anywhere else on the internet, and am at my wit's end.</p>
<p>I followed this tutorial: <a href="https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e" rel="noreferrer">https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e</a></p>
<p>I used ng-packagr to export my app as an npm module. I can successfully install it from a local folder on a barebones test app, but cannot get it to display my app.</p>
<p>Error:</p>
<pre><code>AppComponent.html:1 ERROR Error: inject() must be called from an injection context
at inject (core.js:1362)
at ChangeStackService_Factory (template-wiz.js:2074)
at _callFactory (core.js:8223)
at _createProviderInstance (core.js:8181)
at resolveNgModuleDep (core.js:8156)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:8849)
at resolveDep (core.js:9214)
at createClass (core.js:9094)
at createDirectiveInstance (core.js:8971)
at createViewNodes (core.js:10191)
</code></pre>
<p>template-wiz.module.ts (Module being exported)
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { NgModule, ChangeDetectorRef, ComponentFactoryResolver } from '@angular/core';
import { TemplateWizComponent } from './template-wiz.component';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { BlockListDirective } from './Directives/block-list.directive';
import { TemplateItemsDirective } from './Directives/template-items.directive';
import { ContextMenuComponent, SeperatorComponent, DragBoxComponent, SnapLineComponent, PropertiesComponent, ToolboxComponent } from './Components'
import { AddressBlockComponent, TextBlockComponent, ImageBlockComponent, DataBlockComponent } from './Data-Blocks';
import { BlockFactoryService, BlockRegistryService, DisplayInfoService, MouseClickService, SavingService, SnapService, TextHelperService, UserModeService } from './Services';
import { PageContextMenuComponent } from './Components/page-context-menu/page-context-menu.component';
import { CamelToWordsPipe } from './Pipes/camel-to-words.pipe';
import { PdfPublisherService } from './Services/pdf-publisher/pdf-publisher.service';
import { GradientBlockComponent } from './Data-Blocks/gradient-block/gradient-block.component';
import { PropToTypePipe } from './Pipes/prop-to-type.pipe';
import { ShapeBlockComponent } from './Data-Blocks/shape-block/shape-block.component';
import { CommonModule } from '@angular/common';
import { ModuleWithProviders } from '@angular/compiler/src/core';
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule
],
entryComponents: [
AddressBlockComponent,
ContextMenuComponent,
DragBoxComponent,
GradientBlockComponent,
ImageBlockComponent,
PageContextMenuComponent,
SeperatorComponent,
ShapeBlockComponent,
SnapLineComponent,
TextBlockComponent
],
declarations: [
TemplateWizComponent,
DataBlockComponent,
AddressBlockComponent,
SeperatorComponent,
BlockListDirective,
TemplateItemsDirective,
ImageBlockComponent,
TextBlockComponent, DragBoxComponent,
SnapLineComponent,
ToolboxComponent,
PropertiesComponent,
ContextMenuComponent,
PageContextMenuComponent,
GradientBlockComponent,
CamelToWordsPipe,
PropToTypePipe,
ShapeBlockComponent
],
providers: [
BlockFactoryService,
BlockRegistryService,
DisplayInfoService,
MouseClickService,
SavingService,
SnapService,
TextHelperService,
UserModeService,
PdfPublisherService
],
//bootstrap: [TemplateWizComponent],
exports: [
TemplateWizComponent
]
})
export class TemplateWizModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: TemplateWizModule,
providers: [
ComponentFactoryResolver
]
}
}
}</code></pre>
</div>
</div>
</p>
<p>app.module.ts (Bare bones test app using my module)
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { TemplateWizModule } from 'template-wiz';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
TemplateWizModule.forRoot(),
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }</code></pre>
</div>
</div>
</p>
<p>Any help or pointers at all would be appreciated, thank you.</p>
| 0debug |
React Native - navigation issue "undefined is not an object (this.props.navigation.navigate)" : <p>Im following this tutorial <a href="https://reactnavigation.org/docs/intro/" rel="noreferrer">https://reactnavigation.org/docs/intro/</a> and im running into a bit of issues.</p>
<p>Im using the Expo Client app to render my app every time and not a simulator/emulator.</p>
<p>my code is seen down below. </p>
<p>I originally had the "SimpleApp" const defined above "ChatScreen" component but that gave me the following error:</p>
<blockquote>
<p>Route 'Chat' should declare a screen. For example: ...etc</p>
</blockquote>
<p>so I moved the decleration of SimpleApp to just above "AppRegistry" and that flagged a new error </p>
<blockquote>
<p>Element type is invalid: expected string.....You likely forgot to export your component..etc</p>
</blockquote>
<p>the tutorial did not add the key words "export default" to any component which I think it may have to do with the fact that im running it on the Expo app? so I added "export default" to "HomeScreen" and the error went away.</p>
<p>The new error that I cant seem to get rid off(based on the code below) is the following:</p>
<blockquote>
<p>undefined is not an object (evaluating 'this.props.navigation.navigate')</p>
</blockquote>
<p>I can't get rid of it unless I remove the "{}" around "const {navigate}" but that will break the navigation when I press on the button from the home screen</p>
<pre><code>import React from 'react';
import {AppRegistry,Text,Button} from 'react-native';
import { StackNavigator } from 'react-navigation';
export default class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Welcome',
};
render() {
const { navigate } = this.props.navigation;
return (
<View>
<Text>Hello, Chat App!</Text>
<Button
onPress={() => navigate('Chat')}
title="Chat with Lucy"
/>
</View>
);
}
}
class ChatScreen extends React.Component {
static navigationOptions = {
title: 'Chat with Lucy',
};
render() {
return (
<View>
<Text>Chat with Lucy</Text>
</View>
);
}
}
const SimpleApp = StackNavigator({
Home: { screen: HomeScreen },
Chat: { screen: ChatScreen },
});
AppRegistry.registerComponent('SimpleApp', () => SimpleApp);
</code></pre>
| 0debug |
QList *qlist_new(void)
{
QList *qlist;
qlist = g_malloc(sizeof(*qlist));
QTAILQ_INIT(&qlist->head);
QOBJECT_INIT(qlist, &qlist_type);
return qlist;
}
| 1threat |
void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,
int is_cpu_write_access)
{
TranslationBlock *tb, *tb_next;
#if defined(TARGET_HAS_PRECISE_SMC)
CPUState *cpu = current_cpu;
CPUArchState *env = NULL;
#endif
tb_page_addr_t tb_start, tb_end;
PageDesc *p;
int n;
#ifdef TARGET_HAS_PRECISE_SMC
int current_tb_not_found = is_cpu_write_access;
TranslationBlock *current_tb = NULL;
int current_tb_modified = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0;
#endif
assert_memory_lock();
assert_tb_locked();
p = page_find(start >> TARGET_PAGE_BITS);
if (!p) {
return;
}
#if defined(TARGET_HAS_PRECISE_SMC)
if (cpu != NULL) {
env = cpu->env_ptr;
}
#endif
tb = p->first_tb;
while (tb != NULL) {
n = (uintptr_t)tb & 3;
tb = (TranslationBlock *)((uintptr_t)tb & ~3);
tb_next = tb->page_next[n];
if (n == 0) {
tb_start = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
tb_end = tb_start + tb->size;
} else {
tb_start = tb->page_addr[1];
tb_end = tb_start + ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
}
if (!(tb_end <= start || tb_start >= end)) {
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb_not_found) {
current_tb_not_found = 0;
current_tb = NULL;
if (cpu->mem_io_pc) {
current_tb = tb_find_pc(cpu->mem_io_pc);
}
}
if (current_tb == tb &&
(current_tb->cflags & CF_COUNT_MASK) != 1) {
current_tb_modified = 1;
cpu_restore_state_from_tb(cpu, current_tb, cpu->mem_io_pc);
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
}
#endif
tb_phys_invalidate(tb, -1);
}
tb = tb_next;
}
#if !defined(CONFIG_USER_ONLY)
if (!p->first_tb) {
invalidate_page_bitmap(p);
tlb_unprotect_code(start);
}
#endif
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb_modified) {
tb_gen_code(cpu, current_pc, current_cs_base, current_flags,
1 | curr_cflags());
cpu_loop_exit_noexc(cpu);
}
#endif
}
| 1threat |
What AWS instance setting can prevent to perform ssh to this instance? : I supposed to add the ssh key and then ssh to the AWS instance using a jumphost in 2 operations
So adding the key
ssh-add ~/.ssh/<key-file>.pem
Then ssh to jumphost
ssh -A ec2-user@jumphost
And then from jumphost to instance
ssh -A ec2-user@<private IP>
This works for one instance but does not work for another instance - cannot ssh to this instance from a jumphost.
What instance setting can prevent me to do ssh?
| 0debug |
How to change Edit/Done button title in UINavigationBar in Swift : <p>I'm displaying an editButtonItem in my tableview but I need to change the text of Edit and Done to Change and Cancel. All the examples I've found so far are in Objective-C... I need Swift syntax.</p>
<p>I have the following in viewDidLoad function...</p>
<pre><code>self.navigationItem.leftBarButtonItem = self.editButtonItem()
</code></pre>
<p>... which displays the standard Edit/Done button item.</p>
| 0debug |
Fixing common URL mistakes in PHP using regular expression : <p>Im not good at regular expressions so I need some help. How to fix following URL mistakes using RegEx?</p>
<ul>
<li>https:/</li>
<li>https/</li>
<li>https//</li>
<li>http//</li>
<li>http:/</li>
</ul>
| 0debug |
e1000e_intrmgr_delay_rx_causes(E1000ECore *core, uint32_t *causes)
{
uint32_t delayable_causes;
uint32_t rdtr = core->mac[RDTR];
uint32_t radv = core->mac[RADV];
uint32_t raid = core->mac[RAID];
if (msix_enabled(core->owner)) {
return false;
}
delayable_causes = E1000_ICR_RXQ0 |
E1000_ICR_RXQ1 |
E1000_ICR_RXT0;
if (!(core->mac[RFCTL] & E1000_RFCTL_ACK_DIS)) {
delayable_causes |= E1000_ICR_ACK;
}
core->delayed_causes |= *causes & delayable_causes;
*causes &= ~delayable_causes;
if ((rdtr == 0) || (causes != 0)) {
return false;
}
if ((raid == 0) && (core->delayed_causes & E1000_ICR_ACK)) {
return false;
}
e1000e_intrmgr_rearm_timer(&core->rdtr);
if (!core->radv.running && (radv != 0)) {
e1000e_intrmgr_rearm_timer(&core->radv);
}
if (!core->raid.running && (core->delayed_causes & E1000_ICR_ACK)) {
e1000e_intrmgr_rearm_timer(&core->raid);
}
return true;
}
| 1threat |
C+ Programming what am I doing wrong : Create an Employee class. Items to include as data members are employee number, name, date of hire, job description, department, and monthly salary. The class is often used to display an alphabetical listing of all employees. Include appropriate constructors and properties. Override the ToString ( ) method to return all data members. Create a second class to test your Employee class."
I've created an Employee class with the proper variables, properties, and constructors, but am having trouble "testing" it through a second class. The code I have written runs without errors, but doesn't display anything (presumably the goal of the testing). Where am I going wrong in the calling section?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeProgram
{
public class EmployeeProgram
{
private int employeeNumber;
private string name;
private string hiredate;
private int monthlySalary;
private string description;
private string department;
public employee(int employeeNumber, string name, string dateOfHire, int monthlySalary, string description, string department)
{
this.employeeNumber = 456;
this.name = "Joyce";
this.hiredate = "12/15/14";
this.monthlySalary = 3200;
this.description = "Manager";
this.department = "Accounting";
}
public int EmployeeNumber
{
get
{
return employeeNumber;
}
set
{
employeeNumber = value;
}
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string Hiredate
{
get
{
return hiredate;
}
set
{
hiredate = value;
}
}
public int MonthlySalary
{
get
{
return monthlySalary;
}
set
{
monthlySalary = value;
}
}
public string Department
{
get
{
return department;
}
set
{
department = value;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
public override string ToString()
{
return "Employee ID: " + employeeNumber +
"Employee Name: " + name +
"Employee Hire Date: " + hiredate +
"Employee Monthly Salary: " + monthlySalary +
"Employee Description: " + description +
"Employee Department: " + department;
}
public void Print()
{
Console.WriteLine(this.ToString());
}
}
| 0debug |
Creating Custom AuthorizeAttribute in Web API (.Net Framework) : <p>I'm using OAuth2.0 Owin (password grant) in my WebAPI.My initial token Response is like below</p>
<pre><code>{
"access_token": "_ramSlQYasdsRTWEWew.....................",
"token_type": "bearer",
"expires_in": 17999,
"permissions": {
"user": [
"Add",
"Update",
"Delete"
],
"Product": [
"Read",
"Create"
]
}
}
</code></pre>
<p>I've <a href="https://stackoverflow.com/a/49722037/7073340">customized</a> the response by creating a new Key called <code>permissions</code> which hold the privileges for the corresponding user.</p>
<p>From here I need to validate each Request from my <code>Resource server</code>,by checking whether the user has enough permissions to call the API using Authorize Attribute.</p>
<p>I found a similar example from <a href="https://stackoverflow.com/a/43788693/7073340">here</a> where it deals with Dot net Core, which is not suitable for my case.</p>
<p>The difficult part is that the <code>permission</code> JSON Key is itself making a complex with <code>ArrayList</code></p>
<pre><code>[CustomAuthorize(PermissionItem.Product, PermissionAction.Read)]
public async Task<IActionResult> Index()
{
return View(Index);
}
public class CustomAuthorize : AuthorizeAttribute {
public AuthorizeAttribute (PermissionItem item, PermissionAction action) {
//Need to initalize the Permission Enums
}
public override void OnAuthorization (HttpActionContext actionContext) {
//Code to get the value from Permissions ArrayList and compare it with the Enum values
}
}
</code></pre>
<p>The above is the idea I'm having. But due to the complexity of the <code>Permissions</code> Key and Enum comparison I'm couldn't able to move forward.</p>
<p>Also, there is a question like If the permission for User is Add as well as Update means I need to create two Attribute conditions before my Controller.</p>
<p>Like</p>
<pre><code>[CustomAuthorize(PermissionItem.User, PermissionAction.Add)]
[CustomAuthorize(PermissionItem.User, PermissionAction.Update)]
</code></pre>
<p>Which leads to adding more lines of Attributes. So Is there is any way to make it as in a single Conditions with <code>|</code> separated?</p>
<pre><code>[CustomAuthorize(PermissionItem.User, PermissionAction.Update|PermissionAction.Add)]
</code></pre>
| 0debug |
static int get_cluster_offset(BlockDriverState *bs,
VmdkExtent *extent,
VmdkMetaData *m_data,
uint64_t offset,
int allocate,
uint64_t *cluster_offset)
{
unsigned int l1_index, l2_offset, l2_index;
int min_index, i, j;
uint32_t min_count, *l2_table, tmp = 0;
if (m_data)
m_data->valid = 0;
if (extent->flat) {
*cluster_offset = extent->flat_start_offset;
return 0;
}
l1_index = (offset >> 9) / extent->l1_entry_sectors;
if (l1_index >= extent->l1_size) {
return -1;
}
l2_offset = extent->l1_table[l1_index];
if (!l2_offset) {
return -1;
}
for (i = 0; i < L2_CACHE_SIZE; i++) {
if (l2_offset == extent->l2_cache_offsets[i]) {
if (++extent->l2_cache_counts[i] == 0xffffffff) {
for (j = 0; j < L2_CACHE_SIZE; j++) {
extent->l2_cache_counts[j] >>= 1;
}
}
l2_table = extent->l2_cache + (i * extent->l2_size);
goto found;
}
}
min_index = 0;
min_count = 0xffffffff;
for (i = 0; i < L2_CACHE_SIZE; i++) {
if (extent->l2_cache_counts[i] < min_count) {
min_count = extent->l2_cache_counts[i];
min_index = i;
}
}
l2_table = extent->l2_cache + (min_index * extent->l2_size);
if (bdrv_pread(
extent->file,
(int64_t)l2_offset * 512,
l2_table,
extent->l2_size * sizeof(uint32_t)
) != extent->l2_size * sizeof(uint32_t)) {
return -1;
}
extent->l2_cache_offsets[min_index] = l2_offset;
extent->l2_cache_counts[min_index] = 1;
found:
l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size;
*cluster_offset = le32_to_cpu(l2_table[l2_index]);
if (!*cluster_offset) {
if (!allocate) {
return -1;
}
*cluster_offset = bdrv_getlength(extent->file);
bdrv_truncate(
extent->file,
*cluster_offset + (extent->cluster_sectors << 9)
);
*cluster_offset >>= 9;
tmp = cpu_to_le32(*cluster_offset);
l2_table[l2_index] = tmp;
if (get_whole_cluster(
bs, extent, *cluster_offset, offset, allocate) == -1)
return -1;
if (m_data) {
m_data->offset = tmp;
m_data->l1_index = l1_index;
m_data->l2_index = l2_index;
m_data->l2_offset = l2_offset;
m_data->valid = 1;
}
}
*cluster_offset <<= 9;
return 0;
}
| 1threat |
void qemu_thread_exit(void *arg)
{
QemuThread *thread = TlsGetValue(qemu_thread_tls_index);
thread->ret = arg;
CloseHandle(thread->thread);
thread->thread = NULL;
ExitThread(0);
}
| 1threat |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
static int id_wellformed(const char *id)
{
int i;
if (!qemu_isalpha(id[0])) {
return 0;
}
for (i = 1; id[i]; i++) {
if (!qemu_isalnum(id[i]) && !strchr("-._", id[i])) {
return 0;
}
}
return 1;
}
| 1threat |
static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm)
{
NVDIMMDevice *nvdimm = NVDIMM(dimm);
return &nvdimm->nvdimm_mr;
}
| 1threat |
Square Rooting in python : Our code lets us input a number, but then does not let us find the square root of it. Is the code only allowing us to square root perfect squares, or is it something else. Here is the code:
elif a == "Square" or a == "Square please":
print("Please enter a number:")
num1 = int(input())
print("Your answer is:")
answer = sqrt(num1)
print(answer) | 0debug |
int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
{
AVCodecContext *const avctx = h->avctx;
H264SliceContext *sl;
int i;
av_assert0(context_count && h->slice_ctx[context_count - 1].mb_y < h->mb_height);
if (h->avctx->hwaccel ||
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
return 0;
if (context_count == 1) {
int ret = decode_slice(avctx, &h->slice_ctx[0]);
h->mb_y = h->slice_ctx[0].mb_y;
return ret;
} else {
av_assert0(context_count > 0);
for (i = 1; i < context_count; i++) {
sl = &h->slice_ctx[i];
if (CONFIG_ERROR_RESILIENCE) {
sl->er.error_count = 0;
}
}
avctx->execute(avctx, decode_slice, h->slice_ctx,
NULL, context_count, sizeof(h->slice_ctx[0]));
sl = &h->slice_ctx[context_count - 1];
h->mb_y = sl->mb_y;
if (CONFIG_ERROR_RESILIENCE) {
for (i = 1; i < context_count; i++)
h->slice_ctx[0].er.error_count += h->slice_ctx[i].er.error_count;
}
}
return 0;
}
| 1threat |
difference between exactly-once and at-least-once guarantees : <p>I'm studying distributed systems and referring to this old question: <a href="https://stackoverflow.com/questions/13566869/at-most-once-and-exactly-once">stackoverflow link</a></p>
<p>I really can't understand the difference between exactly-once, at-least-once and at-most-once guarantees, I read these concepts in Kafka, Flink and Storm and Cassandra also. For instance someone says that Flink is better because has exactly-once guarantees while Storm has only at-least-once.</p>
<p>I understand that exactly-once mode is better for latency but at the same time it's worse for fault tolerance right? How can recover a stream if I haven't duplicates? and then... if this is a real problem, why exactly-once guarantee is considered better than others?</p>
<p>Someone can give me better definitions?</p>
| 0debug |
static void do_video_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
AVFrame *in_picture,
int *frame_size)
{
int nb_frames, i, ret;
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp;
AVCodecContext *enc, *dec;
avcodec_get_frame_defaults(&picture_crop_temp);
avcodec_get_frame_defaults(&picture_pad_temp);
enc = ost->st->codec;
dec = ist->st->codec;
nb_frames = 1;
*frame_size = 0;
if(video_sync_method>0 || (video_sync_method && av_q2d(enc->time_base) > 0.001)){
double vdelta;
vdelta = get_sync_ipts(ost) / av_q2d(enc->time_base) - ost->sync_opts;
if (vdelta < -1.1)
nb_frames = 0;
else if (video_sync_method == 2)
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
else if (vdelta > 1.1)
nb_frames = lrintf(vdelta);
if (nb_frames == 0){
++nb_frames_drop;
if (verbose>2)
fprintf(stderr, "*** drop!\n");
}else if (nb_frames > 1) {
nb_frames_dup += nb_frames;
if (verbose>2)
fprintf(stderr, "*** %d dup!\n", nb_frames-1);
}
}else
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);
if (nb_frames <= 0)
return;
if (ost->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
if (exit_on_error)
av_exit(1);
return;
}
formatted_picture = &picture_crop_temp;
} else {
formatted_picture = in_picture;
}
final_picture = formatted_picture;
padding_src = formatted_picture;
resampling_dst = &ost->pict_tmp;
if (ost->video_pad) {
final_picture = &ost->pict_tmp;
if (ost->video_resample) {
if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
av_log(NULL, AV_LOG_ERROR, "error padding picture\n");
if (exit_on_error)
av_exit(1);
return;
}
resampling_dst = &picture_pad_temp;
}
}
if (ost->video_resample) {
padding_src = NULL;
final_picture = &ost->pict_tmp;
sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);
}
if (ost->video_pad) {
av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
enc->height, enc->width, enc->pix_fmt,
ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);
}
for(i=0;i<nb_frames;i++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= ost->index;
if (s->oformat->flags & AVFMT_RAWPICTURE) {
AVFrame* old_frame = enc->coded_frame;
enc->coded_frame = dec->coded_frame;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
enc->coded_frame = old_frame;
} else {
AVFrame big_picture;
big_picture= *final_picture;
big_picture.interlaced_frame = in_picture->interlaced_frame;
if(avctx_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
if(top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = top_field_first;
}
if (same_quality) {
big_picture.quality = ist->st->quality;
}else
big_picture.quality = ost->st->quality;
if(!me_threshold)
big_picture.pict_type = 0;
big_picture.pts= ost->sync_opts;
ret = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (ret == -1) {
fprintf(stderr, "Video encoding failed\n");
av_exit(1);
}
if(ret>0){
pkt.data= bit_buffer;
pkt.size= ret;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
if(enc->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
*frame_size = ret;
video_size += ret;
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
}
}
| 1threat |
How to play MP4 video in firefox : <p>I have a dynamic video path coming from database. Video can be uploaded in any format. When I load the video in Firefox, I see the following errors</p>
<p><strong>Specified “type” attribute of “video/mp4” is not supported. Load of media resource path_to_video.mp4 failed.</strong></p>
<p>I am loading the video in my html like</p>
<pre><code><p>
<video class="responsive-video" id="trailer">
<source src="<?php echo $biovideo?>" type="video/mp4">
</video>
</p>
</code></pre>
<p>Is there any way to play the mp4 videos in Firefox as I am not sure what extension the video will have</p>
| 0debug |
React: To know size of the element before it gets rendered : <p>Suppose that a component needs to know its size before it renders. With my knowledge I can do this:
render the component, in componentDidMount get the DOM node and extract size out of it, update state with that size, and then render again (lets not make it complicated with event listeners I'd attach to window's resize event, lets assume that window doesn't resize)
It works but seems dirty, the first render is just waste of resources, I wanna know the size of the element (or its container) before it's rendered, I know most of the time the element itself declares the size, but there are some situations when parent element declares the size and my case is one of those situations.
So to sum it up, is there any way to access parent element of a react component before it gets rendered (in componentWillMount)?</p>
<p>P.S. I know react-dimmensions, but I'd like a simpler solution that doesn't need external plugins. I just wanna know if it's possible to access parent node in componentWillMount in react or not.</p>
| 0debug |
static void gen_rfe(DisasContext *s, TCGv_i32 pc, TCGv_i32 cpsr)
{
gen_set_cpsr(cpsr, CPSR_ERET_MASK);
tcg_temp_free_i32(cpsr);
store_reg(s, 15, pc);
s->is_jmp = DISAS_UPDATE;
}
| 1threat |
How to disable multiple rules for eslint nextline : <p>I have this code</p>
<pre><code> const subTotal = orderInfo.details.reduce((acc, cv) => acc += Number(cv.price) * Number(cv.quantity), 0);
</code></pre>
<p>I want to diable two eslint for this line, <strong>no-return-assign</strong> and <strong>no-param-reassign</strong></p>
<p>I tried this way:</p>
<pre><code> /* eslint-disable-next-line no-return-assign eslint-disable-next-line no-param-reassign */
const subTotal = orderInfo.details.reduce((acc, cv) => acc += Number(cv.price) * Number(cv.quantity), 0);
</code></pre>
<p>but my editor still showing <strong>eslint(no-return-assign)</strong> lint error</p>
| 0debug |
Unsure how certain code works : <pre><code>Grid = ["A1","A2","A3","B1","B2","B3","C1","C2","C3"]
print("This is the grid.")
for i in range(3):
print("\t".join(Grid[(i*3):(i*3+3)]))
</code></pre>
<p>I was looking for a way to create a 2D 3x3 grid in Python and found this. I want to use it but I'm not sure how line 4 actually works, other than "\t".</p>
<p>Help much appreciated, thanks :)</p>
| 0debug |
ibm cloud private 2.1.0.3 fails with "waiting for MongoDB to start" error : <p>I am setting up an IBM cloud private community edition 2.1.0.3 in my sandbox environment which consists of the following:</p>
<p>Boot Node: 1
Master Node: 1
Worker Node: 2
Proxy: 1
Management: 1
VA: 1</p>
<p>I followed all the specifications and the installation gets stuck with "Waiting for MongoDB to start". It re-tries for 100 times and ends with a fatal error.</p>
<p>My ICP-CE edition fails trying to wait for MongoDB to start which is a new edition in 2.1.0.3.</p>
| 0debug |
void align_get_bits(GetBitContext *s)
{
int n= (-get_bits_count(s)) & 7;
if(n) skip_bits(s, n);
}
| 1threat |
SQL join 2 tables where data is not intersecting : <p>I have 2 tables, one for storing a post and the other for users that has liked the post.</p>
<p>I want to fetch the posts only where user has not liked it.</p>
<p>Example</p>
<p><strong>Posts Table:</strong> </p>
<p>post_id, title</p>
<p><strong>Like Table:</strong></p>
<p>like_id, post_id, user_id</p>
<p>I only want the list of posts where user has not liked it.</p>
<p>What should be the SQL query?</p>
| 0debug |
What exactly is Dynamic Routing in ReactJS : <p>I have been all around internet about the dynamic routing of React. But I couldn't find anything which explains how it works and how it is different than static routing in every single sense. </p>
<p>I understood it pretty well how the things go when we want to render something in the same page using React-Route.</p>
<p>My question is how does it work when a whole new page is wanted to be rendered? Because in this case all the DOM inside that page has to be re-rendered. Thus would it be static routing? or still dynamic in some ways?</p>
<p>I hope I've been clear.
Thanks for the answers in advance, I appreciate!</p>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Java is the front end technology and php is the back end technology. how could I connect both? : <p>My company is suppose to create an android application along with it's website. I will be handling the website part. So I need to use php as both app's and site's back end. For site i know to do with php. But for app, how could i connect java and php? </p>
| 0debug |
How to disable cache in apollo-link or apollo-client? : <p>I'm using <em>apollo-client</em>, <em>apollo-link</em> and <em>react-apollo</em>, I want to fully disable cache, but don't know how to do it.</p>
<p>I read the source of <code>apollo-cache-inmemory</code>, it has a <code>config</code> argument in its constructor, but I can't build a dummy <code>storeFactory</code> to make it works.</p>
| 0debug |
int avfilter_parse_graph(AVFilterGraph *graph, const char *filters,
AVFilterInOut *open_inputs,
AVFilterInOut *open_outputs, AVClass *log_ctx)
{
int index = 0;
char chr = 0;
AVFilterInOut *curr_inputs = NULL;
do {
AVFilterContext *filter;
filters += consume_whitespace(filters);
if(parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx) < 0)
goto fail;
filter = parse_filter(&filters, graph, index, log_ctx);
if(!filter)
goto fail;
if(filter->input_count == 1 && !curr_inputs && !index) {
const char *tmp = "[in]";
if(parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx) < 0)
goto fail;
}
if(link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx) < 0)
goto fail;
if(parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
log_ctx) < 0)
goto fail;
filters += consume_whitespace(filters);
chr = *filters++;
if(chr == ';' && curr_inputs) {
av_log(log_ctx, AV_LOG_ERROR,
"Could not find a output to link when parsing \"%s\"\n",
filters - 1);
goto fail;
}
index++;
} while(chr == ',' || chr == ';');
if (*filters) {
av_log(log_ctx, AV_LOG_ERROR,
"Unable to parse graph description substring: \"%s\"\n",
filters - 1);
goto fail;
}
if(open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
const char *tmp = "[out]";
if(parse_outputs(&tmp, &curr_inputs, &open_inputs,
&open_outputs, log_ctx) < 0)
goto fail;
}
return 0;
fail:
avfilter_destroy_graph(graph);
free_inout(open_inputs);
free_inout(open_outputs);
free_inout(curr_inputs);
return -1;
}
| 1threat |
How Are Crate API's are coded for rust lang : I was wondering how are crates for rust language are coded.
for example, there is a crate named num_cpus. This crate has this basic method num_cpus::get() which tells number of CPU in your computer.
My questions
- How the method num_cpus::get() is coded (is it done using other language)
- Can the same result be achieved with plain rust code without using any crates
| 0debug |
static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
register int t1,t2,t3,t4,t5,t6,t7,t8;
DCTELEM *src, *dst;
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
src = block;
dst = block;
for(i = 0; i < 4; i++){
t1 = 12 * (src[0] + src[4]) + 4;
t2 = 12 * (src[0] - src[4]) + 4;
t3 = 16 * src[2] + 6 * src[6];
t4 = 6 * src[2] - 16 * src[6];
t5 = t1 + t3;
t6 = t2 + t4;
t7 = t2 - t4;
t8 = t1 - t3;
t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
dst[0] = (t5 + t1) >> 3;
dst[1] = (t6 + t2) >> 3;
dst[2] = (t7 + t3) >> 3;
dst[3] = (t8 + t4) >> 3;
dst[4] = (t8 - t4) >> 3;
dst[5] = (t7 - t3) >> 3;
dst[6] = (t6 - t2) >> 3;
dst[7] = (t5 - t1) >> 3;
src += 8;
dst += 8;
}
src = block;
for(i = 0; i < 8; i++){
t1 = 17 * (src[ 0] + src[16]) + 64;
t2 = 17 * (src[ 0] - src[16]) + 64;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
src ++;
dest++;
}
}
| 1threat |
static void vfio_intp_inject_pending_lockheld(VFIOINTp *intp)
{
trace_vfio_platform_intp_inject_pending_lockheld(intp->pin,
event_notifier_get_fd(&intp->interrupt));
intp->state = VFIO_IRQ_ACTIVE;
qemu_set_irq(intp->qemuirq, 1);
}
| 1threat |
Python. Noob. Syntax error : <pre><code>A = int(input()) #recom. sleep time
B = int(input()) #unrecom. sleep time
H = int(input()) #fact. slept
if (A <= H < B ):
print('Fine')
elif (A < H >= B):
print('too much')
else (A > H < B):
print('not much')
Error:
File "<ipython-input-9-12133f4a4c3d>", line 8
else(A > H < B):
^
SyntaxError: invalid syntax
</code></pre>
<p>Guys don't be rude, I'm financial and start learning programming :)
I can't see the difference between code who passed errors check and this one.</p>
| 0debug |
def concatenate_strings(test_tup1, test_tup2):
res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | 0debug |
What happens if I forget to close a scanset? : <p>Suppose I forgot to close the right square bracket <code>]</code> of a scanset. What will happen then? Does it invoke Undefined Behavior?</p>
<p>Example:</p>
<pre><code>char str[] = "Hello! One Two Three";
char s1[50] = {0}, s2[50] = {0};
sscanf(str, "%s %[^h", s1, s2); /* UB? */
printf("s1='%s' s2='%s'\n", s1, s2);
</code></pre>
<p>I get a warning from GCC when compiling:</p>
<pre><code>source_file.c: In function ‘main’:
source_file.c:11:5: warning: no closing ‘]’ for ‘%[’ format [-Wformat=]
sscanf(str, "%s %[^h", s1, s2); /* UB? */
</code></pre>
<p>and the output as</p>
<pre><code>s1='Hello!' s2=''
</code></pre>
<p>I've also noticed that the <code>sscanf</code> returns 1. But what exactly is going on here?</p>
<p>I've checked the C11 standard, but found no information related to this.</p>
| 0debug |
Calling outer function from inner function of another outher function : Lets say that
function a(){
console.log("i am a")
}
function b(){
function c(){
//call function a here
}
}
how do i call function a from function c ? | 0debug |
How to make print() accept the user input in same line? : <p>When i am tying to take user input in python then it is taking input in next line but I want ti to take input in same line. How to achieve that? </p>
<p>I am taking input like this</p>
<pre><code>print("Enter your name:",end=" ")
</code></pre>
<p>It is showing on console as</p>
<pre><code>Enter your name:
Ankit
</code></pre>
<p>but I want it as</p>
<pre><code>Enter your name:Ankit
</code></pre>
| 0debug |
How do i show the other "cout" things before inputing a cin? i cant explain it very well sorry : im supposed to do this [what im supposed to do][1]
but what happens to my code is this:
[my work][2]
can someone help me out? i need to input a letter inside the box, but the box wont completely form because of the cin thingy
[1]: https://i.stack.imgur.com/CCLxh.png
[2]: https://i.stack.imgur.com/vPLUT.png | 0debug |
How to use one module from another module in a Rust cargo project? : <p>There's a lot of Rust <a href="https://www.google.ca/search?q=rust+use+module" rel="noreferrer">documentation</a> about using modules, but I haven't found an example of a Cargo binary that has multiple modules, with one module using another. My example has three files inside the src folder. Modules a and b are at the same level. One is not a submodule of another.</p>
<p>main.rs:</p>
<pre><code>mod a;
fn main() {
println!("Hello, world!");
a::a();
}
</code></pre>
<p>a.rs:</p>
<pre><code>pub fn a() {
println!("A");
b::b();
}
</code></pre>
<p>and b.rs:</p>
<pre><code>pub fn b() {
println!("B");
}
</code></pre>
<p>I've tried variations of <code>use b</code> and <code>mod b</code> inside a.rs, but I cannot get this code to compile. If I try to use <code>use b</code>, for example, I get the following error:</p>
<pre><code> --> src/a.rs:1:5
|
1 | use b;
| ^ no `b` in the root. Did you mean to use `a`?
</code></pre>
<p>What's the right way to have Rust recognize that I want to use module b from module a inside a cargo app?</p>
| 0debug |
How to use Progress bar in C#? : <p>I have created a windows form for login. On login button click it reads data from a text file for user name and password verification. In this verification duration i want to show a updating Progress bar to the user on login button click. How exactly it should be done ? Please share the snippet for it.
P.S.:- Please share the snippet using backgroundworker thread if possible.
Thanks in advance.</p>
| 0debug |
How to edit a commit in github : I wanted to change a commit in Github for which I googled and found this command
git commit --amend
Now, When I pass this command, I get a screen which look something like this
[![enter image description here][1]][1]
Now, When i start typing commit here, It just plays sound similar to one that sort of means that I am typing in a wrong place (invalid command)
Can someone please help me in figuring out how we can edit a commit message in git?
[1]: https://i.stack.imgur.com/QumUj.png | 0debug |
python dictionary data manipulation : i have the following dataset in pytyhon:
> data=[{'id': '431876400186007/insights/page_fans_country/lifetime', 'name':
> 'page_fans_country', 'description': 'Lifetime: Aggregated Facebook
> location data, sorted by country, about the people who like your Page.
> (Unique Users)', 'title': 'Lifetime Likes by Country', 'period':
> 'lifetime', 'values': [{'end_time': '2016-07-02T07:00:00+0000',
> 'value': {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID':
> 91, 'MX': 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230,
> 'RU': 99, 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 550, 'GE':
> 178, 'GR': 273321, 'CO': 98, 'DZ': 86, 'US': 2447, 'BG': 732, 'MA':
> 95, 'MK': 831, 'PT': 160, 'CH': 187, 'CA': 317, 'DE': 4463, 'AL':
> 1588, 'FR': 388, 'PE': 204, 'AE': 142, 'TR': 547, 'BR': 609, 'SE':
> 495, 'HU': 120, 'IT': 845, 'PL': 186, 'IN': 114, 'EG': 217, 'NO': 97,
> 'DK': 77, 'RS': 444}}, {'end_time': '2016-07-03T07:00:00+0000',
> 'value': {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID':
> 91, 'MX': 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230,
> 'RU': 99, 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 548, 'GE':
> 178, 'GR': 273275, 'CO': 98, 'DZ': 86, 'US': 2447, 'BG': 732, 'MA':
> 95, 'MK': 831, 'PT': 159, 'CH': 187, 'CA': 317, 'DE': 4462, 'AL':
> 1588, 'FR': 388, 'PE': 204, 'AE': 142, 'TR': 547, 'BR': 607, 'SE':
> 495, 'HU': 120, 'IT': 845, 'PL': 186, 'IN': 114, 'EG': 217, 'NO': 97,
> 'DK': 77, 'RS': 445}}, {'end_time': '2016-07-04T07:00:00+0000',
> 'value': {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID':
> 90, 'MX': 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230,
> 'RU': 99, 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 547, 'GE':
> 178, 'GR': 273249, 'CO': 98, 'DZ': 86, 'US': 2445, 'BG': 732, 'MA':
> 95, 'MK': 831, 'PT': 159, 'CH': 187, 'CA': 317, 'DE': 4460, 'AL':
> 1588, 'FR': 388, 'PE': 204, 'AE': 142, 'TR': 547, 'BR': 608, 'SE':
> 495, 'HU': 120, 'IT': 845, 'PL': 186, 'IN': 114, 'EG': 217, 'NO': 97,
> 'DK': 77, 'RS': 444}}]}]
i want to make a dictionary with country data like this:
> {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID': 91, 'MX':
> 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230, 'RU': 99,
> 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 550, 'GE': 178, 'GR':
> 273321, 'CO': 98}
what should i do?
i cannot use the following code
data['value']
as i could in an ordinary dictionary
| 0debug |
static void chomp3(ChannelData *ctx, int16_t *output, uint8_t val,
const uint16_t tab1[],
const int16_t *tab2, int tab2_stride,
uint32_t numChannels)
{
int16_t current;
current = tab2[((ctx->index & 0x7f0) >> 4)*tab2_stride + val];
current = mace_broken_clip_int16(current + ctx->lev);
ctx->lev = current - (current >> 3);
*output = QT_8S_2_16S(current);
if (( ctx->index += tab1[val]-(ctx->index >> 5) ) < 0)
ctx->index = 0;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.