problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static void qvirtio_pci_set_features(QVirtioDevice *d, uint32_t features)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
qpci_io_writel(dev->pdev, dev->addr + VIRTIO_PCI_GUEST_FEATURES, features);
}
| 1threat |
How to mention user in slack.client : <p>This might be a simple question, but I can not get it work.</p>
<p>I am using Slack Python Api to mention a user in a channel, and I am referring to the document here, <a href="https://api.slack.com/methods/chat.postMessage" rel="noreferrer">https://api.slack.com/methods/chat.postMessage</a>, and my code is simple as,</p>
<pre><code>from slackclient import SlackClient
sc = SlackClient(token)
message = sc.api_call(
'chat.postMessage',
channel='#channelname',
text='This is a test.'
)
</code></pre>
<p>This will send a message to the channel, but I can not find any option to mention users. And I tried to put <code>@someone</code> inside the message such as</p>
<pre><code> text='@someone This is a test.'
</code></pre>
<p>The message will be posted but in plain text, but really mentioning someone.
BTW, I am using a Test Token.(Or maybe this feature is only available for authorized token? )</p>
<p>Is there any option or method to do this?<br>
Thank you in advance.</p>
| 0debug |
What is the mathematics behind the "smoothing" parameter in TensorBoard's scalar graphs? : <p>I presume it is some kind of moving average, but the valid range is between 0 and 1.</p>
| 0debug |
void qemu_bh_cancel(QEMUBH *bh)
{
bh->scheduled = 0;
}
| 1threat |
access root element of react component : <p>If I have the following in the <code>render()</code> function of my react component</p>
<pre><code>return <div ref="myId"></div>;
</code></pre>
<p>I know I can access the div element in my react code with <code>this.refs.myId</code>. But if the ref attribute were not defined in the div element, is there another way for me get a handle on the div element since it is a <strong>root element</strong> of the component?</p>
| 0debug |
How can I write Fibonacci with for...of? : <p>** How can I write a program that produce Fibonacci with for...of in javascript**</p>
<p>I've tried this, and it works well</p>
<pre><code>function createFibonacci(number) {
var i;
var fib = []; // Initialize array!
fib[0] = 0;
fib[1] = 1;
for (i = 2; i <= number; i++) {
// Next fibonacci number = previous + one before previous
// Translated to JavaScript:
fib[i] = fib[i - 2] + fib[i - 1];
console.log(fib[i]);
}
}
createFibonacci(8);
</code></pre>
<p>But I'm wondering if it is possible to write it with <strong>for..of</strong>, is there any way to do this?</p>
| 0debug |
How to check if recipient's email address has no typo : <p>I need to send order confirmations to my customers. Sales people asks for customers email address. But if sales person makes a typo writing down email address, how can I check for it ?</p>
<p>I have a piece of code from php.net. It checks recipients domain and email format but not if email exists. </p>
<p>Let's assume customer's email is like this : someone@domain.com</p>
<p>Code outputs like this :</p>
<p>email someone@domain.com, 0= not ok, 1= ok : 1 <-- correct</p>
<p>email someone@domain.co, 0= not ok, 1= ok : 0 <-- domain typo</p>
<p>email somepne@domain.com, 0= not ok, 1= ok : 1 <-- mailbox typo</p>
<p>It outputs 0 if domain has a typo, but 1 if mailbox part has a typo.</p>
<p>How can I add check for mailbox part in it ?</p>
<p>Code :</p>
<pre><code><?
/*
This script validates an e-mail adress using getmxrr and fsockopen
1. it validates the syntax of the address.
2. get MX records by hostname
3. connect mail server and verify mailbox(using smtp command RCTP TO:<email>)
When the function "validate_email([email])" fails connecting the mail server with the highest priority in the MX record it will continue with the second mail server and so on..
The function "validate_email([email])" returns 0 when it failes one the 3 steps above, it will return 1 otherwise
*/
$email = "someone@domain.com";
echo "email $email, 0= not ok, 1= ok : ".validate_email($email)."<br>";
$email = "someone@domain.co";
echo "email $email, 0= not ok, 1= ok : ".validate_email($email)."<br>";
$email = "somepne@domain.com";
echo "email $email, 0= not ok, 1= ok : ".validate_email($email)."<br>";
function validate_email($email){
$mailparts=explode("@",$email);
$hostname = $mailparts[1];
// validate email address syntax
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$^";
$b_valid_syntax=preg_match($exp, $email);
// get mx addresses by getmxrr
$b_mx_avail=getmxrr( $hostname, $mx_records, $mx_weight );
$b_server_found=0;
if($b_valid_syntax && $b_mx_avail){
// copy mx records and weight into array $mxs
$mxs=array();
for($i=0;$i<count($mx_records);$i++){
$mxs[$mx_weight[$i]]=$mx_records[$i];
}
// sort array mxs to get servers with highest prio
ksort ($mxs, SORT_NUMERIC );
reset ($mxs);
while (list ($mx_weight, $mx_host) = each ($mxs) ) {
if($b_server_found == 0){
//try connection on port 25
$fp = @fsockopen($mx_host,25, $errno, $errstr, 2);
if($fp){
$ms_resp="";
// say HELO to mailserver
$ms_resp.=send_command($fp, "HELO microsoft.com");
// initialize sending mail
$ms_resp.=send_command($fp, "MAIL FROM:<support@microsoft.com>");
// try receipent address, will return 250 when ok..
$rcpt_text=send_command($fp, "RCPT TO:<".$email.">");
$ms_resp.=$rcpt_text;
if(substr( $rcpt_text, 0, 3) == "250")
$b_server_found=1;
// quit mail server connection
$ms_resp.=send_command($fp, "QUIT");
fclose($fp);
}
}
}
}
return $b_server_found;
}
function send_command($fp, $out){
fwrite($fp, $out . "\r\n");
return get_data($fp);
}
function get_data($fp){
$s="";
stream_set_timeout($fp, 2);
for($i=0;$i<2;$i++)
$s.=fgets($fp, 1024);
return $s;
}
// support windows platforms
if (!function_exists ('getmxrr') ) {
function getmxrr($hostname, &$mxhosts, &$mxweight) {
if (!is_array ($mxhosts) ) {
$mxhosts = array ();
}
if (!empty ($hostname) ) {
$output = "";
@exec ("nslookup.exe -type=MX $hostname.", $output);
$imx=-1;
foreach ($output as $line) {
$imx++;
$parts = "";
if (preg_match ("/^$hostname\tMX preference = ([0-9]+), mail exchanger = (.*)$/", $line, $parts) ) {
$mxweight[$imx] = $parts[1];
$mxhosts[$imx] = $parts[2];
}
}
return ($imx!=-1);
}
return false;
}
}
?>
</code></pre>
| 0debug |
How to return array in php ? Acctually I want to return whole value of $x[] insted of last index of $x[].Please help me : How to return array in php ? Acctually I want to return whole value of $x[] insted of last index of $x[].Please help me...
<?php
function top() {
require './php/connection.php';
$sql = "SELECT * FROM tbl_add";
$query = mysqli_query($connect, $sql);
$n = 0;
while ($result = mysqli_fetch_assoc($query)) {
$a[$n] = $result['add_id'];
$n = $n + 1;
}
$n = $n - 1;
for ($j = 0; $j < $n; $j++) {
for ($i = 0; $i < $n - 1 - $j; $i++) {
if ($a[$i] > $a[$i + 1]) {
$tmp = $a[$i];
$a[$i] = $a[$i + 1];
$a[$i + 1] = $tmp;
}
}
}
for ($i = 0; $i <= $n; $i++) {
echo $a[$i] . '<br>';
}
$j = 1;
for ($i = 0; $i <= 5; $i++) {
$r = $a[$i];
$sql = "SELECT * FROM tbl_add WHERE add_id='$r'";
$query = mysqli_query($connect, $sql);
$result = mysqli_fetch_assoc($query);
if ($result) {
$x[] = $result['mail'];
return $x[];
}
}
}
?> | 0debug |
get_pointer_coordinates(int *x, int *y, Display *dpy, AVFormatContext *s1)
{
Window mrootwindow, childwindow;
int dummy;
mrootwindow = DefaultRootWindow(dpy);
if (XQueryPointer(dpy, mrootwindow, &mrootwindow, &childwindow,
x, y, &dummy, &dummy, (unsigned int*)&dummy)) {
} else {
av_log(s1, AV_LOG_INFO, "couldn't find mouse pointer\n");
*x = -1;
*y = -1;
}
}
| 1threat |
SPFX how to get file ID? : <p>I am working on a webpart, and I need to filter a folder with files tied to a <strong>list item</strong>, but I am facing multiple problems:</p>
<p>a) I can store the file ID in a lookup field of the list item, but I cannot retrieve the file ID with any available query. </p>
<pre><code>meetingFolderPath.folder.files.get();
</code></pre>
<p>This query gets me a all the files, but none of them contain the lookup ID. They do contain a NAME, UNIQUEID, and URL, all of which is of type string, but I <strong>cannot</strong> store a string in a lookup field in sharepoint. It doesnt even support any list-type fields other than lookup (which takes int or int[]).</p>
<p>b) .expand seemingly does not support a multiple-lookup field</p>
<pre><code> meetingFolderPath.folder.files.expand("Files").get();
</code></pre>
<p>I would assume some of you to suggest this, and maybe Im doing it wrong, but I cannot get it to work. Remember I have lookup field that contains multiple IDs</p>
<p>c) cannot use Attachments.</p>
<p>The req spec specifically says NOT to use attachments, which would have solved my problem, but they need to be able to collab on a file, so its of no use that they have to upload every little iteration of the file. Instead the file should be in a folder, tied to a Team, where they can make as many changes as needed without losing the reference in the list field.</p>
<p>d) custom query does not support get by ID</p>
<pre><code>_api/yada/yada/files('NAME') // WORKS
_api/yada/yada/files(id) // DOESNT WORK
</code></pre>
<p>I tried messing with a custom query, but putting an ID instead of a name returns an error.</p>
<p>At this point, the only solution I see is a complete seperate list containing a list item ID and a filename.. but I really do not want to implement that.</p>
| 0debug |
I have excel file which more than 10 lack record how i open it. : I have excel file which have about 10 lack record in one Sheet.when i open in excel it can't load properly how i open this record.can other software to open this data properly | 0debug |
Swift Json Date String convert in to Date Object : <p>I was trying to convert JSON date in to date time. But it's not working properly.</p>
<p>My Time Zone (.current) - > +05.30</p>
<p>Json date (string) -> 2017-06-23T04:30:43Z<br>
The DateObject I Needed in the end -> 2017-06-23T10:00:43+0530</p>
<p>What I want in Convert json date in to a DateObject. I could not find any solution over internet thats why I'm asking.</p>
<p>Thank you.</p>
| 0debug |
which is the best frame work for game development in android : <p>i am a beginner on game development. Can anybody suggest a best game frame work for mobile game development. </p>
| 0debug |
bootstrap grid col overflowing : <p>I am starting to learn Bootstrap, I could not understand this behaviour.</p>
<p>Text of a <code>.col</code> element inside a <code>.row</code> is overflowing to enter next <code>col</code> why is it happening and What can i do to wrap the text up.</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<h1>Heading</h1>
<div class="row">
<div class="col-md-6">
HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHel
</div>
<div class="col-md-6">
man
</div>
</div></code></pre>
</div>
</div>
</p>
| 0debug |
Legitimate reason for comparing floats? : I seem to see people asking all the time around here questions about floating point numbers and comparing them.....the canonical answer is always: just see if the numbers are within some small number of eachother..........
So the question is this: Why would you ever need to know if two floating point numbers are equal to eachother?
In all my years of coding I have never needed to do this (although I will admit that even *I* am not omniscient). From my point of view if you are trying to use floating point numbers for and for some reason want to know if the numbers are equal, you should probably be using an integer type (or a decimal type in languages that support it). Am I just missing something? | 0debug |
static int draw_glyphs(DrawTextContext *dtext, AVFilterBufferRef *picref,
int width, int height, const uint8_t rgbcolor[4], const uint8_t yuvcolor[4], int x, int y)
{
char *text = dtext->text;
uint32_t code = 0;
int i;
uint8_t *p;
Glyph *glyph = NULL;
for (i = 0, p = text; *p; i++) {
Glyph dummy = { 0 };
GET_UTF8(code, *p++, continue;);
if (code == '\n' || code == '\r' || code == '\t')
continue;
dummy.code = code;
glyph = av_tree_find(dtext->glyphs, &dummy, (void *)glyph_cmp, NULL);
if (glyph->bitmap.pixel_mode != FT_PIXEL_MODE_MONO &&
glyph->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
return AVERROR(EINVAL);
if (dtext->is_packed_rgb) {
draw_glyph_rgb(picref, &glyph->bitmap,
dtext->positions[i].x+x, dtext->positions[i].y+y, width, height,
dtext->pixel_step[0], rgbcolor, dtext->rgba_map);
} else {
draw_glyph_yuv(picref, &glyph->bitmap,
dtext->positions[i].x+x, dtext->positions[i].y+y, width, height,
yuvcolor, dtext->hsub, dtext->vsub);
}
}
return 0;
}
| 1threat |
Disable certain Docker run options : <p>I'm currently working on a setup to make Docker available on a high performance cluster (HPC). The idea is that every user in our group should be able to reserve a machine for a certain amount of time and be able to use Docker in a "normal way". Meaning accessing the Docker Daemon via the Docker CLI.</p>
<p>To do that, the user would be added to the Docker group. But this imposes a big security problem for us, since this basically means that the user has root privileges on that machine.</p>
<p>The new idea is to make use of the user namespace mapping option (as described in <a href="https://docs.docker.com/engine/reference/commandline/dockerd/#/daemon-user-namespace-options" rel="noreferrer">https://docs.docker.com/engine/reference/commandline/dockerd/#/daemon-user-namespace-options</a>). As I see it, this would tackle our biggest security concern that the root in a container is the same as the root on the host machine.</p>
<p>But as long as users are able to bypass this via --userns=host , this doesn't increase security in any way.</p>
<p><strong>Is there a way to disable this and other Docker run options?</strong></p>
| 0debug |
Bootstrap horizontal navbar not working. Appearing as verticle : Here is my html using bootstrap
<div class="col-lg-8 pull-right col-md-9 col-sm-9">
<div class="col-lg-11 col-md-7 col-sm-5 ">
<div id="navbar" class="navbar-collapse navbar-right collapse hover-effect">
<ul class="nav navbar-nav">
<li><a href="#about">ABOUT</a></li>
<li><a href="#services">SERVICES</a></li>
<li><a href="#gallery">GALLERY</a></li>
<li><a href="#plans">PLANS</a></li>
<li><a href="#faq">FAQs</a></li>
<li><a href="#team">TEAM</a></li>
<li><a href="#contact">CONTACT</a></li>
</ul>
</div>
</div>
</div>
I removed the CSS file also. but still the problem is same.
| 0debug |
What counts as a transaction on the free API license? : <p>I'm working on a book for Manning and want to use Alchemy News API as part of one of the examples. I have a free license which says it allows for 1,000 transactions per day. Does that mean 1,000 queries or something else? I hit the limit today way earlier than I expected to, at significantly less than 1,000 queries. </p>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
static void kvm_apic_realize(DeviceState *dev, Error **errp)
{
APICCommonState *s = APIC_COMMON(dev);
memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, "kvm-apic-msi",
APIC_SPACE_SIZE);
if (kvm_has_gsi_routing()) {
msi_nonbroken = true;
}
}
| 1threat |
static void keyword_literal(void)
{
QObject *obj;
QBool *qbool;
QObject *null;
QString *str;
obj = qobject_from_json("true");
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
g_assert(qbool_get_bool(qbool) == true);
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), "true") == 0);
QDECREF(str);
QDECREF(qbool);
obj = qobject_from_json("false");
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
g_assert(qbool_get_bool(qbool) == false);
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), "false") == 0);
QDECREF(str);
QDECREF(qbool);
obj = qobject_from_jsonf("%i", false);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
g_assert(qbool_get_bool(qbool) == false);
QDECREF(qbool);
obj = qobject_from_jsonf("%i", 2);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
g_assert(qbool_get_bool(qbool) == true);
QDECREF(qbool);
obj = qobject_from_json("null");
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QNULL);
null = qnull();
g_assert(null == obj);
qobject_decref(obj);
qobject_decref(null);
}
| 1threat |
How to set hidden fields in redux form in react native? : <p>How to set hidden fields in redux form in react native ?</p>
<p>i jsut cannot find any way on how to do that . any help?</p>
| 0debug |
Three of the Same JavaScript AJAX calls to same PHP page result in 500 (Internal Server Error) : <p>I have tried <code>@session_start()</code> along with <code>session_write_close()</code>, but that's not working. The requests are the same. If the first 2 AJAX requests work, why not the 3rd? I've looked at <code>phpinfo()</code>, and I'm not exceeding any memory limits. Anything pointing me in the right direction is appreciated.</p>
| 0debug |
How to use Async and Await with AWS SDK Javascript : <p>I am working with the AWS SDK using the KMS libary. I would like to use async and await instead of callbacks.</p>
<pre><code>import AWS, { KMS } from "aws-sdk";
this.kms = new AWS.KMS();
const key = await this.kms.generateDataKey();
</code></pre>
<p>However this does not work, when wrapped in an async function.</p>
<p>How can i use async and await here?</p>
| 0debug |
static void process_event(JSONMessageParser *parser, QList *tokens)
{
GAState *s = container_of(parser, GAState, parser);
QObject *obj;
QDict *qdict;
Error *err = NULL;
int ret;
g_assert(s && parser);
g_debug("process_event: called");
obj = json_parser_parse_err(tokens, NULL, &err);
if (err || !obj || qobject_type(obj) != QTYPE_QDICT) {
qobject_decref(obj);
qdict = qdict_new();
if (!err) {
g_warning("failed to parse event: unknown error");
error_setg(&err, QERR_JSON_PARSING);
} else {
g_warning("failed to parse event: %s", error_get_pretty(err));
}
qdict_put_obj(qdict, "error", qmp_build_error_object(err));
error_free(err);
} else {
qdict = qobject_to_qdict(obj);
}
g_assert(qdict);
if (qdict_haskey(qdict, "execute")) {
process_command(s, qdict);
} else {
if (!qdict_haskey(qdict, "error")) {
QDECREF(qdict);
qdict = qdict_new();
g_warning("unrecognized payload format");
error_setg(&err, QERR_UNSUPPORTED);
qdict_put_obj(qdict, "error", qmp_build_error_object(err));
error_free(err);
}
ret = send_response(s, QOBJECT(qdict));
if (ret < 0) {
g_warning("error sending error response: %s", strerror(-ret));
}
}
QDECREF(qdict);
}
| 1threat |
PHP and redirection : <p>I am fairly new to this site and have a question about a problem that I have recently.
How to interact with a page on which we just made a redirection?
That is, after validating a form, I would like to be able to redirect the user to the login page and show him a success message such as: Successful registration! But I can not do it.</p>
| 0debug |
int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
{
HWVoiceIn *hw = sw->hw;
int samples, live, ret = 0, swlim, isamp, osamp, rpos, total = 0;
st_sample_t *src, *dst = sw->buf;
rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
live = hw->total_samples_captured - sw->total_hw_samples_acquired;
if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
dolog ("live_in=%d hw->samples=%d\n", live, hw->samples);
return 0;
}
samples = size >> sw->info.shift;
if (!live) {
return 0;
}
swlim = (live * sw->ratio) >> 32;
swlim = audio_MIN (swlim, samples);
while (swlim) {
src = hw->conv_buf + rpos;
isamp = hw->wpos - rpos;
if (isamp <= 0) {
isamp = hw->samples - rpos;
}
if (!isamp) {
break;
}
osamp = swlim;
if (audio_bug (AUDIO_FUNC, osamp < 0)) {
dolog ("osamp=%d\n", osamp);
return 0;
}
st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
swlim -= osamp;
rpos = (rpos + isamp) % hw->samples;
dst += osamp;
ret += osamp;
total += isamp;
}
sw->clip (buf, sw->buf, ret);
sw->total_hw_samples_acquired += total;
return ret << sw->info.shift;
}
| 1threat |
static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
int a0_sign = a0 >> 31;
a0 = (a0 ^ a0_sign) - a0_sign;
if(a0 < pq){
int a1 = FFABS((2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3);
int a2 = FFABS((2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3);
if(a1 < a0 || a2 < a0){
int clip = src[-1*stride] - src[ 0*stride];
int clip_sign = clip >> 31;
clip = ((clip ^ clip_sign) - clip_sign)>>1;
if(clip){
int a3 = FFMIN(a1, a2);
int d = 5 * (a3 - a0);
int d_sign = (d >> 31);
d = ((d ^ d_sign) - d_sign) >> 3;
d_sign ^= a0_sign;
if( d_sign ^ clip_sign )
d = 0;
else{
d = FFMIN(d, clip);
d = (d ^ d_sign) - d_sign;
src[-1*stride] = cm[src[-1*stride] - d];
src[ 0*stride] = cm[src[ 0*stride] + d];
}
return 1;
}
}
}
return 0;
}
| 1threat |
static void pci_basic(void)
{
QVirtioPCIDevice *dev;
QPCIBus *bus;
QVirtQueuePCI *vqpci;
QGuestAllocator *alloc;
void *addr;
bus = pci_test_start();
dev = virtio_blk_pci_init(bus, PCI_SLOT);
alloc = pc_alloc_init();
vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev,
alloc, 0);
addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false);
test_basic(&qvirtio_pci, &dev->vdev, alloc, &vqpci->vq,
(uint64_t)(uintptr_t)addr);
guest_free(alloc, vqpci->vq.desc);
pc_alloc_uninit(alloc);
qvirtio_pci_device_disable(dev);
g_free(dev);
qpci_free_pc(bus);
test_end();
}
| 1threat |
python error line 6, in class Noddy: : I have an task to do to figure out what the code below does. it looks like it was constructed in python2 but I want to use python3. I have installed argparse which it requires and set up necessary file path but every time I run the program in command Line I get these issues.
line 6, in <module>
class Noddy:
line 63, in Noddy
if __name__ == '__main__': main()
line 57, in main
ent = Noddy.make(fools)
The code is below.
#! python3
# Hello World program in Python
# Hello World program in Python
class Noddy:
def __init__(self, x):
self.ant = None
self.dec = None
self.holder = x
@classmethod
def make(self, l):
ent = Noddy(l.pop(0))
for x in l:
ent.scrobble(x)
return ent
def scrobble(self, x):
if self.holder > x:
if self.ant is None:
self.ant = Noddy(x)
else:
self.ant.scrobble(x)
else:
if self.dec is None:
self.dec = Noddy(x)
else:
self.dec.scrobble(x)
def bubble(self):
if self.ant:
for x in self.ant.bubble():
yield x
yield self.holder
if self.dec:
for x in self.dec.bubble():
yield x
def bobble(self):
yield self.holder
if self.ant:
for x in self.ant.bobble():
yield x
if self.dec:
for x in self.dec.bobble():
yield x
def main():
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("foo")
args = ap.parse_args()
foo = open(args.foo)
fools = [int(bar) for bar in foo]
ent = Noddy.make(fools)
print(list(ent.bubble()))
print
print(list(ent.bobble()))
if __name__ == '__main__': main()
| 0debug |
Collection Where LIKE Laravel 5.4 : <p>I know collection doesn't support where LIKE but how can I achieve this.</p>
<p>My data is:
<a href="https://i.stack.imgur.com/A7ldY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/A7ldY.png" alt="enter image description here"></a></p>
<pre><code>collect($products)->where('name', 'LIKE', '%'. $productName . '%');
</code></pre>
<p>Laravel doesn't support where like in the collection. I'm thinking to use </p>
<pre><code>collect($products)->filter( function () use ($productName) {
return preg_match(pattern, subject);
})
</code></pre>
<p>but I don't know how to do it. TY</p>
| 0debug |
Python gives me last value of list when I ask it to give the the value at -1 : <p>I am on python 3.7.1.</p>
<p>I am working with data structures, and when using lists, I ran into a bug.
When I try to access index -1, python gives me the last entry in the list.</p>
<p>I opened python shell, and ran the following commands:</p>
<pre class="lang-py prettyprint-override"><code>>>> l = [0,1,2]
>>> l[-1]
2
>>> l[3]
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
l[3]
IndexError: list index out of range
</code></pre>
<p>This is probably due to a bug on python 3.7.1, but is there a way other than updating python that fixes this? I'm in the middle of a project.</p>
| 0debug |
css clouds animation issue : im having trouble integrating this css clouds animation into my
website. the overflow : hidden and scroll are causing my problems.
and I don't want the clouds scrolling outside of the blue box background area, but don't know how . please see http://www.filehostfree.com/cloudcsstest/cssanimation.html
ive left a comment in the source code. please see ,highlights my issue.
any help is appreciated.thanks | 0debug |
What is the difference between Symantic error and Logical error in C? : <p>1.</p>
<pre><code> int a=6, b=5, c;
a + b = c;
printf("%d", c);
return 0;
</code></pre>
<p>2.</p>
<pre><code>int calculateAreaRectangle(int height, int width)
{
return (height + width);
}
</code></pre>
<p>which is symentic error and which is logical error?</p>
<p>My another question - Is it correct that symantic error is always detected during due to compilation? Please give some example.</p>
| 0debug |
static void win32_aio_process_completion(QEMUWin32AIOState *s,
QEMUWin32AIOCB *waiocb, DWORD count)
{
int ret;
s->count--;
if (waiocb->ov.Internal != 0) {
ret = -EIO;
} else {
ret = 0;
if (count < waiocb->nbytes) {
if (waiocb->is_read) {
qemu_iovec_memset(waiocb->qiov, count, 0,
waiocb->qiov->size - count);
} else {
ret = -EINVAL;
}
}
}
if (!waiocb->is_linear) {
if (ret == 0 && waiocb->is_read) {
QEMUIOVector *qiov = waiocb->qiov;
char *p = waiocb->buf;
int i;
for (i = 0; i < qiov->niov; ++i) {
memcpy(qiov->iov[i].iov_base, p, qiov->iov[i].iov_len);
p += qiov->iov[i].iov_len;
}
qemu_vfree(waiocb->buf);
}
}
waiocb->common.cb(waiocb->common.opaque, ret);
qemu_aio_release(waiocb);
}
| 1threat |
State Error CS0501 'MoviesController.Random()' must declare a body because it is not marked abstract, extern, or partial WebApplication1 : <p>**
I can’t find the error, I’ve already completely redone the project, but this error still gets out, what is the problem of the guys.
**</p>
<pre><code> using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class MoviesController : Controller
{
// GET: Movies/Random
public ActionResult Random();
public ActionResult ByReleaseDate(int year, int month)
{
enter code here
return Content(year + "/" + month);
}
}
</code></pre>
| 0debug |
TypeError: Cannot read property 'valid' of undefined : <p>I have the following textarea:</p>
<pre><code><textarea class="form-control" [(ngModel)]="content" name="content" required>
</textarea>
</code></pre>
<p>and the following submit button:</p>
<pre><code> <button type="submit" class="btn btn-default" [disabled]="content.valid">New comment</button>
</code></pre>
<p>As I saw in the angular 2 form guide (<a href="https://angular.io/docs/ts/latest/guide/forms.html">https://angular.io/docs/ts/latest/guide/forms.html</a>) I can use the <code>x.valid</code> in order to check if it's not empty.</p>
<p>Why do I get <code>TypeError: Cannot read property 'valid' of undefined</code> error?</p>
| 0debug |
Use recursively to query get node after root one level (details see in the photo attach)? : [Category is organized by Tree in the following: When I know (Target1),How do I find (Source3) not root (after root one level
)?][1]
[1]: https://i.stack.imgur.com/Aprio.jpg | 0debug |
static int qemu_balloon_status(MonitorCompletion cb, void *opaque)
{
if (!balloon_event_fn) {
return 0;
}
balloon_event_fn(balloon_opaque, 0, cb, opaque);
return 1;
}
| 1threat |
Differences in C++ in different platforms : I was unsure of how should I name this question. It's probably a noob question but anyway...<br>I don't really now why assigning values in `struct` in C++ does work in Linux(Ubuntu) but doesn't in Windows(I get an error compiling same program in windows)<br>It depends on compiler, yes? Or there is something else I should know?
[![It's just a simple example program.][1]][1]
[1]: http://i.stack.imgur.com/lAhrn.png | 0debug |
static void float_to_int16_stride_altivec(int16_t *dst, const float *src,
long len, int stride)
{
int i, j;
vector signed short d, s;
for (i = 0; i < len - 7; i += 8) {
d = float_to_int16_one_altivec(src + i);
for (j = 0; j < 8; j++) {
s = vec_splat(d, j);
vec_ste(s, 0, dst);
dst += stride;
}
}
}
| 1threat |
Nuget Packages are there but missing References : <p>After branching in TFS, VS2015 Update 2 has missing references to all Nuget packages. Package restore says "All packages listed in packages.config are already installed."</p>
<p>I could manually add references to all of the packages in the \packages folder but why isn't VS already checking there?</p>
| 0debug |
returning true if successful deleting the node c++ : I have an assignment where I have to find the node at the end of the linked list (the one just before the tail) and I have to return it and delete it. if its successful and its deleted then I return true so its basically a bool function. So far I dont know what I am doing wrong and this is what I wrote:
bool List::getBack(int & key)
{
Node *temp = new Node;
Node *prev = new Node;
temp = head;
if(tail=head)
{
return false;
}
else {
while (temp->next != nullptr)
{
prev = temp;
temp = temp->next;
}
tail = prev;
prev->next = nullptr;
delete temp;
return true;
}
}
Thank you very much! I hope I gave a clear question. I do not want anyone solving my question I just need help with understanding because I have been stuck for hours.
| 0debug |
HTML5 - Free video player in html5 : <p>I have videos locally in my web server and I want to embed it into a html document. I want to have a player to allow the user to stop the video, to control the sound, to continue seeing it. Do you know any video player free to achieve it?</p>
| 0debug |
How do I change a project's id in SBT 1.0? : <p>I have a bunch of SBT 0.13 project definitions that look like this:</p>
<pre><code>lazy val coreBase = crossProject.crossType(CrossType.Pure).in(file("core"))
.settings(...)
.jvmConfigure(_.copy(id = "core"))
.jsConfigure(_.copy(id = "coreJS"))
lazy val core = coreBase.jvm
lazy val coreJS = coreBase.js
</code></pre>
<p>(Mostly because I'm resentful about having to maintain Scala.js builds and don't want to have to type the <code>JVM</code> suffix every time I'm changing projects, etc.)</p>
<p>This doesn't compile in SBT 1.0 because <code>Project</code> doesn't have a <code>copy</code> method now.</p>
<p>Okay, let's check <a href="http://www.scala-sbt.org/1.0/docs/Migrating-from-sbt-013x.html" rel="noreferrer">the migration guide</a>.</p>
<blockquote>
<p>Many of the case classes are replaced with pseudo case classes generated using Contraband. Migrate <code>.copy(foo = xxx)</code> to <code>withFoo(xxx)</code>.</p>
</blockquote>
<p>Cool, let's try it.</p>
<pre><code>build.sbt:100: error: value withId is not a member of sbt.Project
.jvmConfigure(_.withId("core"))
^
</code></pre>
<p>So I <a href="https://gitter.im/sbt/sbt?at=59b5b846210ac2692015db46" rel="noreferrer">asked on Gitter</a> and got crickets.</p>
<p>The links for the 1.0 API docs actually point to something now, which is nice, but they're not very helpful in <a href="http://www.scala-sbt.org/1.0.1/api/sbt/Project.html" rel="noreferrer">this case</a>, and trying to read the SBT source gives me a headache. I'm not in a rush to update to 1.0, but I'm going to have to at some point, I guess, and maybe some helpful person will have answered this by then.</p>
| 0debug |
static void vhost_begin(MemoryListener *listener)
{
}
| 1threat |
static void test_visitor_in_native_list_uint32(TestInputVisitorData *data,
const void *unused)
{
test_native_list_integer_helper(data, unused,
USER_DEF_NATIVE_LIST_UNION_KIND_U32);
}
| 1threat |
Vue.js : How to set a unique ID for each component instance? : <p>I want to create a component with Vue.js containing a label and an input. for example :</p>
<pre><code><label for="inputId">Label text</label>
<input id="inputId" type="text" />
</code></pre>
<p>How can I set a unique ID for each component instance?</p>
<p>Thank you.</p>
| 0debug |
Does an Application Load Balancer support WebSockets? : <p>I have an Elastic Beanstalk application which was initially configured to use a Classic Load Balancer. I found that this caused errors when connecting via WebSocket. Because of this, I configured the application to use an Application Load Balancer instead, because I was told that ALBs support WebSockets. However, it seems that they do not: I get exactly the same error when attempting to connect to my ALB via WebSocket.</p>
<p>Do ALBs actually support WebSocket? The AWS documentation is contradictory on this. <a href="http://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/what-is-load-balancing.html" rel="noreferrer">This page</a> says it only supports HTTP and HTTPS. There are no guides to setting up an ALB to support WebSocket.</p>
| 0debug |
How to turn off SonarLint automatic triggering on IntelliJ IDEA : <p>Is there some way of turning-off automatic SonarLint analysis in Intellij IDEA?</p>
<p>I have some 10,000 to 20,000 lines-of-code classes (don't ask, not my fault, trying to refactor). Every time I edit even a single character in the class, the SonarLint plugin makes IDEA unusable for a few minutes.</p>
<p>It is not possible to save the "Automatically trigger analysis" checkbox in the unchecked state in Other Settings > SonarLint General Settings. Is there some other solution to my problem? I really want to use the plugin. I just can't use it in automatic mode.</p>
| 0debug |
updating multiple columns in a table with multiple conditions in mysql : Is it possible to run an update query on multiple columns with multiple conditions in MySQL?
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/dRlrv.png
For example above is the structure of a table myTable, where I want to run a query like:
`UPDATE TABLE myTable set value = 25 where id = 1 and price = 12 where pp_flag = 8`.
Just wondering if I can do this in the same query in MYSQL.
Thanks | 0debug |
Android- Load application inside a container of another appliation : [I am trying load application inside a container of another application in Android. Need sample code on how to do the process since I am new to Android. ][1]
[1]: https://i.stack.imgur.com/9Uz6b.png | 0debug |
What files are necessary for a Cordova app build from a Wordpress site? : <p>I am attempting to build a mobile app from my existing wordpress website. I am curious which files I need to include in the assets folder for Cordova? Any assistance would be greatly appreciated</p>
| 0debug |
what is the use of HOST and NONE network in docker? : <p>Trying to understand the docker networks, Docker creates the following networks automatically:</p>
<pre><code># docker network ls
NETWORK ID NAME DRIVER SCOPE
67b4afa88032 bridge bridge local
c88f997a2fa7 host host local
1df2947aad7b none null local
</code></pre>
<p>I understood that the <strong>bridge network</strong> represents the docker0 network present in all Docker installations, referring from the <a href="https://docs.docker.com/engine/userguide/networking/" rel="noreferrer">link.</a></p>
<p>Can someone help me in understanding other networks, <strong>host</strong> and <strong>none</strong>, If possible with examples. </p>
| 0debug |
HTTP Status 500 - Servlet execution threw an exception. I have tried add libraries but still I am getting an exception? : This is my output, I have tried add libraries but still I am getting an exception?
I have tried all previously asked questions in stack overflow. Could you please help me out.
[1]: http://i.stack.imgur.com/XCGFS.png | 0debug |
Javascript code : I am try to fetch a javascript code as it use for converting input decimal to manipulate the data to be binary then count the number of 1's ,The below code is running be no output found nor errors.
Javascript Code:
function demo()
{
var arra, i, rem ;
var Input =document.getElementById('demo');
arra = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var x = 1;
while(Input > 0)
{
rem = Input%2;
Input = (parseInt(Input/ 2));
if (rem > 0)
{
arra[i] = 1;
i = i +1;
}
else
{
i = i +1;
}
}
while ( x < 35 )
{
if(arra[x] == 1)
{
document.getElementById("output").innerHTML= "SOB Found";
x = x +1 ;
}
else
{
x = x +1 ;
}
}
}
Html Code:
<!doctype html>
<html>
<head>
<title>Test Phase</title>
<script src="SOB.js" type="text/javascript"></script>
</head>
<body>
<input type="text" name="value" id="Input" />
<input type="submit" value="submit" onClick="demo()" />
<p id="output"> </p>
<script src="SOB.js" type="text/javascript"></script>
</body>
</html>
| 0debug |
void block_job_resume(BlockJob *job)
{
job->paused = false;
block_job_iostatus_reset(job);
if (job->co && !job->busy) {
qemu_coroutine_enter(job->co, NULL);
}
}
| 1threat |
Safron morpho finger print sensor integration with web java application : I have a requirement to integrate Safron morpho finger print sensor with existing java web application . As of now i have only safron morpho device. Please guide me to enable and integrate with web application. | 0debug |
Hwo to stack vertically many buttons on a html table in a single row cell : I'm creating and filling up an html table dinamically on AJAX callback with Javascript.
My need would be to stack 3 buttons vertically on a single row cell.
I've tried with the standard:
var btn = document.createElement('input');
btn.type = "button";
btn.className = "btn";
btn.value = "Test1";
and then appending these buttons to the pertaining <td> cell.
Actually this makes the buttons to be created on the same row, from left to right. My need would be to have them created vertically, instead.
May I use the button group option, setting its property to vertical?
I'm not sure if the button group can be used as a <td> child.
Thanks for your support. | 0debug |
READ_PRIVILEGED_PHONE_STATE permission error : <p>I have created an app that monitors calls (incoming and outgoing) and during the time that phone is ringing , it shows details about the number.
<strong>everything is fine in incoming calls</strong> , but when user make an outgoing call app crashes with this error :</p>
<pre><code>05-14 23:14:36.376 1427-1475/? W/BroadcastQueue: Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } to ir.apptune.antispam/.CallReceiver requires android.permission.READ_PRIVILEGED_PHONE_STATE due to sender android (uid 1000)
</code></pre>
<p>here is the details about sdk version that i use :</p>
<pre><code>minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
</code></pre>
<p>permissions that i granted :</p>
<pre><code><uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.CALL_PHONE" />
</code></pre>
<p>Also i have checked in run time if permissions are granted. and it returns 0 means yes. but still same error.
also please consider the Broadcast receiver declaration in manifest:</p>
<pre><code><receiver
android:name=".CallReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</code></pre>
<p>any help is appreciated.</p>
| 0debug |
MySQL | Java -> How to get a String from a field : i've got a mysql question within java. I've got a mysql database with different tables. I would like for example to have a database called 'litebans' and a table called 'litebans_mutes'. Within that table there's a kinda-stringy thingy called reason and under that reason (let's say what's within reason) there's a string called 'This is a test'; how would i get the string 'This is a test' in java?
Thanks! | 0debug |
I am trouble with side menu and mid div : enter image description here
When i am click the Main course it's showing Main course Details.
When i am click the Soups it's not showing Soups Details it's going up.
Please help.
[enter image description here][1]
[1]: https://i.stack.imgur.com/OnMdb.jpg
| 0debug |
Returning a value from a SQLAlchemy context manager : <p>I am trying to return the value of my SELECT query from my context manager. However, nothing is returned as a response. How can I return the results of my select query from my context manager/session?</p>
<pre><code>@contextmanager
def aperio_session_scope():
"""Provide a transactional scope around a series of operations."""
session = AperioSession()
try:
yield session
session.commit()
except:
session.rollback()
raise
finally:
session.close()
</code></pre>
<p>In addition, the query class looks like this:</p>
<pre><code>class AperioSlidesAfterDate(object):
def go(self, session):
session.query(Slide).join(Image).filter(Image.scandate > '2018-08-01 00:00:00', Slide.barcodeid.isnot(None))
</code></pre>
<p>I run the query as follows:</p>
<pre><code> with aperio_session_scope() as session:
slides = AperioSlidesAfterDate().go(session)
</code></pre>
<p>All 3 of these snippets are from different files and my imports are set up properly. No compile time or runtime exceptions. It seems that the value of <code>slides</code> is always <code>None</code>. Am I missing something? I followed the examples from SQLAlchemy docs.</p>
<p>If I do something like:</p>
<pre><code>with aperio_session_scope() as session:
slides = session.query(Slide).join(Image).filter(
Image.scandate > '2018-08-01 00:00:00', Slide.barcodeid.isnot(None))
</code></pre>
<p>I get results, but I want to try an and use the session object with go as intended in the documentation. Is this a scoping issue? Or do I just need to somehow access the return value if at all possible?</p>
<p>Thanks.</p>
| 0debug |
Xcode 8, iOS 10 - "Starting WebFilter logging for process" : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> WF: === Starting WebFilter logging for process Test
2016-09-30 08:56:45.458007 Test[616:142557] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2016-09-30 08:56:45.458437 Test[616:142557] WF: _WebFilterIsActive returning: NO</code></pre>
</div>
</div>
</p>
<p>I am receiving this warning in my debugger in xcode 8, iOS-10, when I using UIWebView Delegate methods to load something. I didn't find any documentation in Apple website about this web filter Active/De-active mode. Though it's not causing any problem in my existing webView functionality even I am running some javascript function in my webView did finished method. But still curious to know more about this new feature. </p>
<p>Any suggestion about this feature will be appreciate.</p>
| 0debug |
ls -l command in Unix, cannot remember file size : I created a new file on a Unix server. But when I run the ls -l command, I get the following:
-rwxr-xr-x 1 mccorm14 student 49508 Oct 26 11:29 4th
I cannot remember if the file size is block or bytes. If its block, how do I convert it to bytes?
Thank you! | 0debug |
Draw SVG dashed line on scroll? : <p>I want to have a svg dashed line drawn on scroll and got stuck on this for 4hrs.</p>
<p>If it's just a straight line, I can easily animate it by setting stroke-dasharray on css animation, but it doesn't work on a dashed line.</p>
<p>Since there's a background image on body, I cannot use a mask trick either.</p>
<p>I just want to have a simple 45 degree diagonal dashed line (about 100px) drawn on scroll.</p>
<p>Any advice? </p>
| 0debug |
Finding nullpointerException : <p>Basically I am creating a simply game, I want circles to appear but they can not overlap each other when they are printed on the screen. The objects are created and then put into an arraylist and when ever another is created it needs to check its coordinates with all the others already in the arraylist to make sure its not the same. The method to check is called isCollidingWith and there is a setPosition method that actually sets the position. This is what I have.</p>
<p>This is how the object is created, I can't even get one to be created, once I get it working I would create more of these objects, hence the whole point of this.</p>
<pre><code> Circle circle = new Circle(rng,circles);
circles.add(circle);
</code></pre>
<p>This is the constructor for the object takes in a random number and and arraylist of circles. It starts with a while loop and sets a position for this circle it then goes into a for loop and checks if it is colliding with and of the other ones, if it is, it breaks and goes back to the top of the while loop and sets a different positions and then repeats checking if it is colliding with any of the other ones already in the arraylist.</p>
<pre><code> public Planet(Random rng, ArrayList<Circle> circles){
boolean key = true;
while(key){
this.graphic.setPosition(rng.nextFloat()*GameEngine.getWidth(),rng.nextFloat()*GameEngine.getHeight());
for(int i = 0; i<circles.size();i++){
if(this.graphic.isCollidingWith(circles.get(i).graphic)){
key = true;
break;
}
else key = false;
}
}
}
</code></pre>
<p>The problem is I keep getting a NullPointerException at the line in the constructor where it says this.graphic.setPosition. But I am guessing it has to do with the arraylist, because eclipse usually isn't that accurate with error positioning. If anyone could tell me what looks to be wrong here that would be great.</p>
| 0debug |
SVG transform rotate by 90, 180 or 270 degrees not working on circle in Safari iOS 10 : <p>I want to create a donut chart using an SVG circle element by setting <code>stroke-dasharray</code> and varying <code>stroke-dashoffset</code>. The SVG element needs to be rotated by 270 (or -90) degrees in order for the chart "bar" to start at the top. Here is the code:</p>
<p><a href="http://jsfiddle.net/q3wb6gkq/" rel="noreferrer">http://jsfiddle.net/q3wb6gkq/</a></p>
<p>The rotation angle is specified using the first number in <code>transform="rotate(270, 80, 80)"</code>.</p>
<p>The problem is: when viewed in Safari on iOS 10 this rotation is not applied. In fact, setting 90, 180 or 270 degree rotation has no effect. The same angles but negative (for example -90) are also not applied.</p>
<p>Here is a screenshot of the above fiddle in Safari on iOS 10.0.1:</p>
<p><a href="https://i.stack.imgur.com/7nzXJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7nzXJ.png" alt="iOS 10 screenshot"></a></p>
<p>And here is the same fiddle in Safari on iOS 9.3.5:</p>
<p><a href="https://i.stack.imgur.com/kh5As.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kh5As.png" alt="iOS 9 screenshot"></a></p>
<p>As a workaround, I have found that using something like 270.1 degrees solves the problem, however I would like to know why 270 is not working and if there is a better way of dealing with it.</p>
| 0debug |
Load a txt file in python : i have a simple question here. I have two numbers in a txt file and i am trying to create a method that can change two variables in my code for those two numbers in the txt file
here is my method:
def loadCoords(cordX, cordY):
i=0;
f1 = open( 'continue.txt', "r")
f2 = open( 'continue.txt', "r")
f1.readline();
while i<2:
f2.readline();
i=i+1;
#already tested>>> cord=f.readline() xD
#also tried to put another names for the cordX and cordY here inside xD
cordY=f2;
cordX=f1;
return cordX;
return cordY;
here is where i am calling the method:
if evento.type == pygame.KEYDOWN:
if evento.key == pygame.K_a:
print('GAME BEGIN')
GAME_BEGIN = True
loadCoords(cordX,cordY);
>>>> Someone could help? tks
| 0debug |
Need Assistance Understanding ls -d command in linux : <p>I'm trying to wrap my head around the 'ls -d' command.</p>
<p>I run the command 'ls -d' in any given directory and all I get is a '.'</p>
<p>I run the command 'ls -d */ and I get only the directories</p>
<p>I run the command -ls -d * and I get all files, including those that aren't directories.</p>
<p>The man page just states this:</p>
<pre><code>list directories themselves, not their contents
</code></pre>
<p>Can someone please help explain how this switch is supposed to work?</p>
| 0debug |
How do I programmatically download my bank transactions from Chase without using a third party? : <p>I'm interested in downloading my transactions from Chase without using a third party such as Mint, Quicken, Yodlee, Plaid, and so on. I don't trust third parties with handling my data, which is why I want to do it myself. </p>
| 0debug |
How to read from AsyncStorage in native code (Java, ObjectiveC/Swift) : <p>I have a background service I wrote in native (Java/ObjectiveC) that needs to access data from AsyncStorage in react native. I would like to know if there is an easy way to get this value directly from the native code instead of having to pass it manually through a bridge method.</p>
<p>Since this is a background service that runs even if the app is not running (in Android), it can not call the Javascript code when it needs this data. I could work around it (by setting it in native at the same time I set it in AsyncStorage) but it would be a lot more work.</p>
| 0debug |
Randonly Named DLL use in legitimate programming : <p>So, this is a very general sort of question. How often does one see a totally random name for a DLL in legitimate (as in, not malware) programming? Is it common practice to generate DLLs on-the-fly through CSC.exe during program installation, for example? Or should this be viewed as a good indicator of malicious activity or intent? Thanks for any insight this awesome community provides! </p>
| 0debug |
static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in saddr;
int newfd;
socklen_t saddr_len = sizeof(saddr);
NetClientState *nc;
NetSocketState *s;
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
if (saddr.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
newfd = net_socket_mcast_create(&saddr, NULL);
if (newfd < 0) {
goto err;
}
dup2(newfd, fd);
close(newfd);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
if (is_connected) {
s->dgram_dst = saddr;
}
return s;
err:
closesocket(fd);
return NULL;
}
| 1threat |
static int encode_slices(VC2EncContext *s)
{
uint8_t *buf;
int i, slice_x, slice_y, skip = 0;
int bytes_left = 0;
SliceArgs *enc_args = s->slice_args;
int bytes_top[SLICE_REDIST_TOTAL] = {0};
SliceArgs *top_loc[SLICE_REDIST_TOTAL] = {NULL};
avpriv_align_put_bits(&s->pb);
flush_put_bits(&s->pb);
buf = put_bits_ptr(&s->pb);
for (slice_y = 0; slice_y < s->num_y; slice_y++) {
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];
bytes_left += args->bytes_left;
for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {
if (args->bytes > bytes_top[i]) {
bytes_top[i] = args->bytes;
top_loc[i] = args;
break;
}
}
}
}
while (1) {
int distributed = 0;
for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {
SliceArgs *args;
int bits, bytes, diff, prev_bytes, new_idx;
if (bytes_left <= 0)
break;
if (!top_loc[i] || !top_loc[i]->quant_idx)
break;
args = top_loc[i];
prev_bytes = args->bytes;
new_idx = av_clip(args->quant_idx - 1, 0, s->q_ceil);
bits = count_hq_slice(s, args->cache, args->x, args->y, new_idx);
bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;
diff = bytes - prev_bytes;
if ((bytes_left - diff) >= 0) {
args->quant_idx = new_idx;
args->bytes = bytes;
bytes_left -= diff;
distributed++;
}
}
if (!distributed)
break;
}
for (slice_y = 0; slice_y < s->num_y; slice_y++) {
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];
init_put_bits(&args->pb, buf + skip, args->bytes);
s->q_avg = (s->q_avg + args->quant_idx)/2;
skip += args->bytes;
}
}
s->avctx->execute(s->avctx, encode_hq_slice, enc_args, NULL, s->num_x*s->num_y,
sizeof(SliceArgs));
skip_put_bytes(&s->pb, skip);
return 0;
}
| 1threat |
static av_always_inline int get_dst_color_err(PaletteUseContext *s,
uint32_t c, int *er, int *eg, int *eb,
const enum color_search_method search_method)
{
const uint8_t a = c >> 24 & 0xff;
const uint8_t r = c >> 16 & 0xff;
const uint8_t g = c >> 8 & 0xff;
const uint8_t b = c & 0xff;
const int dstx = color_get(s, c, a, r, g, b, search_method);
const uint32_t dstc = s->palette[dstx];
*er = r - (dstc >> 16 & 0xff);
*eg = g - (dstc >> 8 & 0xff);
*eb = b - (dstc & 0xff);
return dstx;
}
| 1threat |
Get primary category if more than one is selected? : <p>In Wordpress, how can I revert to the primary category?</p>
<p>I'm using the following loop, if all three are checked then it just reverts to the last term. I want to make sure it's the primary category.</p>
<pre><code><?php $term_list = wp_get_post_terms($post->ID, 'category', array("fields" => "names"));
foreach ($term_list as $term) {
$name = $term;
} ?>
</code></pre>
<p><a href="https://i.stack.imgur.com/2VcaN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2VcaN.png" alt="enter image description here"></a></p>
| 0debug |
import math
def max_Prime_Factors (n):
maxPrime = -1
while n%2 == 0:
maxPrime = 2
n >>= 1
for i in range(3,int(math.sqrt(n))+1,2):
while n % i == 0:
maxPrime = i
n = n / i
if n > 2:
maxPrime = n
return int(maxPrime) | 0debug |
A solution to SQLAlchemy temporary table pain? : <p>It seems like the biggest drawback with SQLAlchemy is that it takes several steps backwards when it comes to working with temporary tables. A very common use case, for example, is to create a temporary table that is very specific to one task, throw some data in it, then join against it.</p>
<p>For starters, declaring a temporary table is verbose, and limited. Note that in this example I had to edit it because my classes actually inherit a base class, so what I give here may be slightly incorrect.</p>
<pre><code>@as_declarative(metaclass=MetaBase)
class MyTempTable(object):
__tablename__ = "temp"
__table_args__ = {'prefixes': ['TEMPORARY']}
id = Column(Integer(), primary_key=True)
person_id = Column(BigInteger())
a_string = Column(String(100))
</code></pre>
<p>Creating it is unintuitive:</p>
<pre><code>MyTempTable.__table__.create(session.bind)
</code></pre>
<p>I also have to remember to explictly drop it unless I do something creative to get it to render with ON COMMIT DROP:</p>
<pre><code>MyTempTable.__table__.drop(session.bind)
</code></pre>
<p>Also, what I just gave doesn't even work unless the temporary table is done "top level". I still haven't fully figured this out (for lack of wanting to spend time investigating why it doesn't work), but basically I tried creating a temp table in this manner inside of a nested transaction using session.begin_nested() and you end up with an error saying the relation does not exist. However, I have several cases where I create a temporary table inside of a nested transaction for unit testing purposes and they work just fine. Checking the echo output, it appears the difference is that one renders before the BEGIN statement, while the other renders after it. This is using Postgresql.</p>
<p>What does work inside of a nested transaction, and quite frankly saves you a bunch of time, is to just type out the damned sql and execute it using session.execute. </p>
<pre><code> session.execute(text(
"CREATE TEMPORARY TABLE temp ("
" id SERIAL,"
" person_id BIGINT,"
" a_string TEXT"
") ON COMMIT DROP;"
))
</code></pre>
<p>Of course, if you do this, you still need a corresponding table model to make use of ORM functionality, or have to stick to using raw sql queries, which defeats the purpose of SQLAlchemy in the first place.</p>
<p>I'm wondering if maybe I'm missing something here or if someone has come up with a solution that is a bit more elegant.</p>
| 0debug |
Xcode 8 / Swift 3: "Expression of type UIViewController? is unused" warning : <p>I've got the following function which compiled cleanly previously but generates a warning with Xcode 8.</p>
<pre><code>func exitViewController()
{
navigationController?.popViewController(animated: true)
}
</code></pre>
<blockquote>
<p>"Expression of type "UIViewController?" is unused".</p>
</blockquote>
<p>Why is it saying this and is there a way to remove it?</p>
<p>The code executes as expected.</p>
| 0debug |
Turn off a screenshot on the phone by javascript : <p>How can I prevent a screenshot from the phone on my site by javascript or jquery</p>
| 0debug |
How to search string values in GraphQL : <p>How do you query using GraphQL in a manor similar to SQL's <code>like</code> operator?</p>
<p>Example: What users have a first name starting with <code>jason</code>?</p>
<p><code>select * from users where first_name like "jason%"</code></p>
| 0debug |
How to use AuthorizationServerSecurityConfigurer? : <p>I am looking at a Spring boot project which has this code:</p>
<pre><code>public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
oauthServer
.tokenKeyAccess("permitAll()")
.checkTokenAccess("isAuthenticated()");
}
</code></pre>
<p>Unfortunately, I am not able to find any resources anywhere (i.e. Google, Spring docs, Spring oauth docs) that explains to me how to actually use <code>AuthorizationServerSecurityConfigurer</code>. Moreover, I do not understand exactly what <code>tokenKeyAccess("permitAll()")</code> or <code>checkTokenAccess("isAuthenticated()")</code> do.</p>
<p>Other than helping me understand what those two functions do, please help me learn where to look for these types of information in the future.</p>
| 0debug |
Date() javascript string inserted in DB showed in a pretty way : <p>Is there any way to print a date string stored in db with this format:
2016-09-13T18:18:08.518Z
into a pretty way like this: 13 September 2016
thanks!!</p>
| 0debug |
How to check if time in millis is yesterday : How can i check if time in millis is yesterday? For example my time in millis is 23:59 so actually is yesterday but 00:00 is now today. Sorry for my eng. | 0debug |
Save as option while uploading file using asp.net MVC EF : I'm not sure whether it is possible or not to do. I'm uploading the file to a server in my MVC web application. Currently, it is storing in my project folder.
Here is my code which is working fine.
public ActionResult Upload(HttpPostedFileBase file)
{
try
{
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Documents"), fileName);
file.SaveAs(path);
}
TempData["Message"] = "Upload successful";
return RedirectToAction("Index");
}
catch
{
ViewBag.Message = "Upload failed";
return RedirectToAction("Uploads");
}
}
[![enter image description here][1]][1]
Now I need to store the file on a File server with providing an option to the user to create a directory and store the file where they want. For that, I need to provide SAVE AS option.
How can I store on file server in the network and how to provide Save As option while uploading?
[1]: https://i.stack.imgur.com/XSnmr.png | 0debug |
static int dvvideo_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
DVVideoContext *s = avctx->priv_data;
const uint8_t *vsc_pack;
int apt, is16_9, ret;
const AVDVProfile *sys;
sys = av_dv_frame_profile(s->sys, buf, buf_size);
if (!sys || buf_size < sys->frame_size) {
av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");
return -1;
}
if (sys != s->sys) {
ret = ff_dv_init_dynamic_tables(s, sys);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing the work tables.\n");
return ret;
}
s->sys = sys;
}
s->frame = data;
s->frame->key_frame = 1;
s->frame->pict_type = AV_PICTURE_TYPE_I;
avctx->pix_fmt = s->sys->pix_fmt;
avctx->framerate = av_inv_q(s->sys->time_base);
ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height);
if (ret < 0)
return ret;
vsc_pack = buf + 80 * 5 + 48 + 5;
if (*vsc_pack == dv_video_control) {
apt = buf[4] & 0x07;
is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
(!apt && (vsc_pack[2] & 0x07) == 0x07)));
ff_set_sar(avctx, s->sys->sar[is16_9]);
}
if (ff_get_buffer(avctx, s->frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->frame->interlaced_frame = 1;
s->frame->top_field_first = 0;
s->buf = buf;
avctx->execute(avctx, dv_decode_video_segment, s->work_chunks, NULL,
dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
emms_c();
*got_frame = 1;
return s->sys->frame_size;
}
| 1threat |
which version of java supported by eclipse helios? : im new to eclipse and java.whenever i run the java program in eclipse there is a major.minor 52 exception.i want to know which version of java is supported by eclipse helios. My computer is windows 7 32 bit os. so i cant download any other version of eclipse. plzz help me with a favourable answer
| 0debug |
Execution failed for task ':app:mergeDexDebug'. Firestore | Flutter : <p>Trying to use Firestore in my project. My project is a brand new one, but having problems running the app on my device without getting an error:
<strong>Execution failed for task ':app:mergeDexDebug'.</strong></p>
<p>My app is using AndroidX. I've added my google-services.json file, followed the steps etc.</p>
<p>Yaml file:</p>
<pre><code>dependencies:
cloud_firestore: ^0.13.3
</code></pre>
<p>android/build.gradle:</p>
<pre><code>com.google.gms:google-services:4.3.3
</code></pre>
<p>Full error:</p>
<blockquote>
<p>FAILURE: Build failed with an exception.</p>
<p>What went wrong:
Execution failed for task ':app:mergeDexDebug'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at <a href="https://developer.android.com/tools/building/multidex.html" rel="noreferrer">https://developer.android.com/tools/building/multidex.html</a></p>
</blockquote>
| 0debug |
Arry index increment : I have this array in php code. I want to have that whenever page is being called it should print value of first array index and when next time second value of array index and so on... what modification I could do? for now it´s printing everything when being called singel time.
<html>
<?php
$addresses = array('ifcbxespra', 'ifcheqjbmea', 'ifcqiknsa', 'ifcqirtjla', 'ifcwqsrlmn', 'ifclmkmzhz','ifcwdujhgc','ifcihddngh','icffhzudcd','ifchnsqzgs','ifcgssqrhg');
foreach ($addresses as &$value) {
echo $value ;
}
?>
</html> | 0debug |
static void terrier_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
spitz_common_init(ram_size, vga_ram_size, ds, kernel_filename,
kernel_cmdline, initrd_filename, terrier, 0x33f);
}
| 1threat |
How to make a character with real face unreal engine 4 : <p>i am a beginner in game development.i used unreal engine4 for making a sample game. i successfully create a running game with the help of some tutorials. </p>
<p>next i need to model a character like me.also i interested to create an environment like my home. i have no idea about this. </p>
<ol>
<li>is it possible to create real characters using Unreal engine 4 ?</li>
<li>How to create a new material(Real materials eg: Hose wall,floor) ?</li>
<li>How to create a characters like Gta game characters using Unreal engine?</li>
</ol>
| 0debug |
Cant find clear example for futter_share_me packgae : <p>I cant find example for flutter_share_me package , becuse I dont understand what is url and msg in package , can you please give me an example ?</p>
| 0debug |
When should i pause between shell commands in linux? : So I'm running a script of multiple commands using Linux and i want to know if I should use the sleep/pause script or not?
What's the disadvantage of not using sleep/pause? And will it affect my script a lot ?
Thanks in advance. | 0debug |
Swift 3 : How to get path of file saved in Documents folder : <pre><code>path = Bundle.main.path(forResource: "Owl.jpg", ofType: "jpg")
</code></pre>
<p>returns nil, however, using <code>NSHomeDirectory()</code> I'm able to verify that is under <code>Documents/</code> folder. </p>
| 0debug |
There is an error in my app. Hlp me pls : I'm making an app that will show multiple location on google map and ive read it through csv file. I have an error at OnCreate and displarArrayList method and i need help pls. I'm a newbie in java and android
This is the error:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
at com.w2s.where2shop.ShowAllMap$CSVFile.displayArrayList(ShowAllMap.java:267)
at com.w2s.where2shop.ShowAllMap.onCreate(ShowAllMap.java:65)
at android.app.Activity.performCreate(Activity.java:5975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5264)
at java.lang.reflect.Method.invoke(Native Method)
This is onCreate
private InputStream inputStream;
private CSVFile csvFile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_all_map);
setUpMapIfNeeded();
inputStream = getResources().openRawResource(R.raw.allmap);
csvFile = new CSVFile(inputStream);
csvFile.read();
try {
csvFile.displayArrayList();
} catch (IOException e) {
e.printStackTrace();
}
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
// Create the LocationRequest object
mLocationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_LOW_POWER)
.setNumUpdates(1);
}
And this is where I read my csv file and inside the class CsvFile I got displayarrayItem method.
public class CSVFile {
InputStream inputStream;
ArrayList<String[]> addressList;
public CSVFile(InputStream is) {
this.inputStream = is;
}
public ArrayList<String[]> read() {
ArrayList<String[]> addressList = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
try {
String line;
while ((line = reader.readLine()) != null) {
String[] row = line.split(",");
addressList.add(row);
}
} catch (IOException e) {
Log.e("Main", e.getMessage());
} finally {
try {
inputStream.close();
} catch (IOException e) {
Log.e("Main", e.getMessage());
}
}
return addressList;
}
public ArrayList<String[]> displayArrayList() throws IOException {
for (int x = 0; x > this.addressList.size(); x++) {
Geocoder gc = new Geocoder(ShowAllMap.this);
List<Address> list = gc.getFromLocationName(addressList.get(x).toString(), 1);
if (list.size() > 0) {
Address add = list.get(0);
double lat = add.getLatitude();
double lng = add.getLongitude();
LatLng latLng = new LatLng(lat, lng);
MarkerOptions options = new MarkerOptions()
.position(latLng);
mMap.animateCamera(CameraUpdateFactory.zoomIn());
mMap.addMarker(options);
}
}
return addressList;
}
}
Hlp Pls.... | 0debug |
static int encode_mode(CinepakEncContext *s, CinepakMode mode, int h, int v1_size, int v4_size, int v4, AVPicture *scratch_pict, strip_info *info, unsigned char *buf)
{
int x, y, z, flags, bits, temp_size, header_ofs, ret = 0, mb_count = s->w * h / MB_AREA;
int needs_extra_bit, should_write_temp;
unsigned char temp[64];
mb_info *mb;
AVPicture sub_scratch;
if(v1_size)
ret += encode_codebook(s, info->v1_codebook, v1_size, 0x22, 0x26, buf + ret);
if(v4_size)
ret += encode_codebook(s, info->v4_codebook, v4_size, 0x20, 0x24, buf + ret);
for(z = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, z++) {
mb = &s->mb[z];
if(mode == MODE_MC && mb->best_encoding == ENC_SKIP)
continue;
get_sub_picture(s, x, y, scratch_pict, &sub_scratch);
if(mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1)
decode_v1_vector(s, &sub_scratch, mb, info);
else if(mode != MODE_V1_ONLY && mb->best_encoding == ENC_V4)
decode_v4_vector(s, &sub_scratch, mb->v4_vector[v4], info);
}
}
switch(mode) {
case MODE_V1_ONLY:
ret += write_chunk_header(buf + ret, 0x32, mb_count);
for(x = 0; x < mb_count; x++)
buf[ret++] = s->mb[x].v1_vector;
break;
case MODE_V1_V4:
header_ofs = ret;
ret += CHUNK_HEADER_SIZE;
for(x = 0; x < mb_count; x += 32) {
flags = 0;
for(y = x; y < FFMIN(x+32, mb_count); y++)
if(s->mb[y].best_encoding == ENC_V4)
flags |= 1 << (31 - y + x);
AV_WB32(&buf[ret], flags);
ret += 4;
for(y = x; y < FFMIN(x+32, mb_count); y++) {
mb = &s->mb[y];
if(mb->best_encoding == ENC_V1)
buf[ret++] = mb->v1_vector;
else
for(z = 0; z < 4; z++)
buf[ret++] = mb->v4_vector[v4][z];
}
}
write_chunk_header(buf + header_ofs, 0x30, ret - header_ofs - CHUNK_HEADER_SIZE);
break;
case MODE_MC:
header_ofs = ret;
ret += CHUNK_HEADER_SIZE;
flags = bits = temp_size = 0;
for(x = 0; x < mb_count; x++) {
mb = &s->mb[x];
flags |= (mb->best_encoding != ENC_SKIP) << (31 - bits++);
needs_extra_bit = 0;
should_write_temp = 0;
if(mb->best_encoding != ENC_SKIP) {
if(bits < 32)
flags |= (mb->best_encoding == ENC_V4) << (31 - bits++);
else
needs_extra_bit = 1;
}
if(bits == 32) {
AV_WB32(&buf[ret], flags);
ret += 4;
flags = bits = 0;
if(mb->best_encoding == ENC_SKIP || needs_extra_bit) {
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
temp_size = 0;
} else
should_write_temp = 1;
}
if(needs_extra_bit) {
flags = (mb->best_encoding == ENC_V4) << 31;
bits = 1;
}
if(mb->best_encoding == ENC_V1)
temp[temp_size++] = mb->v1_vector;
else if(mb->best_encoding == ENC_V4)
for(z = 0; z < 4; z++)
temp[temp_size++] = mb->v4_vector[v4][z];
if(should_write_temp) {
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
temp_size = 0;
}
}
if(bits > 0) {
AV_WB32(&buf[ret], flags);
ret += 4;
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
}
write_chunk_header(buf + header_ofs, 0x31, ret - header_ofs - CHUNK_HEADER_SIZE);
break;
}
return ret;
}
| 1threat |
Describe a sorted function by a loop : <p>I have a task. This is a learning task. I successfully solved it. But I have a problem. The problem is that I need to sort the values in the list in descending order without using functions and methods. This needs to be done in a loop (without using sorted(), as I did).</p>
<p>Guys, I honestly looked for a solution to this problem and tried to come up with this solution myself. But I didn’t succeed. Help me please.</p>
<pre><code>import random
spisok = []
for i in range(0,5):
spisok.append(random.randint(1,25))
print('The following numbers are generated: ')
print(spisok)
sorted_nums = sorted(spisok, reverse=True)
i = 1
last_num = sorted_nums[0]
print('{i} maximum: {maxim}'.format(i=i, maxim=last_num))
for j in range(1, len(sorted_nums)):
num = sorted_nums[j]
if num != last_num:
i += 1
print('{i} maximum: {maxim}'.format(i=i, maxim=num))
last_num = num
</code></pre>
| 0debug |
static void colo_old_packet_check_one_conn(void *opaque,
void *user_data)
{
Connection *conn = opaque;
GList *result = NULL;
int64_t check_time = REGULAR_PACKET_CHECK_MS;
result = g_queue_find_custom(&conn->primary_list,
&check_time,
(GCompareFunc)colo_old_packet_check_one);
if (result) {
}
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.