problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Manipulate OS X windows with script : <p>Ok, so I'm trying to make my setup super simple by creating a script that I can run in the morning that will launch all the applications that I use in the day and lay them out across my 'spaces' how I like them.</p>
<p>This was going ok and I was easily able to have a bash script launch the apps and then call to an AppleScript to move and resize their windows.</p>
<p>However, I like to use the new El Capitan feature and have some of my spaces as 'split view' spaces. E.g. Full screen Xcode/Terminal split. I can't seem to find a way to control this via a script.</p>
<p>Tl;dr Does anyone know how to get a bash script/AppleScript to put two applications into 'split view' on OS X El Capitan?</p>
| 0debug |
static int copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
{
int h, w, mv_x, mv_y, offset, offset_dst;
uint8_t *src, *dst;
offset_dst = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2);
dst = plane->pixels[ctx->buf_sel] + offset_dst;
mv_y = cell->mv_ptr[0];
mv_x = cell->mv_ptr[1];
if ((cell->ypos << 2) + mv_y < -1 || (cell->xpos << 2) + mv_x < 0 ||
((cell->ypos + cell->height) << 2) + mv_y > plane->height ||
((cell->xpos + cell->width) << 2) + mv_x > plane->width) {
av_log(ctx->avctx, AV_LOG_ERROR,
"Motion vectors point out of the frame.\n");
return AVERROR_INVALIDDATA;
}
offset = offset_dst + mv_y * plane->pitch + mv_x;
src = plane->pixels[ctx->buf_sel ^ 1] + offset;
h = cell->height << 2;
for (w = cell->width; w > 0;) {
if (!((cell->xpos << 2) & 15) && w >= 4) {
for (; w >= 4; src += 16, dst += 16, w -= 4)
ctx->hdsp.put_pixels_tab[0][0](dst, src, plane->pitch, h);
}
if (!((cell->xpos << 2) & 7) && w >= 2) {
ctx->hdsp.put_pixels_tab[1][0](dst, src, plane->pitch, h);
w -= 2;
src += 8;
dst += 8;
}
if (w >= 1) {
ctx->hdsp.put_pixels_tab[2][0](dst, src, plane->pitch, h);
w--;
src += 4;
dst += 4;
}
}
return 0;
}
| 1threat |
static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
{
tb_flush(cpu);
}
| 1threat |
static inline CopyRet receive_frame(AVCodecContext *avctx,
void *data, int *got_frame)
{
BC_STATUS ret;
BC_DTS_PROC_OUT output = {
.PicInfo.width = avctx->width,
.PicInfo.height = avctx->height,
};
CHDContext *priv = avctx->priv_data;
HANDLE dev = priv->dev;
*got_frame = 0;
ret = DtsProcOutputNoCopy(dev, OUTPUT_PROC_TIMEOUT, &output);
if (ret == BC_STS_FMT_CHANGE) {
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Initial format change\n");
avctx->width = output.PicInfo.width;
avctx->height = output.PicInfo.height;
switch ( output.PicInfo.aspect_ratio ) {
case vdecAspectRatioSquare:
avctx->sample_aspect_ratio = (AVRational) { 1, 1};
break;
case vdecAspectRatio12_11:
avctx->sample_aspect_ratio = (AVRational) { 12, 11};
break;
case vdecAspectRatio10_11:
avctx->sample_aspect_ratio = (AVRational) { 10, 11};
break;
case vdecAspectRatio16_11:
avctx->sample_aspect_ratio = (AVRational) { 16, 11};
break;
case vdecAspectRatio40_33:
avctx->sample_aspect_ratio = (AVRational) { 40, 33};
break;
case vdecAspectRatio24_11:
avctx->sample_aspect_ratio = (AVRational) { 24, 11};
break;
case vdecAspectRatio20_11:
avctx->sample_aspect_ratio = (AVRational) { 20, 11};
break;
case vdecAspectRatio32_11:
avctx->sample_aspect_ratio = (AVRational) { 32, 11};
break;
case vdecAspectRatio80_33:
avctx->sample_aspect_ratio = (AVRational) { 80, 33};
break;
case vdecAspectRatio18_11:
avctx->sample_aspect_ratio = (AVRational) { 18, 11};
break;
case vdecAspectRatio15_11:
avctx->sample_aspect_ratio = (AVRational) { 15, 11};
break;
case vdecAspectRatio64_33:
avctx->sample_aspect_ratio = (AVRational) { 64, 33};
break;
case vdecAspectRatio160_99:
avctx->sample_aspect_ratio = (AVRational) {160, 99};
break;
case vdecAspectRatio4_3:
avctx->sample_aspect_ratio = (AVRational) { 4, 3};
break;
case vdecAspectRatio16_9:
avctx->sample_aspect_ratio = (AVRational) { 16, 9};
break;
case vdecAspectRatio221_1:
avctx->sample_aspect_ratio = (AVRational) {221, 1};
break;
}
return RET_OK;
} else if (ret == BC_STS_SUCCESS) {
int copy_ret = -1;
if (output.PoutFlags & BC_POUT_FLAGS_PIB_VALID) {
if (avctx->codec->id == AV_CODEC_ID_MPEG4 &&
output.PicInfo.timeStamp == 0 && priv->bframe_bug) {
if (!priv->bframe_bug) {
av_log(avctx, AV_LOG_VERBOSE,
"CrystalHD: Not returning packed frame twice.\n");
}
DtsReleaseOutputBuffs(dev, NULL, FALSE);
return RET_COPY_AGAIN;
}
print_frame_info(priv, &output);
copy_ret = copy_frame(avctx, &output, data, got_frame);
} else {
av_log(avctx, AV_LOG_ERROR, "CrystalHD: ProcOutput succeeded with "
"invalid PIB\n");
copy_ret = RET_OK;
}
DtsReleaseOutputBuffs(dev, NULL, FALSE);
return copy_ret;
} else if (ret == BC_STS_BUSY) {
return RET_OK;
} else {
av_log(avctx, AV_LOG_ERROR, "CrystalHD: ProcOutput failed %d\n", ret);
return RET_ERROR;
}
}
| 1threat |
Apply a function to a single column of a csv in Spark : <p>Using Spark I'm reading a csv and want to apply a function to a column on the csv. I have some code that works but it's very hacky. What is the proper way to do this?</p>
<p>My code</p>
<pre><code>SparkContext().addPyFile("myfile.py")
spark = SparkSession\
.builder\
.appName("myApp")\
.getOrCreate()
from myfile import myFunction
df = spark.read.csv(sys.argv[1], header=True,
mode="DROPMALFORMED",)
a = df.rdd.map(lambda line: Row(id=line[0], user_id=line[1], message_id=line[2], message=myFunction(line[3]))).toDF()
</code></pre>
<p>I would like to be able to just call the function on the column name instead of mapping each row to <code>line</code> and then calling the function on <code>line[index]</code>.</p>
<p>I'm using Spark version 2.0.1</p>
| 0debug |
Python get number from mixed list : <p>I have following list</p>
<pre><code>count =('OK', ['3'])
</code></pre>
<p>i need to extract number, tried <a href="https://stackoverflow.com/questions/26725535/python-extract-integers-from-mixed-list">following</a> but only got </p>
<pre><code>[]
</code></pre>
| 0debug |
static int vc9_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
VC9Context *v = avctx->priv_data;
int ret = FRAME_SKIPED, len, start_code;
AVFrame *pict = data;
uint8_t *tmp_buf;
v->avctx = avctx;
if (!buf_size) return 0;
len = avpicture_get_size(avctx->pix_fmt, avctx->width,
avctx->height);
tmp_buf = (uint8_t *)av_mallocz(len);
avpicture_fill((AVPicture *)pict, tmp_buf, avctx->pix_fmt,
avctx->width, avctx->height);
if (avctx->codec_id == CODEC_ID_WMV3)
{
init_get_bits(&v->gb, buf, buf_size*8);
av_log(avctx, AV_LOG_INFO, "Frame: %i bits to decode\n", buf_size*8);
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
if (advanced_decode_picture_header(v) == FRAME_SKIPED) return buf_size;
switch(v->pict_type)
{
case I_TYPE: ret = advanced_decode_i_mbs(v); break;
case P_TYPE: ret = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: ret = decode_b_mbs(v); break;
default: ret = FRAME_SKIPED;
}
if (ret == FRAME_SKIPED) return buf_size;
}
else
#endif
{
if (standard_decode_picture_header(v) == FRAME_SKIPED) return buf_size;
switch(v->pict_type)
{
case I_TYPE: ret = standard_decode_i_mbs(v); break;
case P_TYPE: ret = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: ret = decode_b_mbs(v); break;
default: ret = FRAME_SKIPED;
}
if (ret == FRAME_SKIPED) return buf_size;
}
av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n",
get_bits_count(&v->gb), buf_size*8);
}
else
{
#if 0
uint32_t scp = 0;
int scs = 0, i = 0;
while (i < buf_size)
{
for (; i < buf_size && scp != 0x000001; i++)
scp = ((scp<<8)|buf[i])&0xffffff;
if (scp != 0x000001)
break;
scs = buf[i++];
init_get_bits(&v->gb, buf+i, (buf_size-i)*8);
switch(scs)
{
case 0xf:
decode_sequence_header(avctx, &v->gb);
break;
}
i += get_bits_count(&v->gb)*8;
}
#else
av_abort();
#endif
}
*data_size = len;
return buf_size;
}
| 1threat |
android logcat logs chatty module line expire message : <p>I am getting lots of this kind of logcat messages related to my application.</p>
<p><code>11-19 19:04:23.872 3327 3440 I chatty : uid=10085 com.xxxx.yyy expire 18 lines</code></p>
<p>What are these log messages? Am I missing my actual application logcat logs here?</p>
| 0debug |
cant slide navigation drawer : i am doing a project in android studio and i need a navigation drawer , i made a navigation but the problem i cant slide it left and right its block without moving .
[slide problem][1]
[1]: https://i.stack.imgur.com/eque8.png
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="radiofm.arabelradio.MainActivity"
android:background="#e10716"
>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:menu="@menu/navigation_menu"
android:layout_gravity="start"
>
</android.support.design.widget.NavigationView>
<ImageButton
android:id="@+id/id_play"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="fitCenter"
android:background="#e10716"
android:layout_marginBottom="84dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/imageView"
android:layout_width="250dp"
android:layout_height="100dp"
android:layout_marginTop="55dp"
app:srcCompat="@drawable/arabel"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
| 0debug |
Error while Installing apk in Android Studio 2.3 : I can't install my app on my android device.
After updating android studio to 2.3 getting error while installing apk my app is crushed leaving error message as unfortunately stopped
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0" | 0debug |
static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int i, clut_id;
int version;
DVBSubCLUT *clut;
int entry_id, depth , full_range;
int y, cr, cb, alpha;
int r, g, b, r_add, g_add, b_add;
ff_dlog(avctx, "DVB clut packet:\n");
for (i=0; i < buf_size; i++) {
ff_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
ff_dlog(avctx, "\n");
}
if (i % 16)
ff_dlog(avctx, "\n");
clut_id = *buf++;
version = ((*buf)>>4)&15;
buf += 1;
clut = get_clut(ctx, clut_id);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
if (!clut)
return AVERROR(ENOMEM);
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = clut_id;
clut->version = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->version != version) {
clut->version = version;
while (buf + 4 < buf_end) {
entry_id = *buf++;
depth = (*buf) & 0xe0;
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
}
full_range = (*buf++) & 1;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
buf += 2;
}
if (y == 0)
alpha = 0xff;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
ff_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
}
return 0;
}
| 1threat |
React-Native Flatlist getItemLayout with dynamic item height : <p>I am trying to implement a scrollToIndex function on a flatlist so that it scrolls to a specific item when it renders. The issue I am running into is that the items the flatlist renders have a <code>minHeight</code>. The issue with that is, the flatlist needs to implement a function to calculate the offset for every element. I cant think of a way to <code>pre-render</code> the flatlist and get the height of every item in it. As you can see I am simply adding a static number for the offset and that is not what I need. </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-js lang-js prettyprint-override"><code><FlatList
data={data}
renderItem={this.renderItem}
getItemLayout={(dat, index) => {
let offset = 0;
for (let i = 0; i < index; i++) {
if (data[i].headerText) {
offset += 33;
} else {
offset += 80;
}
}
return { length: 0, offset, index }
}
}
ref={(ref) => { this.flatListRef = ref; }}
/></code></pre>
</div>
</div>
</p>
| 0debug |
Waiting until a variables value isset to display it php : <p>I have a variable $infoCollectedAndSold that is being set inside a form (its values are whatever is being checked in the checkbox).
I want to display this variable, once its values are set. Currently the echo is displaying nothing until i submit the form and then the values are displayed from the variable. Is it possible to display the information inside the variable without submitting the form?</p>
<pre><code>//Set variable to the form inputs
$infoCollectedAndSold = "";
if (!empty($_POST['infoCollectedAndSold'])) {
foreach ($_POST['infoCollectedAndSold'] as $value) {
$infoCollectedAndSold .= $value . ', ';
}
}
//Display variable content (Does not display until form is submitted)
<?php
if(isset($infoCollectedAndSold)){
echo '<h3>'.$infoCollectedAndSold.'</h3>';
}
?>
</code></pre>
| 0debug |
def float_sort(price):
float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)
return float_sort | 0debug |
static void vfio_unmap_bars(VFIOPCIDevice *vdev)
{
int i;
for (i = 0; i < PCI_ROM_SLOT; i++) {
vfio_unmap_bar(vdev, i);
}
if (vdev->has_vga) {
vfio_vga_quirk_teardown(vdev);
pci_unregister_vga(&vdev->pdev);
}
}
| 1threat |
Is not a function error - JavaScript es6 class structure : <p>having issue - is not function error, with my code, here it is:</p>
<pre><code>import $ from 'jquery';
import gsap from 'greensock';
class IntroAnimations{
constructor(){
this.ctaEnter = $('#cta-enter');
this.loadContent = $('.center-h-v');
this.tlLoading = new TimelineLite();
this.animationTime = .5;
this.ctaEnter.click(function(){
this.removeLoadContent(); //<- error is here
})
}
removeLoadContent(){
TweenLite.to(this.loadContent, this.animationTime, {autoAlpha: 0})
}
}
export default IntroAnimations;
</code></pre>
<p>Error is when I call this.removeLoadContent();
Can someone help me explain why this is causing an error?</p>
<p>Thank you.</p>
| 0debug |
Split string if contains any of the following comaprison operators like "==", ">", "<", ">=", "<==", "!=" : <p>i want to split a string if it contains one of the following operators ==, >, <, >=, <=, !=</p>
<ol>
<li>if string equals a>b, result is [a,b]</li>
<li>if string equals a < b, result is [a,b]</li>
<li>if string equals a>=b, result is [a,b] </li>
<li>if string equals a<=b, result is [a,b]</li>
<li>if string equals a==b, result is [a,b]</li>
<li>if string equals a!=b, result is [a,b]</li>
</ol>
| 0debug |
static av_cold int xcbgrab_read_header(AVFormatContext *s)
{
XCBGrabContext *c = s->priv_data;
int screen_num, ret;
const xcb_setup_t *setup;
char *host = s->filename[0] ? s->filename : NULL;
const char *opts = strchr(s->filename, '+');
if (opts) {
sscanf(opts, "%d,%d", &c->x, &c->y);
host = av_strdup(s->filename);
host[opts - s->filename] = '\0';
}
c->conn = xcb_connect(host, &screen_num);
if (opts)
av_free(host);
if ((ret = xcb_connection_has_error(c->conn))) {
av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
s->filename[0] ? host : "default", ret);
return AVERROR(EIO);
}
setup = xcb_get_setup(c->conn);
c->screen = get_screen(setup, screen_num);
if (!c->screen) {
av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",
screen_num);
xcbgrab_read_close(s);
return AVERROR(EIO);
}
ret = create_stream(s);
if (ret < 0) {
xcbgrab_read_close(s);
return ret;
}
#if CONFIG_LIBXCB_SHM
if ((c->has_shm = check_shm(c->conn)))
c->segment = xcb_generate_id(c->conn);
#endif
#if CONFIG_LIBXCB_XFIXES
if (c->draw_mouse) {
if (!(c->draw_mouse = check_xfixes(c->conn))) {
av_log(s, AV_LOG_WARNING,
"XFixes not available, cannot draw the mouse.\n");
}
if (c->bpp < 24) {
avpriv_report_missing_feature(s, "%d bits per pixel screen",
c->bpp);
c->draw_mouse = 0;
}
}
#endif
if (c->show_region)
setup_window(s);
return 0;
}
| 1threat |
How to Consume API GET method that accepts FromBody parameter : <p>How can I consume Web API 2 GET command in C# that accepts one FromUri parameter and 2nd FromBody parameter. I dont know how to send body in GET command, do i need to use POST command? but how? below is the code I have written so far. Thank you. </p>
<p>API Code</p>
<pre><code>[HttpGet]
[ResponseType(typeof(IEnumerable<Student>))]
public IHttpActionResult Find([FromUri]string searchText,[FromBody]SearchType searchType)
{
//EF code to get data from DB
using (handler)
{
return Ok(handler.Find(searchText, searchType));
}
}
</code></pre>
<p>HttpClient Code </p>
<pre><code>static void Main(string[] args)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:55587/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
string aSearchText ="John";
SearchType aSearchType = SearchType.Name; //this is enum
Task<HttpResponseMessage> responseTask = client.GetAsync($"api/Student/{aSearchText}");
responseTask.Wait();
////////////////////
/// Code missing how to send "aSearchType" as a body in Get Command?
////////////////////
var ListTask = responseTask.Content.ReadAsAsync<IEnumerable<Student>>();
ListTask.Wait();
IEnumerable<Student> list = ListTask.Result;
foreach(Student s in list)
{
Console.WriteLine(s.Name);
}
}
</code></pre>
| 0debug |
int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
int flags, BlockDriver *drv)
{
int ret;
char tmp_filename[PATH_MAX + 1];
BlockDriverState *file = NULL;
if (options == NULL) {
options = qdict_new();
}
bs->options = options;
options = qdict_clone_shallow(options);
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
char backing_filename[PATH_MAX];
bs1 = bdrv_new("");
ret = bdrv_open(bs1, filename, NULL, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
goto fail;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (ret < 0) {
goto fail;
}
if (is_protocol) {
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
} else if (!realpath(filename, backing_filename)) {
ret = -errno;
goto fail;
}
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
free_option_parameters(options);
if (ret < 0) {
goto fail;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR;
}
ret = bdrv_file_open(&file, filename, bdrv_open_flags(bs, flags));
if (ret < 0) {
goto fail;
}
if (!drv) {
ret = find_image_format(file, filename, &drv);
}
if (!drv) {
goto unlink_and_fail;
}
ret = bdrv_open_common(bs, file, filename, options, flags, drv);
if (ret < 0) {
goto unlink_and_fail;
}
if (bs->file != file) {
bdrv_delete(file);
file = NULL;
}
if ((flags & BDRV_O_NO_BACKING) == 0) {
ret = bdrv_open_backing_file(bs);
if (ret < 0) {
goto close_and_fail;
}
}
if (qdict_size(options) != 0) {
const QDictEntry *entry = qdict_first(options);
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by "
"device '%s' doesn't support the option '%s'",
drv->format_name, bs->device_name, entry->key);
ret = -EINVAL;
goto close_and_fail;
}
QDECREF(options);
if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs, true);
}
if (bs->io_limits_enabled) {
bdrv_io_limits_enable(bs);
}
return 0;
unlink_and_fail:
if (file != NULL) {
bdrv_delete(file);
}
if (bs->is_temporary) {
unlink(filename);
}
fail:
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
return ret;
close_and_fail:
bdrv_close(bs);
QDECREF(options);
return ret;
}
| 1threat |
static av_cold int decode_init(AVCodecContext *avctx)
{
WMAProDecodeCtx *s = avctx->priv_data;
uint8_t *edata_ptr = avctx->extradata;
unsigned int channel_mask;
int i, bits;
int log2_max_num_subframes;
int num_possible_block_sizes;
if (avctx->codec_id == AV_CODEC_ID_XMA1 || avctx->codec_id == AV_CODEC_ID_XMA2)
avctx->block_align = 2048;
if (!avctx->block_align) {
av_log(avctx, AV_LOG_ERROR, "block_align is not set\n");
return AVERROR(EINVAL);
}
s->avctx = avctx;
s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (!s->fdsp)
return AVERROR(ENOMEM);
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
if (avctx->codec_id == AV_CODEC_ID_XMA2 && avctx->extradata_size >= 34) {
s->decode_flags = 0x10d6;
channel_mask = AV_RL32(edata_ptr+2);
s->bits_per_sample = 16;
for (i = 0; i < avctx->extradata_size; i++)
ff_dlog(avctx, "[%x] ", avctx->extradata[i]);
ff_dlog(avctx, "\n");
} else if (avctx->codec_id == AV_CODEC_ID_XMA1 && avctx->extradata_size >= 28) {
s->decode_flags = 0x10d6;
s->bits_per_sample = 16;
channel_mask = 0;
for (i = 0; i < avctx->extradata_size; i++)
ff_dlog(avctx, "[%x] ", avctx->extradata[i]);
ff_dlog(avctx, "\n");
} else if (avctx->extradata_size >= 18) {
s->decode_flags = AV_RL16(edata_ptr+14);
channel_mask = AV_RL32(edata_ptr+2);
s->bits_per_sample = AV_RL16(edata_ptr);
for (i = 0; i < avctx->extradata_size; i++)
ff_dlog(avctx, "[%x] ", avctx->extradata[i]);
ff_dlog(avctx, "\n");
} else {
avpriv_request_sample(avctx, "Unknown extradata size");
return AVERROR_PATCHWELCOME;
}
if (avctx->codec_id != AV_CODEC_ID_WMAPRO && avctx->channels > 2) {
avpriv_report_missing_feature(avctx, ">2 channels support");
return AVERROR_PATCHWELCOME;
}
s->log2_frame_size = av_log2(avctx->block_align) + 4;
if (s->log2_frame_size > 25) {
avpriv_request_sample(avctx, "Large block align");
return AVERROR_PATCHWELCOME;
}
if (avctx->codec_id != AV_CODEC_ID_WMAPRO)
s->skip_frame = 0;
else
s->skip_frame = 1;
s->packet_loss = 1;
s->len_prefix = (s->decode_flags & 0x40);
if (avctx->codec_id == AV_CODEC_ID_WMAPRO) {
bits = ff_wma_get_frame_len_bits(avctx->sample_rate, 3, s->decode_flags);
if (bits > WMAPRO_BLOCK_MAX_BITS) {
avpriv_request_sample(avctx, "14-bit block sizes");
return AVERROR_PATCHWELCOME;
}
s->samples_per_frame = 1 << bits;
} else {
s->samples_per_frame = 512;
}
log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3);
s->max_num_subframes = 1 << log2_max_num_subframes;
if (s->max_num_subframes == 16 || s->max_num_subframes == 4)
s->max_subframe_len_bit = 1;
s->subframe_len_bits = av_log2(log2_max_num_subframes) + 1;
num_possible_block_sizes = log2_max_num_subframes + 1;
s->min_samples_per_subframe = s->samples_per_frame / s->max_num_subframes;
s->dynamic_range_compression = (s->decode_flags & 0x80);
if (s->max_num_subframes > MAX_SUBFRAMES) {
av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %"PRId8"\n",
s->max_num_subframes);
return AVERROR_INVALIDDATA;
}
if (s->min_samples_per_subframe < WMAPRO_BLOCK_MIN_SIZE) {
av_log(avctx, AV_LOG_ERROR, "min_samples_per_subframe of %d too small\n",
s->min_samples_per_subframe);
return AVERROR_INVALIDDATA;
}
if (s->avctx->sample_rate <= 0) {
av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");
return AVERROR_INVALIDDATA;
}
if (avctx->channels < 0) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n",
avctx->channels);
return AVERROR_INVALIDDATA;
} else if (avctx->channels > WMAPRO_MAX_CHANNELS) {
avpriv_request_sample(avctx,
"More than %d channels", WMAPRO_MAX_CHANNELS);
return AVERROR_PATCHWELCOME;
}
for (i = 0; i < avctx->channels; i++)
s->channel[i].prev_block_len = s->samples_per_frame;
s->lfe_channel = -1;
if (channel_mask & 8) {
unsigned int mask;
for (mask = 1; mask < 16; mask <<= 1) {
if (channel_mask & mask)
++s->lfe_channel;
}
}
INIT_VLC_STATIC(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE,
scale_huffbits, 1, 1,
scale_huffcodes, 2, 2, 616);
INIT_VLC_STATIC(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE,
scale_rl_huffbits, 1, 1,
scale_rl_huffcodes, 4, 4, 1406);
INIT_VLC_STATIC(&coef_vlc[0], VLCBITS, HUFF_COEF0_SIZE,
coef0_huffbits, 1, 1,
coef0_huffcodes, 4, 4, 2108);
INIT_VLC_STATIC(&coef_vlc[1], VLCBITS, HUFF_COEF1_SIZE,
coef1_huffbits, 1, 1,
coef1_huffcodes, 4, 4, 3912);
INIT_VLC_STATIC(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE,
vec4_huffbits, 1, 1,
vec4_huffcodes, 2, 2, 604);
INIT_VLC_STATIC(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE,
vec2_huffbits, 1, 1,
vec2_huffcodes, 2, 2, 562);
INIT_VLC_STATIC(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE,
vec1_huffbits, 1, 1,
vec1_huffcodes, 2, 2, 562);
for (i = 0; i < num_possible_block_sizes; i++) {
int subframe_len = s->samples_per_frame >> i;
int x;
int band = 1;
int rate = get_rate(avctx);
s->sfb_offsets[i][0] = 0;
for (x = 0; x < MAX_BANDS-1 && s->sfb_offsets[i][band - 1] < subframe_len; x++) {
int offset = (subframe_len * 2 * critical_freq[x]) / rate + 2;
offset &= ~3;
if (offset > s->sfb_offsets[i][band - 1])
s->sfb_offsets[i][band++] = offset;
if (offset >= subframe_len)
break;
}
s->sfb_offsets[i][band - 1] = subframe_len;
s->num_sfb[i] = band - 1;
if (s->num_sfb[i] <= 0) {
av_log(avctx, AV_LOG_ERROR, "num_sfb invalid\n");
return AVERROR_INVALIDDATA;
}
}
for (i = 0; i < num_possible_block_sizes; i++) {
int b;
for (b = 0; b < s->num_sfb[i]; b++) {
int x;
int offset = ((s->sfb_offsets[i][b]
+ s->sfb_offsets[i][b + 1] - 1) << i) >> 1;
for (x = 0; x < num_possible_block_sizes; x++) {
int v = 0;
while (s->sfb_offsets[x][v + 1] << x < offset) {
v++;
av_assert0(v < MAX_BANDS);
}
s->sf_offsets[i][x][b] = v;
}
}
}
for (i = 0; i < WMAPRO_BLOCK_SIZES; i++)
ff_mdct_init(&s->mdct_ctx[i], WMAPRO_BLOCK_MIN_BITS+1+i, 1,
1.0 / (1 << (WMAPRO_BLOCK_MIN_BITS + i - 1))
/ (1 << (s->bits_per_sample - 1)));
for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) {
const int win_idx = WMAPRO_BLOCK_MAX_BITS - i;
ff_init_ff_sine_windows(win_idx);
s->windows[WMAPRO_BLOCK_SIZES - i - 1] = ff_sine_windows[win_idx];
}
for (i = 0; i < num_possible_block_sizes; i++) {
int block_size = s->samples_per_frame >> i;
int cutoff = (440*block_size + 3 * (s->avctx->sample_rate >> 1) - 1)
/ s->avctx->sample_rate;
s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size);
}
for (i = 0; i < 33; i++)
sin64[i] = sin(i*M_PI / 64.0);
if (avctx->debug & FF_DEBUG_BITSTREAM)
dump_context(s);
avctx->channel_layout = channel_mask;
return 0;
}
| 1threat |
static int find_image_range(int *pfirst_index, int *plast_index,
const char *path, int start_index)
{
char buf[1024];
int range, last_index, range1, first_index;
for (first_index = start_index; first_index < start_index + 5; first_index++) {
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){
*pfirst_index =
*plast_index = 1;
if (avio_check(buf, AVIO_FLAG_READ) > 0)
return 0;
return -1;
}
if (avio_check(buf, AVIO_FLAG_READ) > 0)
break;
}
if (first_index == 5)
goto fail;
last_index = first_index;
for(;;) {
range = 0;
for(;;) {
if (!range)
range1 = 1;
else
range1 = 2 * range;
if (av_get_frame_filename(buf, sizeof(buf), path,
last_index + range1) < 0)
goto fail;
if (avio_check(buf, AVIO_FLAG_READ) <= 0)
break;
range = range1;
if (range >= (1 << 30))
goto fail;
}
if (!range)
break;
last_index += range;
}
*pfirst_index = first_index;
*plast_index = last_index;
return 0;
fail:
return -1;
}
| 1threat |
static int decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff) {
const int mb_xy = h->s.mb_x + h->s.mb_y*h->s.mb_stride;
static const int significant_coeff_flag_offset[2][6] = {
{ 105+0, 105+15, 105+29, 105+44, 105+47, 402 },
{ 277+0, 277+15, 277+29, 277+44, 277+47, 436 }
};
static const int last_coeff_flag_offset[2][6] = {
{ 166+0, 166+15, 166+29, 166+44, 166+47, 417 },
{ 338+0, 338+15, 338+29, 338+44, 338+47, 451 }
};
static const int coeff_abs_level_m1_offset[6] = {
227+0, 227+10, 227+20, 227+30, 227+39, 426
};
static const uint8_t significant_coeff_flag_offset_8x8[2][63] = {
{ 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 },
{ 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }
};
static const uint8_t last_coeff_flag_offset_8x8[63] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
};
int index[64];
int i, last;
int coeff_count = 0;
int abslevel1 = 1;
int abslevelgt1 = 0;
uint8_t *significant_coeff_ctx_base;
uint8_t *last_coeff_ctx_base;
uint8_t *abs_level_m1_ctx_base;
if( cat != 5 ) {
if( get_cabac( &h->cabac, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n ) ] ) == 0 ) {
if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = 0;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = 0;
return 0;
}
}
significant_coeff_ctx_base = h->cabac_state
+ significant_coeff_flag_offset[MB_FIELD][cat];
last_coeff_ctx_base = h->cabac_state
+ last_coeff_flag_offset[MB_FIELD][cat];
abs_level_m1_ctx_base = h->cabac_state
+ coeff_abs_level_m1_offset[cat];
if( cat == 5 ) {
#define DECODE_SIGNIFICANCE( coefs, sig_off, last_off ) \
for(last= 0; last < coefs; last++) { \
uint8_t *sig_ctx = significant_coeff_ctx_base + sig_off; \
if( get_cabac( &h->cabac, sig_ctx )) { \
uint8_t *last_ctx = last_coeff_ctx_base + last_off; \
index[coeff_count++] = last; \
if( get_cabac( &h->cabac, last_ctx ) ) { \
last= max_coeff; \
break; \
} \
} \
}
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] );
} else {
DECODE_SIGNIFICANCE( max_coeff - 1, last, last );
}
if( last == max_coeff -1 ) {
index[coeff_count++] = last;
}
assert(coeff_count > 0);
if( cat == 0 )
h->cbp_table[mb_xy] |= 0x100;
else if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = coeff_count;
else if( cat == 3 )
h->cbp_table[mb_xy] |= 0x40 << n;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = coeff_count;
else {
assert( cat == 5 );
fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
}
for( i = coeff_count - 1; i >= 0; i-- ) {
uint8_t *ctx = (abslevelgt1 != 0 ? 0 : FFMIN( 4, abslevel1 )) + abs_level_m1_ctx_base;
int j= scantable[index[i]];
if( get_cabac( &h->cabac, ctx ) == 0 ) {
if( !qmul ) {
if( get_cabac_bypass( &h->cabac ) ) block[j] = -1;
else block[j] = 1;
}else{
if( get_cabac_bypass( &h->cabac ) ) block[j] = (-qmul[j] + 32) >> 6;
else block[j] = ( qmul[j] + 32) >> 6;
}
abslevel1++;
} else {
int coeff_abs = 2;
ctx = 5 + FFMIN( 4, abslevelgt1 ) + abs_level_m1_ctx_base;
while( coeff_abs < 15 && get_cabac( &h->cabac, ctx ) ) {
coeff_abs++;
}
if( coeff_abs >= 15 ) {
int j = 0;
while( get_cabac_bypass( &h->cabac ) ) {
j++;
}
coeff_abs=1;
while( j-- ) {
coeff_abs += coeff_abs + get_cabac_bypass( &h->cabac );
}
coeff_abs+= 14;
}
if( !qmul ) {
if( get_cabac_bypass( &h->cabac ) ) block[j] = -coeff_abs;
else block[j] = coeff_abs;
}else{
if( get_cabac_bypass( &h->cabac ) ) block[j] = (-coeff_abs * qmul[j] + 32) >> 6;
else block[j] = ( coeff_abs * qmul[j] + 32) >> 6;
}
abslevelgt1++;
}
}
return 0;
}
| 1threat |
static void rtl8139_cplus_transmit(RTL8139State *s)
{
int txcount = 0;
while (rtl8139_cplus_transmit_one(s))
{
++txcount;
}
if (!txcount)
{
DPRINTF("C+ mode : transmitter queue stalled, current TxDesc = %d\n",
s->currCPlusTxDesc);
}
else
{
s->IntrStatus |= TxOK;
rtl8139_update_irq(s);
}
}
| 1threat |
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
{
BufferSinkContext *buf = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
int ret;
AVFrame *cur_frame;
if (!av_fifo_size(buf->fifo)) {
if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
return AVERROR(EAGAIN);
if ((ret = ff_request_frame(inlink)) < 0)
return ret;
}
if (!av_fifo_size(buf->fifo))
return AVERROR(EINVAL);
if (flags & AV_BUFFERSINK_FLAG_PEEK) {
cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));
av_frame_ref(frame, cur_frame);
} else {
av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);
av_frame_move_ref(frame, cur_frame);
av_frame_free(&cur_frame);
}
return 0;
}
| 1threat |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
Reversing Strings in lists : <p>I have a list of strings.
e.g. [ixpASara12345, ixpBSara1234,...]
I've been trying to reverse the strings inside the list, but it didn't work so far.</p>
<p>Is there any way I can do this without using any reverse functions?</p>
<p>Thanks!</p>
| 0debug |
JS: How can I parse with regex name value pairs but separated only by semi-colon? : So I got this string (faceted search query):
var q = ":salesRevenue:brand:Tchelicon:brand:Eurocom
:brand:Turbosound:brand:Labgruppen:brand:Tannoy:brand:Klarkteknik
:brand:Midas:brand:Bugera
:brand:Tcelectronic
:eligibleProduct:0010000066:publicProduct:false:brand:Behringer:productFilter:All:";
I want to split it to three separate strings, q_brand, q_pubs and q_product and my client wants it all in Regex.
q_brand is consisted only of values with values preceded with "brand:" only.
q_pubs are values preceded with "eligibleProduct:" and "publicProduct:".
q_product are values preceded with "productFilter:".
I want to be able to capture them even if they interchange positions using Regex (ex. like the position of :brand:Behringer:)
The end result is expected to be:
var q_brand = "brand:Tchelicon:brand:Eurocom
:brand:Turbosound:brand:Labgruppen:brand:Tannoy:brand:Klarkteknik
:brand:Midas:brand:Bugera
:brand:Tcelectronic:brand:Behringer";
var q_pubs = "eligibleProduct:0010000066:publicProduct:false";
var q_product = "productFilter:All";
I tried using `(brand:.+:)` on `brand:apple:brand:orange:product:hello:brand:grain:` for one instance and several others but getting unexpected result. | 0debug |
Parse SDK Android - Facebook Graph API v2.0 : <p>I'm using Parse SDK in my app (<a href="https://github.com/ParsePlatform/Parse-SDK-Android">https://github.com/ParsePlatform/Parse-SDK-Android</a>). </p>
<p>My app also uses the Facebook Utils in order to provide a login experience with Facebook (<a href="https://github.com/ParsePlatform/ParseFacebookUtils-Android">https://github.com/ParsePlatform/ParseFacebookUtils-Android</a>) </p>
<p>Recently I've received the following message from Facebook Developers regarding one of my app : "xxx has been making recent API calls to Graph API v2.0, which will reach the end of the 2-year deprecation window on Monday, August 8, 2016. Please migrate all calls to v2.1 or higher in order to avoid potential broken experiences."</p>
<p>How can I fix that problem? </p>
<p>This is my build.gradle file in the dependecies section : </p>
<pre><code>dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.parse:parse-android:1.13.1'
compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'
compile 'com.parse.bolts:bolts-tasks:1.4.0'
compile 'com.parse.bolts:bolts-applinks:1.4.0'
compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'
compile 'com.soundcloud.android:android-crop:1.0.0@aar'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile files('libs/universal-image-loader-1.9.3.jar')
}
</code></pre>
<p>and this is the only point in code where I use the Facebook SDK: </p>
<pre><code>ParseFacebookUtils.logInWithReadPermissionsInBackground(Login.this, permissions, new LogInCallback() {
@Override
public void done(final ParseUser user, ParseException err) {
fbdialog = new ProgressDialog(Login.this);
fbdialog.setTitle("Contacting Facebook");
fbdialog.setMessage("Please wait a moment. We are contacting Facebook to perform the registration");
fbdialog.show();
if (user == null) {
Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
fbdialog.cancel();
} else if (user.isNew() || !user.isNew()) {
Log.d("MyApp", "User signed up and logged in through Facebook!" + AccessToken.getCurrentAccessToken());
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
if(response!=null) {
try {
String nome = object.getString("name");
String email = object.getString("email");
String gender = object.getString("gender");
final String facebookid = object.getString("id");
ParseUser utente = ParseUser.getCurrentUser();
utente.put("namelastname", nome);
utente.put("email", email);
utente.put("gender", gender);
utente.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("idutente", user);
installation.saveInBackground();
//downloading the user profile image from facebook
AsyncTaskLoad as = new AsyncTaskLoad();
as.execute("https://graph.facebook.com/" + facebookid + "/picture?type=large");
fbdialog.cancel();
} else {
fbdialog.cancel();
e.printStackTrace();
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link,email,age_range,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
} else {
Log.d("MyApp", "User logged in through Facebook!");
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("idutente", user);
installation.saveInBackground();
fbdialog.cancel();
//here I start a new activity
}
}
});
}
});
</code></pre>
<p>this is the AsyncTask used to download the Facebook profile image: </p>
<pre><code>private class AsyncTaskLoad extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
pd = new ProgressDialog(Login.this);
pd.setTitle("Logging");
pd.show();
}
@Override
protected Void doInBackground(String... strings) {
try {
URL image_value = new URL(strings[0]);
SynchroHelper sync = new SynchroHelper(Login.this);
//simple http method to download an image and save it into a file in the external storage dir
sync.downloadImage(image_value.toString(), "myprof.jpg", Environment.getExternalStorageDirectory());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void params) {
//starting a new activity...
pd.dismiss();
}
}
</code></pre>
<p>How can I upgrade to Graph API v2.0? Should I wait an update from the Parse-SDK? </p>
| 0debug |
static int cpu_mips_register (CPUMIPSState *env, const mips_def_t *def)
{
env->CP0_PRid = def->CP0_PRid;
env->CP0_Config0 = def->CP0_Config0;
#ifdef TARGET_WORDS_BIGENDIAN
env->CP0_Config0 |= (1 << CP0C0_BE);
#endif
env->CP0_Config1 = def->CP0_Config1;
env->CP0_Config2 = def->CP0_Config2;
env->CP0_Config3 = def->CP0_Config3;
env->CP0_Config6 = def->CP0_Config6;
env->CP0_Config7 = def->CP0_Config7;
env->SYNCI_Step = def->SYNCI_Step;
env->CCRes = def->CCRes;
env->CP0_Status_rw_bitmask = def->CP0_Status_rw_bitmask;
env->CP0_TCStatus_rw_bitmask = def->CP0_TCStatus_rw_bitmask;
env->CP0_SRSCtl = def->CP0_SRSCtl;
env->current_tc = 0;
env->SEGBITS = def->SEGBITS;
env->SEGMask = (target_ulong)((1ULL << def->SEGBITS) - 1);
#if defined(TARGET_MIPS64)
if (def->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
env->SEGMask |= 3ULL << 62;
}
#endif
env->PABITS = def->PABITS;
env->PAMask = (target_ulong)((1ULL << def->PABITS) - 1);
env->CP0_SRSConf0_rw_bitmask = def->CP0_SRSConf0_rw_bitmask;
env->CP0_SRSConf0 = def->CP0_SRSConf0;
env->CP0_SRSConf1_rw_bitmask = def->CP0_SRSConf1_rw_bitmask;
env->CP0_SRSConf1 = def->CP0_SRSConf1;
env->CP0_SRSConf2_rw_bitmask = def->CP0_SRSConf2_rw_bitmask;
env->CP0_SRSConf2 = def->CP0_SRSConf2;
env->CP0_SRSConf3_rw_bitmask = def->CP0_SRSConf3_rw_bitmask;
env->CP0_SRSConf3 = def->CP0_SRSConf3;
env->CP0_SRSConf4_rw_bitmask = def->CP0_SRSConf4_rw_bitmask;
env->CP0_SRSConf4 = def->CP0_SRSConf4;
env->insn_flags = def->insn_flags;
#ifndef CONFIG_USER_ONLY
if (!env->user_mode_only)
mmu_init(env, def);
#endif
fpu_init(env, def);
mvp_init(env, def);
return 0;
}
| 1threat |
int ff_vda_create_decoder(struct vda_context *vda_ctx,
uint8_t *extradata,
int extradata_size)
{
OSStatus status = kVDADecoderNoErr;
CFNumberRef height;
CFNumberRef width;
CFNumberRef format;
CFDataRef avc_data;
CFMutableDictionaryRef config_info;
CFMutableDictionaryRef buffer_attributes;
CFMutableDictionaryRef io_surface_properties;
CFNumberRef cv_pix_fmt;
if (extradata_size >= 4 && (extradata[4] & 0x03) != 0x03) {
uint8_t *rw_extradata;
if (!(rw_extradata = av_malloc(extradata_size)))
return AVERROR(ENOMEM);
memcpy(rw_extradata, extradata, extradata_size);
rw_extradata[4] |= 0x03;
avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, extradata_size);
av_freep(&rw_extradata);
} else {
avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
}
config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
4,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height);
width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width);
format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format);
CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&vda_ctx->cv_pix_fmt_type);
CFDictionarySetValue(buffer_attributes,
kCVPixelBufferPixelFormatTypeKey,
cv_pix_fmt);
CFDictionarySetValue(buffer_attributes,
kCVPixelBufferIOSurfacePropertiesKey,
io_surface_properties);
status = VDADecoderCreate(config_info,
buffer_attributes,
vda_decoder_callback,
vda_ctx,
&vda_ctx->decoder);
CFRelease(height);
CFRelease(width);
CFRelease(format);
CFRelease(avc_data);
CFRelease(config_info);
CFRelease(io_surface_properties);
CFRelease(cv_pix_fmt);
CFRelease(buffer_attributes);
return status;
}
| 1threat |
why ArrayIndexOutOFBoundException in bidirectional bubble sort? : <p>I could not understand why this code is giving ArrayIndexOutOfBoundsException.
here is my code to implement bidirectional bubble sort.</p>
<pre><code>static void bubble(int[] a){
int temp;
for(int i=a.length-1,k=0;i!=k;i--,k++){
for(int j=k;j<i;j++){
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
for(int j=i-1;j>k;j--){
if(a[j-1]>a[j]){
temp=a[j];
a[j]=a[j-1];
a[j-1]=temp;
}
}
}
}
</code></pre>
| 0debug |
Change mysql password in Docker container : <p>How could I change root password in docker container since the container stop automatically once I stop the mysql service. </p>
<p>Should I stop the mysql container and deploy a new one?</p>
| 0debug |
static CharDriverState *qmp_chardev_open_udp(ChardevUdp *udp,
Error **errp)
{
int fd;
fd = socket_dgram(udp->remote, udp->local, errp);
if (error_is_set(errp)) {
return NULL;
}
return qemu_chr_open_udp_fd(fd);
}
| 1threat |
static av_cold int ape_decode_init(AVCodecContext *avctx)
{
APEContext *s = avctx->priv_data;
int i;
if (avctx->extradata_size != 6) {
av_log(avctx, AV_LOG_ERROR, "Incorrect extradata\n");
return AVERROR(EINVAL);
}
if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo is supported\n");
return AVERROR(EINVAL);
}
s->bps = avctx->bits_per_coded_sample;
switch (s->bps) {
case 8:
avctx->sample_fmt = AV_SAMPLE_FMT_U8;
break;
case 16:
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
break;
case 24:
avctx->sample_fmt = AV_SAMPLE_FMT_S32;
break;
default:
av_log_ask_for_sample(avctx, "Unsupported bits per coded sample %d\n",
s->bps);
return AVERROR_PATCHWELCOME;
}
s->avctx = avctx;
s->channels = avctx->channels;
s->fileversion = AV_RL16(avctx->extradata);
s->compression_level = AV_RL16(avctx->extradata + 2);
s->flags = AV_RL16(avctx->extradata + 4);
av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n",
s->compression_level, s->flags);
if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) {
av_log(avctx, AV_LOG_ERROR, "Incorrect compression level %d\n",
s->compression_level);
return AVERROR_INVALIDDATA;
}
s->fset = s->compression_level / 1000 - 1;
for (i = 0; i < APE_FILTER_LEVELS; i++) {
if (!ape_filter_orders[s->fset][i])
break;
FF_ALLOC_OR_GOTO(avctx, s->filterbuf[i],
(ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4,
filter_alloc_fail);
}
ff_dsputil_init(&s->dsp, avctx);
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
return 0;
filter_alloc_fail:
ape_decode_close(avctx);
return AVERROR(ENOMEM);
}
| 1threat |
simple calculator using javascript : I'm trying to create a simple javascript calculator but its not working as expected.
I tried but I'm getting correct results. Below is my code. please let me know what I'm doing wrong here
<HEAD>
<TITLE> Simple Calculation</TITLE>
</HEAD>
<BODY>
<FORM NAME="myForm">
<TABLE BORDER=2>
<TR>
<TD align="center">
<INPUT TYPE="text" ID="screen" NAME="screen" style="width:99%"><br>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" NAME="7" VALUE=" 7 " onclick="update(7)">
<INPUT TYPE="button" NAME="8" VALUE=" 8 " onclick="update(8)">
<INPUT TYPE="button" NAME="9" VALUE=" 9 " onclick="update(9)">
<INPUT TYPE="button" NAME="+" VALUE=" + " onclick="update('+')">
<br>
<INPUT TYPE="button" NAME="4" VALUE=" 4 " onclick="update(4)">
<INPUT TYPE="button" NAME="5" VALUE=" 5 " onclick="update(5)">
<INPUT TYPE="button" NAME="6" VALUE=" 6 " onclick="update(6)">
<INPUT TYPE="button" NAME="-" VALUE=" - " onclick="update('-')">
<br>
<INPUT TYPE="button" NAME="1" VALUE=" 1 " onclick="update(1)">
<INPUT TYPE="button" NAME="2" VALUE=" 2 " onclick="update(2)">
<INPUT TYPE="button" NAME="3" VALUE=" 3 " onclick="update(3)">
<INPUT TYPE="button" NAME="*" VALUE=" x " onclick="update('*')">
<br>
<INPUT TYPE="button" NAME="c" VALUE=" c " onclick="form_reset();">
<INPUT TYPE="button" NAME="0" VALUE=" 0 " onclick="update(0)">
<INPUT TYPE="button" NAME="=" VALUE=" = " onclick="result();">
<INPUT TYPE="button" NAME="/" VALUE=" / " onclick="update('/')">
</TD>
</TR>
</TABLE>
</FORM>
<script type="text/javascript" src="index.js"></SCRIPT>
</BODY>
</HTML>
| 0debug |
Big differences in GCC code generation when compiling as C++ vs C : <p>I've been playing around a little bit with x86-64 assembly trying to learn more about the various SIMD extensions that are available (MMX, SSE, AVX).</p>
<p>In order to see how different C or C++ constructs are translated into machine code by GCC I've been using <a href="https://godbolt.org" rel="noreferrer">Compiler Explorer</a> which is a superb tool.</p>
<p>During one of my 'play sessions' I wanted to see how GCC could optimize a simple run-time initialization of an integer array. In this case I tried to write the numbers 0 to 2047 to an array of 2048 unsigned integers.</p>
<p>The code looks as follows:</p>
<pre><code>unsigned int buffer[2048];
void setup()
{
for (unsigned int i = 0; i < 2048; ++i)
{
buffer[i] = i;
}
}
</code></pre>
<p>If I enable optimizations and AVX-512 instructions <code>-O3 -mavx512f -mtune=intel</code> GCC 6.3 generates some really clever code :)</p>
<pre><code>setup():
mov eax, OFFSET FLAT:buffer
mov edx, OFFSET FLAT:buffer+8192
vmovdqa64 zmm0, ZMMWORD PTR .LC0[rip]
vmovdqa64 zmm1, ZMMWORD PTR .LC1[rip]
.L2:
vmovdqa64 ZMMWORD PTR [rax], zmm0
add rax, 64
cmp rdx, rax
vpaddd zmm0, zmm0, zmm1
jne .L2
ret
buffer:
.zero 8192
.LC0:
.long 0
.long 1
.long 2
.long 3
.long 4
.long 5
.long 6
.long 7
.long 8
.long 9
.long 10
.long 11
.long 12
.long 13
.long 14
.long 15
.LC1:
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
.long 16
</code></pre>
<p>However, when I tested what would be generated if the same code was compiled using the GCC C-compiler by adding the flags <code>-x c</code> I was really surprised.</p>
<p>I expected similar, if not identical, results but the C-compiler seems to generate <strong>much</strong> more complicated and presumably also much slower machine code. The resulting assembly is too large to paste here in full, but it can be viewed at godbolt.org by following <a href="https://godbolt.org/g/A8bRxj" rel="noreferrer">this</a> link.</p>
<p>A snippet of the generated code, lines 58 to 83, can be seen below:</p>
<pre><code>.L2:
vpbroadcastd zmm0, r8d
lea rsi, buffer[0+rcx*4]
vmovdqa64 zmm1, ZMMWORD PTR .LC1[rip]
vpaddd zmm0, zmm0, ZMMWORD PTR .LC0[rip]
xor ecx, ecx
.L4:
add ecx, 1
add rsi, 64
vmovdqa64 ZMMWORD PTR [rsi-64], zmm0
cmp ecx, edi
vpaddd zmm0, zmm0, zmm1
jb .L4
sub edx, r10d
cmp r9d, r10d
lea eax, [r8+r10]
je .L1
mov ecx, eax
cmp edx, 1
mov DWORD PTR buffer[0+rcx*4], eax
lea ecx, [rax+1]
je .L1
mov esi, ecx
cmp edx, 2
mov DWORD PTR buffer[0+rsi*4], ecx
lea ecx, [rax+2]
</code></pre>
<p>As you can see, this code has a lot of complicated moves and jumps and in general feels like a very complex way of performing a simple array initialization.</p>
<p><strong>Why is there such a big difference in the generated code?</strong></p>
<p><strong>Is the GCC C++-compiler better in general at optimizing code that is valid in both C and C++ when compared to the C-compiler?</strong></p>
| 0debug |
How to get an already existing file (on my computer) in my method and convert it to InputStream? : <p>I've a generated file in D:/EXPORT_BASE/Export_report. What I need to do is use the filePath string to fetch this file from my local, and then convert this to InputStream.</p>
<p><code>String filePath = D:/EXPORT_BASE/Export_report/1557834965979_report.txt</code></p>
<p>I need to use the String to get the file and write it to InputStream.</p>
| 0debug |
static int wm8750_tx(I2CSlave *i2c, uint8_t data)
{
WM8750State *s = (WM8750State *) i2c;
uint8_t cmd;
uint16_t value;
if (s->i2c_len >= 2) {
printf("%s: long message (%i bytes)\n", __FUNCTION__, s->i2c_len);
#ifdef VERBOSE
return 1;
#endif
}
s->i2c_data[s->i2c_len ++] = data;
if (s->i2c_len != 2)
return 0;
cmd = s->i2c_data[0] >> 1;
value = ((s->i2c_data[0] << 8) | s->i2c_data[1]) & 0x1ff;
switch (cmd) {
case WM8750_LADCIN:
s->diff[0] = (((value >> 6) & 3) == 3);
if (s->diff[0])
s->in[0] = &s->adc_voice[0 + s->ds * 1];
else
s->in[0] = &s->adc_voice[((value >> 6) & 3) * 1 + 0];
break;
case WM8750_RADCIN:
s->diff[1] = (((value >> 6) & 3) == 3);
if (s->diff[1])
s->in[1] = &s->adc_voice[0 + s->ds * 1];
else
s->in[1] = &s->adc_voice[((value >> 6) & 3) * 1 + 0];
break;
case WM8750_ADCIN:
s->ds = (value >> 8) & 1;
if (s->diff[0])
s->in[0] = &s->adc_voice[0 + s->ds * 1];
if (s->diff[1])
s->in[1] = &s->adc_voice[0 + s->ds * 1];
s->monomix[0] = (value >> 6) & 3;
break;
case WM8750_ADCTL1:
s->monomix[1] = (value >> 1) & 1;
break;
case WM8750_PWR1:
s->enable = ((value >> 6) & 7) == 3;
wm8750_set_format(s);
break;
case WM8750_LINVOL:
s->invol[0] = value & 0x3f;
s->inmute[0] = (value >> 7) & 1;
wm8750_vol_update(s);
break;
case WM8750_RINVOL:
s->invol[1] = value & 0x3f;
s->inmute[1] = (value >> 7) & 1;
wm8750_vol_update(s);
break;
case WM8750_ADCDAC:
s->pol = (value >> 5) & 3;
s->mute = (value >> 3) & 1;
wm8750_vol_update(s);
break;
case WM8750_ADCTL3:
break;
case WM8750_LADC:
s->invol[2] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_RADC:
s->invol[3] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_ALC1:
s->alc = (value >> 7) & 3;
break;
case WM8750_NGATE:
case WM8750_3D:
break;
case WM8750_LDAC:
s->outvol[0] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_RDAC:
s->outvol[1] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_BASS:
break;
case WM8750_LOUTM1:
s->path[0] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_LOUTM2:
s->path[1] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_ROUTM1:
s->path[2] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_ROUTM2:
s->path[3] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_MOUTM1:
s->mpath[0] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_MOUTM2:
s->mpath[1] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_LOUT1V:
s->outvol[2] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_LOUT2V:
s->outvol[4] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_ROUT1V:
s->outvol[3] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_ROUT2V:
s->outvol[5] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_MOUTV:
s->outvol[6] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_ADCTL2:
break;
case WM8750_PWR2:
s->power = value & 0x7e;
wm8750_vol_update(s);
break;
case WM8750_IFACE:
s->format = value;
s->master = (value >> 6) & 1;
wm8750_clk_update(s, s->master);
break;
case WM8750_SRATE:
s->rate = &wm_rate_table[(value >> 1) & 0x1f];
wm8750_clk_update(s, 0);
break;
case WM8750_RESET:
wm8750_reset(&s->i2c);
break;
#ifdef VERBOSE
default:
printf("%s: unknown register %02x\n", __FUNCTION__, cmd);
#endif
}
return 0;
}
| 1threat |
why does kable not print when used within a function in rmarkdown : <p>I have to repeat certain outputs in many rmarkdown reports and want to write a function to use for this.</p>
<p>Calling a function outputs plots ok when I knit the rmd file but not kable data frames.</p>
<p>For example</p>
<pre><code>---
title: "Markdown example"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Markdown example
```{r mtcars}
make_outputs <- function(){
knitr::kable(head(mtcars))
plot(mtcars$mpg, mtcars$cyl)
hist(mtcars$cyl)
}
make_outputs()
```
</code></pre>
<p>Displays the plots but not the kable table.</p>
| 0debug |
c# exception “not all code path return a value” : <p>Hi all I have a method to update my MySQL. I'm using a MS Visual Studio </p>
<pre><code>public static User updateUser(string name, string passwd)
{
MySqlConnection connection = new MySqlConnection(conn);
MySqlCommand cmd;
string query = "UPDATE USER SET Name='" + name +, Password='" + pass + "' ";
try
{
connection.Open();
cmd = connection.CreateCommand();
cmd.CommandText = query;
cmd.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
}
</code></pre>
<p>the above returns an error saying not all code paths return a value.</p>
| 0debug |
I am trying to develop a chart just like this one : [![chart][1]][1]
[Watch this video from 7:58 to 9:40][2]
All suggestions are appreciated.
[1]: https://i.stack.imgur.com/GAIGt.png
[2]: https://www.youtube.com/watch?v=uT7mLsh18XQ&t=749s | 0debug |
static void pci_basic_config(void)
{
QVirtIO9P *v9p;
void *addr;
size_t tag_len;
char *tag;
int i;
qvirtio_9p_start();
v9p = qvirtio_9p_pci_init();
addr = ((QVirtioPCIDevice *) v9p->dev)->addr + VIRTIO_PCI_CONFIG_OFF(false);
tag_len = qvirtio_config_readw(v9p->dev,
(uint64_t)(uintptr_t)addr);
g_assert_cmpint(tag_len, ==, strlen(mount_tag));
addr += sizeof(uint16_t);
tag = g_malloc(tag_len);
for (i = 0; i < tag_len; i++) {
tag[i] = qvirtio_config_readb(v9p->dev, (uint64_t)(uintptr_t)addr + i);
}
g_assert_cmpmem(tag, tag_len, mount_tag, tag_len);
g_free(tag);
qvirtio_9p_pci_free(v9p);
qvirtio_9p_stop();
}
| 1threat |
static int protocol_client_auth(VncState *vs, uint8_t *data, size_t len)
{
if (data[0] != vs->vd->auth) {
VNC_DEBUG("Reject auth %d\n", (int)data[0]);
vnc_write_u32(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
} else {
VNC_DEBUG("Client requested auth %d\n", (int)data[0]);
switch (vs->vd->auth) {
case VNC_AUTH_NONE:
VNC_DEBUG("Accept auth none\n");
if (vs->minor >= 8) {
vnc_write_u32(vs, 0);
vnc_flush(vs);
}
start_client_init(vs);
break;
case VNC_AUTH_VNC:
VNC_DEBUG("Start VNC auth\n");
start_auth_vnc(vs);
break;
#ifdef CONFIG_VNC_TLS
case VNC_AUTH_VENCRYPT:
VNC_DEBUG("Accept VeNCrypt auth\n");;
start_auth_vencrypt(vs);
break;
#endif
#ifdef CONFIG_VNC_SASL
case VNC_AUTH_SASL:
VNC_DEBUG("Accept SASL auth\n");
start_auth_sasl(vs);
break;
#endif
default:
VNC_DEBUG("Reject auth %d\n", vs->vd->auth);
vnc_write_u8(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
}
}
return 0;
}
| 1threat |
int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
AVFilterBufferRef **picref_ptr, AVRational *tb)
{
int ret;
AVFilterBufferRef *picref;
if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
return ret;
if (!(picref = ctx->inputs[0]->cur_buf))
return AVERROR(ENOENT);
*picref_ptr = picref;
ctx->inputs[0]->cur_buf = NULL;
*tb = ctx->inputs[0]->time_base;
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
frame->pkt_pos = picref->pos;
frame->interlaced_frame = picref->video->interlaced;
frame->top_field_first = picref->video->top_field_first;
frame->key_frame = picref->video->key_frame;
frame->pict_type = picref->video->pict_type;
frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
return 1;
} | 1threat |
Search for byte pattern in node.js Buffer : <p>I have this node.js Buffer.</p>
<pre><code>var test_buf = "5E4D802158D002001022201022AB778899A1B2C3";
var buffer_hex = new Buffer(test_buf, "hex");
</code></pre>
<p>I want to search for the existence of byte pattern <code>77 88 99</code> in <code>buffer_hex</code>. From the tutorial <a href="http://www.tutorialspoint.com/nodejs/nodejs_buffers.htm" rel="noreferrer">http://www.tutorialspoint.com/nodejs/nodejs_buffers.htm</a>, I cannot find a suitable Buffer function to use. Any suggestions? </p>
| 0debug |
i got this interview question and i am not sure what is best answer When in the lifecycle would you bind to events? in reactjs : <p>When in the lifecycle would you bind to events? in reactjs</p>
| 0debug |
ASP.NET Core Environment variable colon in Linux : <p>In ASP.NET Core nested configuration via environment variables is typically done via colon syntax:</p>
<p><code>MySettings:SomeSetting=MyNewValue</code></p>
<p>How do you do this in Linux? The <code>export</code> command rejects the colon?
eg:</p>
<p><code>export MySettings:SomeSetting=MyNewValue</code></p>
<p>Errors with </p>
<pre><code>bash: export: `MySettings:SomeSetting=MyNewValue': not a valid identifier
</code></pre>
| 0debug |
static int usb_linux_update_endp_table(USBHostDevice *s)
{
uint8_t *descriptors;
uint8_t devep, type, configuration, alt_interface;
struct usb_ctrltransfer ct;
int interface, ret, length, i;
ct.bRequestType = USB_DIR_IN;
ct.bRequest = USB_REQ_GET_CONFIGURATION;
ct.wValue = 0;
ct.wIndex = 0;
ct.wLength = 1;
ct.data = &configuration;
ct.timeout = 50;
ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);
if (ret < 0) {
perror("usb_linux_update_endp_table");
return 1;
}
if (configuration == 0)
return 1;
descriptors = &s->descr[18];
length = s->descr_len - 18;
i = 0;
if (descriptors[i + 1] != USB_DT_CONFIG ||
descriptors[i + 5] != configuration) {
DPRINTF("invalid descriptor data - configuration\n");
return 1;
}
i += descriptors[i];
while (i < length) {
if (descriptors[i + 1] != USB_DT_INTERFACE ||
(descriptors[i + 1] == USB_DT_INTERFACE &&
descriptors[i + 4] == 0)) {
i += descriptors[i];
continue;
}
interface = descriptors[i + 2];
ct.bRequestType = USB_DIR_IN | USB_RECIP_INTERFACE;
ct.bRequest = USB_REQ_GET_INTERFACE;
ct.wValue = 0;
ct.wIndex = interface;
ct.wLength = 1;
ct.data = &alt_interface;
ct.timeout = 50;
ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);
if (ret < 0) {
alt_interface = interface;
}
if (descriptors[i + 3] != alt_interface) {
i += descriptors[i];
continue;
}
while (i < length && descriptors[i +1] != USB_DT_ENDPOINT)
i += descriptors[i];
if (i >= length)
break;
while (i < length) {
if (descriptors[i + 1] != USB_DT_ENDPOINT)
break;
devep = descriptors[i + 2];
switch (descriptors[i + 3] & 0x3) {
case 0x00:
type = USBDEVFS_URB_TYPE_CONTROL;
break;
case 0x01:
type = USBDEVFS_URB_TYPE_ISO;
break;
case 0x02:
break;
case 0x03:
type = USBDEVFS_URB_TYPE_INTERRUPT;
break;
}
s->endp_table[(devep & 0xf) - 1].type = type;
s->endp_table[(devep & 0xf) - 1].halted = 0;
i += descriptors[i];
}
}
return 0;
} | 1threat |
static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
{
SliceContext *slice = link->dst->priv;
int y2, ret = 0;
if (slice_dir == 1) {
for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) {
ret = ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir);
if (ret < 0)
return ret;
}
if (y2 < y + h)
return ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir);
} else if (slice_dir == -1) {
for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) {
ret = ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir);
if (ret < 0)
return ret;
}
if (y2 > y)
return ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir);
}
return 0;
}
| 1threat |
Dynamic Menu Bar with Chiled Relation In MVC Ajax Call : Hi i am student working on a Project in MVC i am Creating Dynamic Menu bar i retrieve Main Menu successfully Now stuck how to get thier Child Menu here is my code and table
---------------------------
ID ParentID MenuName
---------------------------
1 NULL Home
2 Null Contact Us
3 2 Address
4 2 Place
//html
<div id="menu">
<ul>
</ul>
</div>
//jquery code
function LoadMenubarSuccess(response) {
if (response != undefined && response != null && response.length > 0) {
var IncidentData = "<ul>";
$.each(response, function (index, Obj) {
if (Obj.ParentMenuID == null || Obj.ParentMenuID == 0) {
IncidentData += "<li>"
+ "<a href='" + Obj.Url + "'>" + Obj.MenuName + "</a>"
+ "</li>"
}
if (Obj.ParentMenuID == !null || Obj.ParentMenuID > 0) {
//Chiled Menu???
}
});
IncidentData +="</ul>";
$("#menu").html(IncidentData.replace(/null/g, ' - '));
}
} | 0debug |
int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
{
if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1;
*inv_table = c->srcColorspaceTable;
*table = c->dstColorspaceTable;
*srcRange = c->srcRange;
*dstRange = c->dstRange;
*brightness= c->brightness;
*contrast = c->contrast;
*saturation= c->saturation;
return 0;
}
| 1threat |
create email address validation in this formet in javascript :
**An acceptable email address should meet following criteria to be called a valid email address**
> Contains exactly one '@'
> Minimum 2 characters before '@'
> Any characters including numbers and special characters before '@' are allowed.
> Contains at least one '.' after '@'
> Any number of '.' are allowed after '@'
> Only alphabets and '.' are allowed after '@'
> Minimum 2 characters required between '@' and '.' after '@'
> Minimum 2 characters required between two '.' if more than one '.' is present after '@'
> Minimum 2 characters required after last '.' | 0debug |
qemu_irq *arm_gic_init(uint32_t base, qemu_irq parent_irq)
{
gic_state *s;
qemu_irq *qi;
int iomemtype;
s = (gic_state *)qemu_mallocz(sizeof(gic_state));
if (!s)
return NULL;
qi = qemu_allocate_irqs(gic_set_irq, s, GIC_NIRQ);
s->parent_irq = parent_irq;
if (base != 0xffffffff) {
iomemtype = cpu_register_io_memory(0, gic_cpu_readfn,
gic_cpu_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
iomemtype = cpu_register_io_memory(0, gic_dist_readfn,
gic_dist_writefn, s);
cpu_register_physical_memory(base + 0x1000, 0x00000fff, iomemtype);
s->base = base;
} else {
s->base = 0;
}
gic_reset(s);
return qi;
}
| 1threat |
Multiplying by width/height in processing : In processing I keep getting 0 when I multiply width or height by a number for example:
int x = width*2;
I get x = 0
Why??? | 0debug |
memset_s(): What does the standard mean with this piece of text? : <p>In C11, K.3.7.4.1 <em>The memset_s function</em>, I found this bit of rather confusing text:</p>
<blockquote>
<p>Unlike <code>memset</code>, any call to the <code>memset_s</code> function shall be evaluated strictly according to the rules of the abstract machine as described in (5.1.2.3). That is, any call to the <code>memset_s</code> function shall assume that the memory indicated by <code>s</code> and <code>n</code> may be accessible in the future and thus must contain the values indicated by <code>c</code>.</p>
</blockquote>
<p>This implies that <code>memset</code> is <em>not</em> (necessarily) "evaluated strictly according to the rules of the abstract machine". (The chapter referenced is 5.1.2.3 <em>Program execution</em>.)</p>
<p><strong>I fail to understand the leeway the standard gives to <code>memset</code> that is explicitly ruled out here for <code>memset_s</code>, and what that would mean for an implementor of either function.</strong></p>
| 0debug |
static uint64_t pl011_read(void *opaque, hwaddr offset,
unsigned size)
{
PL011State *s = (PL011State *)opaque;
uint32_t c;
if (offset >= 0xfe0 && offset < 0x1000) {
return s->id[(offset - 0xfe0) >> 2];
}
switch (offset >> 2) {
case 0:
s->flags &= ~PL011_FLAG_RXFF;
c = s->read_fifo[s->read_pos];
if (s->read_count > 0) {
s->read_count--;
if (++s->read_pos == 16)
s->read_pos = 0;
}
if (s->read_count == 0) {
s->flags |= PL011_FLAG_RXFE;
}
if (s->read_count == s->read_trigger - 1)
s->int_level &= ~ PL011_INT_RX;
pl011_update(s);
if (s->chr) {
qemu_chr_accept_input(s->chr);
}
return c;
case 1:
return 0;
case 6:
return s->flags;
case 8:
return s->ilpr;
case 9:
return s->ibrd;
case 10:
return s->fbrd;
case 11:
return s->lcr;
case 12:
return s->cr;
case 13:
return s->ifl;
case 14:
return s->int_enabled;
case 15:
return s->int_level;
case 16:
return s->int_level & s->int_enabled;
case 18:
return s->dmacr;
default:
qemu_log_mask(LOG_GUEST_ERROR,
"pl011_read: Bad offset %x\n", (int)offset);
return 0;
}
}
| 1threat |
The active solution configuration is not configured to build or deploy the Service Fabric Application Project : <p>I have a Service Fabric project with multiple services. When i try to deploy it, i get the following error:</p>
<blockquote>
<p>The active solution configuration is not configured to build or deploy
the Service Fabric Application Project. This can happen if the
solution configuration is not configured to build/deploy the x64
platform which the project requires.</p>
</blockquote>
| 0debug |
static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,
IndividualChannelStream *ics, int decode)
{
const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
int w, filt, m, i;
int bottom, top, order, start, end, size, inc;
float lpc[TNS_MAX_ORDER];
float tmp[TNS_MAX_ORDER];
for (w = 0; w < ics->num_windows; w++) {
bottom = ics->num_swb;
for (filt = 0; filt < tns->n_filt[w]; filt++) {
top = bottom;
bottom = FFMAX(0, top - tns->length[w][filt]);
order = tns->order[w][filt];
if (order == 0)
continue;
compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
start = ics->swb_offset[FFMIN(bottom, mmm)];
end = ics->swb_offset[FFMIN( top, mmm)];
if ((size = end - start) <= 0)
continue;
if (tns->direction[w][filt]) {
inc = -1;
start = end - 1;
} else {
inc = 1;
}
start += w * 128;
if (decode) {
for (m = 0; m < size; m++, start += inc)
for (i = 1; i <= FFMIN(m, order); i++)
coef[start] -= coef[start - i * inc] * lpc[i - 1];
} else {
for (m = 0; m < size; m++, start += inc) {
tmp[0] = coef[start];
for (i = 1; i <= FFMIN(m, order); i++)
coef[start] += tmp[i] * lpc[i - 1];
for (i = order; i > 0; i--)
tmp[i] = tmp[i - 1];
}
}
}
}
}
| 1threat |
Combining audio and video tracks into new MediaStream : <p>I need to get create a MediaStream using audio and video from different MediaStreams. In Firefox, I can instantiate a new MediaStream from an Array of tracks:</p>
<pre><code> var outputTracks = [];
outputTracks = outputTracks.concat(outputAudioStream.getTracks());
outputTracks = outputTracks.concat(outputVideoStream.getTracks());
outputMediaStream = new MediaStream(outputTracks);
</code></pre>
<p>Unfortunately, this doesn't work in Chrome:</p>
<blockquote>
<p>ReferenceError: MediaStream is not defined</p>
</blockquote>
<p>Is there an alternative method in Chrome for combining tracks from separate streams?</p>
| 0debug |
Ember include in-app shared components addon in in-app engine : <p>In an Ember application that contains an in-app engine (my-engine) and an in-app addon for shared components (shared-components), how do you include the shared components addon as a dependency of the in-app engine so you may use the components in the templates of the engine? The shared components addon has two components, global-header and global-footer. </p>
| 0debug |
Boostrap Form with PHP, MySQL not sending data to database : <p>I've been trying to debug this for ages now and don't understand why is it not sending data to my database. Also as an indication, I'm using Boostrap and this form is inside of a modal. Can someone help me out please. I will include my html snipet as well as php code. </p>
<p>HTML CODE</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><form class="form-horizontal" role="form" action="register.php" method="POST">
<div class="input-group margin-bottom-sm"><span class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span> <input class="form-control" type="text" name="fname" id="FirstName" placeholder="First Name" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="lname" id="LastName" placeholder="Last Name" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-calendar" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="dob" id="dob" placeholder="Date of Birth" required>
</div><br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-book" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="school" id="SchoolName" placeholder="School" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="username" id="Username" placeholder="Username" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></span>
<input class="form-control" type="password" name="pass" data-minlenght= "6" id="Pass" placeholder="Password" required>
</div><div class="help-block">Minimum of 6 characters</div></br></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></span>
<input class="form-control" type="password" id="inputPasswordConfirm" data-match="#inputPassword"
data-match-error="Whoops, these don't match" placeholder="Confirm" required>
</div></br>
<div class="form-group">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" id="register">Sing Up</button>
</div>
</form></code></pre>
</div>
</div>
</p>
<p>PHP </p>
<pre><code><?php
$conn=mysqli_connect("localhost","mydatabase","mypassword")
or die("Could not connect:".mysqli_error($conn));
mysqli_select_db($conn , 'mydatabase') or die ('Database will not open');
if(isset($_POST['register'])){
$fname = ($_POST['FirstName']);
$lname = ($_POST['LastName']);
$dob = ($_POST['dob']);
$school = ($_POST['SchoolName']);
$username = ($_POST['Username']);
$pass = ($_POST['Pass']);
$query = "INSERT INTO users (FirstName,LastName,dob,SchoolName,Username,Pass)VALUES('$FirstName','$LastName','$Username','$dob', '$SchoolName','$Pass',)";
$result = mysqli_query($conn,$query);
}
?>
</code></pre>
| 0debug |
void *g_malloc(size_t size)
{
char * p;
size += 16;
p = bsd_vmalloc(size);
*(size_t *)p = size;
return p + 16;
}
| 1threat |
How to partition input field to appear as separate input fields on screen? : <p>Look at the image:</p>
<p><a href="https://i.stack.imgur.com/LoVqe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LoVqe.png" alt="enter image description here"></a></p>
<p>I want design something like in the image, where a 4 digit one time password (OTP) is to be entered by user. Right now I have achieved this by 4 separate inputs and then combining values in javascript:</p>
<pre><code><input type="text" class="form-control" placeholder="0" maxlength="1" />
<input type="text" class="form-control" placeholder="0" maxlength="1" />
<input type="text" class="form-control" placeholder="0" maxlength="1" />
<input type="text" class="form-control" placeholder="0" maxlength="1" />
</code></pre>
<p>I am not sure if this is correct approach. I think there must be some styling options by which one input textbox would appear as partitioned one like in the image. Is it possible using bootstrap? How to style one input control to be appeared as partitioned field of inputs?</p>
| 0debug |
How to remove lag when using more than 50,000 options in <select> tag in html?? : <p>I am fetching options for the dropdown menu from database.
I have already used select2.js but it is not working.
Whenever I click on the dropdown menu the page stops responding.</p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
Given BX. Get it Mirrored and put in CX. How to do this? : <p>Given BX. Get it Mirrored. <em>You can only use SHR, SHL, AND, OR, XOR</em>.</p>
<p>For example:BX = 1234h CX = 4321h</p>
| 0debug |
What is the efficient way to parse JSON array in swift : <p>As of now am parsing the JSON data directly from array,without model class. Please suggest the efficient way to parse JSON either to use model class or directly parse JSON data.</p>
| 0debug |
Excel VBA Macro to Loop and Copy Data to a new sheet : I have an excel workbook with multiple tabs formatted like this:
[1]: https://i.stack.imgur.com/9MAWi.png
I'm learning vba but don't know the excel functions well enough yet to loop through the rows and copy the data reformatted to a new sheet into this format:
[2]: https://i.stack.imgur.com/Uy6aD.png
Specifically I think i need to
a. Initialize the range of worksheets
b. loop through them
c. store column headers for b through G into a variable so when the x is found it can be concatenated or copied over
d. handle the blank spaces so that the last value is used for each one
Any help appreciated. Thanks!
| 0debug |
void ff_vp3_h_loop_filter_mmx(uint8_t *src, int stride, int *bounding_values)
{
x86_reg tmp;
__asm__ volatile(
"movd -2(%1), %%mm6 \n\t"
"movd -2(%1,%3), %%mm0 \n\t"
"movd -2(%1,%3,2), %%mm1 \n\t"
"movd -2(%1,%4), %%mm4 \n\t"
TRANSPOSE8x4(%%mm6, %%mm0, %%mm1, %%mm4, -2(%2), -2(%2,%3), -2(%2,%3,2), -2(%2,%4), %%mm2)
VP3_LOOP_FILTER(%5)
SBUTTERFLY(%%mm4, %%mm3, %%mm5, bw, q)
STORE_4_WORDS((%1), (%1,%3), (%1,%3,2), (%1,%4), %%mm4)
STORE_4_WORDS((%2), (%2,%3), (%2,%3,2), (%2,%4), %%mm5)
: "=&r"(tmp)
: "r"(src), "r"(src+4*stride), "r"((x86_reg)stride), "r"((x86_reg)3*stride),
"m"(*(uint64_t*)(bounding_values+129))
: "memory"
);
}
| 1threat |
First and second half year sum display : Using Oracle i want to write a query which display sum of first and second half year data.<br>
If my data search condition like 2016/02 ~ 2017/12.i want to display result like below.<br>
1.Sum of price from 2016/01/01 ~ 2016/06/30 - First half year row<br>
2.Sum of price from 2016/07/01 ~ 2016/13/31 - Second half year row<br>
3.Sum of price from 2017/01/01 ~ 2017/06/30 - First half year row<br>
have any suggestion ?
| 0debug |
Excel data validation restrict other numbering formats except the given one : my numbering format is "00-000" where 00(left) must not be less than 1 or greater than 12 while 000(right) can be infinite.Also "-" must be present in between both numbers. I want to put restriction through data validation is that when anyone tries to insert any other numbers than the given format it should give error. | 0debug |
uint32_t kvmppc_get_vmx(void)
{
return kvmppc_read_int_cpu_dt("ibm,vmx");
}
| 1threat |
Decode JSON into Elm Maybe : <p>Given the following JSON:</p>
<pre><code>[
{
"id": 0,
"name": "Item 1",
"desc": "The first item"
},
{
"id": 1,
"name": "Item 2"
}
]
</code></pre>
<p>How do you decode that into the following Model:</p>
<pre><code>type alias Model =
{ id : Int
, name : String
, desc : Maybe String
}
</code></pre>
| 0debug |
How to target a component in svelte with css? : <p>How would I do something like this:</p>
<pre><code><style>
Nested {
color: blue;
}
</style>
<Nested />
</code></pre>
<p>i.e. How do I apply a style to a component from its parent?</p>
| 0debug |
static VncClientInfo *qmp_query_vnc_client(const VncState *client)
{
struct sockaddr_storage sa;
socklen_t salen = sizeof(sa);
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
VncClientInfo *info;
if (getpeername(client->csock, (struct sockaddr *)&sa, &salen) < 0) {
return NULL;
}
if (getnameinfo((struct sockaddr *)&sa, salen,
host, sizeof(host),
serv, sizeof(serv),
NI_NUMERICHOST | NI_NUMERICSERV) < 0) {
return NULL;
}
info = g_malloc0(sizeof(*info));
info->base = g_malloc0(sizeof(*info->base));
info->base->host = g_strdup(host);
info->base->service = g_strdup(serv);
info->base->family = inet_netfamily(sa.ss_family);
info->base->websocket = client->websocket;
if (client->tls) {
info->x509_dname = qcrypto_tls_session_get_peer_name(client->tls);
info->has_x509_dname = info->x509_dname != NULL;
}
#ifdef CONFIG_VNC_SASL
if (client->sasl.conn && client->sasl.username) {
info->has_sasl_username = true;
info->sasl_username = g_strdup(client->sasl.username);
}
#endif
return info;
}
| 1threat |
Laravel 5.3 db:seed command simply doesn't work : <p>I do everything by-the-book: </p>
<ol>
<li><p>Installed fresh Laravel 5.3.9 app (all my non-fresh apps produce the same error)</p></li>
<li><p>run <code>php artisan make:auth</code></p></li>
<li><p>create migrations for a new table
`php artisan make:migration create_quotations_table --create=quotations</p>
<pre><code>Schema::create('quotations', function (Blueprint $table) {
$table->increments('id');
$table->string('text');
// my problem persists even with the below two columns commented out
$table->integer('creator_id')->unsigned()->index('creator_id');
$table->integer('updater_id')->unsigned()->index('updater_id');
$table->softDeletes();
$table->timestamps();
});
</code></pre></li>
<li><p>Then I run <code>php artisan migrate</code></p></li>
<li><p>Then I define a new seed <code>php artisan make:seeder QuotationsTableSeeder</code></p></li>
</ol>
<p>The complete content of the file, after I add a simple insert:</p>
<pre><code><?php
use Illuminate\Database\Seeder;
class QuotationsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('quotations')->insert([
'text' => str_random(10),
]);
}
}
</code></pre>
<ol start="6">
<li>Then I run <code>php artisan db:seed</code></li>
</ol>
<h2>problem</h2>
<p>it simply doesn't work. No feedback presented, no errors in log file.
The probem persists in both my local environment (Win7, newest WAMP server)
and my Digital Ocean VPS powered by Ubuntu 16.04.
All the above steps I took in several separate apps - for no result. Also under Laragon 2.0.5 server.</p>
<h2>what I have tried</h2>
<p><code>php artisan optimize</code> <a href="http://laravel.io/forum/04-22-2015-cant-seed-db-in-laravel-5" rel="noreferrer">as suggested here</a>.</p>
<p><code>composer dump-autoload</code> i <code>php artisan clear-compiled</code> also have brought no results</p>
<p>I also tried to seed just following the official docs example - failed.</p>
<p>I added <code>use DB;</code> to the seed file - still no result.</p>
<h2>to do</h2>
<p>help!!! How come they don't work?</p>
| 0debug |
how to setup bootstrap 4 scss with react webpack : <p>i'm starting a new project using reactjs ES6 and webpack</p>
<p>using <a href="https://github.com/kriasoft/react-static-boilerplate" rel="noreferrer">react-static-boilerplate starter</a> question is how can i import bootstrap4 into the build proccess ?</p>
<p>i dont want to use the bootstrap.css generated file, instead i want webpack to build it for me so i can get to change its @variables and apply my theme etc.</p>
<p>i started project by cloning boilerplate</p>
<pre><code>> git clone -o react-static-boilerplate -b master --single-branch \
https://github.com/kriasoft/react-static-boilerplate.git MyApp
>cd MyApp && npm install
</code></pre>
<ol start="2">
<li><p>installed bootstrap using npm</p>
<p>npm install bootstrap@4.0.0-alpha.3</p></li>
</ol>
<p>now if i required the main bootstrap file into my index.js it will load fine. but how can i include the sass files of bootsrap to start customizing it ?</p>
| 0debug |
Print type of variable in python3.5 on django 1.8 : <p>I am having a hard time of determining the type of my variable since I am used on python2 and have just migrated to python3</p>
<pre><code>from django.http import HttpResponse
def myview(request):
x = "Name"
print (x)
print type(x)
return HttpResponse("Example output")
</code></pre>
<p>This code will throw an error because of print type(x). However if you changed that syntax line to type(x). The type does not return an output on the runserver of django.</p>
| 0debug |
static int get_phys_addr_v6(CPUState *env, uint32_t address, int access_type,
int is_user, uint32_t *phys_ptr, int *prot)
{
int code;
uint32_t table;
uint32_t desc;
uint32_t xn;
int type;
int ap;
int domain;
uint32_t phys_addr;
table = get_level1_table_address(env, address);
desc = ldl_phys(table);
type = (desc & 3);
if (type == 0) {
code = 5;
domain = 0;
goto do_fault;
} else if (type == 2 && (desc & (1 << 18))) {
domain = 0;
} else {
domain = (desc >> 4) & 0x1e;
}
domain = (env->cp15.c3 >> domain) & 3;
if (domain == 0 || domain == 2) {
if (type == 2)
code = 9;
else
code = 11;
goto do_fault;
}
if (type == 2) {
if (desc & (1 << 18)) {
phys_addr = (desc & 0xff000000) | (address & 0x00ffffff);
} else {
phys_addr = (desc & 0xfff00000) | (address & 0x000fffff);
}
ap = ((desc >> 10) & 3) | ((desc >> 13) & 4);
xn = desc & (1 << 4);
code = 13;
} else {
table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc);
desc = ldl_phys(table);
ap = ((desc >> 4) & 3) | ((desc >> 7) & 4);
switch (desc & 3) {
case 0:
code = 7;
goto do_fault;
case 1:
phys_addr = (desc & 0xffff0000) | (address & 0xffff);
xn = desc & (1 << 15);
break;
case 2: case 3:
phys_addr = (desc & 0xfffff000) | (address & 0xfff);
xn = desc & 1;
break;
default:
abort();
}
code = 15;
}
if (xn && access_type == 2)
goto do_fault;
if ((env->cp15.c1_sys & (1 << 29)) && (ap & 1) == 0) {
code = (code == 15) ? 6 : 3;
goto do_fault;
}
*prot = check_ap(env, ap, domain, access_type, is_user);
if (!*prot) {
goto do_fault;
}
*phys_ptr = phys_addr;
return 0;
do_fault:
return code | (domain << 4);
}
| 1threat |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Problems pushing in javascript (Cannot read property 'push' of null) : <p>I'm new on javascript and I am having a lot of trouble finding the error to this program:</p>
<pre><code>const listaTweets = document.getElementById("lista-tweets");
//Función para agregar tweets
document.getElementById("formulario").addEventListener("submit", function(e){
e.preventDefault;
//Capturar mensaje
const tweet = document.getElementById("tweet").value;
const lista = document.createElement("li");
lista.innerText = tweet;
//Añadir botón "borrar"
const botonBorrar = document.createElement("a");
botonBorrar.innerText = "X";
botonBorrar.classList = "borrar-tweet";
//Añadir elementos al DOM
lista.appendChild(botonBorrar);
listaTweets.appendChild(lista);
//Añadir tweet a Local Storage
agregarTweetLocalStorage(tweet);
});
//Función para elimitar tweets
document.getElementById("lista-tweets").addEventListener("click", function(e){
e.preventDefault();
if(e.target.className === "borrar-tweet"){
e.target.parentElement.remove();
}
});
//Función para agregar tweets a Local Storage
function agregarTweetLocalStorage(tweet){
let tweets;
//Activar función para obtener tweets y guardar nuevos
tweets = obtenerTweetsLocalStorage()
tweets.push(tweet);
//Convertir arreglo a string para que JSON lo pueda leer
localStorage.setItem("tweets", JSON.stringify(tweets));
}
//Función para leer/obtener los tweets
function obtenerTweetsLocalStorage(){
let tweets;
if(localStorage.getItem("tweets") === "null"){
tweets = [];
}else{
//Conversión del arreglo a JSON
tweets = JSON.parse(localStorage.getItem("tweets"));
}
return tweets;
}
</code></pre>
<p>I'm trying to figure out what is exactly the problem, i know that is on the push() function but i don't really know.</p>
<p>Can you help me please?</p>
| 0debug |
Searching lists then calling same place from other lists : <p>I wish for my program to search resident and if it a specific value it will print the same placed data from other lists. For example in this situation I would want it to print; </p>
<p>"Name is Alan, age is 7 and they do not live in place",</p>
<p>as well as,</p>
<p>"Name is Margaret, age is 66 and they do not live in place"</p>
<pre><code>name = ["Alan", "Susan", "Margaret"]
age = [7, 34, 66]
resident = [0, 1, 0]
if resident = 0:
print ("name is {}, age is {} and they do not live in place".format(name[], age[]))
</code></pre>
| 0debug |
void pl050_init(uint32_t base, qemu_irq irq, int is_mouse)
{
int iomemtype;
pl050_state *s;
s = (pl050_state *)qemu_mallocz(sizeof(pl050_state));
iomemtype = cpu_register_io_memory(0, pl050_readfn,
pl050_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
s->irq = irq;
s->is_mouse = is_mouse;
if (is_mouse)
s->dev = ps2_mouse_init(pl050_update, s);
else
s->dev = ps2_kbd_init(pl050_update, s);
}
| 1threat |
how to solve this expression taking in mind precedence and associativity in c? : Int m=4 ,s=5;
m = (p=s) * (p==s);
Printf("%d",m);
How to solve this expression in c?
What will be the value of m?
How parenthesis () changes the precedence of operators in this example?
| 0debug |
static av_always_inline void MPV_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int dir,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16],
int is_mpeg12)
{
int i;
int mb_y = s->mb_y;
prefetch_motion(s, ref_picture, dir);
if (!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B) {
apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
return;
}
switch (s->mv_type) {
case MV_TYPE_16X16:
if (s->mcsel) {
if (s->real_sprite_warping_points == 1) {
gmc1_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
} else {
gmc_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
}
} else if (!is_mpeg12 && s->quarter_sample) {
qpel_motion(s, dest_y, dest_cb, dest_cr,
0, 0, 0,
ref_picture, pix_op, qpix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
s->mspel && s->codec_id == AV_CODEC_ID_WMV2) {
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else {
mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
}
break;
case MV_TYPE_8X8:
if (!is_mpeg12)
apply_8x8(s, dest_y, dest_cb, dest_cr,
dir, ref_picture, qpix_op, pix_op);
break;
case MV_TYPE_FIELD:
if (s->picture_structure == PICT_FRAME) {
if (!is_mpeg12 && s->quarter_sample) {
for (i = 0; i < 2; i++)
qpel_motion(s, dest_y, dest_cb, dest_cr,
1, i, s->field_select[dir][i],
ref_picture, pix_op, qpix_op,
s->mv[dir][i][0], s->mv[dir][i][1], 8);
} else {
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
0, s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y);
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, s->field_select[dir][1],
ref_picture, pix_op,
s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
}
} else {
if (s->picture_structure != s->field_select[dir][0] + 1 &&
s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y >> 1);
}
break;
case MV_TYPE_16X8:
for (i = 0; i < 2; i++) {
uint8_t **ref2picture;
if (s->picture_structure == s->field_select[dir][i] + 1
|| s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
ref2picture = ref_picture;
} else {
ref2picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][i],
ref2picture, pix_op,
s->mv[dir][i][0], s->mv[dir][i][1] + 16 * i,
8, mb_y >> 1);
dest_y += 16 * s->linesize;
dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
}
break;
case MV_TYPE_DMV:
if (s->picture_structure == PICT_FRAME) {
for (i = 0; i < 2; i++) {
int j;
for (j = 0; j < 2; j++)
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
j, j ^ i, ref_picture, pix_op,
s->mv[dir][2 * i + j][0],
s->mv[dir][2 * i + j][1], 8, mb_y);
pix_op = s->hdsp.avg_pixels_tab;
}
} else {
for (i = 0; i < 2; i++) {
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->picture_structure != i + 1,
ref_picture, pix_op,
s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
16, mb_y >> 1);
pix_op = s->hdsp.avg_pixels_tab;
if (!s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
}
}
break;
default: assert(0);
}
}
| 1threat |
How to change with js / jquery attribute onkeyup with another function : <p>How can I change value of HTML onkeyup attribute with js/jquery?</p>
| 0debug |
static int nbd_can_accept(void *opaque)
{
return nb_fds < shared;
}
| 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 == -1)
expr_error(mon, "unknown register");
else if (ret == -2)
expr_error(mon, "no cpu defined");
n = reg;
}
break;
case '\0':
expr_error(mon, "unexpected end of expression");
n = 0;
break;
default:
#if TARGET_PHYS_ADDR_BITS > 32
n = strtoull(pch, &p, 0);
#else
n = strtoul(pch, &p, 0);
#endif
if (pch == p) {
expr_error(mon, "invalid char in expression");
}
pch = p;
while (qemu_isspace(*pch))
pch++;
break;
}
return n;
}
| 1threat |
How do I load a node module as if the current module were located somewhere else? : <p>I have some nodejs code running in a module somewhere. From this module, I would like to load a module located in a completely different place in the file system -- for example, given the path <code>"/another/dir"</code> and the module name <code>"foo"</code>, I would like Node to act as if a module running in <code>/another/dir</code> had called <code>require("foo")</code>, rather than my own module.</p>
<pre><code> My code is running here
/some/folder/node_modules/mine/my_module.js
I have the path "/another/dir/", the string "foo",
and want to load this module
/another/dir/node_modules/foo/index.js
</code></pre>
<p>In other words, the <a href="https://nodejs.org/api/modules.html#modules_all_together" rel="noreferrer">module documentation</a> refers to the process <em>"require(X) from module at path Y"</em>, and I would like to specify my own value for <code>Y</code></p>
<p>Can this be accomplished? If so, how? If not, why not?</p>
| 0debug |
void stb_phys(target_phys_addr_t addr, uint32_t val)
{
uint8_t v = val;
cpu_physical_memory_write(addr, &v, 1);
}
| 1threat |
deear friends am working on a POS project and am stack at an error about Is operator : Severity Code Description Project File Line Suppression State
Error BC30020 'Is' operator does not accept operands of type 'Integer'. Operands must be reference or nullable types. POS C:\Users\pc\Desktop\POS\POS\GUI\MainWindow.vb 134 Active
now the message above is the error is get. when i change the "Is" to "=" the DGV
gets an error but when i change it to "IS" the R.Barcode gets an error
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'get the details of the item
Dim R As POS.POSDS.ItemsRow = CType(Button1.Tag, POSDS.ItemsRow)
'next search for the barcode in the DGV
Dim I As Integer
Dim ItemLoc As Integer = -1
For I = 0 To DGV2.Rows.Count - 1
If **R.Barcode Is DGV2.Rows**(I).Cells(0).Value Then
ItemLoc = I
Exit For
End If
Next
End Sub | 0debug |
void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
{
kvm_s390_interrupt_internal(cpu, type, code, 0, 0);
}
| 1threat |
How to get Custom date format from timestamp php : <p>I have a time stamp like this code below.</p>
<pre><code>$time=time();
</code></pre>
<p>Please Explain how can i make a custom date from this.</p>
| 0debug |
static int check_write_unsafe(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
if (!bs->probed) {
return 0;
}
if (sector_num == 0 && nb_sectors > 0) {
return check_for_block_signature(bs, buf);
}
return 0;
}
| 1threat |
static void breakpoint_invalidate(CPUArchState *env, target_ulong pc)
{
tb_invalidate_phys_addr(cpu_get_phys_page_debug(env, pc));
}
| 1threat |
static int sdp_parse(AVFormatContext *s, const char *content)
{
const char *p;
int letter;
char buf[16384], *q;
SDPParseState sdp_parse_state, *s1 = &sdp_parse_state;
memset(s1, 0, sizeof(SDPParseState));
p = content;
for(;;) {
skip_spaces(&p);
letter = *p;
if (letter == '\0')
break;
p++;
if (*p != '=')
goto next_line;
p++;
q = buf;
while (*p != '\n' && *p != '\r' && *p != '\0') {
if ((q - buf) < sizeof(buf) - 1)
*q++ = *p;
p++;
}
*q = '\0';
sdp_parse_line(s, s1, letter, buf);
next_line:
while (*p != '\n' && *p != '\0')
p++;
if (*p == '\n')
p++;
}
return 0;
}
| 1threat |
What is the difference between != and <> operators in php? : <p>I am new to the php and what is the main difference between those operators </p>
| 0debug |
static int parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers)
{
int i;
HEVCLocalContext *lc = s->HEVClc;
GetBitContext *gb = &lc->gb;
decode_profile_tier_level(s, &ptl->general_PTL);
ptl->general_PTL.level_idc = get_bits(gb, 8);
for (i = 0; i < max_num_sub_layers - 1; i++) {
ptl->sub_layer_profile_present_flag[i] = get_bits1(gb);
ptl->sub_layer_level_present_flag[i] = get_bits1(gb);
}
if (max_num_sub_layers - 1> 0)
for (i = max_num_sub_layers - 1; i < 8; i++)
skip_bits(gb, 2);
for (i = 0; i < max_num_sub_layers - 1; i++) {
if (ptl->sub_layer_profile_present_flag[i])
decode_profile_tier_level(s, &ptl->sub_layer_PTL[i]);
if (ptl->sub_layer_level_present_flag[i])
ptl->sub_layer_PTL[i].level_idc = get_bits(gb, 8);
}
return 0;
}
| 1threat |
the \b flag not working in javascript regrex : I am new to regular expressions and basically just playing around with them in my brower console , using MDN as a referance , i tried the below regrex:
/\bg/g.test('me building and him')
even if i try `/\bg/g` , i still get false, WHY ?
The MDN definition says the following for `\b`:
> Matches a zero-width word boundary, such as between a letter and a
> space. (Not to be confused with [\b])
>
> For example, /\bno/ matches the "no" in "at noon"; /ly\b/ matches the
> "ly" in "possibly yesterday".
So why is the `g` at the end of building not being matched ? , can anybody explain ? | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.