problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
I am having trouble making my site responsive. I need it to fit any and all screens. Can someone help please? Thanks : Here is the CSS and HTML that I am working with.
I already tried at @media only screen.
I will copy and paste my html and css down below.
Again I need a way to make the webpage fit all screens without shifting from their original positions and layout.
Don't worry about this gibberish they weren't letting me post a question until i used more details.
"hbg j jgv j gj gn vjf bgnfgbngrnbijrnjivnmjinvijrnbijvnejgbnijefnienijvnebijneijbniejnvijeninbitenbienbinbingbnvrgbjrbnornbijnrbijnrbgijngivijrgbjrbniutrbniurtbnibninbnirnribnirnrijnrtinrtnitninitrnirtnbrtnribntjbnitnjngiuthnibrnibnintirnjirbnijnirtijbnirtbirnbirntijgnvirngibrn"
HTML-
<h1><img src="listening_here.png" alt="ListeningHere"></h1>
<div class="invisible">
<div class="first">
<h2>What is the season?</h2>
<div class="box">
<select name="season">
<option value=""></option>
<option value="Winter">Winter</option>
<option value="Summer">Summer</option>
<option value="Spring">Spring</option>
<option value="Fall">Fall</option>
</select>
</div>
</div>
<div class="first">
<h2>What is the time of day?</h2>
<div class="box">
<select name="season">
<option value=""></option>
<option value="Morning">Morning</option>
<option value="Afternoon">Afternoon</option>
<option value="Evening">Evening</option>
<option value="Night">Night</option>
</select>
</div>
</div>
<div class="first">
<h2>What is the weather like?</h2>
<div class="box">
<select name="season">
<option value=""></option>
<option value="Sunny">Sunny</option>
<option value="Rainy">Rainy</option>
<option value="Cloudy">Cloudy</option>
<option value="Snowy">Snowy</option>
</select>
</div>
</div>
<div class="fourth">
<button>Submit</button>
</div>
</div>
CSS-
body {
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0;
height: 100%;
width: 100%;
font-family: Lato, sans-serif;
font color: black;
font-weight: 400;
background-color: #C1E5E5;
}
h1 {
padding-left: 50px;
}
h3 {
text-align: center;
font-size: 500%;
font-style: normal;
font-weight: 400;
}
.invisible {
margin:auto;
border-radius: 15px;
background-color: whitesmoke;
padding: 30px;
width: 60%;
height: 500px;
}
.first {
height: 150px;
width: 90%;
float: left;
text-align: center;
background-color: whitesmoke;
}
.second {
height: 150px;
width:90%;
float: left;
text-align: center;
background-color: whitesmoke;
}
.third {
height: 150px;
width:90%;
float: left;
text-align: center;
background-color: whitesmoke;
}
.fourth {
height: 50px;
width: 90%;
float: left;
text-align: center;
background-color: whitesmoke;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 40%;
border-radius: 8px;
}
.box {
position: absolute;
padding-left: 265px;
padding-right: 50px;
text-align: center;
}
.box select {
background: blue;
color: white;
padding: 10px;
width: 250px;
height: 50px;
border: none;
font-size: 20px;
box-shadow: 0 5px 25px rgba(0,0,0,.5);
-webkit appearance: button;
outline: none;
}
| 0debug
|
UIImagePickerController present quite slow : My phone has about 2000 photos. When i present UIImagePickerController, it will take about 3~4 seconds. So how to optimize this operation. Thank you.
| 0debug
|
How to upgrad to a major version of symfony with composer : I've an old symfony project and here is composer.json :
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": {"": "src/"}
},
"require": {
"php": ">=5.5.9",
"symfony/symfony": "*",
"symfony/console": ">=2.2.3",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"facebook/php-sdk-v4" : "4.0.*",
"symfony/finder": "^3.1",
"sonata-project/core-bundle": "^3.1",
"sonata-project/seo-bundle": "^2.0",
"sonata-project/admin-bundle": "^3.6"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.4-dev"
}
} }
First I'd use : php composer.phar self-update
Then I used below command to upgrade :
php composer.phar update
And here is the result :
> Search for a package: symfony
>
> Found 15 packages matching symfony
>
> [0] symfony/symfony [1] rgies/symfony [2] php-tmdb/symfony
> [3] webforge/symfony [4] lexpress/symfony1 [5] symfony/symfony1
> [6] sabaki-dev/symfony1 [7] behat/symfony2-extension [8]
> escapestudios/symfony2-coding-standard [9] smarkio/symfony1 [10]
> languara/symfony3 [11] m6web/symfony2-coding-standard [12]
> irongit/symfony2-stream-response [13]
> polishsymfonycommunity/symfony2-mocker-extension [14]
> symfony/console
>
> Enter package # to add, or the complete package name if it is not
> listed: 0 Enter the version constraint to require (or leave blank to
> use the latest version): Using version ^3.1 for symfony/symfony Search
> for a package: ./composer.json has been updated Loading composer
> repositories with package information Updating dependencies (including
> require-dev) Your requirements could not be resolved to an installable
> set of packages.
>
> Problem 1
> - Conclusion: don't install symfony/symfony v3.1.6
> - Conclusion: don't install symfony/symfony v3.1.5
> - Conclusion: don't install symfony/symfony v3.1.4
> - Conclusion: don't install symfony/symfony v3.1.3
> - Installation request for sensio/generator-bundle (locked at v2.5.3, required as ~2.3) -> satisfiable by
> sensio/generator-bundle[v2.5.3].
> - Conclusion: don't install symfony/symfony v3.1.2
> - Conclusion: don't install symfony/symfony v3.1.1
> - don't install symfony/finder v3.1.6|don't install symfony/symfony v3.1.0
> - don't install symfony/symfony v3.1.0|remove symfony/finder v3.1.6
> - don't install symfony/symfony v3.1.0|don't install symfony/finder v3.1.6
> - Installation request for symfony/symfony ^3.1 -> satisfiable by symfony/symfony[v3.1.0, v3.1.1, v3.1.2, v3.1.3, v3.1.4, v3.1.5,
> v3.1.6].
> - Installation request for symfony/finder (locked at v3.1.6, required as ^3.1) -> satisfiable by symfony/f inder[v3.1.6],
> symfony/symfony[v3.1.6].
>
>
> Installation failed, reverting ./composer.json to its original
> content.
| 0debug
|
static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %2, %%"REG_a" \n\t"
"movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd 3(%0, %%"REG_b"), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"movd 6(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%0, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm1, %%mm0 \n\t"
"packssdw %%mm3, %%mm2 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"packssdw %%mm2, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 15(%0, %%"REG_b"), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"movd 18(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%0, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm1, %%mm4 \n\t"
"packssdw %%mm3, %%mm2 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm2, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"packuswb %%mm4, %%mm0 \n\t"
"paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t"
"movq %%mm0, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src+width*3), "r" (dst+width), "g" (-width)
: "%"REG_a, "%"REG_b
);
#else
int i;
for(i=0; i<width; i++)
{
int b= src[i*3+0];
int g= src[i*3+1];
int r= src[i*3+2];
dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
}
#endif
}
| 1threat
|
Java Parsing strings : <p>I got .txt file with nationalities and phone numbers in different formats and all these in single quote symbols, also it contains empty lines (''): </p>
<pre><code>''
'French'
'1-500'
'0345134123'
''
''
'German'
etc
</code></pre>
<p>after I parse with the help of <code>readLine()</code> I got <code>arr[0]</code> with each of these lines.<br>
I need to put lines into different arrays: lines with 'nationality' into one array and lines with 'phone numbers' into other.<br>
I tried this </p>
<pre><code>if(!arr[0].equals("''")){
String[] arr1 = arr[0].split("'");
if(!arr1[1].matches("[0-9]+)"){
nations[n] = arr1[1];
n++;
}
else {
phone_numbers[p] = arr1[1];
p++;
}
}
</code></pre>
<p>Ofcourse it didn't work</p>
| 0debug
|
find where in the code an http request was made using chrome dev tools : <p>Is there any way using chrome dev tools to find where an http request (ajax) was made?
I have a large project with many requests happening in different files. There's a particular request that I want to be able to inspect, I've found it on the Network tab, but there doesn't seem to be any way to find where in the code was this request started.</p>
| 0debug
|
static int mov_read_replaygain(MOVContext *c, AVIOContext *pb, int size)
{
int64_t end = avio_tell(pb) + size;
uint8_t *key = NULL, *val = NULL;
int i;
for (i = 0; i < 2; i++) {
uint8_t **p;
uint32_t len, tag;
if (end - avio_tell(pb) <= 12)
break;
len = avio_rb32(pb);
tag = avio_rl32(pb);
avio_skip(pb, 4);
if (len < 12 || len - 12 > end - avio_tell(pb))
break;
len -= 12;
if (tag == MKTAG('n', 'a', 'm', 'e'))
p = &key;
else if (tag == MKTAG('d', 'a', 't', 'a') && len > 4) {
avio_skip(pb, 4);
len -= 4;
p = &val;
} else
break;
*p = av_malloc(len + 1);
if (!*p)
break;
avio_read(pb, *p, len);
(*p)[len] = 0;
}
if (key && val) {
av_dict_set(&c->fc->metadata, key, val,
AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
key = val = NULL;
}
avio_seek(pb, end, SEEK_SET);
av_freep(&key);
av_freep(&val);
return 0;
}
| 1threat
|
How to edit and save text files (.py) in Google Colab? : <p>I cloned a github repo using <code>!git clone https://github.com/llSourcell/Pokemon_GAN.git</code>. I wanted to modify a .py file inside Colab. So i used <code>%load filename.py</code> as suggested here (<a href="https://stackoverflow.com/questions/21034373/how-to-load-edit-run-save-text-files-py-into-an-ipython-notebook-cell">How to load/edit/run/save text files (.py) into an IPython notebook cell?</a>). But whenever i run this command, i get disconnected after some time. I was wondering if there is some other way to edit .py file without undergoing the hassle of downloading it to pc,editing and then re uploading it. Thanks in advance.</p>
| 0debug
|
static inline void gen_movcf_ps (int fs, int fd, int cc, int tf)
{
int cond;
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv r_tmp2 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph1 = tcg_temp_local_new(TCG_TYPE_I32);
int l1 = gen_new_label();
int l2 = gen_new_label();
if (tf)
cond = TCG_COND_EQ;
else
cond = TCG_COND_NE;
gen_load_fpr32(fp0, fs);
gen_load_fpr32h(fph0, fs);
gen_load_fpr32(fp1, fd);
gen_load_fpr32h(fph1, fd);
get_fp_cond(r_tmp1);
tcg_gen_shri_i32(r_tmp1, r_tmp1, cc);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x1);
tcg_gen_brcondi_i32(cond, r_tmp2, 0, l1);
tcg_gen_mov_i32(fp1, fp0);
tcg_temp_free(fp0);
gen_set_label(l1);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x2);
tcg_gen_brcondi_i32(cond, r_tmp2, 0, l2);
tcg_gen_mov_i32(fph1, fph0);
tcg_temp_free(fph0);
gen_set_label(l2);
tcg_temp_free(r_tmp1);
tcg_temp_free(r_tmp2);
gen_store_fpr32(fp1, fd);
gen_store_fpr32h(fph1, fd);
tcg_temp_free(fp1);
tcg_temp_free(fph1);
}
| 1threat
|
Javascript - nested dictionary from array of strings separated with dots : <p>I have to <strong>translate</strong> an array <strong>to</strong> nested dictionary.</p>
<p>In case i have a string array. each string combined from numbers that seprated by dots,
and each number means a key in the translated dictionary. (except the last number)</p>
<p>e.g.</p>
<p>i have this array:
<code>array = ["5.1.1.1","5.1.1.2","5.1.1.3",..."5.2.1.2","5.2.1.4"..."1.1.1.1"..."1.2.1.3"]</code></p>
<p>and i need output to be this:</p>
<pre><code>var output = {
'5': {
'1': {
'1': [1,2,3],
'2': [1]
},
'2':{
'1': [2,4],
'2': [1]
}
},
'1': {
'1':{
'1':[1,2,5],
'2':[1]
},
'2':{
'1':[2,3]
}
}
};
</code></pre>
<p>i have an opposite function, which get a nested dictionary and her output is an array.</p>
<p>link: <a href="https://stackoverflow.com/a/59191937/7593555">https://stackoverflow.com/a/59191937/7593555</a></p>
<p>Thanks for helping :).</p>
| 0debug
|
static inline void gen_sync_flags(DisasContext *dc)
{
if (dc->tb_flags != dc->synced_flags) {
tcg_gen_movi_tl(env_flags, dc->tb_flags);
dc->synced_flags = dc->tb_flags;
}
}
| 1threat
|
Javascript say "document" is not defined : I have a book studing javascript but brackets say's: document is not defined.
In this code:
`var btnMenu = document.getElementById('btn-menu');
var nav = document.getElementById('nav');
btnMenu.addEventListener('click'), function(){
nav.classList.toggle('show');
})`
I dont know what is wrong, can you help me?
| 0debug
|
Safely deleting unused coded: What are all the ways a macro can be called? (Excel-VBA) : I want to remove some code I believe is unused in a specific Excel VBA Project. I think I've checked all the places that macros can be hiding, but I want to be absolutely sure the workbook won't try to a call certain sub after I delete it. Is my checklist complete?
1. The code itself, called by other subroutines
2. Assigned to a shape on a worksheet
3. In a worksheet cell as a user defined function
4. Called by the XML of a custom ribbon
| 0debug
|
ConstraintLayout - proportional width/height to self? : <p>I'm trying to figure out how to achieve the following behaviour using constraint layout:</p>
<ol>
<li>Place a view in the center of the ConstraintLayout parent</li>
<li>Make the view width to be half of the parent's width</li>
<li>Make the view height equals to its width</li>
</ol>
<p>(i.e - place a square in the center)</p>
<p>I tried to use this combination:</p>
<pre><code> android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintDimensionRatio="2:1"
</code></pre>
<p>But I'm not sure how to continue from here</p>
| 0debug
|
Randint and if statements in python: error : correctPath = random.randint(1,2,3)
if chosenPath == str(correctPath):
print("Thank you for your help")
print("this has been altered for creative purposes")
elif chosenPath != str(correctPath):
print("Thanks in advance.")
else:
print ("code to be written")
| 0debug
|
Why is this html program gives an output like this? : <pre><code><!DOCTYPE html>
<html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
</code></pre>
<p>If you run this programme then the desired o/p will come but my question is why the o/p is like that since i've not included break or textsize command.And one more thing if you try to add one more heading then it comes in regular size also from that statement the previous order doesn't follow anymore,WHY IS THAT ??</p>
| 0debug
|
Android Error:Execution failed for task ':app:transformClassesWithDexForDebug'. (Android.banker.A2af7 trojen detected) : Android studio showing this error :
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.io.FileNotFoundException: C:\Users\hp\Desktop\M\app\build\intermediates\pre-dexed\debug\classes_b11ac8137589884ed512c93c59b969dc5dc99df3.jar (The system cannot find the file specified)
Every time i run the app, quick heal shows Android.banker.A2af7(PUP) tojen is detected and it quarantines the file.
Here is the screenshot :
https://i.stack.imgur.com/ukqXo.png
I have no idea what is happening...
Can someone help ?
| 0debug
|
How to debug PS4 internet browser : <p>We noticed our site is not rendered as expected on PS4 browser, is there a way to debug it or get a console?</p>
<p>I know that the PS4 browser is WebKit based so I wonder is there similar debug tools like chrome or safari have?</p>
| 0debug
|
static struct omap_rtc_s *omap_rtc_init(MemoryRegion *system_memory,
hwaddr base,
qemu_irq timerirq, qemu_irq alarmirq,
omap_clk clk)
{
struct omap_rtc_s *s = (struct omap_rtc_s *)
g_malloc0(sizeof(struct omap_rtc_s));
s->irq = timerirq;
s->alarm = alarmirq;
s->clk = timer_new_ms(rtc_clock, omap_rtc_tick, s);
omap_rtc_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_rtc_ops, s,
"omap-rtc", 0x800);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| 1threat
|
how can i connet the sql on c# and using the command of Adapter : private void button2_Click(object sender, EventArgs e)
{
OleDbConnection cnn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\bbbde\Database2.mdb");
cnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\bbbde\Database2.mdb";
OleDbDataAdapter da = new OleDbDataAdapter("select count(*) Form nameList where name='" + textBox1.Text + "'and password ='" + textBox2 + "'", cnn);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Form2 frm = new Form2();
frm.Show();
}
and there is a error that System.Data.OleDb.OleDbException: 'Syntax error (missing operator) in query expression 'count(*) Form nameList where name=''and password ='System.Windows.Forms.TextBox, Text: ''.'
| 0debug
|
how to get output of count variable ? : <?php
$count=0;
class My extends Thread
{
private $myid;
// ini_set('max_execution_time', 0);
//echo date("Y-m-d H:i:s")."<br/>";
public function __construct($id)
{
$this->myid = $id;
}
public function run()
{
for($t=0;$j+$t<=100;$t+=10){ //future buy
for($k=0;$j+$t+$k<=100;$k+=10){//future sell
for($l=1;$l<=14;$l++){ // strike
for($m=0;$j+$k+$m<=300;$m+=10){ //put buy
for($n=1;$n<=14;$n++){ // strike
for($o=0;$o<=300;$o+=10){ // call buy
for($p=1;$p<=14;$p++){ //strike
if($p==$l)
continue;
for($q=0;$q<=300;$q+=10){ // put sell
for($r=1;$r<=14;$r++){ // strike
if($r==$n)
continue;
for($s=0;$s<=300;$s+=10){ // call buy
$count ++;
}
}
}
}
}
}
}
}
}
}
}
}
echo date("Y-m-d H:i:s")."<br/>";
$mycalls = [];
for($i=0;$i<=100;$i+=10)
{
$mycalls[$i]= new My($i);
$mycalls[$i]->start();
$mycalls[$i]->join();
}
echo date("Y-m-d H:i:s")."<br/>";
echo "<br>";
echo $count;
?>
| 0debug
|
What's the use of the "with" statement in Python? : <p>While programming in Python, sometimes I need to launch functions and object methods, something like this:</p>
<pre><code>obj1.launch_method1(); // object method
do_something(); // general function
obj1.launch_method2(); // object method
</code></pre>
<p>Using the <code>with</code> statement, this becomes:</p>
<pre><code>with obj1:
launch_method1();
do_something();
launch_method2();
</code></pre>
<p>In my opinion, this causes confusion, because the next programmer might erroneously think that <code>do_something()</code> is an object method rather than a general function.</p>
<p>In top of this, most IDEs has intellisense, so when you type <code>obj1.</code> (mind the dot), a list of methods and properties appears, which makes it pretty easy to type things like <code>obj1.launch_method1()</code>, <code>obj1.launch_method2()</code>, ...</p>
<p>So, from a programmer's perspective, there seems not to be an advantage in the usage of the <code>with</code> statement.</p>
<p>However, it seems that the <code>with</code> statement launches <code>__enter__</code> and <code>__exit__</code> calls, which seems to create new contexts. What are those calls? What does this mean? Does the usage of the <code>with</code> statement make any difference? If yes, which one(s)?</p>
| 0debug
|
my app always crashes everytime i click friends fragment,allusers activity and settings activity referring to same error : following is the code
package com.example.convo;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ServerValue;
import com.google.firebase.database.ValueEventListener;
import com.squareup.picasso.Callback;
import com.squareup.picasso.NetworkPolicy;
import com.squareup.picasso.Picasso;
import de.hdodenhof.circleimageview.CircleImageView;
/**
* A simple {@link Fragment} subclass.
*/
public class FriendsFragment extends Fragment {
private RecyclerView myFriensList;
private DatabaseReference FriendsReference;
private DatabaseReference UsersReference;
private FirebaseAuth mAuth;
String online_user_id;
private View myMainView;
public FriendsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
myMainView = inflater.inflate(R.layout.fragment_friends, container, false);
myFriensList = myMainView.findViewById(R.id.friends_list);
mAuth = FirebaseAuth.getInstance();
online_user_id = mAuth.getCurrentUser().getUid();
FriendsReference = FirebaseDatabase.getInstance().getReference().child("Friends").child(online_user_id);
FriendsReference.keepSynced(true);
UsersReference = FirebaseDatabase.getInstance().getReference().child("Users");
UsersReference.keepSynced(true);
myFriensList.setLayoutManager(new LinearLayoutManager(getContext()));
// Inflate the layout for this fragment
return myMainView;
}
@Override
public void onStart() {
super.onStart();
FirebaseRecyclerAdapter<Friends, FriendsViewHolder> firebaseRecyclerAdapter
= new FirebaseRecyclerAdapter<Friends, FriendsViewHolder>
(
Friends.class,
R.layout.all_users_display_layout,
FriendsViewHolder.class,
FriendsReference
) {
@Override
protected void populateViewHolder(final FriendsViewHolder viewHolder, Friends model,final int position) {
viewHolder.setDate(model.getDate());
final String list_user_id = getRef(position).getKey();
/*
viewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
String visit_user_id = getRef(position).getKey();
Intent profileIntent = new Intent(AllUsersActivity.this, ProfileActivity.class);
profileIntent.putExtra("visit_user_id", visit_user_id);
startActivity(profileIntent);
}
});
*/
UsersReference.child(list_user_id).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
final String userName = dataSnapshot.child("user_name").getValue().toString();
String thumbImage = dataSnapshot.child("user_thumb_image").getValue().toString();
if(dataSnapshot.hasChild("online")){
String online_status = (String) dataSnapshot.child("online").getValue().toString();
viewHolder.setUserOnline(online_status);
}
viewHolder.setUserName(userName);
viewHolder.setThumbImage(thumbImage, getContext());
viewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CharSequence options[] = new CharSequence[]
{
userName + "'s Profile",
"Send Message"
};
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("Select Options");
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
if(position == 0){
Intent profileIntent = new Intent(getContext(), ProfileActivity.class);
profileIntent.putExtra("visit_user_id", list_user_id);
startActivity(profileIntent);
}
if(position == 1){
if(dataSnapshot.child("online").exists()){
Intent chatIntent = new Intent(getContext(), ChatActivity.class);
chatIntent.putExtra("visit_user_id", list_user_id);
chatIntent.putExtra("user_name", userName);
startActivity(chatIntent);
}
else {
UsersReference.child(list_user_id).child("online")
.setValue(ServerValue.TIMESTAMP).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Intent chatIntent = new Intent(getContext(), ChatActivity.class);
chatIntent.putExtra("visit_user_id", list_user_id);
chatIntent.putExtra("user_name", userName);
startActivity(chatIntent);
}
});
}
}
}
});
builder.show();
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
};
myFriensList.setAdapter(firebaseRecyclerAdapter);
}
public static class FriendsViewHolder extends RecyclerView.ViewHolder{
View mView;
public FriendsViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setDate(String date){
TextView sinceFriendsDate = mView.findViewById(R.id.all_users_status);
sinceFriendsDate.setText(date);
}
public void setUserName(String userName){
TextView userNameDisplay = mView.findViewById(R.id.all_users_username);
userNameDisplay.setText(userName);
}
public void setThumbImage(final String thumbImage, final Context applkicationContext) {
final CircleImageView image = mView.findViewById(R.id.all_users_profile_image);
//loading images offline
Picasso.get().load(thumbImage).networkPolicy(NetworkPolicy.OFFLINE).placeholder(R.drawable.default_profile)
.into(image, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
Picasso.get().load(thumbImage).placeholder(R.drawable.default_profile).into(image);
}
});
}
public void setUserOnline(String online_status) {
ImageView onlineStatusView = (ImageView) mView.findViewById(R.id.online_status);
if(online_status.equals(true)){
onlineStatusView.setVisibility(View.VISIBLE);
}
else {
onlineStatusView.setVisibility(View.INVISIBLE);
}
}
}
}
here's the log
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.koekoe.convo, PID: 15381
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at com.koekoe.convo.FriendsFragment$1$1.onDataChange(FriendsFragment.java:115)
at com.google.android.gms.internal.zzbpx.zza(Unknown Source:13)
at com.google.android.gms.internal.zzbqx.zzZT(Unknown Source:2)
at com.google.android.gms.internal.zzbra$1.run(Unknown Source:69)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I/Process: Sending signal. PID: 15381 SIG: 9
Application terminated.
| 0debug
|
static int usb_net_handle_statusin(USBNetState *s, USBPacket *p)
{
int ret = 8;
if (p->len < 8)
return USB_RET_STALL;
((le32 *) p->data)[0] = cpu_to_le32(1);
((le32 *) p->data)[1] = cpu_to_le32(0);
if (!s->rndis_resp.tqh_first)
ret = USB_RET_NAK;
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: interrupt poll len %u return %d", p->len, ret);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < ret; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", p->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
return ret;
}
| 1threat
|
Quicksort a dict to an OrderedDict : <p>In python, how do I quick sort a nested dictionary into an OrderedDict? For example:</p>
<pre><code>{'susan': {'number': '5', 'fav_color': 'yellow'},
'josh': {'number': '1', 'fav_color': 'blue'},
'casey': {'number': '11', 'fav_color': 'orange'}}
</code></pre>
<p>I want to sort on number such that I end up with:</p>
<pre><code>{'josh': {'number': '1', 'fav_color': 'blue'},
'susan': {'number': '5', 'fav_color': 'yellow'},
'casey': {'number': '11', 'fav_color': 'orange'}}
</code></pre>
| 0debug
|
PHP - How do facebook change the facebook/message/username to facebook/message/username2 on the same page? : <p>I'm trying to create a real-time chat on my website. One of the functions I want to imitate is how <a href="http://facebook.com/messages/" rel="nofollow">facebook.com/messages</a> changes not only content of the webpage but also the url without refreshing. I think this is a lot cleaner more efficient. </p>
<p>My current process is just a <code>("#class_name").click</code> with a <code>var id = $(this).attr("id")</code> running with an <strong>Ajax</strong>.</p>
| 0debug
|
Recursive code, Whats wrong here : public static int power(int x, int y){
if(y>0){
x = x*x;
power(x,y-1);
}
return x;
}
The method should return the value of x^y but it is not working, can someone tell me what is wrong here?
| 0debug
|
how to convert the date format 'YYYY-MM-DD' to ddMMyy in pyspark? : <p>I tried to convert the date format 2018-07-12 to ddMMyy using to_date but i get null after converting the dateformat</p>
<pre><code>df = spark.createDataFrame([('2018-07-12',)], ['Date_col'])
df = df.withColumn('new_date',to_date('Date_col', 'ddMMyy'))
</code></pre>
<p>I need to use this logic to convert the dataframe column. I am new to the spark programming and tried lot of solutions but nothing helps.</p>
<p>I need to concat the ddMMyy from one column and hhss from other column</p>
<p>Any help please?</p>
| 0debug
|
mysqli multi query sepperation : I know you can run multiple queries with mysqli_multi_query but i have a problem.
For a registration page i want to perform 2 checks and then an insert.
Check1 = Does username exist?
Check2 = Email already been used?
If both checks are negative then do the insert query.
But how can i sepperate the errors,, when a username exists it has to return 'Username already exists' if email is already been used it has to return 'Email already in use'
here is my code:
$sql = "check username query; ";
$sql .= "check email query; ";
$sql .= "Insert query";
if (mysqli_multi_query($conn,$sql)) {
do
{
if ($result=mysqli_store_result($conn)) {
while ($row=mysqli_fetch_row($result)) {
if (mysqli_num_rows($result) > 0) {
//DO STUFF
//Here do i need to return if the username or email exists or not.
};
mysqli_free_result($result);
};
} else {
echo 'Query fout!';
};
while (mysqli_next_result($con));
};
mysqli_close($con);
| 0debug
|
How to redirect after selecting 2 selections to specific page? : I'm doing work on my website and hung up on a code
Please check the below link to understand what i'm trying to say
http://matchpoint.finetiger.com/classes-programs/
Shell RD - Fitness and Training :- example.com
Mill Basin - Fitness and Training :- example2.com
<div id="classes-programs-page" class="classes-programs-page text-center">
<form class="form-inline" role="form">
<div class="form-group find-area">
<select id="clubs" class="form-control">
<option value="1">Shell Rd</option>
<option value="2">Mill Basin</option>
</select>
<i class="fa fa-chevron-down"></i>
</div>
<div class="form-group find-area">
<select id="programs" class="form-control">
<option value="3">Fitness & Training </option>
<option value="4">Aquatics </option>
<option value="5">Tennis</option>
<option value="6">Kids Programs</option>
</select>
<i class="fa fa-chevron-down"></i>
</div>
<button type="submit" class="btn btn-find">Find</button>
</form>
</div>
| 0debug
|
Copy lines and replace beginning of some lines : <p>I have a file containing lines of the form</p>
<pre><code>this is block 1
a 1 2 3
this is block 2
a 3 1 9
this is block 3
a 10 2 32
...
</code></pre>
<p>I would like to copy some of the lines and replace the beginning so that it becomes:</p>
<pre><code>this is block 1
a 1 2 3
b 1 2 3
c 1 2 3
this is block 2
a 3 1 9
b 3 1 9
c 3 1 9
this is block 3
a 10 2 32
b 10 2 32
c 10 2 32
...
</code></pre>
<p>Not sure how to solve this with awk, sed or another elegant option. </p>
| 0debug
|
Slack icon not visible any more in notification area : <p>Not sure why but since recently, the <code>Slack</code> icon in bottom right notification area (Windows 10) isn't visible anymore despite Slack app being checked in "Select which icons appear on the taskbar" section. Consequently I need to keep <code>Slack</code> open at all times in my app bar (which I don't want because it's crowded).</p>
<p>Any idea what's causing the problem here?</p>
| 0debug
|
Installing basemap on Mac / Python : <p>I'm having trouble to get the basemap to work in Python in my Mac.</p>
<p>I keep receiving:</p>
<pre><code> from mpl_toolkits.basemap import basemap
ImportError: No module named basemap
</code></pre>
<p>What I did:</p>
<pre><code>brew install gdal
brew install gets
export GEOS_DIR=/usr/local/Cellar/geos/3.4.2/
basemap-1.0.7 $ python setup.py install
</code></pre>
<p>I also tried:</p>
<pre><code>basemap-1.0.7 $ cd geos-3.3.3
basemap-1.0.7/geos-3.3.3 $ export GEOS_DIR=~/
basemap-1.0.7/geos-3.3.3 $ ./configure --prefix=$GEOS_DIR
basemap-1.0.7/geos-3.3.3 $ make
basemap-1.0.7/geos-3.3.3 $ make install
basemap-1.0.7/geos-3.3.3 $ cd ..
basemap-1.0.7 $ python setup.py install
</code></pre>
<p>None of them worked for me.
How can I get this package to work on a MacOS Sierra?</p>
| 0debug
|
import re
def num_position(text):
for m in re.finditer("\d+", text):
return m.start()
| 0debug
|
why is Inline SQL a bad thing to include in an application : <p>I have been doing some research on SQL to boost my knowledge on the topic, I have came across quite a few people saying that Inline SQL is a bad thing but no one is saying why, I was hoping someone could help me to understand; Why inline SQL within an application (Such as c#) is a bad thing, thanks.</p>
| 0debug
|
static int xface_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
XFaceContext *xface = avctx->priv_data;
ProbRangesQueue pq = {{ 0 }, 0};
uint8_t bitmap_copy[XFACE_PIXELS];
BigInt b = {0};
int i, j, k, ret = 0;
const uint8_t *buf;
uint8_t *p;
char intbuf[XFACE_MAX_DIGITS];
if (avctx->width || avctx->height) {
if (avctx->width != XFACE_WIDTH || avctx->height != XFACE_HEIGHT) {
av_log(avctx, AV_LOG_ERROR,
"Size value %dx%d not supported, only accepts a size of %dx%d\n",
avctx->width, avctx->height, XFACE_WIDTH, XFACE_HEIGHT);
return AVERROR(EINVAL);
}
}
avctx->width = XFACE_WIDTH;
avctx->height = XFACE_HEIGHT;
buf = frame->data[0];
for (i = 0, j = 0; i < XFACE_PIXELS; ) {
for (k = 0; k < 8; k++)
xface->bitmap[i++] = (buf[j]>>(7-k))&1;
if (++j == XFACE_WIDTH/8) {
buf += frame->linesize[0];
j = 0;
}
}
memcpy(bitmap_copy, xface->bitmap, XFACE_PIXELS);
ff_xface_generate_face(xface->bitmap, bitmap_copy);
encode_block(xface->bitmap, 16, 16, 0, &pq);
encode_block(xface->bitmap + 16, 16, 16, 0, &pq);
encode_block(xface->bitmap + 32, 16, 16, 0, &pq);
encode_block(xface->bitmap + XFACE_WIDTH * 16, 16, 16, 0, &pq);
encode_block(xface->bitmap + XFACE_WIDTH * 16 + 16, 16, 16, 0, &pq);
encode_block(xface->bitmap + XFACE_WIDTH * 16 + 32, 16, 16, 0, &pq);
encode_block(xface->bitmap + XFACE_WIDTH * 32, 16, 16, 0, &pq);
encode_block(xface->bitmap + XFACE_WIDTH * 32 + 16, 16, 16, 0, &pq);
encode_block(xface->bitmap + XFACE_WIDTH * 32 + 32, 16, 16, 0, &pq);
while (pq.prob_ranges_idx > 0)
push_integer(&b, pq.prob_ranges[--pq.prob_ranges_idx]);
i = 0;
while (b.nb_words) {
uint8_t r;
ff_big_div(&b, XFACE_PRINTS, &r);
intbuf[i++] = r + XFACE_FIRST_PRINT;
}
if ((ret = ff_alloc_packet2(avctx, pkt, i+2)) < 0)
return ret;
p = pkt->data;
while (--i >= 0)
*(p++) = intbuf[i];
*(p++) = '\n';
*(p++) = 0;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat
|
import re
def camel_to_snake(text):
str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()
| 0debug
|
when a python script is executed inside a python script, i donot get the complete output : when a python script is executed inside a python script, i donot get the complete output.
os.system('python -u capture.py > capture.log &')
where capture.py will capture the packets and feeds this to capture.log.
Capture.py will keep sending packets every 100 sec. I couldnt see the complete output in to the file. Only the initial captures are put to capture.log.
Becos capture.py does nt capture any packets after somtime. But when "python -u" executed on bash prompt it work. Pleas help
| 0debug
|
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
{
AVFormatContext *s = of->ctx;
AVStream *st = ost->st;
int ret;
if (!of->header_written) {
AVPacket tmp_pkt = {0};
if (!av_fifo_space(ost->muxing_queue)) {
int new_size = FFMIN(2 * av_fifo_size(ost->muxing_queue),
ost->max_muxing_queue_size);
if (new_size <= av_fifo_size(ost->muxing_queue)) {
av_log(NULL, AV_LOG_ERROR,
"Too many packets buffered for output stream %d:%d.\n",
ost->file_index, ost->st->index);
exit_program(1);
}
ret = av_fifo_realloc2(ost->muxing_queue, new_size);
if (ret < 0)
exit_program(1);
}
ret = av_packet_ref(&tmp_pkt, pkt);
if (ret < 0)
exit_program(1);
av_fifo_generic_write(ost->muxing_queue, &tmp_pkt, sizeof(tmp_pkt), NULL);
av_packet_unref(pkt);
return;
}
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) ||
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed)) {
if (ost->frame_number >= ost->max_frames) {
av_packet_unref(pkt);
return;
}
ost->frame_number++;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
int i;
uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
NULL);
ost->quality = sd ? AV_RL32(sd) : -1;
ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE;
for (i = 0; i<FF_ARRAY_ELEMS(ost->error); i++) {
if (sd && i < sd[5])
ost->error[i] = AV_RL64(sd + 8 + 8*i);
else
ost->error[i] = -1;
}
if (ost->frame_rate.num && ost->is_cfr) {
if (pkt->duration > 0)
av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n");
pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate),
ost->mux_timebase);
}
}
av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base);
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (pkt->dts != AV_NOPTS_VALUE &&
pkt->pts != AV_NOPTS_VALUE &&
pkt->dts > pkt->pts) {
av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n",
pkt->dts, pkt->pts,
ost->file_index, ost->st->index);
pkt->pts =
pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1
- FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1)
- FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1);
}
if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
pkt->dts != AV_NOPTS_VALUE &&
!(st->codecpar->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) &&
ost->last_mux_dts != AV_NOPTS_VALUE) {
int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT);
if (pkt->dts < max) {
int loglevel = max - pkt->dts > 2 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG;
av_log(s, loglevel, "Non-monotonous DTS in output stream "
"%d:%d; previous: %"PRId64", current: %"PRId64"; ",
ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts);
if (exit_on_error) {
av_log(NULL, AV_LOG_FATAL, "aborting.\n");
exit_program(1);
}
av_log(s, loglevel, "changing to %"PRId64". This may result "
"in incorrect timestamps in the output file.\n",
max);
if (pkt->pts >= pkt->dts)
pkt->pts = FFMAX(pkt->pts, max);
pkt->dts = max;
}
}
}
ost->last_mux_dts = pkt->dts;
ost->data_size += pkt->size;
ost->packets_written++;
pkt->stream_index = ost->index;
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "muxer <- type:%s "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
av_get_media_type_string(ost->enc_ctx->codec_type),
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base),
pkt->size
);
}
ret = av_interleaved_write_frame(s, pkt);
if (ret < 0) {
print_error("av_interleaved_write_frame()", ret);
main_return_code = 1;
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED);
}
av_packet_unref(pkt);
}
| 1threat
|
How to delete the latest added book? : <p>I don't know how to delete the latest book that we added on this source code. I want to make a stack implementation program. So if we delete a book, the program will delete the last-added book, not the first-added book like in my source code below. I'm not too understand with stack using pointers. Can anyone fix my code? Thanks</p>
<pre><code>#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
class Book {
int code, year;
string language, name, title;
Book *head, *next, *prev, *link;
public:
Book (string & name, string & title, int code, string & language, int year) {
head = NULL;
this -> name = name;
this -> title = title;
this -> language = language;
this -> code = code;
this -> year = year;
};
~ Book (void) {
delete head;
};
void display (void);
void add (void);
void dellete (void);
};
void Book :: add (void) {
string name, title, language;
int year, code;
system("color E2");
cout << endl << "Author:", cin >> name;
cout << "Title:", cin >> title;
cout << "ISBN code(13 digits):", cin >> code;
cout << "Language:", cin >> language;
cout << "Year of publication:", cin >> year;
Book * p = new Book (name, title, code, language, year);
p -> next = head;
head = p;
}
void Book :: dellete (void) {
string name, title, language;
int year, code;
system("color B0");
Book *p, *prev, *next;
if(head==NULL)
{
cout << "There is no book in the stack\n";
}
else if(head->next==NULL)
{
p = head;
head = NULL;
free(p);
cout << "All book has been deleted. Now the stack is empty\n";
}
else
{
p = head;
while(p->next !=NULL)
{
prev = p;
p = p->next;
}
prev->next = NULL;
free(p);
cout << "A book has been deleted\n";
}
}
void Book :: display (void) {
Book * p = head;
while (p) {
system("color B5");
cout << "----------------------------- \n";
cout << "Author:" << p -> name << endl;
cout << "Title:" << p -> title << endl;
cout << "Number of books" << p -> code << endl;
cout << "Language:" << p -> language << endl;
cout << "Year of publication:" << p -> year << endl;
cout << endl;
p = p -> next;
}
}
int main (int argc, char const ** argv) {
string blank = "";
Book * B = new Book (blank, blank, 0, blank, 0);
int opt;
for (;;) {
system("color A0");
cout << "----------------------------- \n";
cout << "1) Add a book.\n";
cout << "2) Show all books.\n";
cout << "3) Delete a book\n";
cout << "4) Exit. \n";
cout << "Options:", cin >> opt;
switch (opt) {
case 1:
B -> add ();
break;
case 2:
B -> display ();
break;
case 3:
B -> dellete ();
break;
case 4:
exit (0);
default:
continue;
}
}
return 0;
</code></pre>
<p>}</p>
<p>I hope there's someone who help me to fix this code. Thanks.</p>
| 0debug
|
How to find the factors of all the numbers in a list in python 3? : <p>I have been trying to find the factors of all the numbers in a list. I have written my code but it does not work at all. I am new to Python and would appreciate any help. Here's my code:</p>
<pre><code>n = [3,4,5]
for i in n:
if i%n == 0:
print(i)
</code></pre>
| 0debug
|
static int mmubooke206_get_physical_address(CPUState *env, mmu_ctx_t *ctx,
target_ulong address, int rw,
int access_type)
{
ppcmas_tlb_t *tlb;
target_phys_addr_t raddr;
int i, j, ret;
ret = -1;
raddr = (target_phys_addr_t)-1ULL;
for (i = 0; i < BOOKE206_MAX_TLBN; i++) {
int ways = booke206_tlb_ways(env, i);
for (j = 0; j < ways; j++) {
tlb = booke206_get_tlbm(env, i, address, j);
ret = mmubooke206_check_tlb(env, tlb, &raddr, &ctx->prot, address,
rw, access_type);
if (ret != -1) {
goto found_tlb;
found_tlb:
if (ret >= 0) {
ctx->raddr = raddr;
LOG_SWTLB("%s: access granted " TARGET_FMT_lx " => " TARGET_FMT_plx
" %d %d\n", __func__, address, ctx->raddr, ctx->prot,
ret);
} else {
LOG_SWTLB("%s: access refused " TARGET_FMT_lx " => " TARGET_FMT_plx
" %d %d\n", __func__, address, raddr, ctx->prot, ret);
return ret;
| 1threat
|
HOW to copy many rows in the same time? : <p>i have huge data.</p>
<p>HOW to copy many rows in the same time?</p>
<p>where the rows, that i want, are repeated in systematic approach for each four rows. please, see the figure.</p>
<p>thank you in advance for any help.
<a href="http://i.stack.imgur.com/w5mnC.jpg" rel="nofollow">MANY ROWS</a></p>
| 0debug
|
Custom font size for Text in SwiftUI : <p>I have a label in my view that I want to use the system font size in medium, with a size of 21 points.<br>
I created a custom extension to re-use the font created:</p>
<pre><code>extension Font {
static var primaryButton: Font {
return Font.custom("SFUIDisplay-Light", size: 21)
}
}
</code></pre>
<p>However, this does not have any effect. I changed the string to <code>HelveticaNeue-UltraLight</code> and it did work, so I'm guessing that <code>SFUIDisplay-Light</code> is simply the incorrect font name.<br>
In font book, it says <code>SFProText-Light</code>, but that also did not work for me.</p>
<p>What is the correct font name of the San Francisco font in SwiftUI?<br>
Or: how can I set the font size using the system font?</p>
| 0debug
|
fill textview text color when accroding to getting perectage : Hi I have to show progress in the number Text-view text itself.Is their any such built in API to paint characters as in the below image?
[enter image description here][1]
[1]: https://i.stack.imgur.com/BqyaE.png
| 0debug
|
how can I store a variable(Int) permanently after app closes and Display it? : I am trying to store a variable named *total* which holds the number of rows in UItableView. Since the user types strings for UITableView, the variable is *listTable* which is String array.
I have my *total* as total = listTable.count
ISSUE:
Every time the app launches it displays 0 as number of rows used, however once you go to the UITableView ViewController and come back to the main ViewController it automatically corrects its self to the current amount of rows.
Code Used:
import UIKit
var listTable = [String]()
var total = listTable.count
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var numberOfRows: UILabel!
@IBOutlet weak var TypeToCreateRow: UITextField!
@IBOutlet weak var AddRow: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
total = listTable.count
NSUserDefaults.standardUserDefaults().setObject(total, forKey: "rows")
let showRow = NSUserDefaults.standardUserDefaults().objectForKey("rows")!
numberOfRows.text = "\(showRow)"
print(showRow)
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func RowAdd(sender: UIButton) {
listTable.append(TypeToCreateRow.text!)
TypeToCreateRow.text = " "
numberOfRows.text = "\(total)" }
| 0debug
|
static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
{
H264Context *h = &svq3->h;
int i, j, k, m, dir, mode;
int cbp = 0;
uint32_t vlc;
int8_t *top, *left;
MpegEncContext *const s = (MpegEncContext *) h;
const int mb_xy = h->mb_xy;
const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride;
h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
h->topright_samples_available = 0xFFFF;
if (mb_type == 0) {
if (s->pict_type == AV_PICTURE_TYPE_P || s->next_picture.f.mb_type[mb_xy] == -1) {
svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0);
if (s->pict_type == AV_PICTURE_TYPE_B) {
svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 1, 1);
}
mb_type = MB_TYPE_SKIP;
} else {
mb_type = FFMIN(s->next_picture.f.mb_type[mb_xy], 6);
if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0)
return -1;
if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0)
return -1;
mb_type = MB_TYPE_16x16;
}
} else if (mb_type < 8) {
if (svq3->thirdpel_flag && svq3->halfpel_flag == !get_bits1 (&s->gb)) {
mode = THIRDPEL_MODE;
} else if (svq3->halfpel_flag && svq3->thirdpel_flag == !get_bits1 (&s->gb)) {
mode = HALFPEL_MODE;
} else {
mode = FULLPEL_MODE;
}
for (m = 0; m < 2; m++) {
if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) {
for (i = 0; i < 4; i++) {
*(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride];
}
} else {
for (i = 0; i < 4; i++) {
*(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0;
}
}
if (s->mb_y > 0) {
memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));
memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
if (s->mb_x < (s->mb_width - 1)) {
*(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4];
h->ref_cache[m][scan8[0] + 4 - 1*8] =
(h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 ||
h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride ] ] == -1) ? PART_NOT_AVAILABLE : 1;
}else
h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;
if (s->mb_x > 0) {
*(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1];
h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1;
}else
h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE;
}else
memset(&h->ref_cache[m][scan8[0] - 1*8 - 1], PART_NOT_AVAILABLE, 8);
if (s->pict_type != AV_PICTURE_TYPE_B)
break;
}
if (s->pict_type == AV_PICTURE_TYPE_P) {
if (svq3_mc_dir(h, (mb_type - 1), mode, 0, 0) < 0)
return -1;
} else {
if (mb_type != 2) {
if (svq3_mc_dir(h, 0, mode, 0, 0) < 0)
return -1;
} else {
for (i = 0; i < 4; i++) {
memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
}
}
if (mb_type != 1) {
if (svq3_mc_dir(h, 0, mode, 1, (mb_type == 3)) < 0)
return -1;
} else {
for (i = 0; i < 4; i++) {
memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
}
}
}
mb_type = MB_TYPE_16x16;
} else if (mb_type == 8 || mb_type == 33) {
memset(h->intra4x4_pred_mode_cache, -1, 8*5*sizeof(int8_t));
if (mb_type == 8) {
if (s->mb_x > 0) {
for (i = 0; i < 4; i++) {
h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6-i];
}
if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) {
h->left_samples_available = 0x5F5F;
}
}
if (s->mb_y > 0) {
h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+0];
h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+1];
h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+2];
h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+3];
if (h->intra4x4_pred_mode_cache[4+8*0] == -1) {
h->top_samples_available = 0x33FF;
}
}
for (i = 0; i < 16; i+=2) {
vlc = svq3_get_ue_golomb(&s->gb);
if (vlc >= 25){
av_log(h->s.avctx, AV_LOG_ERROR, "luma prediction:%d\n", vlc);
return -1;
}
left = &h->intra4x4_pred_mode_cache[scan8[i] - 1];
top = &h->intra4x4_pred_mode_cache[scan8[i] - 8];
left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]];
left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]];
if (left[1] == -1 || left[2] == -1){
av_log(h->s.avctx, AV_LOG_ERROR, "weird prediction\n");
return -1;
}
}
} else {
for (i = 0; i < 4; i++) {
memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_PRED, 4);
}
}
write_back_intra_pred_mode(h);
if (mb_type == 8) {
ff_h264_check_intra4x4_pred_mode(h);
h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
} else {
for (i = 0; i < 4; i++) {
memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_128_PRED, 4);
}
h->top_samples_available = 0x33FF;
h->left_samples_available = 0x5F5F;
}
mb_type = MB_TYPE_INTRA4x4;
} else {
dir = i_mb_type_info[mb_type - 8].pred_mode;
dir = (dir >> 1) ^ 3*(dir & 1) ^ 1;
if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir)) == -1){
av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n");
return -1;
}
cbp = i_mb_type_info[mb_type - 8].cbp;
mb_type = MB_TYPE_INTRA16x16;
}
if (!IS_INTER(mb_type) && s->pict_type != AV_PICTURE_TYPE_I) {
for (i = 0; i < 4; i++) {
memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
}
if (s->pict_type == AV_PICTURE_TYPE_B) {
for (i = 0; i < 4; i++) {
memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
}
}
}
if (!IS_INTRA4x4(mb_type)) {
memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy], DC_PRED, 8);
}
if (!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B) {
memset(h->non_zero_count_cache + 8, 0, 14*8*sizeof(uint8_t));
s->dsp.clear_blocks(h->mb+ 0);
s->dsp.clear_blocks(h->mb+384);
}
if (!IS_INTRA16x16(mb_type) && (!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B)) {
if ((vlc = svq3_get_ue_golomb(&s->gb)) >= 48){
av_log(h->s.avctx, AV_LOG_ERROR, "cbp_vlc=%d\n", vlc);
return -1;
}
cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc] : golomb_to_inter_cbp[vlc];
}
if (IS_INTRA16x16(mb_type) || (s->pict_type != AV_PICTURE_TYPE_I && s->adaptive_quant && cbp)) {
s->qscale += svq3_get_se_golomb(&s->gb);
if (s->qscale > 31){
av_log(h->s.avctx, AV_LOG_ERROR, "qscale:%d\n", s->qscale);
return -1;
}
}
if (IS_INTRA16x16(mb_type)) {
AV_ZERO128(h->mb_luma_dc[0]+0);
AV_ZERO128(h->mb_luma_dc[0]+8);
if (svq3_decode_block(&s->gb, h->mb_luma_dc, 0, 1)){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\n");
return -1;
}
}
if (cbp) {
const int index = IS_INTRA16x16(mb_type) ? 1 : 0;
const int type = ((s->qscale < 24 && IS_INTRA4x4(mb_type)) ? 2 : 1);
for (i = 0; i < 4; i++) {
if ((cbp & (1 << i))) {
for (j = 0; j < 4; j++) {
k = index ? ((j&1) + 2*(i&1) + 2*(j&2) + 4*(i&2)) : (4*i + j);
h->non_zero_count_cache[ scan8[k] ] = 1;
if (svq3_decode_block(&s->gb, &h->mb[16*k], index, type)){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding block\n");
return -1;
}
}
}
}
if ((cbp & 0x30)) {
for (i = 1; i < 3; ++i) {
if (svq3_decode_block(&s->gb, &h->mb[16*16*i], 0, 3)){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma dc block\n");
return -1;
}
}
if ((cbp & 0x20)) {
for (i = 1; i < 3; i++) {
for (j = 0; j < 4; j++) {
k = 16*i + j;
h->non_zero_count_cache[ scan8[k] ] = 1;
if (svq3_decode_block(&s->gb, &h->mb[16*k], 1, 1)){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma ac block\n");
return -1;
}
}
}
}
}
}
h->cbp= cbp;
s->current_picture.f.mb_type[mb_xy] = mb_type;
if (IS_INTRA(mb_type)) {
h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8);
}
return 0;
}
| 1threat
|
static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start)
{
int err;
union {
uint64_t u64;
uint8_t u8[8];
} tmp = { av_be2ne64(state) };
AC3HeaderInfo hdr, *phdr = &hdr;
GetBitContext gbc;
init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54);
err = avpriv_ac3_parse_header2(&gbc, &phdr);
if(err < 0)
return 0;
hdr_info->sample_rate = hdr.sample_rate;
hdr_info->bit_rate = hdr.bit_rate;
hdr_info->channels = hdr.channels;
hdr_info->channel_layout = hdr.channel_layout;
hdr_info->samples = hdr.num_blocks * 256;
hdr_info->service_type = hdr.bitstream_mode;
if (hdr.bitstream_mode == 0x7 && hdr.channels > 1)
hdr_info->service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
if(hdr.bitstream_id>10)
hdr_info->codec_id = AV_CODEC_ID_EAC3;
else if (hdr_info->codec_id == AV_CODEC_ID_NONE)
hdr_info->codec_id = AV_CODEC_ID_AC3;
*need_next_header = (hdr.frame_type != EAC3_FRAME_TYPE_AC3_CONVERT);
*new_frame_start = (hdr.frame_type != EAC3_FRAME_TYPE_DEPENDENT);
return hdr.frame_size;
}
| 1threat
|
How to reference an instance of another class? : <p>sorry for the stupid question but I really cant solve it myself and can't find a fitting solution.</p>
<p>I have multiple classes: MusicCollection,Albums and Songs. In each is an ArrayList and a bunch of methods to store new albums via a GUI class. Now I built anoter class Playlist with a LinkedList that should be able to get songs from albums .</p>
<p>In the GUI class I create an instance of MusicCollection to add albums and songs and use the methods of these classes. </p>
<p>To add songs to the playlist I create an instance of Playlist in the GUI class. This instance of Playlist needs to have access to the instance of MusicCollection to get its songs. How can I solve this? I tried to make the instance of the MusicCollection public, didn't work, I tried to call it over the getter, didn't work either.</p>
<p>If I make a new instance of MusicCollection within the PlayList Class it's empty of course :-/</p>
<p>Can anybody help me? </p>
<p>Thanks in advance!</p>
| 0debug
|
static const uint8_t *parse_opus_ts_header(const uint8_t *start, int *payload_len, int buf_len)
{
const uint8_t *buf = start + 1;
int start_trim_flag, end_trim_flag, control_extension_flag, control_extension_length;
uint8_t flags;
GetByteContext gb;
bytestream2_init(&gb, buf, buf_len);
flags = bytestream2_get_byte(&gb);
start_trim_flag = (flags >> 4) & 1;
end_trim_flag = (flags >> 3) & 1;
control_extension_flag = (flags >> 2) & 1;
*payload_len = 0;
while (bytestream2_peek_byte(&gb) == 0xff)
*payload_len += bytestream2_get_byte(&gb);
*payload_len += bytestream2_get_byte(&gb);
if (start_trim_flag)
bytestream2_skip(&gb, 2);
if (end_trim_flag)
bytestream2_skip(&gb, 2);
if (control_extension_flag) {
control_extension_length = bytestream2_get_byte(&gb);
bytestream2_skip(&gb, control_extension_length);
}
return buf + bytestream2_tell(&gb);
}
| 1threat
|
In Pandas, whats the equivalent of 'nrows' from read_csv() to be used in read_excel()? : <p>Want to import only certain range of data from an excel spreadsheet (.xlsm format as it has macros) into a pandas dataframe.
Was doing it this way:</p>
<pre><code>data = pd.read_excel(filepath, header=0, skiprows=4, nrows= 20, parse_cols = "A:D")
</code></pre>
<p>But it seems that nrows works only with read_csv() ?
What would be the equivalent for read_excel()?</p>
| 0debug
|
VBA Excel - Pop up message when value between two values : <p>I am looking for a code that will pop up a message box when a value (ie in cell A1) is not between the value of two seperated cell values.
For instance, display a pop message when the value A1 is lower than A2 or if higher then A3;
Can anyone help me with this one?
Thx in adv;
Brgds, Jimmy</p>
| 0debug
|
void qmp_block_job_pause(const char *device, Error **errp)
{
BlockJob *job = find_block_job(device);
if (!job) {
error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
return;
}
trace_qmp_block_job_pause(job);
block_job_pause(job);
}
| 1threat
|
Automation using selenium (java) : <p>I want to check if my filter is resulting into empty grid(not rows). The GUI doesn't have any table to check empty rows. It's getting data at run time. Can somebody please help? Thanks.</p>
| 0debug
|
what is the difference between the 2 cases; in java strings? : <p>why do these statements give different answers?</p>
<pre><code>String s1="hello world";
String s2="hello world";
System.out.println(s1.equals(s2));//true
System.out.println(s1 == s2);//true
</code></pre>
<p>2nd case;</p>
<pre><code>String s1=new String("hello world");
String s2=new String("hello world");
System.out.println(s1.equals(s2));//true
System.out.println(s1 == s2);//false
</code></pre>
| 0debug
|
What really is constant? Definition : <p>I'm getting a little confused about constant. It says here in Programming Principles and Practice Using C++ book that you cannot give a new value to constant.</p>
<pre><code>constexpr int max = 17;
int val = 19;
max+2
</code></pre>
<p>but this code is confusing me. max+2, that means the max will have a new value, 19, so what really is constant? how come you can add 2 to a constant?</p>
| 0debug
|
I must make a bootstrap page : I must urgently make a webpage using Bootstrap.
These are the requirements:
"1 page in bootstrap. We have attached a hand made sketch. The page will have a list. In each list, there will be a title, 8 text fields in the group of 2 divided into 4 parts. For example, FirstName: Oracle(2 fields), LastName: Maven (2 fields), and so on, an image slider, which can have minimum 1 and maximum 3 images in it. We can view the image on big scale and zoom in zoom out the image. Below the slider will be Approve and Reject button which will be visible ONLY at the last Image. The right side of the section will contain 11 Input fields along with the labels. all are optional. Below the 11 fields will be a submit button. This will repeat like a list."
This is the sketch: https://i.stack.imgur.com/q2z1r.jpg
I don't understand how to do the lists.
I would be very grateful if you could help me.
| 0debug
|
Access to headers in request-promise get response : <p>I am complete newbie to JS world. I am trying to write a test case that tests user's actions on a site. I am using request-promise module to test the asyn calls. I could not find any api documentation for request-promise.
How do I get access to status code of the response? Right now it prints undefined. Also, can anyone please confirm, how do we know what promise returns when it is successful, is it a single value that it resolves to or all the parameters that the async function returns. How do we know what are the parameters to function() in <code>request.get(base_url).then(function(response, body)</code>. </p>
<pre><code>var request = require("request-promise");
var promise = require("bluebird");
//
var base_url = "https://mysignin.com/"
//
describe("My first test", function() {
it("User is on the sign in page", function(done) {
request.get(base_url).then(function(response, body){
// expect(response.statusCode).toBe('GET /200');
console.log("respnse " + response.statusCode);
console.log("Body " + body);
done();
}).catch(function(error) {
done("Oops somthing went wrong!!");
});
});
});
</code></pre>
| 0debug
|
TGraphic.Draw(Canvas, Rect) does not work : I need to insert an image into an ImageList. The image is in a descendant of TGraphicControl (see source code below). The insertion seems to work. However, I get only a white rectangle in the ImageList:
function InsertCloudImageIntoImageList(AdvCloudImage1: TAdvCloudImage): Integer;
// TAdvCloudImage = class(TGraphicControl)
// WebPicture is TCloudPicture = class(TGraphic)
var
TempBitmap: TBitmap;
R: TRect;
begin
Result := 0;
TempBitmap := TBitmap.Create;
try
TempBitmap.SetSize(16, 16);
R.Width := 16;
R.Height := 16;
R.Top := 0;
R.Left := 0;
AdvCloudImage1.WebPicture.Draw(TempBitmap.Canvas, R);
Result := Form1.ImageList1.Add(TempBitmap, nil);
finally
TempBitmap.Free;
end;
end;
I suspect the bug is in the drawing on the bitmap canvas?
| 0debug
|
void ff_hevcdsp_init_x86(HEVCDSPContext *c, const int bit_depth)
{
int mm_flags = av_get_cpu_flags();
if (bit_depth == 8) {
if (EXTERNAL_MMX(mm_flags)) {
if (EXTERNAL_MMXEXT(mm_flags)) {
if (EXTERNAL_SSSE3(mm_flags) && ARCH_X86_64) {
EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 8);
EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 8);
EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 8);
EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 8);
QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 8);
QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 8);
QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 8);
QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 8);
}
}
}
} else if (bit_depth == 10) {
if (EXTERNAL_MMX(mm_flags)) {
if (EXTERNAL_MMXEXT(mm_flags) && ARCH_X86_64) {
if (EXTERNAL_SSSE3(mm_flags)) {
EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 10);
EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 10);
EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 10);
EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 10);
QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 10);
QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 10);
QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 10);
QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 10);
}
}
}
}
}
| 1threat
|
Which is better Mysql vs Mysqli in php : <p><strong>which is better to use Mysql or Mysqli and in what conditions?</strong>
I want to start a project that requires a database just wanted to know which of the two is better</p>
| 0debug
|
static void vnc_client_read(VncState *vs)
{
ssize_t ret;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn && vs->sasl.runSSF)
ret = vnc_client_read_sasl(vs);
else
#endif
ret = vnc_client_read_plain(vs);
if (!ret) {
if (vs->disconnecting) {
vnc_disconnect_finish(vs);
}
return;
}
while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {
size_t len = vs->read_handler_expect;
int ret;
ret = vs->read_handler(vs, vs->input.buffer, len);
if (vs->disconnecting) {
vnc_disconnect_finish(vs);
return;
}
if (!ret) {
buffer_advance(&vs->input, len);
} else {
vs->read_handler_expect = ret;
}
}
}
| 1threat
|
Python: setting type of numpy structure array : I have a numpy structured array where I need to control the data types of the individual elements.
This is my example:
y
array([(True, 144.0), (True, 86.0), (True, 448.0), (True, 76.0),
(True, 511.0), (True, 393.0), (False, 466.0), (False, 470.0),
(True, 493.0), (True, 8.0), (True, 123.0), (True, 1439.0),
(True, 3.0), (True, 691.0), (True, 989.0), (True, 320.0),
(True, 570.0), (True, 702.0), (True, 327.0), (True, 280.0),
(True, 71.0), (True, 359.0), (True, 389.0), (True, 263.0),
(True, 97.0), (True, 166.0), (True, 161.0), (True, 579.0),
(True, 95.0), (True, 396.0), (True, 7.0), (True, 67.0),
(True, 1228.0), (False, 2246.0), (True, 801.0), (True, 866.0),
(True, 454.0), (True, 313.0), (True, 557.0), (True, 214.0),
(True, 119.0), (True, 151.0), (True, 360.0), (True, 6.0),
(True, 378.0), (True, 684.0), (True, 11.0), (True, 548.0),
(True, 315.0), (True, 359.0), (True, 455.0), (True, 375.0),
(True, 98.0), (True, 136.0), (True, 294.0), (True, 62.0),
(True, 717.0), (True, 286.0), (True, 679.0), (True, 595.0),
(True, 164.0), (True, 82.0), (True, 66.0), (True, 28.0),
(False, 1322.0), (False, 1405.0), (True, 204.0), (False, 218.0),
(True, 699.0), (True, 178.0), (True, 165.0), (True, 637.0),
(True, 226.0), (True, 109.0), (True, 815.0), (True, 263.0),
(True, 240.0), (True, 414.0), (False, 1031.0), (True, 33.0),
(True, 23.0), (True, 150.0), (True, 282.0), (True, 86.0),
(False, 932.0), (False, 181.0), (True, 207.0), (True, 182.0),
(True, 133.0), (False, 13.0), (False, 958.0), (True, 342.0),
(True, 108.0), (True, 254.0), (True, 138.0), (False, 268.0),
(False, 273.0), (False, 260.0), (False, 204.0), (False, 155.0),
(True, 83.0), (True, 114.0), (False, 187.0), (False, 139.0),
(True, 120.0), (False, 237.0), (True, 164.0), (True, 15.0),
(True, 224.0), (False, 253.0), (False, 391.0), (False, 145.0),
(False, 47.0), (False, 145.0), (False, 151.0), (False, 815.0),
(True, 164.0), (False, 539.0), (True, 478.0), (True, 426.0),
(True, 439.0), (True, 50.0), (True, 316.0), (True, 2005.0),
(True, 3.0), (True, 1161.0), (True, 790.0), (True, 734.0),
(True, 186.0), (True, 80.0), (True, 0.0), (True, 1311.0),
(True, 167.0), (True, 452.0), (True, 2791.0), (True, 754.0),
(True, 562.0), (True, 323.0), (True, 715.0), (True, 845.0),
(True, 1179.0), (True, 272.0), (True, 626.0), (True, 3881.0),
(True, 177.0), (True, 658.0), (True, 364.0), (True, 427.0),
(True, 287.0), (True, 769.0), (True, 414.0), (True, 195.0),
(True, 1807.0), (True, 1315.0), (True, 784.0), (True, 351.0),
(True, 333.0), (True, 358.0), (True, 1050.0), (True, 357.0),
(True, 399.0), (True, 98.0), (True, 62.0), (True, 460.0),
(True, 364.0), (True, 29.0), (True, 701.0), (True, 68.0),
(True, 342.0), (True, 419.0), (True, 99.0), (True, 41.0),
(True, 164.0), (True, 88.0), (True, 502.0), (True, 801.0),
(True, 62.0), (True, 880.0), (True, 485.0), (True, 587.0),
(True, 24.0), (True, 42.0), (True, 34.0), (False, 1788.0),
(True, 703.0), (True, 35.0), (True, 28.0), (False, 1246.0),
(True, 187.0), (True, 30.0), (True, 60.0), (True, 541.0),
(True, 543.0), (True, 179.0), (False, 218.0), (True, 532.0),
(True, 12.0), (False, 115.0), (False, 104.0), (False, 581.0),
(True, 119.0), (True, 302.0), (False, 793.0), (True, 496.0),
(False, 131.0), (True, 883.0), (False, 195.0), (True, 666.0),
(True, 327.0), (True, 276.0), (False, 181.0), (True, 394.0),
(True, 141.0), (True, 772.0), (False, 218.0), (True, 385.0),
(True, 112.0), (True, 99.0), (True, 154.0), (False, 4.0),
(False, 294.0), (True, 148.0), (True, 33.0), (False, 229.0),
(True, 5.0), (True, 124.0), (True, 501.0), (True, 213.0),
(False, 214.0), (False, 137.0), (True, 202.0), (True, 343.0),
(True, 244.0), (True, 567.0), (True, 144.0), (True, 242.0),
(True, 54.0), (True, 198.0), (True, 164.0), (True, 161.0),
(True, 165.0), (False, 541.0), (False, 868.0), (False, 953.0),
(True, 285.0), (False, 286.0), (False, 452.0), (False, 167.0),
(True, 37.0), (False, 48.0), (False, 241.0), (False, 71.0),
(False, 588.0), (True, 146.0), (True, 505.0), (True, 0.0),
(True, 555.0), (True, 1008.0), (True, 648.0), (True, 427.0),
(True, 350.0), (True, 753.0), (True, 316.0), (True, 316.0),
(True, 489.0), (True, 231.0), (True, 87.0), (True, 438.0),
(True, 480.0), (False, 345.0), (False, 6.0), (True, 77.0),
(False, 280.0), (False, 254.0), (False, 232.0), (False, 258.0),
(False, 37.0), (True, 47.0), (False, 4.0), (False, 143.0),
(False, 95.0), (False, 20.0), (False, 205.0), (False, 145.0),
(False, 222.0), (False, 160.0), (True, 275.0), (True, 474.0),
(False, 77.0), (False, 358.0), (False, 951.0), (True, 432.0),
(True, 237.0), (False, 415.0), (True, 128.0), (False, 690.0),
(True, 319.0), (True, 165.0), (True, 468.0), (True, 15.0),
(False, 3.0), (True, 593.0), (True, 36.0), (True, 142.0),
(True, 386.0), (True, 515.0), (True, 372.0), (True, 632.0),
(True, 457.0), (True, 485.0), (True, 224.0), (False, 693.0),
(True, 644.0), (False, 643.0), (True, 604.0), (True, 113.0),
(True, 383.0), (False, 604.0), (True, 330.0), (True, 323.0),
(True, 26.0), (True, 406.0), (False, 272.0), (True, 290.0),
(True, 30.0), (True, 135.0), (True, 360.0), (True, 6.0),
(True, 351.0), (True, 236.0), (False, 124.0), (False, 44.0),
(False, 778.0), (False, 636.0), (False, 132.0), (False, 436.0),
(False, 250.0), (False, 228.0), (True, 146.0), (True, 138.0),
(True, 535.0), (True, 94.0), (True, 111.0), (True, 279.0),
(True, 1458.0), (True, 77.0), (True, 328.0), (True, 508.0),
(True, 100.0), (True, 82.0), (True, 346.0), (True, 519.0),
(True, 254.0), (True, 638.0), (True, 147.0), (True, 153.0),
(True, 7.0), (True, 282.0), (True, 235.0), (False, 1101.0),
(False, 539.0), (False, 800.0), (False, 0.0)], dtype=object)
If I do:
print(y.dtype.fields)
I get back:
None
However, what I wanted was "bool" and "float".
If I access the individual elements, such as `y[0][0]` and `y[0][1]` I surely see that they are indeed bool and float.
I am super confused with this. Any ideas?
I need this because I use the packge "sciki-survival gradient boosting":https://scikit-survival.readthedocs.io/en/latest/generated/sksurv.ensemble.GradientBoostingSurvivalAnalysis.html#sksurv.ensemble.GradientBoostingSurvivalAnalysis.fit
Where the input needs to be a structured array of type "bool" and "float".
| 0debug
|
ES6 in JShint - .jshintrc has esversion, but still getting warning (using atom) : <p>I am using atom, and I've tried several different jshint packages and they all give a warning which says </p>
<pre><code>"template literal syntax' is only available in ES6 (use 'esversion: 6')"
</code></pre>
<p>I created a top level .jshintrc file (at root), and added the following json:</p>
<pre><code>{
"esversion":6
}
</code></pre>
<p>However, it is still throwing the same error. Any ideas how to resolve. I've included the link to the <a href="http://jshint.com/docs/options/" rel="noreferrer">JSHint options</a> page. I'd like to start playing around with ES6 syntax, but would prefer not to have extra warnings.</p>
<p>Thanks SO community!</p>
| 0debug
|
static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst,
const uint8_t *src, int w, int left)
{
int i;
if (s->bps <= 8) {
if (w < 32) {
for (i = 0; i < w; i++) {
const int temp = src[i];
dst[i] = temp - left;
left = temp;
}
return left;
} else {
for (i = 0; i < 32; i++) {
const int temp = src[i];
dst[i] = temp - left;
left = temp;
}
s->llvidencdsp.diff_bytes(dst + 32, src + 32, src + 31, w - 32);
return src[w-1];
}
} else {
const uint16_t *src16 = (const uint16_t *)src;
uint16_t *dst16 = ( uint16_t *)dst;
if (w < 32) {
for (i = 0; i < w; i++) {
const int temp = src16[i];
dst16[i] = temp - left;
left = temp;
}
return left;
} else {
for (i = 0; i < 16; i++) {
const int temp = src16[i];
dst16[i] = temp - left;
left = temp;
}
s->hencdsp.diff_int16(dst16 + 16, src16 + 16, src16 + 15, s->n - 1, w - 16);
return src16[w-1];
}
}
}
| 1threat
|
GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp)
{
if (!error_is_set(errp)) {
return v->next_list(v, list, errp);
}
return 0;
}
| 1threat
|
static int spapr_check_htab_fd(sPAPRMachineState *spapr)
{
int rc = 0;
if (spapr->htab_fd_stale) {
close(spapr->htab_fd);
spapr->htab_fd = kvmppc_get_htab_fd(false);
if (spapr->htab_fd < 0) {
error_report("Unable to open fd for reading hash table from KVM: "
"%s", strerror(errno));
rc = -1;
}
spapr->htab_fd_stale = false;
}
return rc;
}
| 1threat
|
Constructor in Java - Scanner Class : import java.util.Scanner;
public class Tutorials {
public static void main(String[] args) {
Car Vehicle = new Car();
Vehicle.supboys();
}
}
import java.util.Scanner;
public class Car {
private String Vehicle;
public Car(String name) {
Vehicle=name;
}
Car() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setName (String name) {
Vehicle=name;
}
public String getName (){
return Vehicle;
}
public void saying(){
System.out.printf("Vehicle Brand is called %s\n ", getName());
}
public void supboys() {
Scanner Boyz = new Scanner(System.in);
System.out.println ("Your New Car is " + Boyz);
}
}
I am new to programming so I wanted to some practise, regarding constructors. I wanted to try doing a scanner class for this program but cant seem to get it to work. The program does not give a proper error message to me either. Does anyone have any suggestions? (Apologies for the messy code)
| 0debug
|
static void escc_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
SerialState *serial = opaque;
ChannelState *s;
uint32_t saddr;
int newreg, channel;
val &= 0xff;
saddr = (addr >> serial->it_shift) & 1;
channel = (addr >> (serial->it_shift + 1)) & 1;
s = &serial->chn[channel];
switch (saddr) {
case SERIAL_CTRL:
trace_escc_mem_writeb_ctrl(CHN_C(s), s->reg, val & 0xff);
newreg = 0;
switch (s->reg) {
case W_CMD:
newreg = val & CMD_PTR_MASK;
val &= CMD_CMD_MASK;
switch (val) {
case CMD_HI:
newreg |= CMD_HI;
break;
case CMD_CLR_TXINT:
clr_txint(s);
break;
case CMD_CLR_IUS:
if (s->rxint_under_svc) {
s->rxint_under_svc = 0;
if (s->txint) {
set_txint(s);
}
} else if (s->txint_under_svc) {
s->txint_under_svc = 0;
}
escc_update_irq(s);
break;
default:
break;
}
break;
case W_INTR ... W_RXCTRL:
case W_SYNC1 ... W_TXBUF:
case W_MISC1 ... W_CLOCK:
case W_MISC2 ... W_EXTINT:
s->wregs[s->reg] = val;
break;
case W_TXCTRL1:
case W_TXCTRL2:
s->wregs[s->reg] = val;
escc_update_parameters(s);
break;
case W_BRGLO:
case W_BRGHI:
s->wregs[s->reg] = val;
s->rregs[s->reg] = val;
escc_update_parameters(s);
break;
case W_MINTR:
switch (val & MINTR_RST_MASK) {
case 0:
default:
break;
case MINTR_RST_B:
escc_reset_chn(&serial->chn[0]);
return;
case MINTR_RST_A:
escc_reset_chn(&serial->chn[1]);
return;
case MINTR_RST_ALL:
escc_reset(&serial->busdev.qdev);
return;
}
break;
default:
break;
}
if (s->reg == 0)
s->reg = newreg;
else
s->reg = 0;
break;
case SERIAL_DATA:
trace_escc_mem_writeb_data(CHN_C(s), val);
s->tx = val;
if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) {
if (s->chr)
qemu_chr_fe_write(s->chr, &s->tx, 1);
else if (s->type == kbd && !s->disabled) {
handle_kbd_command(s, val);
}
}
s->rregs[R_STATUS] |= STATUS_TXEMPTY;
s->rregs[R_SPEC] |= SPEC_ALLSENT;
set_txint(s);
break;
default:
break;
}
}
| 1threat
|
Visual Studio Code (Windows) Not Detecting Global NPM Modules : <p>I'm experiencing an issue where Visual Studio Code in Windows 10 is not able to detect globally installed NPM packages within the Integrated Terminal.</p>
<p>For example, if the windows command prompt I install <code>@angular/cli</code> via command <code>npm install -g @angular/cli</code>, within that command prompt I can execute @angular/cli commands such as <code>ng --version</code> without error. After that global npm module install, within Visual Studio Code, performing the same <code>ng --version</code> gives me the error:</p>
<blockquote>
<p>The term 'ng' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.</p>
</blockquote>
<p>I can however within the integrated terminal successfully perform commands such as <code>npm -v</code> and <code>node -v</code>.</p>
<p>I have the following items in my system environment variables</p>
<p><code>C:\Program Files\nodejs\</code></p>
<p><code>%AppData%\npm</code></p>
<p>Are there Visual Studio Code user or system environment variables I'm missing to allow detection of global npm modules?</p>
<p>Thank you for any help you can provide.</p>
| 0debug
|
Passing a listener to a custom Fragment in Android : <p>I'm creating a view pager in my app and using a class that extends Fragment on it. When I create an instance I can pass all the elements (an image, text, etc) and store it with the Bundle to use it in the onCreate. But I can't store a listener for the button in the fragment. Here is my class:</p>
<pre><code>public class RegWizardFragmentInfo extends Fragment {
private static final String IMAGE = "image";
private static final String TEXT = "text";
private static final String BUTTON = "buttonText";
private View.OnClickListener buttonCallBack;
private Button button;
private int image;
private int text;
private int buttonText;
public RegWizardFragmentInfo newInstance(int image, int text, int buttonText, View.OnClickListener callback) {
RegWizardFragmentInfo fragment = new RegWizardFragmentInfo();
Bundle bundle = new Bundle();
bundle.putInt(IMAGE, image);
bundle.putInt(BUTTON, buttonText);
bundle.putInt(TEXT, text);
fragment.setArguments(bundle);
fragment.setRetainInstance(true);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onActivityCreated(savedInstanceState);
this.image = getArguments().getInt(IMAGE);
this.text = (getArguments() != null) ? getArguments().getInt(TEXT)
: -1;
this.buttonText = (getArguments() != null) ? getArguments().getInt(BUTTON)
: -1;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(
R.layout.fragment, container, false);
//Extract all the views and add the image and texts
return rootView;
}
</code></pre>
<p>So, how can I store the listener that I get in the newInstance to add it to the button on the onCreateView method?</p>
<p>Thanks for the help.</p>
| 0debug
|
I can not have more than one attribute : Am trying to write "onClick" attribute to different classes using java script.
window.onload=function (){
document.getElementsByClassName("sg")[0].setAttribute("onClick", "ga('send', 'event', { eventCategory: 'Submit a form', eventAction: 'Click', eventLabel: 'Contact form submit'});");
document.getElementsByClassName("sm")[0].setAttribute("onClick", "ga('send', 'event', { eventCategory: 'Submit a form', eventAction: 'Click', eventLabel: 'Contact form submit'});");
}
The problem is adding an attribute is working only if the all classes were on one page like the code above.But if i want to have the same code on another page which have different classes then non of the code will work for the both pages. and i will have this error in the console(Cannot read property 'setAttribute' of undefined
at window.onload):
window.onload=function (){
document.getElementsByClassName("sg")[0].setAttribute("onClick", "ga('send', 'event', { eventCategory: 'Submit a form', eventAction: 'Click', eventLabel: 'Contact form submit'});");
document.getElementsByClassName("sm")[0].setAttribute("onClick", "ga('send', 'event', { eventCategory: 'Submit a form', eventAction: 'Click', eventLabel: 'Contact form submit'});");
document.getElementsByClassName("sf")[0].setAttribute("onClick", "ga('send', 'event', { eventCategory: 'Submit a form', eventAction: 'Click', eventLabel: 'Contact form submit'});");
}
| 0debug
|
Cannot read property 'bind' of undefined. React.js : <p>I'm making list using onsenui and react.
but I cannot call a bind from onchanged.</p>
<p>I couldn't figure out.... Does anyone can solve this?</p>
<p>this is my code.
I'd like to call handlechanged method from input item.
But then, Cannot read property 'bind' of undefined is raised.</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>export default class MainPage extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedValue: "myself",
destinations: ["myself","somebody"],
};
}
handleChange(value) {
this.setState({selectedValue: value});
}
renderRadioRow(row) {
return (
<ListItem key={row} tappable>
<label className='left'>
<Input
inputId={`radio-${row}`}
checked={row === this.selectedValue}
onChange={this.handleChange.bind(this, row)}
type='radio'
/>
</label>
<label htmlFor={`radio-${row}`} className='center'>
{row}
</label>
</ListItem>
)
}
render() {
return (
<Page renderToolbar={this.renderToolbar}>
<p style={{textAlign: 'center'}}>
test
</p>
<List
dataSource={this.state.destinations}
renderRow={this.renderRadioRow}
/>
</Page>
);
}
}</code></pre>
</div>
</div>
</p>
| 0debug
|
Why does just importing OpenCV cause massive CPU usage? : <p>I noticed something very odd in trying a motion detector for Raspberry Pi:</p>
<p>Removing the camera logging from the script, makes it use almost 0 CPU:</p>
<pre><code>#from gpiozero import MotionSensor
#import cv2
from datetime import datetime
from time import sleep
#camera = cv2.VideoCapture(0)
#pir = MotionSensor(4, queue_len=2, sample_rate=2, threshold=0.5)
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
PIR_PIN = 4
GPIO.setup(PIR_PIN, GPIO.IN)
while True:
sleep(1)
if GPIO.input(PIR_PIN):
print( "detected!")
filename = 'motionpics/' + datetime.now().strftime("%Y-%m-%d_%H.%M.%S.jpg")
#ret, frame = camera.read()
#cv2.imwrite(filename, frame)
#camera.release()
#pir.wait_for_no_motion()
</code></pre>
<p>However, uncommenting <em>just one line - the import cv2</em>, makes this script go to 300% CPU Usage!!</p>
<p>What is wrong with OpenCV and why can't I even start to use it to grab usb camera images without it using a bunch of cpu, and wearing down the battery?</p>
| 0debug
|
static AHCIQState *ahci_boot_and_enable(void)
{
AHCIQState *ahci;
ahci = ahci_boot();
ahci_pci_enable(ahci);
ahci_hba_enable(ahci);
return ahci;
}
| 1threat
|
static int decode_slice_header(H264Context *h){
MpegEncContext * const s = &h->s;
int first_mb_in_slice, pps_id;
int num_ref_idx_active_override_flag;
static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
int slice_type;
int default_ref_list_done = 0;
s->current_picture.reference= h->nal_ref_idc != 0;
s->dropable= h->nal_ref_idc == 0;
first_mb_in_slice= get_ue_golomb(&s->gb);
slice_type= get_ue_golomb(&s->gb);
if(slice_type > 9){
av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
return -1;
}
if(slice_type > 4){
slice_type -= 5;
h->slice_type_fixed=1;
}else
h->slice_type_fixed=0;
slice_type= slice_type_map[ slice_type ];
if (slice_type == I_TYPE
|| (h->slice_num != 0 && slice_type == h->slice_type) ) {
default_ref_list_done = 1;
}
h->slice_type= slice_type;
s->pict_type= h->slice_type;
pps_id= get_ue_golomb(&s->gb);
if(pps_id>255){
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
return -1;
}
h->pps= h->pps_buffer[pps_id];
if(h->pps.slice_group_count == 0){
av_log(h->s.avctx, AV_LOG_ERROR, "non existing PPS referenced\n");
return -1;
}
h->sps= h->sps_buffer[ h->pps.sps_id ];
if(h->sps.log2_max_frame_num == 0){
av_log(h->s.avctx, AV_LOG_ERROR, "non existing SPS referenced\n");
return -1;
}
if(h->dequant_coeff_pps != pps_id){
h->dequant_coeff_pps = pps_id;
init_dequant_tables(h);
}
s->mb_width= h->sps.mb_width;
s->mb_height= h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
h->b_stride= s->mb_width*4 + 1;
h->b8_stride= s->mb_width*2 + 1;
s->width = 16*s->mb_width - 2*(h->sps.crop_left + h->sps.crop_right );
if(h->sps.frame_mbs_only_flag)
s->height= 16*s->mb_height - 2*(h->sps.crop_top + h->sps.crop_bottom);
else
s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom);
if (s->context_initialized
&& ( s->width != s->avctx->width || s->height != s->avctx->height)) {
free_tables(h);
MPV_common_end(s);
}
if (!s->context_initialized) {
if (MPV_common_init(s) < 0)
return -1;
if(s->dsp.h264_idct_add == ff_h264_idct_add_c){
memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
memcpy(h-> field_scan, field_scan, 16*sizeof(uint8_t));
}else{
int i;
for(i=0; i<16; i++){
#define T(x) (x>>2) | ((x<<2) & 0xF)
h->zigzag_scan[i] = T(zigzag_scan[i]);
h-> field_scan[i] = T( field_scan[i]);
}
}
if(h->sps.transform_bypass){
h->zigzag_scan_q0 = zigzag_scan;
h->field_scan_q0 = field_scan;
}else{
h->zigzag_scan_q0 = h->zigzag_scan;
h->field_scan_q0 = h->field_scan;
}
alloc_tables(h);
s->avctx->width = s->width;
s->avctx->height = s->height;
s->avctx->sample_aspect_ratio= h->sps.sar;
if(!s->avctx->sample_aspect_ratio.den)
s->avctx->sample_aspect_ratio.den = 1;
if(h->sps.timing_info_present_flag){
s->avctx->time_base= (AVRational){h->sps.num_units_in_tick, h->sps.time_scale};
}
}
if(h->slice_num == 0){
frame_start(h);
}
s->current_picture_ptr->frame_num=
h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num);
h->mb_aff_frame = 0;
if(h->sps.frame_mbs_only_flag){
s->picture_structure= PICT_FRAME;
}else{
if(get_bits1(&s->gb)) {
s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb);
} else {
s->picture_structure= PICT_FRAME;
first_mb_in_slice <<= h->sps.mb_aff;
h->mb_aff_frame = h->sps.mb_aff;
}
}
s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
s->resync_mb_y = s->mb_y = first_mb_in_slice / s->mb_width;
if(s->mb_y >= s->mb_height){
return -1;
}
if(s->picture_structure==PICT_FRAME){
h->curr_pic_num= h->frame_num;
h->max_pic_num= 1<< h->sps.log2_max_frame_num;
}else{
h->curr_pic_num= 2*h->frame_num;
h->max_pic_num= 1<<(h->sps.log2_max_frame_num + 1);
}
if(h->nal_unit_type == NAL_IDR_SLICE){
get_ue_golomb(&s->gb);
}
if(h->sps.poc_type==0){
h->poc_lsb= get_bits(&s->gb, h->sps.log2_max_poc_lsb);
if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME){
h->delta_poc_bottom= get_se_golomb(&s->gb);
}
}
if(h->sps.poc_type==1 && !h->sps.delta_pic_order_always_zero_flag){
h->delta_poc[0]= get_se_golomb(&s->gb);
if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME)
h->delta_poc[1]= get_se_golomb(&s->gb);
}
init_poc(h);
if(h->pps.redundant_pic_cnt_present){
h->redundant_pic_count= get_ue_golomb(&s->gb);
}
h->ref_count[0]= h->pps.ref_count[0];
h->ref_count[1]= h->pps.ref_count[1];
if(h->slice_type == P_TYPE || h->slice_type == SP_TYPE || h->slice_type == B_TYPE){
if(h->slice_type == B_TYPE){
h->direct_spatial_mv_pred= get_bits1(&s->gb);
}
num_ref_idx_active_override_flag= get_bits1(&s->gb);
if(num_ref_idx_active_override_flag){
h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
if(h->slice_type==B_TYPE)
h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
return -1;
}
}
}
if(!default_ref_list_done){
fill_default_ref_list(h);
}
if(decode_ref_pic_list_reordering(h) < 0)
return -1;
if( (h->pps.weighted_pred && (h->slice_type == P_TYPE || h->slice_type == SP_TYPE ))
|| (h->pps.weighted_bipred_idc==1 && h->slice_type==B_TYPE ) )
pred_weight_table(h);
else if(h->pps.weighted_bipred_idc==2 && h->slice_type==B_TYPE)
implicit_weight_table(h);
else
h->use_weight = 0;
if(s->current_picture.reference)
decode_ref_pic_marking(h);
if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE && h->pps.cabac )
h->cabac_init_idc = get_ue_golomb(&s->gb);
h->last_qscale_diff = 0;
s->qscale = h->pps.init_qp + get_se_golomb(&s->gb);
if(s->qscale<0 || s->qscale>51){
av_log(s->avctx, AV_LOG_ERROR, "QP %d out of range\n", s->qscale);
return -1;
}
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
if(h->slice_type == SP_TYPE){
get_bits1(&s->gb);
}
if(h->slice_type==SP_TYPE || h->slice_type == SI_TYPE){
get_se_golomb(&s->gb);
}
h->deblocking_filter = 1;
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if( h->pps.deblocking_filter_parameters_present ) {
h->deblocking_filter= get_ue_golomb(&s->gb);
if(h->deblocking_filter < 2)
h->deblocking_filter^= 1;
if( h->deblocking_filter ) {
h->slice_alpha_c0_offset = get_se_golomb(&s->gb) << 1;
h->slice_beta_offset = get_se_golomb(&s->gb) << 1;
}
}
if( s->avctx->skip_loop_filter >= AVDISCARD_ALL
||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && h->slice_type != I_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && h->slice_type == B_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
h->deblocking_filter= 0;
#if 0
if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5)
slice_group_change_cycle= get_bits(&s->gb, ?);
#endif
h->slice_num++;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
h->slice_num,
(s->picture_structure==PICT_FRAME ? "F" : s->picture_structure==PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_pict_type_char(h->slice_type),
pps_id, h->frame_num,
s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],
h->ref_count[0], h->ref_count[1],
s->qscale,
h->deblocking_filter, h->slice_alpha_c0_offset/2, h->slice_beta_offset/2,
h->use_weight,
h->use_weight==1 && h->use_weight_chroma ? "c" : ""
);
}
return 0;
}
| 1threat
|
def comb_sort(nums):
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i+gaps]:
nums[i], nums[i+gaps] = nums[i+gaps], nums[i]
swapped = True
i += 1
return nums
| 0debug
|
SQLite App Crashing when I try to get data : When I click Show button, App will crash. I am following a guide and just changing names here and there but for some reason, it keeps crashing. please help me understand why this is happening.
This is my CustDbAdapter CODE:
public class CustDbAdapter {
public static final String CUST_TABLE_NAME = "customers";
public static final String _ID = "_id";
public static final String CUSTLNAME = "custlname";
public static final String CUSTFNAME = "custfname";
public static final String CUSTPHONE = "custphone";
private static final String DATABASE_NAME = "cool.db";
static final int CUSTBASE_VERSION = 1;
private static final String DATABASE_CREATE =
"CREATE TABLE " + CUST_TABLE_NAME + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ CUSTLNAME + " TEXT NOT NULL, "
+ CUSTFNAME + " TEXT NOT NULL, "
+ CUSTPHONE + " INTEGER NOT NULL, "
private CustDbHelper dbhelper;
private final Context context;
private SQLiteDatabase db;
public CustDbAdapter(Context c) {
this.context = c;
dbhelper = new CustDbHelper(context);
}
private static class CustDbHelper extends SQLiteOpenHelper {
CustDbHelper(Context context){
super(context, DATABASE_NAME, null, CUSTBASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db){
try{
db.execSQL(DATABASE_CREATE);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
Log.w(TAG, "Upgrading database from version " + oldVersion + " to"
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXIST " + CUST_TABLE_NAME);
onCreate(db);
}
}
public CustDbAdapter open() throws SQLException {
dbhelper = new CustDbHelper(context);
db = dbhelper.getWritableDatabase();
return this;
}
public void close(){
dbhelper.close();
}
public long addCustomer(String lname, String fname, int phone) {
ContentValues initialValues = new ContentValues();
initialValues.put(CUSTLNAME, lname);
initialValues.put(CUSTFNAME, fname);
initialValues.put(CUSTPHONE, phone);
return db.insert(CUST_TABLE_NAME, null, initialValues);
}
public Cursor getAllCustomer(){
return db.query(CUST_TABLE_NAME, new String[]{_ID, CUSTLNAME,
CUSTFNAME, CUSTPHONE}, null, null, null, null, null);
}
}
And This is CustFragment that calls the Apapter.
public class CustFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_util_cust, container, false);
return v;
}
@Override
public void onViewCreated(View v, @Nullable Bundle savedInstanceState) {
super.onViewCreated(v, savedInstanceState);
final Button btnShow = (Button)v.findViewById(R.id.b_utilcust_input);
final TextView txtOutput = (TextView)v.findViewById(R.id.t_utilcust_output);
final CustDbAdapter db = new CustDbAdapter(getActivity());
btnShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
db.open();
Cursor c = db.getAllCustomer();
if (c.moveToFirst()){
txtOutput.setText("Name - Phone \n");
c.moveToNext();
do {
DisplayContact(c);
} while (c.moveToNext());
}
db.close();
}
private void DisplayContact(Cursor c){
int idColumnIndex = c.getColumnIndex(CustDbAdapter._ID);
int lnameColumnIndex = c.getColumnIndex(CustDbAdapter.CUSTLNAME);
int fnameColumnIndex = c.getColumnIndex(CustDbAdapter.CUSTFNAME);
int phoneColumnIndex = c.getColumnIndex(CustDbAdapter.CUSTPHONE);
int currentID = c.getInt(idColumnIndex);
String currentLName = c.getString(lnameColumnIndex);
String currentFName = c.getString(fnameColumnIndex);
int currentPhone = c.getInt(phoneColumnIndex);
txtOutput.append("\n"
+ currentID + " - " + currentLName +", "+currentFName +" Phone:" + currentPhone);
}
});
}
}
| 0debug
|
PHP: How can I get the input of HTML time input : <p>I am new to PHP. I have a PHP file(form1.php) with an HTML form. I would like to get the value of an input box(type=time), save it to PHP variable and transfer it to another PHP page without clicking the submit button. How can I access the input and do this with just PHP, Can i trigger some event?</p>
<p>Form.php</p>
<pre><code> <?php
?>
<!doctype html>
<html lang="en">
<head>
<title>Form</title>
</head>
<body>
<form action="file2.php" method="post">
<input type="time" name="startTime">
</form>
</html>
</code></pre>
| 0debug
|
static int open_input_stream(HTTPContext *c, const char *info)
{
char buf[128];
char input_filename[1024];
AVFormatContext *s;
int buf_size, i, ret;
int64_t stream_pos;
if (c->stream->feed) {
strcpy(input_filename, c->stream->feed->feed_filename);
buf_size = FFM_PACKET_SIZE;
if (find_info_tag(buf, sizeof(buf), "date", info)) {
stream_pos = parse_date(buf, 0);
if (stream_pos == INT64_MIN)
return -1;
} else if (find_info_tag(buf, sizeof(buf), "buffer", info)) {
int prebuffer = strtol(buf, 0, 10);
stream_pos = av_gettime() - prebuffer * (int64_t)1000000;
} else
stream_pos = av_gettime() - c->stream->prebuffer * (int64_t)1000;
} else {
strcpy(input_filename, c->stream->feed_filename);
buf_size = 0;
if (find_info_tag(buf, sizeof(buf), "date", info)) {
stream_pos = parse_date(buf, 1);
if (stream_pos == INT64_MIN)
return -1;
} else
stream_pos = 0;
}
if (input_filename[0] == '\0')
return -1;
#if 0
{ time_t when = stream_pos / 1000000;
http_log("Stream pos = %"PRId64", time=%s", stream_pos, ctime(&when));
}
#endif
if ((ret = av_open_input_file(&s, input_filename, c->stream->ifmt,
buf_size, c->stream->ap_in)) < 0) {
http_log("could not open %s: %d\n", input_filename, ret);
return -1;
}
s->flags |= AVFMT_FLAG_GENPTS;
c->fmt_in = s;
av_find_stream_info(c->fmt_in);
for(i=0;i<s->nb_streams;i++)
open_parser(s, i);
c->pts_stream_index = 0;
for(i=0;i<c->stream->nb_streams;i++) {
if (c->pts_stream_index == 0 &&
c->stream->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) {
c->pts_stream_index = i;
}
}
#if 1
if (c->fmt_in->iformat->read_seek)
av_seek_frame(c->fmt_in, -1, stream_pos, 0);
#endif
c->start_time = cur_time;
c->first_pts = AV_NOPTS_VALUE;
return 0;
}
| 1threat
|
static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
{
if(st->codec->codec_id == CODEC_ID_PROBE){
AVProbeData *pd = &st->probe_data;
av_log(s, AV_LOG_DEBUG, "probing stream %d\n", st->index);
--st->probe_packets;
pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);
memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
pd->buf_size += pkt->size;
memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
if(av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){
set_codec_from_probe_data(s, st, pd, st->probe_packets > 0 ? AVPROBE_SCORE_MAX/4 : 0);
if(st->codec->codec_id != CODEC_ID_PROBE){
pd->buf_size=0;
av_freep(&pd->buf);
av_log(s, AV_LOG_DEBUG, "probed stream %d\n", st->index);
}
}
}
}
| 1threat
|
Cant use a Variable for both fields(Text and Selecteditem) : Wanted to use Disk.Diskvolume as a Global Variable so it contains the things from Listbox1, when making the same Variable as a text for a label It throws an error that says: "Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)"
I made a static class called Disk and included Diskvolume as a static object, I made it so it uses an item from a listbox1 whenever its index has changed, but it seems that it doesnt work for Label.text and when using a string it doesnt work with Listbox1.selectedItem
```
public partial class Form1 : Form
{
public static class Disk
{
public static string Diskvolume;
}
public Form1()
{
InitializeComponent();
}
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//The Labels Will Change depending on the Chosen DriveLetter
Disk.Diskvolume = ListBox1.SelectedItem;
Label2.Text = Disk.Diskvolume;
}
private void Button2_Click(object sender, EventArgs e)
{
}
}
```
I expected Disk.Diskvolume to work on both Listbox1.selecteditem and Label2.text.
My problems are particularly in Line 15 and 16 and it has to do with the the Public static.
| 0debug
|
Trouble with *ngIf in Angular 2 (TypeScript) : <p>I am using Angular 2 beta (TypeScript). I met a weird problem. I tried Chrome, Firefox, Opera, all same results.</p>
<p>When I click the "Toggle" button, it can successfully show/hide the text "Hello World!".</p>
<p>When I send the command from another browser using socket, the boolean "show" changes successfully background, however, the text does not show/hide, which looks like the page does not refresh.</p>
<pre><code>import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap';
import {NgIf} from 'angular2/common';
@Component({
selector: 'app'
})
@View({
directives: [NgIf],
template: `
<button (click)="clicked()">Toggle</button>
<div>
<div *ngIf="show">
<h2>Hello World!</h2>
</div>
</div>
`
})
class App {
show: boolean = true;
constructor() {
Socket.on {
If (getMessage) {
this.show = !this.show;
}
}
}
clicked() {
this.show = !this.show;
}
}
bootstrap(App);
</code></pre>
| 0debug
|
static int usb_serial_initfn(USBDevice *dev)
{
USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev);
s->dev.speed = USB_SPEED_FULL;
if (!s->cs) {
error_report("Property chardev is required");
return -1;
}
qemu_chr_add_handlers(s->cs, usb_serial_can_read, usb_serial_read,
usb_serial_event, s);
usb_serial_handle_reset(dev);
return 0;
}
| 1threat
|
How to round to 1 decimal place using Java : <p>I am trying to round to the nearest decimal value, however, this line of code keeps returning a number between 0 and 1, I also want the output to be between 1 and 10. Where am I going wrong?</p>
<pre><code>power[i] = rng.nextDouble();
</code></pre>
| 0debug
|
importing a method from a class in another code : <p>I want to import a specific method of a class in a file to another file of course in the same directory, so i tried this following way</p>
<pre class="lang-py prettyprint-override"><code>from file1 import Class1
from file1 import Class1.method
</code></pre>
<p>it doesn't work and it shows me a syntax error on the python kernel on the level of the dot between Class1 and method</p>
<p><code>SyntaxError: invalid syntax</code></p>
| 0debug
|
static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
int coded, int codingset, int mquant)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0;
int i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int a_avail = v->a_avail, c_avail = v->c_avail;
int use_pred = s->ac_pred;
int scale;
int q1, q2 = 0;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff) {
if (dcdiff == 119 ) {
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
} else {
if (mquant == 1)
dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
}
if (get_bits1(gb))
dcdiff = -dcdiff;
}
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
i = 1;
if (!a_avail && !c_avail)
use_pred = 0;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
scale = mquant * 2 + ((mquant == v->pq) ? v->halfpq : 0);
if (dc_pred_dir)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.f.qscale_table[mb_pos];
if ( dc_pred_dir && c_avail && mb_pos)
q2 = s->current_picture.f.qscale_table[mb_pos - 1];
if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)
q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
if ( dc_pred_dir && n == 1)
q2 = q1;
if (!dc_pred_dir && n == 2)
q2 = q1;
if (n == 3)
q2 = q1;
if (coded) {
int last = 0, skip, value;
const uint8_t *zz_table;
int k;
if (v->s.ac_pred) {
if (!use_pred && v->fcm == ILACE_FRAME) {
zz_table = v->zzi_8x8;
} else {
if (!dc_pred_dir)
zz_table = v->zz_8x8[2];
else
zz_table = v->zz_8x8[3];
}
} else {
if (v->fcm != ILACE_FRAME)
zz_table = v->zz_8x8[1];
else
zz_table = v->zzi_8x8;
}
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if (i > 63)
break;
block[zz_table[i++]] = value;
}
if (use_pred) {
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
if (dc_pred_dir) {
for (k = 1; k < 8; k++)
block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else {
for (k = 1; k < 8; k++)
block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if (dc_pred_dir) {
for (k = 1; k < 8; k++)
block[k << v->left_blk_sh] += ac_val[k];
} else {
for (k = 1; k < 8; k++)
block[k << v->top_blk_sh] += ac_val[k + 8];
}
}
}
for (k = 1; k < 8; k++) {
ac_val2[k ] = block[k << v->left_blk_sh];
ac_val2[k + 8] = block[k << v->top_blk_sh];
}
for (k = 1; k < 64; k++)
if (block[k]) {
block[k] *= scale;
if (!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if (use_pred) i = 63;
} else {
int k;
memset(ac_val2, 0, 16 * 2);
if (dc_pred_dir) {
if (use_pred) {
memcpy(ac_val2, ac_val, 8 * 2);
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
for (k = 1; k < 8; k++)
ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
} else {
if (use_pred) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
for (k = 1; k < 8; k++)
ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
}
if (use_pred) {
if (dc_pred_dir) {
for (k = 1; k < 8; k++) {
block[k << v->left_blk_sh] = ac_val2[k] * scale;
if (!v->pquantizer && block[k << v->left_blk_sh])
block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;
}
} else {
for (k = 1; k < 8; k++) {
block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
if (!v->pquantizer && block[k << v->top_blk_sh])
block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| 1threat
|
void migrate_decompress_threads_join(void)
{
int i, thread_count;
quit_decomp_thread = true;
thread_count = migrate_decompress_threads();
for (i = 0; i < thread_count; i++) {
qemu_mutex_lock(&decomp_param[i].mutex);
qemu_cond_signal(&decomp_param[i].cond);
qemu_mutex_unlock(&decomp_param[i].mutex);
}
for (i = 0; i < thread_count; i++) {
qemu_thread_join(decompress_threads + i);
qemu_mutex_destroy(&decomp_param[i].mutex);
qemu_cond_destroy(&decomp_param[i].cond);
g_free(decomp_param[i].compbuf);
}
g_free(decompress_threads);
g_free(decomp_param);
decompress_threads = NULL;
decomp_param = NULL;
}
| 1threat
|
static void rng_egd_finalize(Object *obj)
{
RngEgd *s = RNG_EGD(obj);
if (s->chr) {
qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, NULL);
}
g_free(s->chr_name);
rng_egd_free_requests(s);
}
| 1threat
|
static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
int64_t offset, unsigned int bytes, QEMUIOVector *qiov, int flags)
{
BlockDriver *drv = bs->drv;
BdrvTrackedRequest req;
int ret;
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;
assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
if (flags & BDRV_REQ_COPY_ON_READ) {
bs->copy_on_read_in_flight++;
}
if (bs->copy_on_read_in_flight) {
wait_for_overlapping_requests(bs, offset, bytes);
}
tracked_request_begin(&req, bs, offset, bytes, false);
if (flags & BDRV_REQ_COPY_ON_READ) {
int pnum;
ret = bdrv_is_allocated(bs, sector_num, nb_sectors, &pnum);
if (ret < 0) {
goto out;
}
if (!ret || pnum != nb_sectors) {
ret = bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors, qiov);
goto out;
}
}
if (!(bs->zero_beyond_eof && bs->growable)) {
ret = drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);
} else {
int64_t len, total_sectors, max_nb_sectors;
len = bdrv_getlength(bs);
if (len < 0) {
ret = len;
goto out;
}
total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
max_nb_sectors = MAX(0, total_sectors - sector_num);
if (max_nb_sectors > 0) {
ret = drv->bdrv_co_readv(bs, sector_num,
MIN(nb_sectors, max_nb_sectors), qiov);
} else {
ret = 0;
}
if (ret == 0 && total_sectors < sector_num + nb_sectors) {
uint64_t offset = MAX(0, total_sectors - sector_num);
uint64_t bytes = (sector_num + nb_sectors - offset) *
BDRV_SECTOR_SIZE;
qemu_iovec_memset(qiov, offset * BDRV_SECTOR_SIZE, 0, bytes);
}
}
out:
tracked_request_end(&req);
if (flags & BDRV_REQ_COPY_ON_READ) {
bs->copy_on_read_in_flight--;
}
return ret;
}
| 1threat
|
c# method with unlimited params or method with an array or list? : <p>I recently learned that you can create some method with unlimited parameters, for example:</p>
<pre><code>SomeMethod(params int[] numbers);
</code></pre>
<p>but my question is, what's the difference between that and just creating a method that receives a list or an array? </p>
<pre><code>SomeMethod(int[] numbers);
SomeMethod(List<int> numbers);
</code></pre>
<p>perhaps it has some impact in performance? I don't fully understand or see in what way you would prefer the one with unlimited parameters.</p>
<p>A quick search on google didn't help, I hope you could help me.</p>
| 0debug
|
Sequelize instance methods not working : <p>I am trying to use Sequelize's instance method to validate a password on login attempt.
I have defined the User model as :</p>
<pre><code>var User = sequelize.define('User',{
id:{
type:DataTypes.BIGINT,
autoIncrement: true,
allowNull: false,
primaryKey:true
},
username:{
type:DataTypes.STRING,
unique:true
},
password:{
type: DataTypes.STRING
},
...
},
{
classMethods:{
associate:function(models){
...
}
}
},
{
instanceMethods:{
validatePassword:function(password){
return bcrypt.compareSync(password, this.password);
}
}
}
);
return User;
}
</code></pre>
<p>In my login route I do the following :</p>
<ul>
<li>1) Retrieve username & password from request body </li>
<li>2) Check if username exists in database </li>
<li>3) If user exists, get user object and compare sent password with hashed password in database using validatePassword method.</li>
</ul>
<p>Here is the relevant code</p>
<pre><code>var username = req.body.username || "";
var password = req.body.password || "";
models.User.findOne({ where: {username: username} }).
then(
function(user) {
if(user){
console.log(user.validatePassword(password));
}
....
</code></pre>
<p>Each time I try to login I get the following error</p>
<pre><code>[TypeError: user.validatePassword is not a function]
</code></pre>
<p>What am I doing wrong? </p>
| 0debug
|
Fix incomplete character string for year "2016" from "0016" in R : <p>I've tried to find another question like this one but there doesn't seem to be one out there... My question is simple:</p>
<p>I have a data frame that looked like this but I want the format to read YYYY-MM-DD:</p>
<pre><code>> df$Date
Date
1 10/23/16
2 10/24/16
3 10/25/16
</code></pre>
<p>So I coded it up but it returned me this: </p>
<pre><code>df$Date <- strptime(as.character(df$Date), "%m/%d/%Y")
df$Date <- format(df$Date, "%Y-%m-%d")
> df$Date
Date
1 0016-10-23
2 0016-10-24
3 0016-10-25
</code></pre>
<p>Any ideas for how I can make the year 2016 instead of 0016?</p>
<p>Thanks! </p>
| 0debug
|
static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
{
CharDriverState *chr;
WinCharState *s;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(WinCharState));
s->hcom = fd_out;
chr->opaque = s;
chr->chr_write = win_chr_write;
return chr;
}
| 1threat
|
void ff_lzw_decode_tail(LZWState *p)
{
struct LZWState *s = (struct LZWState *)p;
while(!s->eob_reached)
lzw_get_code(s);
}
| 1threat
|
MySQL select where JSON field property has value : <p>How to write a basic MySQL query that has a WHERE on a property within a JSON data-type field? I don't see basic where clause q for json fields on SO.</p>
<p>Something like this, but of course these dont work:</p>
<pre><code>SELECT * from my_table where meta_data->name = 'bob';
SELECT * from my_table where meta_data[name] IS NOT NULL;
</code></pre>
| 0debug
|
static int usbnet_can_receive(VLANClientState *nc)
{
USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;
if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) {
return 1;
}
return !s->in_len;
}
| 1threat
|
text field in matrix layout in sap ui5 : i can not able to place text field in matrix layout please check below code and please suggest how to check xml code errors?
evary time i am stucking in design part with xml code please suggest me how to overcome that.
enter code here
<core:View xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:l="sap.ui.commons.layout"
controllerName="matrix.matrix"
xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="ytftfhgff">
<content>
<l:MatrixLayout layoutFixed="true" columns="4" width="600px"
widths="150px,150px,150px,150px">
<l:MatrixLayoutRow>
<l:MatrixLayoutCell colSpan="4">
<Text text="Its a heading" />
</l:MatrixLayoutCell>
</l:MatrixLayoutRow>
<l:MatrixLayoutRow>
<l:MatrixLayoutCell>
<Label text="First Name"/>
</l:MatrixLayoutCell>
<l:MatrixLayoutCell>
<TextField id="axscx" width="20em"></TextField>
</l:MatrixLayoutCell>
</l:MatrixLayoutRow>
</l:MatrixLayout>
</content>
</Page>
</core:View>
thanks in advance,
sriman.
| 0debug
|
making the xpath for dynamic button class where ID and name are present : below is the inspected content ,Kindly help me in locating the Checkout button.
<div class="col-xs-12 hidden-sm col-sm-6 top-padding-mini bottom-offset-mini">
<button ng-class="continueDellMetricsClass" ng-click="continueButtonClick()" ng-disabled="disableContinueButton" class="btn btn-success btn-block continueButton" data-testid="ContinueAction" data-metrics="" type="button">Submit Order</button>
</div>
| 0debug
|
Printing top n value with If-else condition using range() function in Python : I want to Print top 10 element from a list:
top=10
test=[1,1,1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(0,top):
if test[i]==1:
top=top+1
else:
print(test[i])
It is Printing:
2,3,4,5,6,7,8
I am expecting:
2,3,4,5,6,7,8,9,10,11
What i am missing
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.