problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How do I stretch an image to fit the whole background (100% height x 100% width) in Flutter? : <p>I have an image that doesn't match the aspect ratio of my device's screen. I want to stretch the image so that it fully fills the screen, and I don't want to crop any part of the image.</p>
<p>CSS has the concept of percentages, so I could just set height and width to 100%. But it doesn't seem like Flutter has that concept, and it's bad to just hard code the height and width, so I'm stuck.</p>
<p>Here's what I have (I'm using a Stack since I have something in the foreground of the image):</p>
<pre><code>Widget background = new Container(
height: // Not sure what to put here!
width: // Not sure what to put here!
child: new Image.asset(
asset.background,
fit: BoxFit.fill, // I thought this would fill up my Container but it doesn't
),
);
return new Stack(
children: <Widget>[
background,
foreground,
],
);
</code></pre>
| 0debug |
static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
bool want_zero,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
int64_t total_sectors;
int64_t n;
int64_t ret, ret2;
BlockDriverState *local_file = NULL;
assert(pnum);
*pnum = 0;
total_sectors = bdrv_nb_sectors(bs);
if (total_sectors < 0) {
ret = total_sectors;
goto early_out;
}
if (sector_num >= total_sectors) {
ret = BDRV_BLOCK_EOF;
goto early_out;
}
if (!nb_sectors) {
ret = 0;
goto early_out;
}
n = total_sectors - sector_num;
if (n < nb_sectors) {
nb_sectors = n;
}
if (!bs->drv->bdrv_co_get_block_status) {
*pnum = nb_sectors;
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
if (sector_num + nb_sectors == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
if (bs->drv->protocol_name) {
ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
local_file = bs;
}
goto early_out;
}
bdrv_inc_in_flight(bs);
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,
&local_file);
if (ret < 0) {
*pnum = 0;
goto out;
}
if (ret & BDRV_BLOCK_RAW) {
assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file);
ret = bdrv_co_get_block_status(local_file, want_zero,
ret >> BDRV_SECTOR_BITS,
*pnum, pnum, &local_file);
goto out;
}
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ALLOCATED;
} else if (want_zero) {
if (bdrv_unallocated_blocks_are_zero(bs)) {
ret |= BDRV_BLOCK_ZERO;
} else if (bs->backing) {
BlockDriverState *bs2 = bs->backing->bs;
int64_t nb_sectors2 = bdrv_nb_sectors(bs2);
if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {
ret |= BDRV_BLOCK_ZERO;
}
}
}
if (want_zero && local_file && local_file != bs &&
(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
(ret & BDRV_BLOCK_OFFSET_VALID)) {
int file_pnum;
ret2 = bdrv_co_get_block_status(local_file, want_zero,
ret >> BDRV_SECTOR_BITS,
*pnum, &file_pnum, NULL);
if (ret2 >= 0) {
if (ret2 & BDRV_BLOCK_EOF &&
(!file_pnum || ret2 & BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ZERO;
} else {
*pnum = file_pnum;
ret |= (ret2 & BDRV_BLOCK_ZERO);
}
}
}
out:
bdrv_dec_in_flight(bs);
if (ret >= 0 && sector_num + *pnum == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
early_out:
if (file) {
*file = local_file;
}
return ret;
}
| 1threat |
I am having error while running nativescrpt : Am having this error when ever I try tns run android
Unable to apply changes on device: 037440992E015901. Error is: zlib: unexpected end of file.
ENOTEMPTY: directory not empty, rmdir 'C:\Users\Hazin\AppData\Local\Temp\runtimeDir119530-8496-2dkhiq.wv07n\framework\build-tools' | 0debug |
void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req)
{
VirtIODevice *vdev = (VirtIODevice *)s;
int type;
int r = 0;
if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,
&type, sizeof(type)) < sizeof(type)) {
virtio_scsi_bad_req();
return;
}
virtio_tswap32s(vdev, &req->req.tmf.type);
if (req->req.tmf.type == VIRTIO_SCSI_T_TMF) {
if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICtrlTMFReq),
sizeof(VirtIOSCSICtrlTMFResp)) < 0) {
virtio_scsi_bad_req();
} else {
r = virtio_scsi_do_tmf(s, req);
}
} else if (req->req.tmf.type == VIRTIO_SCSI_T_AN_QUERY ||
req->req.tmf.type == VIRTIO_SCSI_T_AN_SUBSCRIBE) {
if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICtrlANReq),
sizeof(VirtIOSCSICtrlANResp)) < 0) {
virtio_scsi_bad_req();
} else {
req->resp.an.event_actual = 0;
req->resp.an.response = VIRTIO_SCSI_S_OK;
}
}
if (r == 0) {
virtio_scsi_complete_req(req);
} else {
assert(r == -EINPROGRESS);
}
}
| 1threat |
Flutter : Custom Radio Button : <p>How can I create a custom radio button group like this in flutter <a href="https://i.stack.imgur.com/TDsGj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/TDsGj.jpg" alt="custom radio in flutter"></a> </p>
| 0debug |
I have developed a word press website using local host.How can I give that to my client? : I have developed a word press website using local host. Now I am giving that site to my client , what files do I need to give him and how will I generate that files? | 0debug |
Sending data from one controller to another : <p>I think this is a very simple problem but i'm not able to figure it out.</p>
<p>I have 2 controllers in my angularjs file..</p>
<pre><code>analyzer.controller('AnalyzerController',function($scope,$http)
{
$scope.builds = [];
$http.get('/List').success(
function(data) {
$scope.builds = data.responseData;
});
$scope.showbuild=function(item){
alert(item);
}
});
analyzer.controller('Information',function($scope,$http)
{
$scope.cases = [];
$http.get('/info').success(
function(data) {
$scope.cases = data.responseData;
});
});
</code></pre>
<p>I want to send the value of item in the first controller to the 2nd controller . Item is the value user selects from a box of html page.</p>
| 0debug |
import heapq
def merge_sorted_list(num1,num2,num3):
num1=sorted(num1)
num2=sorted(num2)
num3=sorted(num3)
result = heapq.merge(num1,num2,num3)
return list(result) | 0debug |
git rebase -i -- why is it changing commit hashes? : <p>So I'm more or less familiar with how rebasing works, but up until recently I usually just did a <code>git rebase -i HEAD~20</code>, and modified whatever needed to be modified.</p>
<p>I was surprised to learn that this will modify the hashes of all 20 commits, even if the only action I take is to squash the last two.</p>
<p>I'm not sure what causes the hash change for the other 18 commits though, since neither their parents, neither their contents change... Or does it? Maybe a timestamp?</p>
<p>Also is there a way to prevent that?</p>
| 0debug |
static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
{
AVFormatContext *s = ts->stream;
MpegTSFilter *tss;
int len, pid, cc, cc_ok, afc, is_start;
const uint8_t *p, *p_end;
int64_t pos;
pid = AV_RB16(packet + 1) & 0x1fff;
if(pid && discard_pid(ts, pid))
return 0;
is_start = packet[1] & 0x40;
tss = ts->pids[pid];
if (ts->auto_guess && tss == NULL && is_start) {
add_pes_stream(ts, pid, -1, 0);
tss = ts->pids[pid];
}
if (!tss)
return 0;
cc = (packet[3] & 0xf);
cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
tss->last_cc = cc;
afc = (packet[3] >> 4) & 3;
p = packet + 4;
if (afc == 0)
return 0;
if (afc == 2)
return 0;
if (afc == 3) {
p += p[0] + 1;
}
p_end = packet + TS_PACKET_SIZE;
if (p >= p_end)
return 0;
pos = url_ftell(ts->stream->pb);
ts->pos47= pos % ts->raw_packet_size;
if (tss->type == MPEGTS_SECTION) {
if (is_start) {
len = *p++;
if (p + len > p_end)
return 0;
if (len && cc_ok) {
write_section_data(s, tss,
p, len, 0);
if (!ts->pids[pid])
return 0;
}
p += len;
if (p < p_end) {
write_section_data(s, tss,
p, p_end - p, 1);
}
} else {
if (cc_ok) {
write_section_data(s, tss,
p, p_end - p, 0);
}
}
} else {
int ret;
if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start,
pos - ts->raw_packet_size)) < 0)
return ret;
}
return 0;
}
| 1threat |
Helm export YAML files locally (just use templating engine, do not send to Kubernetes) : <p>I want to export <em>already templated</em> Helm Charts as YAML files. I can not use Tiller on my Kubernetes Cluster at the moment, but still want to make use of Helm Charts. Basically, I want Helm to export the YAML that gets send to the Kubernetes API with values that have been templated by Helm. After that, I will upload the YAML files to my Kubernetes cluster.</p>
<p>I tried to run <code>.\helm.exe install --debug --dry-run incubator\kafka</code> but I get the error <code>Error: Unauthorized</code>. </p>
<p>Note that I run Helm on Windows (version helm-v2.9.1-windows-amd64).</p>
| 0debug |
void block_job_yield(BlockJob *job)
{
assert(job->busy);
if (block_job_is_cancelled(job)) {
return;
}
job->busy = false;
if (!block_job_should_pause(job)) {
qemu_coroutine_yield();
}
job->busy = true;
block_job_pause_point(job);
}
| 1threat |
alert('Hello ' + user_input); | 1threat |
How to return specific 60 number row in mysql without using where clause? : How to return specific 60 number row in MYSQL without using where clause ?
SELECT * FROM TABLE | 0debug |
void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1)
{
int cssid, ssid, schid, m;
SubchDev *sch;
int ret = -ENODEV;
int cc;
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(&cpu->env, PGM_OPERAND, 2);
return;
}
trace_ioinst_sch_id("hsch", cssid, ssid, schid);
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_hsch(sch);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EBUSY:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
setcc(cpu, cc);
}
| 1threat |
Upload files and JSON in ASP.NET Core Web API : <p>How can I upload a list of files (images) and json data to ASP.NET Core Web API controller using multipart upload?</p>
<p>I can successfully receive a list of files, uploaded with <code>multipart/form-data</code> content type like that:</p>
<pre><code>public async Task<IActionResult> Upload(IList<IFormFile> files)
</code></pre>
<p>And of course I can successfully receive HTTP request body formatted to my object using default JSON formatter like that:</p>
<pre><code>public void Post([FromBody]SomeObject value)
</code></pre>
<p>But how can I combine these two in a single controller action? How can I upload both images and JSON data and have them bind to my objects?</p>
| 0debug |
Python- get last letter of a string : I am relatively new in python. I wanted to know if is there any possibility for me to get only the **E:** from the string below:
p="\\.\E:" | 0debug |
How to place the div around the div using css : I want to design the divs **using css** like the following image.
I didn't get any clue. Please provide the idea for this to design.
[![Designed image][1]][1]
[1]: https://i.stack.imgur.com/em5Sa.png | 0debug |
How to implement listView inside ExpandableRelativeLayout in android : i want to implement a listView inside ExpandableRelativeLayout but the listview doesn't scroll and the rest of the list can't be displayed i want it to be someting like this a recyclerview above the edit text and a listview below the edit text appears when user search for a name
[enter image description here][1]
[1]: https://i.stack.imgur.com/g525k.png | 0debug |
How to serve Django for an Electron app : <p>I'm trying to create an <a href="https://electron.atom.io" rel="noreferrer">Electron</a> desktop app which has a <a href="https://www.djangoproject.com" rel="noreferrer">Django</a> application at its backend. There are several tutorials and blogs which mention how this can be achieved. I've tried those and it seems to be working, however there are some issues. </p>
<p>One of them for me is how to server Django in this case? For me the current way of doing it creates some unwanted delay making the app slow to start...</p>
<p>Generally, what needs to be done to create an Django/Electron app is to package (I'm using <a href="http://www.pyinstaller.org" rel="noreferrer">pyInstaller</a>)the Django app into an stand-alone executable and then bundle that into an Electron app. The question is which server should be used for this case to server Django before packaging it with pyInstaller? At the moment I'm using <a href="http://cherrypy.org" rel="noreferrer">cherryPy</a> as a WSGI web server to serve Django. </p>
<p>However - is there a better alternative knowing that this will be used in an Electron desktop app? Maybe something faster, or more suitable for this task? What is the typical way of handling Django in this case? </p>
| 0debug |
SystemJS making ~200 requests for non-existing files : <p>I'm really lost about this. When I load my Angular2 app, I have about 200 requests to my server for non-existing files under <code>node_modules/systemjs</code>. Here's a sample of of those requests:</p>
<pre><code>127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Observable.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/root.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/toSubscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isFunction.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subscription.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isArray.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isObject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/tryCatch.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/errorObject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/UnsubscriptionError.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Observer.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/rxSubscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/observable.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/ObjectUnsubscribedError.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/SubjectSubscription.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/from.js.map HTTP/1.1" 404 -
</code></pre>
<p>My Angular2 application works fine, I don't get a single error, everything functions as expected. But those ~200 404 requests are really slowing down the page load. For a reason I really can't understand, those 404 requests don't even show up in my browser's <code>network</code> tab, but Wireshark confirms they are coming from there.</p>
<p>Here is my <code>systemjs.config.js</code>:</p>
<pre><code>/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
defaultJSExtensions: true,
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// angular testing umd bundles
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
'moment': 'npm:moment/moment',
'ng2-bs3-modal': 'npm:ng2-bs3-modal',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
}
});
})(this);
</code></pre>
| 0debug |
PHP: Hash function that generates a string with a given length : <p>I need a function that creates a hash from an arbitrary parameter set (or a serialized string) with a fixed length (say 5), as I need these hashes to serve as keys in an external database with a limited key length (so md5 will not work).</p>
<p>Is there such a function? Or should I use md5 and then substring it?</p>
| 0debug |
xhttp is not defined when using ajax calls into an iframe : <p>Good day all, I'm developing a php page in which there is an iframe, that opens another php page with a checkbox in it, this second page, when the user click on the checkbox, has to make an ajax call to confirm the "click".</p>
<p>so there is pageA.php, with a iframe in it that points to pageB.php, in this one, there is only a form with a checkbox and a javascript (vanilla javascript), that sould call a third page on click.</p>
<p>this is the javascript I'm using to send the "click":</p>
<pre><code>document.getElementById("checkboxMe").onclick = function() {
xhttp.open("POST", "pageC.php", true);
xhttp.send("foo=bar");
};
</code></pre>
<p>when clicking on the checkbox, this is what I see on the console:</p>
<pre><code>Uncaught ReferenceError: xhttp is not defined
</code></pre>
<p>it never happen something like this, infact I can't find this error easily on google, does anyone has some clues?
maybe is the fact I'm into an iframe?
how could I solve this issue?</p>
<p>thanks in advance ppl.</p>
| 0debug |
Need to validate textbox for a value, and a value between two numbers. Throwing an error : So i have a textbox which needs validation upon clicking my "Add" button.
The first check works fine when the other two checks aren't in the code. The bottom two checks are fine if I enter a value into the textbox. However when I have all three checks, when there isn't a value, the program throws back an error saying "input string was not in correct format".
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
if (txtAge.Text == "")
{
message += "<br>Please fill in your Age.</br>";
}
if (Convert.ToInt32(txtAge.Text) > 120)
{
message += "<br>Age cannot be greater than 120</br>";
}
if (Convert.ToInt32(txtAge.Text) < 6)
{
message += "<br>Age cannot be less than 6</br>";
}
<!-- end snippet -->
| 0debug |
Publish/Subscribe vs Producer/Consumer? : <p>From messaging point of view with systems like kafka, rabbit, hornet mq, activemq etc... Is there a difference between pub/sub and prod/con or are they used interchangeably?</p>
| 0debug |
Get div details on scroll : <p>I have a social feed page when a user can post something in his/her mind, I want to add a view count on this page, my problem is how can I count views on every social feed when the user scroll down the page</p>
| 0debug |
convert a list of string list date : <p>Good evening everyone!</p>
<p>My form sends a String list in this format:</p>
<pre><code>dd/ MM / yyyy
</code></pre>
<p>Wanted converts this string list in date to the format : </p>
<pre><code>yyyy - MM - dd
</code></pre>
<p>How can I do this in Java ?</p>
| 0debug |
Deleting rows from mysql that older than 1 minute : <p>I have MySQL database in LAMP server, Database is called coe and table is called pulses. the columns are:</p>
<p>Pulse | int </p>
<p>id | int</p>
<p>time | timestamp - current timestamp</p>
<p>I want select all values in pulse and then choose the max value with last 1 minute from current time. After that, I want to delete all rows in table with also last 1 minute.</p>
<p>I tried this code:</p>
<pre><code><?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "testdb";
$mysqli = mysqli_connect ($servername, $username, $password, $dbname);
$res = mysqli_query($mysqli, "SELECT MAX(pulse) as pulse FROM pulses where pulse BETWEEN 400 and 500 AND time > UNIX_TIMESTAMP() - 60");
$row = mysqli_fetch_assoc($res);
echo $row['pulse'];
$DeleteQuery = mysql_query('DELETE FROM pulses WHERE time > (UNIX_TIMESTAMP() - 60)');
?>
</code></pre>
<p>The code section of connection with database and select data with max value that work and it is not deleting the rows. i tried a lot but without success. please help</p>
| 0debug |
static av_cold void iv_alloc_frames(Indeo3DecodeContext *s)
{
int luma_width, luma_height, luma_pixels, chroma_width, chroma_height,
chroma_pixels, i;
unsigned int bufsize;
luma_width = (s->width + 3) & (~3);
luma_height = (s->height + 3) & (~3);
s->iv_frame[0].y_w = s->iv_frame[0].y_h =
s->iv_frame[0].the_buf_size = 0;
s->iv_frame[1].y_w = s->iv_frame[1].y_h =
s->iv_frame[1].the_buf_size = 0;
s->iv_frame[1].the_buf = NULL;
chroma_width = ((luma_width >> 2) + 3) & (~3);
chroma_height = ((luma_height>> 2) + 3) & (~3);
luma_pixels = luma_width * luma_height;
chroma_pixels = chroma_width * chroma_height;
bufsize = luma_pixels * 2 + luma_width * 3 +
(chroma_pixels + chroma_width) * 4;
if(!(s->iv_frame[0].the_buf = av_malloc(bufsize)))
return;
s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width;
s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height;
s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width;
s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height;
s->iv_frame[0].the_buf_size = bufsize;
s->iv_frame[0].Ybuf = s->iv_frame[0].the_buf + luma_width;
i = luma_pixels + luma_width * 2;
s->iv_frame[1].Ybuf = s->iv_frame[0].the_buf + i;
i += (luma_pixels + luma_width);
s->iv_frame[0].Ubuf = s->iv_frame[0].the_buf + i;
i += (chroma_pixels + chroma_width);
s->iv_frame[1].Ubuf = s->iv_frame[0].the_buf + i;
i += (chroma_pixels + chroma_width);
s->iv_frame[0].Vbuf = s->iv_frame[0].the_buf + i;
i += (chroma_pixels + chroma_width);
s->iv_frame[1].Vbuf = s->iv_frame[0].the_buf + i;
for(i = 1; i <= luma_width; i++)
s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] =
s->iv_frame[0].Ubuf[-i] = 0x80;
for(i = 1; i <= chroma_width; i++) {
s->iv_frame[1].Ubuf[-i] = 0x80;
s->iv_frame[0].Vbuf[-i] = 0x80;
s->iv_frame[1].Vbuf[-i] = 0x80;
s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80;
}
}
| 1threat |
Intergrate Microsoft Word Editor to C# .NET : <p>Can i know Can we intergrate Microsoft Word editor to .NET application ?</p>
<p>I saw some information in internet about office interop dll.</p>
<p>Is there anyway to do this ?</p>
| 0debug |
how do i handle 10000 datas in the array without affecting performance in javascript : I am trying to get 10000 data in an array from the server. But when it was loading initially i takes long time to render in dom. I tried the following approach like divide and load every hundreds of data in new array. The following code i tried but not working. Please let me know if anyone knows in javascript.
var count = 0;
var newarray=[];
var i;
for(i=count;i<10000;i++){
if(i > 100){ count = i; }
newarray.push(data[i]);
}
I tried this code on loading but still performance issue not solved. | 0debug |
How to auto generate pkgconfig files from cmake targets : <p>I would like to generate pkgconfig files in cmake from the targets. I stared by writing something like this:</p>
<pre><code>function(auto_pkgconfig TARGET)
get_target_property(INCLUDE_DIRS ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)
string(REPLACE "$<BUILD_INTERFACE:" "$<0:" INCLUDE_DIRS "${INCLUDE_DIRS}")
string(REPLACE "$<INSTALL_INTERFACE:" "$<1:" INCLUDE_DIRS "${INCLUDE_DIRS}")
string(REPLACE "$<INSTALL_PREFIX>" "${CMAKE_INSTALL_PREFIX}" INCLUDE_DIRS "${INCLUDE_DIRS}")
file(GENERATE OUTPUT ${TARGET}.pc CONTENT "
Name: ${TARGET}
Cflags: -I$<JOIN:${INCLUDE_DIRS}, -I>
Libs: -L${CMAKE_INSTALL_PREFIX}/lib -l${TARGET}
")
install(FILES ${TARGET}.pc DESTINATION lib/pkgconfig)
endfunction()
</code></pre>
<p>This is a simplified version but it basically reads the <code>INTERFACE_INCLUDE_DIRECTORIES</code> properties and processes the <code>INSTALL_INTERFACE</code> of the generator expressions.
This works well as long as the include directories are set before calling <code>auto_pkgconfig</code>, like this:</p>
<pre><code>add_library(foo foo.cpp)
target_include_directories(foo PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${OTHER_INCLUDE_DIRS}
)
auto_pkgconfig(foo)
</code></pre>
<p>However, sometimes properties are set after the call to <code>auto_pkgconfig</code>, like this:</p>
<pre><code>add_library(foo foo.cpp)
auto_pkgconfig(foo)
target_include_directories(foo PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${OTHER_INCLUDE_DIRS}
)
</code></pre>
<p>However, this won't properly read the include directories anymore. I would like <code>auto_pkgconfig</code> to run after all the target properties are set. I could use generator expressions for this, by changing <code>auto_pkgconfig</code> to this:</p>
<pre><code>function(auto_pkgconfig TARGET)
file(GENERATE OUTPUT ${TARGET}.pc CONTENT "
Name: ${TARGET}
Cflags: -I$<JOIN:$<TARGET_PROPERTY:${TARGET},INTERFACE_INCLUDE_DIRECTORIES>, -I>
Libs: -L$<TARGET_FILE_DIR:${TARGET}> -l${TARGET}
")
install(FILES ${TARGET}.pc DESTINATION lib/pkgconfig)
endfunction()
</code></pre>
<p>However, this will read the <code>BUILD_INTERFACE</code> instead of the <code>INSTALL_INTERFACE</code>. So is there another way to read target properties after they have been set?</p>
| 0debug |
firefox eats linux mint /home memory :
Seems Firefox browser uses disk memory. Computer have crashed many times and was eaten some 4GB of memory, approx 100-500Mb each time.
I believed, it was php script, as in this question
https://stackoverflow.com/questions/60065930/nested-php-loop-eats-gigabytes-of-linux-mint-memory
But, now i have found that 3D javascript examples from plotly and echarts eats a lot of memory too.
Seems the Firefox browser is the reason, as it crashes when script is running.
How to recover the lost memory?
I can not copy more files from /home . | 0debug |
static void monitor_readline_cb(void *opaque, const char *input)
{
pstrcpy(monitor_readline_buf, monitor_readline_buf_size, input);
monitor_readline_started = 0;
}
| 1threat |
static void qobject_output_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
qobject_output_add(qov, name, qnum_from_int(*obj));
}
| 1threat |
what is compilation error in c++? : <p>i am attending a online competition. my code is working in my compilier visual studio 2013. but the online judges giving me compilation error.
here is my code.</p>
<pre><code> #include<iostream>
#include<string>
#include<cmath>
#include<fstream>
using namespace std;
void main() {
int first_number;
int second_number;
string str;
char ch;
int count = 0;
ifstream yfile("q4.txt");
while (!yfile.eof())
{
yfile >>first_number;
if (first_number < 0)
first_number = abs(first_number);
yfile >> ch;
yfile >> second_number;
if (second_number < 0)
second_number = abs(second_number);
int gcd;
for (int i = 1; i <= first_number&&i <= second_number; i++){
if (first_number%i == 0 && second_number%i == 0){
gcd = i;
}
}
cout << "Output: " << gcd << endl;
}
</code></pre>
<p>can anyone please tell me solution? I will be thankful to you.
}</p>
| 0debug |
static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
ff_get_wav_header(pb, st->codec, atom.size);
return 0;
}
| 1threat |
Andriod studio missing classes (Constraint Layout) : I don't know what's going on.
I search a lot of information on the website,but it still can't work.
Can someone help me ..?
[enter image description here][1]
[1]: https://i.stack.imgur.com/WemgO.png | 0debug |
int xen_domain_build_pv(const char *kernel, const char *ramdisk,
const char *cmdline)
{
uint32_t ssidref = 0;
uint32_t flags = 0;
xen_domain_handle_t uuid;
unsigned int xenstore_port = 0, console_port = 0;
unsigned long xenstore_mfn = 0, console_mfn = 0;
int rc;
memcpy(uuid, qemu_uuid, sizeof(uuid));
rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
if (rc < 0) {
fprintf(stderr, "xen: xc_domain_create() failed\n");
goto err;
}
qemu_log("xen: created domain %d\n", xen_domid);
atexit(xen_domain_cleanup);
xen_domain_watcher();
xenstore_domain_init1(kernel, ramdisk, cmdline);
rc = xc_domain_max_vcpus(xen_xc, xen_domid, smp_cpus);
if (rc < 0) {
fprintf(stderr, "xen: xc_domain_max_vcpus() failed\n");
goto err;
}
#if 0
rc = xc_domain_setcpuweight(xen_xc, xen_domid, 256);
if (rc < 0) {
fprintf(stderr, "xen: xc_domain_setcpuweight() failed\n");
goto err;
}
#endif
rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);
if (rc < 0) {
fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");
goto err;
}
xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,
kernel, ramdisk, cmdline,
0, flags,
xenstore_port, &xenstore_mfn,
console_port, &console_mfn);
if (rc < 0) {
fprintf(stderr, "xen: xc_linux_build() failed\n");
goto err;
}
xenstore_domain_init2(xenstore_port, xenstore_mfn,
console_port, console_mfn);
qemu_log("xen: unpausing domain %d\n", xen_domid);
rc = xc_domain_unpause(xen_xc, xen_domid);
if (rc < 0) {
fprintf(stderr, "xen: xc_domain_unpause() failed\n");
goto err;
}
xen_poll = qemu_new_timer(rt_clock, xen_domain_poll, NULL);
qemu_mod_timer(xen_poll, qemu_get_clock(rt_clock) + 1000);
return 0;
err:
return -1;
}
| 1threat |
Mysql, get data from another row in the same column : <p>I'm a beginner in mySQL and php. <a href="http://i.stack.imgur.com/Us7We.png" rel="nofollow">my database</a></p>
<p>I would like to know, how to get someones email address based on his username. So for instance if I know the username is: iamtheboss, how could I get his email?</p>
| 0debug |
jQuery not triggering .click function from a jQuery generated HTML tags : <p>I have a button on my document, upon clicking will generate certain html tags.</p>
<pre><code><a type="button" name="repbut" >Reply</a> //on button click
<script type="text/javascript"> // this script will be executed
$(document).ready(function(){
$('a[name=repbut]').click(function(){
var boxid=$(this).attr("id");
$("#"+boxid+"1").html('<ul><li><div class="comment"><div class="comment-content"><div class="comment-meta-author">Post your reply</div><br><div class="comment-body"><div class="form-group"><label>Message</label><textarea id="reep" class="form-control" rows="2"></textarea><br><span id="'+boxid+'2"></span><a type="button" name="repcom" id="test" value="'+boxid+'" class="btn btn-primary pull-right">Reply</a></div><br></div></div></div></li></ul>');
});
});
</script>
</code></pre>
<p>The problem is when i click the generated button nothing happens, not even alert function.</p>
<pre><code><a type="button" name="repcom" id="test" class="btn btn-primary pull-right">
<script type="text/javascript">
$('a[name=repcom]').click(function(){
alert("yes"); // not triggered
});
</script>
</code></pre>
<p>Am i doing something wrong? i am new to jQuery.
Any help is appreciated.</p>
| 0debug |
void qxl_render_update(PCIQXLDevice *qxl)
{
VGACommonState *vga = &qxl->vga;
QXLRect dirty[32], update;
void *ptr;
int i;
if (qxl->guest_primary.resized) {
qxl->guest_primary.resized = 0;
if (qxl->guest_primary.flipped) {
g_free(qxl->guest_primary.flipped);
qxl->guest_primary.flipped = NULL;
}
qemu_free_displaysurface(vga->ds);
qxl->guest_primary.data = memory_region_get_ram_ptr(&qxl->vga.vram);
if (qxl->guest_primary.stride < 0) {
qxl->guest_primary.stride = -qxl->guest_primary.stride;
qxl->guest_primary.flipped = g_malloc(qxl->guest_primary.surface.width *
qxl->guest_primary.stride);
ptr = qxl->guest_primary.flipped;
} else {
ptr = qxl->guest_primary.data;
}
dprint(qxl, 1, "%s: %dx%d, stride %d, bpp %d, depth %d, flip %s\n",
__FUNCTION__,
qxl->guest_primary.surface.width,
qxl->guest_primary.surface.height,
qxl->guest_primary.stride,
qxl->guest_primary.bytes_pp,
qxl->guest_primary.bits_pp,
qxl->guest_primary.flipped ? "yes" : "no");
vga->ds->surface =
qemu_create_displaysurface_from(qxl->guest_primary.surface.width,
qxl->guest_primary.surface.height,
qxl->guest_primary.bits_pp,
qxl->guest_primary.stride,
ptr);
dpy_resize(vga->ds);
}
if (!qxl->guest_primary.commands) {
return;
}
qxl->guest_primary.commands = 0;
update.left = 0;
update.right = qxl->guest_primary.surface.width;
update.top = 0;
update.bottom = qxl->guest_primary.surface.height;
memset(dirty, 0, sizeof(dirty));
qxl_spice_update_area(qxl, 0, &update,
dirty, ARRAY_SIZE(dirty), 1, QXL_SYNC);
for (i = 0; i < ARRAY_SIZE(dirty); i++) {
if (qemu_spice_rect_is_empty(dirty+i)) {
break;
}
if (qxl->guest_primary.flipped) {
qxl_flip(qxl, dirty+i);
}
dpy_update(vga->ds,
dirty[i].left, dirty[i].top,
dirty[i].right - dirty[i].left,
dirty[i].bottom - dirty[i].top);
}
}
| 1threat |
Laravel Mix "sh: 1: cross-env: not found error" : <p>I have been trying to setup laravel mix on my project and followed the install guide on the laravel website however keep getting errors.</p>
<p>My package.json file is</p>
<pre><code>{
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --progress --hide-modules",
"watch": "cross-env NODE_ENV=development webpack --watch --progress --hide-modules",
"hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot",
"production": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"devDependencies": {
"axios": "^0.15.2",
"bootstrap-sass": "^3.3.7",
"jquery": "^3.1.0",
"laravel-mix": "^0.4.0",
"lodash": "^4.16.2",
"vue": "^2.0.1"
},
"name": "Code",
"version": "1.0.0",
"main": "webpack.mix.js",
"directories": {
"test": "tests"
},
"dependencies": {
"ansi-regex": "^2.1.1",
"ansi-styles": "^2.2.1",
"axios": "^0.15.3",
"babel-core": "^6.24.1",
"babel-code-frame": "^6.22.0",
"babel-generator": "^6.24.1",
"babel-messages": "^6.23.0",
"babel-helpers": "^6.24.1",
"babel-register": "^6.24.1",
"babel-template": "^6.24.1",
"babylon": "^6.17.0",
"balanced-match": "^0.4.2",
"babel-runtime": "^6.23.0",
"babel-types": "^6.24.1",
"babel-traverse": "^6.24.1",
"brace-expansion": "^1.1.7",
"bootstrap-sass": "^3.3.7",
"chalk": "^1.1.3",
"convert-source-map": "^1.5.0",
"concat-map": "^0.0.1",
"core-js": "^2.4.1",
"cross-env": "^3.2.4",
"detect-indent": "^4.0.0",
"esutils": "^2.0.2",
"escape-string-regexp": "^1.0.5",
"follow-redirects": "^1.0.0",
"globals": "^9.17.0",
"has-ansi": "^2.0.0",
"home-or-tmp": "^2.0.0",
"is-finite": "^1.0.2",
"invariant": "^2.2.2",
"json5": "^0.5.1",
"js-tokens": "^3.0.1",
"jquery": "^3.2.1",
"jsesc": "^1.3.0",
"laravel-mix": "^0.4.0",
"lodash": "^4.17.4",
"loose-envify": "^1.3.1",
"mkdirp": "^0.5.1",
"minimatch": "^3.0.3",
"minimist": "^0.0.8",
"number-is-nan": "^1.0.1",
"os-homedir": "^1.0.2",
"os-tmpdir": "^1.0.2",
"path-is-absolute": "^1.0.1",
"private": "^0.1.7",
"regenerator-runtime": "^0.10.3",
"repeating": "^2.0.1",
"slash": "^1.0.0",
"source-map": "^0.5.6",
"source-map-support": "^0.4.14",
"strip-ansi": "^3.0.1",
"trim-right": "^1.0.1",
"to-fast-properties": "^1.0.2",
"vue": "^2.3.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
</code></pre>
<p>and the error I am getting when I run any npm run command is</p>
<pre><code>> Code@1.0.0 dev /home/vagrant/Code
> cross-env NODE_ENV=development webpack --progress --hide-modules
sh: 1: cross-env: not found
npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.8.0
npm ERR! npm v4.2.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! Code@1.0.0 dev: `cross-env NODE_ENV=development webpack --progress --hide-modules`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the Code@1.0.0 dev script 'cross-env NODE_ENV=development webpack --progress --hide-modules'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Code package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env NODE_ENV=development webpack --progress --hide-modules
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Code
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Code
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/vagrant/.npm/_logs/2017-04-28T17_24_11_458Z-debug.log
</code></pre>
<p>I am running my project in a vagrant box and I am running laravel 5.4.</p>
| 0debug |
static inline void mix_2f_2r_to_stereo(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
output[1][i] += output[3][i];
output[2][i] += output[4][i];
}
memset(output[3], 0, sizeof(output[3]));
memset(output[4], 0, sizeof(output[4]));
}
| 1threat |
algorithm for finding the number of 1s in a matrix (only vertical 1s). The image is self explanatory that what i exactly want. : [Algorithm is required for Finding the group of 1s in a matrix, but the group of 1s should contain only vertical entry][1]
[1]: https://i.stack.imgur.com/xtegh.png
| 0debug |
C# => syntax for creating a variable : <p>The code below is used to initialise a store in some C# code I am looking at. However I do not understand the => syntax in this context.</p>
<p>Any ideas?</p>
<pre><code>protected new ServiceRepositoryStore<T> Store => (ServiceRepositoryStore<T>) base.Store;
</code></pre>
| 0debug |
static MemTxResult memory_region_oldmmio_write_accessor(MemoryRegion *mr,
hwaddr addr,
uint64_t *value,
unsigned size,
unsigned shift,
uint64_t mask,
MemTxAttrs attrs)
{
uint64_t tmp;
tmp = (*value >> shift) & mask;
if (mr->subpage) {
trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, size);
} else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, size);
}
mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp);
return MEMTX_OK;
} | 1threat |
Can someone elaborately explain this piece of code : <pre><code>var a = 0;
for(b=1; b<=5; b+=a) {
document.write(b);
a++;
}
</code></pre>
<p>Why the output of this code is 124?</p>
| 0debug |
Replace a String in Javascript using regex : <p>my input is
var email = "xyz+wex+rr%40gmail.com";</p>
<p>i need output as </p>
<p>xyz wex rr @ gmail.com</p>
<p>i have tried with this below regex , i can only remove + from my string how to replace %40 with @</p>
<p>email .replace(/+/g, " ");</p>
| 0debug |
Regex Pattern for domain or hostnames or probably the best way to match a pattern : <p>Here's a sample domain name FQDN, How can I match the domain name after the short hostname? instead of making a pattern match for domain names? Advice is really much appreciated.</p>
<pre><code>host1.dept1.domain.com
host2.domain.com
host3.domain3.com
</code></pre>
| 0debug |
python: difference between 'lxml' and "html.parser" and "html5lib" with beautiful soup? : <p>When using beautiful soup what is the difference between 'lxml' and "html.parser" and "html5lib"? When would you use one over the other and the benefits of each? from the times i used each they seem to be interchangeable but i do get corrected that i should be using a different one from people on here. Would like to strengthen my understanding of these. I have read a couple posts on here about this but they are not going over the uses much in any at all.</p>
<p>Example - </p>
<pre><code>soup = BeautifulSoup(response.text, 'lxml')
</code></pre>
| 0debug |
AVFormatContext *avformat_alloc_context(void)
{
AVFormatContext *ic;
ic = av_malloc(sizeof(AVFormatContext));
if (!ic) return ic;
avformat_get_context_defaults(ic);
ic->internal = av_mallocz(sizeof(*ic->internal));
if (!ic->internal) {
avformat_free_context(ic);
return NULL;
}
return ic;
} | 1threat |
Getting data from databse server does not work : I am a beginner and i would need a little bit of help: I have created this php code to get the user information from the "profiles"-table from my Database(note: the variable $username is already defined):
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?php
//getting the data from the Database
$aVar = mysqli_connect('localhost','root','','socialnetwork');
$usernameaccount = mysqli_query($aVar, "SELECT username FROM users WHERE username = '$username'");
$age = mysqli_query($aVar, "SELECT p.age FROM profiles p, users u WHERE u.username = '$username' AND u.id = p.id");
$gender = mysqli_query($aVar, "SELECT p.gender FROM profiles p, users u WHERE u.username = '$username' AND u.id = p.id");
$description = mysqli_query($aVar, "SELECT p.description FROM profiles p, users u WHERE u.username = '$username' AND u.id = p.id");
//after getting the data i insert them into a variable with some html code:
$outputusername = '<h2>'.$usernameaccount.'<hr></h2>';
$outputage = '<h2>'.$age.'<hr></h2>';
$outputgender = '<h2>'.$gender.'<hr></h2>';
$outputdescription = '<h2>'.$description.'<hr></h2>';
?>
<!-- end snippet -->
And than somewhere in the html code i echo them like this:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<div class="info">
<?php
echo $outputusername;
echo $outputage;
echo $outputgender;
echo $outputdescription;
?>
</div>
<!-- end snippet -->
Somehow it gives me the error message:
Recoverable fatal error: Object of class mysqli_result could not be converted to string in C:\xampp\htdocs\ping.com\profile.php on line 10
Can someone please help me to get these datas from my database in the **correct** way and display them in the html-code? If you need any mor information please just ask(Sorry for my bad englisch:/).
| 0debug |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath is not be called : I have a viewcontroller called BNRItemViewcontroller
In the implementation:
- (instancetype)init{
self = [super initWithStyle:UITableViewStylePlain];
if (self) {
for (int i = 0; i < 5; i++) {
[[BNRItemStore sharedStore]createItem];
}
}
return self;
}
- (instancetype)initWithStyle:(UITableViewStyle)style{
return [self init];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[[BNRItemStore sharedStore] allItems] count];
}
I add a breakpoint in the **cellForRowAtIndexPath:** method,but it didn't get in the method.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];
NSArray *items = [[BNRItemStore sharedStore] allItems];
BNRItem *item = items[indexPath.row];
cell.textLabel.text = [item description];
return cell;
} | 0debug |
Couldn't find meta-data for provider with authority : <p>I have integrated Snapchat's Creative Kit in my Android app. After processing, I receive an image from the server in the form of Byte Array which I am saving to the disk and then sending the file to the Snapchat's Creative Kit as shown below.</p>
<pre><code> private fun downloadImage(
fileName: String,
imageByteArray: ByteArray?): Uri? {
val state = Environment.getExternalStorageState()
if (Environment.MEDIA_MOUNTED == state) {
val downloadDir = File(
Environment.getExternalStorageDirectory(), context?.getString(R.string.app_name)
)
if (!downloadDir.isDirectory) {
downloadDir.mkdirs()
}
val file = File(downloadDir, fileName)
var ostream: FileOutputStream? = null
try {
ostream = FileOutputStream(file)
ostream.write(imageByteArray)
ostream.flush()
ostream.close()
}
} catch (e: IOException) {
e.printStackTrace()
}
val snapCreativeKitApi = SnapCreative.getApi(context!!)
val snapMediaFactory = SnapCreative.getMediaFactory(context!!)
lateinit var snapPhotoFile: SnapPhotoFile
try {
snapPhotoFile = snapMediaFactory.getSnapPhotoFromFile(file)
} catch (e: SnapMediaSizeException) {
return
}
val snapPhotoContent = SnapPhotoContent(snapPhotoFile)
snapCreativeKitApi.send(snapPhotoContent)
}
}
</code></pre>
<p>I have also added <code>provider</code> in the manifest file as shown below:</p>
<pre><code> <provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths_app" />
</provider>
</code></pre>
<p>And in the <code>provider_paths_app.xml</code>, I have tried all the possible paths by referring <a href="https://stackoverflow.com/questions/37953476/android-how-to-get-a-content-uri-for-a-file-in-the-external-storage-public-d">this</a> answer and none of them works.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="My App Name"
path="." />
</paths>
</code></pre>
<p>With the above path, I am getting the below error.</p>
<pre><code>Couldn't find meta-data for provider with authority my.package.name.fileprovider
</code></pre>
<p>All I have to do is send this image to Snapchat but I am unable to figure out what I am doing wrong. Any help will be appreciated.</p>
| 0debug |
Display all the columns in employees table along with average salary of each dept : <p>i want a query to display all the columns in employees table along with average salary of each department.</p>
| 0debug |
bool trace_backend_init(const char *events, const char *file)
{
GThread *thread;
if (!g_thread_supported()) {
g_thread_init(NULL);
}
trace_available_cond = g_cond_new();
trace_empty_cond = g_cond_new();
thread = trace_thread_create(writeout_thread);
if (!thread) {
fprintf(stderr, "warning: unable to initialize simple trace backend\n");
return false;
}
atexit(st_flush_trace_buffer);
trace_backend_init_events(events);
st_set_trace_file(file);
return true;
} | 1threat |
Using if else statement to assign a variable in python : <p>I'm trying to make a program telling you how to order a specific number of nuggets, using if and else statements to assign variables. My problem is if one of the first if statements is true, then the program throws an error, because I called a variable that doesn't exist. How can I make My program skip over the rest of the if/else statements if the first one is found to be true?</p>
<pre><code>nuggets = input("How many nuggets do you need? ")
nuggets = int(nuggets)
nuggets20 = nuggets % 20
if nuggets20 == 0:
n20 = True
else:
nuggets10 = nuggets20 % 10
if nuggets10 == 0:
print(nuggets10)
else:
nuggets6 = nuggets10 % 6
if nuggets6 == 0:
print(nuggets6)
else:
nuggets4 = nuggets6 % 4
if n20 == True:
print("nuggets")
</code></pre>
| 0debug |
build_dsdt(GArray *table_data, GArray *linker,
AcpiPmInfo *pm, AcpiMiscInfo *misc,
PcPciInfo *pci, MachineState *machine)
{
CrsRangeEntry *entry;
Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
PCMachineState *pcms = PC_MACHINE(machine);
uint32_t nr_mem = machine->ram_slots;
int root_bus_limit = 0xFF;
PCIBus *bus = NULL;
int i;
dsdt = init_aml_allocator();
acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader));
build_dbg_aml(dsdt);
if (misc->is_piix4) {
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_piix4_pm(dsdt);
build_piix4_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_piix4_pci_hotplug(dsdt);
build_piix4_pci0_int(dsdt);
} else {
sb_scope = aml_scope("_SB");
aml_append(sb_scope,
aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(0xae00), 0x0c));
aml_append(sb_scope,
aml_operation_region("PCSB", AML_SYSTEM_IO, aml_int(0xae0c), 0x01));
field = aml_field("PCSB", AML_ANY_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
aml_append(field, aml_named_field("PCIB", 8));
aml_append(sb_scope, field);
aml_append(dsdt, sb_scope);
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(dev, aml_name_decl("SUPP", aml_int(0)));
aml_append(dev, aml_name_decl("CTRL", aml_int(0)));
aml_append(dev, build_q35_osc_method());
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_q35_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_q35_pci0_int(dsdt);
}
build_cpu_hotplug_aml(dsdt);
build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
pm->mem_hp_io_len);
scope = aml_scope("_GPE");
{
aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
aml_append(scope, aml_method("_L00", 0, AML_NOTSERIALIZED));
if (misc->is_piix4) {
method = aml_method("_E01", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
aml_append(method, aml_call0("\\_SB.PCI0.PCNT"));
aml_append(method, aml_release(aml_name("\\_SB.PCI0.BLCK")));
aml_append(scope, method);
} else {
aml_append(scope, aml_method("_L01", 0, AML_NOTSERIALIZED));
}
method = aml_method("_E02", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD));
aml_append(scope, method);
method = aml_method("_E03", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
aml_append(scope, method);
aml_append(scope, aml_method("_L04", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L05", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L06", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L07", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L08", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L09", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L0A", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L0B", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L0C", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L0D", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L0E", 0, AML_NOTSERIALIZED));
aml_append(scope, aml_method("_L0F", 0, AML_NOTSERIALIZED));
}
aml_append(dsdt, scope);
bus = PC_MACHINE(machine)->bus;
if (bus) {
QLIST_FOREACH(bus, &bus->child, sibling) {
uint8_t bus_num = pci_bus_num(bus);
uint8_t numa_node = pci_bus_numa_node(bus);
if (!pci_bus_is_root(bus)) {
continue;
}
if (bus_num < root_bus_limit) {
root_bus_limit = bus_num - 1;
}
scope = aml_scope("\\_SB");
dev = aml_device("PC%.02X", bus_num);
aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
if (numa_node != NUMA_NODE_UNASSIGNED) {
aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node)));
}
aml_append(dev, build_prt(false));
crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),
io_ranges, mem_ranges);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
}
scope = aml_scope("\\_SB.PCI0");
crs = aml_resource_template();
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0x0000, 0x0, root_bus_limit,
0x0000, root_bus_limit + 1));
aml_append(crs, aml_io(AML_DECODE16, 0x0CF8, 0x0CF8, 0x01, 0x08));
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF);
for (i = 0; i < io_ranges->len; i++) {
entry = g_ptr_array_index(io_ranges, i);
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, entry->base, entry->limit,
0x0000, entry->limit - entry->base + 1));
}
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
crs_replace_with_free_ranges(mem_ranges, pci->w32.begin, pci->w32.end - 1);
for (i = 0; i < mem_ranges->len; i++) {
entry = g_ptr_array_index(mem_ranges, i);
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_NON_CACHEABLE, AML_READ_WRITE,
0, entry->base, entry->limit,
0, entry->limit - entry->base + 1));
}
if (pci->w64.begin) {
aml_append(crs,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, pci->w64.begin, pci->w64.end - 1, 0,
pci->w64.end - pci->w64.begin));
}
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
}
aml_append(scope, aml_name_decl("_CRS", crs));
dev = aml_device("GPE0");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev, aml_name_decl("_UID", aml_string("GPE0 resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->gpe0_blk, pm->gpe0_blk, 1, pm->gpe0_blk_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
g_ptr_array_free(io_ranges, true);
g_ptr_array_free(mem_ranges, true);
if (pm->pcihp_io_len) {
dev = aml_device("PHPR");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("PCI Hotplug resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->pcihp_io_base, pm->pcihp_io_base, 1,
pm->pcihp_io_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(dsdt, scope);
scope = aml_scope("\\");
if (!pm->s3_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S3", pkg));
}
if (!pm->s4_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(pm->s4_val));
aml_append(pkg, aml_int(pm->s4_val));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S4", pkg));
}
pkg = aml_package(4);
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S5", pkg));
aml_append(dsdt, scope);
{
uint8_t io_size = object_property_get_bool(OBJECT(pcms->fw_cfg),
"dma_enabled", NULL) ?
ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) :
FW_CFG_CTL_SIZE;
scope = aml_scope("\\_SB.PCI0");
dev = aml_device("FWCF");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->applesmc_io_base) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("SMC");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->applesmc_io_base, misc->applesmc_io_base,
0x01, APPLESMC_MAX_DATA_LENGTH)
);
aml_append(crs, aml_irq_no_flags(6));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->pvpanic_port) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("PEVT");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
aml_int(misc->pvpanic_port), 1));
field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PEPT", 8));
aml_append(dev, field);
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
aml_append(method, aml_return(aml_local(0)));
aml_append(dev, method);
method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
aml_append(dev, method);
aml_append(scope, dev);
aml_append(dsdt, scope);
}
sb_scope = aml_scope("\\_SB");
{
build_processor_devices(sb_scope, machine, pm);
build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base,
pm->mem_hp_io_len);
{
Object *pci_host;
PCIBus *bus = NULL;
pci_host = acpi_get_i386_pci_host();
if (pci_host) {
bus = PCI_HOST_BRIDGE(pci_host)->bus;
}
if (bus) {
Aml *scope = aml_scope("PCI0");
build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
dev = aml_device("ISA.TPM");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(sb_scope, scope);
}
}
aml_append(dsdt, sb_scope);
}
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data,
(void *)(table_data->data + table_data->len - dsdt->buf->len),
"DSDT", dsdt->buf->len, 1, NULL, NULL);
free_aml_allocator();
}
| 1threat |
Check if router.url contains specific string? : <p>I have this :</p>
<pre><code> if (this.router.url === '/test/sort') {
this.active = 0;
}
</code></pre>
<p>Problem is that sometimes url will be <code>test/sort?procesId=11</code> and than it will not enter in if statement. Any suggestion how can i do that?</p>
| 0debug |
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, i;
AVStream *st;
for(;;){
AVPacketList *pktl = s->raw_packet_buffer;
if (pktl) {
*pkt = pktl->pkt;
if(s->streams[pkt->stream_index]->codec->codec_id != CODEC_ID_PROBE ||
!s->streams[pkt->stream_index]->probe_packets){
s->raw_packet_buffer = pktl->next;
av_free(pktl);
return 0;
}
}
av_init_packet(pkt);
ret= s->iformat->read_packet(s, pkt);
if (ret < 0) {
if (!pktl || ret == AVERROR(EAGAIN))
return ret;
for (i = 0; i < s->nb_streams; i++)
s->streams[i]->probe_packets = 0;
continue;
}
st= s->streams[pkt->stream_index];
switch(st->codec->codec_type){
case CODEC_TYPE_VIDEO:
if(s->video_codec_id) st->codec->codec_id= s->video_codec_id;
break;
case CODEC_TYPE_AUDIO:
if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id;
break;
case CODEC_TYPE_SUBTITLE:
if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id;
break;
}
if(!pktl && (st->codec->codec_id != CODEC_ID_PROBE ||
!st->probe_packets))
return ret;
add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end);
if(st->codec->codec_id == CODEC_ID_PROBE){
AVProbeData *pd = &st->probe_data;
--st->probe_packets;
pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);
memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
pd->buf_size += pkt->size;
memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
if(av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){
set_codec_from_probe_data(st, pd, 1);
if(st->codec->codec_id != CODEC_ID_PROBE){
pd->buf_size=0;
av_freep(&pd->buf);
}
}
}
}
}
| 1threat |
static uint32_t rtl8139_io_readw(void *opaque, uint8_t addr)
{
RTL8139State *s = opaque;
uint32_t ret;
switch (addr)
{
case TxAddr0 ... TxAddr0+4*4-1:
ret = rtl8139_TxStatus_read(s, addr, 2);
break;
case IntrMask:
ret = rtl8139_IntrMask_read(s);
break;
case IntrStatus:
ret = rtl8139_IntrStatus_read(s);
break;
case MultiIntr:
ret = rtl8139_MultiIntr_read(s);
break;
case RxBufPtr:
ret = rtl8139_RxBufPtr_read(s);
break;
case RxBufAddr:
ret = rtl8139_RxBufAddr_read(s);
break;
case BasicModeCtrl:
ret = rtl8139_BasicModeCtrl_read(s);
break;
case BasicModeStatus:
ret = rtl8139_BasicModeStatus_read(s);
break;
case NWayAdvert:
ret = s->NWayAdvert;
DPRINTF("NWayAdvert read(w) val=0x%04x\n", ret);
break;
case NWayLPAR:
ret = s->NWayLPAR;
DPRINTF("NWayLPAR read(w) val=0x%04x\n", ret);
break;
case NWayExpansion:
ret = s->NWayExpansion;
DPRINTF("NWayExpansion read(w) val=0x%04x\n", ret);
break;
case CpCmd:
ret = rtl8139_CpCmd_read(s);
break;
case IntrMitigate:
ret = rtl8139_IntrMitigate_read(s);
break;
case TxSummary:
ret = rtl8139_TSAD_read(s);
break;
case CSCR:
ret = rtl8139_CSCR_read(s);
break;
default:
DPRINTF("ioport read(w) addr=0x%x via read(b)\n", addr);
ret = rtl8139_io_readb(opaque, addr);
ret |= rtl8139_io_readb(opaque, addr + 1) << 8;
DPRINTF("ioport read(w) addr=0x%x val=0x%04x\n", addr, ret);
break;
}
return ret;
}
| 1threat |
static inline int xhci_running(XHCIState *xhci)
{
return !(xhci->usbsts & USBSTS_HCH) && !xhci->intr[0].er_full;
}
| 1threat |
JavaScript blinking eye animation : <p>I am currently trying to learn JavaScript and trying out a lot of stuff, but as for now, my JS skilly are still very limited.
I created a little game where there is a box with bunny heads which randomly appear and the user has to click them as fast as possible.</p>
<p>So I created the bunnies with an interval animation where the bunny closes and opens its eyes within every 2 seconds.
Now I feel kind of stupid, but i can't manage to get the animation working as I want it to. Now the bunny is just closing its eyes every 2 seconds and then opening them again every 2 seconds. However, I want it only to blink, meaning that the eyes should be closed just for an instant and then opened again, so that the bunny is blinking every 2 seconds.
And then I would also like it to randomly sometimes blink only once and sometimes blink twice.
Not sure if this is hella easy and I am just blind from hours of coding stuff and learning new things, but it seems that I might need your help here.</p>
<p><a href="https://jsfiddle.net/schakalwal/y390jcx8/">Here is a fiddle</a> of the whole thing as it is right now.</p>
<p>You can see the complete code that was used inside the fiddle. I did not want to post the whole website here in the code section, but the parts I believe are of interest for my animation.</p>
<p>Here is the js code for the blinking eyes:</p>
<pre><code>var eyeleft = document.getElementById("eyeleft");
var eyeright = document.getElementById("eyeright");
window.onload = setInterval(function() {
eyeleft.className = (eyeleft.className != 'closedeyeleft' ? 'closedeyeleft' : 'eyeleft');
eyeright.className = (eyeright.className != 'closedeyeright' ? 'closedeyeright' : 'eyeright');
}, 2000);
</code></pre>
<p>Next the HTML</p>
<pre><code><div id="shape" class="game-shapes">
<div class="ears left"></div>
<div class="ears right"></div>
<div id="eyeleft" class="eyeleft"></div>
<div id="eyeright" class="eyeright"></div>
<div id="mouth">
<div id="tooth"></div>
<div id="tongue"></div>
</div>
</div>
</code></pre>
<p>And now CSS</p>
<pre><code>.game-shapes {
height: 80px;
width: 80px;
cursor: pointer;
opacity: 0;
position: relative;
transition: opacity ease-in-out .2s;
}
.game-shapes div {
position: absolute;
}
.eyeleft,
.eyeright {
background: #000;
border-radius: 50%;
width: 20px;
height: 20px;
top: 30px;
}
.eyeleft {
left: 4px;
}
.eyeright {
right: 4px;
}
.eyeleft:before,
.eyeleft:after,
.eyeright:before,
.eyeright:after {
content: '';
background: #fff;
width: 7px;
height: 7px;
top: 4px;
left: 4px;
border-radius: 50%;
position: absolute;
z-index: 5;
}
.eyeleft:after,
.eyeright:after {
width: 4px;
height: 4px;
top: 10px;
left: 10px;
}
.closedeyeleft,
.closedeyeright {
background: transparent none repeat scroll 0 0;
border-color: #000;
border-radius: 5px;
border-style: solid;
border-width: 4px 4px 0;
height: 4px;
top: 35px;
width: 12px;
}
.closedeyeleft {
left: 3px;
}
.closedeyeright {
right: 3px;
}
</code></pre>
| 0debug |
How to get length of each string in array element in swift : <p>How to get length of each string in array element ["a", "a2", "b", "a2", "d"] just like "a" length is 1 and " a2" length is 2. how to i will check length of all strings insides array in swift.</p>
| 0debug |
how to do a left,right and mid of array in python? : get_link = []
for a in soup.find_all('a', href=True):
if a.get_text(strip=True):
get_link .append(a['href'])
Following codes append all the link in array "get_link". I am using beautifulsoup.
Output of get_link:
['index.html?country=2',
'index.html?country=25',
'index.html?country=1',
'index.html?country=6',
'index.html?country=2']
Below is my desiger output.
[country=2',
country=25',
country=1',
country=6',
country=2']
| 0debug |
Azure function apps logs not showing : <p>I'm relatively new to Azure and I just went through the tutorial on how to create a new Azure function, which is triggered when a new blob is created, and had this as the default code in it.</p>
<pre><code>public static void Run(Stream myBlob, string name, TraceWriter log)
{
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
</code></pre>
<p>From what I can see on the tutorial, I should be able to see some information in the "logs" area below the code, but nothing shows up, I've been checking for a solution for a while now but can't seem to find anything useful. </p>
<p>Any help would be greatly appreciated.</p>
| 0debug |
Set timeout for HTTPClient get() request : <p>This method submits a simple HTTP request and calls a success or error callback just fine:</p>
<pre><code> void _getSimpleReply( String command, callback, errorCallback ) async {
try {
HttpClientRequest request = await _myClient.get( _serverIPAddress, _serverPort, '/' );
HttpClientResponse response = await request.close();
response.transform( utf8.decoder ).listen( (onData) { callback( onData ); } );
} on SocketException catch( e ) {
errorCallback( e.toString() );
}
}
</code></pre>
<p>If the server isn't running, the Android-app more or less instantly calls the errorCallback.</p>
<p>On iOS, the errorCallback takes a very long period of time - more than 20 seconds - until any callback gets called.</p>
<p><strong>May I set for HttpClient() a maximum number of seconds to wait for the server side to return a reply - if any?</strong></p>
| 0debug |
Spring Test returning 401 for unsecured URLs : <p>I am using Spring for MVC tests</p>
<p>Here is my test class</p>
<pre><code>@RunWith(SpringRunner.class)
@WebMvcTest
public class ITIndexController {
@Autowired
WebApplicationContext context;
MockMvc mockMvc;
@MockBean
UserRegistrationApplicationService userRegistrationApplicationService;
@Before
public void setUp() {
this.mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.apply(springSecurity())
.build();
}
@Test
public void should_render_index() throws Exception {
mockMvc.perform(get("/"))
.andExpect(status().isOk())
.andExpect(view().name("index"))
.andExpect(content().string(containsString("Login")));
}
}
</code></pre>
<p>Here is the MVC config</p>
<pre><code>@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index");
registry.addViewController("/login/form").setViewName("login");
}
}
</code></pre>
<p>Here is the security config</p>
<pre><code>@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
@Qualifier("customUserDetailsService")
UserDetailsService userDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/resources/**", "/signup", "/signup/form", "/").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login/form").permitAll().loginProcessingUrl("/login").permitAll()
.and()
.logout().logoutSuccessUrl("/login/form?logout").permitAll()
.and()
.csrf().disable();
}
@Autowired
public void configureGlobalFromDatabase(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
}
}
</code></pre>
<p>When I run my test it fails with the message:</p>
<pre><code>java.lang.AssertionError: Status expected:<200> but was:<401>
at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:54)
at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:81)
at org.springframework.test.web.servlet.result.StatusResultMatchers$10.match(StatusResultMatchers.java:664)
at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:171)
at com.marco.nutri.integration.web.controller.ITIndexController.should_render_index(ITIndexController.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
</code></pre>
<p>I understand that it fails due to the fact that the url is protected with spring security, but when I run my application I can access that url even without being authenticated.</p>
<p>Am I doing something wrong?</p>
| 0debug |
error TS2304: Build:Cannot find name 'Iterable' after upgrading to Angular 4 : <p>I am using Typescript 2.4.1 and have upgraded many packages in my project. Among them I upgraded Angular from 2 to 4.3.1.
After many corrections in @types packages, the errors I am left with are:</p>
<pre><code>\node_modules\@types\jquery\index.d.ts(2955,63): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(767,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(771,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(775,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(779,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(783,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(787,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(791,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(795,24): error TS2304: Build:Cannot find name 'Iterable'.
\node_modules\@types\three\three-core.d.ts(799,24): error TS2304: Build:Cannot find name 'Iterable'.
</code></pre>
<p>I have found many similar questions and answers and the prevailing solution is to target "es2015" and/or add lib: ["dom", "es2015", "es2015.iterable"].
I have tried all those and more but am still left with the same 'Iterable' error.</p>
<p>My updated tsconfig.json is thus:</p>
<pre><code>{
"compileOnSave": true,
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "dom", "dom.iterable", "es2015", "es2015.iterable", "esnext" ],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"noEmitOnError": true,
"outDir": "./wwwroot/js",
"removeComments": false,
"rootDir": "./Client",
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es2015",
"typeRoots": [
"./node_modules/@types",
"./Client"
]
},
"exclude": [
"node_modules",
"wwwroot/lib"
],
"filesGlob": [
"./Client/**/*.ts"
]
}
</code></pre>
<p>My package.json is:</p>
<pre><code>{
"version": "1.0.0",
"name": "web-server",
"private": true,
"dependencies": {
"@angular/common": "^4.3.1",
"@angular/compiler": "^4.3.1",
"@angular/core": "^4.3.1",
"@angular/forms": "^4.3.1",
"@angular/http": "^4.3.1",
"@angular/platform-browser": "^4.3.1",
"@angular/platform-browser-dynamic": "^4.3.1",
"@angular/router": "^4.3.1",
"@angular/upgrade": "^4.3.1",
"bootstrap": "3.3.7",
"core-js": "2.4.1",
"lodash": "4.17.4",
"pixi.js": "4.5.4",
"reflect-metadata": "0.1.10",
"rxjs": "^5.4.2",
"systemjs": "0.20.17",
"three": "0.86.0",
"zone.js": "0.8.14"
},
"devDependencies": {
"@types/chai": "^4.0.1",
"@types/jquery": "3.2.9",
"@types/lodash": "4.14.71",
"@types/mocha": "2.2.41",
"@types/pixi.js": "4.5.2",
"@types/three": "0.84.19",
"bower": "^1.8.0",
"gulp": "3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.1",
"gulp-typescript": "^3.2.1",
"gulp-inline-ng2-template": "^4.0.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-tsc": "^1.3.2",
"gulp-uglify": "^3.0.0",
"merge2": "^1.1.0",
"path": "^0.12.7",
"rimraf": "^2.6.1",
"systemjs-builder": "^0.16.9",
"typescript": "2.4.1"
},
"scripts": {
"gulp": "gulp",
"rimraf": "rimraf",
"bundle": "gulp bundle",
"postbundle": "rimraf dist"
}
}
</code></pre>
<p>How can it be that "iterable" is not found after all those lib inclusions?
The Typescript compiler does not ignore my tsconfig.json as changing some option gives various outputs, but none without errors.</p>
<p>My environment is Visual Studio 2015 update 3 with Typescript Tools 2.4.1.
I am using npn @types (no typings).
Verbose compilation output shows that Visual Studio effectively uses the 2.4.1 version.</p>
<p>And the most bizarre thing is that compiling using gulp gives no error using the same Typescript version and tsconfig.</p>
| 0debug |
Terraform: what does AssumeRole: Service: ec2 do? : <p>What exactly does this AWS role do?</p>
<p>The most relevant bits seem to be:
<code>"Action": "sts:AssumeRole",</code> and
<code>"Service": "ec2.amazonaws.com"</code></p>
<p>The full role is here:</p>
<pre><code>resource "aws_iam_role" "test_role" {
name = "test_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
</code></pre>
<p>From: <a href="https://www.terraform.io/docs/providers/aws/r/iam_role.html" rel="noreferrer">https://www.terraform.io/docs/providers/aws/r/iam_role.html</a></p>
| 0debug |
How to bulk replace A.b to A('b') in Sublime Text? : I want to bulk replace A.b to A('b') in sublime text, but I don't know if it's possible or how to write the regex expression. Any suggestion would be appreciated! | 0debug |
Can it improve performance when I query specified partition table using parallel,thanks in advance : SELECT /*+ PARALLEL(A,5)*/
A.USER_ID, A.RES_TYPE, A.RES_ID, A.LIMIT_TAG, A.FEEPOLICY_INS_ID, A.FEEPOLICY_ID, TO_NUMBER(TO_CHAR(A.START_DATE, 'YYYYMMDDHH24MISS')) AS START_DATE, TO_NUMBER(TO_CHAR(A.END_DATE, 'YYYYMMDDHH24MISS')) AS END_DATE
FROM TF_B_USER_FREECDR_HASH PARTITION(PAR_TF_B_USER_FREECDR_0) A
ORDER BY A.USER_ID | 0debug |
Swift. URL returning nil : <p>I am trying to open a website in my app, but for some reason one line keeps returning nil, heres my code:</p>
<pre><code>let url = URL(string: "http://en.wikipedia.org/wiki/\(element.Name)")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
</code></pre>
<p>It's the first line (<code>let url = URL...</code>) that keeps on returning this error:</p>
<blockquote>
<p>fatal error: unexpectedly found nil while unwrapping an Optional value.</p>
</blockquote>
<p>What should I do to fix this?</p>
| 0debug |
How does stream.write work? : <p>Basically, why does this work?</p>
<pre><code>System.IO.Stream stream = new MemoryStream();
int a = 4;
byte[] barray = new byte[a];
stream.Write(barray, 0, Marshal.SizeOf(a));
</code></pre>
<p>When this doesn't:</p>
<pre><code>System.IO.Stream stream = new MemoryStream();
int a = 3;
byte[] barray = new byte[a];
stream.Write(barray, 0, Marshal.SizeOf(a));
</code></pre>
<p>This is the error I get:</p>
<pre><code>The offset and length were greater than allowed for the matrix, or the number is greater than the number of elements from the index to the end of the source collection.
</code></pre>
| 0debug |
why my background image not showing on live review? : [i try it a lot of different ways and nothing is showing up, I never use Brackets environment and I'm facing this issue I added my URL image background and isn't showing up][1]
[1]: https://i.stack.imgur.com/HFGxH.png | 0debug |
static void qemu_input_queue_process(void *opaque)
{
struct QemuInputEventQueueHead *queue = opaque;
QemuInputEventQueue *item;
g_assert(!QTAILQ_EMPTY(queue));
item = QTAILQ_FIRST(queue);
g_assert(item->type == QEMU_INPUT_QUEUE_DELAY);
QTAILQ_REMOVE(queue, item, node);
g_free(item);
while (!QTAILQ_EMPTY(queue)) {
item = QTAILQ_FIRST(queue);
switch (item->type) {
case QEMU_INPUT_QUEUE_DELAY:
timer_mod(item->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)
+ item->delay_ms);
return;
case QEMU_INPUT_QUEUE_EVENT:
qemu_input_event_send(item->src, item->evt);
qapi_free_InputEvent(item->evt);
break;
case QEMU_INPUT_QUEUE_SYNC:
qemu_input_event_sync();
break;
}
QTAILQ_REMOVE(queue, item, node);
g_free(item);
}
} | 1threat |
How would I go about make function for object JavaScript? : <p>How would I making my own function like <code>.innerHTML</code> for <code>document.getElementById("idName");</code>? For example it would look something like <code>document.getElementById("idName").myFunction;</code>.</p>
| 0debug |
static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
MXFPartition *partition, *tmp_part;
UID op;
uint64_t footer_partition;
uint32_t nb_essence_containers;
tmp_part = av_realloc_array(mxf->partitions, mxf->partitions_count + 1, sizeof(*mxf->partitions));
if (!tmp_part)
return AVERROR(ENOMEM);
mxf->partitions = tmp_part;
if (mxf->parsing_backward) {
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
partition->pack_length = avio_tell(pb) - klv_offset + size;
switch(uid[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", uid[13]);
return AVERROR_INVALIDDATA;
}
partition->closed = partition->type == Footer || !(uid[14] & 1);
partition->complete = uid[14] > 2;
avio_skip(pb, 4);
partition->kag_size = avio_rb32(pb);
partition->this_partition = avio_rb64(pb);
partition->previous_partition = avio_rb64(pb);
footer_partition = avio_rb64(pb);
partition->header_byte_count = avio_rb64(pb);
partition->index_byte_count = avio_rb64(pb);
partition->index_sid = avio_rb32(pb);
avio_skip(pb, 8);
partition->body_sid = avio_rb32(pb);
avio_read(pb, op, sizeof(UID));
nb_essence_containers = avio_rb32(pb);
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR,
"inconsistent FooterPartition value: %"PRIu64" != %"PRIu64"\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc,
"PartitionPack: ThisPartition = 0x%"PRIX64
", PreviousPartition = 0x%"PRIX64", "
"FooterPartition = 0x%"PRIX64", IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
if (partition->previous_partition &&
mxf->run_in + partition->previous_partition >= klv_offset) {
av_log(mxf->fc, AV_LOG_ERROR,
"PreviousPartition points to this partition or forward\n");
return AVERROR_INVALIDDATA;
}
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 64&& op[13] == 1) mxf->op = OPSONYOpt;
else if (op[12] == 0x10) {
if (nb_essence_containers != 1) {
MXFOP op = nb_essence_containers ? OP1a : OPAtom;
if (!mxf->op)
av_log(mxf->fc, AV_LOG_WARNING, "\"OPAtom\" with %u ECs - assuming %s\n",
nb_essence_containers, op == OP1a ? "OP1a" : "OPAtom");
mxf->op = op;
} else
mxf->op = OPAtom;
} else {
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
mxf->op = OP1a;
}
if (partition->kag_size <= 0 || partition->kag_size > (1 << 20)) {
av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %i - guessing ", partition->kag_size);
if (mxf->op == OPSONYOpt)
partition->kag_size = 512;
else
partition->kag_size = 1;
av_log(mxf->fc, AV_LOG_WARNING, "%i\n", partition->kag_size);
}
return 0;
}
| 1threat |
List process for current user : <p>As an administrator I can get a users processes by running this</p>
<p><code>Get-Process -IncludeUserName | Where UserName -match test</code></p>
<p>But as a non-administrator I can't use <code>-IncludeUserName</code> becuase "The 'IncludeUserName' parameter requires elevated user rights".</p>
<p>So if I'm logged on as the user test, how do I list only his processes and not everything that's running?</p>
| 0debug |
Angular2 UL/LI JSON-tree recursive in ngFor : <p>I'd like to convert JSON-trees into unordered lists in Angular2. I know the recursive directive solution from Angular1 and I am pretty sure the solution in Angular2 will be recursive too.</p>
<pre><code> [
{name:"parent1", subnodes:[]},
{name:"parent2",
subnodes:[
{name:"parent2_child1", subnodes:[]}
],
{name:"parent3",
subnodes:[
{name:"parent3_child1",
subnodes:[
{name:"parent3_child1_child1", subnodes:[]}
]
}
]
}
]
</code></pre>
<p>to this unordered list</p>
<pre><code><ul>
<li>parent1</li>
<li>parent2
<ul>
<li>parent2_child1</li>
</ul>
</li>
<li>parent3
<ul>
<li>parent3_child1
<ul>
<li>parent3_child1_child1</li>
</ul>
</li>
</ul>
</li>
</ul>
</code></pre>
<p>using <strong>Angular2</strong> and ngFor. Anyone got an idea? </p>
| 0debug |
Initialize data on dockerized mongo : <p>I'm running a dockerized mongo container.</p>
<p>I'd like to create a mongo image with some initialized data.</p>
<p>Any ideas?</p>
| 0debug |
what if i start a thread in infinite loop and update my database : please refer below code:
public class InfiniteThreads {
public static int cnt=0;
public static void main(String[] args) {
while (true) {
new MyThread().start();
}
}
public void run(){
// I am updating a database,(if false, then update to true)
}
}
And suppose my database is
id b_status
1 false
2 false
3 false
So my question is, every time I create a new thread my run method will update a row. But as this thread creation is inside an infinite loop, how will my updation work?
Will it keep on updating my database?
Or, first thread will update first row, second will update second?
| 0debug |
Python - basic arithmetic/variable names : <p>The assignment is to write a program that spits out an odd number, a number, and then does basic arithmetic on those numbers. I've gotten it to spit out outputs fine, but I cannot seem to find a way to have the generated numbers be part of the equation. Here is the code I have:</p>
<pre><code>odd = int(input("Please enter an odd number from 1 to 99: "))
print(int(odd))
num = int(input("Please enter a number from 1 to 200: "))
print(int(num))
print('odd + num =',odd+num)
print('odd - num =',odd-num)
print('odd * num=',odd*num)
print('odd / num =',odd/num)
print('odd + num =',num+odd)
print('odd - num =',num-odd)
print('odd * num =',num*odd)
print('odd / num =',num/odd)
</code></pre>
<p>I need the 'odd / num =' section to be replaced with the numbers generated, but I'm unsure as to how to do that and my textbook says nothing about it.</p>
<p>Any help would really be appreciated.</p>
| 0debug |
static void icp_control_init(target_phys_addr_t base)
{
MemoryRegion *io;
io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion));
memory_region_init_io(io, &icp_control_ops, NULL,
"control", 0x00800000);
memory_region_add_subregion(get_system_memory(), base, io);
}
| 1threat |
how use sql primitive in c # entities. : how use sql primitive in c # entities.
ex: SELECT studentID, studentName FROM dbo.Student
I did: using(studentEbestuur db = new studentEbestuur())
{
var ListST = db.ChungLoais.SqlQuery("SELECT studentID, studentName FROM dbo.Student").toList();
}
but it is an err:
[enter image description here][1]
[1]: https://i.stack.imgur.com/D6jHO.png
Okay. Help me. Thank all you. =) =) | 0debug |
get sql count and rows : guys.
I want to get total rows and also get rows. I have something like this
SELECT count(id), id FROM post LIMIT 10; | 0debug |
static void tcg_out_brcond(TCGContext *s, TCGCond cond,
TCGArg arg1, TCGArg arg2, int const_arg2,
int label_index, TCGType type)
{
tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type);
tcg_out_bc(s, tcg_to_bc[cond], label_index);
}
| 1threat |
static QDM2SubPNode *qdm2_search_subpacket_type_in_list(QDM2SubPNode *list,
int type)
{
while (list != NULL && list->packet != NULL) {
if (list->packet->type == type)
return list;
list = list->next;
}
return NULL;
}
| 1threat |
uint32_t hpet_in_legacy_mode(void)
{
if (hpet_statep)
return hpet_statep->config & HPET_CFG_LEGACY;
else
return 0;
}
| 1threat |
void cpu_interrupt(CPUArchState *env, int mask)
{
CPUState *cpu = ENV_GET_CPU(env);
env->interrupt_request |= mask;
cpu_unlink_tb(cpu);
}
| 1threat |
static void bochs_bios_init(void)
{
void *fw_cfg;
uint8_t *smbios_table;
size_t smbios_len;
uint64_t *numa_fw_cfg;
int i, j;
register_ioport_write(0x400, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x401, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x402, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x403, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x8900, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x501, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x502, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x500, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x503, 1, 1, bochs_bios_write, NULL);
fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, (uint8_t *)acpi_tables,
acpi_tables_len);
smbios_table = smbios_get_table(&smbios_len);
if (smbios_table)
fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
smbios_table, smbios_len);
numa_fw_cfg = qemu_mallocz((1 + smp_cpus + nb_numa_nodes) * 8);
numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
for (i = 0; i < smp_cpus; i++) {
for (j = 0; j < nb_numa_nodes; j++) {
if (node_cpumask[j] & (1 << i)) {
numa_fw_cfg[i + 1] = cpu_to_le64(j);
break;
}
}
}
for (i = 0; i < nb_numa_nodes; i++) {
numa_fw_cfg[smp_cpus + 1 + i] = cpu_to_le64(node_mem[i]);
}
fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, (uint8_t *)numa_fw_cfg,
(1 + smp_cpus + nb_numa_nodes) * 8);
}
| 1threat |
Bootstrap 4 .modal('hide') not working : <p>I am creating a really simple, but a bit tweaked, modal for showing an iFrame. I open the model by a javascript function and the modal call function provided by bootstrap. In my modal I've placed an icon for closing the modal. If I click on this close icon the modal won't hide. I use a javascript onclick with the <code>.modal('show')</code> and <code>.modal('hide')</code> functions provided by bootstrap. The modal doesn't hide, but my console log is fired. </p>
<p>I know there are many questions out there with a similiar problem but these questions did not contain the answer I was looking for. I know that css in html is just not right, but I was doing some fast prototyping so please forgive me for that.</p>
<p>Code</p>
<p>Open link for modal</p>
<pre><code><a href="#" onClick="openFeedback('getBootstrap')">Klik hier om de website te bekijken</a>
</code></pre>
<p>The modal html</p>
<pre><code><!-- Modal -->
<div class="modal fade" id="iframe_feedback" style="padding-top: 20px;">
<i class="ion-close-round close-modal" style="position: fixed; right: 40px; font-size: 32px; color: white; top: 40px; cursor: pointer;" onClick="closeModal()"></i>
<div class="body-modal" style="max-width: 90%; margin: 0 auto; overflow: scroll;">
<div id="clip" style="overflow:scroll;">
<iframe src="/dashboard" style=" width:2600px; height: 1600px;"></iframe>
</div>
</div>
</div>
</code></pre>
<p>The JS </p>
<pre><code>function openFeedback(link) {
$('#iframe_feedback').modal('show');
console.log(link);
};
function closeModal() {
$("#iframe_feedback").modal('hide');
console.log('Close fired');
};
</code></pre>
<p>My main problem is that my modal is showing up, also fires the <code>console.log</code> for both show and hide but after clicking on the close button the modal doesn't hide.</p>
| 0debug |
How to remove tthe duplicate lines in a div using javascript jquery php : Hi am trying to remove the duplicate lines in a div . How can I remove them
<div id="content>
<p>Hello</p>
<p>why</p>
<p>are</p>
<p>hello</p>
</div>
Output is shown as
hello
why
are
hello
How can I remove the duplicate lines | 0debug |
Need help creating CSS cards : This question might be a bit broad but I need urgent help in completing this. I am trying to create three cards and a bar that is on top of them like this:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/Vg5d8.png
Where the orange parts are images and the grey parts are text.
Here is my code:
<h1>HTML</h1>
<body>
<div class="blue-line"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</body>
<h1>CSS</h1>
.blue-line{
height: 100px;
background-color: lightblue;
margin-left: 10px;
margin-right:10px;
}
.card{
height: 400px;
width: 300px;
background-color: grey;
margin-left: 10px;
margin-right:10px;
margin-top:20px;
}
| 0debug |
static void sch_handle_start_func(SubchDev *sch, ORB *orb)
{
PMCW *p = &sch->curr_status.pmcw;
SCSW *s = &sch->curr_status.scsw;
int path;
int ret;
bool suspend_allowed;
path = 0x80;
if (!(s->ctrl & SCSW_ACTL_SUSP)) {
s->cstat = 0;
s->dstat = 0;
assert(orb != NULL);
p->intparm = orb->intparm;
if (!(orb->lpm & path)) {
s->flags |= SCSW_FLAGS_MASK_CC;
s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
s->ctrl |= (SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND);
return;
}
sch->ccw_fmt_1 = !!(orb->ctrl0 & ORB_CTRL0_MASK_FMT);
s->flags |= (sch->ccw_fmt_1) ? SCSW_FLAGS_MASK_FMT : 0;
sch->ccw_no_data_cnt = 0;
suspend_allowed = !!(orb->ctrl0 & ORB_CTRL0_MASK_SPND);
} else {
s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND);
suspend_allowed = true;
}
sch->last_cmd_valid = false;
do {
ret = css_interpret_ccw(sch, sch->channel_prog, suspend_allowed);
switch (ret) {
case -EAGAIN:
break;
case 0:
s->ctrl &= ~SCSW_ACTL_START_PEND;
s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
SCSW_STCTL_STATUS_PEND;
s->dstat = SCSW_DSTAT_CHANNEL_END | SCSW_DSTAT_DEVICE_END;
s->cpa = sch->channel_prog + 8;
break;
case -EIO:
break;
case -ENOSYS:
s->ctrl &= ~SCSW_ACTL_START_PEND;
s->dstat = SCSW_DSTAT_UNIT_CHECK;
sch->sense_data[0] = 0x80;
s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
s->cpa = sch->channel_prog + 8;
break;
case -EFAULT:
s->ctrl &= ~SCSW_ACTL_START_PEND;
s->cstat = SCSW_CSTAT_DATA_CHECK;
s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
s->cpa = sch->channel_prog + 8;
break;
case -EBUSY:
s->flags &= ~SCSW_FLAGS_MASK_CC;
s->flags |= (1 << 8);
s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
s->ctrl |= SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
break;
case -EINPROGRESS:
s->ctrl &= ~SCSW_ACTL_START_PEND;
s->ctrl |= SCSW_ACTL_SUSP;
break;
default:
s->ctrl &= ~SCSW_ACTL_START_PEND;
s->cstat = SCSW_CSTAT_PROG_CHECK;
s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
s->cpa = sch->channel_prog + 8;
break;
}
} while (ret == -EAGAIN);
}
| 1threat |
Group by not working - Laravel : <p>I'm not able to run this simple query in Laravel 5.3</p>
<pre><code>$top_performers = DB::table('pom_votes')
->groupBy('performer_id')
->get();
</code></pre>
<p>It gives me:</p>
<pre><code>SQLSTATE[42000]: Syntax error or access violation: 1055 'assessment_system.pom_votes.id' isn't in GROUP BY (SQL: select * from `pom_votes` group by `performer_id`)
</code></pre>
<p>However if I copy raw query from the error and fire directly in PhpMyAdmin, it works fine.</p>
<p>I have already checked this:</p>
<p><a href="https://laravel.com/docs/5.3/queries#ordering-grouping-limit-and-offset" rel="noreferrer">https://laravel.com/docs/5.3/queries#ordering-grouping-limit-and-offset</a></p>
<p>Any help would be appricaited.</p>
<p>Thanks,</p>
<p>Parth Vora</p>
| 0debug |
def matrix_to_list(test_list):
temp = [ele for sub in test_list for ele in sub]
res = list(zip(*temp))
return (str(res)) | 0debug |
OCSP certificate stapling in Android : <p>I've been banging my head on the wall for the past few days trying to implement OCSP validation in Android. </p>
<p>So far in iOS has been easy to implement, but for Android every single piece of information I've come across just doesn't work. I've been using both my customer's API endpoint and <a href="https://revoked.grc.com">this website</a> to run tests for certificate revocation and so far I haven't been lucky to detect a revoked certificate inside my Android Application. I'm using OKHTTPClient.
Here's the method where I validate certification revocation</p>
<pre><code>public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
assert (chain != null);
if (chain == null) {
throw new IllegalArgumentException(
"checkServerTrusted: X509Certificate array is null");
}
assert (chain.length > 0);
if (!(chain.length > 0)) {
throw new IllegalArgumentException(
"checkServerTrusted: X509Certificate is empty");
}
if (VERIFY_AUTHTYPE) {
assert (null != authType && authType.equalsIgnoreCase(AUTH_TYPE));
if (!(null != authType && authType.equalsIgnoreCase(AUTH_TYPE))) {
throw new CertificateException(
"checkServerTrusted: AuthType is not " + AUTH_TYPE);
}
}
if(chain[0]!=null){
try {
X509Certificate issuerCert = chain[1];
X509Certificate c1 = chain[0];
TrustAnchor anchor = new TrustAnchor(issuerCert, null);
Set anchors = Collections.singleton(anchor);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
List list = Arrays.asList(new Certificate[]{c1});
CertPath path = cf.generateCertPath(list);
PKIXParameters params = new PKIXParameters(anchors);
// Activate certificate revocation checking
params.setRevocationEnabled(false);
// Activate OCSP
Security.setProperty("ocsp.enable", "true");
// Ensure that the ocsp.responderURL property is not set.
if (Security.getProperty("ocsp.responderURL") != null) {
throw new
Exception("The ocsp.responderURL property must not be set");
}
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
PKIXCertPathValidatorResult result = (PKIXCertPathValidatorResult) validator
.validate(path, params);
System.out.println("VALID");
} catch (Exception e) {
System.out.println("EXCEPTION " + e.getMessage());
e.printStackTrace();
}
</code></pre>
| 0debug |
static void coroutine_fn verify_entered_step_2(void *opaque)
{
Coroutine *caller = (Coroutine *)opaque;
g_assert(qemu_coroutine_entered(caller));
g_assert(qemu_coroutine_entered(qemu_coroutine_self()));
qemu_coroutine_yield();
g_assert(qemu_coroutine_entered(caller));
g_assert(qemu_coroutine_entered(qemu_coroutine_self()));
qemu_coroutine_yield();
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.