problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Android 8: Cleartext HTTP traffic not permitted : <p>I had reports from users with Android 8 that my app (that uses back-end feed) does not show content. After investigation I found following Exception happening on Android 8:</p>
<pre><code>08-29 12:03:11.246 11285-11285/ E/: [12:03:11.245, main]: Exception: IOException java.io.IOException: Cleartext HTTP traffic to * not permitted
at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:115)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:458)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
at com.deiw.android.generic.tasks.AbstractHttpAsyncTask.doConnection(AbstractHttpAsyncTask.java:207)
at com.deiw.android.generic.tasks.AbstractHttpAsyncTask.extendedDoInBackground(AbstractHttpAsyncTask.java:102)
at com.deiw.android.generic.tasks.AbstractAsyncTask.doInBackground(AbstractAsyncTask.java:88)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
</code></pre>
<p>(I've removed package name, URL and other possible identifiers)</p>
<p>On Android 7 and lower everything works, I do not set <code>android:usesCleartextTraffic</code> in Manifest (and setting it to <code>true</code> does not help, that is the default value anyway), neither do I use Network Security Information. If I call <code>NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted()</code>, it returns <code>false</code> for Android 8, <code>true</code> for older version, using the same apk file.
I tried to find some mention of this on Google info about Android O, but without success.</p>
| 0debug |
How to make a word of all letters in a list? (Python) : <p>How can I make a word from all the letters in a string?</p>
<p>For example:
(this is my list)</p>
<blockquote>
<p>["h","e","l","l","o"]</p>
</blockquote>
<p>And I want this as output:</p>
<blockquote>
<p>hello</p>
</blockquote>
| 0debug |
Find next item using Linq based on the last Index : I want to search for a string in a list of strings and get its index
List<string> list;
int index;
private void button1_Click(object sender, EventArgs e)
{
index = list.FindIndex(x => x.Contains(textBox1.Text));
if (index >= 0)
{
listView1.Items[index].Selected = true;
}
}
Now if the user hits the button another time, the index should be the next occurrence of the search item in the list. How can I do this based on the last index `index`? | 0debug |
Is it possible to code XHTML and HTML5 together? : <p>I have seen on several occasions that some companies are looking for web developers who know how to program in html5 and xhtml. I wonder why they specify xhtml. I do not know if these languages are used separately or if you can join strengths in the same file.</p>
<p>I'm sorry if my English is not very good and if my question is novice. Thank you</p>
| 0debug |
static int writev_f(BlockBackend *blk, int argc, char **argv)
{
struct timeval t1, t2;
bool Cflag = false, qflag = false;
int flags = 0;
int c, cnt;
char *buf;
int64_t offset;
int total = 0;
int nr_iov;
int pattern = 0xcd;
QEMUIOVector qiov;
while ((c = getopt(argc, argv, "CqP:")) != -1) {
switch (c) {
case 'C':
Cflag = true;
break;
case 'f':
flags |= BDRV_REQ_FUA;
break;
case 'q':
qflag = true;
break;
case 'P':
pattern = parse_pattern(optarg);
if (pattern < 0) {
return 0;
}
break;
default:
return qemuio_command_usage(&writev_cmd);
}
}
if (optind > argc - 2) {
return qemuio_command_usage(&writev_cmd);
}
offset = cvtnum(argv[optind]);
if (offset < 0) {
print_cvtnum_err(offset, argv[optind]);
return 0;
}
optind++;
nr_iov = argc - optind;
buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern);
if (buf == NULL) {
return 0;
}
gettimeofday(&t1, NULL);
cnt = do_aio_writev(blk, &qiov, offset, flags, &total);
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("writev failed: %s\n", strerror(-cnt));
goto out;
}
if (qflag) {
goto out;
}
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);
out:
qemu_iovec_destroy(&qiov);
qemu_io_free(buf);
return 0;
}
| 1threat |
void op_subo (void)
{
target_ulong tmp;
tmp = T0;
T0 = (int32_t)T0 - (int32_t)T1;
if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) {
CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
}
RETURN();
}
| 1threat |
Is there a python 3.x debugger like gdb : <p>I am wondering if there is a python debugger as powerful as gdb, for example at setting breakpoints, stepping into functions, and the like. I have been working with gdb in c and assembly and it has been excellent. SO is there a python debugger like so?</p>
| 0debug |
Checking if the first character of a string is lower case : <p>I am trying figure out how to change the character at position 0 of a string to uppercase if it is lower case. I am sorry if this is a dumb question, but it is stumping me. Something like this:</p>
<pre><code>String myString = "hello";
if( //string position 0 is lowercase )
{
char myChar = myString.charAt(0);
myChar.toUpperCase();
}
</code></pre>
<p>I think .toUpperCase() only works for strings though. Any help would be appreciated!</p>
| 0debug |
ListView item with checkbox - how to remove checkbox ripple effect? : <p>I have a ListView with item contains a checkbox and some other elements. The problem is when I click on the list item on Android 5+ device I have it looks like this:</p>
<p><a href="https://i.stack.imgur.com/jnctG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jnctG.png" alt="enter image description here"></a></p>
<p>I don't want to have ripple effect around the checkbox.
How can I acheive that?</p>
<p>Item XML code:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:gravity="center_vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/item_check"
android:checked="false"
android:focusable="false"
android:layout_marginRight="32dp"
android:clickable="false"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/item_title"
android:textAppearance="@android:style/TextAppearance.Medium"
android:maxLines="1"
android:lines="1"/>
</LinearLayout>
</code></pre>
| 0debug |
inline qemu_irq omap_inth_get_pin(struct omap_intr_handler_s *s, int n)
{
return s->pins[n];
}
| 1threat |
What Replaces Code Analysis in Visual Studio 2019? : <p>I'm toying with getting our team and projects ready for VS 2019. Right away, trying to set up Code Analysis for a new project, I find this:</p>
<p><a href="https://i.stack.imgur.com/deZRE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/deZRE.png" alt="enter image description here"></a></p>
<p>So, if this is deprecated (and apparently can't even be used, so I'm thinking "deprecated" really means "gone"), where are we supposed to set up our Rule Sets? Is there some other location, or perhaps an altogether new solution to the problem of style and code quality?</p>
| 0debug |
await Task.CompletedTask for what? : <p>I created UWP app with <a href="https://blogs.windows.com/buildingapps/2017/05/16/announcing-windows-template-studio/" rel="noreferrer">Windows Template Studio</a> that introduced at Build2017.</p>
<p>Below class is a part of generated code from it.</p>
<pre><code>public class SampleModelService
{
public async Task<IEnumerable<SampleModel>> GetDataAsync()
{
await Task.CompletedTask; // <-- what is this for?
var data = new List<SampleModel>();
data.Add(new SampleModel
{
Title = "Lorem ipsum dolor sit 1",
Description = "Lorem ipsum dolor sit amet",
Symbol = Symbol.Globe
});
data.Add(new SampleModel
{
Title = "Lorem ipsum dolor sit 2",
Description = "Lorem ipsum dolor sit amet",
Symbol = Symbol.MusicInfo
});
return data;
}
}
</code></pre>
<p>My question is, what is the purpose and reason of <code>await Task.CompletedTask;</code> code in here? It actually does not have <code>Task</code> result receiver from it.</p>
| 0debug |
API Access Control Check : <p>I'm accessing an external API from Javascript in my app and I get this error:</p>
<p>Failed to load <a href="http://www.myapp.com//api/v1/syndication/categories?output=json" rel="nofollow noreferrer">http://www.myapp.com//api/v1/syndication/categories?output=json</a>: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://local.myapp.com" rel="nofollow noreferrer">http://local.myapp.com</a>' is therefore not allowed access. The response had HTTP status code 400.</p>
<pre><code> function MakeAPIRequest(requestUrl, requestData, callback) {
$.ajax({
beforeSend: function(xhr){
xhr.setRequestHeader('Access-Control-Allow-Origin', 'http://local.myapp.com');
xhr.setRequestHeader('Token', apiKey);
},
type: "GET",
url: requestUrl,
data: requestData,
dataType: "json",
success: function(json){
callback(json);
}
});
}
</code></pre>
<p>Could be the API doesn't accept an "OPTIONS" request?
This is the server response:</p>
<p>{"error":"Bad Request - Only accepts get requests","code":1009}</p>
| 0debug |
static int iff_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
IffDemuxContext *iff = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
int ret;
int64_t pos = avio_tell(pb);
if (pos >= iff->body_end)
return AVERROR_EOF;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->codec_tag == ID_MAUD) {
ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));
} else {
ret = av_get_packet(pb, pkt, iff->body_size);
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
uint8_t *buf;
if (av_new_packet(pkt, iff->body_size + 2) < 0) {
return AVERROR(ENOMEM);
}
buf = pkt->data;
bytestream_put_be16(&buf, 2);
ret = avio_read(pb, buf, iff->body_size);
} else {
av_assert0(0);
}
if (pos == iff->body_pos)
pkt->flags |= AV_PKT_FLAG_KEY;
if (ret < 0)
return ret;
pkt->stream_index = 0;
return ret;
} | 1threat |
static int64_t expr_unary(Monitor *mon)
{
int64_t n;
char *p;
int ret;
switch(*pch) {
case '+':
next();
n = expr_unary(mon);
break;
case '-':
next();
n = -expr_unary(mon);
break;
case '~':
next();
n = ~expr_unary(mon);
break;
case '(':
next();
n = expr_sum(mon);
if (*pch != ')') {
expr_error(mon, "')' expected");
}
next();
break;
case '\'':
pch++;
if (*pch == '\0')
expr_error(mon, "character constant expected");
n = *pch;
pch++;
if (*pch != '\'')
expr_error(mon, "missing terminating \' character");
next();
break;
case '$':
{
char buf[128], *q;
target_long reg=0;
pch++;
q = buf;
while ((*pch >= 'a' && *pch <= 'z') ||
(*pch >= 'A' && *pch <= 'Z') ||
(*pch >= '0' && *pch <= '9') ||
*pch == '_' || *pch == '.') {
if ((q - buf) < sizeof(buf) - 1)
*q++ = *pch;
pch++;
}
while (qemu_isspace(*pch))
pch++;
*q = 0;
ret = get_monitor_def(®, buf);
if (ret < 0)
expr_error(mon, "unknown register");
n = reg;
}
break;
case '\0':
expr_error(mon, "unexpected end of expression");
n = 0;
break;
default:
errno = 0;
n = strtoull(pch, &p, 0);
if (errno == ERANGE) {
expr_error(mon, "number too large");
}
if (pch == p) {
expr_error(mon, "invalid char in expression");
}
pch = p;
while (qemu_isspace(*pch))
pch++;
break;
}
return n;
}
| 1threat |
static int mxg_update_cache(AVFormatContext *s, unsigned int cache_size)
{
MXGContext *mxg = s->priv_data;
unsigned int current_pos = mxg->buffer_ptr - mxg->buffer;
unsigned int soi_pos;
int ret;
if (current_pos > current_pos + cache_size)
return AVERROR(ENOMEM);
soi_pos = mxg->soi_ptr - mxg->buffer;
mxg->buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,
current_pos + cache_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!mxg->buffer)
return AVERROR(ENOMEM);
mxg->buffer_ptr = mxg->buffer + current_pos;
if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + soi_pos;
ret = avio_read(s->pb, mxg->buffer_ptr + mxg->cache_size,
cache_size - mxg->cache_size);
if (ret < 0)
return ret;
mxg->cache_size += ret;
return ret;
}
| 1threat |
Module Seaborn has no attribute '<any graph>' : <p>I am having trouble switching from ggplot2 into seaborn. Currently using Anaconda v. 4.5.8 and Python 3.6.3</p>
<p>Any graph I use cannot be found. For example I can take any code from seaborn's site and run:</p>
<pre><code>import matplotlib as plt
import seaborn as sns
sns.set(style="ticks")
dots = sns.load_dataset("dots")
# Define a palette to ensure that colors will be
# shared across the facets
palette = dict(zip(dots.coherence.unique(),
sns.color_palette("rocket_r", 6)))
# Plot the lines on two facets
sns.relplot(x="time", y="firing_rate",
hue="coherence", size="choice", col="align",
size_order=["T1", "T2"], palette=palette,
height=5, aspect=.75, facet_kws=dict(sharex=False),
kind="line", legend="full", data=dots)
sns.plt.show() #this was not on site code but tried it(plt.show() as referenced by other posts)
</code></pre>
<p>Error message:</p>
<pre><code> File "<ipython-input-8-893759310442>", line 13, in <module>
sns.relplot(x="time", y="firing_rate",
AttributeError: module 'seaborn' has no attribute 'relplot'
</code></pre>
<p>Looked at these posts( among others) </p>
<p>(1) AtributeError: 'module' object has no attribute 'plt' - Seaborn</p>
<p>(2) Seaborn ImportError: DLL load failed: The specified module could not be found</p>
<p>(3) ImportError after successful pip installation</p>
<p>(4) Error importing Seaborn module in Python</p>
<p>and tried the install/uninstall methods they described ( python -m pip install seaborn, uninstall seaborn/ reinstall - etc.) I did this in both conda using conda and cmd using pip.</p>
<p>I haven't spent much time with PATHs but here are screenshots:</p>
<p><a href="https://i.stack.imgur.com/Kj8ZT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Kj8ZT.png" alt="conda "></a></p>
<p><a href="https://i.stack.imgur.com/AXmCs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AXmCs.png" alt="pip"></a></p>
<p>Any ideas?</p>
<p>Many Thanks</p>
| 0debug |
Oracle virtual machine (Ubuntu) on windows 7 : <p>I have windows 7 with Oracle Virtualbox 5.0.4 and Ubuntun image 15.10. I notice when I disable VirtualBox DHCP, and make network settings as Bridge, I could ping or ssh from host to guest. But at this time, I could not download package or sudo apt-get install xxx from internet.</p>
<p>when I still disable VirtualBox, I make network as NAT, then I could download package, but could not ping from host to guest. </p>
<p>How could I do both ping from host to guest and download from internet at guest(virtual box)?</p>
<p>Why I am doing that? We have project using kafka storm, solr as backend. (log management system). Client side could be Eclipse in windows, why I could put kakfa storm solr in virtualbox or vagrant, so that saving developer setting up development environment time. </p>
| 0debug |
how do i select a value from drop down in selenium webdriver using python. drop down is very dynamic : how do i select a value from drop down in selenium web-driver using python. Drop down is very dynamic.
As per discussion with developer each value in drop down is a label.Before even I right click, the drop down vanishes.So not able to pick the xpath or framed xpath also not working. Am not able to see the drop down labels as well in HTMl. Values are not from DB it is from API.Only in UI am able to see the drop down values. Find below the screen shot.So how do i pick value from drop down for selenium python.
Screen shot when drop down is opened
[image when drop down is open][1]
Image when down is closed
[image when drop down is closed][2]
[1]: https://i.stack.imgur.com/axZH9.png
[2]: https://i.stack.imgur.com/aYtf1.png | 0debug |
Upload a base64 image with Firebase Storage : <p>I'm making this app where users can have a profile picture (but only one picture each). I got everything set up, but when the pictures are 2mb+, it takes some time to load and actually I just need the pictures to be 50kb or so (only small display of pictures, max 40 pixels). I made some code to put the images directly into the realtime database (convert to canvas and make them a 7kb base64 string). However, this is not really clean and it's better to use Firebase Storage. </p>
<p>Since the new update 3.3.0 you can upload Base64 formatted strings to Storage, using the putString() method. However, when I upload my canvas image (which starts with "data:image/jpeg;base64,"), I get the error:</p>
<p><strong>v {code: "storage/invalid-format", message: "Firebase Storage: String does not match format 'base64': Invalid character found", serverResponse: null, name: "FirebaseError"}</strong>.</p>
<p>Does this error occur because of string of the canvas image in the beginning? I've searched all over Stack, but I can't seem to find the answer. </p>
| 0debug |
Get all sourced functions : <p>In R, I am using <code>source()</code> to load some functions:</p>
<pre><code>source("functions.R")
</code></pre>
<p>Is it possible to get the list of all functions defined in this file? As function names. (Maybe <code>source()</code> itself can somehow return it?). </p>
<p>PS: The last resort would be to call <code>source()</code> second time like <code>local({ source(); })</code> and then do <code>ls()</code> inside and filter functions, but that's too complicated - is there easier and less clumsy solution?</p>
| 0debug |
static void m68k_cpu_reset(CPUState *s)
{
M68kCPU *cpu = M68K_CPU(s);
M68kCPUClass *mcc = M68K_CPU_GET_CLASS(cpu);
CPUM68KState *env = &cpu->env;
mcc->parent_reset(s);
memset(env, 0, offsetof(CPUM68KState, end_reset_fields));
#if !defined(CONFIG_USER_ONLY)
env->sr = 0x2700;
#endif
m68k_switch_sp(env);
cpu_m68k_set_ccr(env, 0);
env->pc = 0;
}
| 1threat |
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
AVCPBProperties *cpb_props;
int i, ret, format_supported;
mpv_encode_defaults(s);
switch (avctx->codec_id) {
case AV_CODEC_ID_MPEG2VIDEO:
if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
avctx->pix_fmt != AV_PIX_FMT_YUV422P) {
av_log(avctx, AV_LOG_ERROR,
"only YUV420 and YUV422 are supported\n");
return -1;
}
break;
case AV_CODEC_ID_MJPEG:
format_supported = 0;
if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
(avctx->color_range == AVCOL_RANGE_JPEG &&
(avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P)))
format_supported = 1;
else if (avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL &&
(avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P))
format_supported = 1;
if (!format_supported) {
av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
return -1;
}
break;
default:
if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
return -1;
}
}
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUVJ422P:
case AV_PIX_FMT_YUV422P:
s->chroma_format = CHROMA_422;
break;
case AV_PIX_FMT_YUVJ420P:
case AV_PIX_FMT_YUV420P:
default:
s->chroma_format = CHROMA_420;
break;
}
s->bit_rate = avctx->bit_rate;
s->width = avctx->width;
s->height = avctx->height;
if (avctx->gop_size > 600 &&
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(avctx, AV_LOG_ERROR,
"Warning keyframe interval too large! reducing it ...\n");
avctx->gop_size = 600;
}
s->gop_size = avctx->gop_size;
s->avctx = avctx;
if (avctx->max_b_frames > MAX_B_FRAMES) {
av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum "
"is %d.\n", MAX_B_FRAMES);
}
s->max_b_frames = avctx->max_b_frames;
s->codec_id = avctx->codec->id;
s->strict_std_compliance = avctx->strict_std_compliance;
s->quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0;
s->mpeg_quant = avctx->mpeg_quant;
s->rtp_mode = !!avctx->rtp_payload_size;
s->intra_dc_precision = avctx->intra_dc_precision;
s->user_specified_pts = AV_NOPTS_VALUE;
if (s->gop_size <= 1) {
s->intra_only = 1;
s->gop_size = 12;
} else {
s->intra_only = 0;
}
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
s->me_method = avctx->me_method;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
s->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE);
#if FF_API_MPV_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->border_masking != 0.0)
s->border_masking = avctx->border_masking;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
s->adaptive_quant = (s->avctx->lumi_masking ||
s->avctx->dark_masking ||
s->avctx->temporal_cplx_masking ||
s->avctx->spatial_cplx_masking ||
s->avctx->p_masking ||
s->border_masking ||
(s->mpv_flags & FF_MPV_FLAG_QP_RD)) &&
!s->fixed_qscale;
s->loop_filter = !!(s->avctx->flags & AV_CODEC_FLAG_LOOP_FILTER);
if (avctx->rc_max_rate && !avctx->rc_buffer_size) {
av_log(avctx, AV_LOG_ERROR,
"a vbv buffer size is needed, "
"for encoding with a maximum bitrate\n");
return -1;
}
if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) {
av_log(avctx, AV_LOG_INFO,
"Warning min_rate > 0 but min_rate != max_rate isn't recommended!\n");
}
if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) {
av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n");
return -1;
}
if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) {
av_log(avctx, AV_LOG_INFO, "bitrate above max bitrate\n");
return -1;
}
if (avctx->rc_max_rate &&
avctx->rc_max_rate == avctx->bit_rate &&
avctx->rc_max_rate != avctx->rc_min_rate) {
av_log(avctx, AV_LOG_INFO,
"impossible bitrate constraints, this will fail\n");
}
if (avctx->rc_buffer_size &&
avctx->bit_rate * (int64_t)avctx->time_base.num >
avctx->rc_buffer_size * (int64_t)avctx->time_base.den) {
av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n");
return -1;
}
if (!s->fixed_qscale &&
avctx->bit_rate * av_q2d(avctx->time_base) >
avctx->bit_rate_tolerance) {
av_log(avctx, AV_LOG_ERROR,
"bitrate tolerance too small for bitrate\n");
return -1;
}
if (s->avctx->rc_max_rate &&
s->avctx->rc_min_rate == s->avctx->rc_max_rate &&
(s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO) &&
90000LL * (avctx->rc_buffer_size - 1) >
s->avctx->rc_max_rate * 0xFFFFLL) {
av_log(avctx, AV_LOG_INFO,
"Warning vbv_delay will be set to 0xFFFF (=VBR) as the "
"specified vbv buffer is too large for the given bitrate!\n");
}
if ((s->avctx->flags & AV_CODEC_FLAG_4MV) && s->codec_id != AV_CODEC_ID_MPEG4 &&
s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P &&
s->codec_id != AV_CODEC_ID_FLV1) {
av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n");
return -1;
}
if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) {
av_log(avctx, AV_LOG_ERROR,
"OBMC is only supported with simple mb decision\n");
return -1;
}
if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) {
av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
return -1;
}
if (s->max_b_frames &&
s->codec_id != AV_CODEC_ID_MPEG4 &&
s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n");
return -1;
}
if ((s->codec_id == AV_CODEC_ID_MPEG4 ||
s->codec_id == AV_CODEC_ID_H263 ||
s->codec_id == AV_CODEC_ID_H263P) &&
(avctx->sample_aspect_ratio.num > 255 ||
avctx->sample_aspect_ratio.den > 255)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid pixel aspect ratio %i/%i, limit is 255/255\n",
avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
return -1;
}
if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME)) &&
s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
return -1;
}
if (s->mpeg_quant && s->codec_id != AV_CODEC_ID_MPEG4) {
av_log(avctx, AV_LOG_ERROR,
"mpeg2 style quantization not supported by codec\n");
return -1;
}
if ((s->mpv_flags & FF_MPV_FLAG_CBP_RD) && !avctx->trellis) {
av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
return -1;
}
if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) &&
s->avctx->mb_decision != FF_MB_DECISION_RD) {
av_log(avctx, AV_LOG_ERROR, "QP RD needs mbd=2\n");
return -1;
}
if (s->avctx->scenechange_threshold < 1000000000 &&
(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) {
av_log(avctx, AV_LOG_ERROR,
"closed gop with scene change detection are not supported yet, "
"set threshold to 1000000000\n");
return -1;
}
if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) {
if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
av_log(avctx, AV_LOG_ERROR,
"low delay forcing is only available for mpeg2\n");
return -1;
}
if (s->max_b_frames != 0) {
av_log(avctx, AV_LOG_ERROR,
"b frames cannot be used with low delay\n");
return -1;
}
}
if (s->q_scale_type == 1) {
if (avctx->qmax > 12) {
av_log(avctx, AV_LOG_ERROR,
"non linear quant only supports qmax <= 12 currently\n");
return -1;
}
}
if (avctx->slices > 1 &&
(avctx->codec_id == AV_CODEC_ID_FLV1 || avctx->codec_id == AV_CODEC_ID_H261)) {
av_log(avctx, AV_LOG_ERROR, "Multiple slices are not supported by this codec\n");
return AVERROR(EINVAL);
}
if (s->avctx->thread_count > 1 &&
s->codec_id != AV_CODEC_ID_MPEG4 &&
s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
s->codec_id != AV_CODEC_ID_MPEG2VIDEO &&
(s->codec_id != AV_CODEC_ID_H263P)) {
av_log(avctx, AV_LOG_ERROR,
"multi threaded encoding not supported by codec\n");
return -1;
}
if (s->avctx->thread_count < 1) {
av_log(avctx, AV_LOG_ERROR,
"automatic thread number detection not supported by codec,"
"patch welcome\n");
return -1;
}
if (!avctx->time_base.den || !avctx->time_base.num) {
av_log(avctx, AV_LOG_ERROR, "framerate not set\n");
return -1;
}
if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {
av_log(avctx, AV_LOG_INFO,
"notice: b_frame_strategy only affects the first pass\n");
avctx->b_frame_strategy = 0;
}
i = av_gcd(avctx->time_base.den, avctx->time_base.num);
if (i > 1) {
av_log(avctx, AV_LOG_INFO, "removing common factors from framerate\n");
avctx->time_base.den /= i;
avctx->time_base.num /= i;
}
if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO || s->codec_id == AV_CODEC_ID_MJPEG) {
s->intra_quant_bias = 3 << (QUANT_BIAS_SHIFT - 3);
s->inter_quant_bias = 0;
} else {
s->intra_quant_bias = 0;
s->inter_quant_bias = -(1 << (QUANT_BIAS_SHIFT - 2));
}
#if FF_API_QUANT_BIAS
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
s->intra_quant_bias = avctx->intra_quant_bias;
if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
s->inter_quant_bias = avctx->inter_quant_bias;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (avctx->codec_id == AV_CODEC_ID_MPEG4 &&
s->avctx->time_base.den > (1 << 16) - 1) {
av_log(avctx, AV_LOG_ERROR,
"timebase %d/%d not supported by MPEG 4 standard, "
"the maximum admitted value for the timebase denominator "
"is %d\n", s->avctx->time_base.num, s->avctx->time_base.den,
(1 << 16) - 1);
return -1;
}
s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
switch (avctx->codec->id) {
case AV_CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1;
s->low_delay = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY);
avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1);
break;
case AV_CODEC_ID_MPEG2VIDEO:
s->out_format = FMT_MPEG1;
s->low_delay = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY);
avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1);
s->rtp_mode = 1;
break;
case AV_CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
s->intra_only = 1;
if (!CONFIG_MJPEG_ENCODER ||
ff_mjpeg_encode_init(s) < 0)
return -1;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_H261:
if (!CONFIG_H261_ENCODER)
return -1;
if (ff_h261_get_picture_format(s->width, s->height) < 0) {
av_log(avctx, AV_LOG_ERROR,
"The specified picture size of %dx%d is not valid for the "
"H.261 codec.\nValid sizes are 176x144, 352x288\n",
s->width, s->height);
return -1;
}
s->out_format = FMT_H261;
avctx->delay = 0;
s->low_delay = 1;
s->rtp_mode = 0;
break;
case AV_CODEC_ID_H263:
if (!CONFIG_H263_ENCODER)
return -1;
if (ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format),
s->width, s->height) == 8) {
av_log(avctx, AV_LOG_INFO,
"The specified picture size of %dx%d is not valid for "
"the H.263 codec.\nValid sizes are 128x96, 176x144, "
"352x288, 704x576, and 1408x1152."
"Try H.263+.\n", s->width, s->height);
return -1;
}
s->out_format = FMT_H263;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_H263P:
s->out_format = FMT_H263;
s->h263_plus = 1;
s->h263_aic = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0;
s->modified_quant = s->h263_aic;
s->loop_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
s->unrestricted_mv = s->obmc || s->loop_filter || s->umvplus;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_FLV1:
s->out_format = FMT_H263;
s->h263_flv = 2;
s->unrestricted_mv = 1;
s->rtp_mode = 0;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_RV10:
s->out_format = FMT_H263;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_RV20:
s->out_format = FMT_H263;
avctx->delay = 0;
s->low_delay = 1;
s->modified_quant = 1;
s->h263_aic = 1;
s->h263_plus = 1;
s->loop_filter = 1;
s->unrestricted_mv = 0;
break;
case AV_CODEC_ID_MPEG4:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->low_delay = s->max_b_frames ? 0 : 1;
avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1);
break;
case AV_CODEC_ID_MSMPEG4V2:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 2;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_MSMPEG4V3:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 3;
s->flipflop_rounding = 1;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_WMV1:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 4;
s->flipflop_rounding = 1;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_WMV2:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 5;
s->flipflop_rounding = 1;
avctx->delay = 0;
s->low_delay = 1;
break;
default:
return -1;
}
avctx->has_b_frames = !s->low_delay;
s->encoding = 1;
s->progressive_frame =
s->progressive_sequence = !(avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT |
AV_CODEC_FLAG_INTERLACED_ME) ||
s->alternate_scan);
ff_mpv_idct_init(s);
if (ff_mpv_common_init(s) < 0)
return -1;
if (ARCH_X86)
ff_mpv_encode_init_x86(s);
ff_fdctdsp_init(&s->fdsp, avctx);
ff_me_cmp_init(&s->mecc, avctx);
ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
ff_pixblockdsp_init(&s->pdsp, avctx);
ff_qpeldsp_init(&s->qdsp);
if (s->msmpeg4_version) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
2 * 2 * (MAX_LEVEL + 1) *
(MAX_RUN + 1) * 2 * sizeof(int), fail);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix, 64 * 32 * sizeof(int), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix, 64 * 32 * sizeof(int), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
MAX_PICTURE_COUNT * sizeof(Picture *), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
MAX_PICTURE_COUNT * sizeof(Picture *), fail);
if (s->avctx->noise_reduction) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
2 * 64 * sizeof(uint16_t), fail);
}
if (CONFIG_H263_ENCODER)
ff_h263dsp_init(&s->h263dsp);
if (!s->dct_quantize)
s->dct_quantize = ff_dct_quantize_c;
if (!s->denoise_dct)
s->denoise_dct = denoise_dct_c;
s->fast_dct_quantize = s->dct_quantize;
if (avctx->trellis)
s->dct_quantize = dct_quantize_trellis_c;
if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)
s->chroma_qscale_table = ff_h263_chroma_qscale_table;
if (s->slice_context_count > 1) {
s->rtp_mode = 1;
if (avctx->codec_id == AV_CODEC_ID_H263 || avctx->codec_id == AV_CODEC_ID_H263P)
s->h263_slice_structured = 1;
}
s->quant_precision = 5;
ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, s->avctx->ildct_cmp);
ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->avctx->frame_skip_cmp);
if (CONFIG_H261_ENCODER && s->out_format == FMT_H261)
ff_h261_encode_init(s);
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_encode_init(s);
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version)
if ((ret = ff_msmpeg4_encode_init(s)) < 0)
return ret;
if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
&& s->out_format == FMT_MPEG1)
ff_mpeg1_encode_init(s);
for (i = 0; i < 64; i++) {
int j = s->idsp.idct_permutation[i];
if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 &&
s->mpeg_quant) {
s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
s->intra_matrix[j] =
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
} else {
s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
}
if (s->avctx->intra_matrix)
s->intra_matrix[j] = s->avctx->intra_matrix[i];
if (s->avctx->inter_matrix)
s->inter_matrix[j] = s->avctx->inter_matrix[i];
}
if (s->out_format != FMT_MJPEG) {
ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, avctx->qmin,
31, 1);
ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16,
s->inter_matrix, s->inter_quant_bias, avctx->qmin,
31, 0);
}
if (ff_rate_control_init(s) < 0)
return -1;
#if FF_API_ERROR_RATE
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->error_rate)
s->error_rate = avctx->error_rate;
FF_ENABLE_DEPRECATION_WARNINGS;
#endif
#if FF_API_NORMALIZE_AQP
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->flags & CODEC_FLAG_NORMALIZE_AQP)
s->mpv_flags |= FF_MPV_FLAG_NAQ;
FF_ENABLE_DEPRECATION_WARNINGS;
#endif
#if FF_API_MV0
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->flags & CODEC_FLAG_MV0)
s->mpv_flags |= FF_MPV_FLAG_MV0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_MPV_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->rc_qsquish != 0.0)
s->rc_qsquish = avctx->rc_qsquish;
if (avctx->rc_qmod_amp != 0.0)
s->rc_qmod_amp = avctx->rc_qmod_amp;
if (avctx->rc_qmod_freq)
s->rc_qmod_freq = avctx->rc_qmod_freq;
if (avctx->rc_buffer_aggressivity != 1.0)
s->rc_buffer_aggressivity = avctx->rc_buffer_aggressivity;
if (avctx->rc_initial_cplx != 0.0)
s->rc_initial_cplx = avctx->rc_initial_cplx;
if (avctx->lmin)
s->lmin = avctx->lmin;
if (avctx->lmax)
s->lmax = avctx->lmax;
if (avctx->rc_eq) {
av_freep(&s->rc_eq);
s->rc_eq = av_strdup(avctx->rc_eq);
if (!s->rc_eq)
return AVERROR(ENOMEM);
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (avctx->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc();
if (!s->tmp_frames[i])
return AVERROR(ENOMEM);
s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P;
s->tmp_frames[i]->width = s->width >> avctx->brd_scale;
s->tmp_frames[i]->height = s->height >> avctx->brd_scale;
ret = av_frame_get_buffer(s->tmp_frames[i], 32);
if (ret < 0)
return ret;
}
}
cpb_props = ff_add_cpb_side_data(avctx);
if (!cpb_props)
return AVERROR(ENOMEM);
cpb_props->max_bitrate = avctx->rc_max_rate;
cpb_props->min_bitrate = avctx->rc_min_rate;
cpb_props->avg_bitrate = avctx->bit_rate;
cpb_props->buffer_size = avctx->rc_buffer_size;
return 0;
fail:
ff_mpv_encode_end(avctx);
return AVERROR_UNKNOWN;
}
| 1threat |
How to install a specific version of MongoDB? : <p>I have yet to find a solution to the problem of installing a specific release of MongoDB. I've found several SO posts and other resources, to no avail. The official docs say:</p>
<pre><code>sudo apt-get install -y mongodb-org=3.0.12 mongodb-org-server=3.0.12 mongodb-org-shell=3.0.12 mongodb-org-mongos=3.0.12 mongodb-org-tools=3.0.12
</code></pre>
<p>But I get error messages saying those versions are not found. I've tried previous versions as well, but I get the same error output.</p>
| 0debug |
Check if list contains at least one of another - enums : <p>I have an enum :</p>
<pre><code>public enum PermissionsEnum {
ABC("Abc"),
XYZ("Xyz"),
....
}
</code></pre>
<p>And then I have a list of <strong>Enums</strong>. I want to check if my list has at least one of the enums. I currently check it by an iterative approach. I also know there is a way to do it by using <code>||</code> checking <code>list.contains(enum.ABC..) || list.contains(enum.XYZ) || ...</code>. </p>
<p>Is there a better way to do it?</p>
<p><a href="https://stackoverflow.com/questions/49747276/best-way-to-check-if-list-contains-at-least-one-of-an-enum">This question</a> shows how to do it if the objective list is a list of Strings, I want to get the matching status if the list is another list of enums. </p>
| 0debug |
C# Task.Result is Null : <p>I have following method which will eventually return some <code>Task<IList<DataModel>></code> but for now just returns <code>null</code>. I want to load result of this list to ObservableCollection in my ViewModel which is then displayed in a ListView.</p>
<p>But for now, I just want to return null and check that that is handled properly, so my ListView should show nothing in it as a result. I simmulate that by this code:</p>
<pre><code>public async Task<IList<DatatModel>> GetData(string id)
{
return await Task.FromResult<IList<DataModel>>(null);
}
</code></pre>
<p>I call the code above and will loop through result of my Task and load it all in my ObservableCollection like so:</p>
<pre><code>public void Initialize()
{
foreach (var data in GetData(Id).Result)
{
MyObservableCollection.Add(data);
}
}
</code></pre>
<p>However, my app just freezes. I think that above call to GetData(id).Result is problem because Result is null. How do I loop through this data and load it into my ObservableCollection if some data exist, or simply dont load anything if there is no data returned?</p>
| 0debug |
Creating UUIDs in Elixir : <p>What's a canonical way to generate UUIDs in Elixir? Should I necessarily use the library <a href="https://hex.pm/packages/uuid" rel="noreferrer">https://hex.pm/packages/uuid</a> or is there a built-in library? I better have less dependencies and do more work than vise versa, therefore if I can generate in Elixir with an external dependency, it'll better go with it.</p>
| 0debug |
how can i append a value to a tuple inside a list in Haskell? : For example, if I have a list of tuples such as [("a1", ["a2", "a3"]), ("b1", ["b2", "b3"])], and i want to add "a4" using "a1" "a4" as an input to update the list so that we get
[("a1", ["a2", "a3", "a4"]), ("b1", ["b2", "b3"])] as an output, how would I go about approaching this? I know that we can't literally "update" a tuple, and that I have to make an entirely new list | 0debug |
opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp)
{
OptsVisitor *ov = to_ov(v);
const QemuOpt *opt;
int64_t val;
opt = lookup_scalar(ov, name, errp);
if (!opt) {
return;
}
val = qemu_strtosz(opt->str ? opt->str : "", NULL);
if (val < 0) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
"a size value representible as a non-negative int64");
return;
}
*obj = val;
processed(ov, name);
}
| 1threat |
How can I get the path that the application is running with typescript? : <p>I am trying to create a desktop application with electron, angular2, typescript and neDB.In order to be able create a 'file' database with neDB I want the path to my project.How can I get this with typescript ? </p>
| 0debug |
Unit test SparseArray using JUnit (using JVM) : <p>I have an implementation which is using a Integer as key in HashMap. It is already unit tested using JUnit. But I want to change it to SparseArray which is more optimised version from Android. I am not sure how will it be unit tested using JUnit. Does anyone have a better way to do this?</p>
| 0debug |
python Compressing function within for loop : I am taking `l=['1','2','3','rt4','rt5']` as input and I am converting it into `l=[1,2,3,'rt4','rt5']` by following code:-
def RepresentsInt(s):
try:
int(s)
return True
except ValueError:
return False
l=['1','2','3','rt4','rt5']
l=[int(l[i]) if RepresentsInt(l[i]) else l[i] for i in range(0,len(l))]
I want to compress above code using python compression. I want to make code containing only ***two line***. *First line assign value to list* and *second line changing the list using my above mentioned code*. Can any one tell how to compress above code using python compression ?
Thanks in advance.
| 0debug |
angular-cli run command after ng build : <p>I am wondering how to extend ng build to run tasks after it has finished. </p>
<p>At the moment, my end goal is to copy my 'package.json' to the dist folder. </p>
<p>Something like this if I was using plain npm:</p>
<pre><code>"postbuild": "cpx ./package.json ./dist/",
</code></pre>
<p>I know in the angular-cli.json I can use "assets" to copy static files, but it does not work for files outside of src. So, I'm wondering if I can do the copy task after ng build completes. </p>
| 0debug |
Automatically run gulp tasks after saving some of javascript files in Visual Studio : <p>I have a folder in my asp.net project that contains some javascript files. Just before building project, they are minified and copied to "wwwroot" folder using gulp. It works great, but when I make some changes to any of javascript files, I have to restart entire project (to run tasks connected with building) or manually run tasks from "Task Runner Explorer".</p>
<p>It takes some time and it is quite irritating. Is it some way to run those tasks as soon as I save any of javascript files in this folder?</p>
| 0debug |
How to get a default string value from resources in SafeArgs? : <p>I'm just learning a Android NavigationUI, and try set a toolbar title using string default value from Safe Args. But have some problem about it.</p>
<p>'String resources' file:</p>
<pre><code> <string name="title_add_item">Add new items</string>
</code></pre>
<p>Navigation graph file. Set label as <code>Title: {title}</code> argument.</p>
<pre><code><navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/mainFragment">
<fragment
android:id="@+id/addNewItemFragment"
android:name="com.myapplication.AddNewItemFragment"
android:label="Title: {title}"
tools:layout="@layout/fragment_add_new_item" >
<argument
android:name="title"
app:argType="string"
android:defaultValue="@string/title_add_item" />
</fragment>
<fragment
android:id="@+id/mainFragment"
android:name="com.myapplication.MainFragment"
android:label="fragment_main"
tools:layout="@layout/fragment_main" >
<action
android:id="@+id/action_to_add_items_fragment"
app:destination="@id/addNewItemFragment" />
</fragment>
</code></pre>
<p></p>
<p>If <code>{app:argType="string"}</code> I got an error :</p>
<pre><code> Caused by: org.xmlpull.v1.XmlPullParserException: unsupported value 'Add new items' for string. You must use a "reference" type to reference other resources.
</code></pre>
<p>If <code>{app:argType="reference"}</code> app works, but i have a number in title (i think it's a resource id):</p>
<p><a href="https://i.stack.imgur.com/iWOIS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iWOIS.png" alt="enter image description here"></a></p>
<p>Of course I can assign the value of the toolbar title in the code by getting it from the arguments. But is it possible to change this code so that the title filled in correctly?</p>
| 0debug |
How to visualize a tensor summary in tensorboard : <p>I'm trying to visualize a tensor summary in tensorboard. However I can't see the tensor summary at all in the board. Here is my code:</p>
<pre><code> out = tf.strided_slice(logits, begin=[self.args.uttWindowSize-1, 0], end=[-self.args.uttWindowSize+1, self.args.numClasses],
strides=[1, 1], name='softmax_truncated')
tf.summary.tensor_summary('softmax_input', out)
</code></pre>
<p>where out is a multi-dimensional tensor. I guess there must be something wrong with my code. Probably I used the <code>tensor_summary</code> function incorrectly.</p>
| 0debug |
static void test_acpi_one(const char *params, test_data *data)
{
char *args;
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int i;
const char *device = "";
if (!g_strcmp0(data->machine, MACHINE_Q35)) {
device = ",id=hd -device ide-hd,drive=hd";
}
args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
params ? params : "", disk, device);
qtest_start(args);
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)
for (i = 0; i < TEST_CYCLES; ++i) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
test_acpi_rsdt_table(data);
test_acpi_fadt_table(data);
test_acpi_facs_table(data);
test_acpi_dsdt_table(data);
test_acpi_ssdt_tables(data);
if (iasl) {
test_acpi_asl(data);
}
qtest_quit(global_qtest);
g_free(args);
}
| 1threat |
static bool vexpress_cfgctrl_read(arm_sysctl_state *s, unsigned int dcc,
unsigned int function, unsigned int site,
unsigned int position, unsigned int device,
uint32_t *val)
{
if (dcc != 0 || position != 0 ||
(site != SYS_CFG_SITE_MB && site != SYS_CFG_SITE_DB1)) {
goto cfgctrl_unimp;
}
switch (function) {
case SYS_CFG_VOLT:
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_vsensors) {
*val = s->db_voltage[device];
return true;
}
if (site == SYS_CFG_SITE_MB && device == 0) {
*val = 3300000;
return true;
}
break;
case SYS_CFG_OSC:
if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) {
*val = s->mb_clock[device];
return true;
}
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_clocks) {
*val = s->db_clock[device];
return true;
}
break;
default:
break;
}
cfgctrl_unimp:
qemu_log_mask(LOG_UNIMP,
"arm_sysctl: Unimplemented SYS_CFGCTRL read of function "
"0x%x DCC 0x%x site 0x%x position 0x%x device 0x%x\n",
function, dcc, site, position, device);
return false;
}
| 1threat |
static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
{
TextConsole *s;
static int color_inited;
s = chr->opaque;
chr->chr_write = console_puts;
chr->chr_send_event = console_send_event;
s->out_fifo.buf = s->out_fifo_buf;
s->out_fifo.buf_size = sizeof(s->out_fifo_buf);
s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);
s->ds = ds;
if (!color_inited) {
color_inited = 1;
console_color_init(s->ds);
}
s->y_displayed = 0;
s->y_base = 0;
s->total_height = DEFAULT_BACKSCROLL;
s->x = 0;
s->y = 0;
if (s->console_type == TEXT_CONSOLE) {
s->g_width = ds_get_width(s->ds);
s->g_height = ds_get_height(s->ds);
}
s->hw_invalidate = text_console_invalidate;
s->hw_text_update = text_console_update;
s->hw = s;
s->t_attrib_default.bold = 0;
s->t_attrib_default.uline = 0;
s->t_attrib_default.blink = 0;
s->t_attrib_default.invers = 0;
s->t_attrib_default.unvisible = 0;
s->t_attrib_default.fgcol = COLOR_WHITE;
s->t_attrib_default.bgcol = COLOR_BLACK;
s->t_attrib = s->t_attrib_default;
text_console_resize(s);
if (chr->label) {
char msg[128];
int len;
s->t_attrib.bgcol = COLOR_BLUE;
len = snprintf(msg, sizeof(msg), "%s console\r\n", chr->label);
console_puts(chr, (uint8_t*)msg, len);
s->t_attrib = s->t_attrib_default;
}
qemu_chr_generic_open(chr);
if (chr->init)
chr->init(chr);
}
| 1threat |
firebase serve: From a locally served app, call locally served functions : <blockquote>
<p>How can I properly simulate a cloud function locally so that it has all data as when being invoked on firebase servers? (e.g. the <code>context.auth</code>)</p>
</blockquote>
<p>I am serving my project with <code>firebase serve</code>, it runs ok on <code>http://localhost:5000/</code>, however, my cloud functions are being called from <code>https://us-central1-<my-app>.cloudfunctions.net/getUser</code>. (The function is not even deployed.)</p>
<p>To avoid XY problem, I am trying to debug my function, but calling it from <strong>firebase shell</strong> results in <code>context.auth</code> being undefined, same when calling via <strong>postman</strong> from <code>http://localhost:5000/<my-app>/us-central1/getUser</code>.</p>
<p>This is my <code>./functions/src/index.ts</code> file</p>
<pre><code>import * as functions from 'firebase-functions'
import admin from 'firebase-admin'
import { inspect } from 'util'
admin.initializeApp()
export const getUser = functions.https.onCall((data, context) => {
console.debug('== getUser called =========================================')
console.log('getUser', inspect(data), inspect(context.auth))
return admin.database().ref('userRights/admin').child(context.auth.uid).once('value', snapshot => {
console.log(snapshot.val())
if (snapshot.val() === true) {
return 'OK'
// return {status: 'OK'}
} else {
return 'NOK'
// return {status: 'error', code: 401, message: 'Unauthorized'}
}
})
})
</code></pre>
<p>file <code>./firebase.functions.ts</code></p>
<pre><code>import { functions } from '~/firebase'
export const getUser = functions.httpsCallable('getUser')
</code></pre>
<p>Consumer <code>./src/pages/AdminPanel/index.tsx</code></p>
<pre><code>import { getUser } from '~/firebase.functions'
//...
getUser({myDataX: 'asd'}).then(response => console.debug('response', response))
</code></pre>
| 0debug |
multiset combinatorics generation : <p>I came across the following problem.</p>
<p>Is there a fast python built-in method to do the following:</p>
<pre><code>Input: sets {1,2}, {3,4}, {6,7,8}
Output: sets {1,3,6}, {1,3,7}, {1,3,8}, {1,4,6}, {1,4,7}, {1,4,8}, {2,3,6}, {2,3,7}, {2,3,8}, {2,4,6}, {2,4,7}, {2,4,8}
</code></pre>
<p>Thanks!</p>
| 0debug |
remote execute script on Linux : Wondering if it is possible to write a shell script like this, and if possible, any reference/sample implementation I can refer to? Thanks.
Step 1, scp a local file on a local box to a remote box ABC, may need input password or we can hard code password into script possible?
Step 2, remote execute a script on box ABC, and leverage the file uploaded in Step 1
Step 3, the output of Step 2 (which is on console/stdout) is redirected to local box.
regards,
Lin | 0debug |
MySQL Cannot Generate dynamic order number : i cannot generate order numbers using sub query.
here i give sample code which has few tables join.
here i add only main concept others i skipped. so i need to get order number from this query only.
i got correct result but some of the other join tables got Recline(order) is got null after changing the BookHeadId.
select @rhBookHeadId :=rh.BookHeadId ,rd.BookDetailId,@inrec:=0,(select RecLine from (SELECT spodno.BookDetailId, @inrec:= ifnull(@inrec,0)+1, @inrec as RecLine FROM tblBookDetail spodno where spodno.BookHeadId=@rhBookHeadId and spodno.isActive=1 order by spodno.BookDetailId asc ) temp where temp.BookDetailId=rd.BookDetailId) as RecLine from tblBookHead rh inner join tblBookDetail rh on rh.BookHeadId=rd.BookHeadId inner join ......;
| 0debug |
c++ pointer being freed was not allocated error when deleting pointer : <p>I am new to c++ , I want to remove the maximum value in linked list. But I got the error message. Here is the function that removing the max value and return the value removed. While running the line "delete cur", I got the error message. Somebody help me please! </p>
<pre><code>int removeMax(Dnode*& list) {
Dnode *p = list->next;
Dnode *cur = list;
int max = list->info;
while (p != NULL) {
if (p->info > max) {
max = p->info;
cur = p;
}
p = p->next;
}
if(cur->back == NULL && cur != NULL){
Dnode *after = cur->next;
after->back = NULL;
delete cur;
}
else if(cur->next == NULL && cur != NULL){
Dnode *pre = cur->back;
pre->next = NULL;
delete cur;
}
else{
Dnode *pre = cur->back;
Dnode *after = cur->next;
pre->next = cur->back;
after->back = pre;
delete cur;
}
return max;
</code></pre>
<p>}</p>
| 0debug |
Get random day, month, year, day of the week : <p>I need to create a random generated day of the week, date, month, year. The problem is that I don't know how to consider the 28 days in February, as well the 30-31 days in different months. Any help will be highly appreciated. Thank you</p>
| 0debug |
static inline void gen_jcc1(DisasContext *s, int b, int l1)
{
CCPrepare cc = gen_prepare_cc(s, b, cpu_T[0]);
gen_update_cc_op(s);
if (cc.mask != -1) {
tcg_gen_andi_tl(cpu_T[0], cc.reg, cc.mask);
cc.reg = cpu_T[0];
}
set_cc_op(s, CC_OP_DYNAMIC);
if (cc.use_reg2) {
tcg_gen_brcond_tl(cc.cond, cc.reg, cc.reg2, l1);
} else {
tcg_gen_brcondi_tl(cc.cond, cc.reg, cc.imm, l1);
}
}
| 1threat |
C language - death loop, maybe it's the scanf : scanf("%d",&jogadores[pos].dados[4][2]);
while(jogadores[pos].dados[4][2]<0){
printf("O valor não pode ser menor que 0, introduz novamente: ");
scanf("%d",&jogadores[pos].dados[4][2]);
};
Do you know what is wrong is this piece of code, I think it skips the first scanf because it keeps printing "O valor não pode ser menor que 0, introduz novamente: " | 0debug |
I need to run an exe on a site directly from it's database : <p>I have an exe that I need to run on a site, I have access to it's database, I need to upload it and run it directly from the site, so how can I make it execute like in windows and how do I make it to show on the site(javascript?)</p>
| 0debug |
static int mpeg_field_start(MpegEncContext *s){
AVCodecContext *avctx= s->avctx;
Mpeg1Context *s1 = (Mpeg1Context*)s;
if(s->first_field || s->picture_structure==PICT_FRAME){
if(MPV_frame_start(s, avctx) < 0)
return -1;
ff_er_frame_start(s);
s->current_picture_ptr->repeat_pict = 0;
if (s->repeat_first_field) {
if (s->progressive_sequence) {
if (s->top_field_first)
s->current_picture_ptr->repeat_pict = 4;
else
s->current_picture_ptr->repeat_pict = 2;
} else if (s->progressive_frame) {
s->current_picture_ptr->repeat_pict = 1;
}
}
*s->current_picture_ptr->pan_scan= s1->pan_scan;
}else{
int i;
if(!s->current_picture_ptr){
av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
return -1;
}
for(i=0; i<4; i++){
s->current_picture.data[i] = s->current_picture_ptr->data[i];
if(s->picture_structure == PICT_BOTTOM_FIELD){
s->current_picture.data[i] += s->current_picture_ptr->linesize[i];
}
}
}
#if CONFIG_MPEG_XVMC_DECODER
if(s->avctx->xvmc_acceleration)
ff_xvmc_field_start(s,avctx);
#endif
return 0;
}
| 1threat |
static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_slice) {
uint8_t *state= &h->cabac_state[ctx_base];
int mb_type;
if(intra_slice){
MpegEncContext * const s = &h->s;
const int mba_xy = h->left_mb_xy[0];
const int mbb_xy = h->top_mb_xy;
int ctx=0;
if( h->slice_table[mba_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mba_xy] ) )
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mbb_xy] ) )
ctx++;
if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 )
return 0;
state += 2;
}else{
if( get_cabac_noinline( &h->cabac, state ) == 0 )
return 0;
}
if( get_cabac_terminate( &h->cabac ) )
return 25;
mb_type = 1;
mb_type += 12 * get_cabac_noinline( &h->cabac, &state[1] );
if( get_cabac_noinline( &h->cabac, &state[2] ) )
mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice] );
mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] );
mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] );
return mb_type;
}
| 1threat |
PHP error ! how to resolve? :
Warning: require_once(C:\xampp\htdocs\phonoblog\system\core): failed to open stream: Permission denied in C:\xampp\htdocs\phonoblog\system\core\CodeIgniter.php on line 80
Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\phonoblog\system\core/' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\phonoblog\system\core\CodeIgniter.php on line 80 | 0debug |
In python what does the keyword "from" mean : <pre><code> from twilio.rest import Client
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
for sms in client.messages.list():
print(sms.to)
</code></pre>
<p>here what is the meaning of keyword "from"?</p>
| 0debug |
Determining odd and even numbers in python : <p>I have this code but whenever I enter any number odd or even it says it is even (the indents may not be correct here but that's not the cause as they are in the program)...</p>
<pre><code>import random
number1 = random.randint(1,6)
number2 = random.randint(1,6)
input("Ready for round one? Press enter key to begin!")
print("Player one, you rolled", number1, "and", number2)
number3 = number1 + number2
time.sleep(1)
print("This means your total is", number3)
time.sleep(1)
if number3 == ("1", "3", "5", "7", "9", "11"):
print("However, you rolled an odd. -5 points for you!")
p1score = number3 -5
else:
print("Also.... YOU GOT AN EVEN! +10 Points!")
p1score = number3 +10
time.sleep(1)
print("Player ones total is", p1score)
</code></pre>
| 0debug |
i didn't find "import org.springframework.jbdc.core.JsbcTemplate" : <p>i was searching for an hour to find a solution to my problem and i i'm using maven to pom.xml to find the library of this import org.springframework.jdbc.core.JdbcTemplate </p>
<p><strong>my pom.xml</strong> </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>test1</artifactId>
<name> Spring boots test</name>
<version>0.0.2-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
</properties>
</project></code></pre>
</div>
</div>
</p>
<p><em>the result was :-</em> </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< org.sample:test1 >--------------------------
[INFO] Building Spring boots test 0.0.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/spring-jdbc/3.2.1.RELEASE/spring-jdbc-3.2.1.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.626 s
[INFO] Finished at: 2018-10-21T08:41:16+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project test1: Could not resolve dependencies for project org.sample:test1:jar:0.0.2-SNAPSHOT: Failed to collect dependencies at org.springframework:spring-jdbc:jar:3.2.1.RELEASE: Failed to read artifact descriptor for org.springframework:spring-jdbc:jar:3.2.1.RELEASE: Could not transfer artifact org.springframework:spring-jdbc:pom:3.2.1.RELEASE from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException</code></pre>
</div>
</div>
</p>
| 0debug |
Decompress array of byte, unknown compression C# : In database I have blob column with chart data. I
The data was compressed, unfortunately I tried different solutions and none worked.
Here is example from database:
5a 49 50 08 52 00 00 78 9c ed 9c 0b 54 56 55 fe (...)
After converting to ascii, the first three characters are "ZIP" (the fourth character is always random which means to me this is the end of header) but I can't find this type of compression.
If needed I can send full size BLOB from db (~6500 bytes) | 0debug |
What are free floater code? : <p>which code can be considered free floaters ? I am java beginner and I want to know how can I figure out free floater code.</p>
<pre><code>public class Ocz2{
//Ocz2 obj = new Ocz2();
int a[] ;
a=new int[3];
}
</code></pre>
<p>In the above code, I am not able to figure out why it is throwing error on line 3. same declaration(line 3 & 4) doesn't throw any error inside method.
But from error and google search I got to know it is because free floater code.
Kindly help.</p>
| 0debug |
Python - unpacking kwargs in local function call : <p>I would like to pass a <code>dictionary</code>:</p>
<pre><code>items = {"artist": "Radiohead", "track": "Karma Police"}
</code></pre>
<p>as a parameter to this <code>function</code>:</p>
<pre><code>def lastfm_similar_tracks(**kwargs):
result = last.get_track(kwargs)
st = dict(str(item[0]).split(" - ") for item in result.get_similar())
print (st)
</code></pre>
<p>where <code>last.get_track("Radiohead", "Karma Police")</code> is the correct way of calling the local <code>function</code>.</p>
<p>and then call it like this:</p>
<pre><code>lastfm_similar_tracks(items)
</code></pre>
<p>I'm getting this error:</p>
<p><code>TypeError: lastfm_similar_tracks() takes exactly 0 arguments (1 given)</code></p>
<p>how should I correct this?</p>
| 0debug |
static uint64_t qvirtio_pci_config_readq(QVirtioDevice *d, uint64_t off)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
uint64_t val;
val = qpci_io_readq(dev->pdev, CONFIG_BASE(dev) + off);
if (qvirtio_is_big_endian(d)) {
val = bswap64(val);
}
return val;
}
| 1threat |
How I check if all required filled is selected before hide a div? : I want to hide a div and show another div I used jquery and the hide step is fine..
$('.next').click(function(){
$(this).parent().hide().next().show();//hide parent and show next
});
But the problem that the div can hide even if required field is not selected.. I have 5 dropdown select options in each div and must select any option for each dropdown before hide the div, so if the button next in the first div is clicked I must checked all required is selected then hide the first div and show the second div?? how I can do this check?
| 0debug |
static int ehci_state_fetchqtd(EHCIQueue *q)
{
EHCIqtd qtd;
EHCIPacket *p;
int again = 0;
get_dwords(q->ehci, NLPTR_GET(q->qtdaddr), (uint32_t *) &qtd,
sizeof(EHCIqtd) >> 2);
ehci_trace_qtd(q, NLPTR_GET(q->qtdaddr), &qtd);
p = QTAILQ_FIRST(&q->packets);
if (p != NULL) {
if (p->qtdaddr != q->qtdaddr ||
(!NLPTR_TBIT(p->qtd.next) && (p->qtd.next != qtd.next)) ||
(!NLPTR_TBIT(p->qtd.altnext) && (p->qtd.altnext != qtd.altnext)) ||
p->qtd.bufptr[0] != qtd.bufptr[0]) {
ehci_cancel_queue(q);
ehci_trace_guest_bug(q->ehci, "guest updated active QH or qTD");
p = NULL;
} else {
p->qtd = qtd;
ehci_qh_do_overlay(q);
}
}
if (!(qtd.token & QTD_TOKEN_ACTIVE)) {
if (p != NULL) {
ehci_cancel_queue(q);
p = NULL;
}
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = 1;
} else if (p != NULL) {
switch (p->async) {
case EHCI_ASYNC_NONE:
case EHCI_ASYNC_INITIALIZED:
ehci_set_state(q->ehci, q->async, EST_EXECUTE);
break;
case EHCI_ASYNC_INFLIGHT:
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
break;
case EHCI_ASYNC_FINISHED:
ehci_set_state(q->ehci, q->async, EST_EXECUTING);
break;
}
again = 1;
} else {
p = ehci_alloc_packet(q);
p->qtdaddr = q->qtdaddr;
p->qtd = qtd;
ehci_set_state(q->ehci, q->async, EST_EXECUTE);
again = 1;
}
return again;
}
| 1threat |
static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
AVFrame *p)
{
int i, j;
uint8_t *pd = p->data[0];
uint8_t *pd_last = s->last_picture.f->data[0];
uint8_t *pd_last_region = s->dispose_op == APNG_DISPOSE_OP_PREVIOUS ?
s->previous_picture.f->data[0] : s->last_picture.f->data[0];
int ls = FFMIN(av_image_get_linesize(p->format, s->width, 0), s->width * s->bpp);
if (s->blend_op == APNG_BLEND_OP_OVER &&
avctx->pix_fmt != AV_PIX_FMT_RGBA && avctx->pix_fmt != AV_PIX_FMT_ARGB) {
avpriv_request_sample(avctx, "Blending with pixel format %s",
av_get_pix_fmt_name(avctx->pix_fmt));
return AVERROR_PATCHWELCOME;
}
ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
if (s->dispose_op == APNG_DISPOSE_OP_PREVIOUS)
ff_thread_await_progress(&s->previous_picture, INT_MAX, 0);
for (j = 0; j < s->y_offset; j++) {
for (i = 0; i < ls; i++)
pd[i] = pd_last[i];
pd += s->image_linesize;
pd_last += s->image_linesize;
}
if (s->dispose_op != APNG_DISPOSE_OP_BACKGROUND && s->blend_op == APNG_BLEND_OP_OVER) {
uint8_t ri, gi, bi, ai;
pd_last_region += s->y_offset * s->image_linesize;
if (avctx->pix_fmt == AV_PIX_FMT_RGBA) {
ri = 0;
gi = 1;
bi = 2;
ai = 3;
} else {
ri = 3;
gi = 2;
bi = 1;
ai = 0;
}
for (j = s->y_offset; j < s->y_offset + s->cur_h; j++) {
for (i = 0; i < s->x_offset * s->bpp; i++)
pd[i] = pd_last[i];
for (; i < (s->x_offset + s->cur_w) * s->bpp; i += s->bpp) {
uint8_t alpha = pd[i+ai];
switch (alpha) {
case 0:
pd[i+ri] = pd_last_region[i+ri];
pd[i+gi] = pd_last_region[i+gi];
pd[i+bi] = pd_last_region[i+bi];
pd[i+ai] = 0xff;
break;
case 255:
break;
default:
pd[i+ri] = FAST_DIV255(alpha * pd[i+ri] + (255 - alpha) * pd_last_region[i+ri]);
pd[i+gi] = FAST_DIV255(alpha * pd[i+gi] + (255 - alpha) * pd_last_region[i+gi]);
pd[i+bi] = FAST_DIV255(alpha * pd[i+bi] + (255 - alpha) * pd_last_region[i+bi]);
pd[i+ai] = 0xff;
break;
}
}
for (; i < ls; i++)
pd[i] = pd_last[i];
pd += s->image_linesize;
pd_last += s->image_linesize;
pd_last_region += s->image_linesize;
}
} else {
for (j = s->y_offset; j < s->y_offset + s->cur_h; j++) {
for (i = 0; i < s->x_offset * s->bpp; i++)
pd[i] = pd_last[i];
for (i = (s->x_offset + s->cur_w) * s->bpp; i < ls; i++)
pd[i] = pd_last[i];
pd += s->image_linesize;
pd_last += s->image_linesize;
}
}
for (j = s->y_offset + s->cur_h; j < s->height; j++) {
for (i = 0; i < ls; i++)
pd[i] = pd_last[i];
pd += s->image_linesize;
pd_last += s->image_linesize;
}
return 0;
}
| 1threat |
void pcie_aer_root_init(PCIDevice *dev)
{
uint16_t pos = dev->exp.aer_cap;
pci_set_long(dev->wmask + pos + PCI_ERR_ROOT_COMMAND,
PCI_ERR_ROOT_CMD_EN_MASK);
pci_set_long(dev->w1cmask + pos + PCI_ERR_ROOT_STATUS,
PCI_ERR_ROOT_STATUS_REPORT_MASK);
} | 1threat |
matplotlib not displaying image on Jupyter Notebook : <p>I am using ubuntu 14.04 and coding in jupyter notebook using anaconda2.7 and everything else is up to date . Today I was coding, every thing worked fine. I closed the notebook and when I reopened it, every thing worked fine except that the image was not being displayed.</p>
<pre><code>%matplotlib inline
import numpy as np
import skimage
from skimage import data
from matplotlib import pyplot as plt
%pylab inline
img = data.camera()
plt.imshow(img,cmap='gray')
</code></pre>
<p>this is the code i am using, a really simple one but doesn't display the image</p>
<pre><code><matplotlib.image.AxesImage at 0xaf7017ac>
</code></pre>
<p>this is displayed in the output area
please help</p>
| 0debug |
SOS please, how to fix this code : ## SOS please, how to fix this code ##
----------
[Error] a function-definition is not allowed here before '}' token
[Error] expected '}' at the end of input
I don't know what's the problem with my code even though I've already checked the compiler errors
#include<iostream>
using namespace std;
struct name_type
{
string first,middle,last;
};
struct SD
{
name_type name;
float grade;
};
const int MAX_SIZE = 35;
int isFull(int last) {
if(last == MAX_SIZE - 1) {
return(1);
}
else {
return(0);
}
}
int isEmpty(int last) {
if(last < 0) {
return(1);
}
else {
return(0);
}
}
main()
{
SD SD2[MAX_SIZE];
int last = -1;
if(isEmpty(last))
{
cout << "List is empty\n";
}
for (int a=0; a <35; a++)
{
cout << "Enter first name:.....";
cin >> SD2[a].name.first;
cout << "Enter middle name:....";
cin >> SD2[a].name.middle;
cout << "Enter last name:......";
cin >> SD2[a].name.last;
cout << "Enter your grade:.....";
cin >> SD2[a].grade;
cout << '\n';
}
system("cls");
cout << "1 - Add";
cout << "2 - Delete";
cout << "3 - Search";
cout << "4 - Print";
cout << "5 - Exit";
string lname, fname;
int choice, search;
cin >> choice;
if(choice == 3) {
cin >> fname;
cin >> lname;
int index = search;
(SD2, lname, fname, last);
if (index > 0) {
cout << "ERROR\n";
}
else {
cout << "The grade of " << lname << "," << fname << "is " << SD2[index].grade;
}
}
int search(SD list [], string search_lname, string search_fname, int last) {
int index;
if(isEmpty(last)==1) {
cout << "\nThe list is Empty!";
}
else {
index = 0;
while(index!= last+1 && list[index].name.first != search_fname && list[index].name.last != search_lname) {
++index;
}
if(index != last + 1) {
cout << "\nItem Requested is Item" << index + 1 << ".";
return index;
}
else {
cout << "\n Item Does Not Exist.";
}
}
return -1; // list is empty or search item does not exist
}
} | 0debug |
static int net_init_nic(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
int idx;
NICInfo *nd;
const NetLegacyNicOptions *nic;
assert(opts->type == NET_CLIENT_OPTIONS_KIND_NIC);
nic = opts->u.nic;
idx = nic_get_free_idx();
if (idx == -1 || nb_nics >= MAX_NICS) {
error_setg(errp, "too many NICs");
return -1;
}
nd = &nd_table[idx];
memset(nd, 0, sizeof(*nd));
if (nic->has_netdev) {
nd->netdev = qemu_find_netdev(nic->netdev);
if (!nd->netdev) {
error_setg(errp, "netdev '%s' not found", nic->netdev);
return -1;
}
} else {
assert(peer);
nd->netdev = peer;
}
nd->name = g_strdup(name);
if (nic->has_model) {
nd->model = g_strdup(nic->model);
}
if (nic->has_addr) {
nd->devaddr = g_strdup(nic->addr);
}
if (nic->has_macaddr &&
net_parse_macaddr(nd->macaddr.a, nic->macaddr) < 0) {
error_setg(errp, "invalid syntax for ethernet address");
return -1;
}
if (nic->has_macaddr &&
is_multicast_ether_addr(nd->macaddr.a)) {
error_setg(errp,
"NIC cannot have multicast MAC address (odd 1st byte)");
return -1;
}
qemu_macaddr_default_if_unset(&nd->macaddr);
if (nic->has_vectors) {
if (nic->vectors > 0x7ffffff) {
error_setg(errp, "invalid # of vectors: %"PRIu32, nic->vectors);
return -1;
}
nd->nvectors = nic->vectors;
} else {
nd->nvectors = DEV_NVECTORS_UNSPECIFIED;
}
nd->used = 1;
nb_nics++;
return idx;
}
| 1threat |
RestSharp get full URL of a request : <p>Is there a way to get the full url of a RestSharp request including its resource and querystring parameters?</p>
<p>I.E for this request:</p>
<pre><code>RestClient client = new RestClient("http://www.some_domain.com");
RestRequest request = new RestRequest("some/resource", Method.GET);
request.AddParameter("some_param_name", "some_param_value", ParameterType.QueryString);
IRestResponse<ResponseData> response = client.Execute<ResponseData>(request);
</code></pre>
<p>I would like to get the full request URL:</p>
<pre><code>http://www.some_domain.com/some/resource?some_param_name=some_param_value
</code></pre>
| 0debug |
use mat-datepicker directly without input : <p>I want to put the datepicker in a permanent sidebar always visible and not dependent on an input, is this possible?
I imagined that just putting the component and adding opened = true could leave the datepicker inside a box always visible.</p>
| 0debug |
Writing a void as a parameter : <p>(I'm a bit new to programming so if this doesn't make sense just say so)</p>
<p>Let's say that a method takes in a void as parameter. Ex: </p>
<pre><code>method(anotherMethod);
</code></pre>
<p>and I want to write the void inside of the brackets rather than writing the void and putting the name inside so rather than </p>
<pre><code>void theVoid() {
doSomethingHere;
}
</code></pre>
<p>and then calling it like</p>
<pre><code>method(theVoid());
</code></pre>
<p>I wanted to do</p>
<pre><code>method({ doSomethingHere; })
</code></pre>
<p>directly, is it possible to do so?</p>
| 0debug |
static int usb_wacom_handle_control(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data)
{
USBWacomState *s = (USBWacomState *) dev;
int ret;
ret = usb_desc_handle_control(dev, request, value, index, length, data);
if (ret >= 0) {
return ret;
}
ret = 0;
switch (request) {
case DeviceRequest | USB_REQ_GET_STATUS:
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
data[1] = 0x00;
ret = 2;
break;
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 0;
} else {
goto fail;
}
ret = 0;
break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 1;
} else {
goto fail;
}
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
data[0] = 1;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
data[0] = 0;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
ret = 0;
break;
case WACOM_SET_REPORT:
if (s->mouse_grabbed) {
qemu_remove_mouse_event_handler(s->eh_entry);
s->mouse_grabbed = 0;
}
s->mode = data[0];
ret = 0;
break;
case WACOM_GET_REPORT:
data[0] = 0;
data[1] = s->mode;
ret = 2;
break;
case HID_GET_REPORT:
if (s->mode == WACOM_MODE_HID)
ret = usb_mouse_poll(s, data, length);
else if (s->mode == WACOM_MODE_WACOM)
ret = usb_wacom_poll(s, data, length);
break;
case HID_GET_IDLE:
ret = 1;
data[0] = s->idle;
break;
case HID_SET_IDLE:
s->idle = (uint8_t) (value >> 8);
ret = 0;
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat |
JavaScript hardware access : <p>I know difference between browser Js and NodeJS. I'm looking at this trezor.io bitcoin hardware wallet. How are they managing to send information from their drive to javascript on website only trough USB port ? (device has no WiFi or Bluetooth) ? </p>
| 0debug |
static inline int64_t gb_get_v(GetBitContext *gb)
{
int64_t v = 0;
int bits = 0;
while(get_bits1(gb) && bits < 64-7){
v <<= 7;
v |= get_bits(gb, 7);
bits += 7;
}
v <<= 7;
v |= get_bits(gb, 7);
return v;
}
| 1threat |
How to design a calendar reminder/alert system : <p>I have a calendar system in my web app. We need to implement reminders.</p>
<p>Are there any reminder/alert patterns or system designs, or best practices? If so or if not, what might be some ways of achieving this?</p>
<p><strong>Design Considerations</strong></p>
<ol>
<li>Need to be able to cancel/prevent reminders if the calendar event is deleted or changed, or the user turns off the reminder for that event. So we can't just fire and forget them in a queue or something.</li>
<li>The reminders can be X amount of time before the event, X being set in the calendar event settings</li>
<li>Reminders don't need to be super accurate (to the second or even minute). +- 5 minutes is fine.</li>
<li>Don't want to pre-calculate reminders because then the maintenance becomes a nightmare as calendar events change, especially where recurring events are concerned.</li>
</ol>
<p><strong>So far my design is something like this:</strong></p>
<ol>
<li>Have a scheduled job run every 10 minutes.</li>
<li>The job grabs all possible relevant events and calculates potential occurrences for the next 10 minute interval (filtering out events that don't have a reminder set).</li>
<li>Job calls an API endpoint in my server side that kicks of a front end notification and an email reminder for all relevant parties.</li>
</ol>
<p>But maybe there are more elegant patterns than this? Something already established? Or some tool in azure etc.?</p>
<p>Our stack is .net and azure.</p>
| 0debug |
drag and drop is not properly placing the elements in selenium : I am using the below code to drag and drop the elements in an application.But most of the times it is dropping to the different section of the page.And in rarely its placing the element to the correct destination.The issue is coming when moving the third element to its destination. From third element onwards, the element is getting dropped in different path.The xpath of the all the three elements are exactly same.I am dragging 7 elements totally.From 4th element onwards the area of the destination is changing.So the issue is the third element is getting moved to the area where the 4th element should go.
The code upto 4th element is updated below
WebElement element1 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/div/table/tbody/tr/td[2]/div/div/button"));
WebElement target1 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[2]/td[1]/div"));
(new Actions(driver)).dragAndDrop(element1, target1).perform();
Thread.sleep(7000);
WebElement element2= driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/div/table/tbody/tr/td[2]/div/div/button"));
WebElement target2 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[2]/td[1]/div"));
(new Actions(driver)).dragAndDrop(element2, target2).perform();
Thread.sleep(7000);
WebElement element3= driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/div/table/tbody/tr/td[2]/div/div/button"));
WebElement target3 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[2]/td[1]/div"));
(new Actions(driver)).dragAndDrop(element3, target3).perform();
Thread.sleep(7000);
WebElement element4 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/div/table/tbody/tr/td[2]/div/div/button"));
WebElement target4 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/div[5]/div[3]/div/div[3]/div/div/div/table/tbody/tr[2]/td[2]/div"));
(new Actions(driver)).dragAndDrop(element4, target4).perform();
Thread.sleep(7000);
| 0debug |
Which ad network do these guys use? : I've been watching these guys and their ad on the lock screen, i'd like to know which ad network they're using, is there a way to find this out?
please let me know as this would really help me make an informed decision.
[enter image description here][1]
[1]: http://i.stack.imgur.com/J849H.png | 0debug |
Clear input fields aftersubitting AJAX to PHP : This is a password recovery form through HTML page that post data to PHP file via AJAX. Everything is okay with the code except once submitted and response recived, form input fields don't clear. I have been searching the web for the past 4 hours and found too many code lines to do so but none of them seems to work. plz help me in this matter :) have a good day.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$(function() {
/////////////////////////////////////////////////////////'Form ID' & 'Element Name' /////////////////////////////////////////
// Get the form.
var form = $('#emailform');
// Get the messages div.
var formMessages = $('#formresults');
// Set up an event listener for the contact form.
$(form).submit(function(e) {
// Stop the browser from submitting the form.
e.preventDefault();
// Serialize the form data.
var formData = $(form).serialize();
// Submit the form using AJAX.
$.ajax({
type: 'POST',
url: $(form).attr('action'),
data: formData
})
.done(function(response) {
// Make sure that the formMessages div has the 'success' class.
$(formMessages).removeClass('error');
$(formMessages).addClass('success');
// Set the message text.
$(formMessages).text(response);
// Clear the form.
// $('#email1').val('');
//var email = $('input[name=#email]').val("");
//document.getElementById("emailform").reset();
//$('#emailform')[0].reset();
//$('input:text').val('');
//$('#emailform input[type=text]').val('');
//setTimeout(function(){
//$('input,textarea','#emailform').val(''); //clearing inputs
//},1);
})
.fail(function(data) {
// Make sure that the formMessages div has the 'error' class.
$(formMessages).removeClass('success');
$(formMessages).addClass('error');
// Set the message text.
if (data.responseText !== '') {
$(formMessages).text(data.responseText);
} else {
$(formMessages).text('Oops! An error occured and your message could not be sent.');
}
});
});
});
<!-- language: lang-html -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AJAX Contact Form Demo</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="page-wrapper">
<h1>AJAX Contact Form Demo</h1>
<div id="formresults"></div>
<form id="emailform" name="emailform1" method="post" action="exa.php">
<table align="center">
<tr><td><div class="input-append"><input type="text" name="email" id="email1" class="input-xlarge" placeholder="email" maxlength="100" /><span class="add-on"><li class="icon-envelope"></li></span></div></td></tr>
</table>
<!-- <hr /> -->
<center><input type="submit" name="Forget" id="btn" class="btn btn-primary Loading-btn" value="ٍSend" data-loading-text="Sending ..." /></center>
</form>
</div>
<script src="ajax/jquery-2.1.0.min.js"></script>
<script src="ajax/app.js"></script>
</body>
</html>
<!-- end snippet -->
<?php
// Get Access to data base
// Only process POST reqeusts.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form fields and remove whitespace.
$email = $_POST["email"];
// Check that data was sent to the mailer.
if ( empty($email) ) {
// Set a 400 (bad request) response code and exit.
http_response_code(100);
echo "BLABLABLA.";
exit;
}
if ( !filter_var($email, FILTER_VALIDATE_EMAIL) ) {
// Set a 400 (bad request) response code and exit.
http_response_code(200);
echo "BLABLABLA.";
exit;
}
if (@mysql_num_rows(mysql_query("SELECT `id` FROM `accounts` WHERE `email`='$email'")) < 1) {
// Set a 400 (bad request) response code and exit.
http_response_code(300);
echo "BLABLABLA.";
exit;
}
$row_user = @mysql_fetch_array(mysql_query("SELECT * FROM `accounts` WHERE `email`='$email'"));
////////////////////////////
$password = $row_user['pass'];
$to = $row_user['email'];
$subject = "Your Recovered Password";
$message = "Please use this password to login: " . $password;
$headers = "From : XXX@XXX.XXX";
// Send the email.
if (mail($to, $subject, $message, $headers)) {
// Set a 200 (okay) response code.
http_response_code(400);
echo "BLABLABLA.";
} else {
// Set a 500 (internal server error) response code.
http_response_code(500);
echo "BLABLABLA.";
}
} else {
// Not a POST request, set a 403 (forbidden) response code.
http_response_code(600);
echo "There was a problem with your submission, please try again.";
}
?>
| 0debug |
static void mirror_read_complete(void *opaque, int ret)
{
MirrorOp *op = opaque;
MirrorBlockJob *s = op->s;
aio_context_acquire(blk_get_aio_context(s->common.blk));
if (ret < 0) {
BlockErrorAction action;
bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, true, -ret);
if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) {
s->ret = ret;
}
mirror_iteration_done(op, ret);
} else {
blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
0, mirror_write_complete, op);
}
aio_context_release(blk_get_aio_context(s->common.blk));
}
| 1threat |
how to hide the black lines betwen my ListView rows(picture included) : Hey how can i hide the dark line on the ground of my row in the listView.
Or to make the line smaller is also ok. Thank you all.
[picture with line][1]
[1]: https://i.stack.imgur.com/hE2uN.jpg | 0debug |
Dropping pins on an IOS map with MapKit? : <p>I'm trying to learn to use MapKit by creating a sample project; I want to create a map that has all the locations of a particular chain of restaurants with a pin dropped on their coordinate locations (which I have).</p>
<p>The region for this area is Boston, MA and I have a working program of the map with user location shown as a blue dot.</p>
<p>I have been trying to sift through the documentation for MapKit but I can't figure out what I would need to do in order to start the process of placing the pins on all of the store locations. </p>
| 0debug |
int av_buffersink_poll_frame(AVFilterContext *ctx)
{
BufferSinkContext *buf = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
av_assert0(!strcmp(ctx->filter->name, "buffersink") || !strcmp(ctx->filter->name, "abuffersink"));
return av_fifo_size(buf->fifo)/sizeof(AVFilterBufferRef *) + ff_poll_frame(inlink);
}
| 1threat |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
Javascript load each file in folder : <p>In my project I have got a folder with .csv files. I dont know how much - it could be 1, 0 or even 50. How can I load all of them with javascript or with some javascript plugin?</p>
| 0debug |
Mongo is unable to start : <p>I'm trying to start mongo uin windows10 by type: <code>mongo</code> in cmd.</p>
<p>I am getting this error: </p>
<pre><code>C:\Users\Itzik>mongo
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
2016-12-26T19:00:16.604+0200 W NETWORK [main] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2016-12-26T19:00:16.605+0200 E QUERY [main] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:234:13
@(connect):1:6
exception: connect failed
C:\Users\Itzik>
</code></pre>
<p>I have opened port 27017 in the firewall,
and restart mongo's services
and it still dont work.</p>
<p>what could it be?</p>
| 0debug |
How do i get the first line of a txt file and set it as a %variable% in Batch? : <p>I would like to send a number to file.txt as a temporary storage for another variable, which can easily be done. I just can't work out what to use to extract the first line of file.txt (which is a number ranging 1-100000) and set it as a %variable% in my running batch script.</p>
<p>So by the end of it I should be able to do echo %first-line-of-file.txt% and it'll print x</p>
<p>Any ideas on how to make this work is much appreciated </p>
| 0debug |
How can I create sections on my app? [ANDROID] : I want to improve my new app so I have question for you. How can I make sections in my app, in Navigation Drawer?
[There's a photo if you don't understand what's in my mind. This photo is from Google Play][1]
[1]: http://i.stack.imgur.com/65r7O.png
There's my activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_pagrindinis"
android:icon="@drawable/ic_menu_pagrindinis"
android:title="Pagrindinis" />
<item
android:id="@+id/nav_soctinklai"
android:icon="@drawable/ic_menu_soctinklai"
android:title="Gimnazijos socialiniai tinklai" />
<item
android:id="@+id/nav_dienynas"
android:icon="@drawable/ic_menu_dienynas"
android:title="El. dienynas" />
<item
android:id="@+id/nav_naudingosnuor"
android:icon="@drawable/ic_menu_naudingosnuor"
android:title="Naudingos nuorodos"/>
<item
android:id="@+id/nav_kontaktai"
android:icon="@drawable/ic_menu_kontaktai"
android:title="Kontaktinė informacija" />
</group>
</menu>
And there's an excerpt from MainActivity.java
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_pagrindinis) {
//Set the fragment initially
PagrindinisFragment fragment = new PagrindinisFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
// Handle the camera action
} else if (id == R.id.nav_soctinklai) {
//Set the fragment initially
SocTinklaiFragment fragment = new SocTinklaiFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
} else if (id == R.id.nav_dienynas) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://sistema.tamo.lt"));
startActivity(i);
} else if (id == R.id.nav_naudingosnuor) {
} else if (id == R.id.nav_kontaktai) {
KontaktaiFragment fragment = new KontaktaiFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
I want to make section in this place
android:id="@+id/nav_naudingosnuor"
Thanks for your support, mates! :) | 0debug |
Is it possible to log in facebook account without an alert warning if login alerts are already enabled? : <p>Recently someone of my friends tells me that he logged in my facebook account without knowing my password and without login alerts warning, he told me that he hacked my facebook account with some techniques. so my question: Is it possible to login into facebook account which facebook account owner allows unexpected logs alerts without him knowing that?</p>
| 0debug |
Java, the clipboard code does not work, : <p>The program should analyze the clipboard for the presence in it of a 5-digit number starting with one. The problem is that when copying the text I do not answer <code>if (clipboardContent.length () == 5)</code> the program stops working.</p>
<pre><code>import java.awt.*;
import java.awt.datatransfer.*;
import java.io.IOException;
public class drob implements FlavorListener {
private static Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
public static void main(String[] args) throws InterruptedException {
clipboard.addFlavorListener(new drob());
// fall asleep for 100 seconds, otherwise the program will immediately end
Thread.sleep(100 * 1000);
}
@Override
public void flavorsChanged(FlavorEvent event) {
try {
String clipboardContent = (String) clipboard.getData(DataFlavor.stringFlavor);
handleClipboardContent(clipboardContent);
} catch (UnsupportedFlavorException | IOException e) {
// TODO handle the error
e.printStackTrace();
}
}
private void handleClipboardContent(String clipboardContent) {
// check if the string satisfies condition
// for example, check that the length of the string is five
if (clipboardContent.length() == 5) {
System.out.println(clipboardContent);
}
}
}
</code></pre>
| 0debug |
Why choosing Google Kubernetes Engine instead of Google AppEngine? : <p>As far as I can see, GKE seems to be slighty more complex to configure and deploy an application (using Kubernetes direct files or Helm Charts or something else ?). Furthermore it seems to have no better pod failure detection or better performances ?</p>
<p>Why should we use GKE whereas there is GAE which only needs dispatch.yaml, app.yaml files and gcloud cli to deploy ?</p>
<p>Is there any technical or financial feedback against GAE ?</p>
<p>Finally, how can we make a choice between GKE and GAE ? What whould be the reason to not choose GAE ?</p>
| 0debug |
int64_t bdrv_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
Coroutine *co;
BdrvCoGetBlockStatusData data = {
.bs = bs,
.base = base,
.file = file,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.pnum = pnum,
.done = false,
};
if (qemu_in_coroutine()) {
bdrv_get_block_status_above_co_entry(&data);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);
qemu_coroutine_enter(co, &data);
while (!data.done) {
aio_poll(aio_context, true);
}
}
return data.ret;
}
| 1threat |
Json.NET Deserializing System.NullReferenceException : <p>I want to write all names of each library in textBox1 from a .json file. So far I have this code:</p>
<pre><code>client.DownloadFile("https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/1.8.8.json", "1.8.8.json");
Library libs = JsonConvert.DeserializeObject<Library>(File.ReadAllText("1.8.8.json"));
foreach (var item in libs.name) { textBox1.Text += item; }
public class Library { public string name { get; set; } }
</code></pre>
<p>It makes no errors, but when I run it the error is System.NullReferenceException. Can you please tell me what am I doing wrong?</p>
| 0debug |
Javscript, How to get sum of multiple fields that have same id and get the value of each summation : Okay so i have a loop dynamic input field ID but i will show how it look likes.
the output is like this
`<input type="text" id="sp_criteria1">` value -> 20
`<input type="text" id="sp_criteria1">` value -> 25
i need the sum of this ^ = 45
`<input type="text" id="sp_criteria3">` value -> 20
`<input type="text" id="sp_criteria3">` value -> 25
i need the sum of this ^ = 45
`<input type="text" id="sp_criteria5">` value -> 20
`<input type="text" id="sp_criteria5">` value -> 25
i need the sum of this ^ = 45
`<input type="text" id="sp_criteria6">` value -> 20
`<input type="text" id="sp_criteria6">` value -> 25
`<input type="text" id="sp_criteria6">` value -> 20
i need the sum of this ^ = 65
so i need to get those sum at the same time 45 45 45 65
| 0debug |
JavaScript ''x'' is not a function : I'm just recently starting with JavaScript and I couldn't figure out what is wrong with my function.
It supposed to put out: "This is true" but it doesn't display anything.
[Image of code][1]
The Console is saying that randomQuestion is not defined.
I hoped to get a answer on here.
[1]: https://i.stack.imgur.com/RFEkn.png | 0debug |
static inline void gen_ins(DisasContext *s, int ot)
{
gen_string_movl_A0_EDI(s);
gen_op_movl_T0_0();
gen_op_st_T0_A0(ot + s->mem_index);
gen_op_mov_TN_reg(OT_WORD, 1, R_EDX);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[1]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_helper_1_1(helper_in_func[ot], cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(ot + s->mem_index);
gen_op_movl_T0_Dshift[ot]();
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_addq_EDI_T0();
} else
#endif
if (s->aflag) {
gen_op_addl_EDI_T0();
} else {
gen_op_addw_EDI_T0();
}
}
| 1threat |
Can't understand how the submit button is vertically aligned : <p>When all the controls on this page are lined up, for some reason the submit button (and the first select control) are vertically aligned to the top of the other controls, even though the other controls HAVE a label and the submit DOESN'T...</p>
<p>Also if you resize the page so that the controls are broken over two lines, the submit button align to the top and not to the other controls anymore.</p>
<p><a href="http://test.cdudigital.com/?q=test" rel="nofollow noreferrer">http://test.cdudigital.com/?q=test</a></p>
<p>Why is this?</p>
| 0debug |
I am using Mobile Security Framework. When run python manage.py runserver, it displays this kind of error. : Unhandled exception in thread started by <function wrapper at 0x062BE630>
Traceback (most recent call last):
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\contrib\auth\models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\models\base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\utils.py", line 134, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'sqlite3'
Error was: No module named postgresql.base
| 0debug |
static int mxf_read_sequence(MXFSequence *sequence, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x0202:
sequence->duration = get_be64(pb);
break;
case 0x0201:
get_buffer(pb, sequence->data_definition_ul, 16);
break;
case 0x1001:
sequence->structural_components_count = get_be32(pb);
if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
return -1;
sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
if (!sequence->structural_components_refs)
return -1;
url_fskip(pb, 4);
get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
break;
}
return 0;
}
| 1threat |
In android, tab layout getting improper view in landscape mode : <p><a href="https://i.stack.imgur.com/BVls6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BVls6.png" alt="This is what my app getting in landscape mode"></a></p>
<p><a href="https://i.stack.imgur.com/HmWxt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HmWxt.png" alt="and this is what I want in landscape mode"></a></p>
<p>I made an application with android.support.design.widget.TabLayout and when I am switching the app into landscape mode, the tab will not fit into the window. Please help, thanks in advance.</p>
| 0debug |
Haskell erro load module with mysql : Haskell : Database.MySQL.Base
**
insert_Producto = do
conn <- connect
defaultConnectInfo {ciUser = "root", ciPassword = "", ciDatabase = "prueba"}
oks <- executeMany conn "delete from producto"
**
load Module :
**Conexion.hs:27:5: error:
The last statement in a 'do' block must be an expression
oks <- executeMany conn "delete from producto"
|
27 | oks <- executeMany conn "delete from producto" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^**
I try to load the module, but it marks me error.
Does anyone know what would be the right way to do it?
| 0debug |
Why can't I change variables in a protocol extension where self is a class? : <p>I am curious why this doesn't work:</p>
<pre><code>public protocol MyProtocol {
var i: Int { get set }
}
public protocol MyProtocol2: class, MyProtocol {}
public extension MyProtocol2 where Self: AnyObject {
func a() {
i = 0 <-- error
}
}
</code></pre>
<p>Error:</p>
<blockquote>
<p>Cannot assign to property: 'self' is immutable</p>
</blockquote>
<p>Why? Only classes can adopt MyProtocol2. If I add <code>: class</code> declaration behind MyProtocol it works. I do not understand why it doesn't work on a subprotocol.</p>
| 0debug |
static uint8_t qvirtio_pci_get_status(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS);
}
| 1threat |
Telegraf : How to add a "input plugin"? : <p>I am a beginner with Telegraf, and I would like to install an "input plugin". I have the configuration and the .go file but I do not know what to do with it, even after searching on Google.</p>
<p>Thank you in advance !</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.