problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
AVFilterBufferRef *ref)
{
AVFilterLink *outlink = ctx->outputs[0];
AVFilterBufferRef *buf;
int channels, data_size, i;
switch (outlink->type) {
case AVMEDIA_TYPE_VIDEO:
buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
ref->video->w, ref->video->h);
av_image_copy(buf->data, buf->linesize,
(void*)ref->data, ref->linesize,
ref->format, ref->video->w, ref->video->h);
break;
case AVMEDIA_TYPE_AUDIO:
buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
ref->audio->nb_samples);
channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
av_samples_copy(buf->extended_data, ref->buf->extended_data,
0, 0, ref->audio->nb_samples,
channels,
ref->format);
break;
default:
}
avfilter_copy_buffer_ref_props(buf, ref);
return buf;
}
| 1threat
|
Error 'Cannot Convert double to int' : <p>I have what seems to me as a weird issue with my code. I have a method that performs a simple query and returns the result. I'm trying to return the value as a double but I get an error:</p>
<blockquote>
<p>CS0266 Cannot implicitly convert type 'double' to 'int'. An explicit
conversion exists (are you missing a cast?)</p>
</blockquote>
<p>I'm not trying to do any conversions so I don't understand what the issue is.
Here is the calling code:</p>
<pre><code> double displacement = sqLite.GetDisplacement( transItem.Item.Name );
</code></pre>
<p>and here is the code that is called:</p>
<pre><code>public int GetDisplacement( string item )
{
double dDisposition = 0;
string sSql = "SELECT [Displacement] FROM [Items] WHERE [Name] = '" + item + "';";
using ( var dbConnection = new SQLiteConnection( sConnectionString ) )
{
try
{
dbConnection.Open();
SQLiteCommand cmd = new SQLiteCommand( sSql, dbConnection );
object result = cmd.ExecuteScalar();
dDisposition = Convert.ToDouble( result );
}
catch ( Exception e )
{
MessageBox.Show( "Error retreiving displacement information: " + e.ToString() );
}
}
return dDisposition; // This is where I get the error
}
</code></pre>
<p>I'm not trying to convert anything, everything is declared as a double. I've tried to clean and rebuild the solution several times to no avail. What am I missing?</p>
| 0debug
|
Quiz form design : this is milind and i'm trying to design form for quiz. I have 15 question in database. I want to display 10 question for user with shuffling. But i have 1 problem to set question sequentially.
My php code is
<form action="includes/backend_quiz.php" method="post">
<?php
$query=mysqli_query($conn, "SELECT * FROM quiz order by rand() LIMIT 10") or die("Could not retrieve data: " .mysqli_error($conn));
if (mysqli_num_rows($query) > 0){
while($row = mysqli_fetch_assoc($query)){
extract($row);
?>
<input type="hidden" name="id" value="<?php echo $id ?>" />
<h4><?php echo $id ?>.  <?php echo $quation; ?></h4><br />
<input type="radio" name="response" value="a" /> <?php echo $opt1;?><br />
<input type="radio" name="response" value="b" /> <?php echo $opt2;?><br />
<input type="radio" name="response" value="c" /> <?php echo $opt3;?><br />
<input type="radio" name="response" value="d" /> <?php echo $opt4;?><br />
<br />
<?php
}
}
?>
<input type="submit" name="ans" value="Finish"/>
</form>
Output:[My quiz output][1]
[1]: https://i.stack.imgur.com/q2mUf.png
So, how to set question sequentially like Q1. Q2. Q3. etc etc.
| 0debug
|
void do_commit(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
BlockDriverState *bs;
if (!strcmp(device, "all")) {
bdrv_commit_all();
} else {
bs = bdrv_find(device);
if (!bs) {
qerror_report(QERR_DEVICE_NOT_FOUND, device);
return;
}
bdrv_commit(bs);
}
}
| 1threat
|
gatsby-image: difference between childImageSharp vs imageSharp : <p>I'm using gatsby-image to handle automatically handle different image sizes. It works great.</p>
<p>However, in the <a href="https://www.gatsbyjs.org/packages/gatsby-image/" rel="noreferrer">docs</a> of gatsby-image, one example uses <code>imageSharp</code> in graphql to get different image sizes, while another example uses <code>childImageSharp</code>. I was curious what the difference between the two are?</p>
<p>I assume it has to do with either <code>gatsby-transformer-sharp</code> or <code>gatsby-plugin-sharp</code>, but the docs for those plugins don't have any info on that either.</p>
| 0debug
|
Read Each charectar from file in c : i want to read each element of my text file which include new line and also space. hear is my code
void test3()
{
char a;
FILE *csv;
csv=fopen64("C:\\Users\\Md. Akash\\Desktop\\csv\\Book1.csv","r");
int i;
for(i=0;;i++)
{
if(fgetc(csv)==EOF)
break;
a=fgetc(csv);
printf("%c",a);
}
}
[enter image description here][1]
this code skip one char.
[1]: https://i.stack.imgur.com/TiJNe.jpg
| 0debug
|
Is there a way to get the next letter in the alphabet : <p>I am trying to create a method which takes in a character from the alphabet (for example 'd') and return the next character from the alphabet (aka. e). How can I do that?</p>
| 0debug
|
Reading JSON file with Python 3 : <p>I'm using Python 3.5.2 on Windows 10 x64. The <code>JSON</code> file I'm reading is <a href="http://pastebin.com/Yjs6FAfm" rel="noreferrer" title="this">this</a> which is a <code>JSON</code> array containing 2 more arrays.</p>
<p>I'm trying to parse this <code>JSON</code> file using the <code>json</code> module. As described in the <a href="https://docs.python.org/3/library/json.html" rel="noreferrer" title="docs">docs</a> the <code>JSON</code> file must be compliant to <code>RFC 7159</code>. I checked my file <a href="https://jsonformatter.curiousconcept.com/" rel="noreferrer" title="here">here</a> and it tells me it's perfectly fine with the <code>RFC 7159</code> format, but when trying to read it using this simple python code:</p>
<pre><code>with open(absolute_json_file_path, encoding='utf-8-sig') as json_file:
text = json_file.read()
json_data = json.load(json_file)
print(json_data)
</code></pre>
<p>I'm getting this exception:</p>
<pre><code>Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd.py", line 2217, in <module>
globals = debugger.run(setup['file'], None, None)
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd.py", line 1643, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Andres Torti/Git-Repos/MCF/Sur3D.App/shapes-json-checker.py", line 14, in <module>
json_data = json.load(json_file)
File "C:\Users\Andres Torti\AppData\Local\Programs\Python\Python35-32\lib\json\__init__.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\Users\Andres Torti\AppData\Local\Programs\Python\Python35-32\lib\json\__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "C:\Users\Andres Torti\AppData\Local\Programs\Python\Python35-32\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Andres Torti\AppData\Local\Programs\Python\Python35-32\lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
</code></pre>
<p>I can read this exact file perfectly fine on Javascript but I can't get Python to parse it. Is there anything wrong with my file or is any problem with the Python parser?</p>
| 0debug
|
Difference among mavenCentral(), jCenter() and mavenLocal()? : <p>Actually, I am studying on <code>build.gradle</code> file. In some cases, I got that sometimes they are using <code>mavenCentral()</code>, <code>jCenter()</code> and <code>mavenLocal()</code> in repositories section. Sometimes they also using URL. So some question arises in my mind?</p>
<blockquote>
<p>i) Difference among mavenCentral(), jCenter() and mavenLocal()?</p>
<p>ii) Which one should I use most?</p>
<p>iii) Is there any performance related issue?</p>
</blockquote>
| 0debug
|
cant get data form nodejs by angular : hi i cant get data from nodejs by angular 6 .
i added a service to connect between them but it is not working
i succeed to get data by nodejs server .. but i cant receive it on angular components .
i know that i missed somthing to connect between them but i cant resolve it .
HostingstartComponent.ts
import { Component, OnInit } from '@angular/core';
import { NgAnalyzedFile } from '@angular/compiler';
import {RouterModule ,Routes } from '@angular/router';
import {HttpModule, Http} from '@angular/http'
import { AngularFontAwesomeModule } from 'angular-font-awesome';
import { SecComponent } from '../sec/sec.component';
import { ThirdComponent } from '../third/third.component';
import {aService} from '../services/a.service';
@Component({
selector: 'app-hostingstart',
templateUrl: './hostingstart.component.html',
styleUrls: ['./hostingstart.component.css']
})
export class HostingstartComponent implements OnInit {
aService: any;
data: any;
appRoutes : Routes=[
{path: 'hostingstar',component : HostingstartComponent},
{path: '',component : HostingstartComponent},
{path: 'sec',component : SecComponent, data : {some_data : 'some value'}},
{path: 'third',component : ThirdComponent, data : {some_data : 'some value'}}
];
headImg : any="assets/images/pan.JPG";
constructor(private http: Http , private service: aService) {
this.headImg ="assets/images/pan.JPG";
// this.aService.getData().then( (result) => {this.data = result; });
}
ngOnInit() {
// alert(this.aService.getData());
// this.aService.getData().then( (result) => {this.data = result; });
// alert(this.data);
}
myFunc() {
//this.router.navigate(['/third', 'north']);
// alert( document.getElementById("search-input").value);
}
getData() {
this.aService.getData().subscribe((dataFromServer) => {
this.data=dataFromServer;
// Now you can use the data
// alert(dataFromServer)
console.log(dataFromServer);
});
}
}
aService.ts
import 'rxjs/add/operator/toPromise';
import { Http, Response, Headers } from '@angular/http';
import { Injectable } from '@angular/core';
@Injectable()
export class aService {
constructor(private http: Http) {
}
async getData() {
const options = {
headers: new Headers({
'Content-Type': 'application/json;charset=utf-8',
'Access-Control-Allow-Origin': '*'
})
};
// const url = './assets/heroes.data.json';
const url = 'http://localhost:3000/';
return this.http.get(url, options)
.toPromise()
.then(response => {
if (response != null) {
const result = response.json();
return Promise.resolve(result);
}
return [];
})
.catch(err => {
console.warn('error in getCats', err);
return Promise.reject(null);
});
}
}
Node js : index.js
console.log('Running File: index.js')
//-- Create Express Server:
var express = require('express');
var app = express();
var util = require('util');
var mysql = require('mysql');
var a;
var con = mysql.createConnection({
host : 'localhost',
user: 'node',
password : 'arafat1990!@#$',
database: "iTour"
});
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM feedback", function (err, result, fields) {
if (err) throw err;
// console.log(result);
a=result;
});
});
//-- Map Base URL to res (Response)
app.get('/', function(req, res){
var fname = req.query.fname;
var lname = req.query.lname;
var html = util.format('<p>Hello %s %s</p>', a[1].username,a[0].rating);
res.send(a);
});
app.get('/hostingstar', function(req, res){
var fname = req.query.fname;
var lname = req.query.lname;
var html = util.format('<p>Hello %s %s</p>', a[1].username,a[0].rating);
res.send(a);
});
//-- Listen on Port 3000:
app.listen(3000);
app.js
const express = require('express');
const app = express();
//const firebase = require('firebase-admin');
app.get('/hostingstart', (req, res) => res.send('Server Is Active!'))
app.get('/hostingstart', (req, res) => {
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user: 'node',
password : 'arafat1990!@#$',
database: "iTour"
});
connection.connect();
connection.query('SELECT * FROM feedback;', function (error, results, fields) {
if (error) {
console.warn(error);
res.send('');
return;
}
console.log("Result: " + results);
res.send(results);
});
connection.end();
})
app.get('/hostingstart', (req, res) => {
var ref = firebase.app().database().ref();
ref.once("value").then(function (snap) {
console.log("snap.val()", snap.val());
res.send(snap.val());
});
});
app.use(function(req, res, next){
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
res.setHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
// Check if preflight request
if (req.method === 'OPTIONS') {
res.status(200);
res.end();
}
else {
next();
}
});
app.listen(3000, () => console.log('Server is listening on port 3000!'))
| 0debug
|
static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno)
{
int compno, reslevelno, bandno, ret;
Jpeg2000T1Context t1;
Jpeg2000CodingStyle *codsty = &s->codsty;
for (compno = 0; compno < s->ncomponents; compno++){
Jpeg2000Component *comp = s->tile[tileno].comp + compno;
av_log(s->avctx, AV_LOG_DEBUG,"dwt\n");
if (ret = ff_dwt_encode(&comp->dwt, comp->i_data))
return ret;
av_log(s->avctx, AV_LOG_DEBUG,"after dwt -> tier1\n");
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < reslevel->nbands ; bandno++){
Jpeg2000Band *band = reslevel->band + bandno;
Jpeg2000Prec *prec = band->prec;
int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;
yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
y0 = yy0;
yy1 = FFMIN(ff_jpeg2000_ceildivpow2(band->coord[1][0] + 1, band->log2_cblk_height) << band->log2_cblk_height,
band->coord[1][1]) - band->coord[1][0] + yy0;
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
bandpos = bandno + (reslevelno > 0);
for (cblky = 0; cblky < prec->nb_codeblocks_height; cblky++){
if (reslevelno == 0 || bandno == 1)
xx0 = 0;
else
xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
x0 = xx0;
xx1 = FFMIN(ff_jpeg2000_ceildivpow2(band->coord[0][0] + 1, band->log2_cblk_width) << band->log2_cblk_width,
band->coord[0][1]) - band->coord[0][0] + xx0;
for (cblkx = 0; cblkx < prec->nb_codeblocks_width; cblkx++, cblkno++){
int y, x;
if (codsty->transform == FF_DWT53){
for (y = yy0; y < yy1; y++){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x++){
*ptr++ = comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] << NMSEDEC_FRACBITS;
}
}
} else{
for (y = yy0; y < yy1; y++){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x++){
*ptr = (comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * y + x]);
*ptr = (int64_t)*ptr * (int64_t)(16384 * 65536 / band->i_stepsize) >> 14 - NMSEDEC_FRACBITS;
ptr++;
}
}
}
encode_cblk(s, &t1, prec->cblk + cblkno, tile, xx1 - xx0, yy1 - yy0,
bandpos, codsty->nreslevels - reslevelno - 1);
xx0 = xx1;
xx1 = FFMIN(xx1 + (1 << band->log2_cblk_width), band->coord[0][1] - band->coord[0][0] + x0);
}
yy0 = yy1;
yy1 = FFMIN(yy1 + (1 << band->log2_cblk_height), band->coord[1][1] - band->coord[1][0] + y0);
}
}
}
av_log(s->avctx, AV_LOG_DEBUG, "after tier1\n");
}
av_log(s->avctx, AV_LOG_DEBUG, "rate control\n");
truncpasses(s, tile);
if (ret = encode_packets(s, tile, tileno))
return ret;
av_log(s->avctx, AV_LOG_DEBUG, "after rate control\n");
return 0;
}
| 1threat
|
static int coroutine_fn sd_co_rw_vector(void *p)
{
SheepdogAIOCB *acb = p;
int ret = 0;
unsigned long len, done = 0, total = acb->nb_sectors * BDRV_SECTOR_SIZE;
unsigned long idx = acb->sector_num * BDRV_SECTOR_SIZE / SD_DATA_OBJ_SIZE;
uint64_t oid;
uint64_t offset = (acb->sector_num * BDRV_SECTOR_SIZE) % SD_DATA_OBJ_SIZE;
BDRVSheepdogState *s = acb->common.bs->opaque;
SheepdogInode *inode = &s->inode;
AIOReq *aio_req;
if (acb->aiocb_type == AIOCB_WRITE_UDATA && s->is_snapshot) {
ret = sd_create_branch(s);
if (ret) {
acb->ret = -EIO;
goto out;
}
}
acb->nr_pending++;
while (done != total) {
uint8_t flags = 0;
uint64_t old_oid = 0;
bool create = false;
oid = vid_to_data_oid(inode->data_vdi_id[idx], idx);
len = MIN(total - done, SD_DATA_OBJ_SIZE - offset);
switch (acb->aiocb_type) {
case AIOCB_READ_UDATA:
if (!inode->data_vdi_id[idx]) {
qemu_iovec_memset(acb->qiov, done, 0, len);
goto done;
}
break;
case AIOCB_WRITE_UDATA:
if (!inode->data_vdi_id[idx]) {
create = true;
} else if (!is_data_obj_writable(inode, idx)) {
create = true;
old_oid = oid;
flags = SD_FLAG_CMD_COW;
}
break;
case AIOCB_DISCARD_OBJ:
if (len != SD_DATA_OBJ_SIZE || inode->data_vdi_id[idx] == 0) {
goto done;
}
break;
default:
break;
}
if (create) {
DPRINTF("update ino (%" PRIu32 ") %" PRIu64 " %" PRIu64 " %ld\n",
inode->vdi_id, oid,
vid_to_data_oid(inode->data_vdi_id[idx], idx), idx);
oid = vid_to_data_oid(inode->vdi_id, idx);
DPRINTF("new oid %" PRIx64 "\n", oid);
}
aio_req = alloc_aio_req(s, acb, oid, len, offset, flags, old_oid, done);
if (create) {
AIOReq *areq;
QLIST_FOREACH(areq, &s->inflight_aio_head, aio_siblings) {
if (areq->oid == oid) {
aio_req->flags = 0;
aio_req->base_oid = 0;
QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req,
aio_siblings);
goto done;
}
}
}
QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, create,
acb->aiocb_type);
done:
offset = 0;
idx++;
done += len;
}
out:
if (!--acb->nr_pending) {
return acb->ret;
}
return 1;
}
| 1threat
|
static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
int buf_size, AVSubtitle *sub)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubDisplayDefinition *display_def = ctx->display_definition;
DVBSubRegion *region;
DVBSubRegionDisplay *display;
AVSubtitleRect *rect;
DVBSubCLUT *clut;
uint32_t *clut_table;
int i;
int offset_x=0, offset_y=0;
sub->end_display_time = ctx->time_out * 1000;
if (display_def) {
offset_x = display_def->x;
offset_y = display_def->y;
}
sub->num_rects = ctx->display_list_size;
if (sub->num_rects > 0){
sub->rects = av_mallocz(sizeof(*sub->rects) * sub->num_rects);
for(i=0; i<sub->num_rects; i++)
sub->rects[i] = av_mallocz(sizeof(*sub->rects[i]));
i = 0;
for (display = ctx->display_list; display; display = display->next) {
region = get_region(ctx, display->region_id);
if (!region)
continue;
if (!region->dirty)
continue;
rect = sub->rects[i];
rect->x = display->x_pos + offset_x;
rect->y = display->y_pos + offset_y;
rect->w = region->width;
rect->h = region->height;
rect->nb_colors = (1 << region->depth);
rect->type = SUBTITLE_BITMAP;
rect->pict.linesize[0] = region->width;
clut = get_clut(ctx, region->clut);
if (!clut)
clut = &default_clut;
switch (region->depth) {
case 2:
clut_table = clut->clut4;
break;
case 8:
clut_table = clut->clut256;
break;
case 4:
default:
clut_table = clut->clut16;
break;
}
rect->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
memcpy(rect->pict.data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
rect->pict.data[0] = av_malloc(region->buf_size);
memcpy(rect->pict.data[0], region->pbuf, region->buf_size);
i++;
}
sub->num_rects = i;
}
#ifdef DEBUG
save_display_set(ctx);
#endif
return 1;
}
| 1threat
|
NullPointerException despite specifying : <p>I want to code a personal modloader for minecraft (create files , download files, sort files, etc) and the first window which is created is a JOptionPane which asks for a Version (i do not code in java really long, i don´t use spinner, just a "msg dialog" asking for a version). The code is:</p>
<pre><code>public JOptionPane version = new JOptionPane();
public String modversion;
public Version()
{
showVersion();
}
public static void main(String[] args)
{
}
public void showVersion()
{
//input = version
String vers = version.showInputDialog("Welche Version soll modifiziert werden?");
if (vers.equals(null)) {
return;
} else {
if(vers.equals("1.5.2") || vers.equals("1.6.2") || vers.equals("1.6.4") || vers.equals("1.7.2") || vers.equals("1.7.10") || vers.equals("1.8") || vers.equals("1.8.9") || vers.equals("1.9") || vers.equals("1.10.2") || vers.equals("1.11.2"))
{
//mod version is saved as String (title for the config list)
modversion = vers;
return;
} else {
// with incompatible input the method will be repeated
JOptionPane.showMessageDialog(null, "Diese Version wird leider nicht supportet");
showVersion();
}
}
}
</code></pre>
<p>If you just press "Ok", the input would equal "null":</p>
<pre><code>if (vers.equals(null)) {
return;
}
</code></pre>
<p>but it don´t quit the method, it says NullPointerException. Why doesn´t it just quit the method?</p>
| 0debug
|
uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
farg.d = float64_div(float64_one, farg.d, &env->fp_status);
}
return farg.ll;
}
| 1threat
|
Select all records from table a. table b has complementary data but only one record matches table a. I need all of them : <p>I have a MySQL database with 2 tables:</p>
<pre><code>Table A:
id name age
123a John 34
143w Mark 27
143x Rony 30
Table B:
id company job
143w Google developer
I need:
id name age company job
123a John 34
143w Mark 27 Google developer
143x Rony 30
</code></pre>
<p>I need a select statement that can extract the result above.<br>
Thanks in advance<br>
Paulo</p>
| 0debug
|
static int colo_packet_compare_all(Packet *spkt, Packet *ppkt)
{
trace_colo_compare_main("compare all");
return colo_packet_compare(ppkt, spkt);
}
| 1threat
|
void checkasm_check_jpeg2000dsp(void)
{
LOCAL_ALIGNED_32(uint8_t, ref, [BUF_SIZE*3]);
LOCAL_ALIGNED_32(uint8_t, new, [BUF_SIZE*3]);
Jpeg2000DSPContext h;
ff_jpeg2000dsp_init(&h);
if (check_func(h.mct_decode[FF_DWT53], "jpeg2000_rct_int"))
check_mct(&ref[BUF_SIZE*0], &ref[BUF_SIZE*1], &ref[BUF_SIZE*2],
&new[BUF_SIZE*0], &new[BUF_SIZE*1], &new[BUF_SIZE*2]);
report("mct_decode");
}
| 1threat
|
static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cs = CPU(dev);
XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(dev);
cs->gdb_num_regs = xcc->config->gdb_regmap.num_regs;
xcc->parent_realize(dev, errp);
}
| 1threat
|
How to LEFT ANTI join under some matching condition : <p>I have two tables - one is a core data with a pair of IDs (PC1 and P2) and some blob data (P3). The other is a blacklist data for PC1 in the former table. I will call the first table in_df and the second blacklist_df.</p>
<p>What I want to do is to remove rows from in_df long as in_df.PC1 == blacklist_df.P1 and in_df.P2 == black_list_df.B1. Here is a code snippet to show what I want to achieve more explicitly.</p>
<pre><code>in_df = sqlContext.createDataFrame([[1,2,'A'],[2,1,'B'],[3,1,'C'],
[4,11,'D'],[1,3,'D']],['PC1','P2','P3'])
in_df.show()
+---+---+---+
|PC1| P2| P3|
+---+---+---+
| 1| 2| A|
| 2| 1| B|
| 3| 1| C|
| 4| 11| D|
| 1| 3| D|
+---+---+---+
blacklist_df = sqlContext.createDataFrame([[1,2],[2,1]],['P1','B1'])
blacklist_df.show()
+---+---+
| P1| B1|
+---+---+
| 1| 2|
| 2| 1|
+---+---+
</code></pre>
<p>In the end what I want to get is the followings:</p>
<pre><code>+---+--+--+
|PC1|P2|P3|
+---+--+--+
| 1| 3| D|
| 3| 1| C|
| 4|11| D|
+---+--+--+
</code></pre>
<p>I tried LEFT_ANTI join but I haven't been successful. Thanks!</p>
| 0debug
|
static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
unsigned int epid, unsigned int streamid)
{
XHCIStreamContext *stctx;
XHCIEPContext *epctx;
XHCIRing *ring;
USBEndpoint *ep = NULL;
uint64_t mfindex;
int length;
int i;
trace_usb_xhci_ep_kick(slotid, epid, streamid);
assert(slotid >= 1 && slotid <= xhci->numslots);
assert(epid >= 1 && epid <= 31);
if (!xhci->slots[slotid-1].enabled) {
DPRINTF("xhci: xhci_kick_ep for disabled slot %d\n", slotid);
return;
}
epctx = xhci->slots[slotid-1].eps[epid-1];
if (!epctx) {
DPRINTF("xhci: xhci_kick_ep for disabled endpoint %d,%d\n",
epid, slotid);
return;
}
if (!xhci->slots[slotid - 1].uport ||
!xhci->slots[slotid - 1].uport->dev ||
!xhci->slots[slotid - 1].uport->dev->attached) {
return;
}
if (epctx->retry) {
XHCITransfer *xfer = epctx->retry;
trace_usb_xhci_xfer_retry(xfer);
assert(xfer->running_retry);
if (xfer->timed_xfer) {
mfindex = xhci_mfindex_get(xhci);
xhci_check_intr_iso_kick(xhci, xfer, epctx, mfindex);
if (xfer->running_retry) {
return;
}
xfer->timed_xfer = 0;
xfer->running_retry = 1;
}
if (xfer->iso_xfer) {
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
assert(xfer->packet.status != USB_RET_NAK);
xhci_complete_packet(xfer);
} else {
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
if (xfer->packet.status == USB_RET_NAK) {
return;
}
xhci_complete_packet(xfer);
}
assert(!xfer->running_retry);
epctx->retry = NULL;
}
if (epctx->state == EP_HALTED) {
DPRINTF("xhci: ep halted, not running schedule\n");
return;
}
if (epctx->nr_pstreams) {
uint32_t err;
stctx = xhci_find_stream(epctx, streamid, &err);
if (stctx == NULL) {
return;
}
ring = &stctx->ring;
xhci_set_ep_state(xhci, epctx, stctx, EP_RUNNING);
} else {
ring = &epctx->ring;
streamid = 0;
xhci_set_ep_state(xhci, epctx, NULL, EP_RUNNING);
}
assert(ring->dequeue != 0);
while (1) {
XHCITransfer *xfer = &epctx->transfers[epctx->next_xfer];
if (xfer->running_async || xfer->running_retry) {
break;
}
length = xhci_ring_chain_length(xhci, ring);
if (length < 0) {
break;
} else if (length == 0) {
break;
}
if (xfer->trbs && xfer->trb_alloced < length) {
xfer->trb_count = 0;
xfer->trb_alloced = 0;
g_free(xfer->trbs);
xfer->trbs = NULL;
}
if (!xfer->trbs) {
xfer->trbs = g_new(XHCITRB, length);
xfer->trb_alloced = length;
}
xfer->trb_count = length;
for (i = 0; i < length; i++) {
TRBType type;
type = xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL);
assert(type);
}
xfer->streamid = streamid;
if (epid == 1) {
if (xhci_fire_ctl_transfer(xhci, xfer) >= 0) {
epctx->next_xfer = (epctx->next_xfer + 1) % TD_QUEUE;
} else {
DPRINTF("xhci: error firing CTL transfer\n");
}
} else {
if (xhci_fire_transfer(xhci, xfer, epctx) >= 0) {
epctx->next_xfer = (epctx->next_xfer + 1) % TD_QUEUE;
} else {
if (!xfer->timed_xfer) {
DPRINTF("xhci: error firing data transfer\n");
}
}
}
if (epctx->state == EP_HALTED) {
break;
}
if (xfer->running_retry) {
DPRINTF("xhci: xfer nacked, stopping schedule\n");
epctx->retry = xfer;
break;
}
}
ep = xhci_epid_to_usbep(xhci, slotid, epid);
if (ep) {
usb_device_flush_ep_queue(ep->dev, ep);
}
}
| 1threat
|
ios10 swift instantiateViewController : i trying open new view : IOS 10
Swift 3
I trying open new view
ViewController.swift
-> InAppBrowserController.swift
Main.storyboard -> InAppBrowser View make & Storyboard Id -> Ok.
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let nextViewController = storyboard.instantiateViewController(withIdentifier: "InAppBrowserView") as! InAppBrowserController
self.present(nextViewController, animated: true, completion: nil)
> Blockquote
fatal error: unexpectedly found nil while unwrapping an Optional value
2016-11-24 20:24:50.569000 GMK SWork[5920:2148780] fatal error: unexpectedly found nil while unwrapping an Optional value
what is problem?..
| 0debug
|
VSTS - prevent push to master but allow PR merge : <p>We have branch policies set up in VSTS to prevent pull requests being merged into master unless a build passes and work items are linked. However, I can't work out how to prevent developers pushing directly to master. Setting the "Contribute" permission to Deny does not allow pull requests to be merged.</p>
<p>All developers should be allowed to merge PRs into master but none should be permitted to push directly to master. Is this possible?</p>
| 0debug
|
My image doesn't get displayed, why? (Java) : I have an exercise in school where you are meant to change the code so that the image moves. The problem is that the image doesn't show in the first place and I don't know why. Here is the code:
public void exercise1e() {
Random rand = new Random();
ImageIcon image = new ImageIcon("images/gubbe.jpg");
PaintWindow_GU1.showWindow(600, 400, "P1", Color.WHITE);
PaintWindow_GU1.addSound("Skor", "sounds/trasiga_skor.mp3");
PaintWindow_GU1.playSound("Skor");
int width = PaintWindow_GU1.getBackgroundWidth();
int height = PaintWindow_GU1.getBackgroundHeight();
int dx = -2;
int dy = 1;
int x = 250;
int y = rand.nextInt(height-100);
PaintWindow_GU1.addIcon("Gubbe", image, 250, y, true);
while(true) {
PaintWindow_GU1.setIconXY("Gubbe",x,y);
PaintWindow_GU1.pause(20);
x += dx;
y += dy;
if(x<0) {
dx = -dx;
}
}
}
| 0debug
|
Hello, I stopped the postgresql process and i don't know how to reopen it : <p>Please give me complete tutorial because i am new. I know it's dumb question but please help me</p>
| 0debug
|
javascript rounding by 500 : <p>how to round 17000595 to 17000500 with javascript?</p>
| 0debug
|
Can someone exlplain to me how ajax can be work on a for loop : I am stressed and desperate if how ajax isn't working on a for loop.
Can someone correct my code and please explain it to me. I am willing to learn more. But it keeps getting down whenever I cant get
var counter = $("input[name^= 'quantity']").length;
var array1 = $("input[name^= 'quantity']");
var array2 = $("input[name^= 'unit']");
var array3 = $("input[name^= 'item_description']");
var array4 = $("input[name^= 'stock_no']");
var array5 = $("input[name^= 'eunitcost']");
var array6 = $("input[name^= 'ecost']");
var i;
for(i=0;i<counter;i++){
$.ajax({
url: 'http://localhost/pm/admin/service/user-service.php',
type: 'POST',
dataType: 'json',
data: {
operation: 'pr-items',
pr_no: $('#prno').val(),
quantity: array1.eq(i).val(),
unit: array2.eq(i).val(),
item_description: array3.eq(i).val(),
stock_no: array4.eq(i).val(),
eunitcost: array5.eq(i).val(),
ecost: array6.eq(i).val
},
success: function(data) {
alert('pr items success');
//todo
},
error: function(data){
// alert('pr items error');
//todo
}
});
}
I just want to put those value on my database. I can only make it work if i call ajax once not like this, it is in a for loop
| 0debug
|
def check_Triangle(x1,y1,x2,y2,x3,y3):
a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))
if a == 0:
return ('No')
else:
return ('Yes')
| 0debug
|
Android - Storing images in mipmap vs drawable folder : <p>As a general rule, when storing image resources for use in an Android project, should they be placed in the <em>res/drawable</em> or the <em>res/mipmap</em> folder?</p>
<p>Apologies for the simple question, I'm relatively new to Android development. The IDE I'm using is Android Studio 1.0.</p>
| 0debug
|
How to make a Material UI react Button act as a react-router-dom Link? : <p>How can I make a <strong>Material UI</strong> react <code>Button</code> component act as a <code>Link</code> component from <strong>react-router-dom</strong> without losing it's original style? Like changing the route on click.</p>
<pre><code>import Button from '@material-ui/core/Button';
<Button variant="contained" color="primary">
About Page
</Button>
</code></pre>
<p>To something like this, but maintaining the original <code>Button</code> style:</p>
<pre><code>import Button from '@material-ui/core/Button';
import { Link } from 'react-router-dom';
<Button variant="contained" color="primary">
<Link to="/about">
About Page
</Link>
</Button>
</code></pre>
| 0debug
|
Only run job on specific branch with GitHub Actions : <p>I'm relatively new to GitHub Actions and I have 2 jobs–one that runs my tests, and one that deploys my project onto a server.</p>
<p>Obviously I want the tests to run on every branch, but deploying should only happen when something gets pushed to master.</p>
<p>I'm struggling to find a way to run a job on a specific branch. I know it's possible to only run <em>entire workflows</em> on a specific branch, however that would mean I would have a "test" workflow and a "deploy" workflow. </p>
<p>This sounds like a solution, however they would run parallel. In an ideal world, the tests would run first, and only if they succeed, then the deploy job would start. This isn't the case when using 2 separate workflows.</p>
<p>How would I be able to achieve this? Is it possible to run <strong>jobs</strong> on a specific branch?</p>
| 0debug
|
Javascript push() function is not adding objects to an array : <p>I have a for-loop that cycles thru some html elements collected with jquery selectors and extracts some text or values from them. Each loop creates a new object. The object is simple, it is just text and a value. Console.log confirms that the object is created successfully each loop.</p>
<p>Outside the for-loop, I have a variable (kvObjs) that is initialized as an array. At the end of the for-loop, I push the new object into the array. But console.log confirms that the array stays empty.</p>
<p>This is part of a larger piece of code. This appears to be the part that isn't working. The specific function that isn't working is getKVs(), well, it works except for the part that tries to push the object on the array.</p>
<p>I promise you I looked thru all or almost all the "similar questions" and nothing clicked with me. I might have missed something in them, though. I feel like I'm overlooking something obvious.</p>
<p>I have tried to creating an array manually (var x = ["bob", "steve", "frank"]) and then setting another variable equal to that (var y = x) and that seems to work. I even created an array of objects, as in var x = [{"Key":"Bob","Value":10}, {"Key":"Steve","Value":5}], and I think that worked to. But my for-loop doesn't.</p>
<pre><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
.Jobs {
width: 300px;
margin: 0 auto;
}
.Jobs li {
display: grid;
grid-template-columns: 1fr 50px;
padding: 2px 5px 2px 7px;
align-items: center;
}
.Jobs .value {
text-align: right;
}
.Jobs p.value {
padding-right: 7px;
}
.even {
background-color: rgba(0,0,0,0.2);
}
</style>
<div class="Jobs">
<ul>
<li class="kvp">
<p class="key">Bob</p>
<input class="value" type="number" value="3"/>
</li>
<li class="kvp even">
<p class="key">Frank</p>
<input class="value" type="number" value="2"/>
</li>
<li class="kvp">
<p class="key">Tom</p>
<input class="value" type="number" value="8"/>
</li>
<li class="kvp total even">
<p class="key">Total</p>
<p class="value">13</p>
</li>
</ul>
</div>
<script>
class KV {
constructor(key, value) {
this.Key = key;
this.Value = value;
}
}
function getKVs(type) {
type = "." + type + " .kvp";
var elmts = $(type);
var kvObjs = [];
for (var i = 0; i < elmts.length; i++) {
var elmt = $(elmts[i]);
if(elmt.hasClass("total")) {
// do nothing
} else {
var k = elmt.find(".key").text();
var v = elmt.find("input").val();
var kv = new KV(k, v);
console.log(kv); // the kv object is successfully created
kvObjs.push[kv];
console.log(kvObjs.length); // but it is not being added to the array (length stays 0)
}
}
return kvObjs;
}
var x = getKVs("Jobs");
console.log(x); // so I'm transferring an empty array to x
</script>
</code></pre>
<p>I keep getting an empty array.</p>
| 0debug
|
qemu_irq get_cps_irq(MIPSCPSState *s, int pin_number)
{
MIPSCPU *cpu = MIPS_CPU(first_cpu);
CPUMIPSState *env = &cpu->env;
assert(pin_number < s->num_irq);
return env->irq[pin_number];
}
| 1threat
|
static int altivec_uyvy_rgb32 (SwsContext *c,
unsigned char **in, int *instrides,
int srcSliceY, int srcSliceH,
unsigned char **oplanes, int *outstrides)
{
int w = c->srcW;
int h = srcSliceH;
int i,j;
vector unsigned char uyvy;
vector signed short Y,U,V;
vector signed short R0,G0,B0,R1,G1,B1;
vector unsigned char R,G,B;
vector unsigned char *out;
ubyte *img;
img = in[0];
out = (vector unsigned char *)(oplanes[0]+srcSliceY*outstrides[0]);
for (i=0;i<h;i++) {
for (j=0;j<w/16;j++) {
uyvy = vec_ld (0, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (c, Y,U,V,&R0,&G0,&B0);
uyvy = vec_ld (16, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (c, Y,U,V,&R1,&G1,&B1);
R = vec_packclp (R0,R1);
G = vec_packclp (G0,G1);
B = vec_packclp (B0,B1);
out_rgba (R,G,B,out);
img += 32;
}
}
return srcSliceH;
}
| 1threat
|
how to get list of all connected devices on one router programmatically in android? : I am developing an app in which I want to shows list of all devices which are connected to one router using wifip2p. I don't know how to do this because I am new in developing. please help Thank you in advance
| 0debug
|
Matplotlib figure to image as a numpy array : <p>I'm trying to get a numpy array image from a Matplotlib figure and I'm currently doing it by saving to a file, then reading the file back in, but I feel like there has to be a better way. Here's what I'm doing now:</p>
<pre><code>from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.gca()
ax.text(0.0,0.0,"Test", fontsize=45)
ax.axis('off')
canvas.print_figure("output.png")
image = plt.imread("output.png")
</code></pre>
<p>I tried this:</p>
<pre><code>image = np.fromstring( canvas.tostring_rgb(), dtype='uint8' )
</code></pre>
<p>from an example I found but it gives me an error saying that 'FigureCanvasAgg' object has no attribute 'renderer'.</p>
| 0debug
|
360 degrees view for Account/Contact in Microsot Dynamics CRM 2016 : I'm working on Ms Dynamics CRM 2016 and I'm looking for a tool or a way to have a 360° view on the Account/Contact forms.
If you have some suggestions. Thanks in advance.
| 0debug
|
static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,
TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.mem_idx = env->mmu_idx;
ctx.insns_flags = env->insns_flags;
ctx.insns_flags2 = env->insns_flags2;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_is_64bit(env, env->msr);
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
ctx.vsx_enabled = msr_vsx;
} else {
ctx.vsx_enabled = 0;
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(cs->singlestep_enabled)) {
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
tcg_clear_temp_count();
while (ctx.exception == POWERPC_EXCP_NONE
&& tcg_ctx.gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
if (unlikely(search_pc)) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
tcg_ctx.gen_opc_pc[lj] = ctx.nip;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(ctx.le_mode)) {
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
} else {
ctx.opcode = cpu_ldl_code(env, ctx.nip);
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx.nip);
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
} else {
uint32_t inval;
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {
inval = handler->inval2;
} else {
inval = handler->inval1;
if (unlikely((ctx.opcode & inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(cs->singlestep_enabled) ||
singlestep ||
num_insns >= max_insns)) {
break;
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(cs->singlestep_enabled)) {
gen_debug_exception(ctxp);
tcg_gen_exit_tb(0);
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
#endif
| 1threat
|
How to check if a commit has been merged to my current branch - somewhere in time? : <p>I have a random feature/XXXXXXX branch that has some commits and naturally the "develop" branch where those features are eventually merged.</p>
<p>How do I check if a certain old commit (e.g. commit ab123456 from branch feature/user-registration) has been somehow brought/merged to my currently active branch (e.g. develop)? Either by directly merging the feature branch to develop or by going up/merged through some other intermediary branch.</p>
<p>Through git commands or through SourceTree UI, both ways are equally suitable for me.</p>
| 0debug
|
void register_device_unmigratable(DeviceState *dev, const char *idstr,
void *opaque)
{
SaveStateEntry *se;
char id[256] = "";
if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
char *path = dev->parent_bus->info->get_dev_path(dev);
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
se->no_migrate = 1;
}
}
}
| 1threat
|
How to change Navigation Drawer icon color in Android Studio? : <p>I am not getting answer. because when i am giving transparent color for toolbar on one activity then i am not able to see navigation drawer icon.
Please help me out.</p>
| 0debug
|
Best way to read specify length of bytes in stream (C#) : What is the best way to read a **specify** Length of bytes in a stream.
| 0debug
|
Type 'Headers' has no properties in common with type 'RequestOptionsArgs'? : <p>I just made two important upgrades to our Angular 4 application and build tools:</p>
<ol>
<li><em>@angular/core</em> <code>^4.1.3</code> => <code>^4.2.4</code> (and /http, /forms, etc)</li>
<li><em>tslint</em> <code>^5.3.2</code> => <code>^5.4.3</code></li>
</ol>
<p>I have a Service which declares options like so:</p>
<pre><code>@Injectable()
export class WorkOrderService {
private headers: Headers = new Headers({ 'Content-Type': 'application/json' });
private options: RequestOptions = new RequestOptions(this.headers);
constructor(private http: Http) {}
/* Methods ... */
}
</code></pre>
<p>The above now no longer validates tslint, throwing the following error:</p>
<blockquote>
<p>error TS2559: Type 'Headers' has no properties in common with type 'RequestOptionsArgs'.</p>
</blockquote>
<p>The source (@angular/http <code>interface.d.ts:43</code>) clearly allows for <code>Headers</code> as a <code>RequestOptionsArgs</code>:</p>
<pre><code>/**
* Interface for options to construct a RequestOptions, based on
* [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
*
* @experimental
*/
export interface RequestOptionsArgs {
url?: string | null;
method?: string | RequestMethod | null;
/** @deprecated from 4.0.0. Use params instead. */
search?: string | URLSearchParams | {
[key: string]: any | any[];
} | null;
params?: string | URLSearchParams | {
[key: string]: any | any[];
} | null;
headers?: Headers | null;
body?: any;
withCredentials?: boolean | null;
responseType?: ResponseContentType | null;
}
</code></pre>
| 0debug
|
vnc_socket_ip_addr_string(QIOChannelSocket *ioc,
bool local,
Error **errp)
{
SocketAddress *addr;
char *ret;
if (local) {
addr = qio_channel_socket_get_local_address(ioc, errp);
} else {
addr = qio_channel_socket_get_remote_address(ioc, errp);
}
if (!addr) {
return NULL;
}
if (addr->type != SOCKET_ADDRESS_KIND_INET) {
error_setg(errp, "Not an inet socket type");
return NULL;
}
ret = g_strdup_printf("%s;%s", addr->u.inet->host, addr->u.inet->port);
qapi_free_SocketAddress(addr);
return ret;
}
| 1threat
|
Golang - Parallelism From Slices : I have a problem and end up with this code.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"runtime"
"strconv"
"strings"
"sync"
"time"
)
func main() {
start := time.Now()
target := os.Args[1]
thread, _ := strconv.Atoi(os.Args[3])
file, err := ioutil.ReadFile(os.Args[2])
if err != nil {
fmt.Println("Error: Please double check if the file " + os.Args[2] + " is exist!")
os.Exit(0)
}
wordlist := strings.Split(string(file), "\n")
var wg sync.WaitGroup
runtime.GOMAXPROCS(runtime.NumCPU())
jobs := make(chan string)
for i := 0; i < thread; i++ {
wg.Add(1)
defer wg.Done()
for _, word := range wordlist {
go func(word string) {
jobs <- word
}(word)
}
}
go func() {
for job := range jobs {
code := visit(target + job)
fmt.Println(target + job + " - " + strconv.Itoa(code))
}
}()
wg.Wait()
elapsed := time.Since(start)
fmt.Printf("Timer: %s\n", elapsed)
}
func visit(url string) int {
data, err := http.Get(url)
if err != nil {
panic(err)
}
return data.StatusCode
}
I want to make it run parallel based on number of thread. But the result was not as i expected. I dont know how to make it efficient and fast.
Any help would be appreciated. Thank you.
| 0debug
|
how to change dd/mm/yyyy hh:mm:ss to yyyy-mm-dd hh:mm:ss using sql : how to change dd/mm/yyyy hh:mm:ss to yyyy-mm-dd hh:mm:ss using sql
| 0debug
|
static int64_t scene_sad8(FrameRateContext *s, uint8_t *p1, int p1_linesize, uint8_t* p2, int p2_linesize, int height)
{
int64_t sad;
int x, y;
for (sad = y = 0; y < height; y += 8) {
for (x = 0; x < p1_linesize; x += 8) {
sad += s->sad(p1 + y * p1_linesize + x,
p1_linesize,
p2 + y * p2_linesize + x,
p2_linesize);
}
}
emms_c();
return sad;
}
| 1threat
|
Add a class to a div at a condition : The following is my code I wanted to add a class to a div when a certain condition is true. Tried jquery also but didn't worked. My code is as follows
$('.addressStatus').each(function(index, value){
var el = 0;
if($(this).data('status') == true){
el = $(this).data('param1');
console.log(el);
var id = document.getElementById('statusID'+el);
id.classList.add('inactiveAddrsColor');
// id.className += id.className ? ' inactiveAddrsColor' : 'inactiveAddrsColor';
//element.classList.add('inactiveAddrsColor');
// $('statusID'+el).addClass('inactiveAddrsColor');
}
});
| 0debug
|
What is the advantage of cassandra database? : Could you let me know why do we use the Cassandra database?
We cannot search Cassandra tables with other than those in the primary key or clustering columns.
For example, if my primary key is 'a' and clustering columns are 'b' and 'c'.
I can only use the following in where condition.
select * from table where a = 1 and b = 2 and c = 3
Or there any other queries that I can use with where?
I want to use
select * from table where a=1
and
select * from table where a = 1 and b = 2 and c = 3 and d = 4
Is that possible?
If not, then why people chose to use Cassandra if it is not serving this minimum request.
| 0debug
|
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
dst[i] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
} else {
#endif
x86_reg xInc_shr16 = (x86_reg) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
x86_reg dstWidth_reg = dstWidth;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
".p2align 4 \n\t"
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
#endif
}
| 1threat
|
void put_vp8_epel_h_altivec_core(uint8_t *dst, int dst_stride,
uint8_t *src, int src_stride,
int h, int mx, int w, int is6tap)
{
LOAD_H_SUBPEL_FILTER(mx-1);
vec_u8 align_vec0, align_vec8, permh0, permh8, filt;
vec_u8 perm_6tap0, perm_6tap8, perml0, perml8;
vec_u8 a, b, pixh, pixl, outer;
vec_s16 f16h, f16l;
vec_s32 filth, filtl;
vec_u8 perm_inner = { 1,2,3,4, 2,3,4,5, 3,4,5,6, 4,5,6,7 };
vec_u8 perm_outer = { 4,9, 0,5, 5,10, 1,6, 6,11, 2,7, 7,12, 3,8 };
vec_s32 c64 = vec_sl(vec_splat_s32(1), vec_splat_u32(6));
vec_u16 c7 = vec_splat_u16(7);
align_vec0 = vec_lvsl( -2, src);
align_vec8 = vec_lvsl(8-2, src);
permh0 = vec_perm(align_vec0, align_vec0, perm_inner);
permh8 = vec_perm(align_vec8, align_vec8, perm_inner);
perm_inner = vec_add(perm_inner, vec_splat_u8(4));
perml0 = vec_perm(align_vec0, align_vec0, perm_inner);
perml8 = vec_perm(align_vec8, align_vec8, perm_inner);
perm_6tap0 = vec_perm(align_vec0, align_vec0, perm_outer);
perm_6tap8 = vec_perm(align_vec8, align_vec8, perm_outer);
while (h --> 0) {
FILTER_H(f16h, 0);
if (w == 16) {
FILTER_H(f16l, 8);
filt = vec_packsu(f16h, f16l);
vec_st(filt, 0, dst);
} else {
filt = vec_packsu(f16h, f16h);
vec_ste((vec_u32)filt, 0, (uint32_t*)dst);
if (w == 8)
vec_ste((vec_u32)filt, 4, (uint32_t*)dst);
}
src += src_stride;
dst += dst_stride;
}
}
| 1threat
|
Angular 2 ng2-charts doughnut text in the middle? : <p>I am using Doughnut chart from ng2-charts (<a href="http://valor-software.com/ng2-charts/" rel="noreferrer">http://valor-software.com/ng2-charts/</a>) in angular 2.
I have been searching for an option to put a text in the middle without success.
I already searched in ng-chart options as in chart.js (dependency).
Do you know another way to achieve this in Angular 2 typescript? or there is something I am missing?</p>
| 0debug
|
nonincremental update requires all .SBR files : <p>I am working in .net platform . I am using VS 2013.
After building I am getting error like
nonincremental update requires all .SBR files</p>
| 0debug
|
Naming centers of triangles within triangles to nth level, and how to find center by it's name later : Intro:
I have a recursive function that finds centers of given three points.
I start with vertices a, b, and c.
The center is labeled (abc).
The center splits triangle abc into three triangles: (abc)ab, (abc)ac, and (abc)bc, with centers: ((abc)ab), ((abc)ac), and ((abc)bc). And so on.
My function sorts the vertices' names - parentheses character codes are smaller than letters, that's why ((abc)ab) and not, for example, (ab(abc)).
I've noticed that each point has a unique count of a's, b's, and c's (as well as parentheses, which can be ignored).
Looking for:
A way to visually (I can, and do, draw the triangles: each vertex to the other two and to the center) get to a point given it's name, but it can get very long, so, perhaps, use letter-count. For example: point (((abc)ab)((abc)a((abc)ab))((abc)((abc)ab)((abc)a((abc)ab)))) has a, b, and c letter-count of 13, 11, and 7, and to get to it, assuming a is top vertex, b is below a and to the right, and c is below a and to the left (just for example. they can be in any order/direction), we (1) go to the center, (2) then right-up-right, (3) then left-up-left, (4) then down-right-down, and, finally, (5) right-up-right - all along drawn lines.
How to get these directions from the point's name/letter-count?!? Instead of painfully dissecting the point's name and using pencil and paper...
| 0debug
|
Simple form validation with PHP - Login Screen : <p>I know there is many ways to do a login form validation with mysql, but i'm trying to make a simple form validation with php. I'm getting this error: </p>
<blockquote>
<p>Parse error: syntax error, unexpected 'echo' (T_ECHO) in
C:\xampp2\htdocs\one\homedir\public_html\calendario\valida.php on line
11</p>
</blockquote>
<p>Here is my form:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
font-family: "Open Sans", sans-serif;
height: 100vh;
background: url("https://i.imgur.com/HgflTDf.jpg") 50% fixed;
background-size: cover;
}
@keyframes spinner {
0% {
transform: rotateZ(0deg);
}
100% {
transform: rotateZ(359deg);
}
}
* {
box-sizing: border-box;
}
.wrapper {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
width: 100%;
min-height: 100%;
padding: 20px;
background: rgba(4, 40, 68, 0.85);
}
.login {
border-radius: 2px 2px 5px 5px;
padding: 10px 20px 20px 20px;
width: 90%;
max-width: 320px;
background: #ffffff;
position: relative;
padding-bottom: 80px;
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.3);
}
.login.loading button {
max-height: 100%;
padding-top: 50px;
}
.login.loading button .spinner {
opacity: 1;
top: 40%;
}
.login.ok button {
background-color: #8bc34a;
}
.login.ok button .spinner {
border-radius: 0;
border-top-color: transparent;
border-right-color: transparent;
height: 20px;
animation: none;
transform: rotateZ(-45deg);
}
.login input {
display: block;
padding: 15px 10px;
margin-bottom: 10px;
width: 100%;
border: 1px solid #ddd;
transition: border-width 0.2s ease;
border-radius: 2px;
color: #ccc;
}
.login input + i.fa {
color: #fff;
font-size: 1em;
position: absolute;
margin-top: -47px;
opacity: 0;
left: 0;
transition: all 0.1s ease-in;
}
.login input:focus {
outline: none;
color: #444;
border-color: #2196F3;
border-left-width: 35px;
}
.login input:focus + i.fa {
opacity: 1;
left: 30px;
transition: all 0.25s ease-out;
}
.login a {
font-size: 0.8em;
color: #2196F3;
text-decoration: none;
}
.login .title {
color: #444;
font-size: 1.2em;
font-weight: bold;
margin: 10px 0 30px 0;
border-bottom: 1px solid #eee;
padding-bottom: 20px;
}
.login button {
width: 100%;
height: 100%;
padding: 10px 10px;
background: #2196F3;
color: #fff;
display: block;
border: none;
margin-top: 20px;
position: absolute;
left: 0;
bottom: 0;
max-height: 60px;
border: 0px solid rgba(0, 0, 0, 0.1);
border-radius: 0 0 2px 2px;
transform: rotateZ(0deg);
transition: all 0.1s ease-out;
border-bottom-width: 7px;
}
.login button .spinner {
display: block;
width: 40px;
height: 40px;
position: absolute;
border: 4px solid #ffffff;
border-top-color: rgba(255, 255, 255, 0.3);
border-radius: 100%;
left: 50%;
top: 0;
opacity: 0;
margin-left: -20px;
margin-top: -20px;
animation: spinner 0.6s infinite linear;
transition: top 0.3s 0.3s ease, opacity 0.3s 0.3s ease, border-radius 0.3s ease;
box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.2);
}
.login:not(.loading) button:hover {
box-shadow: 0px 1px 3px #2196F3;
}
.login:not(.loading) button:focus {
border-bottom-width: 4px;
}
footer {
display: block;
padding-top: 50px;
text-align: center;
color: #ddd;
font-weight: normal;
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);
font-size: 0.8em;
}
footer a, footer a:link {
color: #fff;
text-decoration: none;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Calendário de E-mail marketing</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body>
<div class="wrapper">
<form class="login" action="valida.php" method="post">
<p class="title">Log in</p>
<input id="usuario" class="usuario" type="text" placeholder="Usuário" autofocus/>
<i class="fa fa-user"></i>
<input id="senha" clas="senha" type="password" placeholder="Senha" />
<i class="fa fa-key"></i>
<button>
<i class="spinner"></i>
<span class="state">Log in</span>
</button>
</form>
<footer>2017 One Imóveis de Luxo</footer>
</p>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>And, most important, here is my php file:</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-html lang-html prettyprint-override"><code><?php
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
if( ($usuario=='marketing') && ($senha=='onecia40012121') {
echo header('Location: http://www.onecia.com.br/ato/?lead=ok'); THIS LINE HAVE A PROBLEM
} else {
echo "<script>alert('Login ou senha incorretos!');</script>";
}
?></code></pre>
</div>
</div>
</p>
<p>Wait for your help, thanks!</p>
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
jquery doesn't work on wordpad++ : I have little problem with simple exercise with jQuery. Code is short so I'll put it whole here:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>fast exercise</title>
<script scr="jquery.js"></script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
$("#main").text("The width of the element is " + $("#main").width() +"px and height is " + $("#main").height() + "px.")
});
});
</script>
<style>
#main {
width: 300px;
height: 300px;
background: red;
color: black;
padding: 30px;
border: 2px solid black;
margin: 5px;
}
</style>
</head>
<body>
<button id="btn1">Click here to see basic measurements</button>
<div id="main">
<p>This is div called "main"</p>
</div>
</body>
</html>
I'm just beginner but I've managed to get some basics. When I'm using button I see no reaction. I use Notepad++ and latest jQuery version. For example when I download same file from website that I'm using to learn it works but if I create it myself it's not. Sorry for such simple problem but it really grinds my gears. Any ideas? Thank you in advance!
| 0debug
|
python linkedin learning course dowload : I got an isssue while executing the script python lld.py to download linkedin course for offline use
C:\Users\Srilokan\Downloads\linkedin>python lld.py
Traceback (most recent call last):
File "lld.py", line 13, in <module>
reload(sys)
NameError: name 'reload' is not defined
I have taken this code from https://github.com/mclmza/linkedin-learning-downloader
Please rectify the error
Thanks for advance
| 0debug
|
MYSQL Insert strips backslash escape character from json string : <p>I'm trying to insert data into a mysql database, with the code below.
Problem is, my json code containing the value "R\u00f8nde" is changed to "Ru00f8nde" after I insert it into the database.</p>
<p>What is the best way to avoid this?</p>
<pre><code>INSERT INTO jos_payplans_user(user_id, params) VALUES ('24882', '{"modtager":"Anders And","adresse":"Paradisaeblevej 111","postnr":"1234","by":"R\u00f8nde","telefon":"12345678","user_notes":""}')
</code></pre>
| 0debug
|
Cython interfaced with C++: segmetation fault for large arrays : I am transferring my code from Python/C interfaced using ctypes to Python/C++ interfaced using Cython. The new interface will give me an easier to maintain code, because I can exploit all the C++ features and need relatively few lines of interface-code.
The interfaced code works perfectly with small arrays. However it encounters a *segmentation fault* when using large arrays. I have been wrapping my head around this problem, but have not gotten any closer to a solution. I have included a minimal example in which the segmentation fault occurs. Please note that it consistently occurs on Linux and Mac, and also valgrind did not give insights. Also note that the exact same example in pure C++ does work without problems.
The example contains a Sparse matrix class (of the compressed row format) in C++. An interface is created in Cython. As a result the class can be used from Python.
# C++ side
``sparse.h``
#ifndef SPARSE_H
#define SPARSE_H
#include <iostream>
#include <cstdio>
using namespace std;
class Sparse {
public:
double* data;
int* row_ptr;
int* col_ind;
int* shape;
int nnz;
Sparse();
~Sparse();
Sparse(int* shape, int nnz, double* data, int* row_ptr, int* col_ind);
void view(void);
};
#endif
``sparse.cpp``
#include "sparse.h"
// =============================================================================
Sparse::Sparse()
{
data = NULL;
row_ptr = NULL;
col_ind = NULL;
shape = NULL;
nnz = 0 ;
}
// =============================================================================
Sparse::~Sparse() {}
// =============================================================================
Sparse::Sparse(int* Shape, int NNZ, double* Data, int* Row_ptr, int* Col_ind)
{
shape = Shape ;
nnz = NNZ ;
data = Data ;
row_ptr = Row_ptr;
col_ind = Col_ind;
}
// =============================================================================
void Sparse::view(void)
{
if ( row_ptr==NULL || col_ind==NULL || data==NULL || shape==NULL ) {
cout << "NULL-pointer found" << endl;
return;
}
int i,j;
for ( i=0 ; i<shape[0] ; i++ )
for ( j=row_ptr[i] ; j<row_ptr[i+1] ; j++ )
printf("(%3d,%3d) %4.1f\n",i,col_ind[j],data[j]);
}
// =============================================================================
# Cython interface
``csparse.pyx``
import numpy as np
cimport numpy as np
# ==============================================================================
cdef extern from "sparse.h":
cdef cppclass Sparse:
Sparse(int*, int, double*, int*, int*) except +
double* data
int* row_ptr
int* col_ind
int* shape
int nnz
void view()
# ==============================================================================
cdef class PySparse:
# ----------------------------------------------------------------------------
cdef Sparse *ptr
# ----------------------------------------------------------------------------
def __init__(self,**kwargs):
pass
def __cinit__(self,**kwargs):
cdef np.ndarray[np.int32_t , ndim=1, mode="c"] shape, col_ind, row_ptr
cdef np.ndarray[np.float64_t, ndim=1, mode="c"] data
shape = np.array(kwargs['shape' ],dtype='int32' )
data = kwargs['data' ].astype(np.float64)
row_ptr = kwargs['row_ptr'].astype(np.int32 )
col_ind = kwargs['col_ind'].astype(np.int32 )
self.ptr = new Sparse(
<int*> shape.data if shape is not None else NULL,
data.shape[0],
<double*> data .data if data is not None else NULL,
<int*> row_ptr.data if row_ptr is not None else NULL,
<int*> col_ind.data if col_ind is not None else NULL,
)
# ----------------------------------------------------------------------------
def __dealloc__(self):
del self.ptr
# ----------------------------------------------------------------------------
def view(self):
self.ptr.view()
# ----------------------------------------------------------------------------
``setup.py``
from distutils.core import setup, Extension
from Cython.Build import cythonize
setup(ext_modules = cythonize(Extension(
"csparse",
sources=["csparse.pyx", "sparse.cpp"],
language="c++",
)))
# Python side
import numpy as np
import csparse
N = 5000
matrix = csparse.PySparse(
shape = np.array([N,N],dtype='int32'),
data = np.random.rand(N*N),
row_ptr = np.arange(0,N*N+1,N ,dtype='int32'),
col_ind = np.tile(np.arange(0,N,dtype='int32'),N),
)
matrix.view() # --> segmentation fault
| 0debug
|
How do i code so that my button after clicking will direct user to the footer in the same html? : <p>How do i code so that my button onclick will link to my footer section class named "footeradc" in the same html </p>
| 0debug
|
static int gdb_handle_packet(GDBState *s, const char *line_buf)
{
CPUState *env;
const char *p;
int ch, reg_size, type, res, thread;
char buf[MAX_PACKET_LENGTH];
uint8_t mem_buf[MAX_PACKET_LENGTH];
uint8_t *registers;
target_ulong addr, len;
#ifdef DEBUG_GDB
printf("command='%s'\n", line_buf);
#endif
p = line_buf;
ch = *p++;
switch(ch) {
case '?':
snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP,
s->c_cpu->cpu_index+1);
put_packet(s, buf);
gdb_breakpoint_remove_all();
break;
case 'c':
if (*p != '\0') {
addr = strtoull(p, (char **)&p, 16);
#if defined(TARGET_I386)
s->c_cpu->eip = addr;
#elif defined (TARGET_PPC)
s->c_cpu->nip = addr;
#elif defined (TARGET_SPARC)
s->c_cpu->pc = addr;
s->c_cpu->npc = addr + 4;
#elif defined (TARGET_ARM)
s->c_cpu->regs[15] = addr;
#elif defined (TARGET_SH4)
s->c_cpu->pc = addr;
#elif defined (TARGET_MIPS)
s->c_cpu->active_tc.PC = addr;
#elif defined (TARGET_CRIS)
s->c_cpu->pc = addr;
#elif defined (TARGET_ALPHA)
s->c_cpu->pc = addr;
#endif
}
s->signal = 0;
gdb_continue(s);
return RS_IDLE;
case 'C':
s->signal = gdb_signal_to_target (strtoul(p, (char **)&p, 16));
if (s->signal == -1)
s->signal = 0;
gdb_continue(s);
return RS_IDLE;
case 'k':
fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
exit(0);
case 'D':
gdb_breakpoint_remove_all();
gdb_continue(s);
put_packet(s, "OK");
break;
case 's':
if (*p != '\0') {
addr = strtoull(p, (char **)&p, 16);
#if defined(TARGET_I386)
s->c_cpu->eip = addr;
#elif defined (TARGET_PPC)
s->c_cpu->nip = addr;
#elif defined (TARGET_SPARC)
s->c_cpu->pc = addr;
s->c_cpu->npc = addr + 4;
#elif defined (TARGET_ARM)
s->c_cpu->regs[15] = addr;
#elif defined (TARGET_SH4)
s->c_cpu->pc = addr;
#elif defined (TARGET_MIPS)
s->c_cpu->active_tc.PC = addr;
#elif defined (TARGET_CRIS)
s->c_cpu->pc = addr;
#elif defined (TARGET_ALPHA)
s->c_cpu->pc = addr;
#endif
}
cpu_single_step(s->c_cpu, sstep_flags);
gdb_continue(s);
return RS_IDLE;
case 'F':
{
target_ulong ret;
target_ulong err;
ret = strtoull(p, (char **)&p, 16);
if (*p == ',') {
p++;
err = strtoull(p, (char **)&p, 16);
} else {
err = 0;
}
if (*p == ',')
p++;
type = *p;
if (gdb_current_syscall_cb)
gdb_current_syscall_cb(s->c_cpu, ret, err);
if (type == 'C') {
put_packet(s, "T02");
} else {
gdb_continue(s);
}
}
break;
case 'g':
len = 0;
for (addr = 0; addr < num_g_regs; addr++) {
reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr);
len += reg_size;
}
memtohex(buf, mem_buf, len);
put_packet(s, buf);
break;
case 'G':
registers = mem_buf;
len = strlen(p) / 2;
hextomem((uint8_t *)registers, p, len);
for (addr = 0; addr < num_g_regs && len > 0; addr++) {
reg_size = gdb_write_register(s->g_cpu, registers, addr);
len -= reg_size;
registers += reg_size;
}
put_packet(s, "OK");
break;
case 'm':
addr = strtoull(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoull(p, NULL, 16);
if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 0) != 0) {
put_packet (s, "E14");
} else {
memtohex(buf, mem_buf, len);
put_packet(s, buf);
}
break;
case 'M':
addr = strtoull(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoull(p, (char **)&p, 16);
if (*p == ':')
p++;
hextomem(mem_buf, p, len);
if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 1) != 0)
put_packet(s, "E14");
else
put_packet(s, "OK");
break;
case 'p':
if (!gdb_has_xml)
goto unknown_command;
addr = strtoull(p, (char **)&p, 16);
reg_size = gdb_read_register(s->g_cpu, mem_buf, addr);
if (reg_size) {
memtohex(buf, mem_buf, reg_size);
put_packet(s, buf);
} else {
put_packet(s, "E14");
}
break;
case 'P':
if (!gdb_has_xml)
goto unknown_command;
addr = strtoull(p, (char **)&p, 16);
if (*p == '=')
p++;
reg_size = strlen(p) / 2;
hextomem(mem_buf, p, reg_size);
gdb_write_register(s->g_cpu, mem_buf, addr);
put_packet(s, "OK");
break;
case 'Z':
case 'z':
type = strtoul(p, (char **)&p, 16);
if (*p == ',')
p++;
addr = strtoull(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoull(p, (char **)&p, 16);
if (ch == 'Z')
res = gdb_breakpoint_insert(addr, len, type);
else
res = gdb_breakpoint_remove(addr, len, type);
if (res >= 0)
put_packet(s, "OK");
else if (res == -ENOSYS)
put_packet(s, "");
else
put_packet(s, "E22");
break;
case 'H':
type = *p++;
thread = strtoull(p, (char **)&p, 16);
if (thread == -1 || thread == 0) {
put_packet(s, "OK");
break;
}
for (env = first_cpu; env != NULL; env = env->next_cpu)
if (env->cpu_index + 1 == thread)
break;
if (env == NULL) {
put_packet(s, "E22");
break;
}
switch (type) {
case 'c':
s->c_cpu = env;
put_packet(s, "OK");
break;
case 'g':
s->g_cpu = env;
put_packet(s, "OK");
break;
default:
put_packet(s, "E22");
break;
}
break;
case 'T':
thread = strtoull(p, (char **)&p, 16);
#ifndef CONFIG_USER_ONLY
if (thread > 0 && thread < smp_cpus + 1)
#else
if (thread == 1)
#endif
put_packet(s, "OK");
else
put_packet(s, "E22");
break;
case 'q':
case 'Q':
if (!strcmp(p,"qemu.sstepbits")) {
snprintf(buf, sizeof(buf), "ENABLE=%x,NOIRQ=%x,NOTIMER=%x",
SSTEP_ENABLE,
SSTEP_NOIRQ,
SSTEP_NOTIMER);
put_packet(s, buf);
break;
} else if (strncmp(p,"qemu.sstep",10) == 0) {
p += 10;
if (*p != '=') {
snprintf(buf, sizeof(buf), "0x%x", sstep_flags);
put_packet(s, buf);
break;
}
p++;
type = strtoul(p, (char **)&p, 16);
sstep_flags = type;
put_packet(s, "OK");
break;
} else if (strcmp(p,"C") == 0) {
put_packet(s, "QC1");
break;
} else if (strcmp(p,"fThreadInfo") == 0) {
s->query_cpu = first_cpu;
goto report_cpuinfo;
} else if (strcmp(p,"sThreadInfo") == 0) {
report_cpuinfo:
if (s->query_cpu) {
snprintf(buf, sizeof(buf), "m%x", s->query_cpu->cpu_index+1);
put_packet(s, buf);
s->query_cpu = s->query_cpu->next_cpu;
} else
put_packet(s, "l");
break;
} else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) {
thread = strtoull(p+16, (char **)&p, 16);
for (env = first_cpu; env != NULL; env = env->next_cpu)
if (env->cpu_index + 1 == thread) {
len = snprintf((char *)mem_buf, sizeof(mem_buf),
"CPU#%d [%s]", env->cpu_index,
env->halted ? "halted " : "running");
memtohex(buf, mem_buf, len);
put_packet(s, buf);
break;
}
break;
}
#ifdef CONFIG_LINUX_USER
else if (strncmp(p, "Offsets", 7) == 0) {
TaskState *ts = s->c_cpu->opaque;
snprintf(buf, sizeof(buf),
"Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx
";Bss=" TARGET_ABI_FMT_lx,
ts->info->code_offset,
ts->info->data_offset,
ts->info->data_offset);
put_packet(s, buf);
break;
}
#endif
if (strncmp(p, "Supported", 9) == 0) {
snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH);
#ifdef GDB_CORE_XML
strcat(buf, ";qXfer:features:read+");
#endif
put_packet(s, buf);
break;
}
#ifdef GDB_CORE_XML
if (strncmp(p, "Xfer:features:read:", 19) == 0) {
const char *xml;
target_ulong total_len;
gdb_has_xml = 1;
p += 19;
xml = get_feature_xml(p, &p);
if (!xml) {
snprintf(buf, sizeof(buf), "E00");
put_packet(s, buf);
break;
}
if (*p == ':')
p++;
addr = strtoul(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoul(p, (char **)&p, 16);
total_len = strlen(xml);
if (addr > total_len) {
snprintf(buf, sizeof(buf), "E00");
put_packet(s, buf);
break;
}
if (len > (MAX_PACKET_LENGTH - 5) / 2)
len = (MAX_PACKET_LENGTH - 5) / 2;
if (len < total_len - addr) {
buf[0] = 'm';
len = memtox(buf + 1, xml + addr, len);
} else {
buf[0] = 'l';
len = memtox(buf + 1, xml + addr, total_len - addr);
}
put_packet_binary(s, buf, len + 1);
break;
}
#endif
goto unknown_command;
default:
unknown_command:
buf[0] = '\0';
put_packet(s, buf);
break;
}
return RS_IDLE;
}
| 1threat
|
How to concatenate char *variable in C : <pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char *hi = "bye";
char *bye = "abc";
strcat(hi, bye);
printf("%s\n", hi);
}
</code></pre>
<p>How would I concatenate these variables? Everything I'm trying crashes it</p>
| 0debug
|
is it possible to check websites is opened in other tab of a browser in php? : <p>I have two application in php and want to check that any one of them is already opened in other tab of browser. So, is it possible if yes then how?</p>
| 0debug
|
How to tune spark executor number, cores and executor memory? : <p>Where do you start to tune the above mentioned params. Do we start with executor memory and get number of executors, or we start with cores and get the executor number. I followed the <a href="http://blog.cloudera.com/blog/2015/03/how-to-tune-your-apache-spark-jobs-part-2/" rel="noreferrer">link</a>. However got a high level idea, but still not sure how or where to start and arrive to a final conclusion.</p>
| 0debug
|
How should I pass sensitive environment variables to Amazon ECS tasks? : <p>What is the recommended way to pass sensitive environment variables, e.g. passwords, to <a href="https://aws.amazon.com/documentation/ecs/">Amazon ECS</a> tasks? With Docker Compose, I can use <a href="https://docs.docker.com/compose/compose-file/#environment">key-only environment variables</a>, which results in the values being read from the OS environment. I can't see any corresponding method for <a href="http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html">ECS task definitions</a> however.</p>
| 0debug
|
Finding the visitors network ip adress : Im interested in finding the visitors ip similar to how www.ipchicken.com does it, can someone nice out there tell me how to do this and send me a simple code?
Have a great day, love from Sweden!
| 0debug
|
static void dec_ill(DisasContext *dc)
{
cpu_abort(dc->env, "unknown opcode 0x%02x\n", dc->opcode);
}
| 1threat
|
void qemu_aio_poll(void)
{
}
| 1threat
|
FileUpload using Socket in java : <p>when i try upload file from client device to server using socket in java. it get uploaded in server but the problem is that when i tried to open it show some error.(for example:if i upload photos from client to server,it get uploaded but when i tried to open it show error "<strong>unsupported file format</strong>".</p>
<p>clientSide:</p>
<pre><code>DataOutputStream dos = new DataOutputStream(tmp.getClientSocket().getOutputStream());
BufferedInputStream fileReader=new BufferedInputStream(new FileInputStream(f));
byte[] buffer = new byte[1024];
int byteRead=0;
while((byteRead=fileReader.read(buffer))!=-1) {
dos.write(buffer,0,byteRead);
dos.flush();
System.out.println("uploading "+byteRead);
}
fileReader.close();
System.out.println("uploading file completed");
</code></pre>
<p>serverSide:</p>
<pre><code>String filename=this.input.readLine();
System.out.println("file to be upload is "+filename);
InputStream inputByte=socket.getInputStream();
BufferedInputStream input=new BufferedInputStream(inputByte);
String response=this.input.readLine();
if(response.equals("start")) {
BufferedOutputStream outputFile=new BufferedOutputStream(new FileOutputStream(projectDirPath+"\\"+filename));
byte[] buffer =new byte[1024];
int byteRead=0;
while((byteRead=input.read(buffer))!=-1) {
outputFile.write(buffer,0,byteRead);
outputFile.flush();
System.out.println("uploading "+byteRead);
}
outputFile.close();
}else {
System.out.println("nothing to upload");
}
</code></pre>
| 0debug
|
A vector container declared in a different source file used in an "if" statement is out of scope? : I've created a source file that contains a number of data structures (maps, vector, array). Its header file is `#included` in the main-file.
The main file looks like this:
#include "src1.h" //Where monkey() and vector<int> bar are declared
main()
{
monkey(bar); // Calling monkey(bar) here is OK! Bar is visible
...
ifstream fp("foo.txt");
if(fp.is_open())
{
std::string line;
while( getline(fp,line) )
{
monkey(bar); //'bar' is an undefined reference!
}
}
}
And **src1.h**
#ifndef SRC1_H
#define SRC1_H
extern std::vector<int> bar;
void monkey(std::vector<int> feces);
#endif
And **src1.cpp**
std::vector<int> bar;
void monkey(std::vector<int> thrown_obj)
{
... //Iteration and dereferencing of "thrown_obj"
}
I've accessed data structures that are declared in `src1.cpp` in a for-loop in the scope of main and *that* was fine. Something wonky is happening in this if-statement though.
Compiler Error:
lab1.o: In function `main':
/home/ubuntu/workspace/ECE597/Lab1/lab1.cc:105: undefined reference to `int_req'
collect2: error: ld returned 1 exit status
| 0debug
|
Failed to find byte code for com/google/firebase : <p>I made following upgrades today</p>
<ol>
<li>Android Studio <strong>3.0</strong> -> <strong>3.1</strong></li>
<li><p>In <code>build.gradle</code></p>
<p>dependencies {
classpath 'com.android.tools.build:gradle:<strong>3.0.1</strong>' -> <strong>3.1.0</strong>
}</p></li>
<li><p>In <code>gradle/wrapper/gradle-wrapper.properties</code></p>
<p>distributionUrl=https://services.gradle.org/distributions/<strong>gradle-4.5-all.zip</strong> -> <strong>gradle-4.6-all.zip</strong></p></li>
</ol>
<p>And I am now getting following error with my firebase modules (random module at a time when I build)</p>
<blockquote>
<p>Failed to find byte code for
com/google/firebase/storage/StreamDownloadTask$StreamProcessor</p>
</blockquote>
<p>or sometimes</p>
<blockquote>
<p>Failed to find byte code for
com/google/firebase/database/ChildEventListener</p>
</blockquote>
<p>My project implements</p>
<pre><code>dependencies {
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-firestore:11.8.0'
compile 'com.google.firebase:firebase-invites:11.8.0'
compile "com.google.firebase:firebase-messaging:11.8.0"
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.1.0'
}
</code></pre>
| 0debug
|
int cpu_cris_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
int mmu_idx, int is_softmmu)
{
struct cris_mmu_result res;
int prot, miss;
int r = -1;
target_ulong phy;
D(printf ("%s addr=%x pc=%x rw=%x\n", __func__, address, env->pc, rw));
miss = cris_mmu_translate(&res, env, address & TARGET_PAGE_MASK,
rw, mmu_idx, 0);
if (miss)
{
if (env->exception_index == EXCP_BUSFAULT)
cpu_abort(env,
"CRIS: Illegal recursive bus fault."
"addr=%x rw=%d\n",
address, rw);
env->pregs[PR_EDA] = address;
env->exception_index = EXCP_BUSFAULT;
env->fault_vector = res.bf_vec;
r = 1;
}
else
{
phy = res.phy & ~0x80000000;
prot = res.prot;
tlb_set_page(env, address & TARGET_PAGE_MASK, phy,
prot | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE);
r = 0;
}
if (r > 0)
D_LOG("%s returns %d irqreq=%x addr=%x"
" phy=%x ismmu=%d vec=%x pc=%x\n",
__func__, r, env->interrupt_request,
address, res.phy, is_softmmu, res.bf_vec, env->pc);
return r;
}
| 1threat
|
{"multicast_id":8972998920482382311,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} : i want to send push notification from web to android devices but it responses invallid registration
i tried to send from firebase consol but is does not include message data
<?php
//$con= new mysqli("localhost","root","","doctor_appointment");
include('connection.php');
$sql = " Select * From token_register where id = 1";
$result = mysqli_query($connection_to_db,$sql);
$tokens = array();
if(mysqli_num_rows($result) > 0 ){
while ($row = mysqli_fetch_assoc($result)) {
$tokens[] = $row["token"];
// $token = $row["token"];
// echo "$token";
}
}
mysqli_close($connection_to_db);
function send_notification ($tokens, $message)
{
// define( 'API_ACCESS_KEY', 'AIzaSyDt2xaRw4XGzghfxAMRFVy-I8ZeacBDbHA');
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'registration_ids' => array($tokens),
'data' => array( "message" => $message ),
);
$headers = array(
'Authorization:key = AIzaSyDdHTdvqzN8lrUqhZKOeuiR2d9cETRBhNw',
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
return $result;
}
$message = array("message" => " FCM PUSH NOTIFICATION TEST MESSAGE");
$message_status = send_notification($tokens, $message);
echo $message_status;
?>
i expected to be {"multicast_id":7068539387015084016,"success":1,"failure":0,"results":[{"RegistrationSuccess"}]} but responses {"multicast_id":7068539387015084016,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
| 0debug
|
static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
{
char mime[1024];
char description[1024];
unsigned int filesize;
AVStream *st;
int64_t pos = avio_tell(pb);
avio_get_str16le(pb, INT_MAX, mime, sizeof(mime));
if (strcmp(mime, "image/jpeg"))
goto done;
avio_r8(pb);
avio_get_str16le(pb, INT_MAX, description, sizeof(description));
filesize = avio_rl32(pb);
if (!filesize)
goto done;
st = avformat_new_stream(s, NULL);
if (!st)
goto done;
av_dict_set(&st->metadata, "title", description, 0);
st->codec->codec_id = AV_CODEC_ID_MJPEG;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_mallocz(filesize);
if (!st->codec->extradata)
goto done;
st->codec->extradata_size = filesize;
avio_read(pb, st->codec->extradata, filesize);
done:
avio_seek(pb, pos + length, SEEK_SET);
}
| 1threat
|
void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
{
QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
QXLCursor *cursor;
QEMUCursor *c;
if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {
return;
}
if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {
fprintf(stderr, "%s", __FUNCTION__);
qxl_log_cmd_cursor(qxl, cmd, ext->group_id);
fprintf(stderr, "\n");
}
switch (cmd->type) {
case QXL_CURSOR_SET:
cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id);
if (cursor->chunk.data_size != cursor->data_size) {
fprintf(stderr, "%s: multiple chunks\n", __FUNCTION__);
return;
}
c = qxl_cursor(qxl, cursor);
if (c == NULL) {
c = cursor_builtin_left_ptr();
}
qemu_mutex_lock(&qxl->ssd.lock);
if (qxl->ssd.cursor) {
cursor_put(qxl->ssd.cursor);
}
qxl->ssd.cursor = c;
qxl->ssd.mouse_x = cmd->u.set.position.x;
qxl->ssd.mouse_y = cmd->u.set.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
break;
case QXL_CURSOR_MOVE:
qemu_mutex_lock(&qxl->ssd.lock);
qxl->ssd.mouse_x = cmd->u.position.x;
qxl->ssd.mouse_y = cmd->u.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
break;
}
}
| 1threat
|
Why is a tuple of falsey objects truthy? : <p>Came across this in a recent project and was curious as to why this is the case.</p>
<pre><code>test_ = None
test_1 = []
test_2 = ([], None)
if test_:
print('hello')
if test_1:
print('hello')
if test_2:
print('hello')
> hello
</code></pre>
| 0debug
|
-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x7aa78d20 : I got Json response from server as json array.
but if i am accessing element of that array using indexpath.row in didselectrowatindexpath, I am getting error as *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x7aa78d20'
| 0debug
|
Kotlin - Idiomatic way to remove duplicate strings from array? : <p>How to remove duplicates from an <code>Array<String?></code> in kotlin?</p>
| 0debug
|
How to reopen a fuction : I have disabled the quick fix function (Alt+Enter) in android stutio by mistake and now I want to reopen it.
I tried to change the settings, but failed because I'm not familiar with Android Stutio.Can someone help me?
| 0debug
|
int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps, int dx, int dy)
{
int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1;
if (ret=ff_j2k_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels-1, codsty->transform))
return ret;
for (i = 0; i < 2; i++)
csize *= comp->coord[i][1] - comp->coord[i][0];
comp->data = av_malloc(csize * sizeof(int));
if (!comp->data)
return AVERROR(ENOMEM);
comp->reslevel = av_malloc(codsty->nreslevels * sizeof(J2kResLevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
int declvl = codsty->nreslevels - reslevelno;
J2kResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_j2k_ceildivpow2(comp->coord[i][j], declvl - 1);
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x = ff_j2k_ceildivpow2(reslevel->coord[0][1], codsty->log2_prec_width)
- (reslevel->coord[0][0] >> codsty->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y = ff_j2k_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height)
- (reslevel->coord[1][0] >> codsty->log2_prec_height);
reslevel->band = av_malloc(reslevel->nbands * sizeof(J2kBand));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++){
J2kBand *band = reslevel->band + bandno;
int cblkno, precx, precy, precno;
int x0, y0, x1, y1;
int xi0, yi0, xi1, yi1;
int cblkperprecw, cblkperprech;
if (qntsty->quantsty != J2K_QSTY_NONE){
static const uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}};
int numbps;
numbps = cbps + lut_gain[codsty->transform][bandno + reslevelno>0];
band->stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]);
} else
band->stepsize = 1 << 13;
if (reslevelno == 0){
band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width-1);
band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height-1);
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] = ff_j2k_ceildivpow2(comp->coord[i][j], declvl-1);
} else{
band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width);
band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height);
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] = ff_j2k_ceildivpow2(comp->coord[i][j] - (((bandno+1>>i)&1) << declvl-1), declvl);
}
band->cblknx = ff_j2k_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width;
band->cblkny = ff_j2k_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height;
for (j = 0; j < 2; j++)
band->coord[0][j] = ff_j2k_ceildiv(band->coord[0][j], dx);
for (j = 0; j < 2; j++)
band->coord[1][j] = ff_j2k_ceildiv(band->coord[1][j], dy);
band->cblknx = ff_j2k_ceildiv(band->cblknx, dx);
band->cblkny = ff_j2k_ceildiv(band->cblkny, dy);
band->cblk = av_malloc(band->cblknx * band->cblkny * sizeof(J2kCblk));
if (!band->cblk)
return AVERROR(ENOMEM);
band->prec = av_malloc(reslevel->num_precincts_x * reslevel->num_precincts_y * sizeof(J2kPrec));
if (!band->prec)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){
J2kCblk *cblk = band->cblk + cblkno;
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
y0 = band->coord[1][0];
y1 = ((band->coord[1][0] + (1<<codsty->log2_prec_height)) & ~((1<<codsty->log2_prec_height)-1)) - y0;
yi0 = 0;
yi1 = ff_j2k_ceildivpow2(y1 - y0, codsty->log2_cblk_height) << codsty->log2_cblk_height;
yi1 = FFMIN(yi1, band->cblkny);
cblkperprech = 1<<(codsty->log2_prec_height - codsty->log2_cblk_height);
for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++){
for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++){
band->prec[precno].yi0 = yi0;
band->prec[precno].yi1 = yi1;
}
yi1 += cblkperprech;
yi0 = yi1 - cblkperprech;
yi1 = FFMIN(yi1, band->cblkny);
}
x0 = band->coord[0][0];
x1 = ((band->coord[0][0] + (1<<codsty->log2_prec_width)) & ~((1<<codsty->log2_prec_width)-1)) - x0;
xi0 = 0;
xi1 = ff_j2k_ceildivpow2(x1 - x0, codsty->log2_cblk_width) << codsty->log2_cblk_width;
xi1 = FFMIN(xi1, band->cblknx);
cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width);
for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++){
for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0){
J2kPrec *prec = band->prec + precno;
prec->xi0 = xi0;
prec->xi1 = xi1;
prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
if (!prec->cblkincl || !prec->zerobits)
return AVERROR(ENOMEM);
}
xi1 += cblkperprecw;
xi0 = xi1 - cblkperprecw;
xi1 = FFMIN(xi1, band->cblknx);
}
}
}
return 0;
}
| 1threat
|
static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2;
srcStride[2] *= 2;
}
assert(srcStride[1] == srcStride[2]);
mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
return srcSliceH;
}
| 1threat
|
Refreshing page by f5 or reload button without lost the iframe page : <p>Refreshing page by f5 or reload button without lost the iframe page:</p>
<p>Hello!</p>
<p>I'v a webpage that contains a iframe and I want that when refresh button will clicks the iframe stay on currnet page and not back to the defult page.</p>
<p>For exmple:</p>
<p>When I enter to webpage I see an iframe with url google.com and I move in iframe to google.co.il, I want that when I refresh this it will refresh the google.co.il and isn't back to google.com.</p>
<p>tnx very much!</p>
| 0debug
|
C++, Plotting points using Nested For Loops : wondering if someone can help me. I'm relatively new to C++ and we have been given this task to do:
**Write a C++ program which asks the user for a number n between 1 and 10. The program should then print out n lines. Each should consist of a number of stars of the same number as the current line number. For example:
Please enter a number: 5
*
**
***
****
*****
The problem I am having is that when I use the code I've written it displays wrong.
[enter image description here][1]
[1]: http://i.stack.imgur.com/pxTZL.png
The code I have right now reads like this:
#include<iostream>
using namespace std;
int main() {
int n;
cout << "Please enter a number between 1 and 10:" << endl;
cin >> n;
for (int x = 0; x <= n; x++)
{
for (int y = 0; y <= n; y++) {
cout << "*" ;
}
cout << "*" << endl;
cin.get();
}
return 0;
}
Any help would really be appreciated! Thanks a lot.
| 0debug
|
static void kvmclock_realize(DeviceState *dev, Error **errp)
{
KVMClockState *s = KVM_CLOCK(dev);
kvm_update_clock(s);
qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s);
| 1threat
|
What is the purpose of using the -i and -1 in the following: array[name.Length - i] = name[i - 1]; : <p>array[name.Length - i] = name[i - 1];</p>
<p>In the piece of code above, I understand that the purpose of it is is taking each letter of the name array and placing it into the array named array. What I am not sure about is the logical explanation as to what exactly the -i and the -1 is doing. Is this just syntax I have to memorize?</p>
<p>Thus far, I understand that the left side of the assignment state is indicating where the letters are going ( 1 letter a at time) while the right side is indicating where the letters are coming from (1 letter at a time). However, the reason for the structure is still not clear to me.</p>
<p>The purpose of the code is to ask the user to enter their name. Use an array to reverse the name and then store the result in a new string.
/// Display the reversed name on the console.</p>
<pre><code> {
Console.Write("What's your name? ");
var name = Console.ReadLine();
var array = new char[name.Length];
for (var i = name.Length; i > 0; i--)
array[name.Length - i] = name[i - 1];
var reversed = new string(array);
Console.WriteLine("Reversed name: " + reversed);
}
</code></pre>
| 0debug
|
How to prevent http.ListenAndServe altering style attributes in static output? : <p>In a very rudimentary handwritten web page (no js, stylesheets, etc) I have some static html with a section that looks like this.</p>
<pre><code><li style="font-size:200%; margin-bottom:3vh;">
<a href="http://192.168.1.122:8000">
Reload HMI
</a>
</li>
</code></pre>
<p>I'm using Go's http.ListenAndServe to serve the page. What's coming out looks like this:</p>
<pre><code><li style="font-size:200%!;(MISSING) margin-bottom:3vh;">
<a href="http://192.168.1.122:8000">
Reload HMI
</a>
</li>
</code></pre>
<p>Note the altered style attribute.</p>
<p>The server implementation is also rudimentary. It's launched as a goroutine:</p>
<pre><code>// systemControlService provides pages on localhost:8003 that
// allow reboots, shutdowns and restoring configurations.
func systemControlService() {
info("Launching system control service")
http.HandleFunc("/", controlPage)
log.Fatal(http.ListenAndServe(":8003", nil))
}
// loadPage serves the page named by title
func loadPage(title string) ([]byte, error) {
filename := "__html__/" + title + ".html"
info(filename + " requested")
content, err := ioutil.ReadFile(filename)
if err != nil {
info(fmt.Sprintf("error reading file: %v", err))
return nil, err
}
info(string(content))
return content, nil
}
// controlPage serves controlpage.html
func controlPage(w http.ResponseWriter, r *http.Request) {
p, _ := loadPage("controlpage")
fmt.Fprintf(w, string(p))
}
</code></pre>
<p>In func <code>loadPage()</code> above, <code>info</code> is a logging call. For debug, I'm calling it just before returning the content of <code>controlpage.html</code>. The log entry shows it's not mangled at that point, so the problem pretty much has to be within ListenAndServe. </p>
<p>I'm not finding anything in the Go docs for <code>http</code> that seems applicable. I have no idea what's going on here. Any help appreciated.</p>
| 0debug
|
Urgent Assignment assistance error message : So I'm working on an assignment, using codeblocks for c language.
first year student, trying to solve an error message.
user must choose between the following projectiles.
each projectile has a blast radius and this is the code i have so far:
userProjectileChoice = myProjectiles[3];
myProjectiles[0].projectileName = "cannonBall"; myProjectiles[0].blastRadius = 10;
myProjectiles[1].projectileName = "highExplosiveShell"; myProjectiles[1].blastRadius = 1;
myProjectiles[2].projectileName = "mortarBomb";
myProjectiles[2].blastRadius = 1000;
i need to use the struct as it is required.
error message: incompatible types when assigning to type 'int' from type 'struct'
please help
| 0debug
|
ClassName styles not working in react : <p>I'm having a little issue with styling react components. I have my scss stylesheets in a separate file and importing them into my react file. My scss stylsheet looks like this:</p>
<pre><code>.testStyle {
font-family: avenir;
color: blue;
}
</code></pre>
<p>My react file, looks like this:</p>
<pre><code>import React from 'react'
import styles from '../styles/main.scss'
class Temp extends React.Component {
render() {
return (
**<div className={styles.testStyle}>**
<h1>Hello</h1>
</div>
)
}
}
export default Temp
</code></pre>
<p>With this setup, my styles are not passed through, however, if it works if I replace the starred line with <code><div className='testStyle'></code>, so it seems like the styles are being imported correctly. Can anyone help with this? Thanks.</p>
| 0debug
|
How to change application icon in Xamarin.Forms? : <p>I replaced all the images everywhere (by this I mean in drawable folders and all Windows Assets folders and iOS Resources folder), but it still shows me the default Xamarin icon for the app. I tried this code, too, but it doesn't seem to work either. Can someone tell me the solution?</p>
<pre><code>[assembly: Application(Icon = "@drawable/icon")]
</code></pre>
| 0debug
|
static int check_refcounts_l1(BlockDriverState *bs,
uint16_t *refcount_table,
int refcount_table_size,
int64_t l1_table_offset, int l1_size,
int check_copied)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l1_table, l2_offset, l1_size2;
int i, refcount, ret;
int errors = 0;
l1_size2 = l1_size * sizeof(uint64_t);
errors += inc_refcounts(bs, refcount_table, refcount_table_size,
l1_table_offset, l1_size2);
l1_table = qemu_malloc(l1_size2);
if (bdrv_pread(s->hd, l1_table_offset,
l1_table, l1_size2) != l1_size2)
goto fail;
for(i = 0;i < l1_size; i++)
be64_to_cpus(&l1_table[i]);
for(i = 0; i < l1_size; i++) {
l2_offset = l1_table[i];
if (l2_offset) {
if (check_copied) {
refcount = get_refcount(bs, (l2_offset & ~QCOW_OFLAG_COPIED)
>> s->cluster_bits);
if ((refcount == 1) != ((l2_offset & QCOW_OFLAG_COPIED) != 0)) {
fprintf(stderr, "ERROR OFLAG_COPIED: l2_offset=%" PRIx64
" refcount=%d\n", l2_offset, refcount);
l2_offset &= ~QCOW_OFLAG_COPIED;
errors += inc_refcounts(bs, refcount_table,
refcount_table_size,
l2_offset,
s->cluster_size);
ret = check_refcounts_l2(bs, refcount_table, refcount_table_size,
l2_offset, check_copied);
if (ret < 0) {
goto fail;
errors += ret;
qemu_free(l1_table);
return errors;
fail:
fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n");
qemu_free(l1_table);
return -EIO;
| 1threat
|
iterating through a dictionary and an array within (Python) : I have a dictionary example as:
dict = {Bay1: [False,False,True],
Bay2: [True,True,True],
Bay3: [True,True,False],
Bay4: [False,False,False] }
And what Iam trying to do is go through the dictionary by checking each bay(Bay1..Bay2...) to see which one has an array where everything inside it is False so i want it to return 'Bay4' to me.
Secondly, I want to be able to check to see which is false and which is true in each Bayx by doing some Loops. So in other words, if you imagine that True represents being 'Booked' and false to represent being free or 'Not booked'. I want to be able to check that for each bay and present it to the user in a good and easily readable format.
Thank you very much in advance!!!
| 0debug
|
Spring retry connection until datasource is available : <p>I have a docker-compose setup to start my SpringBoot application and a MySQL database. If the database starts first, then my application can connect successfully. But if my application starts first, no database exists yet, so the application throws the following exception and exits:</p>
<pre><code>app_1 | 2018-05-27 14:15:03.415 INFO 1 --- [ main]
com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
app_1 | 2018-05-27 14:15:06.770 ERROR 1 --- [ main]
com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization
app_1 | com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
</code></pre>
<p>I could edit my docker-compose file to make sure the database is always up before the application starts up, but I want the application to be able to handle this case on its own, and not immediately exit when it cannot reach the database address.</p>
<p>There are ways to configure the datasource in the application.properties file to make the application reconnect to the database, as answered <a href="https://stackoverflow.com/a/33213802/6566891">here</a> and <a href="https://stackoverflow.com/a/22687418/6566891">here</a>. But that doesn't work for a startup connection to the datasource.</p>
<p>How can I make my SpringBoot application retry the connection at startup to the database at a given interval until it successfully connects to the database?</p>
| 0debug
|
Query string closures in php : <p>I'm attempting to setup a query through php to a MySQL database. Within the query string I have placed functions and thus have used the dot (.) operator with string closures as seen below. The issue is that my query is not going through and try as i might I can't seem to make out the error. Thanks for any help in advance. :) </p>
<pre><code>$query = "INSERT INTO `foo` (`ip`, `time`, `date`, `reason`) VALUES ('".strval(getUserIpAddr())."', '".$time."', '".$date."', '".$reason."')";
</code></pre>
| 0debug
|
How to use decimal type in MongoDB : <p>How can I store decimals in MongoDB using the standard C# driver? It seems that all decimals are stored inside the database as strings.</p>
| 0debug
|
How to remove one of duplicate keys (one in lowercase one in uppercase) but keep their values? : I have a list of dictionaries called `dicts`. I am writing `dicts` into a csv file using DictWriter. `dicts` has duplicate keys like: `Accepted Currencies (DASH)` and `Accepted Currencies (Dash)` which I would like to merge those keys into a single key with uppercase i.e. I want to only keep `Accepted Currencies (DASH)` as a key and also keep both keys' values. For instance, currently, I'd like to have something like the following:
[![enter image description here][1]][1]
Here is my code:
fieldnames = set()
fieldnames.update(*(d.keys() for d in dicts))
fieldnames = sorted(fieldnames)
with open('/home/zeinab/Documents/ICOannouncements/myfile.csv', 'a', newline='') as f:
writer= csv.DictWriter(f, fieldnames=fieldnames)
writer.writeheader()
for d in dicts:
writer.writerow(d)
[1]: https://i.stack.imgur.com/NzjEg.png
| 0debug
|
static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt, int *serial)
{
int got_picture;
if (packet_queue_get(&is->videoq, pkt, 1, serial) < 0)
return -1;
if (pkt->data == flush_pkt.data) {
avcodec_flush_buffers(is->video_st->codec);
SDL_LockMutex(is->pictq_mutex);
while (is->pictq_size && !is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex);
}
is->video_current_pos = -1;
is->frame_last_pts = AV_NOPTS_VALUE;
is->frame_last_duration = 0;
is->frame_timer = (double)av_gettime() / 1000000.0;
is->frame_last_dropped_pts = AV_NOPTS_VALUE;
SDL_UnlockMutex(is->pictq_mutex);
return 0;
}
if(avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt) < 0)
return 0;
if (got_picture) {
int ret = 1;
if (decoder_reorder_pts == -1) {
*pts = av_frame_get_best_effort_timestamp(frame);
} else if (decoder_reorder_pts) {
*pts = frame->pkt_pts;
} else {
*pts = frame->pkt_dts;
}
if (*pts == AV_NOPTS_VALUE) {
*pts = 0;
}
if (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) {
SDL_LockMutex(is->pictq_mutex);
if (is->frame_last_pts != AV_NOPTS_VALUE && *pts) {
double clockdiff = get_video_clock(is) - get_master_clock(is);
double dpts = av_q2d(is->video_st->time_base) * *pts;
double ptsdiff = dpts - is->frame_last_pts;
if (!isnan(clockdiff) && fabs(clockdiff) < AV_NOSYNC_THRESHOLD &&
ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD &&
clockdiff + ptsdiff - is->frame_last_filter_delay < 0) {
is->frame_last_dropped_pos = pkt->pos;
is->frame_last_dropped_pts = dpts;
is->frame_drops_early++;
ret = 0;
}
}
SDL_UnlockMutex(is->pictq_mutex);
}
return ret;
}
return 0;
}
| 1threat
|
How to sort a version list? :
<p>I have a method that list some versions of an application on my computer, the list following has this format and the content are strings:</p>
<pre class="lang-none prettyprint-override"><code>['1.15.1.23', '1.10.1.34', '1.9.2.3', ...]
</code></pre>
<p>When I call <code>sorted(mylist)</code>, the output does not appear to sort some items, I'm getting this:</p>
<pre class="lang-none prettyprint-override"><code>['1.15.1.51', '1.15.1.9', '1.15.2.11', '1.15.2.6']
</code></pre>
<p>What I'm doing wrong? I expected the output as:</p>
<pre class="lang-none prettyprint-override"><code>['1.15.1.9', '1.15.1.51', '1.15.2.6', '1.15.2.11']
</code></pre>
| 0debug
|
How to avoid multiple for loop - R Programing : I have a dataframe that has 175180 rows and 301 columns. My first 6 columns are filled with data and after that columns in (2k+1) [k>=5] are filled and rest are null. The null columns will be filled based on the values in columns that will get filled with the for loop running.
Since, it will be an element wise comparison for each column, I am using two for loops, the inner one to run through all the columns and the outer one to run through all the rows. This is taking like infinite time to run. How can I optimise this?
I tried removing the outer for loop and the j elements from my code, but then it just compares vector of length 1 and I am not able to do element wise comparison. Following is my code :
for (j in 1:175180) {
for (i in 6:(ncol(nsd)-2)) {
if ((i-1)%%5==0) {nsd[j,i]<-nsd[j,i]}
else if ((i-2)%%5==0) {nsd[j,i]<-nsd[j,i-1]}
else if ( (i-3)%%5==0 && nsd[j,i-1]>0 && nsd[j,i-1] >= nsd[j,i-3] ) {nsd[j,i] <- nsd[j,i-1] - nsd[j,i-3]}
else if ((i-3)%%5==0 && nsd[j,i-1]>=0 && nsd[j,i-1]<nsd[j,i-3]) {nsd[j,i]<- 0}
else if ((i-4)%%5==0 && nsd[j,i+2]>=(nsd[j,i-1]+nsd[j,i-4])) {nsd[j,i]<- nsd[j,i-1]+nsd[j,i-4]}
else if ((i-4)%%5==0 && nsd[j,i+2]<(nsd[j,i-1]+nsd[j,i-4])) {nsd[j,i]<- nsd[j,i+2]}
else if ((i-5)%%5==0 && (nsd[j,i-2] + nsd[j,i-5]) > nsd[j, i-1]) {nsd[j,i]<- nsd[j,i-2] + nsd[j,i-5] - nsd[j, i-1] }
else if ((i-5)%%5==0 && (nsd[j,i-2] + nsd[j,i-5]) <= nsd[j, i-1]) {nsd[j,i]<- 0 }
}}
| 0debug
|
Any way to workaround that css grid doesn't ignore <object> tags? : I have a grid that distributes elements in rows of 4, something like this
```html
<div class="grid">
<div>el1</div>
<div>el2</div>
<div>el3</div>
<div>el4</div>
<div>el5</div>
<div>el6</div>
<div>el7</div>
<div>el8</div>
<div>el9</div>
<div>el10</div>
<div>el11</div>
<div>el12</div>
</div>
```
So I would have a table of 3 rows of 4 elements each one
```css
.grid {
display: grid;
grid-template-columns: repeat(8,auto);
}
```
I create this grid with a `map()` function in `React`, with a function like this
```js
Table.info = () => (
<>
<div>el1</div>
<div>el2</div>
<div>el3</div>
<div>el4</div>
{myarray.map((el, i) => (
<>
<div>{el.name}</div>
<div>{el.name}</div>
<div>{el.name}</div>
<div>{el.name}</div>
</>
))}
</>
)
```
But as expected, I get the warning to include a key
The problem is that to do so I need to use the `<object>` tag, but this tag is seen by `css-grid` destroying the alignment
```js
Table.info = () => (
<>
<div>el1</div>
<div>el2</div>
<div>el3</div>
<div>el4</div>
{myarray.map((el, i) => (
<object key={'table'+i}>
<div>{el.name}</div>
<div>{el.name}</div>
<div>{el.name}</div>
<div>{el.name}</div>
</object >
))}
</>
)
```
```html
<div class="grid">
<div>el1</div>
<div>el2</div>
<div>el3</div>
<div>el4</div>
<object>
<div>el5</div>
<div>el6</div>
<div>el7</div>
<div>el8</div>
</object>
<object>
<div>el9</div>
<div>el10</div>
<div>el11</div>
<div>el12</div>
</object>
</div>
```
How could I workaround this, preferably keeping the use of `grid`?
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.