problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Set Proxy for Linux server by bash script failed : <p>I use the command below to set proxy in command line and it succeed:</p>
<pre><code>export http_proxy="http://proxy.company.com:8080/"
</code></pre>
<p>But When I use a bash script, below is the content of the script</p>
<pre><code>export http_proxy="http://proxy.company.com:8080/"
export https_proxy="http://proxy.company.com:8080/"
sudo yum list
</code></pre>
<p>And it failed. </p>
<p>Can anyone tell me the difference? </p>
<p>Thanks.</p>
| 0debug
|
Using dplyr summarise_at with column index : <p>I noticed that when supplying column indices to <code>dplyr::summarize_at</code> the column to be summarized is determined excluding the grouping column(s). I wonder if that is how it's supposed to be since by this design, using the correct column index depends on whether the summarising column(s) are positioned before or after the grouping columns.</p>
<p>Here's an example:</p>
<pre><code>library(dplyr)
data("mtcars")
# grouping column after summarise columns
mtcars %>% group_by(gear) %>% summarise_at(3:4, mean)
## A tibble: 3 x 3
# gear disp hp
# <dbl> <dbl> <dbl>
#1 3 326.3000 176.1333
#2 4 123.0167 89.5000
#3 5 202.4800 195.6000
# grouping columns before summarise columns
mtcars %>% group_by(cyl) %>% summarise_at(3:4, mean)
## A tibble: 3 x 3
# cyl hp drat
# <dbl> <dbl> <dbl>
#1 4 82.63636 4.070909
#2 6 122.28571 3.585714
#3 8 209.21429 3.229286
# no grouping columns
mtcars %>% summarise_at(3:4, mean)
# disp hp
#1 230.7219 146.6875
# actual third & fourth columns
names(mtcars)[3:4]
#[1] "disp" "hp"
packageVersion("dplyr")
#[1] ‘0.7.2’
</code></pre>
<p>Notice how the summarised columns change depending on grouping and position of the grouping column.</p>
<p>Is this the same on other platforms? Is it a bug or a feature?</p>
| 0debug
|
'for' structure: usage of char : <p>I have just started learning programming, and as I was reading about strings, I found this piece of code:</p>
<pre><code>System.out.print("Conversion from string to char array\n");
char [] stringToarray = exampleString.toCharArray();
for (char character : stringToarray) {
System.out.print(character);
}
</code></pre>
<p>Which I don't fully understand... what does "char character : stringToarray" do?
Why can you use it inside a 'for', like that?
I am confused because it is not the structure of 'for' I am used to see</p>
<p>Thank you very much for your attention !</p>
| 0debug
|
Scikit learn SVC predict probability doesn't work as expected : <p>I built sentiment analyzer using SVM classifier. I trained model with probability=True and it can give me probability. But when I pickled my model and load it again later, the probability doesn't work anymore.</p>
<p>The model:</p>
<pre><code>from sklearn.svm import SVC, LinearSVC
pipeline_svm = Pipeline([
('bow', CountVectorizer()),
('tfidf', TfidfTransformer()),
('classifier', SVC(probability=True)),])
# pipeline parameters to automatically explore and tune
param_svm = [
{'classifier__C': [1, 10, 100, 1000], 'classifier__kernel': ['linear']},
{'classifier__C': [1, 10, 100, 1000], 'classifier__gamma': [0.001, 0.0001], 'classifier__kernel': ['rbf']},
]
grid_svm = GridSearchCV(
pipeline_svm,
param_grid=param_svm,
refit=True,
n_jobs=-1,
scoring='accuracy',
cv=StratifiedKFold(label_train, n_folds=5),)
svm_detector_reloaded = cPickle.load(open('svm_sentiment_analyzer.pkl', 'rb'))
print(svm_detector_reloaded.predict([""""Today is awesome day"""])[0])
</code></pre>
<p>Gives me: </p>
<blockquote>
<p>AttributeError: predict_proba is not available when probability=False</p>
</blockquote>
| 0debug
|
When to use tf.resource and tf.variant? : <p>TensorFlow DType has tf.resource and tf.variant with pretty vague description. Can someone please explain to me what those two types are for? It'd be great if there are examples. Thanks a lot!</p>
| 0debug
|
Ansible append text to line in certain section in file : I would like to know if there is a way using Ansible to append text to the end of a line in certain section of a file, an example is going to clarify what I want to do:
Think of a file like this:
[section01]
path = /home/section01
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
[section02]
path = /home/section02
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
[section03]
path = /home/section03
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
I would like to add "brazil" on host_allow in [section02] to get this "new file"
[section01]
path = /home/section01
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
[section02]
path = /home/section02
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada,brazil
[section03]
path = /home/section03
read only = yes
list = yes
uid = apache
gid = apache
hosts deny = 0.0.0.0/0.0.0.0
hosts allow = mexico,usa,canada
I really appreciate your help
| 0debug
|
Custom date format in javascript form date format yyyy-mm-dd : <p>I have the date <code>2013-03-10</code> how can i get <code>March 10,2013</code>. I tried a lot with Date function in javascript but can't get correct format as given above.Help should be appreciated.</p>
| 0debug
|
I have a list as UEID = ['0','0 1 ','0 1 2','0 1 2 3'] need an output as ['0',['0','1'],...] or UEID[1][1] should print 1 : My code:
for x in UEID:
if " " in UEID[x]:
ueid_list = [int(j) for j in UEID[x]]
print ueid_list
This is showing an error as:
TypeError: list indices must be in integer, not str
| 0debug
|
strips out all characters except: a-z, A-Z, 0-9, underscore and the forward slash from a String using Python : <p>Using regular expression strips out all characters except a-z, A-Z, 0-9, underscore and the forward slash from a String and All other characters are to get removed and replaced by an underscore. In the replaced version, no consecutive multiple underscores should exist. </p>
<p>For example, </p>
<p>input :- "Ab 4/5 (t) "
output:- "Ab_4/5_t_"</p>
<p>input :- "AB___cd@# E"
output:- "AB_cd_E"</p>
| 0debug
|
ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224) : <p>I have a list say, temp_list with following properties : </p>
<pre><code>len(temp_list) = 9260
temp_list[0].shape = (224,224,3)
</code></pre>
<p>Now, when I am converting into numpy array, </p>
<pre><code>x = np.array(temp_list)
</code></pre>
<p>I am getting the error : </p>
<pre><code>ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)
</code></pre>
<p>Can someone help me here?</p>
| 0debug
|
void lance_init(NICInfo *nd, target_phys_addr_t leaddr, void *dma_opaque,
qemu_irq irq, qemu_irq *reset)
{
PCNetState *d;
int lance_io_memory;
qemu_check_nic_model(nd, "lance");
d = qemu_mallocz(sizeof(PCNetState));
lance_io_memory =
cpu_register_io_memory(0, lance_mem_read, lance_mem_write, d);
d->dma_opaque = dma_opaque;
*reset = *qemu_allocate_irqs(parent_lance_reset, d, 1);
cpu_register_physical_memory(leaddr, 4, lance_io_memory);
d->irq = irq;
d->phys_mem_read = ledma_memory_read;
d->phys_mem_write = ledma_memory_write;
pcnet_common_init(d, nd);
}
| 1threat
|
How to access SparkContext from SparkSession instance? : <p>I am importing <code>SparkSession</code> as follows in PySpark:</p>
<pre><code>from pyspark.sql import SparkSession
</code></pre>
<p>Then I create <code>SparkSession</code>:</p>
<pre><code>spark = SparkSession.builder.appName("test").getOrCreate()
</code></pre>
<p>and try to access <code>SparkContext</code>:</p>
<pre><code>spark.SparkContext.broadcast(...)
</code></pre>
<p>However, I get an error that <code>SparkContext</code> does not exist. How can I access it in order to set <code>broadcast</code> variables?</p>
| 0debug
|
Debounce computed properties/getters in Vue : <p>I can't seem to debounce (lodash) computed properties or vuex getters. The debounced functions always return undefined.</p>
<p><a href="https://jsfiddle.net/guanzo/yqk0jp1j/2/" rel="noreferrer">https://jsfiddle.net/guanzo/yqk0jp1j/2/</a></p>
<p>HTML:</p>
<pre><code><div id="app">
<input v-model="text">
<div>computed: {{ textComputed }} </div>
<div>debounced: {{ textDebounced }} </div>
</div>
</code></pre>
<p>JS:</p>
<pre><code>new Vue({
el:'#app',
data:{
text:''
},
computed:{
textDebounced: _.debounce(function(){
return this.text
},500),
textComputed(){
return this.text
}
}
})
</code></pre>
| 0debug
|
css Border radius looking blur : Css border radius looking blur(pixel out).i used css
border: 1px solid #8d2034;-webkit-border-radius: 50%;-moz-border-radius: 50%;border-radius: 50%;width: 27px;height: 27px !important;/* float: left; */
text-align: center;padding: 0px !important;line-height: 26px;margin: 10px 10px 0px 0px;
| 0debug
|
Is there any library to convert seconds to days/hours/miniutes in java? : <p>I just want to convert seconds to proper time format.</p>
<p>e.g. if it is 30 seconds, then it is just displayed as 30 seconds.
if it is 80 seconds, it will be displayed as 1 minute 20 seconds
It is similar when it is larger than one hour and one day.</p>
<p>Of course it is simple to implement by myself, just just wonder whether there's any existed library I can leverage. Thanks</p>
| 0debug
|
HTTP2 support in MAMP Pro : <p>Is there any way to enable HTTP2 support in MAMP Pro? I want to test and improve some of my local development websites with HTTP2 support.</p>
<p>I've been searching for a while now, but haven't found a single solution.</p>
| 0debug
|
static void revert_cdlms(WmallDecodeCtx *s, int tile_size)
{
int icoef, ich;
int32_t pred, channel_coeff;
int ilms, num_lms;
for (ich = 0; ich < s->num_channels; ich++) {
if (!s->is_channel_coded[ich])
continue;
for (icoef = 0; icoef < tile_size; icoef++) {
num_lms = s->cdlms_ttl[ich];
channel_coeff = s->channel_residues[ich][icoef];
if (icoef == s->transient_pos[ich]) {
s->transient[ich] = 1;
use_high_update_speed(s, ich);
}
for (ilms = num_lms; ilms >= 0; ilms--) {
pred = lms_predict(s, ich, ilms);
channel_coeff += pred;
lms_update(s, ich, ilms, channel_coeff, pred);
}
if (s->transient[ich]) {
--s->channel[ich].transient_counter;
if(!s->channel[ich].transient_counter)
use_normal_update_speed(s, ich);
}
s->channel_coeffs[ich][icoef] = channel_coeff;
}
}
}
| 1threat
|
add data into primary key : <p>this is my table.In this table i want to add a primary key column name "emp_id" as the first column .I don't know how to do it .So,can you please help me! </p>
<pre><code>EMP_NAME EMP_POS SALARY GENDER
----------------- ----------------- -------------- ------
anand worker 10000 M
balu manager 50000 M
carl manager 50000 M
riya md 60000 F
prabhu owner 99999999 M
</code></pre>
| 0debug
|
On child hover change the css of Parent : <p>I want to change the css of parent on hover of Child element.</p>
<pre><code><ul id="main-menu">
<li>
<a href="#">
<i class="fa fa-building-o" aria-hidden="true"></i>
Private Limited
<i class="fa fa-caret-down"></i>
</a>
<ul class="submenu">
<li><a href="#0">Company</a></li>
<li><a href="#0">Contact</a></li>
<li><a href="#0">Industry</a></li>
</ul>
</li></ ul>
</code></pre>
<p>What i want is if i hover on li of <strong>submenu</strong>, li of <strong>main-menu</strong> get highlighted.</p>
| 0debug
|
Could not add entry '0' to cache localClassSetAnalysis.bin : <p>This project was running but today when i run it it gives this error</p>
<blockquote>
<p>Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not add entry '0' to cache localClassSetAnalysis.bin (/home/blackgoogle/Desktop/SpeechToText/.gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin).</p>
</blockquote>
<p>this is my app gradle file</p>
<pre><code>apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "timepass.vectorx.com.speechtotext"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.nuance:speechkit:2.1+@aar'
compile 'com.android.support:appcompat-v7:23.4.0'
}
</code></pre>
<p>and this one is project gradle file</p>
<pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
</code></pre>
<p>please guys help....</p>
| 0debug
|
URGENT: ORACLE TRIGGER: update a field (field+1 and field -1) when inserting and deleting : This is a bit urgent doubt I have for my DBMS on the next 1.30h.
I need to make a trigger that when inserting or deleting an employee (EMPLOYERS TABLE), the attribute EMPTOTAL from table SHOPS UPDATE.
EMPLOYERS table has a field (and Foreig Key) called SHOP that references the SHOPS table.
I know it should be something similar to this, but I don't have any example that involves more than 1 table on my exercises.
__________________________________
CREATE OR REPLACE TRIGGER UPD_EMPTOTAL BEFORE INSERT OR DELETE ON EMPLOYERS FOR EACH ROW
DECLARE
BEGIN
IF INSERTING THEN
UPDATE TIENDAS SET EMPTOTAL=EMPTOTAL+1;
ELSIF DELETING THEN
UPDATE TIENDAS SET EMPTOTAL=EMPTOTAL-1;
END IF;
END;
_____________
Thank you in advance!
| 0debug
|
static int qemu_rdma_broken_ipv6_kernel(Error **errp, struct ibv_context *verbs)
{
struct ibv_port_attr port_attr;
#ifdef CONFIG_LINUX
if (!verbs) {
int num_devices, x;
struct ibv_device ** dev_list = ibv_get_device_list(&num_devices);
bool roce_found = false;
bool ib_found = false;
for (x = 0; x < num_devices; x++) {
verbs = ibv_open_device(dev_list[x]);
if (ibv_query_port(verbs, 1, &port_attr)) {
ibv_close_device(verbs);
ERROR(errp, "Could not query initial IB port");
return -EINVAL;
}
if (port_attr.link_layer == IBV_LINK_LAYER_INFINIBAND) {
ib_found = true;
} else if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) {
roce_found = true;
}
ibv_close_device(verbs);
}
if (roce_found) {
if (ib_found) {
fprintf(stderr, "WARN: migrations may fail:"
" IPv6 over RoCE / iWARP in linux"
" is broken. But since you appear to have a"
" mixed RoCE / IB environment, be sure to only"
" migrate over the IB fabric until the kernel "
" fixes the bug.\n");
} else {
ERROR(errp, "You only have RoCE / iWARP devices in your systems"
" and your management software has specified '[::]'"
", but IPv6 over RoCE / iWARP is not supported in Linux.");
return -ENONET;
}
}
return 0;
}
if (ibv_query_port(verbs, 1, &port_attr)) {
ERROR(errp, "Could not query initial IB port");
return -EINVAL;
}
if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) {
ERROR(errp, "Linux kernel's RoCE / iWARP does not support IPv6 "
"(but patches on linux-rdma in progress)");
return -ENONET;
}
#endif
return 0;
}
| 1threat
|
Ruby BigDecimal Method Error : Using Ruby v2.2.1 with following code, i am getting Error
- r56.rb:6:in `<module:BigMath>': undefined method `log_slow' for module `BigMath' (NameError)
from r56.rb:5:in `<main>'
i have created log_slow alias and it is not working
require 'bigdecimal'
require 'bigdecimal/math'
require 'bigdecimal/util'
module BigMath
alias :log :log_slow
def log(x, prec)
if x <= 0 || prec <= 0
raise ArgumentError, "Zero or negative argument for log"
end
return x if x.infinite? || x.nan?
sign, fraction, power, exponent = x.split
fraction = BigDecimal(".#{fraction}")
power = power.to_s.to_d
log_slow(fraction, prec) + (log_slow(power, prec) * exponent)
end
end
include BigMath
number = BigDecimal("1234.5678")
Math.log(number)
prec = 50
puts BigMath.log_slow(number, prec).round(prec).to_s("F")
puts BigMath.log(number, prec).round(prec).to_s("F")
puts BigMath.log(number ** 1000, prec).round(prec).to_s("F")
| 0debug
|
int mm_support(void)
{
int rval;
int eax, ebx, ecx, edx;
__asm__ __volatile__ (
"pushf\n\t"
"pop %0\n\t"
"movl %0, %1\n\t"
"xorl $0x200000, %0\n\t"
"push %0\n\t"
"popf\n\t"
"pushf\n\t"
"pop %0\n\t"
: "=a" (eax), "=c" (ecx)
:
: "cc"
);
if (eax == ecx)
return 0;
cpuid(0, eax, ebx, ecx, edx);
if (ebx == 0x756e6547 &&
edx == 0x49656e69 &&
ecx == 0x6c65746e) {
inteltest:
cpuid(1, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (edx & 0x02000000)
rval |= MM_MMXEXT | MM_SSE;
if (edx & 0x04000000)
rval |= MM_SSE2;
return rval;
} else if (ebx == 0x68747541 &&
edx == 0x69746e65 &&
ecx == 0x444d4163) {
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (edx & 0x80000000)
rval |= MM_3DNOW;
if (edx & 0x00400000)
rval |= MM_MMXEXT;
return rval;
} else if (ebx == 0x746e6543 &&
edx == 0x48727561 &&
ecx == 0x736c7561) {
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
rval = 0;
if( edx & ( 1 << 31) )
rval |= MM_3DNOW;
if( edx & ( 1 << 23) )
rval |= MM_MMX;
if( edx & ( 1 << 24) )
rval |= MM_MMXEXT;
if(rval==0)
goto inteltest;
return rval;
} else if (ebx == 0x69727943 &&
edx == 0x736e4978 &&
ecx == 0x64616574) {
if (eax != 2)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((eax & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (eax & 0x01000000)
rval |= MM_MMXEXT;
return rval;
} else if (ebx == 0x756e6547 &&
edx == 0x54656e69 &&
ecx == 0x3638784d) {
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
return 0;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
return MM_MMX;
} else {
return 0;
}
}
| 1threat
|
static ExitStatus gen_store_conditional(DisasContext *ctx, int ra, int rb,
int32_t disp16, int quad)
{
TCGv addr;
if (ra == 31) {
return NO_EXIT;
}
#if defined(CONFIG_USER_ONLY)
addr = cpu_lock_st_addr;
#else
addr = tcg_temp_local_new();
#endif
tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16);
#if defined(CONFIG_USER_ONLY)
return gen_excp(ctx, quad ? EXCP_STQ_C : EXCP_STL_C, ra);
#else
{
int lab_fail, lab_done;
TCGv val;
lab_fail = gen_new_label();
lab_done = gen_new_label();
tcg_gen_brcond_i64(TCG_COND_NE, addr, cpu_lock_addr, lab_fail);
val = tcg_temp_new();
tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx, quad ? MO_LEQ : MO_LESL);
tcg_gen_brcond_i64(TCG_COND_NE, val, cpu_lock_value, lab_fail);
tcg_gen_qemu_st_i64(cpu_ir[ra], addr, ctx->mem_idx,
quad ? MO_LEQ : MO_LEUL);
tcg_gen_movi_i64(cpu_ir[ra], 1);
tcg_gen_br(lab_done);
gen_set_label(lab_fail);
tcg_gen_movi_i64(cpu_ir[ra], 0);
gen_set_label(lab_done);
tcg_gen_movi_i64(cpu_lock_addr, -1);
tcg_temp_free(addr);
return NO_EXIT;
}
#endif
}
| 1threat
|
int qemu_can_send_packet(VLANClientState *sender)
{
VLANState *vlan = sender->vlan;
VLANClientState *vc;
for (vc = vlan->first_client; vc != NULL; vc = vc->next) {
if (vc == sender) {
continue;
}
if (!vc->can_receive || vc->can_receive(vc->opaque)) {
return 1;
}
}
return 0;
}
| 1threat
|
static inline int tcg_gen_code_common(TCGContext *s,
tcg_insn_unit *gen_code_buf,
long search_pc)
{
int oi, oi_next;
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) {
qemu_log("OP:\n");
tcg_dump_ops(s);
qemu_log("\n");
}
#endif
#ifdef CONFIG_PROFILER
s->opt_time -= profile_getclock();
#endif
#ifdef USE_TCG_OPTIMIZATIONS
tcg_optimize(s);
#endif
#ifdef CONFIG_PROFILER
s->opt_time += profile_getclock();
s->la_time -= profile_getclock();
#endif
tcg_liveness_analysis(s);
#ifdef CONFIG_PROFILER
s->la_time += profile_getclock();
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT))) {
qemu_log("OP after optimization and liveness analysis:\n");
tcg_dump_ops(s);
qemu_log("\n");
}
#endif
tcg_reg_alloc_start(s);
s->code_buf = gen_code_buf;
s->code_ptr = gen_code_buf;
tcg_out_tb_init(s);
for (oi = s->gen_first_op_idx; oi >= 0; oi = oi_next) {
TCGOp * const op = &s->gen_op_buf[oi];
TCGArg * const args = &s->gen_opparam_buf[op->args];
TCGOpcode opc = op->opc;
const TCGOpDef *def = &tcg_op_defs[opc];
uint16_t dead_args = s->op_dead_args[oi];
uint8_t sync_args = s->op_sync_args[oi];
oi_next = op->next;
#ifdef CONFIG_PROFILER
tcg_table_op_count[opc]++;
#endif
switch (opc) {
case INDEX_op_mov_i32:
case INDEX_op_mov_i64:
tcg_reg_alloc_mov(s, def, args, dead_args, sync_args);
break;
case INDEX_op_movi_i32:
case INDEX_op_movi_i64:
tcg_reg_alloc_movi(s, args, dead_args, sync_args);
break;
case INDEX_op_debug_insn_start:
break;
case INDEX_op_discard:
temp_dead(s, args[0]);
break;
case INDEX_op_set_label:
tcg_reg_alloc_bb_end(s, s->reserved_regs);
tcg_out_label(s, args[0], s->code_ptr);
break;
case INDEX_op_call:
tcg_reg_alloc_call(s, op->callo, op->calli, args,
dead_args, sync_args);
break;
default:
if (def->flags & TCG_OPF_NOT_PRESENT) {
tcg_abort();
}
tcg_reg_alloc_op(s, def, opc, args, dead_args, sync_args);
break;
}
if (search_pc >= 0 && search_pc < tcg_current_code_size(s)) {
return oi;
}
#ifndef NDEBUG
check_regs(s);
#endif
}
tcg_out_tb_finalize(s);
return -1;
}
| 1threat
|
static ExitStatus trans_fop_wed_0e(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned rt = assemble_rt64(insn);
unsigned ra = extract32(insn, 21, 5);
return do_fop_wed(ctx, rt, ra, di->f_wed);
}
| 1threat
|
loss decrease starts from second epoch : <p>I am using Python with Keras and Tensorflow (gpu).</p>
<p>I train a ConvNet for an image classification task. When I train the Network, I get following results for the loss function on training data:</p>
<p><strong>before</strong> first epoch: 1.099</p>
<p>after first epoch: 1.094 </p>
<p>after second epoch: 0.899 </p>
<p>after third epoch: 0.713 </p>
<p>after fourth epoch: 0.620722375 </p>
<p>after fifth epoch: 0.532505135</p>
<p>Why does the decrease of loss function starts at second epoch? Why is there no decrease after first epoch?</p>
<p>Thanks in advance.</p>
| 0debug
|
Grafana: Template variables are not supported in alert queries : <p>Hi I want to create a simple alert in grafana to check whether there is no data for the last 5 minutes.</p>
<p>But I get an error </p>
<blockquote>
<p>Template variables are not supported in alert queries</p>
</blockquote>
<p>Well, according to this <a href="https://github.com/grafana/grafana/issues/6230" rel="noreferrer">issue</a> templates are not supporting in grafana yet.
I have two questions:</p>
<ol>
<li><p>What is templating? </p></li>
<li><p>How can I avoid this error?</p></li>
</ol>
<p><a href="https://i.stack.imgur.com/onZAC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/onZAC.png" alt="enter image description here"></a></p>
| 0debug
|
SwiftUI: Increase tap/drag area for user interaction : <p>I've built a custom slider in SwiftUI with a thumb dragger that is 20x20. Everything is working, except the tap target is quite small since it's just the 20x20 view. I'm looking for a way to increase this to make it easier for users to interact with my slider. Is there a way to do this in SwiftUI?</p>
<p>I tried wrapping my thumb in <code>Color.clear.overlay</code> and setting the frame to 60x60. This works if the color is solid, like <code>red</code>, but with <code>clear</code> the tap target seems to revert back to visible pixels of 20x20.</p>
<p>You can see on this gif I'm able to drag the slider even when clicking outside of the thumb.</p>
<p><a href="https://i.stack.imgur.com/KiCiF.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/KiCiF.gif" alt="slider with red background"></a></p>
<p>However, as soon as I change the color to <code>clear</code>, this area no longer receives interactions.</p>
<p><a href="https://i.stack.imgur.com/Y96SV.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/Y96SV.gif" alt="slider with clear background"></a></p>
| 0debug
|
static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
{
Error *local_err = NULL;
int64_t bytes = 0;
int64_t objsize;
int obj_order = 0;
const char *pool, *name, *conf, *clientname, *keypairs;
const char *secretid;
rados_t cluster;
rados_ioctx_t io_ctx;
QDict *options = NULL;
int ret = 0;
secretid = qemu_opt_get(opts, "password-secret");
bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
objsize = qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, 0);
if (objsize) {
if ((objsize - 1) & objsize) {
error_setg(errp, "obj size needs to be power of 2");
ret = -EINVAL;
goto exit;
}
if (objsize < 4096) {
error_setg(errp, "obj size too small");
ret = -EINVAL;
goto exit;
}
obj_order = ctz32(objsize);
}
options = qdict_new();
qemu_rbd_parse_filename(filename, options, &local_err);
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto exit;
}
pool = qdict_get_try_str(options, "pool");
conf = qdict_get_try_str(options, "conf");
clientname = qdict_get_try_str(options, "user");
name = qdict_get_try_str(options, "image");
keypairs = qdict_get_try_str(options, "=keyvalue-pairs");
ret = rados_create(&cluster, clientname);
if (ret < 0) {
error_setg_errno(errp, -ret, "error initializing");
goto exit;
}
ret = rados_conf_read_file(cluster, conf);
if (conf && ret < 0) {
error_setg_errno(errp, -ret, "error reading conf file %s", conf);
ret = -EIO;
goto shutdown;
}
ret = qemu_rbd_set_keypairs(cluster, keypairs, errp);
if (ret < 0) {
ret = -EIO;
goto shutdown;
}
if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) {
ret = -EIO;
goto shutdown;
}
ret = rados_connect(cluster);
if (ret < 0) {
error_setg_errno(errp, -ret, "error connecting");
goto shutdown;
}
ret = rados_ioctx_create(cluster, pool, &io_ctx);
if (ret < 0) {
error_setg_errno(errp, -ret, "error opening pool %s", pool);
goto shutdown;
}
ret = rbd_create(io_ctx, name, bytes, &obj_order);
if (ret < 0) {
error_setg_errno(errp, -ret, "error rbd create");
}
rados_ioctx_destroy(io_ctx);
shutdown:
rados_shutdown(cluster);
exit:
QDECREF(options);
return ret;
}
| 1threat
|
Tried using pip3 install netfilterqueue but I.m getting this error : pip3 install netfilterqueue
Collecting netfilterqueue
Downloading https://files.pythonhosted.org/packages/39/c4/8f73f70442aa4094b3c37876c96cddad2c3e74c058f6cd9cb017d37ffac0/NetfilterQueue-0.8.1.tar.gz (58kB)
100% |████████████████████████████████| 61kB 144kB/s
Building wheels for collected packages: netfilterqueue
Running setup.py bdist_wheel for netfilterqueue ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-s7oerfb1/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-u29vs26s --python-tag cp37:
running bdist_wheel
running build
running build_ext
building 'netfilterqueue' extension
creating build
creating build/temp.linux-x86_64-3.7
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -flto -fuse-linker-plugin -ffat-lto-objects -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c netfilterqueue.c -o build/temp.linux-x86_64-3.7/netfilterqueue.o
netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’:
netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types]
2150 | __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload));
| ~^~~~~~~~~~~~~~~~~~~~~~~
| |
| char **
In file included from netfilterqueue.c:440:
/usr/include/libnetfilter_queue/libnetfilter_queue.h:122:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’
122 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data);
| ~~~~~~~~~~~~~~~~^~~~
netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’:
netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration]
2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| PyBytes_FromStringAndSize
netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
| ^
netfilterqueue.c: In function ‘__Pyx_PyCFunction_FastCall’:
netfilterqueue.c:6436:13: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))meth’
6436 | return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
netfilterqueue.c: In function ‘__Pyx__ExceptionSave’:
netfilterqueue.c:7132:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7132 | *type = tstate->exc_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7133:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7133 | *value = tstate->exc_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7134:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7134 | *tb = tstate->exc_traceback;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c: In function ‘__Pyx__ExceptionReset’:
netfilterqueue.c:7141:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7141 | tmp_type = tstate->exc_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7142:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7142 | tmp_value = tstate->exc_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7143:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7143 | tmp_tb = tstate->exc_traceback;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c:7144:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7144 | tstate->exc_type = type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7145:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7145 | tstate->exc_value = value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7146:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7146 | tstate->exc_traceback = tb;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c: In function ‘__Pyx__GetException’:
netfilterqueue.c:7201:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7201 | tmp_type = tstate->exc_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7202:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7202 | tmp_value = tstate->exc_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7203:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7203 | tmp_tb = tstate->exc_traceback;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c:7204:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7204 | tstate->exc_type = local_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7205:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7205 | tstate->exc_value = local_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7206:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7206 | tstate->exc_traceback = local_tb;
| ^~~~~~~~~~~~~
| curexc_traceback
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for netfilterqueue
Running setup.py clean for netfilterqueue
Failed to build netfilterqueue
Installing collected packages: netfilterqueue
Running setup.py install for netfilterqueue ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-s7oerfb1/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-c4a9b5uz/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'netfilterqueue' extension
creating build
creating build/temp.linux-x86_64-3.7
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -flto -fuse-linker-plugin -ffat-lto-objects -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c netfilterqueue.c -o build/temp.linux-x86_64-3.7/netfilterqueue.o
netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’:
netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types]
2150 | __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload));
| ~^~~~~~~~~~~~~~~~~~~~~~~
| |
| char **
In file included from netfilterqueue.c:440:
/usr/include/libnetfilter_queue/libnetfilter_queue.h:122:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’
122 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data);
| ~~~~~~~~~~~~~~~~^~~~
netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’:
netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration]
2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| PyBytes_FromStringAndSize
netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
2533 | __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
| ^
netfilterqueue.c: In function ‘__Pyx_PyCFunction_FastCall’:
netfilterqueue.c:6436:13: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))meth’
6436 | return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
netfilterqueue.c: In function ‘__Pyx__ExceptionSave’:
netfilterqueue.c:7132:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7132 | *type = tstate->exc_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7133:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7133 | *value = tstate->exc_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7134:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7134 | *tb = tstate->exc_traceback;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c: In function ‘__Pyx__ExceptionReset’:
netfilterqueue.c:7141:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7141 | tmp_type = tstate->exc_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7142:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7142 | tmp_value = tstate->exc_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7143:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7143 | tmp_tb = tstate->exc_traceback;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c:7144:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7144 | tstate->exc_type = type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7145:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7145 | tstate->exc_value = value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7146:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7146 | tstate->exc_traceback = tb;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c: In function ‘__Pyx__GetException’:
netfilterqueue.c:7201:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7201 | tmp_type = tstate->exc_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7202:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7202 | tmp_value = tstate->exc_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7203:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7203 | tmp_tb = tstate->exc_traceback;
| ^~~~~~~~~~~~~
| curexc_traceback
netfilterqueue.c:7204:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
7204 | tstate->exc_type = local_type;
| ^~~~~~~~
| curexc_type
netfilterqueue.c:7205:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
7205 | tstate->exc_value = local_value;
| ^~~~~~~~~
| curexc_value
netfilterqueue.c:7206:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
7206 | tstate->exc_traceback = local_tb;
| ^~~~~~~~~~~~~
| curexc_traceback
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-s7oerfb1/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-c4a9b5uz/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-s7oerfb1/netfilterqueue/
| 0debug
|
Apply click method to outer div but not inner div : <p>In this example I want the alert to be triggered when the black outer div is clicked but not when anything inside the inner div is clicked.</p>
<p>Currently when I click the inner button it triggers the alert.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$("#outer").click(function() {
alert("triggered");
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#outer{
position: absolute;
width: 100%;
height: 100%;
background-color: #000;
display: flex;
justify-content: center;
align-items: center;
}
#inner{
background-color: #fff;
width: 300px;
height: 300px;
text-align: center;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="outer">
<div id="inner">
<button>inner button</button>
</div>
</div></code></pre>
</div>
</div>
</p>
<p>I want inside the inner div nothing to trigger the alert. How do i do this?</p>
<p>(for some reason inner button isn't showing in snippet, here is codepen link: <a href="https://codepen.io/GuerrillaCoder/pen/Pmvmqx" rel="noreferrer">https://codepen.io/GuerrillaCoder/pen/Pmvmqx</a>)</p>
| 0debug
|
static int theora_decode_init(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
int ptype;
uint8_t *p= avctx->extradata;
int op_bytes, i;
s->theora = 1;
if (!avctx->extradata_size)
{
av_log(avctx, AV_LOG_ERROR, "Missing extradata!\n");
return -1;
}
for(i=0;i<3;i++) {
op_bytes = *(p++)<<8;
op_bytes += *(p++);
init_get_bits(&gb, p, op_bytes);
p += op_bytes;
ptype = get_bits(&gb, 8);
debug_vp3("Theora headerpacket type: %x\n", ptype);
if (!(ptype & 0x80))
{
av_log(avctx, AV_LOG_ERROR, "Invalid extradata!\n");
return -1;
}
skip_bits(&gb, 6*8);
switch(ptype)
{
case 0x80:
theora_decode_header(avctx, gb);
break;
case 0x81:
break;
case 0x82:
theora_decode_tables(avctx, gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80);
break;
}
}
vp3_decode_init(avctx);
return 0;
}
| 1threat
|
filtering R dataframe and show each variable once : <p>I have a huge dataframe that contains a column of gene's IDs. Each Gene ID appears in the column in a different number of times.
I want to extract from the dataframe a column that presents every Gene ID once, and at the same time I want to keep the data as a dataframe and not to change it to a list with factors.</p>
<p>example:
GeneID
589034
489034
589034
589034
48999
99449
99449</p>
<p>And i want my output to be:
GeneID
589034
489034
48999
99449</p>
| 0debug
|
static int mp_decode_frame(MPADecodeContext *s,
OUT_INT *samples, const uint8_t *buf, int buf_size)
{
int i, nb_frames, ch;
OUT_INT *samples_ptr;
init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8);
if (s->error_protection)
skip_bits(&s->gb, 16);
dprintf(s->avctx, "frame %d:\n", s->frame_count);
switch(s->layer) {
case 1:
s->avctx->frame_size = 384;
nb_frames = mp_decode_layer1(s);
break;
case 2:
s->avctx->frame_size = 1152;
nb_frames = mp_decode_layer2(s);
break;
case 3:
s->avctx->frame_size = s->lsf ? 576 : 1152;
default:
nb_frames = mp_decode_layer3(s);
s->last_buf_size=0;
if(s->in_gb.buffer){
align_get_bits(&s->gb);
i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
if(i >= 0 && i <= BACKSTEP_SIZE){
memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i);
s->last_buf_size=i;
}else
av_log(s->avctx, AV_LOG_ERROR, "invalid old backstep %d\n", i);
s->gb= s->in_gb;
s->in_gb.buffer= NULL;
}
align_get_bits(&s->gb);
assert((get_bits_count(&s->gb) & 7) == 0);
i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){
av_log(s->avctx, AV_LOG_WARNING, "invalid new backstep %d\n", i);
i= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE);
}
assert(i <= buf_size - HEADER_SIZE && i>= 0);
memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);
s->last_buf_size += i;
break;
}
for(ch=0;ch<s->nb_channels;ch++) {
samples_ptr = samples + ch;
for(i=0;i<nb_frames;i++) {
ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]),
window, &s->dither_state,
samples_ptr, s->nb_channels,
s->sb_samples[ch][i]);
samples_ptr += 32 * s->nb_channels;
}
}
return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
}
| 1threat
|
static void load_symbols(struct elfhdr *hdr, int fd, abi_ulong load_bias)
{
int i, shnum, nsyms, sym_idx = 0, str_idx = 0;
struct elf_shdr *shdr;
char *strings = NULL;
struct syminfo *s = NULL;
struct elf_sym *new_syms, *syms = NULL;
shnum = hdr->e_shnum;
i = shnum * sizeof(struct elf_shdr);
shdr = (struct elf_shdr *)alloca(i);
if (pread(fd, shdr, i, hdr->e_shoff) != i) {
return;
}
bswap_shdr(shdr, shnum);
for (i = 0; i < shnum; ++i) {
if (shdr[i].sh_type == SHT_SYMTAB) {
sym_idx = i;
str_idx = shdr[i].sh_link;
goto found;
}
}
return;
found:
s = g_try_new(struct syminfo, 1);
if (!s) {
goto give_up;
}
i = shdr[str_idx].sh_size;
s->disas_strtab = strings = g_try_malloc(i);
if (!strings || pread(fd, strings, i, shdr[str_idx].sh_offset) != i) {
goto give_up;
}
i = shdr[sym_idx].sh_size;
syms = g_try_malloc(i);
if (!syms || pread(fd, syms, i, shdr[sym_idx].sh_offset) != i) {
goto give_up;
}
nsyms = i / sizeof(struct elf_sym);
for (i = 0; i < nsyms; ) {
bswap_sym(syms + i);
if (syms[i].st_shndx == SHN_UNDEF
|| syms[i].st_shndx >= SHN_LORESERVE
|| ELF_ST_TYPE(syms[i].st_info) != STT_FUNC) {
if (i < --nsyms) {
syms[i] = syms[nsyms];
}
} else {
#if defined(TARGET_ARM) || defined (TARGET_MIPS)
syms[i].st_value &= ~(target_ulong)1;
#endif
syms[i].st_value += load_bias;
i++;
}
}
if (nsyms == 0) {
goto give_up;
}
new_syms = g_try_renew(struct elf_sym, syms, nsyms);
if (new_syms == NULL) {
goto give_up;
}
syms = new_syms;
qsort(syms, nsyms, sizeof(*syms), symcmp);
s->disas_num_syms = nsyms;
#if ELF_CLASS == ELFCLASS32
s->disas_symtab.elf32 = syms;
#else
s->disas_symtab.elf64 = syms;
#endif
s->lookup_symbol = lookup_symbolxx;
s->next = syminfos;
syminfos = s;
return;
give_up:
g_free(s);
g_free(strings);
g_free(syms);
}
| 1threat
|
static void vfio_exitfn(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
vfio_unregister_err_notifier(vdev);
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
vfio_disable_interrupts(vdev);
if (vdev->intx.mmap_timer) {
timer_free(vdev->intx.mmap_timer);
}
vfio_teardown_msi(vdev);
vfio_unmap_bars(vdev);
}
| 1threat
|
c++: Calling base class virtual function using base class pointer of derived class instance : <p>I have three classes: I have access to the only base class pointer, but this pointer is actually a derived class object. I want to use this base pointer to call the base class virtual function.</p>
<pre><code> class A
{
public:
virtual void print() = 0;
};
class B: public A
{
public:
virtual void print() override { cout <<"I am B\n"; }
};
class C: public B
{
public:
virtual void print() override { cout <<"I am C\n"; }
};
int main()
{
cout<<"Hello World\n";
A *a = new C();
a->print(); // prints "I am C"
//use pointer 'a' to print "I am B"
return 0;
}
</code></pre>
| 0debug
|
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
{
PerThreadContext *p;
atomic_int *progress = f->progress ? (atomic_int*)f->progress->data : NULL;
if (!progress ||
atomic_load_explicit(&progress[field], memory_order_acquire) >= n)
return;
p = f->owner->internal->thread_ctx;
if (f->owner->debug&FF_DEBUG_THREADS)
av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field);
pthread_mutex_lock(&p->progress_mutex);
atomic_store(&progress[field], n);
pthread_cond_broadcast(&p->progress_cond);
pthread_mutex_unlock(&p->progress_mutex);
}
| 1threat
|
START_TEST(qdict_get_not_exists_test)
{
fail_unless(qdict_get(tests_dict, "foo") == NULL);
}
| 1threat
|
Understanding darknet's yolo.cfg config files : <p>I have searched around the internet but found very little information around this, I don't understand what each variable/value represents in yolo's <code>.cfg</code> files. So I was hoping some of you could help, I don't think I'm the only one having this problem, so if anyone knows 2 or 3 variables please post them so that people who needs such info in the future might find them.</p>
<p>The main one that I'd like to know are : </p>
<ul>
<li>batch</li>
<li><p>subdivisions</p></li>
<li><p>decay</p></li>
<li><p>momentum</p></li>
<li><p>channels</p></li>
<li><p>filters</p></li>
<li><p>activation</p></li>
</ul>
| 0debug
|
Contains method in java doesn't exist? : I am trying to make a java script for a mobile app check if a string contains specific characters.
if(fn.contains(" ")){
}
Not sure why this doesn't work. In android studio, the 'contains' function highlights red as it doesn't exist. You can click [here][1] to see what I am talking about. Is there another method than this?
[1]: https://i.stack.imgur.com/6whGy.png
| 0debug
|
html table with json angularjs : "I have a different format of json below,I need to put it with html table and display it.I need to do this in angularjs.I tried with normal json format it was working fine but for this json its not working.This example is for indexing search.so I need to maintain json like that. Can you please help me on it.Thanks in advnace.
I have a different format of json below,I need to put it with html table and display it.I need to do this in angularjs.I tried with normal json format it was working fine but for this json its not working.This example is for indexing search.so I need to maintain json like that. Can you please help me on it.Thanks in advnace
For example :"
<div ng-app="myApp" ng-controller="customersCtrl">
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in names">
<td>{{x.Name}}</td>
<td>{{x.City}}</td>
<td>{{x.Country}}</td>
</tr>
</tbody>
</table>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope) {
$scope.names =[
{
"Name" : "Max Joe",
"City" : "Lulea",
"Country" : "Sweden"
},
{
"Name" : "Manish",
"City" : "Delhi",
"Country" : "India"
},
{
"Name" : "Koniglich",
"City" : "Barcelona",
"Country" : "Spain"
},
{
"Name" : "Wolski",
"City" : "Arhus",
"Country" : "Denmark"
}
];
});
</script>
</div>
"Now I need to do same thing with below json format."
{
"data": [
[
"1",
"supply chain Management",
"https://www.google.co.in/",
"abc",
1234567,
"abc@gmail.com",
"assdadsddsf",
"1"
],
[
"2",
"Data Tower",
"https://www.google.co.in/",
"abc",
1234567,
"abc@gmail.com",
"assdadsddsf",
"2"
],
[
"3",
"Enter business",
"https://www.google.co.in/",
"abc",
1234567,
"abc@gmail.com",
"assdadsddsf",
"3"
],
[
"4",
"IOT",
"https://www.google.co.in/",
"abc",
1234567,
"abc@gmail.com",
"assdadsddsf",
"4"
],
[
"5",
"Supplys Chain",
"https://www.google.co.in/",
"abc",
1234567,
"abc@gmail.com",
"assdadsddsf",
"5"
],
[
"6",
"Supplys Chain",
"https://www.google.co.in/",
"abc",
1234567,
"abc@gmail.com",
"assdadsddsf",
"6"
]
]
}
| 0debug
|
How to check Mysqli query empty or not? : I have trying this as like in MySQL but it is not working.Here is my code.Please help me.
$sql_st_check="SELECT station_name FROM station WHERE station_code=".$station_code."";
$sql_st_query=mysqli_query($connect,$sql_st_check);
if ($sql_st_query && mysqli_num_rows($sql_st_query) > 0){
}else{
$sql_st_insert = "INSERT INTO station (id, station_code, station_name, station_title, url, datetime)
VALUES ('', '".$station_code."', '".$station_name."', '".$station_title."', '".$station_url."', '".$time."')";
$sql_st_query=mysqli_query($connect,$sql_st_insert);
}
| 0debug
|
static int vdi_open(BlockDriverState *bs, int flags)
{
BDRVVdiState *s = bs->opaque;
VdiHeader header;
size_t bmap_size;
int ret;
logout("\n");
ret = bdrv_read(bs->file, 0, (uint8_t *)&header, 1);
if (ret < 0) {
goto fail;
}
vdi_header_to_cpu(&header);
#if defined(CONFIG_VDI_DEBUG)
vdi_header_print(&header);
#endif
if (header.disk_size % SECTOR_SIZE != 0) {
logout("odd disk size %" PRIu64 " B, round up\n", header.disk_size);
header.disk_size += SECTOR_SIZE - 1;
header.disk_size &= ~(SECTOR_SIZE - 1);
}
if (header.version != VDI_VERSION_1_1) {
logout("unsupported version %u.%u\n",
header.version >> 16, header.version & 0xffff);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) {
logout("unsupported block map offset 0x%x B\n", header.offset_bmap);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) {
logout("unsupported data offset 0x%x B\n", header.offset_data);
ret = -ENOTSUP;
goto fail;
} else if (header.sector_size != SECTOR_SIZE) {
logout("unsupported sector size %u B\n", header.sector_size);
ret = -ENOTSUP;
goto fail;
} else if (header.block_size != 1 * MiB) {
logout("unsupported block size %u B\n", header.block_size);
ret = -ENOTSUP;
goto fail;
} else if (header.disk_size >
(uint64_t)header.blocks_in_image * header.block_size) {
logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
logout("link uuid != 0, unsupported\n");
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
logout("parent uuid != 0, unsupported\n");
ret = -ENOTSUP;
goto fail;
}
bs->total_sectors = header.disk_size / SECTOR_SIZE;
s->block_size = header.block_size;
s->block_sectors = header.block_size / SECTOR_SIZE;
s->bmap_sector = header.offset_bmap / SECTOR_SIZE;
s->header = header;
bmap_size = header.blocks_in_image * sizeof(uint32_t);
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
if (bmap_size > 0) {
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
}
ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
if (ret < 0) {
goto fail_free_bmap;
}
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vdi", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail_free_bmap:
g_free(s->bmap);
fail:
return ret;
}
| 1threat
|
React Virtualized - onclick, expand Rows for additional details : <p>I have a requirement to open/close additional row details. </p>
<p>Has anyone implemented or have ideas on how to go about implementing expand/collapse feature for each row?</p>
| 0debug
|
block_crypto_open_opts_init(QCryptoBlockFormat format,
QemuOpts *opts,
Error **errp)
{
Visitor *v;
QCryptoBlockOpenOptions *ret = NULL;
Error *local_err = NULL;
ret = g_new0(QCryptoBlockOpenOptions, 1);
ret->format = format;
v = opts_visitor_new(opts);
visit_start_struct(v, NULL, NULL, 0, &local_err);
if (local_err) {
goto out;
}
switch (format) {
case Q_CRYPTO_BLOCK_FORMAT_LUKS:
visit_type_QCryptoBlockOptionsLUKS_members(
v, &ret->u.luks, &local_err);
break;
default:
error_setg(&local_err, "Unsupported block format %d", format);
break;
}
if (!local_err) {
visit_check_struct(v, &local_err);
}
visit_end_struct(v, NULL);
out:
if (local_err) {
error_propagate(errp, local_err);
qapi_free_QCryptoBlockOpenOptions(ret);
ret = NULL;
}
visit_free(v);
return ret;
}
| 1threat
|
What is the name of -embedded- objects in Document? : I have many Excel objects are embedded in a MS-Word Document.
How can reach them from MS-Word Document's module?
I need `Sum`ing the all total row's value for an specific field. (The embedded Excels are containing tables with total row)
| 0debug
|
How to combine ReactJs Router Link and material-ui components (like a button)? : <p>I need to find a solution to be able to combine together the functionality of react router with the material ui components.</p>
<p>For instance, I've this scenario: a router and a button. What I tried to do it is to mix them together, and restyle them.</p>
<p>So from a simple link</p>
<pre><code><Link className={this.getClass(this.props.type)} to={`${url}`} title={name}>{name}</Link>
</code></pre>
<p>I tried to create a material ui button as the following</p>
<pre><code><Link className={this.getClass(this.props.type)} to={`${url}`} title={name}>
<FlatButton label={name} />
</Link>
</code></pre>
<p>but I have the following error and Javascript breaks</p>
<blockquote>
<p>invariant.js?4599:38Uncaught Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's <code>render</code> method, or you have multiple copies of React loaded (details: <a href="https://gist.github.com/jimfb/4faa6cbfb1ef476bd105" rel="noreferrer">https://gist.github.com/jimfb/4faa6cbfb1ef476bd105</a>).</p>
</blockquote>
<p>Do you have any idea how to manage this situation?
Thank you in advance and if you need more information let me know</p>
| 0debug
|
I want custom keyboard in my desktop application : In my project point of sale i want a custom keyboard(Numeric and full keyboard). Please help me.
| 0debug
|
static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
const int data_size, AVCodecContext *avctx)
{
int hdr_size, width, height, flags;
int version;
const uint8_t *ptr;
hdr_size = AV_RB16(buf);
av_dlog(avctx, "header size %d\n", hdr_size);
if (hdr_size > data_size) {
av_log(avctx, AV_LOG_ERROR, "error, wrong header size\n");
return AVERROR_INVALIDDATA;
}
version = AV_RB16(buf + 2);
av_dlog(avctx, "%.4s version %d\n", buf+4, version);
if (version > 1) {
av_log(avctx, AV_LOG_ERROR, "unsupported version: %d\n", version);
return AVERROR_PATCHWELCOME;
}
width = AV_RB16(buf + 8);
height = AV_RB16(buf + 10);
if (width != avctx->width || height != avctx->height) {
av_log(avctx, AV_LOG_ERROR, "picture resolution change: %dx%d -> %dx%d\n",
avctx->width, avctx->height, width, height);
return AVERROR_PATCHWELCOME;
}
ctx->frame_type = (buf[12] >> 2) & 3;
ctx->alpha_info = buf[17] & 0xf;
if (ctx->alpha_info > 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid alpha mode %d\n", ctx->alpha_info);
return AVERROR_INVALIDDATA;
}
if (avctx->skip_alpha) ctx->alpha_info = 0;
av_dlog(avctx, "frame type %d\n", ctx->frame_type);
if (ctx->frame_type == 0) {
ctx->scan = ctx->progressive_scan;
} else {
ctx->scan = ctx->interlaced_scan;
ctx->frame->interlaced_frame = 1;
ctx->frame->top_field_first = ctx->frame_type == 1;
}
if (ctx->alpha_info) {
avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P10 : AV_PIX_FMT_YUVA422P10;
} else {
avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P10 : AV_PIX_FMT_YUV422P10;
}
ptr = buf + 20;
flags = buf[19];
av_dlog(avctx, "flags %x\n", flags);
if (flags & 2) {
if(buf + data_size - ptr < 64) {
av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
return AVERROR_INVALIDDATA;
}
permute(ctx->qmat_luma, ctx->prodsp.idct_permutation, ptr);
ptr += 64;
} else {
memset(ctx->qmat_luma, 4, 64);
}
if (flags & 1) {
if(buf + data_size - ptr < 64) {
av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
return AVERROR_INVALIDDATA;
}
permute(ctx->qmat_chroma, ctx->prodsp.idct_permutation, ptr);
} else {
memset(ctx->qmat_chroma, 4, 64);
}
return hdr_size;
}
| 1threat
|
static int add_shorts_metadata(int count, const char *name,
const char *sep, TiffContext *s)
{
char *ap;
int i;
int16_t *sp;
if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t))
return -1;
sp = av_malloc(count * sizeof(int16_t));
if (!sp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
sp[i] = tget_short(&s->gb, s->le);
ap = shorts2str(sp, count, sep);
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| 1threat
|
static bool ide_sect_range_ok(IDEState *s,
uint64_t sector, uint64_t nb_sectors)
{
uint64_t total_sectors;
bdrv_get_geometry(s->bs, &total_sectors);
if (sector > total_sectors || nb_sectors > total_sectors - sector) {
return false;
}
return true;
}
| 1threat
|
static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
int idx;
int node_id;
CPUState *cs;
CPUArchId *cpu_slot;
X86CPUTopoInfo topo;
X86CPU *cpu = X86_CPU(dev);
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
if (cpu->apic_id == UNASSIGNED_APIC_ID) {
int max_socket = (max_cpus - 1) / smp_threads / smp_cores;
if (cpu->socket_id < 0) {
error_setg(errp, "CPU socket-id is not set");
return;
} else if (cpu->socket_id > max_socket) {
error_setg(errp, "Invalid CPU socket-id: %u must be in range 0:%u",
cpu->socket_id, max_socket);
return;
}
if (cpu->core_id < 0) {
error_setg(errp, "CPU core-id is not set");
return;
} else if (cpu->core_id > (smp_cores - 1)) {
error_setg(errp, "Invalid CPU core-id: %u must be in range 0:%u",
cpu->core_id, smp_cores - 1);
return;
}
if (cpu->thread_id < 0) {
error_setg(errp, "CPU thread-id is not set");
return;
} else if (cpu->thread_id > (smp_threads - 1)) {
error_setg(errp, "Invalid CPU thread-id: %u must be in range 0:%u",
cpu->thread_id, smp_threads - 1);
return;
}
topo.pkg_id = cpu->socket_id;
topo.core_id = cpu->core_id;
topo.smt_id = cpu->thread_id;
cpu->apic_id = apicid_from_topo_ids(smp_cores, smp_threads, &topo);
}
cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx);
if (!cpu_slot) {
MachineState *ms = MACHINE(pcms);
x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &topo);
error_setg(errp, "Invalid CPU [socket: %u, core: %u, thread: %u] with"
" APIC ID %" PRIu32 ", valid index range 0:%d",
topo.pkg_id, topo.core_id, topo.smt_id, cpu->apic_id,
ms->possible_cpus->len - 1);
return;
}
if (cpu_slot->cpu) {
error_setg(errp, "CPU[%d] with APIC ID %" PRIu32 " exists",
idx, cpu->apic_id);
return;
}
x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &topo);
if (cpu->socket_id != -1 && cpu->socket_id != topo.pkg_id) {
error_setg(errp, "property socket-id: %u doesn't match set apic-id:"
" 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, topo.pkg_id);
return;
}
cpu->socket_id = topo.pkg_id;
if (cpu->core_id != -1 && cpu->core_id != topo.core_id) {
error_setg(errp, "property core-id: %u doesn't match set apic-id:"
" 0x%x (core-id: %u)", cpu->core_id, cpu->apic_id, topo.core_id);
return;
}
cpu->core_id = topo.core_id;
if (cpu->thread_id != -1 && cpu->thread_id != topo.smt_id) {
error_setg(errp, "property thread-id: %u doesn't match set apic-id:"
" 0x%x (thread-id: %u)", cpu->thread_id, cpu->apic_id, topo.smt_id);
return;
}
cpu->thread_id = topo.smt_id;
cs = CPU(cpu);
cs->cpu_index = idx;
node_id = cpu_slot->props.node_id;
if (!cpu_slot->props.has_node_id) {
node_id = 0;
}
if (cs->numa_node == CPU_UNSET_NUMA_NODE_ID) {
cs->numa_node = node_id;
} else if (cs->numa_node != node_id) {
error_setg(errp, "node-id %d must match numa node specified"
"with -numa option for cpu-index %d",
cs->numa_node, cs->cpu_index);
return;
}
}
| 1threat
|
milkymist_init(QEMUMachineInitArgs *args)
{
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
LM32CPU *cpu;
CPULM32State *env;
int kernel_size;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_sdram = g_new(MemoryRegion, 1);
qemu_irq irq[32], *cpu_irq;
int i;
char *bios_filename;
ResetInfo *reset_info;
hwaddr flash_base = 0x00000000;
size_t flash_sector_size = 128 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr sdram_base = 0x40000000;
size_t sdram_size = 128 * 1024 * 1024;
hwaddr initrd_base = sdram_base + 0x1002000;
hwaddr cmdline_base = sdram_base + 0x1000000;
size_t initrd_max = sdram_size - 0x1002000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
cpu = cpu_lm32_init(cpu_model);
env = &cpu->env;
reset_info->cpu = cpu;
cpu_lm32_set_phys_msb_ignore(env, 1);
memory_region_init_ram(phys_sdram, NULL, "milkymist.sdram", sdram_size);
vmstate_register_ram_global(phys_sdram);
memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(flash_base, NULL, "milkymist.flash", flash_size,
dinfo ? dinfo->bdrv : NULL, flash_sector_size,
flash_size / flash_sector_size, 2,
0x00, 0x89, 0x00, 0x1d, 1);
cpu_irq = qemu_allocate_irqs(cpu_irq_handler, cpu, 1);
env->pic_state = lm32_pic_init(*cpu_irq);
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(env->pic_state, i);
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (bios_filename) {
load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE);
reset_info->bootstrap_pc = BIOS_OFFSET;
if (!kernel_filename && !dinfo && !bios_filename && !qtest_enabled()) {
fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
bios_name);
milkymist_uart_create(0x60000000, irq[0]);
milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3],
80000000, 0x10014d31, 0x0000041f, 0x00000001);
milkymist_hpdmc_create(0x60002000);
milkymist_vgafb_create(0x60003000, 0x40000000, 0x0fffffff);
milkymist_memcard_create(0x60004000);
milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]);
milkymist_pfpu_create(0x60006000, irq[8]);
milkymist_tmu2_create(0x60007000, irq[9]);
milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]);
milkymist_softusb_create(0x6000f000, irq[15],
0x20000000, 0x1000, 0x20020000, 0x2000);
env->juart_state = lm32_juart_init();
if (kernel_filename) {
uint64_t entry;
kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, ELF_MACHINE, 0);
reset_info->bootstrap_pc = entry;
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, sdram_base,
sdram_size);
reset_info->bootstrap_pc = sdram_base;
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
if (kernel_cmdline && strlen(kernel_cmdline)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
kernel_cmdline);
reset_info->cmdline_base = (uint32_t)cmdline_base;
if (initrd_filename) {
size_t initrd_size;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
initrd_max);
reset_info->initrd_base = (uint32_t)initrd_base;
reset_info->initrd_size = (uint32_t)initrd_size;
qemu_register_reset(main_cpu_reset, reset_info);
| 1threat
|
Creating a UIView programatically : If I create a UIView with a frame like - `UIView(frame:..)` **AND** also set constraints on this view will the frame dimensions take precedence over the constraints? Will iOS runtime ignore the constraints?
I created a UIView in `viewDidLoad()` with a frame and attached constraints to this view. However the constraints are not being enforced at all and the view is rendered in the frame passed to the initializer.
| 0debug
|
static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev)
{
struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) };
struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
int ret, i;
ret = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name);
if (ret < 0) {
error_report("vfio: error getting device %s from group %d: %m\n",
name, group->groupid);
error_report("Verify all devices in group %d are bound to vfio-pci "
"or pci-stub and not already in use\n", group->groupid);
return ret;
}
vdev->fd = ret;
vdev->group = group;
QLIST_INSERT_HEAD(&group->device_list, vdev, next);
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_INFO, &dev_info);
if (ret) {
error_report("vfio: error getting device info: %m\n");
goto error;
}
DPRINTF("Device %s flags: %u, regions: %u, irgs: %u\n", name,
dev_info.flags, dev_info.num_regions, dev_info.num_irqs);
if (!(dev_info.flags & VFIO_DEVICE_FLAGS_PCI)) {
error_report("vfio: Um, this isn't a PCI device\n");
goto error;
}
vdev->reset_works = !!(dev_info.flags & VFIO_DEVICE_FLAGS_RESET);
if (!vdev->reset_works) {
error_report("Warning, device %s does not support reset\n", name);
}
if (dev_info.num_regions != VFIO_PCI_NUM_REGIONS) {
error_report("vfio: unexpected number of io regions %u\n",
dev_info.num_regions);
goto error;
}
if (dev_info.num_irqs != VFIO_PCI_NUM_IRQS) {
error_report("vfio: unexpected number of irqs %u\n", dev_info.num_irqs);
goto error;
}
for (i = VFIO_PCI_BAR0_REGION_INDEX; i < VFIO_PCI_ROM_REGION_INDEX; i++) {
reg_info.index = i;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting region %d info: %m\n", i);
goto error;
}
DPRINTF("Device %s region %d:\n", name, i);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->bars[i].flags = reg_info.flags;
vdev->bars[i].size = reg_info.size;
vdev->bars[i].fd_offset = reg_info.offset;
vdev->bars[i].fd = vdev->fd;
vdev->bars[i].nr = i;
}
reg_info.index = VFIO_PCI_ROM_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting ROM info: %m\n");
goto error;
}
DPRINTF("Device %s ROM:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->rom_size = reg_info.size;
vdev->rom_offset = reg_info.offset;
reg_info.index = VFIO_PCI_CONFIG_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting config info: %m\n");
goto error;
}
DPRINTF("Device %s config:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->config_size = reg_info.size;
vdev->config_offset = reg_info.offset;
error:
if (ret) {
QLIST_REMOVE(vdev, next);
vdev->group = NULL;
close(vdev->fd);
}
return ret;
}
| 1threat
|
Linux: how do i add few seconds to an old times temp bash? : for example :, i have tile as veritable like: tt="Thu 09/22/2016 11:03:55 AM" and i need to add few seconds to this time stamp in bash
current status :Thu 09/22/2016 11:03:55
requested status: Thu 09/22/2016 11:04:02 + var
in this case the var will be 7 seconds
thanks for your comments .
| 0debug
|
Unable to download language data of tesseract : <p>The site <a href="http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz" rel="nofollow">http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz</a> is not working and is not downloading the data. Is there any site where I can download the same data in the app. The error is "Cant download language data.Please enable network access and restart the app". My manifest file has permission for internet</p>
| 0debug
|
How do I create JTextFileds on a popup when I select JRadioButton in Java swings : I am new to Java swings...when I select a JRadioButton it should popup with JTextFiels.. where user enter details like name,age etc please let me know if anything is wrong
Can anyone help me out for the below sample code
import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class DialogTest extends JDialog implements ActionListener {
private static final String TITLE = "Season Test";
private enum Season {
WINTER("Winter"), SPRING("Spring");
private JRadioButton button;
private Season(String title) {
this.button = new JRadioButton(title);
}
}
private DialogTest(JFrame frame, String title) {
super(frame, title);
JPanel radioPanel = new JPanel();
radioPanel.setSize(800,800);
radioPanel.setLayout(new GridLayout(3, 1));
ButtonGroup group = new ButtonGroup();
for (Season s : Season.values()) {
group.add(s.button);
radioPanel.add(s.button);
s.button.addActionListener(this);
}
Season.SPRING.button.setSelected(true);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.add(radioPanel);
this.pack();
this.setLocationRelativeTo(frame);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
JRadioButton b = (JRadioButton) e.getSource();
JOptionPane.showMessageDialog(null, "You chose: " + b.getText());
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new DialogTest(null, TITLE);
}
});
}
}
| 0debug
|
void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
CPUState *cpu, TranslationBlock *tb)
{
int max_insns;
db->tb = tb;
db->pc_first = tb->pc;
db->pc_next = db->pc_first;
db->is_jmp = DISAS_NEXT;
db->num_insns = 0;
db->singlestep_enabled = cpu->singlestep_enabled;
max_insns = db->tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
}
if (db->singlestep_enabled || singlestep) {
max_insns = 1;
}
max_insns = ops->init_disas_context(db, cpu, max_insns);
tcg_debug_assert(db->is_jmp == DISAS_NEXT);
tcg_clear_temp_count();
gen_tb_start(db->tb);
ops->tb_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT);
while (true) {
db->num_insns++;
ops->insn_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT);
if (unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) {
CPUBreakpoint *bp;
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
if (bp->pc == db->pc_next) {
if (ops->breakpoint_check(db, cpu, bp)) {
break;
}
}
}
if (db->is_jmp > DISAS_TOO_MANY) {
break;
}
}
if (db->num_insns == max_insns && (db->tb->cflags & CF_LAST_IO)) {
gen_io_start();
ops->translate_insn(db, cpu);
gen_io_end();
} else {
ops->translate_insn(db, cpu);
}
if (db->is_jmp != DISAS_NEXT) {
break;
}
if (tcg_op_buf_full() || db->num_insns >= max_insns) {
db->is_jmp = DISAS_TOO_MANY;
break;
}
}
ops->tb_stop(db, cpu);
gen_tb_end(db->tb, db->num_insns);
db->tb->size = db->pc_next - db->pc_first;
db->tb->icount = db->num_insns;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(db->pc_first)) {
qemu_log_lock();
qemu_log("----------------\n");
ops->disas_log(db, cpu);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
| 1threat
|
Error with Array.map() in IE11 : <p>I have this code:</p>
<pre><code>var labelsPrint= new Array();
var vector = labelsPrint.map((el) => el.id);
</code></pre>
<p>IE11 give me a error, because lost the datas. Do you know an other way for make this .map?</p>
| 0debug
|
static int ppc_hash32_pte_update_flags(struct mmu_ctx_hash32 *ctx, target_ulong *pte1p,
int ret, int rw)
{
int store = 0;
if (!(*pte1p & HPTE32_R_R)) {
*pte1p |= HPTE32_R_R;
store = 1;
}
if (!(*pte1p & HPTE32_R_C)) {
if (rw == 1 && ret == 0) {
*pte1p |= HPTE32_R_C;
store = 1;
} else {
ctx->prot &= ~PAGE_WRITE;
}
}
return store;
}
| 1threat
|
What is the difference of all main functions? : <p>What is the difference between main, void main and int main in C? what does each one of them do?
Also what is return 0; used for? i know it somehow tells the OS that the program finished succesfully but what does that have to offer?
I would like to note that ive been working on C for a little more than a month so im not really experienced </p>
| 0debug
|
Split data from ethernet [C] : PLS I need split data from ethernet. Data is in this format:
ZMXXX,angle*CHCK
where angle is number. For example: `ZMXXX,900*5A`
And I need separated ZMXXX,900 and 5A.
I write this function.
void split_data(char analyze[])
{
char *words[5]; uint8_t i=0;
words[i] = strtok(analyze,"*");
while(words[i]!=NULL)
{
words[++i] = strtok(NULL,"*");
}
}
And result is here: [PICTURE][1]
And now, How I can get this data from variable:
words[0]
words[1]
[1]: http://s32.postimg.org/jz4kilf3p/variable.png
| 0debug
|
Telegram Bot How to delete or remove a message or media from a channel or group : <p>I want to know an example of removing message or file like a photo</p>
<p>I did not find any functional tutorial in this regard,</p>
| 0debug
|
Dynamically accessing Ruby JSON object variables : <pre><code>puts @file
# {
# "0.js": "js/0.js",
# "about-page.js": "js/about-page.js",
# "img/heart.png": "img/ae985f1437f67f39c4393e31c6785970.png",
# "index-page.js": "js/index-page.js",
# "init.js": "js/init.js",
# "main.js": "js/main.js"
# }
a = "0.js"
puts a // => "0.js"
puts @file[a] // => "0.js" ????!!!???
</code></pre>
<p>Why the above code wouldn't work? I am expecting the last line to output <code>"js/0.js"</code> instead of <code>"0.js"</code>.</p>
<p>Thanks</p>
| 0debug
|
Vuetify issue with v-menu : <p>Vuetify 1.1.8 / Vue 2.5.16</p>
<p>I don't understand why I get 2 different behaviors :</p>
<p>1- testing in Codepen.io</p>
<p><strong>html</strong></p>
<pre><code> <div id="app">
<v-app id="inspire">
<div class="text-xs-center">
<v-menu offset-y>
<v-btn
slot="activator"
color="primary"
dark
>
<span v-if="this.locale === 'en'">English</span>
<span v-if="this.locale === 'fr'">Français</span>
<span v-if="this.locale === 'br'">Português</span>
</v-btn>
<v-list>
<v-list-tile
v-for="(locale, index) in locales"
:key="index"
@click="switchLocale(index)"
>
<v-list-tile-title>{{ locale.title }}</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</div>
</v-app>
</div>
</code></pre>
<p>js</p>
<pre><code> new Vue({
el: '#app',
data: () => ({
locale: 'en',
locales: [
{ locale: 'en', title: 'English', icon: '@/assets/images/flag_gb_24.png' },
{ locale: 'fr', title: 'Français', icon: '@/assets/images/flag_fr_24.png' },
{ locale: 'br', title: 'Português', icon: '@/assets/images/flag_br_24.png' }
]
}),
methods: {
switchLocale: function (index) {
console.log('switch locale: ', this.locales[index].title)
this.locale = this.locales[index].locale
}
}
})
</code></pre>
<p>is running fine...</p>
<p>BUT once I insert it into a Vue.js component in my app, I get an error :</p>
<p><strong>console</strong></p>
<pre><code> vuetify.js?ce5b:19387 [Vuetify] Unable to locate target [data-app]
found in
---> <VMenu>
<VToolbar>
<Toolbar>
<App> at src/App.vue
<Root>
consoleWarn @ vuetify.js?ce5b:19387
initDetach @ vuetify.js?ce5b:16782
mounted @ vuetify.js?ce5b:16742
callHook @ vue.runtime.esm.js?2b0e:2917
insert @ vue.runtime.esm.js?2b0e:4154
invokeInsertHook @ vue.runtime.esm.js?2b0e:5956
patch @ vue.runtime.esm.js?2b0e:6175
Vue._update @ vue.runtime.esm.js?2b0e:2666
updateComponent @ vue.runtime.esm.js?2b0e:2784
get @ vue.runtime.esm.js?2b0e:3138
run @ vue.runtime.esm.js?2b0e:3215
flushSchedulerQueue @ vue.runtime.esm.js?2b0e:2977
(anonymous) @ vue.runtime.esm.js?2b0e:1833
flushCallbacks @ vue.runtime.esm.js?2b0e:1754
Promise.then (async)
microTimerFunc @ vue.runtime.esm.js?2b0e:1802
nextTick @ vue.runtime.esm.js?2b0e:1846
queueWatcher @ vue.runtime.esm.js?2b0e:3064
update @ vue.runtime.esm.js?2b0e:3205
Vue.$forceUpdate @ vue.runtime.esm.js?2b0e:2687
(anonymous) @ index.js?6435:233
(anonymous) @ index.js?6435:231
(anonymous) @ index.js?6435:116
(anonymous) @ Toolbar.vue?be73:29
./src/components/Shared/Toolbar.vue @ app.js:2759
__webpack_require__ @ app.js:768
hotApply @ app.js:687
(anonymous) @ app.js:344
Promise.then (async)
hotUpdateDownloaded @ app.js:343
hotAddUpdateChunk @ app.js:319
webpackHotUpdateCallback @ app.js:37
(anonymous) @ app.a888e56db407050b2768.hot-update.js:1
Toolbar.vue?9799:67 TOOLBAR mounted locale: en
</code></pre>
<p><strong>Toolbar.vue</strong></p>
<pre><code> <template>
<v-toolbar height="80px" fixed>
<v-toolbar-title>
<img src="@/assets/images/app_logo.png" alt="">
<v-menu offset-y>
<v-btn
slot="activator"
color="primary"
dark
>
<span v-if="this.locale === 'en'">English</span>
<span v-if="this.locale === 'fr'">Français</span>
<span v-if="this.locale === 'br'">Português</span>
</v-btn>
<v-list>
<v-list-tile
v-for="(locale, index) in locales"
:key="index"
@click="switchLocale(index)"
>
<v-list-tile-title>{{ locale.title }}</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
....
</v-toolbar-items>
</v-toolbar>
</template>
<script>
export default {
name: 'Toolbar',
props: ['appName'],
data () {
return {
menuItems: {
home: { icon: 'home', title: 'Home', link: '/' },
about: { icon: 'info', title: 'About', link: '/about' }
},
locale: 'en',
locales: [
{ locale: 'en', title: 'English', icon: '@/assets/images/flag_gb_24.png' },
{ locale: 'fr', title: 'Français', icon: '@/assets/images/flag_fr_24.png' },
{ locale: 'br', title: 'Português', icon: '@/assets/images/flag_br_24.png' }
]
}
},
methods: {
switchLocale: function (index) {
console.log('switch locale: ', this.locales[index].title)
this.locale = this.locales[index].locale
}
},
mounted () {
console.log('TOOLBAR mounted locale: ', this.locale)
}
}
</script>
</code></pre>
| 0debug
|
Keras deep learning model to android : <p>I'm developing a real-time object classification app for android. First I created a deep learning model using "keras" and I already have trained model saved as "model.h5" file. I would like to know how can I use that model in android for image classification. </p>
| 0debug
|
Implement Hashmap with different value types in Kotlin : <p>Is it possible to have a hashmap in Kotlin that takes different value types?</p>
<p>I've tried this:</p>
<pre><code>val template = "Hello {{world}} - {{count}} - {{tf}}"
val context = HashMap<String, Object>()
context.put("world", "John")
context.put("count", 1)
context.put("tf", true)
</code></pre>
<p>... but that gives me a type mismatch (apparantly <code>"John"</code>, <code>1</code> and <code>true</code> are not Objects) </p>
<p>In Java you can get around this by creating types <code>new String("John")</code>, <code>new Integer(1)</code>, <code>Boolean.TRUE</code>, I've tried the equivalent in Kotlin, but still getting the type mismatch error.</p>
<pre><code>context.put("tf", Boolean(true))
</code></pre>
<p>Any ideas?</p>
| 0debug
|
Should I master maven or start learning gradle : <p>The project I'm working on uses Maven as a build tool. I know the basic concepts like profiles, pom inheritance, modules, plugins, goals, phases and so on the surface, but I'm still missing the true craftsmanship to implement complicated builds from a starch for different environments.</p>
<p>Now, should I become Maven expert or start learning Gradle instead of unveiling all technical nuances of Maven? </p>
<p>I don't see what value Gradle brings on the table. It is configured programmatically, but could this actually be evil? I have worked in Javascript world and used tools like Gulp and Webpack. The programmatic configuration in those tools was just a horrible mess and lacked consistency. It wasn't possible to form a clear mental picture of the configuration, as it was dynamic code, not a static document. When you had to make a change, it wasn't so obvious where to find that line of code handling that functionality. Well defined XML document is self describing, organized and easily grepable.</p>
<p>Also, by programmatic configuration, there is a higher change to introduce bug in the build itself. Will there be a time, when builds become so complex that it's necessary to build the build configuration of the project?</p>
<p>Considering these aspects, is there some pragmatic reason start using Gradle (other than following the trend)? </p>
| 0debug
|
Adding variables to dictionary : <p>I have a empty dictionary</p>
<pre><code>d = {}
</code></pre>
<p>I have these variables:</p>
<pre><code>key = "foo"
value = 1
</code></pre>
<p>I want to add them to dictionary as <code>key</code> and <code>value</code> variables because they can be change in a for loop. What should be the proper syntax?</p>
| 0debug
|
Using Git in Windows Subsystem for Linux through IntelliJ : <p>I'm trying to set Git executable in IntelliJ to be the git installed in Windows Subsystem for Linux, I tried a few different ways, but always got some sort of error. Today I installed to Creators Update (Version 1703), reinstalled WSL and tried again, here's what I did:</p>
<p>I created a .bat script:</p>
<pre><code>@echo off
C:\Windows\System32\bash.exe -c "git %*"
</code></pre>
<p>So when running it:</p>
<pre><code>C:\Users\Limon\Desktop>bash.bat --version
git version 2.7.4
</code></pre>
<p>So then I tried to set this bat at the git executable in IntelliJ:
<a href="https://i.stack.imgur.com/TIvMG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TIvMG.png" alt="Setting Git executable in IntelliJ"></a></p>
<p>And it worked! But everything else fails, for example when I try to pull or branch in IntelliJ, I get:</p>
<pre><code>Couldn't check the working tree for unmerged files because of an error.
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command,
operable program or batch file.
</code></pre>
<p>Any ideas on how fix this? I don't really know anything about batch scripting. It works perfectly off command line.</p>
| 0debug
|
How to add a gesture detector to a view in Android : <p>I was struggling with adding a gesture detector to a subview in my project. Do I override the parent's <code>onTouchEvent</code> or the child's <code>onTouchEvent</code>? Do I make an <code>OnTouchListener</code> and add the gesture detector there? The <a href="https://developer.android.com/training/gestures/detector.html" rel="noreferrer">documentation</a> shows an example for how to add a gesture detector to the activity itself but it is not clear how to add it to a view. The same process could be used if subclassing a view (example <a href="https://stackoverflow.com/a/20112261/3681880">here</a>), but I want to add the gesture without subclassing anything.</p>
<p><a href="https://stackoverflow.com/questions/4098198/adding-fling-gesture-to-an-image-view-android">This</a> is the closest other question I could find but it is specific to a fling gesture on an <code>ImageView</code>, not to the general case of any <code>View</code>. Also there is some disagreement in those answers about when to return <code>true</code> or <code>false</code>. </p>
<p>To help myself understand how it works, I made a stand alone project. My answer is below.</p>
| 0debug
|
Strange Error in C++ Program : <p>So I have written a simple calculator for study purpose. But I can't get it working because I get a strange error. I tried everything I could but I couldn't fix the error. Please have a look at it and tell me.</p>
<pre><code>#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
double add (double x, double y)
{
double addition = x+y;
return addition;
}
double sub (double x ,double y)
{
double subtraction = x-y;
return subtraction;
}
double mul (double x , double y)
{
double multiplication = x*y;
return multiplication;
}
double div (double x, double y)
{
double division = x/y;
return division;
}
int main ()
{
int x; int y; int op;
cout << "Enter a number: ";
cin >> x;
cout << "Enter second number: ";
cin >> y;
cout << "1: Addition, 2: Subtraction, 3: Multiplication, 4: Division" << endl;
cout << "What operation you want: ";
cin >> op;
switch (op)
{
case 1:
cout << x << " + " << y << " = " << add(x, y);`enter code here`
break;
case 2:
cout << x << " - " << y << " = " << sub(x,y);
break;
case 3:
cout << x << " * " << y << " = " << mul (x,y);
break;
case 4:
cout << x << " / " << y << " = " << div (x,y);
break;
default:
cout << "Invalid operation"
}
}
</code></pre>
| 0debug
|
Python scrapping(Image) : I managed to get everything I wanted except the image i would like to download this image into the current directory this is the html of image
<div class="pull-left custom-photo">
<a href="javascript:newWindow('https://www.metart.com/cover/6EB90E2A3A54EB14810A178E4A5FF927/');"><img src="https://static.metart.com/media/6EB90E2A3A54EB14810A178E4A5FF927/t_cover_6EB90E2A3A54EB14810A178E4A5FF927.jpg" alt="" class="img-responsive"/></a>
</div>
I need to get image that is in <a href="javascript:newWindow('HERE');"><img src="https://static.metart.com/media/6EB90E2A3A54EB14810A178E4A5FF927/t_cover_6EB90E2A3A54EB14810A178E4A5FF927.jpg" alt="" class="img-responsive"/></a>
</div>
Any suggestions? Thanks
| 0debug
|
Explanation on "Integer.Max_Value" and Integer.Min_Value : <p>I am going to write a program that takes in five integer values as the test grades for some class.Then I will determine what the minimum grade is and what the maximum grade will be. Following that I am going to calculate the average. My professor specified that she wants the minimum grade stored in <code>Integer.Max_Value</code> and the maximum grade in <code>Integer.Min_Value</code>. I'm having a rough time comprehending this. Can someone please explain to me what the meaning of those statements are? </p>
| 0debug
|
static int encode_plane(AVCodecContext *avctx, uint8_t *src,
uint8_t *dst, int stride,
int width, int height, PutByteContext *pb)
{
UtvideoContext *c = avctx->priv_data;
uint8_t lengths[256];
uint64_t counts[256] = { 0 };
HuffEntry he[256];
uint32_t offset = 0, slice_len = 0;
int i, sstart, send = 0;
int symbol;
switch (c->frame_pred) {
case PRED_NONE:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
write_plane(src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
case PRED_LEFT:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
left_predict(src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
case PRED_MEDIAN:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
median_predict(c, src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown prediction mode: %d\n",
c->frame_pred);
return AVERROR_OPTION_NOT_FOUND;
}
count_usage(dst, width, height, counts);
for (symbol = 0; symbol < 256; symbol++) {
if (counts[symbol]) {
if (counts[symbol] == width * height) {
for (i = 0; i < 256; i++) {
if (i == symbol)
bytestream2_put_byte(pb, 0);
else
bytestream2_put_byte(pb, 0xFF);
}
for (i = 0; i < c->slices; i++)
bytestream2_put_le32(pb, 0);
return 0;
}
break;
}
}
ff_huff_gen_len_table(lengths, counts);
for (i = 0; i < 256; i++) {
bytestream2_put_byte(pb, lengths[i]);
he[i].len = lengths[i];
he[i].sym = i;
}
calculate_codes(he);
send = 0;
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
offset += write_huff_codes(dst + sstart * width, c->slice_bits,
width * (send - sstart), width,
send - sstart, he) >> 3;
slice_len = offset - slice_len;
c->dsp.bswap_buf((uint32_t *) c->slice_bits,
(uint32_t *) c->slice_bits,
slice_len >> 2);
bytestream2_put_le32(pb, offset);
bytestream2_seek_p(pb, 4 * (c->slices - i - 1) +
offset - slice_len, SEEK_CUR);
bytestream2_put_buffer(pb, c->slice_bits, slice_len);
bytestream2_seek_p(pb, -4 * (c->slices - i - 1) - offset,
SEEK_CUR);
slice_len = offset;
}
bytestream2_seek_p(pb, offset, SEEK_CUR);
return 0;
}
| 1threat
|
UnrecoverableKeyException Failed to obtain information about private key, KeyStoreException: Invalid key blob : <p>In our app we've been having issues with data in the Android Keystore suddenly becoming inaccessible. The specific exception we're seeing is here:</p>
<pre><code>java.security.UnrecoverableKeyException: Failed to obtain information about private key
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStorePublicKeyFromKeystore(AndroidKeyStoreProvider.java:223)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreKeyPairFromKeystore(AndroidKeyStoreProvider.java:259)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStorePrivateKeyFromKeystore(AndroidKeyStoreProvider.java:269)
at android.security.keystore.AndroidKeyStoreSpi.engineGetKey(AndroidKeyStoreSpi.java:94)
at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:474)
at java.security.KeyStore.getEntry(KeyStore.java:1560)
at <PACKAGE_NAME>.EncryptionInteractor.generateKeys(EncryptionInteractor.java:104)
at <PACKAGE_NAME>.EncryptionInteractor.generateKeys(EncryptionInteractor.java:100)
at <PACKAGE_NAME>.EncryptionInteractor.init(EncryptionInteractor.java:93)
at <PACKAGE_NAME>.EncryptionInteractor.<init>(EncryptionInteractor.java:80)
at <PACKAGE_NAME>.EncryptionInteractor.init(EncryptionInteractor.java:65)
at <PACKAGE_NAME>.<APPLICATION_CLASS>.onCreate(APPLICATION_CLASS.java:17)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5791)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.security.KeyStoreException: Invalid key blob
at android.security.KeyStore.getKeyStoreException(KeyStore.java:695)
at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStorePublicKeyFromKeystore(AndroidKeyStoreProvider.java:224)
... 21 more
</code></pre>
<p>We have not been able to come up with a reliable way of reproducing the issue. Several articles mention possible states that can cause the Keystore to "forget" a Key or become locked such as <a href="https://doridori.github.io/android-security-the-forgetful-keystore/#sthash.SPGO7JXV.wE9npzuE.dpbs" rel="noreferrer">here</a>. However, as far as I can tell we have not fallen into any of these edge cases. It seems to happen after letting the device sit for a while after the first setup of the key. We have seen this happen across multiple emulators and devices, ranging from 21 to 26. Additionally these devices have used either swipe to unlock or a PIN. Changing the PIN or security method does not seem to cause the issue. Again, this issue seems to occur after the device has been sitting unused for several days. </p>
<p>I have found two other SOs <a href="https://stackoverflow.com/questions/36652675/java-security-unrecoverablekeyexception-failed-to-obtain-information-about-priv">here</a> and <a href="https://stackoverflow.com/questions/36488219/android-security-keystoreexception-invalid-key-blob">here</a> as well as one Google <a href="https://issuetracker.google.com/u/1/issues/63786177" rel="noreferrer">issue</a>. If I'm understanding correctly, the answer linked in both seems to rely upon the premise that the caller has called <code>setUserAuthenticationValidityDurationSeconds</code> when creating the Key, and we have not done so. Additionally the given solution seems to rely upon just deleting the key and generating a new one. </p>
<p>Below is our setup for the key on for versions >= API 23. I've left out our key generation for versions older than 23, since we've primarily seen this on APIs >= 23. </p>
<pre><code>private static final int RSA_KEY_SIZE = 2048;
private static final String CERT_SUBJECT_STRING = "CN=<COMPANY_NAME> Android App O=<COMPANY_NAME>";
private static final String ANDROID_KEY_STORE = "AndroidKeyStore";
try {
String alias = KEY_NAME;
KeyPairGenerator generator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, ANDROID_KEY_STORE);
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
end.add(Calendar.YEAR, 1);
KeyGenParameterSpec spec = new KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
.setAlgorithmParameterSpec(new RSAKeyGenParameterSpec(RSA_KEY_SIZE, RSAKeyGenParameterSpec.F4))
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)
.setBlockModes(KeyProperties.BLOCK_MODE_ECB)
.setCertificateNotAfter(end.getTime())
.setCertificateNotBefore(start.getTime())
.setCertificateSerialNumber(BigInteger.ONE)
.setCertificateSubject(new X500Principal(CERT_SUBJECT_STRING))
.build();
generator.initialize(spec);
generator.generateKeyPair();
} catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidAlgorithmParameterException e) {
e.printStackTrace();
}
</code></pre>
<p>We then attempt to access the keys later via <code>keyStore.getEntry(KEY_NAME, null)</code>. Again, this works for a while, but then will begin to throw the above exception.</p>
| 0debug
|
int omap_validate_imif_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return addr >= OMAP_IMIF_BASE && addr < OMAP_IMIF_BASE + s->sram_size;
}
| 1threat
|
Flutter how to execute when clicking back button : <p>I have a page that is called from bottom tab nav which executes a initState function, I then navigate to a page via button click that has details and actions to take, however when I click the back button to goto originating page, the initState does not run again, I have found out that because Flutter does not destroy the page when you put one on top, since the NAV is not on new page as its not in the menu, how do I make initState run again on clicking back button or is there another way to listen for that navigate from back button and run the code that needs to update data?</p>
<p>Any help would be great.</p>
| 0debug
|
How do I overlay ActivityIndicator in react-native? : <p>I have a View with few form elements and a button (TouchableHighlight). On clicking the button, an Activity Indicator should be shown as an overlay to the existing view. The Activity Indicator should be centered within the page and the existing view should be slightly blurred to indicate overlay. I tried different options but could not get it to work.</p>
<pre><code>render() {
const { username, password } = this.state;
return (
<View style={styles.container}>
<View style={styles.group}>
<Text style={styles.text}>Username:</Text>
<TextInput
style={styles.input}
onChangeText={this.handleUserNameChange.bind(this)}
value={username}
underlineColorAndroid="transparent"
/>
</View>
<View style={styles.group}>
<Text style={styles.text}>Password:</Text>
<TextInput
style={styles.input}
secureTextEntry={true}
onChangeText={this.handlePasswordChange.bind(this)}
value={password}
underlineColorAndroid="transparent"
/>
</View>
<TouchableHighlight
style={styles.button}
onPress={this.handleLogin.bind(this)}>
<Text style={styles.buttonText}>Logon</Text>
</TouchableHighlight>
</View>
);
}
</code></pre>
<p>Existing styles:</p>
<pre><code>const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'flex-start',
alignItems: 'center',
backgroundColor: '#F5FCFF',
marginTop: 60
},
group: {
alignItems: 'flex-start',
padding: 10
},
input: {
width: 150,
padding: 2,
paddingLeft: 5,
borderColor: 'gray',
borderWidth: 1
},
text: {
padding: 0
},
button: {
width: 150,
backgroundColor: '#2299F2',
padding: 15,
marginTop: 20,
borderRadius: 5
},
buttonText: {
textAlign: 'center',
color: '#fff',
fontSize: 24
},
});
</code></pre>
<p>I need to an ActivityIndicator to the above View, overlay the view, and center the ActivityIndicator.</p>
| 0debug
|
CSS position:absolute but html order still matters : <p>I have a web page with an equivalent of the following html, and the corresponding CSS:</p>
<pre><code><div class="father">
<div class="divson"></div>
<a class="ason"></a>
</div>
.father {position:relative}
.father div {position:absolute}
.father a {position:relative}
</code></pre>
<p>Because 'divson' has position:absolute, I'd expect it to be always placed relatively to 'father' (because this one is positioned as well). Although, 'divson' still moves elsewhere when I reorder the html as follows:</p>
<pre><code><div class="father">
<a class="ason"></a>
<div class="divson"></div>
</div>
</code></pre>
<p>How is it possible that a div with position:absolute still depends on the html order? What could be a cause that I wouldn't have thought of?</p>
<p>Thanks</p>
| 0debug
|
Subtracting datetimes in pandas always equals 0 : <p>two columns of dates in my dataframe. The first column is df['schedule_day'] and the second is df['appointment_day']. I am trying to create another column that will be the different between these two. However, when I do the subtraction, the new column just has 0 for each answer. </p>
<p>The original data has these dates as strings and I convert them to datetime objects before doing the subtraction and the result is still a datetime object.
Here is the code I have used so far. </p>
<pre><code>df = pd.read_csv('noshowappointments-kagglev2-may-2016.csv')
df['schedule_day'] = pd.to_datetime(df['schedule_day'])
df['appointment_day'] = pd.to_datetime(df['schedule_day'])
df['difference'] = df['schedule_date'] - df['appointment_date']
</code></pre>
<p>When I inspect the dtypes the after the initial read they are object / string types. After I do the conversion they are datetime64[ns].</p>
<p>I also tried to split the date and time apart into seperate columns to do the subtractions but I still just get 0 days for each row. </p>
| 0debug
|
Getting bug while decoding the morse : I,m trying to decode a given morse into English. However, I'm getting a bug in the code I've written. Here is my code :
1. String code=".... . -.-- .--- ..- -.. ."; //Decodes to "HEY JUDE"
2. String[] letters = code.split(" ");
3. StringBuilder res = new StringBuilder();
4. for(String str : letters){
5. if(!str.equals(""))
6. res.append(MorseCode.get(str));//get is a method which takes a String input (morse code) and returns appropriate letter as a String
7. else res.append(" "); //If I write like this the output will be : "HEY JUDE"
8. }
9. System.out.println(res);
At line 7 if I write
res.append("");
Output will be : "HEYJUDE"<br>Please correct me If I miss something.
| 0debug
|
Add items to one array after each item on another array : <p>Basically I need to add each item from one array after each on from another array. So if these are the two arrays:</p>
<pre><code>array1 = [
"item1",
"item2",
"item3",
"item4"
];
array2 = [
"choice1",
"choice2",
"choice3",
"choice4"
];
</code></pre>
<p>I need to make array1 become this:</p>
<pre><code>"item1",
"choice1",
"item2",
"choice2",
"item3",
"choice3",
"item4",
"choice4"
];
</code></pre>
<p>Does anyone have any idea how to do this? Thanks</p>
| 0debug
|
add coma to numbers : I have an input field, by Javascript, I'm allowing the user to enter only number in that input by ( I'm using React):
validateValue(e) {
return (
e.target.value = e.target.value.replace(/[^0-9,.]/, '')
);
}
working great.
however I would like to add a coma every numbers entered in that function.
How is this possible to be achieve ?
Many thanks !
| 0debug
|
static void xan_wc3_decode_frame(XanContext *s) {
int width = s->avctx->width;
int height = s->avctx->height;
int total_pixels = width * height;
unsigned char opcode;
unsigned char flag = 0;
int size = 0;
int motion_x, motion_y;
int x, y;
unsigned char *opcode_buffer = s->buffer1;
int opcode_buffer_size = s->buffer1_size;
const unsigned char *imagedata_buffer = s->buffer2;
const unsigned char *huffman_segment;
const unsigned char *size_segment;
const unsigned char *vector_segment;
const unsigned char *imagedata_segment;
huffman_segment = s->buf + AV_RL16(&s->buf[0]);
size_segment = s->buf + AV_RL16(&s->buf[2]);
vector_segment = s->buf + AV_RL16(&s->buf[4]);
imagedata_segment = s->buf + AV_RL16(&s->buf[6]);
xan_huffman_decode(opcode_buffer, opcode_buffer_size,
huffman_segment, s->size - (huffman_segment - s->buf) );
if (imagedata_segment[0] == 2)
xan_unpack(s->buffer2, &imagedata_segment[1], s->buffer2_size);
else
imagedata_buffer = &imagedata_segment[1];
x = y = 0;
while (total_pixels) {
opcode = *opcode_buffer++;
size = 0;
switch (opcode) {
case 0:
flag ^= 1;
continue;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
size = opcode;
break;
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
size += (opcode - 10);
break;
case 9:
case 19:
size = *size_segment++;
break;
case 10:
case 20:
size = AV_RB16(&size_segment[0]);
size_segment += 2;
break;
case 11:
case 21:
size = AV_RB24(size_segment);
size_segment += 3;
break;
}
if (opcode < 12) {
flag ^= 1;
if (flag) {
xan_wc3_copy_pixel_run(s, x, y, size, 0, 0);
} else {
xan_wc3_output_pixel_run(s, imagedata_buffer, x, y, size);
imagedata_buffer += size;
}
} else {
motion_x = sign_extend(*vector_segment >> 4, 4);
motion_y = sign_extend(*vector_segment & 0xF, 4);
vector_segment++;
xan_wc3_copy_pixel_run(s, x, y, size, motion_x, motion_y);
flag = 0;
}
total_pixels -= size;
y += (x + size) / width;
x = (x + size) % width;
}
}
| 1threat
|
static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
int keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
int duration = pkt->duration;
int ret;
int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
if (ts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_ERROR, "Can't write packet with unknown timestamp\n");
return AVERROR(EINVAL);
}
if (!s->pb->seekable) {
if (!mkv->dyn_bc)
avio_open_dyn_buf(&mkv->dyn_bc);
pb = mkv->dyn_bc;
}
if (mkv->cluster_pos == -1) {
mkv->cluster_pos = avio_tell(s->pb);
mkv->cluster = start_ebml_master(pb, MATROSKA_ID_CLUSTER, 0);
put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, FFMAX(0, ts));
mkv->cluster_pts = FFMAX(0, ts);
}
if (codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe << 7);
} else if (codec->codec_id == AV_CODEC_ID_SSA) {
duration = mkv_write_ass_blocks(s, pb, pkt);
} else if (codec->codec_id == AV_CODEC_ID_SRT) {
duration = mkv_write_srt_blocks(s, pb, pkt);
} else {
ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt->size));
if (pkt->convergence_duration > 0) {
duration = pkt->convergence_duration;
}
mkv_write_block(s, pb, MATROSKA_ID_BLOCK, pkt, 0);
put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, duration);
end_ebml_master(pb, blockgroup);
}
if (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe) {
ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, ts, mkv->cluster_pos);
if (ret < 0) return ret;
}
mkv->duration = FFMAX(mkv->duration, ts + duration);
return 0;
}
| 1threat
|
Tensorflow: why 'pip uninstall tensorflow' cannot find tensorflow : <p>I'm using Tensorflow-0.8 on Ubuntu14.04. I first install Tensorflow from sources and then setup Tensorflow for development according to the <a href="https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#setting-up-tensorflow-for-development" rel="noreferrer">official tutorial</a>. When I want to uninstall tensorflow using the following command</p>
<pre><code>sudo pip uninstall tensorflow
</code></pre>
<p>I encountered the following error:</p>
<pre><code>Can't uninstall 'tensorflow'. No files were found to uninstall
</code></pre>
<p>Could anyone tell me where is wrong?</p>
<p>For your reference, the output of
<code>pip show tensorflow</code> is</p>
<pre><code>Name: tensorflow
Version: 0.8.0
Location: /home/AIJ/tensorflow/_python_build
Requires: numpy, six, protobuf, wheel
</code></pre>
<p>But I actually find another Tensorflow directory at </p>
<pre><code>/usr/local/lib/python2.7/dist-packages/tensorflow
</code></pre>
<p>Besides, I also have a question about the general usage of Python. I have seen two quite similar directories in my system, i.e.</p>
<pre><code>/usr/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages
</code></pre>
<p>Could any one tell me the differences between them? I noticed that everytime I use <code>sudo pip install <package></code>, the package will be installed to <code>/usr/local/lib/python2.7/dist-packages</code>, could I instead install packages into <code>/usr/lib/python2.7/dist-packages</code> using <code>pip install</code>?</p>
<p>Thanks a lot for your help in advance!</p>
| 0debug
|
Best way of passing callback function parameters in C++ : <p>What is the best way of passing a <strong>callback function</strong> parameter in C++?</p>
<p>I thought of simply using templates, like this:</p>
<pre><code>template <typename Function>
void DoSomething(Function callback)
</code></pre>
<p>This is the way used e.g. in <a href="http://en.cppreference.com/w/cpp/algorithm/sort" rel="noreferrer"><code>std::sort</code></a> for the comparison function object.</p>
<p>What about passing using <strong><code>&&</code></strong>? E.g.:</p>
<pre><code>template <typename Function>
void DoSomething(Function&& callback)
</code></pre>
<p>What are the pros and cons of those two methods, and why does the STL uses the former e.g. in <code>std::sort</code>?</p>
| 0debug
|
BottomNavigationView - Shadow and Ripple Effect : <p>I was really happy when <a href="https://developer.android.com/reference/android/support/design/widget/BottomNavigationView.html" rel="noreferrer">BottomNavigationView</a> was released one week ago but I am facing some problems which makes me unable to solve it, like to see a shadow over the BottomNavigationView, on the same way as Google Photos Android App shows us:</p>
<p><a href="https://i.stack.imgur.com/cQgvG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cQgvG.png" alt="The shadow over Bottom Navigation Bar"></a></p>
<p>If we tap on an Google Photos menu item, we can see a ripple effect which is tinted blue like the icon and text color (when selected). </p>
<p>Implementing the solution provided by Google only is displayed a gray ripple effect color, and worse, it is not displayed when we change the background color of the bottomnavigationview (<code>design:itemBackground="..."</code>).</p>
<p>Someone knows how to solve it?</p>
| 0debug
|
why I can't get s in this code ,who know matlab,help me? : I want to use t to calculate s,but i got error
the code can't find S
[this is the logs][1]
it's in chinese,the mean is can't find S,S is undefined.
a=1;
b=2;
t=input('输入');
if (-100<t<0)
T=t+100
c1=20
s=T*t
end
fprintf('输出%f\n',s)
THANKS!!
[1]: https://i.stack.imgur.com/74VgM.png
| 0debug
|
build script in package.json using webpack with --config flag as : <p>In my package.json I'm trying to use <code>webpack</code> in a script but it keeps failing.</p>
<pre><code> "scripts": {
"start": "node server.js",
"test": "mocha 'src/**/test*.coffee' --watch --compilers coffee:coffee-script/register",
"build": "webpack --config webpack.dist.config.js"
},
</code></pre>
<p>the scripts <code>start</code> and <code>test</code> works as expected but when running <code>npm build</code> in terminal I'm getting nothing:</p>
<pre><code>➜ client git:(master) ✗ npm build
➜ client git:(master) ✗
</code></pre>
<p>When running the command manually, things happen:</p>
<pre><code>➜ client git:(master) ✗ webpack --config webpack.dist.config.js
Hash: 9274a04acd39605afc25
Version: webpack 1.9.10
Time: 5206ms
Asset Size Chunks Chunk Names
bundle.js 5.23 MB 0 [emitted] main
[0] multi main 28 bytes {0} [built]
[349] ../config.js 181 bytes {0} [built]
+ 413 hidden modules
➜ client git:(master) ✗
</code></pre>
<p>Have I miss understod how npm scripts are suppose to work?</p>
| 0debug
|
error while starting kafka broker : <p>I was able to successfully set up zookeeper and one kafka broker yesterday. Everything worked as expected. I shut down kafka (ctrl + c) and then zookeeper.</p>
<p>Today I started zookeeper and when I started kafka (<code>bin/kafka-server-start.sh config/server0.properties</code>), I get the following error. I tried various remedies suggested (removing completely my kafka installation and doing it again from scratch). Still I get same error.</p>
<pre><code>[2016-09-28 16:15:55,895] FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable)
java.lang.RuntimeException: A broker is already registered on the path /brokers/ids/0. This probably indicates that you either have configured a brokerid that is already in use, or else you have shutdown this broker and restarted it faster than the zookeeper timeout so it appears to be re-registering.
at kafka.utils.ZkUtils.registerBrokerInZk(ZkUtils.scala:305)
at kafka.utils.ZkUtils.registerBrokerInZk(ZkUtils.scala:291)
at kafka.server.KafkaHealthcheck.register(KafkaHealthcheck.scala:70)
at kafka.server.KafkaHealthcheck.startup(KafkaHealthcheck.scala:51)
at kafka.server.KafkaServer.startup(KafkaServer.scala:244)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:37)
at kafka.Kafka$.main(Kafka.scala:67)
at kafka.Kafka.main(Kafka.scala)
[2016-09-28 16:15:55,896] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer)
</code></pre>
<p>All set up in mac</p>
| 0debug
|
Not getting latitude and longitude values android java : > I tried below code but i not getting value of latitude and longitude.I
> also cant get log:"GPS is on" which i describe in code.I also granted
> location service permission.I think my code always get null location
> then it go for else condition in gotlocation(); I west to much time
> but i get no solution.
MY code:
package gd.rf.ddl.vipsrc.service;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import static android.content.ContentValues.TAG;
@SuppressLint("HandlerLeak")
public class BootService extends Service implements LocationListener {
public double latitude;
public double longitude;
public LocationManager locationManager;
public Criteria criteria;
public String bestProvider;
@Override
public void onCreate() {
super.onCreate();
getLocation();
}
@Override
public void onDestroy() {
super.onDestroy();
locationManager.removeUpdates(this);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@SuppressLint("MissingPermission")
protected void getLocation() {
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
criteria = new Criteria();
bestProvider = String.valueOf(locationManager.getBestProvider(criteria, true)).toString();
//You can still do this if you like, you might get lucky:
@SuppressLint("MissingPermission") Location location = locationManager.getLastKnownLocation(bestProvider);
if (location != null) {
Log.e("TAG", "GPS is on");
latitude = location.getLatitude();
longitude = location.getLongitude();
senddata(latitude,longitude);
}
else{
//This is what you need:
locationManager.requestLocationUpdates(bestProvider, 1000, 0, this);
}
}
private void senddata(final double a, final double b){
Log.d(TAG, "aum your wish fullfilled");
class AsyncT extends AsyncTask<Object, Object, Void> {
@Override
protected Void doInBackground(Object... voids) {
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("latitude", String.valueOf(a)));
nameValuePairs.add(new BasicNameValuePair("longitude", String.valueOf(b)));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://example.com/send.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
str.append(line + "\n");
}
in.close();
} catch (Exception e) {
}
return null;
}
}
}
@Override
public void onLocationChanged(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();
senddata(latitude,longitude);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
}
| 0debug
|
Gradle build fail with Cannot run program No such file or directory : <p>I have a gradle build file with the following task which need to run <code>sphinx-build</code>, I'm running it on Mac OS X with the gradle information bellow.</p>
<pre><code>task makeDocs(type:Exec) {
workingDir 'sphinx'
commandLine 'sphinx-build'
args = ["-b", "html", "-d", "build/doctrees", "-t", "$platformDir", "build/ppsource", "build/html"]
}
</code></pre>
<p>When I run this task I get the following exception:</p>
<pre><code>Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'sphinx-build'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
... 1 more
Caused by: java.io.IOException: Cannot run program "sphinx-build" (in directory "/Users/idoran/Documents/Seebo/dev/SDK/seebosdk_docs/sphinx"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 3 more
Caused by: java.io.IOException: error=2, No such file or directory
</code></pre>
<p>When I run sphinx-build from the same terminal everything works fine.</p>
<hr>
<pre><code>$ gradle --version
------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------
Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_65 (Oracle Corporation 25.65-b01)
OS: Mac OS X 10.10.5 x86_64
</code></pre>
| 0debug
|
turtle.screen freezes and crash everytime i run my script : im making a space invader copy just to learn a little python since i just started with it and i made a turtle.screen but everytime i run it, it instantly freeze and crash.. does anyone know what's causing this problem?
> import turtle
> from turtle import forward, right, left
> forward(50)
> import os
> import math
> import random
> import shelve
> wn = turtle.Screen()
> wn.bgcolor("black")
> wn.title("Space invaders")
> border_pen = turtle.Turtle()
> border_pen.speed(0)
> border_pen.color("white")
> border_pen.penup()
> border_pen.setposition(-300, -300)
> border_pen.pendown()
> border_pen.pensize(3)
> for side in range(4):
> border_pen.fd(600)
> border_pen.lt(90)
> border_pen.hideturtle()
> delay = input("press enter to finish.")
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.