problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Measure full page size in Chrome DevTools : <p>I've been googling for some time but haven't found any clear solution for this.</p>
<p>I want to measure full webpage weight / size (all doucment + scripts + fonts + styles etc.). I know the network tab in the devtools has size/content - but I want to have it summed (and not sum it every time).</p>
<p>I've been looking for chrome.devtools.* API but haven't found anything straight-forward. </p>
<p>Do you have some ideas how to achieve that?</p>
| 0debug |
Data Structures Implementation : <p>Data Structures like arrays, linked list, queue, stack, binary tree etc exist. A language like Java or C++ has already implemented them for the most part and API's exist which can be used in any program or application. Based on need, a specific data structure can be selected. </p>
<p>My question is what is the need to know the implementation details. Is it not enough to just know for example, arrays can be used instead of linked list if search is a recurring task of the program. </p>
<p>I am new and might be naive in even asking such a question. Even interviews focus so much on how they are implemented. Please help me understand. </p>
<p>Thank you!</p>
| 0debug |
static int mv_read_header(AVFormatContext *avctx)
{
MvContext *mv = avctx->priv_data;
AVIOContext *pb = avctx->pb;
AVStream *ast = NULL, *vst = NULL;
int version, i;
avio_skip(pb, 4);
version = avio_rb16(pb);
if (version == 2) {
uint64_t timestamp;
int v;
avio_skip(pb, 22);
ast = avformat_new_stream(avctx, NULL);
if (!ast)
return AVERROR(ENOMEM);
vst = avformat_new_stream(avctx, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->time_base = (AVRational){1, 15};
vst->nb_frames = avio_rb32(pb);
v = avio_rb32(pb);
switch (v) {
case 1:
vst->codec->codec_id = AV_CODEC_ID_MVC1;
break;
case 2:
vst->codec->pix_fmt = AV_PIX_FMT_ARGB;
vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
break;
default:
av_log_ask_for_sample(avctx, "unknown video compression %i\n", v);
break;
}
vst->codec->codec_tag = 0;
vst->codec->width = avio_rb32(pb);
vst->codec->height = avio_rb32(pb);
avio_skip(pb, 12);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->nb_frames = vst->nb_frames;
ast->codec->sample_rate = avio_rb32(pb);
avpriv_set_pts_info(ast, 33, 1, ast->codec->sample_rate);
ast->codec->channels = avio_rb32(pb);
ast->codec->channel_layout = (ast->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
v = avio_rb32(pb);
if (v == AUDIO_FORMAT_SIGNED) {
ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
} else {
av_log_ask_for_sample(avctx, "unknown audio compression (format %i)\n", v);
}
avio_skip(pb, 12);
var_read_metadata(avctx, "title", 0x80);
var_read_metadata(avctx, "comment", 0x100);
avio_skip(pb, 0x80);
timestamp = 0;
for (i = 0; i < vst->nb_frames; i++) {
uint32_t pos = avio_rb32(pb);
uint32_t asize = avio_rb32(pb);
uint32_t vsize = avio_rb32(pb);
avio_skip(pb, 8);
av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME);
av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME);
timestamp += asize / (ast->codec->channels * 2);
}
} else if (!version && avio_rb16(pb) == 3) {
avio_skip(pb, 4);
read_table(avctx, NULL, parse_global_var);
if (mv->nb_audio_tracks > 1) {
av_log_ask_for_sample(avctx, "multiple audio streams\n");
return AVERROR_PATCHWELCOME;
} else if (mv->nb_audio_tracks) {
ast = avformat_new_stream(avctx, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
read_table(avctx, ast, parse_audio_var);
if (ast->codec->codec_tag == 100 && ast->codec->codec_id == AUDIO_FORMAT_SIGNED && ast->codec->bits_per_coded_sample == 16) {
ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
} else {
av_log_ask_for_sample(avctx, "unknown audio compression %i (format %i, width %i)\n",
ast->codec->codec_tag, ast->codec->codec_id, ast->codec->bits_per_coded_sample);
ast->codec->codec_id = AV_CODEC_ID_NONE;
}
ast->codec->codec_tag = 0;
}
if (mv->nb_video_tracks > 1) {
av_log_ask_for_sample(avctx, "multiple video streams\n");
return AVERROR_PATCHWELCOME;
} else if (mv->nb_video_tracks) {
vst = avformat_new_stream(avctx, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
read_table(avctx, vst, parse_video_var);
}
if (mv->nb_audio_tracks)
read_index(pb, ast);
if (mv->nb_video_tracks)
read_index(pb, vst);
} else {
av_log_ask_for_sample(avctx, "unknown version %i\n", version);
return AVERROR_PATCHWELCOME;
}
return 0;
}
| 1threat |
Correct async function export in node.js : <p>I had my custom module with following code:</p>
<pre><code>module.exports.PrintNearestStore = async function PrintNearestStore(session, lat, lon) {
...
}
</code></pre>
<p>It worked fine if call the function outside my module, however if I called inside I got error while running:</p>
<blockquote>
<p>(node:24372) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): ReferenceError: PrintNearestStore is not
defined</p>
</blockquote>
<p>When I changed syntax to:</p>
<pre><code>module.exports.PrintNearestStore = PrintNearestStore;
var PrintNearestStore = async function(session, lat, lon) {
}
</code></pre>
<p>It started to work fine inside module, but fails outside the module - I got error:</p>
<blockquote>
<p>(node:32422) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): TypeError: mymodule.PrintNearestStore is
not a function</p>
</blockquote>
<p>So I've changed code to:</p>
<pre><code>module.exports.PrintNearestStore = async function(session, lat, lon) {
await PrintNearestStore(session, lat, lon);
}
var PrintNearestStore = async function(session, lat, lon) {
...
}
</code></pre>
<p>And now it works in all cases: inside and outside. However want to understand semantics and if there is more beautiful and shorter way to write it? How to correctly define and use <strong>async</strong> function both: inside and outside (exports) module?</p>
| 0debug |
static int arm_gic_common_init(SysBusDevice *dev)
{
GICState *s = FROM_SYSBUS(GICState, dev);
int num_irq = s->num_irq;
if (s->num_cpu > NCPU) {
hw_error("requested %u CPUs exceeds GIC maximum %d\n",
s->num_cpu, NCPU);
}
s->num_irq += GIC_BASE_IRQ;
if (s->num_irq > GIC_MAXIRQ) {
hw_error("requested %u interrupt lines exceeds GIC maximum %d\n",
num_irq, GIC_MAXIRQ);
}
if (s->num_irq < 32 || (s->num_irq % 32)) {
hw_error("%d interrupt lines unsupported: not divisible by 32\n",
num_irq);
}
register_savevm(NULL, "arm_gic", -1, 3, gic_save, gic_load, s);
return 0;
}
| 1threat |
Dynamic Tree in C# : <p>Could anybody help me doing this in c# and allow the user to add or remove nodes or is there any library.
Thanks</p>
<p><a href="https://i.stack.imgur.com/L9tEp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L9tEp.jpg" alt="enter image description here"></a></p>
| 0debug |
Show Dialog from ViewModel in Android MVVM Architecture : <p>About MVVM with new architecture components, I've a question, how should I implement if my app needs to display for example a Dialog with 3 options from some action that happened in my VM? Who is responsible for sending to Activity/Fragment the command to show dialog?</p>
| 0debug |
Enable Windows 10 Developer Mode programmatically : <p>I know you can <a href="http://www.hanselman.com/blog/Windows10DeveloperMode.aspx" rel="noreferrer">enable Windows 10 Developer mode interactively</a> by going to Settings | For developers, selecting 'Developer mode' and then rebooting.</p>
<p>Is there a way to enable this programmatically? (eg. via PowerShell or similar so that I can include it as a step in a <a href="http://boxstarter.org/" rel="noreferrer">Boxstarter</a> script when refreshing my developer workstation)</p>
| 0debug |
static int mjpegb_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MJpegDecodeContext *s = avctx->priv_data;
const uint8_t *buf_end, *buf_ptr;
AVFrame *picture = data;
GetBitContext hgb;
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size, sod_offs;
buf_ptr = buf;
buf_end = buf + buf_size;
read_header:
s->restart_interval = 0;
s->restart_count = 0;
s->mjpb_skiptosod = 0;
if (buf_end - buf_ptr >= 1 << 28)
return AVERROR_INVALIDDATA;
init_get_bits(&hgb, buf_ptr, (buf_end - buf_ptr)*8);
skip_bits(&hgb, 32);
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
{
av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
return AVERROR_INVALIDDATA;
}
field_size = get_bits_long(&hgb, 32);
av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size);
skip_bits(&hgb, 32);
second_field_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "second_field_offs is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs);
dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs);
if (dqt_offs)
{
init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8);
s->start_code = DQT;
if (ff_mjpeg_decode_dqt(s) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs);
if (dht_offs)
{
init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8);
s->start_code = DHT;
ff_mjpeg_decode_dht(s);
}
sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs);
if (sof_offs)
{
init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8);
s->start_code = SOF0;
if (ff_mjpeg_decode_sof(s) < 0)
return -1;
}
sos_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sos is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs);
sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
if (sos_offs)
{
init_get_bits(&s->gb, buf_ptr + sos_offs,
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
s->start_code = SOS;
if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (s->interlaced) {
s->bottom_field ^= 1;
if (s->bottom_field != s->interlace_polarity && second_field_offs)
{
buf_ptr = buf + second_field_offs;
goto read_header;
}
}
*picture= *s->picture_ptr;
*data_size = sizeof(AVFrame);
if(!s->lossless){
picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]);
picture->qstride= 0;
picture->qscale_table= s->qscale_table;
memset(picture->qscale_table, picture->quality, (s->width+15)/16);
if(avctx->debug & FF_DEBUG_QP)
av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
picture->quality*= FF_QP2LAMBDA;
}
return buf_size;
} | 1threat |
Error in program-censor(codecademy)Practice makes perfect : <p>I wanted to include spaces too while splitting the text, for that i looked up on google used import re</p>
<pre><code>import re
def censor(text,word) :
text1=re.split(r"(\s+)",text)
#print text1
sum=""
for i in range(0,len(text1)) :
if text1[i]==word :
for j in range(0,len(word)) :
sum=sum+"*"
else :
sum=sum+text[i]
return sum
</code></pre>
<p>The error I am getting is </p>
<p><a href="https://i.stack.imgur.com/OTIvu.png" rel="nofollow noreferrer">image displaying error and code</a></p>
<p>If I include an another for loop to replace every 'e' with a whitespace , it doesn't work.</p>
| 0debug |
static int window(venc_context_t * venc, signed short * audio, int samples) {
int i, j, channel;
const float * win = venc->win[0];
int window_len = 1 << (venc->blocksize[0] - 1);
float n = (float)(1 << venc->blocksize[0]) / 4.;
if (!venc->have_saved && !samples) return 0;
if (venc->have_saved) {
for (channel = 0; channel < venc->channels; channel++) {
memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len);
}
} else {
for (channel = 0; channel < venc->channels; channel++) {
memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len);
}
}
if (samples) {
for (channel = 0; channel < venc->channels; channel++) {
float * offset = venc->samples + channel*window_len*2 + window_len;
j = channel;
for (i = 0; i < samples; i++, j += venc->channels)
offset[i] = audio[j] / 32768. * win[window_len - i] / n;
}
} else {
for (channel = 0; channel < venc->channels; channel++) {
memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len);
}
}
for (channel = 0; channel < venc->channels; channel++) {
ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor);
}
if (samples) {
for (channel = 0; channel < venc->channels; channel++) {
float * offset = venc->saved + channel*window_len;
j = channel;
for (i = 0; i < samples; i++, j += venc->channels)
offset[i] = audio[j] / 32768. * win[i] / n;
}
venc->have_saved = 1;
} else {
venc->have_saved = 0;
}
return 1;
}
| 1threat |
SQL BETWEEN - SELECT count only for the latest range found : I have this select statement
> SELECT id, liked, markers, search_body, remote_bare_jid, direction
> FROM mam_message where user_id='20' AND remote_bare_jid =
> '5a95c47078f92c6337019521' ORDER BY id DESC;
that returns the following
[![enter image description here][1]][1]
I want to use BETWEEN so that I can retrieve the count of the latest range
> direction 'I' and 'I'
[![enter image description here][2]][2]
Even when the range is not on top/direction 'I' is not lastest. Meaning if the SELECT result is:
[![enter image description here][3]][3]
I am still able to get only the latest range of direction 'I'
[![enter image description here][4]][4]
[1]: https://i.stack.imgur.com/2k2V7.png
[2]: https://i.stack.imgur.com/y313u.png
[3]: https://i.stack.imgur.com/okWLU.png
[4]: https://i.stack.imgur.com/70I7J.png | 0debug |
Simple moving averages with formula : <p>I have to calculate Simple Moving Averages on some data with this formula in R:</p>
<p><a href="https://i.stack.imgur.com/dHXCT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dHXCT.png" alt="formula"></a></p>
<p>Does anybody know how to do that?</p>
| 0debug |
Create php variables from a single input : <p>I have this input:</p>
<pre><code><input name="an_input" id="an_input">
</code></pre>
<p>An user write in the input field some words separated by comma.</p>
<p>Let's say he introduces milk, coffee, tea.</p>
<p>I want to create a php variable for each word:</p>
<pre><code>$milk = "milk";
$coffe = "coffe";
$tea = "tea";
</code></pre>
| 0debug |
Add metadata comment to Numpy ndarray : <p>I have a Numpy ndarray of three large arrays and I'd just like to store the path to the file that generated the data in there somewhere. Some toy data:</p>
<pre><code>A = array([[ 6.52479351e-01, 6.54686928e-01, 6.56884432e-01, ...,
2.55901861e+00, 2.56199503e+00, 2.56498647e+00],
[ nan, nan, 9.37914686e-17, ...,
1.01366425e-16, 3.20371075e-16, -6.33655223e-17],
[ nan, nan, 8.52057308e-17, ...,
4.26943463e-16, 1.51422386e-16, 1.55097437e-16]],
dtype=float32)
</code></pre>
<p>I can't just append it as an array to the ndarray because it needs to be the same length as the other three. </p>
<p>I could just append <code>np.zeros(len(A[0]))</code> and make the first value the string so that I can retrieve it with A[-1][0] but that seems ridiculous.</p>
<p>Is there some metadata key I can use to store a string like <code>/Documents/Data/foobar.txt'</code> so I can retrieve it with something like <code>A.metadata.comment</code>?</p>
<p>Thanks!</p>
| 0debug |
Is this an adapter design pattern correctly implemented? If not what am i missing? : I made an effort to create an adapter design pattern.
A simple interface using which users can connect to both old and modern media player.
The modern media player plays `mp4` format, whereas the old plays only `wav` format.
Using the class mediaPlayerInterface users can play both media types.
If you feel this is not an adapter design pattern, please comment what is missing.
#include <iostream>
#include <string>
using namespace std;
class MediaPlayer
{
public:
virtual void playSong()=0;
};
class ModernMediaPlayer : public MediaPlayer
{
public:
void playSong( )
{
cout << "Playing from modern media player" << endl;
}
};
class oldMediaPlayer: public MediaPlayer
{
public:
void playSong( )
{
cout << "Playing from old media player" << endl;
}
};
class mediaPlayerInterface
{
private:
string fileType;
public:
mediaPlayerInterface(string fType)
{
fileType=fType;
}
MediaPlayer* getMediaPlayer( )
{
if (fileType == "mp4")
{
return new ModernMediaPlayer;
}
else if (fileType == "wav")
{
return new oldMediaPlayer;
}
}
};
int main()
{
mediaPlayerInterface *mIface = new mediaPlayerInterface("mp4");
MediaPlayer *mplayer = mIface->getMediaPlayer();
mplayer->playSong();
mIface = new mediaPlayerInterface("wav");
mplayer = mIface->getMediaPlayer();
mplayer->playSong();
}
Output:
Playing from modern media player
Playing from old media player
| 0debug |
I want to parse part of my json data into table.Json is given below,I only want to get "Data"=[ ] part in my table : in this json, I want to parse only Data:[] part
{
"head": {
"StatusValue": 200,
"StatusText": "Success"
},
"body": {
"Data": [
{
"payer_type_id": 1,
"payer_type": "Self Pay"
},
{
"payer_type_id": 2,
"payer_type": "Corporate"
},
{
"payer_type_id": 6,
"payer_type": "Insurance"
}
],
"RecordCount": 3,
"TotalRecords": null
}
} | 0debug |
void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
if (lpc->pm.acpi_memory_hotplug.is_enabled &&
object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
acpi_memory_plug_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug,
dev, errp);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
if (lpc->pm.cpu_hotplug_legacy) {
legacy_acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.gpe_cpu, dev, errp);
} else {
acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.cpuhp_state, dev, errp);
}
} else {
error_setg(errp, "acpi: device plug request for not supported device"
" type: %s", object_get_typename(OBJECT(dev)));
}
}
| 1threat |
Swift and Objective-c framework exposes its internals : <p>I’m trying to integrate Swift into an existing objective-c framework that has public, private and project files. In order for swift to access the project files, I added a modulemap that defines a new module (e.g <em>MyFramework_Internal</em>) by including all the project headers as explained here: <a href="http://nsomar.com/project-and-private-headers-in-a-swift-and-objective-c-framework/" rel="noreferrer">http://nsomar.com/project-and-private-headers-in-a-swift-and-objective-c-framework/</a></p>
<p>That setup is sort of working but one thing I was surprised to see is that now a client can access the internal classes by importing MyFramework_Internal (<em>@import MyFramework_Internal</em>). Is there a way to hide the module since it's only needed by the framework itself?
The modulemap looks like this now:</p>
<pre><code>module MyFramework_Internal {
header "Folder1/Baz.h"
header "Folder1/Folder2/Bar.h"
export *
}
</code></pre>
| 0debug |
Aws cognito linkedin : <p>I'm trying to add LinkedIn login to my react app that using Amazon Cognito, I did everything like explained <a href="https://aws.amazon.com/premiumsupport/knowledge-center/cognito-linkedin-auth0-social-idp/" rel="noreferrer">here</a> and yes it works <strong>but</strong> I'm not using Amazon Cognito hosted UI and I don't want my user to get redirected to Auth0 site to login with LinkedIn...</p>
<p>Is there any way to implement LinkedIn Cognito login\signup without getting redirected to Cognito\Auth0?</p>
<p>Or maybe there is already a better way to implement this?</p>
| 0debug |
C programmering - For loops : First of all, I am not very good at programming, and sorry for my bad english. I am having trouble understanding this following C-program. I can see the program consists of a for-loop, but why not use a do- or a while loop? Sorry if this is a stupid question. Thanks for your help.
void opgave_1 (loebsdata2017 *alle_loebsdata2017 ) {
int i = 0;
for (i = 0; i < MAX_RYTTERE; i++) {
if(alle_loebsdata2017[i].rytteralder < 23 && strcmp(alle_loebsdata2017[i].nationalitet, "BEL") == 0)
{
printf("%s %s %d %s \n", alle_loebsdata2017[i].rytternavn, alle_loebsdata2017[i].rytterhold, alle_loebsdata2017[i].rytteralder, alle_loebsdata2017[i].nationalitet);
}
}
} | 0debug |
static void stellaris_enet_receive(void *opaque, const uint8_t *buf, size_t size)
{
stellaris_enet_state *s = (stellaris_enet_state *)opaque;
int n;
uint8_t *p;
uint32_t crc;
if ((s->rctl & SE_RCTL_RXEN) == 0)
return;
if (s->np >= 31) {
DPRINTF("Packet dropped\n");
return;
}
DPRINTF("Received packet len=%d\n", size);
n = s->next_packet + s->np;
if (n >= 31)
n -= 31;
s->np++;
s->rx[n].len = size + 6;
p = s->rx[n].data;
*(p++) = (size + 6);
*(p++) = (size + 6) >> 8;
memcpy (p, buf, size);
p += size;
crc = crc32(~0, buf, size);
*(p++) = crc;
*(p++) = crc >> 8;
*(p++) = crc >> 16;
*(p++) = crc >> 24;
if ((size & 3) != 2) {
memset(p, 0, (6 - size) & 3);
}
s->ris |= SE_INT_RX;
stellaris_enet_update(s);
}
| 1threat |
Background and foreground bash/zsh jobs without adding newlines in "continued/suspended" messages : <p>I have a process that goes something like this:</p>
<ul>
<li>Run a command that generates a bunch of results in a bunch of files</li>
<li>Open a file in vim</li>
<li>Edit one of the results</li>
<li>Background vim, get the next result, foreground vim</li>
<li>Repeat until the list is complete</li>
</ul>
<p>Each time I background and foreground vim, though, bash/zsh prints two messages that look like this:</p>
<pre><code>[1] + 4321 continued nvim
[1] + 4321 suspended nvim
</code></pre>
<p>These are annoying because they eat screen space and eventually the results filter off the screen. I have to rerun the command or continually scroll up and down to find it.</p>
<p>Is there a way to get the "continued/suspended" messages to avoid adding so many newlines? Alternatively, can I suppress them altogether.</p>
| 0debug |
Trying to press answer button on main page but window freezes: Python Tkinter. : #Learning how to create a GUI
from tkinter import *
from random import randint
#Naming the Tk window
master = Tk()
#Setting the size of Tk Window
master.geometry('800x750')
#Dictionary for the questions
easy3 = ["Who is CEO of Apple?", "Who is the founder of Facebook?", "Who is the CEO of Google?"]
easy3_A = ["Tim Cook", "Mark Zuckerburg", "Sundar Pichai"]
#Defining some variables
question_number = randint(0,2)
global score
question_index = 0
#Procedure
def callback():
#A loading... symbol to ease a consumer's concern
top = Toplevel(master)
top.geometry('800x750')
def question_label():
question_label = Label(top, text = ('Your Question'), bg = 'light blue', font=('Times New Roman',20), highlightbackground='black', width = 25, height = 3)
question_label.place(x=215,y=125)
question_label.pack
def question_text():
question_text = Label(top, text = easy3[question_number], bg = 'light blue', font=('Times New Roman',16), highlightbackground='black', width = 25, height = 3)
question_text.place(x=250,y=300)
question_text.pack
def answer():
score = 0
answer = input('Answer: ')
if answer == easy3_A[question_number]:
print('Correct!')
score = score `enter code here`+ 1
print('Score = ',score)
else:
print('Wrong!')
print('GAME OVER!')
top.configure(background = 'light blue')
image = PhotoImage(file="STEM_1_final.gif")
w = Label(top, image=image)
w.place(x=1,y=1)
image_2 = PhotoImage(file="STEM_2_final.gif")
c = Label(top, image=image_2)
c.place(x=750,y=1)
image_3 = PhotoImage(file="STEM_3_final.gif")
a = Label(top, image=image_3)
a.place(x=1,y=700)
image_4 = PhotoImage(file="STEM_4_final.gif")
d = Label(top, image=image_4)
d.place(x=750,y=700)
top.title('Question #1')
b = Button(text="Answer", command=answer)
b.pack()
b.place(relx=.5, rely=.9, anchor=CENTER)
question_text()
question_label()
mainloop()
def main_content():
#A procedure to create and display the title
title_label = Label(master, text = 'Can You Beat the Compu-tition?', bg = 'light blue', font=('Times New Roman',40), highlightbackground='black', width = 25, height = 3)
title_label.pack()
#Making the background of window light blue
master.configure(background = 'light blue')
#Titling the window, "Can you beat the Compu-tition?"
master.title('Can You Beat the Compu-tition?')
#Creating the button, and positioning it
b = Button(text="Next Page", command=callback,)
b.pack()
b.place(relx=.5, rely=.75, anchor=CENTER)
#Invoking the procedure to display the title
main_content()
#Uploading all photos for the user interface
image = PhotoImage(file="STEM_1_final.gif")
w = Label(master, image=image)
w.place(x=1,y=1)
image_2 = PhotoImage(file="STEM_2_final.gif")
c = Label(master, image=image_2)
c.place(x=750,y=1)
image_3 = PhotoImage(file="STEM_3_final.gif")
a = Label(master, image=image_3)
a.place(x=1,y=700)
image_4 = PhotoImage(file="STEM_4_final.gif")
d = Label(master, image=image_4)
d.place(x=750,y=700)
image_5 = PhotoImage(file="STEM_5_final.gif")
e = Label(master, image=image_5)
e.place(x=400,y=350, anchor=CENTER)
#Creating, displaying, positioning, and centering the slogan label
slogan = Label(master, text = 'A Trivia Game In The STEM Field', bg = 'light blue',font=('Times New Roman',15))
slogan.place(x=400,y=160, anchor=CENTER)
#Making this whole piece of code specific to the Tkinter window run
mainloop()
Answer button on Main page is not working if you press it. The window just says not responding. I dont know what mode to use for the user to input their answer for the question. If you want to input the answer to the question, go to the Python Shell.
| 0debug |
int avconv_parse_options(int argc, char **argv)
{
OptionParseContext octx;
uint8_t error[128];
int ret;
memset(&octx, 0, sizeof(octx));
ret = split_commandline(&octx, argc, argv, options, groups);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error splitting the argument list: ");
goto fail;
}
ret = parse_optgroup(NULL, &octx.global_opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error parsing global options: ");
goto fail;
}
ret = open_files(&octx.groups[GROUP_INFILE], "input", open_input_file);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error opening input files: ");
goto fail;
}
ret = open_files(&octx.groups[GROUP_OUTFILE], "output", open_output_file);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error opening output files: ");
goto fail;
}
fail:
uninit_parse_context(&octx);
if (ret < 0) {
av_strerror(ret, error, sizeof(error));
av_log(NULL, AV_LOG_FATAL, "%s\n", error);
}
return ret;
}
| 1threat |
Fetch strings of date from a given arrays of date : I want to extract dates from a a arrays of dates which i was fetching from the database .
[{"event_start_date":"2019-03-12"},{"event_start_date":"2019-07-05"},{"event_start_date":"2019-07-05"},{"event_start_date":"2019-08-01"}]
i want to fetch those controller datas to .blade.php file in ["2019-03-12,2019-03-12,2019-03-12,2019-03-12".split(",")] this format | 0debug |
Convert sequence of longitude and latitude to polygon via sf in R : <p>I have five longitude and latitude that form a shape like this.</p>
<pre><code>df <- c(order=1:5,
lon=c(119.4,119.4,119.4,119.5,119.5),
lat=c(-5.192,-5.192,-5.187,-5.187,-5.191))
</code></pre>
<p>How could I easily convert them into an sf polygon data frame using <code>sf</code> package like this?</p>
<pre><code>## Simple feature collection with 1 feature and 0 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: 119.4 ymin: -5.192 xmax: 119.5 ymax: -5.187
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## geometry
## 1 POLYGON ((119.4 ...
</code></pre>
| 0debug |
Sync between two Android devices without Internet connection :
Is it possible to sync between two Android devices directly when there **is no Internet connection** (like a remote location or an outage at the Internet provider)?
Using a direct wireless connection between just these two Android devices (**without using a PC or a WiFi router**)
I need to sync all data (Location , time , Postion) | 0debug |
Insert A Character After 7 Characters (C#) : <p>So each player in my game has a seven digit number that they are assigned. For example, if a player has an ID number of 0002232, how would I make it so that the ID number in game appears 000-2232. Basically, after three characters I want to add a "-".</p>
<p>Thanks! :)</p>
| 0debug |
check if file exists without allocating memory : <p>I need to check if a file exists without allocating memory for it. I just want to check that it exists, I am not interested in getting the content. Is there a simple way to achieve that?</p>
| 0debug |
If statement does not print out the body when the condition has met : <p>I expect the output will be the string in the wordList when it matched the search before the for loop exits but it does not print out every time when the if statements met the condition.</p>
<p>search = "ABC" <br/>
wordList = [["ABC", "123"], ["ABC", "456"], ["DEF", "123"]]</p>
<pre><code>public void biDi(String searchWord, String[][] wordList) {
int start = 0;
int end = list.size ()-1;
String search = searchWord;
int path = 0;
for (int i = 0; (i < (list.size ()/2)); i++) {
if (search == wordList[start][0]) {
System.out.println (wordList[start][1]);
}
if (search == wordList[end][0]) {
System.out.println (wordList[end][1]);
}
start++;
end--;
path++;
}
System.out.println (path);
}
</code></pre>
| 0debug |
Creating stripe token using separate elements : <p>Instead of using the element type 'card' I needed to separate the elements, In the documentation example they only use 'card' so when they create a token they just pass the card object to the create token parameter.</p>
<pre><code>stripe.createToken(card).then(function(result) {
});
</code></pre>
<p>How can I pass these multiple objects to create a token?</p>
<pre><code>var cardNumber = elements.create('cardNumber');
cardNumber.mount('#card-number');
var cardExpiry = elements.create('cardExpiry');
cardExpiry.mount('#card-expiry');
var cardCvc = elements.create('cardCvc');
cardCvc.mount('#card-cvc');
var cardPostalCode = elements.create('postalCode');
cardPostalCode.mount('#card-postal-code');
</code></pre>
| 0debug |
How to delete completely dokan plugin? : I deactivated and delete dokan plugin but this only delete files but not delete setting. | 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
"image/png;base64?" what does it do? : <p>I have a question about this piece of code:</p>
<p><code>redirectUrl</code>: <code>"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="</code></p>
<p>When I include this piece of code, all pictures on a website dont get loaded. But what does this encoder do? </p>
<p>Does it block pictures, hides them or just isn't loading them?</p>
| 0debug |
static void arm11mpcore_initfn(Object *obj)
{
ARMCPU *cpu = ARM_CPU(obj);
set_feature(&cpu->env, ARM_FEATURE_V6K);
set_feature(&cpu->env, ARM_FEATURE_VFP);
set_feature(&cpu->env, ARM_FEATURE_VAPA);
cpu->midr = ARM_CPUID_ARM11MPCORE;
cpu->reset_fpsid = 0x410120b4;
cpu->mvfr0 = 0x11111111;
cpu->mvfr1 = 0x00000000;
cpu->ctr = 0x1dd20d2;
cpu->id_pfr0 = 0x111;
cpu->id_pfr1 = 0x1;
cpu->id_dfr0 = 0;
cpu->id_afr0 = 0x2;
cpu->id_mmfr0 = 0x01100103;
cpu->id_mmfr1 = 0x10020302;
cpu->id_mmfr2 = 0x01222000;
cpu->id_isar0 = 0x00100011;
cpu->id_isar1 = 0x12002111;
cpu->id_isar2 = 0x11221011;
cpu->id_isar3 = 0x01102131;
cpu->id_isar4 = 0x141;
}
| 1threat |
use conda environment in sublime text 3 : <p>Using Sublime Text 3, how can I build a python file using a conda environment that I've created as in <a href="http://conda.pydata.org/docs/using/envs.html" rel="noreferrer">http://conda.pydata.org/docs/using/envs.html</a></p>
| 0debug |
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
int ret;
#ifdef CONFIG_ACCEPT4
ret = accept4(s, addr, addrlen, SOCK_CLOEXEC);
if (ret != -1 || errno != EINVAL) {
return ret;
}
#endif
ret = accept(s, addr, addrlen);
if (ret >= 0) {
qemu_set_cloexec(ret);
}
return ret;
}
| 1threat |
What is the difference between OAuth based and Token based authentication? : <p>I thought that OAuth is basically a token based authentication specification but most of the time frameworks act as if there is a difference between them. For example, as shown in the picture below <a href="https://jhipster.github.io/" rel="noreferrer">Jhipster</a> asks whether to use an OAuth based or a token based authentication. </p>
<p>Aren't these the same thing ? What exactly is the difference since both includes tokens in their implementations ?</p>
<p><a href="https://i.stack.imgur.com/vCcXA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vCcXA.png" alt="enter image description here"></a></p>
| 0debug |
Is there a keyspace event in redis for a key entering the database that isn't already present? : <p>I have a program that utilizes a redis key with an expire time set. I want to detect when there is a new entry to the data set. I can tell when there is a removal by listening for the "expired" event, but the "set" and "expire" events are fired every time the key is set, even if it's already in the database.</p>
<p>Is there a keyspace event for a NEW key appearing?</p>
| 0debug |
Java parse string as date "2017-06-12T14:45:00+05:30" : <p>How do I parse this String in Java as date
"2017-06-12T14:45:00+05:30"
I've tried using SimpleDateFormat but it is throwing exception.
Thanks</p>
| 0debug |
PYTHON how to save variables to a file which orders them : For I task I'm required to save variables to a new file, I can do this but don't know how I will be able to order the file. The file will contain a string and integer I want to order it from highest integer to lowest would appreciate the help. | 0debug |
static void residual_interp(int16_t *buf, int16_t *out, int lag,
int gain, int *rseed)
{
int i;
if (lag) {
int16_t *vector_ptr = buf + PITCH_MAX;
for (i = 0; i < lag; i++)
out[i] = vector_ptr[i - lag] * 3 >> 2;
av_memcpy_backptr((uint8_t*)(out + lag), lag * sizeof(*out),
(FRAME_LEN - lag) * sizeof(*out));
} else {
for (i = 0; i < FRAME_LEN; i++) {
*rseed = *rseed * 521 + 259;
out[i] = gain * *rseed >> 15;
}
memset(buf, 0, (FRAME_LEN + PITCH_MAX) * sizeof(*buf));
}
}
| 1threat |
void helper_ldfsr(CPUSPARCState *env, uint32_t new_fsr)
{
env->fsr = (new_fsr & FSR_LDFSR_MASK) | (env->fsr & FSR_LDFSR_OLDMASK);
set_fsr(env);
}
| 1threat |
probleme dans la fonction main d'un projet javafx :
Bonsoir , j'essaye d'exécuter ma fonction main dans un projet java fx et je rencontre l'exception suivante
Exception in Application start method java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at Gestion.view.MainClass.initialisationContenu(MainClass.java:57)
at Gestion.view.MainClass.start(MainClass.java:28)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Exception running application Gestion.view.MainClass
J'ai vraiment chercher partout mais je n'ai trouvé aucune réponse convenable . J'ai essayé de mettre le chemin vers les fichiers fxml tout entier mais sans résultat . j'ai aussi consulté les sujets similaires mais je suis toujours bloquée .
voici mon code
package Gestion.view ;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class MainClass extends Application {
private Stage stagePrincipal;
private BorderPane conteneurPrincipal;
@Override
public void start(Stage primaryStage) {
stagePrincipal = primaryStage;
stagePrincipal.setTitle("Application de gestion du centre socio-médical OCP");
initialisationConteneurPrincipal();
initialisationContenu();
}
private void initialisationConteneurPrincipal() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainClass.class.getResource("Welcome.fxml"));
try {
conteneurPrincipal = (BorderPane) loader.load();
Scene scene = new Scene(conteneurPrincipal);
stagePrincipal.setScene(scene);
stagePrincipal.show();
} catch (IOException e) {
e.printStackTrace();
}
}
private void initialisationContenu() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getClassLoader().getResource("Acceuil1.fxml"));
try {
AnchorPane conteneurPersonne = (AnchorPane) loader.load();
conteneurPrincipal.setCenter(conteneurPersonne);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
public Stage getStage() {
return null;
}
}
merci d'avance .
| 0debug |
static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
int l1_size, uint8_t **expanded_clusters,
uint64_t *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
bool is_active_l1 = (l1_table == s->l1_table);
uint64_t *l2_table = NULL;
int ret;
int i, j;
if (!is_active_l1) {
l2_table = qemu_blockalign(bs, s->cluster_size);
}
for (i = 0; i < l1_size; i++) {
uint64_t l2_offset = l1_table[i] & L1E_OFFSET_MASK;
bool l2_dirty = false;
if (!l2_offset) {
continue;
}
if (is_active_l1) {
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
(void **)&l2_table);
} else {
ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE,
(void *)l2_table, s->cluster_sectors);
}
if (ret < 0) {
goto fail;
}
for (j = 0; j < s->l2_size; j++) {
uint64_t l2_entry = be64_to_cpu(l2_table[j]);
int64_t offset = l2_entry & L2E_OFFSET_MASK, cluster_index;
int cluster_type = qcow2_get_cluster_type(l2_entry);
bool preallocated = offset != 0;
if (cluster_type == QCOW2_CLUSTER_NORMAL) {
cluster_index = offset >> s->cluster_bits;
assert((cluster_index >= 0) && (cluster_index < *nb_clusters));
if ((*expanded_clusters)[cluster_index / 8] &
(1 << (cluster_index % 8))) {
ret = qcow2_update_cluster_refcount(bs, cluster_index, 1,
QCOW2_DISCARD_NEVER);
if (ret < 0) {
goto fail;
}
l2_table[j] = cpu_to_be64(l2_entry & ~QCOW_OFLAG_COPIED);
l2_dirty = true;
}
continue;
}
else if (qcow2_get_cluster_type(l2_entry) != QCOW2_CLUSTER_ZERO) {
continue;
}
if (!preallocated) {
if (!bs->backing_hd) {
l2_table[j] = 0;
l2_dirty = true;
continue;
}
offset = qcow2_alloc_clusters(bs, s->cluster_size);
if (offset < 0) {
ret = offset;
goto fail;
}
}
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,
offset, s->cluster_size);
if (ret < 0) {
if (!preallocated) {
qcow2_free_clusters(bs, offset, s->cluster_size,
QCOW2_DISCARD_ALWAYS);
}
goto fail;
}
ret = bdrv_write_zeroes(bs->file, offset / BDRV_SECTOR_SIZE,
s->cluster_sectors);
if (ret < 0) {
if (!preallocated) {
qcow2_free_clusters(bs, offset, s->cluster_size,
QCOW2_DISCARD_ALWAYS);
}
goto fail;
}
l2_table[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED);
l2_dirty = true;
cluster_index = offset >> s->cluster_bits;
if (cluster_index >= *nb_clusters) {
uint64_t old_bitmap_size = (*nb_clusters + 7) / 8;
uint64_t new_bitmap_size;
assert(bs->file->growable);
*nb_clusters = size_to_clusters(s, bs->file->total_sectors *
BDRV_SECTOR_SIZE);
new_bitmap_size = (*nb_clusters + 7) / 8;
*expanded_clusters = g_realloc(*expanded_clusters,
new_bitmap_size);
memset(&(*expanded_clusters)[old_bitmap_size], 0,
new_bitmap_size - old_bitmap_size);
}
assert((cluster_index >= 0) && (cluster_index < *nb_clusters));
(*expanded_clusters)[cluster_index / 8] |= 1 << (cluster_index % 8);
}
if (is_active_l1) {
if (l2_dirty) {
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
qcow2_cache_depends_on_flush(s->l2_table_cache);
}
ret = qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table);
if (ret < 0) {
l2_table = NULL;
goto fail;
}
} else {
if (l2_dirty) {
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT &
~(QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2), l2_offset,
s->cluster_size);
if (ret < 0) {
goto fail;
}
ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE,
(void *)l2_table, s->cluster_sectors);
if (ret < 0) {
goto fail;
}
}
}
}
ret = 0;
fail:
if (l2_table) {
if (!is_active_l1) {
qemu_vfree(l2_table);
} else {
if (ret < 0) {
qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table);
} else {
ret = qcow2_cache_put(bs, s->l2_table_cache,
(void **)&l2_table);
}
}
}
return ret;
}
| 1threat |
int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int ret;
AVPacket tmp = *avpkt;
if (!avctx->codec)
return AVERROR(EINVAL);
if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
return AVERROR(EINVAL);
}
*got_picture_ptr = 0;
if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return AVERROR(EINVAL);
avcodec_get_frame_defaults(picture);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) {
int did_split = av_packet_split_side_data(&tmp);
ret = apply_param_change(avctx, &tmp);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error applying parameter changes.\n");
if (avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
avctx->internal->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp);
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
&tmp);
picture->pkt_dts = avpkt->dts;
if(!avctx->has_b_frames){
av_frame_set_pkt_pos(picture, avpkt->pos);
}
if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) {
if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!picture->width) picture->width = avctx->width;
if (!picture->height) picture->height = avctx->height;
if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt;
}
}
add_metadata_from_side_data(avctx, picture);
fail:
emms_c();
avctx->internal->pkt = NULL;
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_picture_ptr) {
if (!avctx->refcounted_frames) {
int err = unrefcount_frame(avci, picture);
if (err < 0)
return err;
}
avctx->frame_number++;
av_frame_set_best_effort_timestamp(picture,
guess_correct_pts(avctx,
picture->pkt_pts,
picture->pkt_dts));
} else
av_frame_unref(picture);
} else
ret = 0;
picture->extended_data = picture->data;
return ret;
}
| 1threat |
Merge number in the array when the id is same : Already search tutorial in google but don't find what i need...
I've array like this
[{Username:'user1', Balance:'123'}, {Username:'user2', Balance:'213'}, {Username:'user1', Balance:'424'}]
How to merge `Balance` whene the username is same, for example merge **Balance** `Username:'user2'` | 0debug |
static int usbredir_handle_status(USBRedirDevice *dev,
int status, int actual_len)
{
switch (status) {
case usb_redir_success:
return actual_len;
case usb_redir_stall:
return USB_RET_STALL;
case usb_redir_cancelled:
WARNING("returning cancelled packet to HC?\n");
return USB_RET_NAK;
case usb_redir_inval:
WARNING("got invalid param error from usb-host?\n");
return USB_RET_NAK;
case usb_redir_babble:
return USB_RET_BABBLE;
case usb_redir_ioerror:
case usb_redir_timeout:
default:
return USB_RET_IOERROR;
}
}
| 1threat |
Is it possible to debug a Gitlab CI build interactively? : <p>I have a build in Gitlab CI that takes a long time (10mins+) to run, and it's very annoying to wait for the entire process every time I need to experiment / make changes. It seems like surely there's a way to access some sort of shell during the build process and run commands interactively instead of placing them all in a deploy script. </p>
<p>I know it's possible to run Gitlab CI <em>tests</em> locally, but I can't seem to find a way to access the deploy running in process, even after scouring the docs. </p>
<p>Am I out of luck or is there a way to manually control this lengthy build?</p>
| 0debug |
My CSS does not seem to be working? : <p>I'm having trouble with my CSS.</p>
<ul>
<li>It's not working even though it is linked correctly to my HTML
document.</li>
<li>The files <em>are</em> in the same folder.</li>
<li>Both files are saved in the correct format.</li>
<li>From what I can see, I don't see anything wrong or missing from the
CSS.</li>
</ul>
<p><a href="http://i.stack.imgur.com/l227W.jpg" rel="nofollow">The CSS</a></p>
<p><a href="http://i.stack.imgur.com/sesvf.jpg" rel="nofollow">The HTML</a></p>
| 0debug |
how to slice array of hashes : I am trying to basically split an array of hashes into multiple arrays based on the value inside of the hashes. All hashes have the same keys.
The code i'm trying to get working is:
buyer_ids = specific_buyer.slice_after{ |obj| obj["tid"] != nil}
the result I am getting is:
#<Enumerator: #<Enumerator::Generator:0x007ffe9ea2f5b8>:each>
And honestly I have no clue what it means.
My perfect end result would be something that looks like this:
1 = [{"tid" => nil}, {"tid" => nil}, {"tid" => true}]
2 = [{"tid" => nil}, {"tid" => true}]
3 = [{"tid" => nil}, {"tid" => nil}, {"tid" => nil}, {"tid" => true}]
| 0debug |
static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
{
void **lp, **p;
p = (void **)l1_phys_map;
#if TARGET_PHYS_ADDR_SPACE_BITS > 32
#if TARGET_PHYS_ADDR_SPACE_BITS > (32 + L1_BITS)
#error unsupported TARGET_PHYS_ADDR_SPACE_BITS
#endif
lp = p + ((index >> (L1_BITS + L2_BITS)) & (L1_SIZE - 1));
p = *lp;
if (!p) {
if (!alloc)
return NULL;
p = qemu_vmalloc(sizeof(void *) * L1_SIZE);
memset(p, 0, sizeof(void *) * L1_SIZE);
*lp = p;
}
#endif
lp = p + ((index >> L2_BITS) & (L1_SIZE - 1));
p = *lp;
if (!p) {
if (!alloc)
return NULL;
p = qemu_vmalloc(sizeof(PhysPageDesc) * L2_SIZE);
memset(p, 0, sizeof(PhysPageDesc) * L2_SIZE);
*lp = p;
}
return ((PhysPageDesc *)p) + (index & (L2_SIZE - 1));
}
| 1threat |
Java Why isn't it allowed to set a protected final field from a subclass constructor? : <p>Why isn't it allowed to set a protected final field from a subclass constructor?</p>
<p>Example:</p>
<pre><code>class A {
protected final boolean b;
protected A() {
b = false;
}
}
class B extends A {
public B() {
super();
b = true;
}
}
</code></pre>
<p>I think it would make sense in some cases, wouldn't it?</p>
| 0debug |
static hwaddr vfio_container_granularity(VFIOContainer *container)
{
return (hwaddr)1 << ctz64(container->iova_pgsizes);
}
| 1threat |
Is there a regular expression for "foldernameMM_DD__YYYY" : <p>I am setting up Perl script that runs periodically and delete unwanted folders and to identity auto generated folder my organization following naming convention like </p>
<blockquote>
<p>foldernameMM_DD_YYYY</p>
</blockquote>
<p>can someone please help me with this regex</p>
| 0debug |
How to enable directory listing in apache web server : <p>I am not able to enable directory listing in my apache web server. I have tried various solutions posted but not working. I just freshly installed httpd 2.4.6 and enabled https using ssl.conf under /etc/httpd/conf.d/ssl.conf dir and trying to access <a href="https://server.example.com/" rel="noreferrer">https://server.example.com/</a> but this is not listing the dir. These are the config in ssl.conf</p>
<pre><code>DocumentRoot "/home/userx/Downloads/"
ServerName server.example.com:443
</code></pre>
<p>Below is what it has in ssl.conf under the VirtualHost element. Files and the first Directory elements were already there when I installed, I just added Directory for "/home/userx/Downloads". I want to browse the contents of /home/userx/Downloads when I access the URL <a href="https://server.example.com/" rel="noreferrer">https://server.example.com/</a>. What am I missing here ?</p>
<pre><code><Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
<Directory "/home/userx/Downloads">
Options +Indexes
AllowOverride all
</Directory>
</code></pre>
| 0debug |
static int dvbsub_probe(AVProbeData *p)
{
int i, j, k;
const uint8_t *end = p->buf + p->buf_size;
int type, len;
int max_score = 0;
for(i=0; i<p->buf_size; i++){
if (p->buf[i] == 0x0f) {
const uint8_t *ptr = p->buf + i;
uint8_t histogram[6] = {0};
int min = 255;
for(j=0; ptr + 6 < end; j++) {
if (*ptr != 0x0f)
break;
type = ptr[1];
len = AV_RB16(ptr + 4);
if (type == 0x80) {
;
} else if (type >= 0x10 && type <= 0x14) {
histogram[type - 0x10] ++;
} else
break;
ptr += 6 + len;
}
for (k=0; k < 4; k++) {
min = FFMIN(min, histogram[k]);
}
if (min && j > max_score)
max_score = j;
}
}
if (max_score > 5)
return AVPROBE_SCORE_EXTENSION;
return 0;
}
| 1threat |
Set value of DependencyProperty directly : <p>Ok so I have a test control that derives from Panel. I added new dependency property to it.</p>
<pre><code>public class TestPanel : Panel
{
public static DependencyProperty TestProperty = DependencyProperty.Register(
"Test",
typeof(double),
typeof(TestPanel),
new FrameworkPropertyMetadata(
0.0,
null));
public double Test
{
get
{
return (double)this.GetValue(TestProperty);
}
set
{
this.SetValue(TestProperty, value);
}
}
}
</code></pre>
<p>I then defined it in xaml <code><controls:TestPanel Test="50" /></code></p>
<p>But now I wonder, why the setter of Test is not called? Shouldn't it pass value(50)? I get default value (0.0) during arrange pass.</p>
<p>Or is it only valid using the binding instead?</p>
| 0debug |
static void io_region_del(MemoryListener *listener,
MemoryRegionSection *section)
{
isa_unassign_ioport(section->offset_within_address_space,
int128_get64(section->size));
}
| 1threat |
Stopping a started background service (phantomjs) in gitlab-ci : <p>I'm starting phantomjs with specific arguments as part of my job.</p>
<p>This is running on a custom gitlab/gitlab-ci server, I'm currently not using containers, I guess that would simplify that.</p>
<p>I'm starting phantomjs like this:</p>
<pre><code>- "timeout 300 phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768 2>&1 >> /tmp/gastonjs.log &"
</code></pre>
<p>Then I'm running my behat tests, and then I'm stopping that process again:</p>
<pre><code>- "pkill -f 'src/Client/main.js' || true"
</code></pre>
<p>The problem is when a behat test fails, then it doesn't execute the pkill and the test-run is stuck waiting on phantomjs to finish. I already added the timeout 300 but that means I'm still currently waiting 2min or so after a fail and it will eventually stop it while test are still running when they get slow enough.</p>
<p>I haven't found a way to run some kind of post-run/cleanup command that also runs in case of fails.</p>
<p>Is there a better way to do this? Can I start phantomjs in a way that gitlab-ci doesn't care that it is still running? nohup maybe? </p>
| 0debug |
static int g722_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
G722Context *c = avctx->priv_data;
int16_t *out_buf = data;
int j, out_len = 0;
const int skip = 8 - avctx->bits_per_coded_sample;
const int16_t *quantizer_table = low_inv_quants[skip];
GetBitContext gb;
init_get_bits(&gb, avpkt->data, avpkt->size * 8);
for (j = 0; j < avpkt->size; j++) {
int ilow, ihigh, rlow, rhigh, dhigh;
int xout1, xout2;
ihigh = get_bits(&gb, 2);
ilow = get_bits(&gb, 6 - skip);
skip_bits(&gb, skip);
rlow = av_clip((c->band[0].scale_factor * quantizer_table[ilow] >> 10)
+ c->band[0].s_predictor, -16384, 16383);
ff_g722_update_low_predictor(&c->band[0], ilow >> (2 - skip));
dhigh = c->band[1].scale_factor * ff_g722_high_inv_quant[ihigh] >> 10;
rhigh = av_clip(dhigh + c->band[1].s_predictor, -16384, 16383);
ff_g722_update_high_predictor(&c->band[1], dhigh, ihigh);
c->prev_samples[c->prev_samples_pos++] = rlow + rhigh;
c->prev_samples[c->prev_samples_pos++] = rlow - rhigh;
ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
&xout1, &xout2);
out_buf[out_len++] = av_clip_int16(xout1 >> 12);
out_buf[out_len++] = av_clip_int16(xout2 >> 12);
if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
memmove(c->prev_samples, c->prev_samples + c->prev_samples_pos - 22,
22 * sizeof(c->prev_samples[0]));
c->prev_samples_pos = 22;
}
}
*data_size = out_len << 1;
return avpkt->size;
}
| 1threat |
Why is require() undefined during karma tests but is ok during runtime? : <p>So I'm working on Angular 2 app, which is being written in TypeScript, and wrote some unit tests with Jasmine (also in TypeScript). After compilation all imports are translated to <code>require()</code>. When I run my app in the browser everything works fine, but when I try to run unit test with <code>karma</code> it says <code>Uncaught ReferenceError: require is not defined</code>. I've googled that and folks say it's because <code>karma</code> runs test in browser and browser doesn't know about <code>require()</code>, but why it works ok during runtime then?</p>
| 0debug |
Xcode 9 Server: Unable to boot device due to insufficient system resources : <p>I'm trying to run my unit tests on all device simulators from iOS 8.4 to 11.0 at the same time by checking the option 'Run test in parallel' when setting up the Xcode Bot. Unfortunately after trying to boot the 13th simulator it failes with the error message in the build log:</p>
<pre><code>xcodebuild: error: Failed to build workspace xxxxx with scheme yyyyy.
Reason: Unable to boot device due to insufficient system resources.
Testing failed on 'iPhone 4s'
</code></pre>
<p>I'm running the server on a mac mini and i think it is just not capable to run so many simulators at the same time due to full memory.</p>
<p>Anyone experience with it?</p>
| 0debug |
static void arm_sysctl_write(void *opaque, target_phys_addr_t offset,
uint64_t val, unsigned size)
{
arm_sysctl_state *s = (arm_sysctl_state *)opaque;
switch (offset) {
case 0x08:
s->leds = val;
case 0x0c:
case 0x10:
case 0x14:
case 0x18:
case 0x1c:
break;
case 0x20:
if (val == LOCK_VALUE)
s->lockval = val;
else
s->lockval = val & 0x7fff;
break;
case 0x28:
s->cfgdata1 = val;
break;
case 0x2c:
s->cfgdata2 = val;
break;
case 0x30:
s->flags |= val;
break;
case 0x34:
s->flags &= ~val;
break;
case 0x38:
s->nvflags |= val;
break;
case 0x3c:
s->nvflags &= ~val;
break;
case 0x40:
switch (board_id(s)) {
case BOARD_ID_PB926:
if (s->lockval == LOCK_VALUE) {
s->resetlevel = val;
if (val & 0x100) {
qemu_system_reset_request();
}
}
break;
case BOARD_ID_PBX:
case BOARD_ID_PBA8:
if (s->lockval == LOCK_VALUE) {
s->resetlevel = val;
if (val & 0x04) {
qemu_system_reset_request();
}
}
break;
case BOARD_ID_VEXPRESS:
case BOARD_ID_EB:
default:
break;
}
break;
case 0x44:
break;
case 0x4c:
break;
case 0x50:
switch (board_id(s)) {
case BOARD_ID_PB926:
s->sys_clcd &= 0x3f00;
s->sys_clcd |= val & ~0x3f00;
qemu_set_irq(s->pl110_mux_ctrl, val & 3);
break;
case BOARD_ID_EB:
s->sys_clcd &= 0x3f00;
s->sys_clcd |= val & ~0x3f00;
break;
case BOARD_ID_PBA8:
case BOARD_ID_PBX:
s->sys_clcd &= (1 << 7);
s->sys_clcd |= val & ~(1 << 7);
break;
case BOARD_ID_VEXPRESS:
default:
break;
}
case 0x54:
case 0x64:
case 0x68:
case 0x6c:
case 0x70:
case 0x74:
case 0x80:
case 0x84:
case 0x88:
case 0x8c:
case 0x90:
case 0x94:
case 0x98:
case 0x9c:
break;
case 0xa0:
if (board_id(s) != BOARD_ID_VEXPRESS) {
goto bad_reg;
}
s->sys_cfgdata = val;
return;
case 0xa4:
if (board_id(s) != BOARD_ID_VEXPRESS) {
goto bad_reg;
}
s->sys_cfgctrl = val & ~(3 << 18);
s->sys_cfgstat = 1;
switch (s->sys_cfgctrl) {
case 0xc0800000:
qemu_system_shutdown_request();
break;
case 0xc0900000:
qemu_system_reset_request();
break;
default:
s->sys_cfgstat |= 2;
}
return;
case 0xa8:
if (board_id(s) != BOARD_ID_VEXPRESS) {
goto bad_reg;
}
s->sys_cfgstat = val & 3;
return;
default:
bad_reg:
printf ("arm_sysctl_write: Bad register offset 0x%x\n", (int)offset);
return;
}
}
| 1threat |
How to use a string (stored in a variable) to find a symbol in a hash. Ruby : I have a question that seems fairly basic, and I searched the site and did not see it asked (so I hope this is not a duplicate).
The simple problem I am trying to solve is that I have some user input that will be a string. I need to use this string to see if there is a key/symbol that exists in the hash, like this:
# user gives input about what category that they want to retrieve, and it is stored in a variable called category:
category = "cupcake"
products = {
:cupcakes => [{:title => "chocolate", :flavor => "chocolate"}, {:title => "summer special", :flavor => "pink cake"}],
:cookies => [{:title => "chocolate bliss", :flavor => "chocolate chip"}, {:title => "breakfast surprise", :flavor => "oatmeal raisin"}]
}
# This one does not work because category is a string, not a symbol
p products.key?(category)
# This one does not work because :cupcake is a unique symbol, and we are just creating another symbol
p products.key?(category.to_sym)
| 0debug |
How to convert the firebase timestamp using angular date pipe : <p>I am trying to display some firebase timestamp in the template view, Unfortunately no luck with the angular datePipe.</p>
<pre><code><p>Seen {{user.updatedAt | date: 'yyyy/MM/dd h:mm:ss a'}}</p>
</code></pre>
<p>I do get this error:</p>
<pre><code> ERROR Error: InvalidPipeArgument:
'Unable to convert "Timestamp(seconds=1528515928, nanoseconds=105000000)"
into a date' for pipe 'DatePipe
</code></pre>
| 0debug |
static int quantize_coefs(double *coef, int *idx, float *lpc, int order)
{
int i;
uint8_t u_coef;
const float *quant_arr = tns_tmp2_map[TNS_Q_BITS == 4];
const double iqfac_p = ((1 << (TNS_Q_BITS-1)) - 0.5)/(M_PI/2.0);
const double iqfac_m = ((1 << (TNS_Q_BITS-1)) + 0.5)/(M_PI/2.0);
for (i = 0; i < order; i++) {
idx[i] = ceilf(asin(coef[i])*((coef[i] >= 0) ? iqfac_p : iqfac_m));
u_coef = (idx[i])&(~(~0<<TNS_Q_BITS));
lpc[i] = quant_arr[u_coef];
}
return order;
}
| 1threat |
Can't get POST data using NodeJS/ExpressJS and Postman : <p>This is the code of my server :</p>
<pre><code>var express = require('express');
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.json());
app.post("/", function(req, res) {
res.send(req.body);
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
</code></pre>
<p>From Postman, I launch a POST request to <a href="http://localhost:3000/" rel="noreferrer">http://localhost:3000/</a> and in Body/form-data I have a key "foo" and value "bar".</p>
<p>However I keep getting an empty object in the response. The <code>req.body</code> property is always empty.</p>
<p>Did I miss something?<a href="https://i.stack.imgur.com/1CJX4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1CJX4.png" alt="enter image description here"></a></p>
| 0debug |
static void test_pci_enable(void)
{
AHCIQState *ahci;
ahci = ahci_boot();
ahci_pci_enable(ahci);
ahci_shutdown(ahci);
}
| 1threat |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
Using pods with Playgrounds in Xcode 9 (beta) : <p>I would like to use some CocoaPod libraries in playgrounds, but can't see a way of linking the playground with a target in <strong>Xcode 9 (beta 4)</strong>. I think this is doable in earlier Xcode versions, but don't have an earlier version of Xcode on my current machine. </p>
<p>Creating a playground creates it as part of the group <em>Unsaved Xcode Document</em> - and opens it in a separate window. </p>
<p><a href="https://i.stack.imgur.com/IK6rcm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IK6rcm.png" alt="enter image description here"></a></p>
<p><strong>How can I install pods which can be imported in the playground?</strong> <em>(through a workspace or project if needed)</em></p>
| 0debug |
static void x86_cpu_reset(CPUState *s)
{
X86CPU *cpu = X86_CPU(s);
X86CPUClass *xcc = X86_CPU_GET_CLASS(cpu);
CPUX86State *env = &cpu->env;
int i;
xcc->parent_reset(s);
memset(env, 0, offsetof(CPUX86State, breakpoints));
tlb_flush(env, 1);
env->old_exception = -1;
#ifdef CONFIG_SOFTMMU
env->hflags |= HF_SOFTMMU_MASK;
#endif
env->hflags2 |= HF2_GIF_MASK;
cpu_x86_update_cr0(env, 0x60000010);
env->a20_mask = ~0x0;
env->smbase = 0x30000;
env->idt.limit = 0xffff;
env->gdt.limit = 0xffff;
env->ldt.limit = 0xffff;
env->ldt.flags = DESC_P_MASK | (2 << DESC_TYPE_SHIFT);
env->tr.limit = 0xffff;
env->tr.flags = DESC_P_MASK | (11 << DESC_TYPE_SHIFT);
cpu_x86_load_seg_cache(env, R_CS, 0xf000, 0xffff0000, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK |
DESC_R_MASK | DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_DS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_ES, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_SS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_FS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_GS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
env->eip = 0xfff0;
env->regs[R_EDX] = env->cpuid_version;
env->eflags = 0x2;
for (i = 0; i < 8; i++) {
env->fptags[i] = 1;
}
env->fpuc = 0x37f;
env->mxcsr = 0x1f80;
env->xstate_bv = XSTATE_FP | XSTATE_SSE;
env->pat = 0x0007040600070406ULL;
env->msr_ia32_misc_enable = MSR_IA32_MISC_ENABLE_DEFAULT;
memset(env->dr, 0, sizeof(env->dr));
env->dr[6] = DR6_FIXED_1;
env->dr[7] = DR7_FIXED_1;
cpu_breakpoint_remove_all(env, BP_CPU);
cpu_watchpoint_remove_all(env, BP_CPU);
#if !defined(CONFIG_USER_ONLY)
if (s->cpu_index == 0) {
apic_designate_bsp(env->apic_state);
}
s->halted = !cpu_is_bsp(cpu);
#endif
} | 1threat |
static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,
int len)
{
int payload_len;
while (len >= 4) {
payload_len = FFMIN(len, (AV_RB16(buf + 2) + 1) * 4);
switch (buf[1]) {
case RTCP_SR:
if (payload_len < 20) {
av_log(NULL, AV_LOG_ERROR,
"Invalid length for RTCP SR packet\n");
return AVERROR_INVALIDDATA;
}
s->last_rtcp_reception_time = av_gettime_relative();
s->last_rtcp_ntp_time = AV_RB64(buf + 8);
s->last_rtcp_timestamp = AV_RB32(buf + 16);
if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
if (!s->base_timestamp)
s->base_timestamp = s->last_rtcp_timestamp;
s->rtcp_ts_offset = s->last_rtcp_timestamp - s->base_timestamp;
}
break;
case RTCP_BYE:
return -RTCP_BYE;
}
buf += payload_len;
len -= payload_len;
}
return -1;
}
| 1threat |
How to create a stopwatch in c#? : <p>How to create a stopwatch in c# (visual studio 2012)that starts when you start typing in a a text box and stops when enter is pressed? It should start again when i start typing another word and end again on pressing enter, then display the times recorded for each word. </p>
<p>The following example demonstrates how to use the Stopwatch class to determine the execution time for an application.
C#</p>
<pre><code>using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime " + elapsedTime);
}
}
</code></pre>
| 0debug |
Why thos for loop isnt working? : Hello i have loop like this:
char word[10];
word[0] = 'a';
word [1] = 'b';
word[2] = 'c';
word[3] = '\0';
char* ptr = word;
int x = 0;
int counter = 0;
for ( char c = *(ptr + x); c == '\0'; c = *(ptr + x))
{
counter++;
x++;
}
After execution of this loop counter is equal to 0. I dont know why.
Any ideas why this loop exits? | 0debug |
Firebase: change the location of the service worker : <p>I am trying to use Firebase messaging (web). Firebase by default searches for the file "firebase-messaging-sw.js" which holds the service worker. </p>
<p>The service worker script is expected to be on the absolute path of the application! For example : <a href="http://localhost/firebase-messaging-sw.js" rel="noreferrer">http://localhost/firebase-messaging-sw.js</a> </p>
<p>How to change this default location?! Searching the official docs I found this method: <code>useServiceWorker</code> which accepts a service worker registeration, but trying to use it I get an error that the method doesn't even exist!</p>
<p>So, How to change the location of the service worker for firebase messaging? </p>
| 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
C++ operation too confusing? : <p>I can't seem to understand this operation.
What is the output of the following code?
I've tried interpreting why b has two different values one as b=1+2 and the other as b=2, since a++ should equal to a=1+a ,then the cout is asking for ++b, which one should it should equal to, b=2-1 or b=3-1?</p>
<pre><code>int a=3;
int b=2;
b=a++;
cout<<++b;
</code></pre>
<p>I know the answer to this question is 4. But i can't get my head around it. </p>
| 0debug |
How can I get a specific field within my table where the ID is the max id? : <p>I'm not sure how to create an sql procedure to get a JobID as LastJobID where the ID is the max.</p>
<p>My procedure looks like this as of right now : <code>`SELECT MAX( ID ) as LastJobID FROM jobs;`</code></p>
<p>But I need something like this: <code>`SELECT JobID as LastJobID FROM jobs where MAX( ID );`</code></p>
<p>The latter gives me an error.</p>
<p>My table consists of a unique auto incremented ID, JobID and other attributes as well. I just need to get the JobID from the Max( ID ) because the JobID's are Alpha numeric so getting the MAX( JobID ) won't get me correct results.</p>
<p>Sorry if this is hard to understand, but if anyone has an idea of a procedure that would let me do this, I would greatly appreciate it!</p>
| 0debug |
Flickering HTML Form button radio Javascript true/false : <p>I would like to make a button which I can put on "true/false" on a certain time with javascript. I want to make a flickering button. How could I do this in Javascript?</p>
<p>I tried something like this: </p>
<pre><code> <td colspan="1" class="button" tabindex="1">
<input type="radio" tabindex="-1">
</td>
</code></pre>
<p>__ </p>
<pre><code> setTimeout(function() {
$("*[tabindex='1']").find('input').get(0).checked = true;
</code></pre>
<p><a href="http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_radio" rel="nofollow noreferrer">http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_radio</a>
(This button) </p>
| 0debug |
php isnt inserting into database : im having an issue with my php script im trying to run. The user is supposed to fill out the application with the desired information, and once submited, goes directly into the database, and displayed on an external, application manager i made. Well.. in submitting the applications, nothing gets added into the database. Ive made sure my sqli query is the correct structure as the schema of my database, and still nothing. running the query into the database itself using PHPMyAdmin, and it works just fine..
Here is my full php which adds the info from the <form> into the database.
<?php
$q1 = "SELECT username FROM tmod WHERE username = '".$_SESSION['user']['username']."'";
$sql = mysqli_query($mysqli, $q1);
if(isset($_POST['submit']))
{
if (empty($_POST['real']) || empty($_POST['age']) || empty($_POST['why']) || empty($_POST['dif']) || empty($_POST['agree']))
{
echo '<div class="animated shake">
<div class="message error">Please fill in all fields.</div>
</div>';
}
else
{
if(mysqli_num_rows($sql) < 1){
$q2 = "INSERT INTO `tmod` (AppID, username,`realname`,age,position,why,different,additional,agree) VALUES (NULL, '".$_SESSION['user']['username']."', '".filter($_POST["real"])."', '".filter($_POST["position"])."', '".filter($_POST["age"])."', '".filter($_POST["why"])."', '".filter($_POST["dif"])."', '".filter($_POST["additional"])."', '".filter($_POST["agree"])."')";
mysqli_query($mysqli, $q2);
echo '<div class="animated shake">
<div class="message success"><b>Thank you!</b> Your application has been submitted and is awaiting to be reviewed by staff!</div>
</div>';
}else{
echo '<div class="animated shake">
<div class="message error">You have already applied, please wait for a reply.</div>
</div>';
}
}
}
?>
<div class="box">
<div class="contentHeader headerGreen">
<div class="inside">
Staff Application
</div>
</div>
<div class="inside">
<form method="post">
<div class="form-section">
<strong>Username:</strong><br />
<input disabled="disabled" type="text" value="{username}">
</div>
<div class="form-section">
<strong>Real Name:</strong><br />
<input type="text" name="real" maxlength="28">
</div>
<div class="form-section">
<strong>Position:</strong><br />
<input type="text" name="position" maxlength="28">
</div>
<div class="form-section">
<strong>Age:</strong><br />
<select name="age">
<?php for ($i = 13; $i <= 60; $i++) : ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
</div>
<div class="form-section">
<textarea name="why" rows="4" cols="29" placeholder="Why Should We Hire You?"></textarea>
</div>
<div class="form-section">
<textarea name="dif" rows="4" cols="40"placeholder="How are you different from the rest?"></textarea>
</div>
<div class="form-section">
<strong>
<textarea name="additional" rows="4" cols="40" placeholder="Additional Information - Leave your Skype here" ></textarea>
</div>
<div class="form-section" style="float:bottom">
<input type="checkbox" value="1" name="agree" >
<label>I agree to be active on the Habbsane Hotel.</label>
</div>
<div class="form-section">
<input type="submit" class="submit" name="submit" value="Apply">
</div>
</form>
</div>
</div>
Here is the setup of my tmod table in the database
`AppID` int(11) NOT NULL,
`different` varchar(6000) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`realname` varchar(255) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`why` varchar(6000) DEFAULT NULL,
`additional` varchar(6000) DEFAULT NULL,
`agree` varchar(1) DEFAULT NULL,
`denied` varchar(255) DEFAULT 'Not Read Yet',
`reply` varchar(1000) DEFAULT NULL,
`save` varchar(255) DEFAULT NULL | 0debug |
What is libswiftRemoteMirror.dylib and why is it being included in my app bundle? : <p>I've got an iOS app which I've recently switched to Xcode 8.
As part of that we switched from swift 2.2 to 2.3 (swift 3 will come later).</p>
<p>I've got an automated build pipeline which essentially runs <code>xcodebuild</code> to produce a release binary on a dedicated build machine, and after I sorted all that out (Xcode 8's automatic code signing really screws everything up), now when I upload my app to iTunes connect, it fails with this error:</p>
<blockquote>
<p>ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'MyApp.app/libswiftRemoteMirror.dylib' is not permitted. Your app can't contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at <a href="https://developer.apple.com/go/?id=bundle-structure">https://developer.apple.com/go/?id=bundle-structure</a> for information on the iOS app bundle structure."</p>
</blockquote>
<p>Sure enough, if I unzip the .ipa file and have a look, there's <code>libswiftRemoteMirror.dylib</code> sitting there.</p>
<p>If I archive/export for iTunes via Xcode, then it produces an app bundle which does not have <code>libswiftRemoteMirror.dylib</code>, however all other builds of my app appear to have it. Even just doing a debug build within Xcode, then looking at the output shows that libswiftRemoteMirror.dylib is sitting in my app's bundle, indicating that Xcode itself is definitely putting it there, not any part of my automated build script.</p>
<p>What is this file, why is it being put there, and what should I do about it?
I can modify my build script to delete this file for release builds, but I'm concerned that might affect the code signing process. I'll try it anyway and see what happens, but it feels like that's not quite the right thing to be doing.</p>
<p>Any advice would be appreciated.</p>
| 0debug |
how can I retrieve data from Firebase in web using javascript? : <p>How can I retrieve data from Firebase and add to html page?
and, How can I open new html pages automatically to add the data I was retrieving it?
example:
I have this course from firbase:
<a href="https://i.stack.imgur.com/R6BZQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R6BZQ.png" alt="image"></a></p>
<p>this key I was pushing it .
and I want my website like this course :
<a href="https://i.stack.imgur.com/kg2cW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kg2cW.png" alt="courses image "></a></p>
<p>When I click this courses I want to see all data about this course like this :
<a href="https://i.stack.imgur.com/2sajb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2sajb.png" alt="description coursers "></a></p>
<p>Can anyone help me ?!
I won't like this style just I want to know how can i retrieve data and add it in new html pages in the same style in all courses .</p>
| 0debug |
TextField and Submit JavaFx for Hangman game : <p>How to make TextField that inputs letter than compares it with string? It's Hangman game.</p>
| 0debug |
False Iterations in Tparallel.for : I have a problem with number of iterations in Tparallel.for.
i have 100 folder and in each folder exist a file to be run (run.bat).
After run the out.txt file is created in folder.when i use Tparalle.for with 100 iterations, i recieve randomly 90 to 98 out.txt while it be 100.
my code is as below (Delphi XE7):
Tparallel.for(1,100.procedure(i:integer)
begin
setcurrentdir(path+'\test\'+inttostr(i));
winexec32andwait(pchar('run.bat'),0);
end);
can you help me?
| 0debug |
Intellij delete multiple local branches : <p>Using Intellij IDE (I have version 2017.3.5) is there a way to delete multiple local git branches at once</p>
| 0debug |
void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
BlockCompletionFunc *cb, void *opaque)
{
BlockAIOCB *acb;
acb = g_slice_alloc(aiocb_info->aiocb_size);
acb->aiocb_info = aiocb_info;
acb->bs = bs;
acb->cb = cb;
acb->opaque = opaque;
acb->refcnt = 1;
return acb;
}
| 1threat |
Understanding How to Store Web Push Endpoints : <p>I'm trying to get started implementing <a href="https://developer.mozilla.org/en-US/docs/Web/API/Push_API" rel="noreferrer">Web Push</a> in one of my apps. In the examples I have found, the client's endpoint URL is generally stored in memory with a comment saying something like:</p>
<blockquote>
<p>In production you would store this in your database...</p>
</blockquote>
<p>Since only registered users of my app can/will get push notifications, my plan was to store the endpoint URL in the user's meta data in my database. So far, so good.</p>
<p>The problem comes when I want to allow the same user to receive notifications on multiple devices. In theory, I will just add a new endpoint to the database for each device the user subscribes with. However, in testing I have noticed that endpoints change with each subscription/unsubscription on the <em>same device</em>. So, if a user subscribes/unsubscribes several times in a row on the same device, I wind up with several endpoints saved for that user (all but one of which are bad).</p>
<p>From <a href="http://blog.pushpad.xyz/2016/05/the-push-api-and-its-wild-unsubscription-mechanism/" rel="noreferrer">what I have read</a>, there is no reliable way to be notified when a user unsubscribes or an endpoint is otherwise invalidated. So, how can I tell if I should remove an old endpoint before adding a new one?</p>
<p>What's to stop a user from effectively mounting a denial of service attack by filling my db with endpoints through repeated subscription/unsubscription?</p>
<p>That's more meant as a joke (I can obvioulsy limit the total endpoints for a given user), but the problem I see is that when it comes time to send a notification, I will blast notification services with hundreds of notifications for invalid endpoints.</p>
<hr>
<p>I want the subscribe logic on my server to be:</p>
<ol>
<li>Check if we already have an endpoint saved for this user/device combo</li>
<li>If not add it, if yes, update it</li>
</ol>
<p>The problem is that I can't figure out how to reliably do #1.</p>
| 0debug |
def sort_matrix(M):
result = sorted(M, key=sum)
return result | 0debug |
static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt) {
const uint8_t *buf = avpkt->data;
SUNRASTContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p = &s->picture;
unsigned int w, h, depth, type, maptype, maplength, stride, x, y, len, alen;
uint8_t *ptr;
const uint8_t *bufstart = buf;
if (AV_RB32(buf) != 0x59a66a95) {
av_log(avctx, AV_LOG_ERROR, "this is not sunras encoded data\n");
return -1;
}
w = AV_RB32(buf+4);
h = AV_RB32(buf+8);
depth = AV_RB32(buf+12);
type = AV_RB32(buf+20);
maptype = AV_RB32(buf+24);
maplength = AV_RB32(buf+28);
if (type == RT_FORMAT_TIFF || type == RT_FORMAT_IFF) {
av_log(avctx, AV_LOG_ERROR, "unsupported (compression) type\n");
return -1;
}
if (type > RT_FORMAT_IFF) {
av_log(avctx, AV_LOG_ERROR, "invalid (compression) type\n");
return -1;
}
if (maptype & ~1) {
av_log(avctx, AV_LOG_ERROR, "invalid colormap type\n");
return -1;
}
buf += 32;
switch (depth) {
case 1:
avctx->pix_fmt = PIX_FMT_MONOWHITE;
break;
case 8:
avctx->pix_fmt = PIX_FMT_PAL8;
break;
case 24:
avctx->pix_fmt = (type == RT_FORMAT_RGB) ? PIX_FMT_RGB24 : PIX_FMT_BGR24;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid depth\n");
return -1;
}
if (p->data[0])
avctx->release_buffer(avctx, p);
if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
if (avctx->get_buffer(avctx, p) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = AV_PICTURE_TYPE_I;
if (depth != 8 && maplength) {
av_log(avctx, AV_LOG_WARNING, "useless colormap found or file is corrupted, trying to recover\n");
} else if (depth == 8) {
unsigned int len = maplength / 3;
if (!maplength) {
av_log(avctx, AV_LOG_ERROR, "colormap expected\n");
return -1;
}
if (maplength % 3 || maplength > 768) {
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
return -1;
}
ptr = p->data[1];
for (x=0; x<len; x++, ptr+=4)
*(uint32_t *)ptr = (buf[x]<<16) + (buf[len+x]<<8) + buf[len+len+x];
}
buf += maplength;
ptr = p->data[0];
stride = p->linesize[0];
len = (depth * w + 7) >> 3;
alen = len + (len&1);
if (type == RT_BYTE_ENCODED) {
int value, run;
uint8_t *end = ptr + h*stride;
x = 0;
while (ptr != end) {
run = 1;
if ((value = *buf++) == 0x80) {
run = *buf++ + 1;
if (run != 1)
value = *buf++;
}
while (run--) {
if (x < len)
ptr[x] = value;
if (++x >= alen) {
x = 0;
ptr += stride;
if (ptr == end)
break;
}
}
}
} else {
for (y=0; y<h; y++) {
memcpy(ptr, buf, len);
ptr += stride;
buf += alen;
}
}
*picture = s->picture;
*data_size = sizeof(AVFrame);
return buf - bufstart;
}
| 1threat |
JAVA: adding and removing elements from a defined variable within a class : I'm trying to get this class to run but I keep running into issues. I'm new to Java and not sure if I am doing this correctly. If someone could just help me out with the addition of elements to a list I can figure out the rest!
class ListPractice implements Testable {
def mylist = [4,5,6]
/**
* Adds a set of elements to the mylist variable
*
* @param elts The elements to be added
*/
def addToList(List elts) {
def newlist = getMylist()+List
return newlist
}
@Override
void testMe() {
addToList([7,8,9])
assert getMylist() == [4,5,6,7,8,9]
assert getMylist() == [7,8,9]
}
} | 0debug |
Add unique constraint to an existing PostgreSQL index : <p>I have an index in my PostgreSQL 9.3 database:</p>
<pre><code>CREATE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);
</code></pre>
<p>(from a schema migration using Ruby on Rails)</p>
<p>The index is present and made things faster. Now that I've cleaned up duplicate foos, I'd like to make this index unique:</p>
<pre><code>CREATE UNIQUE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);
</code></pre>
<p>Is there a way to alter the existing index and make it unique? Or is it easier/faster to delete the existing index and create a new, unique one?</p>
| 0debug |
Is it possible to run a Power Shell script in the remote computer? : For example,
I wish to run a IE Rest Script to a node present in the same network. | 0debug |
What does a function with 2 values on the right side mean? (Model -> Html msg) : <p>I have encountered that in the guide:</p>
<pre><code>viewValidation : Model -> Html msg
viewValidation model =
let
(color, message) =
if model.password == model.passwordAgain then
("green", "OK")
else
("red", "Passwords do not match!")
in
div [ style [("color", color)] ] [ text message ]
</code></pre>
<p>So this is a function, which takes the <code>Model</code>.
<code>Html msg</code> usually looks to me like we are calling the function <code>Html</code> with the argument <code>msg</code>.</p>
<p><code>msg</code> doesn't seem to play any role in any other part of the <code>viewValidation</code> function, though. So what does it mean and what is it for in this case?</p>
| 0debug |
static int dirac_probe(AVProbeData *p)
{
if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
return AVPROBE_SCORE_MAX;
else
return 0;
}
| 1threat |
PPC_OP(icbi)
{
do_icbi();
RETURN();
}
| 1threat |
Segmentation fault on properly allocated array : <p>I get a segmentation fault while assigning values to what looks to me a properly allocated array. Here is the code below:</p>
<pre><code>int SpV = L*L*L;
int V = SpV*T;
int M = 16;
int Ns = 2;
int Np = 10;
float *twopBuf = (float*) malloc(Np*Ns*V*M*2*sizeof(float));
if(twopBuf == NULL){
fprintf(stderr,"Cannot allocate twopBuf. Exiting\n");
exit(-1);
}
for(int bar=0;bar<Np;bar++)
for(int pr=0;pr<Ns;pr++)
for(int t=0;t<T;t++)
for(int v=0;v<SpV;v++)
for(int gm=0;gm<M;gm++){
int pos = 2*gm + 2*M*v + 2*M*SpV*t + 2*M*SpV*T*pr + 2*M*SpV*T*Ns*bar;
twopBuf[ 0 + pos ] = 1.0; // Set to 1.0 for
twopBuf[ 1 + pos ] = 1.0; // testing purposes
}
</code></pre>
<p>L and T are input, so when say <code>L = 32</code> and <code>T = 64</code> it runs fine. But for <code>L = 48</code> and <code>T = 96</code> I get segmentation fault after <code>bar</code> becomes 2 and before it becomes 3. If there wasn't enough memory to allocate <code>twopBuf</code> wouldn't I already get the error message?</p>
<p>I'm running this on the head node of a large supercomputer, if it makes a difference. Thanks.</p>
| 0debug |
I don't know how long to run the loop for : I'm working on this small code. It is giving the right output but I think the loop that I have on it could be improved.
Question 1: Given a string A consisting of n characters and a string B consisting of m characters, write a function that will return the number of times A must be stated such that B is a substring of the repeated A. If B can never be a substring, return -1.
Example:
A = ‘abcd’
B = ‘cdabcdab’
The function should return 3 because after stating A 3 times, getting ‘abcdabcdabcd’, B is now a substring of A.
You can assume that n and m are integers in the range [1, 1000].
This is my code:
#include "pch.h"
#include <iostream>
#include <string>
#include <fstream>
#include <istream>
using namespace std;
int findthestring(string A, string B)
{
string original = B;
int x;
int times = 1 ;
for (unsigned int i = 0; i < (10 * A.length());i++)
{
if (B.find(A) != string::npos)
{
x = 1;
cout << "String Found\n";
}
else
{
x = 0;
cout << "String not Found\n";
B = B + original;
times = times + 1;
}
}
return times;
}
main()
{
int times = findthestring("cdabcdab","abcd");
cout << "Number of Times: " << times;
}
On this code, I have the loop running for 3 times the length of A because I assumed if it runs for that long and a substring is not found, then I'm never going to find one. How can that be improved ? | 0debug |
This script in not compatible with jquery 3 : <p>This script works fine when I include jquery 1.8.3 but it won't work with jquery 3.2.1 what should I change? <a href="https://docs.sonhlab.com/protect-javascript-from-copying/" rel="nofollow noreferrer">here</a> the link where it comes from</p>
<pre><code> <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo of Protecting Javascript Code From Copying</title>
<!-- jQuery Library 1.8.3 -->
<script type="text/javascript" src="js/jquery/jquery.min.183.js"></script>
<script type="text/javascript">
$(window).load(function() {
$.ajax({
url: 'js/js.php',
type:'POST',
cache: false,
success: function(data){
if(data){
$('body').append(data);
}
}
});
})
</script>
</head>
<body>
Demo of Protecting Javascript Code From Copying.
</body>
</html>
</code></pre>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.