problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
{
uint16_t nodenr;
uint16List *cpus = NULL;
if (node->has_nodeid) {
nodenr = node->nodeid;
} else {
nodenr = nb_numa_nodes;
}
if (nodenr >= MAX_NODES) {
error_setg(errp, "Max number of NUMA nodes reached: %"
PRIu16 "", nodenr);
return;
}
if (numa_info[nodenr].present) {
error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr);
return;
}
for (cpus = node->cpus; cpus; cpus = cpus->next) {
if (cpus->value > MAX_CPUMASK_BITS) {
error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",
cpus->value, MAX_CPUMASK_BITS);
return;
}
bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);
}
if (node->has_mem && node->has_memdev) {
error_setg(errp, "qemu: cannot specify both mem= and memdev=");
return;
}
if (have_memdevs == -1) {
have_memdevs = node->has_memdev;
}
if (node->has_memdev != have_memdevs) {
error_setg(errp, "qemu: memdev option must be specified for either "
"all or no nodes");
return;
}
if (node->has_mem) {
uint64_t mem_size = node->mem;
const char *mem_str = qemu_opt_get(opts, "mem");
if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) {
mem_size <<= 20;
}
numa_info[nodenr].node_mem = mem_size;
}
if (node->has_memdev) {
Object *o;
o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL);
if (!o) {
error_setg(errp, "memdev=%s is ambiguous", node->memdev);
return;
}
object_ref(o);
numa_info[nodenr].node_mem = object_property_get_int(o, "size", NULL);
numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);
}
numa_info[nodenr].present = true;
max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
}
| 1threat
|
Tidy evaluation programming with dplyr::case_when : <p>I try to write a simple function wrapping around the dplyr::case_when() function. I read the <em>programming with dplyr</em> documentation on <a href="https://cran.r-project.org/web/packages/dplyr/vignettes/programming.html" rel="noreferrer">https://cran.r-project.org/web/packages/dplyr/vignettes/programming.html</a> but can't figure out how this works with the case_when() function. </p>
<p>I have the following data:</p>
<pre><code>data <- tibble(
item_name = c("apple", "bmw", "bmw")
)
</code></pre>
<p>And the following list:</p>
<pre><code>cat <- list(
item_name == "apple" ~ "fruit",
item_name == "bmw" ~ "car"
)
</code></pre>
<p>Then I would like to write a function like:</p>
<pre><code>category_fn <- function(df, ...){
cat1 <- quos(...)
df %>%
mutate(category = case_when((!!!cat1)))
}
</code></pre>
<p>Unfortunately <code>category_fn(data,cat)</code> gives an evaluation error in this case. I would like to obtain the same output as the output obtained by:</p>
<pre><code>data %>%
mutate(category = case_when(item_name == "apple" ~ "fruit",
item_name == "bmw" ~ "car"))
</code></pre>
<p>What is the way to do this?</p>
| 0debug
|
How do i find empty cells or cells with   in td in table and make it editable using js and jquery : I am working with huge table like i have 5000 tds and i want make all the empty cells or cells with only   editable using js and jquery
| 0debug
|
Why do I have to set the dataSource and delegate to self? : <p>I'm learning swift, and the course I'm following teaches tableViews. It I have to set the <code>TableViewController</code> t include <code>UITableViewDataSource</code> and <code>UITableViewDelegate</code>. Then, in <code>viewDidLoad</code>, I have to set </p>
<pre><code>tableView.dataSource = self
tableView.delegate = self
</code></pre>
<p>in order for the tableView to appear and load data. </p>
<p>Why do I have to do this?</p>
| 0debug
|
how to updaload image twice with diffrent sizes : <p>hello i have project i work on , it have some issues ,</p>
<p>the problem here i need to get file twice once to move it and one with resizing </p>
<p>this is my code , what should i do here</p>
<pre><code> public function update_image(Request $request)
{
$ad = Ad::where('id',$request->ad_id)->first();
$photos= explode('||',$ad->photos);
$thumbnails= explode('||',$ad->thumbnails);
$number = count($photos);
$length = strlen($photos[$number-1]);
$last_image_number = $photos[$number-1][$length - 5];
// dd($photos[$number-1][$length - 5]);
$last_image_number++;
$image = $request->file('image');
$image_name = 'preview_'.$last_image_number.'.'.$image->getClientOriginalExtension();
$previews_path = public_path().'/uploads/images/'.$ad->ad_id.'/previews/';
$thumbs_path = public_path().'/uploads/images/'.$ad->ad_id.'/thumbnails/';
// $im = Image::make($image->getFullPath());
chmod($previews_path,0777);
$image->move($previews_path,$image_name);
$photos[]= '/'.$ad->ad_id.'/previews/'.$image_name;
$ad->photos = implode('||',$photos);
$photo_path = basename($previews_path . $image_name);
$ad->save();
list($width, $heigh) = getimagesize($previews_path.$photo_path);
$photo_path->move($thumbs_path,'ddd.jpg');
dd($photo_path);
// dd($width);
$ratio = $width/ $heigh;
$target_width = $width / $ratio;
$target_height = $target_width / $ratio;
$photo_path->resize($target_width,$target_height);
$thumb_name= 'thumbnail_'.$last_image_number.'.'.$image->getClientOriginalExtension();
$image->move($thumbs_path , $thumb_name);
$thumbnails [] = '/'.$ad->ad_id.'/thumbnails/'.$thumb_name;
$ad->thumbnails = implode('||',$thumbnails);
$ad->save();
// dd($image_name);
return response()->json(['success'=>true]);
</code></pre>
| 0debug
|
how to pass parameter to where clause dyanamically in store procedure :
ALTER PROCEDURE [dbo].[GetCustomers_PagerSelected]
@PageIndex INT
,@PageSize INT = 10
,@SubCondition nvarchar(max)
,@RecordCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY [Plan_Id] ASC
)AS RowNumber
,[Plan_Id]
,[User_Id]
,[Plan_Name]
,[ImageCount]
,[PlanPrice]
,'../User/HomePlanImage/' + CONVERT(varchar(5), User_Id ) +'/' + CONVERT(varchar(5), Plan_Id ) + '/' + CONVERT(varchar(5),1) +'.jpg' AS PlanImagePath
INTO #Results
FROM [mf_BuildingPlanDetails]
WHERE IsActive=1 @SubCondition
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
| 0debug
|
static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
NBDExportInfo *info, Error **errp)
{
nbd_opt_reply reply;
uint32_t len = strlen(wantname);
uint16_t type;
int error;
char *buf;
info->flags = 0;
trace_nbd_opt_go_start(wantname);
buf = g_malloc(4 + len + 2 + 1);
stl_be_p(buf, len);
memcpy(buf + 4, wantname, len);
stw_be_p(buf + 4 + len, 0);
if (nbd_send_option_request(ioc, NBD_OPT_GO, len + 6, buf, errp) < 0) {
return -1;
}
while (1) {
if (nbd_receive_option_reply(ioc, NBD_OPT_GO, &reply, errp) < 0) {
return -1;
}
error = nbd_handle_reply_err(ioc, &reply, errp);
if (error <= 0) {
return error;
}
len = reply.length;
if (reply.type == NBD_REP_ACK) {
if (len) {
error_setg(errp, "server sent invalid NBD_REP_ACK");
nbd_send_opt_abort(ioc);
return -1;
}
if (!info->flags) {
error_setg(errp, "broken server omitted NBD_INFO_EXPORT");
nbd_send_opt_abort(ioc);
return -1;
}
trace_nbd_opt_go_success();
return 1;
}
if (reply.type != NBD_REP_INFO) {
error_setg(errp, "unexpected reply type %" PRIx32 ", expected %x",
reply.type, NBD_REP_INFO);
nbd_send_opt_abort(ioc);
return -1;
}
if (len < sizeof(type)) {
error_setg(errp, "NBD_REP_INFO length %" PRIu32 " is too short",
len);
nbd_send_opt_abort(ioc);
return -1;
}
if (nbd_read(ioc, &type, sizeof(type), errp) < 0) {
error_prepend(errp, "failed to read info type");
nbd_send_opt_abort(ioc);
return -1;
}
len -= sizeof(type);
be16_to_cpus(&type);
switch (type) {
case NBD_INFO_EXPORT:
if (len != sizeof(info->size) + sizeof(info->flags)) {
error_setg(errp, "remaining export info len %" PRIu32
" is unexpected size", len);
nbd_send_opt_abort(ioc);
return -1;
}
if (nbd_read(ioc, &info->size, sizeof(info->size), errp) < 0) {
error_prepend(errp, "failed to read info size");
nbd_send_opt_abort(ioc);
return -1;
}
be64_to_cpus(&info->size);
if (nbd_read(ioc, &info->flags, sizeof(info->flags), errp) < 0) {
error_prepend(errp, "failed to read info flags");
nbd_send_opt_abort(ioc);
return -1;
}
be16_to_cpus(&info->flags);
trace_nbd_receive_negotiate_size_flags(info->size, info->flags);
break;
default:
trace_nbd_opt_go_info_unknown(type, nbd_info_lookup(type));
if (nbd_drop(ioc, len, errp) < 0) {
error_prepend(errp, "Failed to read info payload");
nbd_send_opt_abort(ioc);
return -1;
}
break;
}
}
}
| 1threat
|
Xcode build error - Multiple commands produce .o, Target 'ProjectCoreData' has compile command for Swift source files listed twice : <p>I am running xCode Version 10.1 (10B61), Mojave 10.14 (18A391)</p>
<p>Searching shows similar issue in Xcode 10 greater than a year ago, but no issues since then. The solution from last year seemed to be switching to legacy mode, but that doesn't work now. It appears the source code that is stored on my desktop is conflicting with code that is in 'DerivedData', I'm not sure why this would suddenly pop up so randomly.</p>
<p>I see this problem go away if I remove the last model added in Core Data. It seems to trigger when I add a relationship to another object. It's apparently random.</p>
<p>Any advice on how to fix this issue so I can develop? </p>
<pre><code>Multiple commands produce '//Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/Objects-normal/x86_64/Contact+CoreDataClass.o':
Target 'ProjectCoreData' (project 'ProjectCoreData') has compile command for Swift source files
Target 'ProjectCoreData' (project 'ProjectCoreData') has compile command for Swift source files
</code></pre>
<p>from the logs:</p>
<pre><code><unknown>:0: error: filename "Contact+CoreDataClass.swift" used twice: '/Users/<user>/Desktop/ProjectCoreData/Contact+CoreDataClass.swift' and '/Users/<user>/Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/DerivedSources/CoreDataGenerated/ProjectCoreData/Contact+CoreDataClass.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
<unknown>:0: error: filename "Contact+CoreDataProperties.swift" used twice: '/Users/<user>/Desktop/ProjectCoreData/Contact+CoreDataProperties.swift' and '/Users/<user>/Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/DerivedSources/CoreDataGenerated/ProjectCoreData/Contact+CoreDataProperties.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
</code></pre>
| 0debug
|
Why is my program is outputting '0' when run, even though it is not supposed too? : <p>I am quite new to c++, and was just playing around with if statements, so I made this program:</p>
<pre><code>#include <iostream>
using namespace std;
int getMax(int num1, int num2){
if (num1>num2)
{
cout << num1 <<endl;
}else{
cout << num2 <<endl;
}
return EXIT_SUCCESS;
}
int main(){
cout<<getMax(7,13)<<endl;
return 0;
}
</code></pre>
<p>My getMax function takes two parmeters and is supposed to output the greater of the 2 numbers — in this case 13. But instead of only outputting 13, it also outputs 0. Why is this happening?</p>
| 0debug
|
Gradle does not find my tests with Kotlin and JUnit 5 : <p>I have written some basic unit tests with Kotlin and Junit 5. Unfortunately, when I run them from Intellij IDEA, the tests are not found by Gradle.
I am getting the message "No tests found for given includes: [de.mhaug.phd.btcwallet.BasicTests]" from Gradle and the message "Test event not received" from Intellij. </p>
<p>Interestingly, running it from the commandline with "./gradlew :clean :test" reports a successful build. However, my first test is obviously red, so this shows that Gradle did not execute it.</p>
<p>I already tried running it with more verbose output but nothing helpful showed up. Here is a minimal (not) working example:</p>
<pre><code>package de.mhaug.phd.btcwallet
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Test
class BasicTests {
@Test
fun hey() {
assertEquals(3,1+1)
}
@Test
fun hey2() {
assertFalse(3==1+1)
}
}
</code></pre>
<p>This is my build.gradle:</p>
<pre><code>buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
group 'de.mhaug.phd'
version '1.0-SNAPSHOT'
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.0.2'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.0.2'
// testCompile group: 'org.junit.platform', name: 'junit-platform-runner', version: ''
// testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.0.2'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
</code></pre>
<p>How can I make Intellij/Gradle execute my tests?</p>
| 0debug
|
How to change data in notepad using python : <p>Ok so I want to make a simple game where it's essential for the game to save. I wish to store all the data in notepad. However how do I pull notepad into python. I have tried saving notepad into the same folder where my .py file is. Then in the program im not sure what to do. Im just very confused on how to do this. I do know how to program in python, but how do I pull data out of notepad into python.</p>
<p>Also I wish to know how would I change the inside of the notepad file. Let's just say it has a couple of variables with certain numbers. I want to change those in game.</p>
<p>Thank you for any answers. :)</p>
| 0debug
|
Put SVG images next to each other : HTML
<div class="button">
<a href="#">
<img id="img1" src="icons/onas1.svg" alt="O nas[enter image description here][1]">
</>
<a href="#">
<img id="img2" src="icons/kontakt1.svg" alt="kontakt">
</a>
</div>
</div>
CSS:
div.button img{
position: fixed;
height: 10%;
display: inline-block;
}
Hey, how can I put these two images next to each other?
https://i.stack.imgur.com/2vD2T.jpg
| 0debug
|
Add a resizing layer to a keras sequential model : <p>How can I add a resizing layer to </p>
<pre><code>model = Sequential()
</code></pre>
<p>using </p>
<pre><code>model.add(...)
</code></pre>
<p>To resize an image from shape (160, 320, 3) to (224,224,3) ?</p>
| 0debug
|
static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
Error **errp)
{
PCIQXLDevice *qxl = opaque;
VGACommonState *vga = &qxl->vga;
switch (qxl->mode) {
case QXL_MODE_COMPAT:
case QXL_MODE_NATIVE:
qxl_render_update(qxl);
ppm_save(filename, qxl->ssd.ds, errp);
break;
case QXL_MODE_VGA:
vga->screen_dump(vga, filename, cswitch, errp);
break;
default:
break;
}
}
| 1threat
|
QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
{
QapiDeallocVisitor *v;
v = g_malloc0(sizeof(*v));
v->visitor.start_struct = qapi_dealloc_start_struct;
v->visitor.end_struct = qapi_dealloc_end_struct;
v->visitor.start_implicit_struct = qapi_dealloc_start_implicit_struct;
v->visitor.end_implicit_struct = qapi_dealloc_end_implicit_struct;
v->visitor.start_list = qapi_dealloc_start_list;
v->visitor.next_list = qapi_dealloc_next_list;
v->visitor.end_list = qapi_dealloc_end_list;
v->visitor.type_enum = qapi_dealloc_type_enum;
v->visitor.type_int64 = qapi_dealloc_type_int64;
v->visitor.type_uint64 = qapi_dealloc_type_uint64;
v->visitor.type_bool = qapi_dealloc_type_bool;
v->visitor.type_str = qapi_dealloc_type_str;
v->visitor.type_number = qapi_dealloc_type_number;
v->visitor.type_any = qapi_dealloc_type_anything;
v->visitor.start_union = qapi_dealloc_start_union;
QTAILQ_INIT(&v->stack);
return v;
}
| 1threat
|
static void nand_command(NANDFlashState *s)
{
unsigned int offset;
switch (s->cmd) {
case NAND_CMD_READ0:
s->iolen = 0;
break;
case NAND_CMD_READID:
s->ioaddr = s->io;
s->iolen = 0;
nand_pushio_byte(s, s->manf_id);
nand_pushio_byte(s, s->chip_id);
nand_pushio_byte(s, 'Q');
if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) {
nand_pushio_byte(s, (s->buswidth == 2) ? 0x55 : 0x15);
} else {
nand_pushio_byte(s, 0xc0);
}
break;
case NAND_CMD_RANDOMREAD2:
case NAND_CMD_NOSERIALREAD2:
if (!(nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP))
break;
offset = s->addr & ((1 << s->addr_shift) - 1);
s->blk_load(s, s->addr, offset);
if (s->gnd)
s->iolen = (1 << s->page_shift) - offset;
else
s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
break;
case NAND_CMD_RESET:
nand_reset(&s->busdev.qdev);
break;
case NAND_CMD_PAGEPROGRAM1:
s->ioaddr = s->io;
s->iolen = 0;
break;
case NAND_CMD_PAGEPROGRAM2:
if (s->wp) {
s->blk_write(s);
}
break;
case NAND_CMD_BLOCKERASE1:
break;
case NAND_CMD_BLOCKERASE2:
s->addr &= (1ull << s->addrlen * 8) - 1;
if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP)
s->addr <<= 16;
else
s->addr <<= 8;
if (s->wp) {
s->blk_erase(s);
}
break;
case NAND_CMD_READSTATUS:
s->ioaddr = s->io;
s->iolen = 0;
nand_pushio_byte(s, s->status);
break;
default:
printf("%s: Unknown NAND command 0x%02x\n", __FUNCTION__, s->cmd);
}
}
| 1threat
|
static void vnc_dpy_setdata(DisplayChangeListener *dcl,
DisplayState *ds)
{
VncDisplay *vd = ds->opaque;
qemu_pixman_image_unref(vd->guest.fb);
vd->guest.fb = pixman_image_ref(ds->surface->image);
vd->guest.format = ds->surface->format;
vnc_dpy_update(dcl, ds, 0, 0, ds_get_width(ds), ds_get_height(ds));
}
| 1threat
|
static int mpeg1_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
ParseContext *pc= &s->parse_context;
int i;
uint32_t state;
state= pc->state;
i=0;
if(!pc->frame_start_found){
for(i=0; i<buf_size; i++){
state= (state<<8) | buf[i];
if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){
i++;
pc->frame_start_found=1;
break;
}
}
}
if(pc->frame_start_found){
for(; i<buf_size; i++){
state= (state<<8) | buf[i];
if((state&0xFFFFFF00) == 0x100){
if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){
pc->frame_start_found=0;
pc->state=-1;
return i-3;
}
}
}
}
pc->state= state;
return -1;
}
| 1threat
|
int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
{
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_ioctl)
return drv->bdrv_ioctl(bs, req, buf);
return -ENOTSUP;
}
| 1threat
|
calculate the difference between two time durations php : <p>I Have two-time durations</p>
<ol>
<li>5 hours and 55 minutes. </li>
<li>6 hours.</li>
</ol>
<p>expecting the answer +5.00 or -5.00 for the difference between. </p>
<p>what are the best options to resolve the matter? </p>
| 0debug
|
Google Map JavaScript API from server page : I hava a problem about Google Map JavaScript API access.
I can access Google Maps API with Javascript class, google.maps.DirectionsService and google.maps.Geocoder, from my local html file (C:\path\to\google.html).
script tag is:
<script async defer type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initialize"></script>
but I can't do it with same source on localhost server(http://localhost:8080/static/path/to/google.html).
The console.log() message is:
Directions Service: This API project is not authorized to use this API. For more information on authentication and Google Maps JavaScript API services please see: https://developers.google.com/maps/documentation/javascript/get-api-key
How can I access there?
| 0debug
|
Swift Detect Every Time Device Orientation Changes : <p>I'm creating an iPhone game in Xcode with the latest version of Swift. Why I'm asking this question is when the user flips the phone and changes the orientation, is there any way I can detect that, so I can change the placing, size, etc. of things?</p>
| 0debug
|
How can this small C program work? Variables are equal to zero but enters loop anyway : Im experimenting on a very low level with some C coding. This is not an actual problem because the program works as i wish, but could someone explain to me how the following conditions in the while-loop are evaluated?
I read that int variables without any given value equal to zero? Then 0+0 should be zero? But the program enters the while-loop anyway...
Thanks in advance.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int randomNumber1;
int randomNumber2;
int answer;
while (randomNumber1+randomNumber2!=answer){
randomNumber1=(rand()%100)+1;
randomNumber2=(rand()%100)+1;
printf("\nWhat is %i + %i= ", randomNumber1, randomNumber2);
scanf("%i,", &answer);
if (randomNumber1+randomNumber2==answer){
printf("Very Good\n");
}
else
{
printf("Wrong answer.\n");
}
}
}
| 0debug
|
static int mpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
Mpeg1Context *s = avctx->priv_data;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
av_dlog(avctx, "fill_buffer\n");
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
if (s2->low_delay == 0 && s2->next_picture_ptr) {
*picture = s2->next_picture_ptr->f;
s2->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame);
}
return buf_size;
}
if (s2->flags & CODEC_FLAG_TRUNCATED) {
int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
if (ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0)
return buf_size;
}
s2->codec_tag = avpriv_toupper4(avctx->codec_tag);
if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
|| s2->codec_tag == AV_RL32("BW10")
))
vcr2_init_sequence(avctx);
s->slice_count = 0;
if (avctx->extradata && !avctx->frame_number) {
int ret = decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
}
return decode_chunks(avctx, picture, data_size, buf, buf_size);
}
| 1threat
|
How to include untyped node modules with Typescript 1.8? : <blockquote>
<p>Typescript 1.8 now supports untyped JS files. To enable this feature,
just add the compiler flag --allowJs or add "allowJs": true to
compilerOptions in tsconfig.json</p>
</blockquote>
<p>via <a href="https://blogs.msdn.microsoft.com/typescript/2016/01/28/announcing-typescript-1-8-beta/">https://blogs.msdn.microsoft.com/typescript/2016/01/28/announcing-typescript-1-8-beta/</a></p>
<p>I'm trying to import <a href="https://github.com/zilverline/react-tap-event-plugin">react-tap-event-plugin</a> which does not have a typings file.</p>
<pre><code>import * as injectTapEventPlugin from 'injectTapEventPlugin';
</code></pre>
<p>says module not found. So i tried:</p>
<pre><code>import * as injectTapEventPlugin from '../node_modules/react-tap-event-plugin/src/injectTapEventPlugin.js';
</code></pre>
<p>This says Module resolves to a non-module entity and cannot be imported using this construct. And then I tried:</p>
<pre><code>import injectTapEventPlugin = require('../node_modules/react-tap-event-plugin/src/injectTapEventPlugin.js');
</code></pre>
<p>It's crashing with <code>ERROR in ./scripts/index.tsx
Module build failed: TypeError: Cannot read property 'kind' of undefined</code> at <code>node_modules/typescript/lib/typescript.js:39567</code></p>
<p>My tsconfig:</p>
<pre><code>{
"compilerOptions": {
"target": "ES5",
"removeComments": true,
"jsx": "react",
"module": "commonjs",
"sourceMap": true,
"allowJs": true
},
"exclude": [
"node_modules"
]
}
</code></pre>
<p>I'm using webpack with ts-loader:</p>
<pre><code> {
test: /\.tsx?$/,
exclude: ['node_modules', 'tests'],
loader: 'ts-loader'
}
</code></pre>
| 0debug
|
static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
int a_avail, int c_avail,
int16_t **dc_val_ptr, int *dir_ptr)
{
int a, b, c, wrap, pred;
int16_t *dc_val;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int q1, q2 = 0;
wrap = s->block_wrap[n];
dc_val = s->dc_val[0] + s->block_index[n];
c = dc_val[ - 1];
b = dc_val[ - 1 - wrap];
a = dc_val[ - wrap];
q1 = s->current_picture.f.qscale_table[mb_pos];
if (c_avail && (n != 1 && n != 3)) {
q2 = s->current_picture.f.qscale_table[mb_pos - 1];
if (q2 && q2 != q1)
c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && (n != 2 && n != 3)) {
q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
if (q2 && q2 != q1)
a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && c_avail && (n != 3)) {
int off = mb_pos;
if (n != 1)
off--;
if (n != 2)
off -= s->mb_stride;
q2 = s->current_picture.f.qscale_table[off];
if (q2 && q2 != q1)
b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && c_avail) {
if (abs(a - b) <= abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
} else if (a_avail) {
pred = a;
*dir_ptr = 0;
} else if (c_avail) {
pred = c;
*dir_ptr = 1;
} else {
pred = 0;
*dir_ptr = 1;
}
*dc_val_ptr = &dc_val[0];
return pred;
}
| 1threat
|
explaining constuctor and coppy costructor example : i have this code and i can understand what happening with the contractor of class Fat.
#include <iostream>
using namespace std;
class Block{ int data;
public:
Block(int i = 10) : data(i)
{ cout << "I just created a Block " << endl; }
~Block() { cout << "I will destroy a Block with " << data << endl; }
void inc() { data++; } };
class A{ Block& block1; Block block2;
public :
A(Block& blk) : block1(blk),block2(blk)
{ cout << "I just created an A " << endl; }
A(const A& a): block1(a.block1), block2(a.block2) {
cout << "I just created an A by copying but I will also do bad things" << endl;
block1.inc(); block2.inc(); }
~A() { cout << "I will destroy an A " << endl; }
void inc() { block1.inc(); block2.inc(); } };
class Fat{ A a; A& ra; A* pa;
public:
Fat(A& da) : a(da),ra(da) { pa = new A(da);
cout << "Fat just created !" << endl;}
~Fat() { delete pa;
cout << "Fat to be destroyed !" << endl; }
void inc() { a.inc(); ra.inc(); pa->inc(); } };
int main(){ Block block; A a(block); Fat fat(a);
fat.inc();
return 0; }
and the result of this :
I just created a Block
I just created an A
I just created an A by copying but I will also do bad things
I just created an A by copying but I will also do bad things
Fat just created !
I will destroy an A
I will destroy a Block with 12
Fat to be destroyed !
I will destroy an A
I will destroy a Block with 12
I will destroy an A
I will destroy a Block with 11
I will destroy a Block with 15
why copy contractor run twice?
| 0debug
|
Is it possible to dump the AST while building an Xcode project? : <p>I've been doing some work on analyzing Swift projects using their ASTs, and I would like to know if it is possible to generate it somehow when building a Swift project with Xcode.</p>
<p>Right now, I am able to print the AST on the terminal when running the <code>swiftc -dump-ast</code> command for single files and simple projects. However, it becomes harder when using it for more complex projects. </p>
<p>For this reason, I'd like to use xcode. I already tried to pass the <code>-dump-ast</code> flag to the compiler in Build Settings > Swift Compiler - Custom Flags > Other Swift Flags. The flag was indeed passed to the compiler (the output does report calling swiftc with the -dump-ast flag when building). I tried to build the project both with xcode and through the <code>xcodebuild</code>command below, but neither dumped the ast. </p>
<pre><code>xcodebuild -target 'CompilingTest.xcodeproj' -scheme 'CompilingTest' -
configuration "Debug" -sdk iphoneos -arch "armv7"
CONFIGURATION_BUILD_DIR="TestBuild" ONLY_ACTIVE_ARCH=NO
</code></pre>
<p>Now, I'm reasoning that either Xcode's build process redirects swiftc's output to some file, or it silences it somehow. Any thoughts?</p>
<p>Any help would be greatly appreciated.</p>
| 0debug
|
static int slirp_smb(SlirpState* s, const char *exported_dir,
struct in_addr vserver_addr)
{
static int instance;
char smb_conf[128];
char smb_cmdline[128];
FILE *f;
snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d",
(long)getpid(), instance++);
if (mkdir(s->smb_dir, 0700) < 0) {
error_report("could not create samba server dir '%s'", s->smb_dir);
return -1;
}
snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf");
f = fopen(smb_conf, "w");
if (!f) {
slirp_smb_cleanup(s);
error_report("could not create samba server configuration file '%s'",
smb_conf);
return -1;
}
fprintf(f,
"[global]\n"
"private dir=%s\n"
"smb ports=0\n"
"socket address=127.0.0.1\n"
"pid directory=%s\n"
"lock directory=%s\n"
"log file=%s/log.smbd\n"
"smb passwd file=%s/smbpasswd\n"
"security = share\n"
"[qemu]\n"
"path=%s\n"
"read only=no\n"
"guest ok=yes\n",
s->smb_dir,
s->smb_dir,
s->smb_dir,
s->smb_dir,
s->smb_dir,
exported_dir
);
fclose(f);
snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s",
SMBD_COMMAND, smb_conf);
if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) {
slirp_smb_cleanup(s);
error_report("conflicting/invalid smbserver address");
return -1;
}
return 0;
}
| 1threat
|
Convert string text into an array : <p>I have string in DB that looks like this</p>
<pre><code>1233,3332,2333,2333
</code></pre>
<p>How can I convert it so it becomes like this:</p>
<pre><code>'1233','3332','2333','2333'
</code></pre>
<p>with php. Thanks in advance</p>
| 0debug
|
static uint32_t qpci_spapr_io_readl(QPCIBus *bus, void *addr)
{
QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
uint64_t port = (uintptr_t)addr;
uint32_t v;
if (port < s->pio.size) {
v = readl(s->pio_cpu_base + port);
} else {
v = readl(s->mmio_cpu_base + port);
}
return bswap32(v);
}
| 1threat
|
Format on python string gives error : <p>In python, I'm trying to create a string by format()</p>
<pre><code>json_data_resp = '{"error":false,"code":"{0}","mac":"{1}","message":"Device configured successfully"}'.format(activation_code, macaddress)
</code></pre>
<p>When I execute this code, it gives me an error like so:</p>
<blockquote>
<p>KeyError: '"error"'</p>
</blockquote>
<p>What is it that I'm doing incorrectly?</p>
| 0debug
|
User Control Won't Return Value : I am writing a user control. I want it to return a customer number when the user double clicks on the customer. I can't seem to get it to work. The user control is displayed and, on the double click, the data shows in the messagebox but I can't seem to get it to update the value on the main form. Anytime I try to add a return value into FindCustomerControl_ItemHasBeenSelected, I get an error. So far, this is what I have:
In my main window:
public partial class TestForm : Form
{
public TestForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// one close button on the form
Close();
}
private void ShowSelectFromListWidget()
{
// show the user control
var uc = new FindCustomerControl();
uc.ItemHasBeenSelected += uc_ItemHasBeenSelected;
MakeUserControlPrimaryWindow(uc);
}
void uc_ItemHasBeenSelected(object sender,
FindCustomerControl.SelectedItemEventArgs e)
{
// once it has been selected, change a label on the screen to show the customer number
var value = e.SelectedChoice;
lblCustomer.Text = value;
}
}
In my user control:
public partial class FindCustomerControl : UserControl
{
public class SelectedItemEventArgs : EventArgs
{
public string SelectedChoice { get; set; }
}
public event EventHandler<SelectedItemEventArgs> ItemHasBeenSelected;
public FindCustomerControl()
{
InitializeComponent();
}
DataTable dt = new DataTable();
public void btnFind_Click(object sender, EventArgs e)
{
var dt = GetData();
dataGridView1.DataSource = dt;
}
//Query database
public DataTable GetData()
{
UtilitiesClass ru = new UtilitiesClass();
string connectionString = ru.getConnectionString();
DataTable dt = new DataTable();
SqlConnection myConnection = new SqlConnection(connectionString);
try
{
myConnection.Open();
SqlCommand cmd = new SqlCommand("FindCustomer", myConnection);
cmd.Parameters.AddWithValue("@customer", txtCustomer.Text.Trim());
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ta = new SqlDataAdapter(cmd);
ta.Fill(dt);
myConnection.Close();
}
catch (Exception x)
{
MessageBox.Show(x.ToString());
}
return (dt);
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
// this updates the search window text box
int Row = dataGridView1.CurrentRow.Index;
txtCustomer.Text = dataGridView1[0, Row].Value.ToString();
}
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
var handler = ItemHasBeenSelected;
string choice = dataGridView1[0, e.RowIndex].Value.ToString();
if (handler != null) handler(this, new SelectedItemEventArgs { SelectedChoice = choice });
}
private void FindCustomerControl_Load(object sender, EventArgs e)
{
ItemHasBeenSelected += FindCustomerControl_ItemHasBeenSelected;
}
private void FindCustomerControl_ItemHasBeenSelected(object sender, SelectedItemEventArgs e)
{
// this shows it but it doesn't return it
MessageBox.Show("Chosen: " + e.SelectedChoice);
}
}
| 0debug
|
How can I change a .NET standard library to a .NET framework library? : <p>I'm writing a class library for a simple parser in C#. When I first created it, I used .NET standard 2.0, but now I need to migrate it to .NET 4.6 both to conform to the other projects in my solution and in order to use NUnit.</p>
<p>I tried to follow the instructions <a href="https://docs.microsoft.com/en-us/visualstudio/ide/how-to-target-a-version-of-the-dotnet-framework" rel="noreferrer">in the Microsoft documentation</a>, but when I try to select another framework in the properties, I can only find other .NET standard versions.</p>
<p>How can I migrate it? Will I need to manually edit the <code>.csproj</code> file?</p>
| 0debug
|
Python: set varaibles in array : <p>Is it possible to set piece array as [x , y] variable. For example, piece [ [x1,y1],[x2,y2],....] </p>
<p>Below is my code:</p>
<pre><code>piece = [[387,500] , [247,499] , [120,496] , [533,488] , [191,432] , [464,432],[328,426] , [50,426]]
if (292<x<350) and (390<y<450) in piece:
print("do something")
</code></pre>
| 0debug
|
static inline void gen_op_eval_bg(TCGv dst, TCGv_i32 src)
{
gen_mov_reg_N(cpu_tmp0, src);
gen_mov_reg_V(dst, src);
tcg_gen_xor_tl(dst, dst, cpu_tmp0);
gen_mov_reg_Z(cpu_tmp0, src);
tcg_gen_or_tl(dst, dst, cpu_tmp0);
tcg_gen_xori_tl(dst, dst, 0x1);
}
| 1threat
|
void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1)
{
int cssid, ssid, schid, m;
SubchDev *sch;
int ret = -ENODEV;
int cc;
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(&cpu->env, PGM_OPERAND, 4);
return;
}
trace_ioinst_sch_id("rsch", cssid, ssid, schid);
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_rsch(sch);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EINVAL:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
setcc(cpu, cc);
}
| 1threat
|
Is there a way to disable SSL/TLS for GitHub Pages? : <p>I have been looking for a place to store some of my XML schemas publicly without actually having to host them. I decided <a href="https://pages.github.com/" rel="noreferrer">GitHub Pages</a> would be the ideal platform. I was correct except that I cannot figure out how to turn off SSL/TLS. <strong>When I try to fetch my pages with plain old HTTP I get a <code>301 Moved Permanently</code> response.</strong></p>
<p>So obviously this isn't a big deal. Worst case scenario it takes a little longer to download my schemas, and people generally only use schemas that they've already cached anyway. But is there really no way to turn this off?</p>
| 0debug
|
sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type,
uint32_t id)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(object_new(type));
char *prop_name;
drc->id = id;
drc->owner = owner;
prop_name = g_strdup_printf("dr-connector[%"PRIu32"]",
spapr_drc_index(drc));
object_property_add_child(owner, prop_name, OBJECT(drc), NULL);
object_property_set_bool(OBJECT(drc), true, "realized", NULL);
g_free(prop_name);
if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_PCI) {
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
}
return drc;
}
| 1threat
|
static void pit_common_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = pit_common_realize;
dc->vmsd = &vmstate_pit_common;
dc->no_user = 1;
}
| 1threat
|
Serialize in JSON a base64 encoded data : <p>I'm writing a script to automate data generation for a demo and I need to serialize in a JSON some data. Part of this data is an image, so I encoded it in base64, but when I try to run my script I get:</p>
<pre><code>Traceback (most recent call last):
File "lazyAutomationScript.py", line 113, in <module>
json.dump(out_dict, outfile)
File "/usr/lib/python3.4/json/__init__.py", line 178, in dump
for chunk in iterable:
File "/usr/lib/python3.4/json/encoder.py", line 422, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.4/json/encoder.py", line 396, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.4/json/encoder.py", line 396, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.4/json/encoder.py", line 429, in _iterencode
o = _default(o)
File "/usr/lib/python3.4/json/encoder.py", line 173, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b'iVBORw0KGgoAAAANSUhEUgAADWcAABRACAYAAABf7ZytAAAABGdB...
...
BF2jhLaJNmRwAAAAAElFTkSuQmCC' is not JSON serializable
</code></pre>
<p>As far as I know, a base64-encoded-whatever (a PNG image, in this case) is just a string, so it should pose to problem to serializating. What am I missing?</p>
| 0debug
|
How do display different runs in TensorBoard? : <p>TensorBoard seems to have a feature to display multiple different runs and toggle them. </p>
<p><a href="https://i.stack.imgur.com/5E3eQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5E3eQ.png" alt="enter image description here"></a></p>
<p>How can I make multiple runs show up here and how can assign a name to them to differentiate them?</p>
| 0debug
|
Log event datetime with.Net Core Console logger : <p>I'm using logging to Console output, that built-in to .Net Core framework.
Here initialization of the logger:</p>
<pre><code>var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton(new LoggerFactory()
.AddConsole());
</code></pre>
<p>Also for logging I'm using <code>Microsoft.Extensions.Logging.LoggerExtension</code>s class with methods <code>Log...</code>
Here an example of logging in my App:</p>
<pre><code>_logger.LogInformation(eventId, "Action is started.");
</code></pre>
<p>Where <code>_logger</code> is instance of <code>ILogger<T></code> class and initialized in the class constructor with built-in dependency injection.
As result of calling of the above method Console output shows following string:</p>
<pre><code>info: NameSpaceName.ClassName[eventId] Action is started.
</code></pre>
<p>I would like to display date-time in the Console output, that points to time, when the Log method is executed, but it seems that Log.. methods don't contain any methods that allow to display date time.</p>
<p>Does it exist some method or additioanl classes-formatters that allow to display the action datetime in console output without passing it to the method as part of the message?</p>
| 0debug
|
Android studio Listview in Fragment : I want to create a ListView in Fragment but something goes wrong.
In layout listmygroups.xml are three TextViews (trainermygroupslistwhen, trainermygroupslistwhere, trainermygroupslistname).
I try to open fragment with listview(TrainerMyGroups) from another fragment by:
getFragmentManager().beginTransaction().replace(R.id.MainContainer,new TrainerMyGroups()).addToBackStack(null).commit();
TrainerMyGroups.java:
package com.hgyghyfghyu.apkana40;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
/**
* A simple {@link Fragment} subclass.
*/
public class TrainerMyGroups extends Fragment {
ListView listView;
TrainerGroupsAdapter adapter;
String when[]={"tak","ret","sd"};
String where[]={"dsf","sdf","sdfsdf"};
String name[]={"sdfsdf","xcvxcv","xcvxcv"};
public TrainerMyGroups() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_trainer_my_groups, container, false);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listView = (ListView) getActivity().findViewById(R.id.trainermygroupslistview);
adapter = new TrainerGroupsAdapter(getContext(),R.layout.list_mygroups);
listView.setAdapter(adapter);
for(int i=0;i<3;i++){
TrainerGroupsDataProvider dataprovider = new TrainerGroupsDataProvider(when[i],name[i],where[i]);
adapter.add(dataprovider);
}
}
}
TrainerGroupsAdapter.java:
package com.hgyghyfghyu.apkana40;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
import java.util.ArrayList;
/**
* Created by dd on 2016-04-04.
*/
public class TrainerGroupsAdapter extends ArrayAdapter {
List list = new ArrayList();
public TrainerGroupsAdapter(Context context, int resource) {
super(context, resource);
}
static class Datahandler{
TextView name;
TextView when;
TextView where;
}
@Override
public void add(Object object) {
super.add(object);
list.add(object);
}
@Override
public int getCount() {
return this.list.size();
}
@Override
public Object getItem(int position) {
return this.list.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row;
row=convertView;
Datahandler handler;
if(convertView==null){
LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row= inflater.inflate(R.layout.list_mygroups,parent,false);
handler = new Datahandler();
handler.name = (TextView) row.findViewById(R.id.trainermygroupslistname);
handler.where = (TextView) row.findViewById(R.id.trainermygroupslistwhere);
handler.when = (TextView) row.findViewById(R.id.trainermygroupslistwhen);
row.setTag(handler);
}
else {
handler = (Datahandler)row.getTag();
}
TrainerGroupsDataProvider dataProvider;
dataProvider = (TrainerGroupsDataProvider)this.getItem(position);
handler.name.setText(dataProvider.getName());
handler.when.setText(dataProvider.getWhen());
handler.where.setText(dataProvider.getWhere());
return row;
}
}
and there is error from AndroidMonitor
FATAL EXCEPTION: main
Process: com.hgyghyfghyu.apkana40, PID: 27778
java.lang.NullPointerException
at com.hgyghyfghyu.apkana40.TrainerMyGroups.onCreate(TrainerMyGroups.java:41)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1951)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1029)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
line 41 from TrainerMyGroups is
listView.setAdapter(adapter);
I am not sure but probably this solution works only in Activity, not in Fragment, How can I change my code to make it workable?
| 0debug
|
regex for specific username format : There's a ton of these things here and I really suck with regex/ it's been way too long since I've used it so a little bit of guidance here would be amazing.
My username criterion is simple: <br>
- Must contain 1 or more letters, anywhere <br>
- May contain any amount of numbers, anywhere <br>
- Can contain up to 2 - or _, anywhere <br>
^[0-9\\-_]*[a-z|A-Z]+[0-9\\-_]*$ is what I'm using right now but this will reject usernames such as 123hi123hi, or hi123hi - I need something less string location dependent.
Thanks for any help!
I'm using ruby on rails to match strings against this.
| 0debug
|
Converting a Regex from JS flavor to Golang flavor? : <p>I am trying to convert a certain regex from ECMAScript flavor to Golang flavor, here it is : </p>
<pre><code>((r|🇷)+)(( |\n)*)((🇪|e)+)(( |\n)*)((p|🇵)+)(( |\n)*)((🇴|o)+)(( |\n)*)((🇸|s)+)(( |\n)*)((t|🇹)+)
</code></pre>
<p>Basically the point is to match messages like "r 🇪 p O s t".
I've tried to replace " " by "\s" but it's still not working. Any idea please?</p>
| 0debug
|
Angular 8 and Observable that waits for another observable : <p>I need the data of observable1, but I need it only when observable2 is set to <code>true</code>. It is set to <code>true</code> AFTER the data of observable1 changes. How can I chain the two observables so that I will get the data of observable1 every time it changes, but that these results will wait for the change of observable2 before they are being used? </p>
| 0debug
|
How to configure setCustomValidity for selectize in onchange event? : How to configure setCustomValidity for selectize in onchange event?
every think is ok, but setCustomValidity does not work.
var countyPhoneCodeId = '#county_phone_code';
$(countyPhoneCodeId).selectize({
maxItems: 1,
labelField: 'name',
valueField: 'code',
render: {
item: function (item, escape) {
return "<div><span style='margin-top:2px' class='flag flag-" + escape(item.code) + "' /> " + escape(item.name) + "</div>";
},
option: function (item, escape) {
return "<div><span style='margin-top:2px' class='flag flag-" + escape(item.code) + "' /> " + escape(item.name) + "</div>";
}
},
onChange: function(value) {
if (value == "") {
$(countyPhoneCodeId).css('border', 'solid 2px red');
document.querySelector(countyPhoneCodeId).setCustomValidity("Դաշտը պարտադիր է");
document.querySelector(countyPhoneCodeId).reportValidity();
} else {
$(countyPhoneCodeId).css('border', 'solid 2px green');
document.querySelector(countyPhoneCodeId).setCustomValidity("");
}
}
});
| 0debug
|
is the latest mongodb 4.2 just released is a stable new version? : <p>i found on <a href="https://github.com/mongodb/mongo/tree/r4.2.0" rel="nofollow noreferrer">https://github.com/mongodb/mongo/tree/r4.2.0</a>, it is released. </p>
<p>i know, that even versions are the stable versions, so, should i start using it? </p>
<p>i can build it with my github repo, but i am on the 4.0.12...</p>
<p><a href="https://github.com/patrikx3/docker-debian-testing-mongodb-stable" rel="nofollow noreferrer">https://github.com/patrikx3/docker-debian-testing-mongodb-stable</a></p>
| 0debug
|
'setConfigSettings(FirebaseRemoteConfigSettings!): Unit' is deprecated : <p>After upgrading Firebase libraries to </p>
<pre><code>implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'com.google.firebase:firebase-config:17.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
</code></pre>
<p>and syncing Gradle, I got warning:</p>
<pre><code>'setConfigSettings(FirebaseRemoteConfigSettings!): Unit' is deprecated. Deprecated in Java
'setDeveloperModeEnabled(Boolean): FirebaseRemoteConfigSettings.Builder!' is deprecated. Deprecated in Java
</code></pre>
<p>in these lines:</p>
<pre><code>//Setting Developer Mode enabled to fast retrieve the values
firebaseRemoteConfig.setConfigSettings(
FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(BuildConfig.DEBUG)
.build())
</code></pre>
| 0debug
|
Disable Firebase in development mode in Android : <p>I am using Firebase in my android project. Wanted to know how to disable it in development mode. All crashes and usage/events are being logged and messing up with actual analytics.</p>
<p>Any better way to disable this in development mode?</p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, unsigned int *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int ret;
trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset,
*host_offset, *nb_clusters);
ret = handle_dependencies(bs, guest_offset, nb_clusters);
if (ret < 0) {
return ret;
}
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
if (*host_offset == 0) {
int64_t cluster_offset =
qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size);
if (cluster_offset < 0) {
return cluster_offset;
}
*host_offset = cluster_offset;
return 0;
} else {
ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters);
if (ret < 0) {
return ret;
}
*nb_clusters = ret;
return 0;
}
}
| 1threat
|
Pass a dynamically allocated multidimensional array to a function : <pre><code>#include<iostream>
using namespace std;
void seed(int* matrixAddr, int n, int m);
void main()
{
int n, m;
cin >> n >> m;
int matrix[n][m]; // DevC++ does not throw an error here, where VS does instead
seed(matrix, n, m);
}
void seed(int* matrixAddr, int n, int m) {}
</code></pre>
<p>Accessing <code>matrix</code> directly means referencing a memory address - in this case, to the first element of the two-dimensional array.</p>
<p>Apparently, though, the address cannot be passed as-is to the <code>seed</code> function, which accepts a pointer as its first argument. </p>
<p>Why does this happen? Should this not be allowed? </p>
<p>The error DevC++ throws is the following: <code>[Error] cannot convert 'int (*)[m]' to 'int*' for argument '1' to 'void seed(int*, int, int)'</code> </p>
| 0debug
|
How can i duplicate an HashMAP with duplicate values : so i need to create new hashmaps that contain only the duplicate values of my first hashmap
Original map: {Player1=Hello, Player2=Hi, Player3=Hi, Player4=Hello, Player5=Hello}
Hello map: {Player1=Hello,Player4=Hello, Player5=Hello}
Hi map: {Player2=Hi, Player3=Hi}
what is best way to do?
Thanks !!
| 0debug
|
Excel VBA Sheet EnableCalculation Working Intermitently : I am working on a spreadsheet for my company and I am having trouble with the EnableCalculation function. We copy large chunks of data and paste them into a workbook. To expedite this process, I 'freeze' sheets by turning the EnableCalculation to False as shown in the example ([Disabled][1]). Without this, Excel slows to a crawl while background calculations are done as the data is being pasted.
In the macro that does the calculation for this workbook once all the data has been pasted, I re-enable the calculation by setting EnableCalculation to True. ([Re-Enabled][2]) The issue that I have found, however, is that sometimes the sheets calculate properly but other times they do not with seemingly no rhyme or reason. It is extremely frustrating for it to be so unpredictable. Is there a way to ensure that the sheets calculate when they are supposed to? Thanks,
[1]: https://i.stack.imgur.com/uvV2d.png
[2]: https://i.stack.imgur.com/hJ22l.png
| 0debug
|
Write a function unction that takes as input ݊n and returns the matrix C, Cij= 0 if i/j<2 , Cij =ij^2 otherwise in MATLAB : Consider the ݊nxn matrix C with elements
Cij= 0 if i/j<2 ,
Cij =ij^2 otherwise
while 1=<i,y=<n
Write a Matlab function matSetup that takes as input ݊n and returns the matrix C .Use your function to create C for ݊ = 6. function [Cij]= matSetup(n)
I have written this but it seems not to be correct
```
function [Cij]= matSetup(n)
if (i/j)<2
Cij=0
else
Cij=i*(j)^2
while 1<i,j<n
end
end
end
```
| 0debug
|
static void check_lowpass_line(int depth){
LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);
LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);
LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);
int w = WIDTH;
int mref = WIDTH_PADDED * -1;
int pref = WIDTH_PADDED;
int i, depth_byte;
InterlaceContext s;
declare_func(void, uint8_t *dstp, ptrdiff_t linesize, const uint8_t *srcp,
ptrdiff_t mref, ptrdiff_t pref, int clip_max);
s.lowpass = 1;
s.lowpass = VLPF_LIN;
depth_byte = depth >> 3;
w /= depth_byte;
memset(src, 0, SRC_SIZE);
memset(dst_ref, 0, WIDTH_PADDED);
memset(dst_new, 0, WIDTH_PADDED);
randomize_buffers(src, SRC_SIZE);
ff_interlace_init(&s, depth);
if (check_func(s.lowpass_line, "lowpass_line_%d", depth)) {
for (i = 0; i < 32; i++) {
call_ref(dst_ref, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0);
call_new(dst_new, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0);
if (memcmp(dst_ref, dst_new, WIDTH - i))
fail();
}
bench_new(dst_new, w, src + WIDTH_PADDED, mref, pref, 0);
}
}
| 1threat
|
how to develop a basic online ordering app? : need a small clarity regarding developing an android app..basically the idea is to build an app where the user can select the items(eg.books),after selecting he will be taken to next activity where he can choose the number of items(say 2)...after selecting he will be taken to another activity where he is given option to pay online.After payment..the seller(that is me)should generate a bill containing the details provided by the user...so my doubt is...how to know what items has he selected and the details(how do i receive that info) he had entered and how do i generate a bill back to him?....please help me with this...i just need an idea of how to implement it...thank you!
| 0debug
|
RuntimeError: There is no current event loop in thread in async + apscheduler : <p>I have a async function and need to run in with apscheduller every N minutes.
There is a python code below</p>
<pre><code>URL_LIST = ['<url1>',
'<url2>',
'<url2>',
]
def demo_async(urls):
"""Fetch list of web pages asynchronously."""
loop = asyncio.get_event_loop() # event loop
future = asyncio.ensure_future(fetch_all(urls)) # tasks to do
loop.run_until_complete(future) # loop until done
async def fetch_all(urls):
tasks = [] # dictionary of start times for each url
async with ClientSession() as session:
for url in urls:
task = asyncio.ensure_future(fetch(url, session))
tasks.append(task) # create list of tasks
_ = await asyncio.gather(*tasks) # gather task responses
async def fetch(url, session):
"""Fetch a url, using specified ClientSession."""
async with session.get(url) as response:
resp = await response.read()
print(resp)
if __name__ == '__main__':
scheduler = AsyncIOScheduler()
scheduler.add_job(demo_async, args=[URL_LIST], trigger='interval', seconds=15)
scheduler.start()
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
# Execution will block here until Ctrl+C (Ctrl+Break on Windows) is pressed.
try:
asyncio.get_event_loop().run_forever()
except (KeyboardInterrupt, SystemExit):
pass
</code></pre>
<p>But when i tried to run it i have the next error info</p>
<pre><code>Job "demo_async (trigger: interval[0:00:15], next run at: 2017-10-12 18:21:12 +04)" raised an exception.....
..........\lib\asyncio\events.py", line 584, in get_event_loop
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread '<concurrent.futures.thread.ThreadPoolExecutor object at 0x0356B150>_0'.
</code></pre>
<p>Could you please help me with this?
Python 3.6, APScheduler 3.3.1, </p>
| 0debug
|
How to start mongo v4.2.0 : <p>I have successfully installed Mongo v4.2.0.</p>
<pre><code>mongo --version
MongoDB shell version v4.2.0
git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
OpenSSL version: OpenSSL 1.1.1c 28 May 2019
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1804
distarch: x86_64
target_arch: x86_64
</code></pre>
<p>But when i start mongo, it is showing error. Kindly help me out. I am using ubuntu 18.04.
mongo</p>
<pre><code>MongoDB shell version v4.2.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2019-10-07T11:35:13.915+0530 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2019-10-07T11:35:13.916+0530 F - [main] exception: connect failed
2019-10-07T11:35:13.916+0530 E - [main] exiting with code 1
</code></pre>
| 0debug
|
static int decode_init(AVCodecContext *avctx)
{
HYuvContext *s = avctx->priv_data;
int width, height;
s->avctx= avctx;
s->flags= avctx->flags;
dsputil_init(&s->dsp, avctx);
memset(s->vlc, 0, 3*sizeof(VLC));
width= s->width= avctx->width;
height= s->height= avctx->height;
avctx->coded_frame= &s->picture;
s->bgr32=1;
assert(width && height);
if(avctx->extradata_size){
if((avctx->bits_per_sample&7) && avctx->bits_per_sample != 12)
s->version=1;
else
s->version=2;
}else
s->version=0;
if(s->version==2){
int method;
method= ((uint8_t*)avctx->extradata)[0];
s->decorrelate= method&64 ? 1 : 0;
s->predictor= method&63;
s->bitstream_bpp= ((uint8_t*)avctx->extradata)[1];
if(s->bitstream_bpp==0)
s->bitstream_bpp= avctx->bits_per_sample&~7;
s->context= ((uint8_t*)avctx->extradata)[2] & 0x40 ? 1 : 0;
if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size) < 0)
return -1;
}else{
switch(avctx->bits_per_sample&7){
case 1:
s->predictor= LEFT;
s->decorrelate= 0;
break;
case 2:
s->predictor= LEFT;
s->decorrelate= 1;
break;
case 3:
s->predictor= PLANE;
s->decorrelate= avctx->bits_per_sample >= 24;
break;
case 4:
s->predictor= MEDIAN;
s->decorrelate= 0;
break;
default:
s->predictor= LEFT;
s->decorrelate= 0;
break;
}
s->bitstream_bpp= avctx->bits_per_sample & ~7;
s->context= 0;
if(read_old_huffman_tables(s) < 0)
return -1;
}
if(((uint8_t*)avctx->extradata)[2] & 0x20)
s->interlaced= ((uint8_t*)avctx->extradata)[2] & 0x10 ? 1 : 0;
else
s->interlaced= height > 288;
switch(s->bitstream_bpp){
case 12:
avctx->pix_fmt = PIX_FMT_YUV420P;
break;
case 16:
if(s->yuy2){
avctx->pix_fmt = PIX_FMT_YUV422;
}else{
avctx->pix_fmt = PIX_FMT_YUV422P;
}
break;
case 24:
case 32:
if(s->bgr32){
avctx->pix_fmt = PIX_FMT_RGBA32;
}else{
avctx->pix_fmt = PIX_FMT_BGR24;
}
break;
default:
assert(0);
}
return 0;
}
| 1threat
|
Check whether the file is password protected or not in C# : <p>I Have a path, which contains different kind of files(like .sdf,.sdb). I need to find out how many files are password protected. I searched but i found the result only for doc,xls kind of files. I need generic result. Can any one suggest me.</p>
| 0debug
|
Remove � charcter from the text : I am trying to remove � symbol from text, but my method is not working .
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/6dSHZ.jpg
This my code to remove the symbol.
public static function cleanText($text)
{
// Strip HTML Tags
$textStripped = strip_tags($text);
// Clean up things like &
$textStripped = html_entity_decode($textStripped);
// Strip out any url-encoded stuff
$textStripped = urldecode($textStripped);
return $textStripped;
}
The page encoding is utf-8.
| 0debug
|
void qmp_drive_backup(DriveBackup *arg, Error **errp)
{
return do_drive_backup(arg, NULL, errp);
}
| 1threat
|
static void avc_luma_vt_and_aver_dst_4x4_msa(const uint8_t *src,
int32_t src_stride,
uint8_t *dst, int32_t dst_stride)
{
int16_t filt_const0 = 0xfb01;
int16_t filt_const1 = 0x1414;
int16_t filt_const2 = 0x1fb;
v16u8 dst0, dst1, dst2, dst3;
v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r;
v16i8 src87_r, src2110, src4332, src6554, src8776;
v8i16 out10, out32;
v16i8 filt0, filt1, filt2;
v16u8 res;
filt0 = (v16i8) __msa_fill_h(filt_const0);
filt1 = (v16i8) __msa_fill_h(filt_const1);
filt2 = (v16i8) __msa_fill_h(filt_const2);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3,
src10_r, src21_r, src32_r, src43_r);
ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332);
XORI_B2_128_SB(src2110, src4332);
LD_SB4(src, src_stride, src5, src6, src7, src8);
ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7,
src54_r, src65_r, src76_r, src87_r);
ILVR_D2_SB(src65_r, src54_r, src87_r, src76_r, src6554, src8776);
XORI_B2_128_SB(src6554, src8776);
out10 = DPADD_SH3_SH(src2110, src4332, src6554, filt0, filt1, filt2);
out32 = DPADD_SH3_SH(src4332, src6554, src8776, filt0, filt1, filt2);
SRARI_H2_SH(out10, out32, 5);
SAT_SH2_SH(out10, out32, 7);
LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
res = PCKEV_XORI128_UB(out10, out32);
ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst1);
dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0);
dst0 = __msa_aver_u_b(res, dst0);
ST4x4_UB(dst0, dst0, 0, 1, 2, 3, dst, dst_stride);
}
| 1threat
|
AKS. Can't pull image from an acr : <p>I try to pull image from an ACR using a secret and I can't do it.</p>
<p>I created resources using azure cli commands:</p>
<pre><code>az login
az provider register -n Microsoft.Network
az provider register -n Microsoft.Storage
az provider register -n Microsoft.Compute
az provider register -n Microsoft.ContainerService
az group create --name aksGroup --location westeurope
az aks create --resource-group aksGroup --name aksCluster --node-count 1 --generate-ssh-keys -k 1.9.2
az aks get-credentials --resource-group aksGroup --name aksCluster
az acr create --resource-group aksGroup --name aksClusterRegistry --sku Basic --admin-enabled true
</code></pre>
<p>After that I logged in and pushed image successfully to created ACR from local machine.</p>
<pre><code>docker login aksclusterregistry.azurecr.io
docker tag jetty aksclusterregistry.azurecr.io/jetty
docker push aksclusterregistry.azurecr.io/jetty
</code></pre>
<p>The next step was creating a secret:</p>
<pre><code>kubectl create secret docker-registry secret --docker-server=aksclusterregistry.azurecr.io --docker-username=aksClusterRegistry --docker-password=<Password from tab ACR/Access Keys> --docker-email=some@email.com
</code></pre>
<p>And eventually I tried to create pod with image from the ACR:</p>
<pre><code>#pod.yml
apiVersion: v1
kind: Pod
metadata:
name: jetty
spec:
containers:
- name: jetty
image: aksclusterregistry.azurecr.io/jetty
imagePullSecrets:
- name: secret
kubectl create -f pod.yml
</code></pre>
<p>In result I have a pod with status ImagePullBackOff:</p>
<pre><code>>kubectl get pods
NAME READY STATUS RESTARTS AGE
jetty 0/1 ImagePullBackOff 0 1m
> kubectl describe pod jetty
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 2m default-scheduler Successfully assigned jetty to aks-nodepool1-62963605-0
Normal SuccessfulMountVolume 2m kubelet, aks-nodepool1-62963605-0 MountVolume.SetUp succeeded for volume "default-token-w8png"
Normal Pulling 2m (x2 over 2m) kubelet, aks-nodepool1-62963605-0 pulling image "aksclusterregistry.azurecr.io/jetty"
Warning Failed 2m (x2 over 2m) kubelet, aks-nodepool1-62963605-0 Failed to pull image "aksclusterregistry.azurecr.io/jetty": rpc error: code = Unknown desc = Error response from daemon: Get https://aksclusterregistry.azurecr.io/v2/jetty/manifests/latest: unauthorized: authentication required
Warning Failed 2m (x2 over 2m) kubelet, aks-nodepool1-62963605-0 Error: ErrImagePull
Normal BackOff 2m (x5 over 2m) kubelet, aks-nodepool1-62963605-0 Back-off pulling image "aksclusterregistry.azurecr.io/jetty"
Normal SandboxChanged 2m (x7 over 2m) kubelet, aks-nodepool1-62963605-0 Pod sandbox changed, it will be killed and re-created.
Warning Failed 2m (x6 over 2m) kubelet, aks-nodepool1-62963605-0 Error: ImagePullBackOff
</code></pre>
<p>What's wrong? Why does approach with secret not work?
Please don't advice me approach with service principal, because I would like to understand why this aproach doesn't work. I think it must be working. </p>
| 0debug
|
What is the meaning of start a goroutine which is also a goroutine : https://github.com/fhmq/hmq/blob/master/pool/fixpool.go . here are the codes, I do not understand why the function startWorker is written like the following.
```go
func startWorker(taskChan chan func()) {
go func() {
var task func()
var ok bool
for {
task, ok = <-taskChan
if !ok {
break
}
// Execute the task.
task()
}
}()
}
```
If I were the developer, I will write this function like this:
```Go
func startWorker(taskChan chan func()) {
var task func()
var ok bool
for {
task, ok = <-taskChan
if !ok {
return
}
// Execute the task.
task()
}
}()
}
```
| 0debug
|
Not ignoring 0 on Java : <p>I need help, I have an <code>int num = 0000;</code> but on <code>System.out.print(num);</code> it only shows like this: <code>0</code>.
I would like to know what can I do if I have <code>num = 0111;</code> or <code>num = 0011;</code> or <code>num = 0001</code> and I want to show the 0 before the number, so the final result can be <code>0001</code> and not <code>1</code>.
Thanks!</p>
| 0debug
|
How to use CryptoJS with Angular 4 : <p>When I was not using Angular 4, I would just put the <code>script</code> tags for the library. Even when I put the <code>script</code> tags in the <code>index.html</code> file it is not recognizing <code>CryptoJS</code>. Is there a way to use the library or a Angular equivalent? </p>
| 0debug
|
HTML - Allow only pattern with numbers and dots for input type text : <p>I need to have a text input that accepts only numbers and the dot sign for float numbers.</p>
<p>I don't want a number type input.</p>
| 0debug
|
Is it possible to, with a C# program, get a list of PDF readers installed on a given PC? : <p>I need to list all the PDF readers available in a given PC.
I've found many ways to get the default one, or to get just the adobe acrobat, but I need to be able to list them all like:
Adobe Acrobat
Foxit
...</p>
| 0debug
|
using enzyme.mount().setProps with a react-redux Provider : <p>I have a test which is setting props, to observe some changes in the component. The only complication is that I'm wrapping the rendered element in a <code><Provider></code> because there are some connected components further down the tree.</p>
<p>I'm rendering via</p>
<pre><code>const el = () => <MyComponent prop1={ prop1 } />;
const wrapper = mount(<Provider store={store}>{ el() }</Provider>);
</code></pre>
<p>I'm then trying to observe some changes by using the following:</p>
<pre><code>wrapper.setProps({ /* new props */ });
// expect()s etc.
</code></pre>
<p>The problem is that <code>setProps()</code> is not setting the props properly on the wrapped component. I assume that this is because <code><Provider></code> is not actually passing props through as it's not an HoC. Is there a better way to test this than just changing the locally scoped prop variables and re-rendering?</p>
| 0debug
|
How to code a countdown timer always countdown to tomorrow? : I would like to have a countdown timer always show a countdown until tomorrow to a new client id. Thinking of using the js variable code functions to define new client's timezone together with if statement comment. and make it a repeat loop ?
Anyone have down this before?
A new client id will always see the countdown timer counting down to tomorrow no matter when does the client loading the page.
| 0debug
|
Why does this very simple C# method produce such illogical CIL code? : <p>I've been digging into IL recently, and I noticed some odd behavior of the C# compiler. The following method is a very simple and verifiable application, it will immediately exit with exit code 1:</p>
<pre><code>static int Main(string[] args)
{
return 1;
}
</code></pre>
<p>When I compile this with Visual Studio Community 2015, the following IL code is generated (comments added):</p>
<pre><code>.method private hidebysig static int32 Main(string[] args) cil managed
{
.entrypoint
.maxstack 1
.locals init ([0] int32 V_0) // Local variable init
IL_0000: nop // Do nothing
IL_0001: ldc.i4.1 // Push '1' to stack
IL_0002: stloc.0 // Pop stack to local variable 0
IL_0003: br.s IL_0005 // Jump to next instruction
IL_0005: ldloc.0 // Load local variable 0 onto stack
IL_0006: ret // Return
}
</code></pre>
<p>If I were to handwrite this method, seemingly the same result could be achieved with the following IL:</p>
<pre><code>.method static int32 Main()
{
.entrypoint
ldc.i4.1 // Push '1' to stack
ret // Return
}
</code></pre>
<p>Are there underlying reasons that I'm not aware of that make this the expected behaviour? </p>
<p>Or is just that the assembled IL object code further optimized down the line, so the C# compiler does not have to worry about optimization?</p>
| 0debug
|
Java: Difference between Class.function() and Object.function() : <p>In cases where it does not seem to matter, i.e. the value is a parameter and the function is not operating directly on the calling object instance, what are the "under the hood" differences between calling a Class.function() and Object.function()?</p>
<p>This can be illustrated by a convoluted example:</p>
<pre><code>Character c = new Character();
boolean b = c.isDigit(c);
</code></pre>
<p>vs.</p>
<pre><code>boolean b = Character.isDigit(c);
</code></pre>
<p>I can see cases where hardcoded variables would easier to change (find/replace) if only Character were used repeatedly instead of a bunch of different instance names. MOST IMPORTANTLY: What is the accepted best practice?</p>
| 0debug
|
How can i redirect a webpage to another webpage permanently through cpanel : How can redirect a webpage to another webpage permanently using cpanel
Ex:
www.abc/contactUs.php
redirect to
www.abc/contactus.php
Your quick response appreciated.
| 0debug
|
How to find and replace with regex in excel : <p>I have an excel file with 1 column and multiple rows.</p>
<p>The rows contain various text, here's an example:</p>
<pre><code>texts are home
texts are whatever
dafds
dgretwer
werweerqwr
texts are 21412
texts are 346345
texts are rwefdg
terfesfasd
rwerw
</code></pre>
<p>I want to replace "texts are *" where * is anything after "texts are" with a specific word, for example "texts are replaced". How can I do that in Excel?</p>
| 0debug
|
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
{
int ret, i;
av_assert0(!dst->f->buf[0]);
av_assert0(src->f->buf[0]);
av_assert0(src->tf.f == src->f);
dst->tf.f = dst->f;
ret = ff_thread_ref_frame(&dst->tf, &src->tf);
if (ret < 0)
goto fail;
dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf);
dst->mb_type_buf = av_buffer_ref(src->mb_type_buf);
if (!dst->qscale_table_buf || !dst->mb_type_buf)
goto fail;
dst->qscale_table = src->qscale_table;
dst->mb_type = src->mb_type;
for (i = 0; i < 2; i++) {
dst->motion_val_buf[i] = av_buffer_ref(src->motion_val_buf[i]);
dst->ref_index_buf[i] = av_buffer_ref(src->ref_index_buf[i]);
if (!dst->motion_val_buf[i] || !dst->ref_index_buf[i])
goto fail;
dst->motion_val[i] = src->motion_val[i];
dst->ref_index[i] = src->ref_index[i];
}
if (src->hwaccel_picture_private) {
dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
if (!dst->hwaccel_priv_buf)
goto fail;
dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
}
for (i = 0; i < 2; i++)
dst->field_poc[i] = src->field_poc[i];
memcpy(dst->ref_poc, src->ref_poc, sizeof(src->ref_poc));
memcpy(dst->ref_count, src->ref_count, sizeof(src->ref_count));
dst->poc = src->poc;
dst->frame_num = src->frame_num;
dst->mmco_reset = src->mmco_reset;
dst->long_ref = src->long_ref;
dst->mbaff = src->mbaff;
dst->field_picture = src->field_picture;
dst->reference = src->reference;
dst->recovered = src->recovered;
dst->invalid_gap = src->invalid_gap;
dst->sei_recovery_frame_cnt = src->sei_recovery_frame_cnt;
return 0;
fail:
ff_h264_unref_picture(h, dst);
return ret;
}
| 1threat
|
static inline void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_t min_delta[17])
{
int pass, i;
for (pass = 0; pass < 20; pass++) {
int k, min_diff = 0;
for (i = 0; i < order+1; i++) {
int low = i != 0 ? nlsf[i-1] : 0;
int high = i != order ? nlsf[i] : 32768;
int diff = (high - low) - (min_delta[i]);
if (diff < min_diff) {
min_diff = diff;
k = i;
if (pass == 20)
break;
}
}
if (min_diff == 0)
return;
if (k == 0) {
nlsf[0] = min_delta[0];
} else if (k == order) {
nlsf[order-1] = 32768 - min_delta[order];
} else {
int min_center = 0, max_center = 32768, center_val;
for (i = 0; i < k; i++)
min_center += min_delta[i];
min_center += min_delta[k] >> 1;
for (i = order; i > k; i--)
max_center -= min_delta[i];
max_center -= min_delta[k] >> 1;
center_val = nlsf[k - 1] + nlsf[k];
center_val = (center_val >> 1) + (center_val & 1);
center_val = FFMIN(max_center, FFMAX(min_center, center_val));
nlsf[k - 1] = center_val - (min_delta[k] >> 1);
nlsf[k] = nlsf[k - 1] + min_delta[k];
}
}
for (i = 1; i < order; i++) {
int j, value = nlsf[i];
for (j = i - 1; j >= 0 && nlsf[j] > value; j--)
nlsf[j + 1] = nlsf[j];
nlsf[j + 1] = value;
}
if (nlsf[0] < min_delta[0])
nlsf[0] = min_delta[0];
for (i = 1; i < order; i++)
if (nlsf[i] < nlsf[i - 1] + min_delta[i])
nlsf[i] = nlsf[i - 1] + min_delta[i];
if (nlsf[order-1] > 32768 - min_delta[order])
nlsf[order-1] = 32768 - min_delta[order];
for (i = order-2; i >= 0; i--)
if (nlsf[i] > nlsf[i + 1] - min_delta[i+1])
nlsf[i] = nlsf[i + 1] - min_delta[i+1];
return;
}
| 1threat
|
function that returns number of vowels in a string : <pre><code>if(string[i] === "a" || string[i] === "e" || string[i] === "i" || string[i] === "o" || string[i] ==="u"){}
</code></pre>
<p>I'm writing a function that takes a string and returns the number of vowels in that string. </p>
<p>The code above is what I used to compare each letter to see if it was a vowel. It worked.</p>
<p>However, the code seems incredibly messy to me. Yet I have no idea how to write it better. Is there a more concise way to write this code?</p>
| 0debug
|
How can i echo the last record php mysql : <p>For a project a need the echo the last 4 database records. I have a script that show all the records but I need only the last 4. Can someone help me?</p>
<pre><code><?php
$con = mysql_connect("localhost","test","test");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM formulier");
echo "<table border='1'>
<tr>
<th>tafel</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['tafel'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</code></pre>
<p>Thanks!</p>
| 0debug
|
How can I run functions within a Vue data object? : <p>So I am trying to use the following component within Vue JS:</p>
<pre><code>Vue.component('careers', {
template: '<div>A custom component!</div>',
data: function() {
var careerData = [];
client.getEntries()
.then(function (entries) {
// log the title for all the entries that have it
entries.items.forEach(function (entry) {
if(entry.fields.jobTitle) {
careerData.push(entry);
}
})
});
return careerData;
}
});
</code></pre>
<p>The following code emits an error like so:</p>
<pre><code>[Vue warn]: data functions should return an object:
https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
(found in component <careers>)
</code></pre>
<p>However as you can see I am running a foreach through all of my Contentful <code>entries</code>, then each object within entries is being pushed to an array, I then try to return the array but I get an error.</p>
<p>Any idea how I can extract all of my <code>entries</code> to my data object within my component?</p>
<p>When I use the <code>client.getEntries()</code> function outside of my Vue component I get the following data:</p>
<p><a href="https://i.stack.imgur.com/f41iM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/f41iM.png" alt="enter image description here"></a></p>
| 0debug
|
Codeigniter Controller return to previous page : <p>I'd like to ask you how can I instead of $this->load->view('some_view.php') at the end of controller code, return user to page from where he invoked controller method? Simple return statement is not working. </p>
<p>ie.</p>
<pre><code>public function someMethod($IDCustomer) {
$this->Some_modal->persist($IDCustomer);
// how to return to previous page instead of line after?
// i've used $this->load->view('someView.php');
}
</code></pre>
| 0debug
|
OSX dev_appserver.py file not accessible: '/System/Library/CoreServices/SystemVersion.plist' : <p>I did a <code>gcloud components update</code> 2 days ago and started getting this error when i run <code>dev_appserver.py</code></p>
<pre><code>(venv) myusername@mymachine:~/projects/myproject$ dev_appserver.py ./ --host 0.0.0.0 --port 8002 --enable_console --env_var GCS_TOKEN=ya29........YJDQAnp772B0
INFO 2019-03-13 23:45:31,205 devappserver2.py:278] Skipping SDK update check.
INFO 2019-03-13 23:45:31,268 api_server.py:275] Starting API server at: http://localhost:64587
INFO 2019-03-13 23:45:31,319 dispatcher.py:256] Starting module "default" running at: http://0.0.0.0:8002
INFO 2019-03-13 23:45:31,325 admin_server.py:150] Starting admin server at: http://localhost:8000
/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:182: UserWarning: There are too many files in your application for changes in all of them to be monitored. You may have to restart the development server to see some changes to your files.
'There are too many files in your application for '
INFO 2019-03-13 23:45:35,237 instance.py:294] Instance PID: 29760
appengine_config
requests.__version__ 2.21.0
Appengine config done
4
ERROR 2019-03-13 23:45:35,986 wsgi.py:263]
Traceback (most recent call last):
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/myusername/projects/myproject/main.py", line 34, in <module>
from bp_includes.lib.error_handler import handle_error
File "/Users/myusername/projects/myproject/bp_includes/lib/error_handler.py", line 15, in <module>
from bp_includes.lib import jinja_bootstrap
File "/Users/myusername/projects/myproject/bp_includes/lib/jinja_bootstrap.py", line 7, in <module>
from src.handlers.utils import ordinal
File "/Users/myusername/projects/myproject/src/handlers/utils.py", line 14, in <module>
from lib.pytz.gae import pytz
File "/Users/myusername/projects/myproject/lib/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1022, in <module>
class Environment(object):
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1025, in Environment
def __init__(self, search_path=None, platform=get_supported_platform(),
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 263, in get_supported_platform
plat = get_build_platform()
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 472, in get_build_platform
INFO 2019-03-13 23:45:36,002 module.py:861] default: "GET /_ah/warmup HTTP/1.1" 500 -
version = _macosx_vers()
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 439, in _macosx_vers
version = platform.mac_ver()[0]
File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 764, in mac_ver
info = _mac_ver_xml()
File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 741, in _mac_ver_xml
pl = plistlib.readPlist(fn)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 75, in readPlist
pathOrFile = open(pathOrFile)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/stubs.py", line 284, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/System/Library/CoreServices/SystemVersion.plist'
</code></pre>
<p>I originally installed gcloud with <code>brew cask install google-cloud-sdk</code> in case that's relevant</p>
| 0debug
|
static int raw_fd_pool_get(BDRVRawState *s)
{
int i;
for (i = 0; i < RAW_FD_POOL_SIZE; i++) {
if (s->fd_pool[i] != -1)
continue;
s->fd_pool[i] = dup(s->fd);
if (s->fd_pool[i] != -1)
return s->fd_pool[i];
}
return s->fd;
}
| 1threat
|
Why my if elif logic in Python is not working.. Please explain : Dataframe(test1):
cons_flag
Mas
Mas
Wood
Wood
Wood
Mas
Conc
Wood
OUTPUT:
cons_flag new_var
Mas MASOM
Mas MASOM
Wood MASOM
Wood MASOM
Wood MASOM
Mas MASOM
Conc MASOM
Wood MASOM
CODE USED:
for x in test1['cons_flag']:
if x.find('Mas'):
test1['new_var']="MASOM"
elif x.find('Wood'):
test1['new_var']= "WOODEN"
| 0debug
|
Given a matrix, how do I determine whether the entries of the matrix are Independent and Identically Distributed (IID)? : <p>The matrix was not generated with a <code>rand</code> function; rather, it was obtained by collecting data from a server. I want to know if there is a method to check if any given matrix, A, has IID entries or not.</p>
| 0debug
|
TortoiseSVN error The XML response contains invalid XML and Malformed XML: no element found : <p>My TortoiseSVN Checkout and Update error </p>
<p><strong>The XML response contains invalid XML
Malformed XML: no element found</strong></p>
<p>What do you do
Please help me.</p>
| 0debug
|
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags)
{
BDRVRBDState *s = bs->opaque;
char pool[RBD_MAX_POOL_NAME_SIZE];
char snap_buf[RBD_MAX_SNAP_NAME_SIZE];
char conf[RBD_MAX_CONF_SIZE];
char clientname_buf[RBD_MAX_CONF_SIZE];
char *clientname;
QemuOpts *opts;
Error *local_err = NULL;
const char *filename;
int r;
opts = qemu_opts_create_nofail(&runtime_opts);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
qemu_opts_del(opts);
return -EINVAL;
}
filename = qemu_opt_get(opts, "filename");
qemu_opts_del(opts);
if (qemu_rbd_parsename(filename, pool, sizeof(pool),
snap_buf, sizeof(snap_buf),
s->name, sizeof(s->name),
conf, sizeof(conf)) < 0) {
return -EINVAL;
}
clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
r = rados_create(&s->cluster, clientname);
if (r < 0) {
error_report("error initializing");
return r;
}
s->snap = NULL;
if (snap_buf[0] != '\0') {
s->snap = g_strdup(snap_buf);
}
if (flags & BDRV_O_NOCACHE) {
rados_conf_set(s->cluster, "rbd_cache", "false");
} else {
rados_conf_set(s->cluster, "rbd_cache", "true");
}
if (strstr(conf, "conf=") == NULL) {
rados_conf_read_file(s->cluster, NULL);
}
if (conf[0] != '\0') {
r = qemu_rbd_set_conf(s->cluster, conf);
if (r < 0) {
error_report("error setting config options");
goto failed_shutdown;
}
}
r = rados_connect(s->cluster);
if (r < 0) {
error_report("error connecting");
goto failed_shutdown;
}
r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
if (r < 0) {
error_report("error opening pool %s", pool);
goto failed_shutdown;
}
r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
if (r < 0) {
error_report("error reading header from %s", s->name);
goto failed_open;
}
bs->read_only = (s->snap != NULL);
s->event_reader_pos = 0;
r = qemu_pipe(s->fds);
if (r < 0) {
error_report("error opening eventfd");
goto failed;
}
fcntl(s->fds[0], F_SETFL, O_NONBLOCK);
fcntl(s->fds[1], F_SETFL, O_NONBLOCK);
qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], qemu_rbd_aio_event_reader,
NULL, qemu_rbd_aio_flush_cb, s);
return 0;
failed:
rbd_close(s->image);
failed_open:
rados_ioctx_destroy(s->io_ctx);
failed_shutdown:
rados_shutdown(s->cluster);
g_free(s->snap);
return r;
}
| 1threat
|
Get the values of a Observable<any> into an array in typescript : <p>I'm trying to get the values from a post in typescript, I'm getting a Observable type variable from the post operation but I don't know how can I get the values within. Is there a way to do this?</p>
<p>Here is the code I have until now</p>
<pre><code>TryLogin() {
this.loggedUser.email = this.inputUsername;
this.loggedUser.password = this.inputPass;
const myObjStr = JSON.stringify(this.loggedUser)
const response = this.http.post<any>(this.url, myObjStr,{headers: this.httpheaders});
}
</code></pre>
| 0debug
|
How do I replace cells with formulas with its calculated value automatically? : I am making a payroll program in Excel and one of my concerns is that the salaries of the employees are searched using the INDEX and MATCH or VLOOKUP function. The problem is if the salaries get updated in the future (e.g. a raise or changes in rates), all the previous entries that used the old salaries will be updated to the new salaries. This is a disaster and would make my entire program useless and inefficient. Therefore I need to automatically lock previous calculated cells after a certain time.
| 0debug
|
sum of values for multiple rows with same name in r : <p>how to perform a sum of values for multiple rows with the same name in r and render a chart in plotly.i have tried a couple of methods like aggregate and tapply, none of them seems to be working for me, could anyone tell me where I am going wrong. </p>
<pre><code>library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(shiny)
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
cdata1<-data.frame(stringsAsFactors=FALSE,
names = c("a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b",
"b", "c", "c", "c", "d", "d", "d"),
values = c(12, 32, 43, 45, 21, 21, 21, 32, 43, 54, 65, 76, 87, 80, 78,
68, 68, 67, 57)
)
ui<-fluidPage(fluidRow(plotlyOutput("id1")),
fluidRow(plotlyOutput("id2"))
)
server<-function(input,output){
output$id1<-renderPlotly({
# a<-aggregate(cdata1$X2014,by=list(cdata1$States.UTs),FUN=sum)
# plot_ly(cdata1,x=cdata1$States.UTs,y=cdata1$X2014)
cdata1 %>%
group_by(grp = rleid(cdata1$names)) %>%
summarise(names = first(cdata1$names),
values = sum(cdata1$values)) %>%
ungroup %>%
select(-grp)
plot_ly(cdata1,x=cdata1$names,y=cdata1$values)
})
}
shinyApp(ui,server)
</code></pre>
| 0debug
|
Can AWS CodePipeline track multiple feature branches and run tests on each? : <p>With Bitbucket and Bamboo, I was able to have Bamboo track every feature branch and run tests on each so that, at the pull request time, I was able to see if the branch passed its unit tests.</p>
<p>With <a href="http://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html" rel="noreferrer">AWS CodePipeline</a>, I can't tell if I am able to track each feature branch and have tests run on them before merging.</p>
<p>Is this possible? If so, please point me to documentation.</p>
| 0debug
|
static void nbd_teardown_connection(NbdClientSession *client)
{
struct nbd_request request = {
.type = NBD_CMD_DISC,
.from = 0,
.len = 0
};
nbd_send_request(client->sock, &request);
shutdown(client->sock, 2);
nbd_recv_coroutines_enter_all(client);
qemu_aio_set_fd_handler(client->sock, NULL, NULL, NULL);
closesocket(client->sock);
client->sock = -1;
}
| 1threat
|
static int apng_read_header(AVFormatContext *s)
{
APNGDemuxContext *ctx = s->priv_data;
AVIOContext *pb = s->pb;
uint32_t len, tag;
AVStream *st;
int acTL_found = 0;
int64_t ret = AVERROR_INVALIDDATA;
if (avio_rb64(pb) != PNGSIG)
return ret;
len = avio_rb32(pb);
tag = avio_rl32(pb);
if (len != 13 || tag != MKTAG('I', 'H', 'D', 'R'))
return ret;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100000);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_APNG;
st->codecpar->width = avio_rb32(pb);
st->codecpar->height = avio_rb32(pb);
if ((ret = av_image_check_size(st->codecpar->width, st->codecpar->height, 0, s)) < 0)
return ret;
ctx->extra_data = av_malloc(len + 12 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!ctx->extra_data)
return AVERROR(ENOMEM);
ctx->extra_data_size = len + 12;
AV_WB32(ctx->extra_data, len);
AV_WL32(ctx->extra_data+4, tag);
AV_WB32(ctx->extra_data+8, st->codecpar->width);
AV_WB32(ctx->extra_data+12, st->codecpar->height);
if ((ret = avio_read(pb, ctx->extra_data+16, 9)) < 0)
goto fail;
while (!avio_feof(pb)) {
if (acTL_found && ctx->num_play != 1) {
int64_t size = avio_size(pb);
int64_t offset = avio_tell(pb);
if (size < 0) {
ret = size;
goto fail;
} else if (offset < 0) {
ret = offset;
goto fail;
} else if ((ret = ffio_ensure_seekback(pb, size - offset)) < 0) {
av_log(s, AV_LOG_WARNING, "Could not ensure seekback, will not loop\n");
ctx->num_play = 1;
}
}
if ((ctx->num_play == 1 || !acTL_found) &&
((ret = ffio_ensure_seekback(pb, 4 + 4 )) < 0))
goto fail;
len = avio_rb32(pb);
if (len > 0x7fffffff) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
tag = avio_rl32(pb);
switch (tag) {
case MKTAG('a', 'c', 'T', 'L'):
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
(ret = append_extradata(ctx, pb, len + 12)) < 0)
goto fail;
acTL_found = 1;
ctx->num_frames = AV_RB32(ctx->extra_data + ret + 8);
ctx->num_play = AV_RB32(ctx->extra_data + ret + 12);
av_log(s, AV_LOG_DEBUG, "num_frames: %"PRIu32", num_play: %"PRIu32"\n",
ctx->num_frames, ctx->num_play);
break;
case MKTAG('f', 'c', 'T', 'L'):
if (!acTL_found) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0)
goto fail;
return 0;
default:
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
(ret = append_extradata(ctx, pb, len + 12)) < 0)
goto fail;
}
}
fail:
if (ctx->extra_data_size) {
av_freep(&ctx->extra_data);
ctx->extra_data_size = 0;
}
return ret;
}
| 1threat
|
static void fdt_add_psci_node(const VirtBoardInfo *vbi)
{
void *fdt = vbi->fdt;
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(0));
if (kvm_enabled()) {
qemu_fdt_add_subnode(fdt, "/psci");
if (armcpu->psci_version == 2) {
const char comp[] = "arm,psci-0.2\0arm,psci";
qemu_fdt_setprop(fdt, "/psci", "compatible", comp, sizeof(comp));
} else {
qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
}
qemu_fdt_setprop_string(fdt, "/psci", "method", "hvc");
qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
QEMU_PSCI_0_1_FN_CPU_SUSPEND);
qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off", QEMU_PSCI_0_1_FN_CPU_OFF);
qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on", QEMU_PSCI_0_1_FN_CPU_ON);
qemu_fdt_setprop_cell(fdt, "/psci", "migrate", QEMU_PSCI_0_1_FN_MIGRATE);
}
}
| 1threat
|
First program with Rails framework : I try to exec a first ruby on rails project.
I have done this few commands but no html page I see on localhost:3000 after rails server.
The comands that I wrote, are:
rails new first_proj;
cd first_proj
rails generate scaffold project name:string cost:decimal;
bundle exec rake db:migrate
No HTML page I can I see with firefox or chrome.
Can You help me please??
It's very weird
| 0debug
|
static void test_visitor_out_enum(TestOutputVisitorData *data,
const void *unused)
{
QObject *obj;
EnumOne i;
for (i = 0; i < ENUM_ONE__MAX; i++) {
visit_type_EnumOne(data->ov, "unused", &i, &error_abort);
obj = visitor_get(data);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==,
EnumOne_lookup[i]);
visitor_reset(data);
}
}
| 1threat
|
PHP Warning: get_included_files() expects exactly 0 parameters, 1 given in : <p>I'm trying to uploade and use an old script i made way back, but it gives me an error:</p>
<p>PHP Warning: get_included_files() expects exactly 0 parameters, 1 given in</p>
<pre><code>session_start();
ob_start();
get_required_files('config.php');
get_required_files('funksjoner.php');
</code></pre>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.