problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
C++ keeps skipping my "for" loop : <p>I'm trying to create a program that will find a four-digit number that meets four specific requirements: all four digits are different, the thousands number is 3x the tens number, the number is odd, and the sum of the digits is 27. For some reason, despite the program compiling, the for loop won't run and always outputs the initializer number (1000). My main code and the four functions I'm calling are below. I can't figure out why it won't run correctly. I'm completely new to coding so any tips/help are appreciated. Thanks!</p>
<p>main function:</p>
<pre><code> 5 //prototypes
6 bool differentDigits(int);
7 bool thouThreeTen(int);
8 bool numberIsOdd(int);
9 bool sumIs27(int);
10
11 #include <iostream>
12 using namespace std;
13
14 int main ()
15 {
16 //variables
17 int n;
18
19 //processing
20
21 for(n=1000;n<=9999;n++)
22 {
23 if(differentDigits(n)==true)
24 {
25 break;
26 }
27
28 if(thouThreeTen(n)==true)
29 {
30 break;
31 }
32
33 if(numberIsOdd(n)==true)
34 {
35 break;
36 }
37
38 if(sumIs27(n)==true)
39 {
40 break;
41 }
42
43 }
44
45 //output
46 cout << n << endl;
47
48 return 0;
49 }
</code></pre>
<p>differentDigits function:</p>
<pre><code> 3 //Verify all four digits are the same
4
5 #include <iostream>
6 using namespace std;
7
8 bool differentDigits (int n)
9 {
10 int n1, n2, n3, n4;
11
12 n1 = n/1000;
13 n2 = (n/100) % 10;
14 n3 = (n/10) % 10;
15 n4 = n % 10;
16
17 if(n1 != n2 != n3 != n4)
18 {
19 return true;
20 }
21 else
22 {
23 return false;
24 }
25
26 }
</code></pre>
<p>thouThreeTen function:</p>
<pre><code> 3 //Verify digit in thousands place is 3x the digit in tens place
4
5 #include <iostream>
6 using namespace std;
7
8 bool thouThreeTen(int n)
9 {
10 int n1, n2, n3, n4;
11
12 n1 = n/1000;
13 n2 = (n/100) % 10;
14 n3 = (n/10) % 10;
15 n4 = n % 10;
16
17 if(n1 = (n3 * 3))
18 {
19 return true;
20 }
21 else
22 {
23 return false;
24 }
25
26 }
</code></pre>
<p>numberIsOdd function:</p>
<pre><code> 3 //Verify that the number is odd
4
5 #include <iostream>
6 using namespace std;
7
8 bool numberIsOdd (int n)
9 {
10 if((n % 2)==1)
11 {
12 return true;
13 }
14 else
15 {
16 return false;
17 }
18
19 }
</code></pre>
<p>sumIs27 function:</p>
<pre><code> 3 //Verify that the sum of digits is 27
4
5 #include <iostream>
6 using namespace std;
7
8 bool sumIs27(int n)
9 {
10 int n1, n2, n3, n4;
11
12 n1 = n/1000;
13 n2 = (n/100) % 10;
14 n3 = (n/10) % 10;
15 n4 = n % 10;
16
17 if((n1+n2+n3+n4)==27)
18 {
19 return true;
20 }
21 else
22 {
23 return false;
24 }
25
26 }
</code></pre>
| 0debug |
Simple local search function. Javascript and JSON? : <p>Building a 'fake' web browser and web pages that are all compiled locally in a windows form application. The whole thing operates offline.</p>
<p>I need to build a search function on one of the web pages I've made. Obviously theirs no server involved, so I have to have the data extracted and displayed from a local source. I've used 'Jput' before in a <a href="http://fooda.website/" rel="nofollow noreferrer">previous project</a> so i was thinking about having a Json file that can be called. The site is a fake social network, so when a user searches a name or phrase, it displays related results (profiles) either on a separate page or within the current doc. Jput is good, but its pretty limited when it comes to styling.</p>
<p><strong>QUESTION</strong></p>
<p>What would be the best way of doing this? How would I index all these results and how would the search engine work?</p>
<p>Let me know if more detail is needed for this question</p>
<p>Thanks!</p>
| 0debug |
How can I create a java program that reads from the user a number and searches for that number in an array? : <p>This is the code which I've tried so far: </p>
<pre><code>int num;
int[] a={2, 3, 4,7, 9};
System.out.println("enter a no");
for(int i=0; i<a.length; i++){
num= in.nextInt();
if(num==a[i])
</code></pre>
| 0debug |
static int start_auth_vnc(VncState *vs)
{
make_challenge(vs);
vnc_write(vs, vs->challenge, sizeof(vs->challenge));
vnc_flush(vs);
vnc_read_when(vs, protocol_client_auth_vnc, sizeof(vs->challenge));
return 0;
}
| 1threat |
Create a file on .jar folder same that are in project java : How I can create a file on the .jar folder that is on the project folder?
Thanks, and sorry for my bad english :v | 0debug |
What is the difference between new pointer and simple pointer? : What is the difference between those two declarations?
```
int *p = new int;
int *q;
``` | 0debug |
int64_t qemu_clock_get_ns(QEMUClockType type)
{
int64_t now, last;
QEMUClock *clock = qemu_clock_ptr(type);
switch (type) {
case QEMU_CLOCK_REALTIME:
return get_clock();
default:
case QEMU_CLOCK_VIRTUAL:
if (use_icount) {
return cpu_get_icount();
} else {
return cpu_get_clock();
}
case QEMU_CLOCK_HOST:
now = get_clock_realtime();
last = clock->last;
clock->last = now;
if (now < last) {
notifier_list_notify(&clock->reset_notifiers, &now);
}
return now;
case QEMU_CLOCK_VIRTUAL_RT:
return cpu_get_clock();
}
}
| 1threat |
int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count,
const uint8_t *in_arg [SWR_CH_MAX], int in_count){
AudioData * in= &s->in;
AudioData *out= &s->out;
if (!swr_is_initialized(s)) {
av_log(s, AV_LOG_ERROR, "Context has not been initialized\n");
return AVERROR(EINVAL);
}
while(s->drop_output > 0){
int ret;
uint8_t *tmp_arg[SWR_CH_MAX];
#define MAX_DROP_STEP 16384
if((ret=swri_realloc_audio(&s->drop_temp, FFMIN(s->drop_output, MAX_DROP_STEP)))<0)
return ret;
reversefill_audiodata(&s->drop_temp, tmp_arg);
s->drop_output *= -1;
ret = swr_convert(s, tmp_arg, FFMIN(-s->drop_output, MAX_DROP_STEP), in_arg, in_count);
s->drop_output *= -1;
in_count = 0;
if(ret>0) {
s->drop_output -= ret;
if (!s->drop_output && !out_arg)
return 0;
continue;
}
av_assert0(s->drop_output);
return 0;
}
if(!in_arg){
if(s->resample){
if (!s->flushed)
s->resampler->flush(s);
s->resample_in_constraint = 0;
s->flushed = 1;
}else if(!s->in_buffer_count){
return 0;
}
}else
fill_audiodata(in , (void*)in_arg);
fill_audiodata(out, out_arg);
if(s->resample){
int ret = swr_convert_internal(s, out, out_count, in, in_count);
if(ret>0 && !s->drop_output)
s->outpts += ret * (int64_t)s->in_sample_rate;
return ret;
}else{
AudioData tmp= *in;
int ret2=0;
int ret, size;
size = FFMIN(out_count, s->in_buffer_count);
if(size){
buf_set(&tmp, &s->in_buffer, s->in_buffer_index);
ret= swr_convert_internal(s, out, size, &tmp, size);
if(ret<0)
return ret;
ret2= ret;
s->in_buffer_count -= ret;
s->in_buffer_index += ret;
buf_set(out, out, ret);
out_count -= ret;
if(!s->in_buffer_count)
s->in_buffer_index = 0;
}
if(in_count){
size= s->in_buffer_index + s->in_buffer_count + in_count - out_count;
if(in_count > out_count) {
if( size > s->in_buffer.count
&& s->in_buffer_count + in_count - out_count <= s->in_buffer_index){
buf_set(&tmp, &s->in_buffer, s->in_buffer_index);
copy(&s->in_buffer, &tmp, s->in_buffer_count);
s->in_buffer_index=0;
}else
if((ret=swri_realloc_audio(&s->in_buffer, size)) < 0)
return ret;
}
if(out_count){
size = FFMIN(in_count, out_count);
ret= swr_convert_internal(s, out, size, in, size);
if(ret<0)
return ret;
buf_set(in, in, ret);
in_count -= ret;
ret2 += ret;
}
if(in_count){
buf_set(&tmp, &s->in_buffer, s->in_buffer_index + s->in_buffer_count);
copy(&tmp, in, in_count);
s->in_buffer_count += in_count;
}
}
if(ret2>0 && !s->drop_output)
s->outpts += ret2 * (int64_t)s->in_sample_rate;
return ret2;
}
}
| 1threat |
Semaphore Wait vs WaitAsync in an async method : <p>I'm trying to find out what is the difference between the SemaphoreSlim use of Wait and WaitAsync, used in this kind of context:</p>
<pre><code>private SemaphoreSlim semaphore = new SemaphoreSlim(1);
public async Task<string> Get()
{
// What's the difference between using Wait and WaitAsync here?
this.semaphore.Wait(); // await this.semaphore.WaitAsync()
string result;
try {
result = this.GetStringAsync();
}
finally {
this.semaphore.Release();
}
return result;
}
</code></pre>
| 0debug |
int omap_validate_emifs_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return addr >= OMAP_EMIFS_BASE && addr < OMAP_EMIFF_BASE;
}
| 1threat |
android textview issue in run() : class BTCSync extends Thread{
public void run(){
while(!BTC && MainPage.BTC){
TextView BTCPer = (TextView) findViewById(R.id.lblBTCPer);
BTCPer.setText(BTCProgress+"%");
if(BTCProgress == 100) {
BTCPer.setText("100%");
BTC = true;
}
}
}
}
the error is where findviewbyid my label is lblBTCPer.
The reason i have it in run() is because this block needs to run until the value hits 100.
I know that usually you would have to throw in the View v but then it would negate the void run().
I looked for a few solutions but i havent found a working example.
I also believe i posted this already just yesterday but i cant seem to find it anywhere. Its not under my account and i distincly remember posting it and waiting for responses. | 0debug |
Two arrays into one Dictinary C# : <p>I would like to create a</p>
<p><code>Dictionary<string, int[]> dict</code></p>
<p>out of two arrays(different length):</p>
<pre><code>string[] keys = { "A", "B", "A", "D", "C","E" };
string[] values = { green, blue, yellow};
</code></pre>
<p>The results:</p>
<pre><code>["A"] = {green}
["B"] = {blue}
["D"] = {yellow}
["C"] = {green}
["E"] = {blue}
</code></pre>
| 0debug |
configuration.module has an unknown property 'loaders' : <p>my output of error:</p>
<blockquote>
<p>Invalid configuration object. Webpack has been initialised using a
configuration object that does not match the API schema.
- configuration.module has an unknown property 'loaders'. These properties are valid: object { exprContextCritical?,
exprContextRecursive?, exprContextRegExp?, exprContextRequest?,
noParse?, rules?, defaultRules?, unknownContextCritical?,
unknownContextRecursive?, unknownContextRegExp?,
unknownContextRequest?, unsafeCache?, wrappedContextCritical?,
wrappedContextRecursive?, wrappedContextRegExp?,
strictExportPresence?, strictThisContextOnImports? } -> Options
affecting the normal modules (<code>NormalModuleFactory</code>).</p>
</blockquote>
<p>my webpack.config.js:</p>
<pre><code>var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, 'src/client/public');
var APP_DIR = path.resolve(__dirname, 'src/client/app');
var config = {
entry: APP_DIR + '/index.jsx',
module : {
loaders : [
{
test : /\.jsx?/,
include : APP_DIR,
loader : 'babel-loader'
}
]
},
output: {
path: BUILD_DIR,
filename: 'bundle.js'
}
};
module.exports = config;
</code></pre>
<p>my webpack version:</p>
<pre><code>webpack@4.1.1
</code></pre>
| 0debug |
Spy on setTimeout and clearTimeout in Karma and Jasmine : <p>I cannot seem to be able to spy on <code>setTimeout</code> and <code>clearTimeout</code> in my Jasmine tests, which are being run through Karma. </p>
<p>I have tried variations on all of this</p>
<pre><code>spyOn(window, 'setTimeout').and.callFake(()=>{});
spyOn(global, 'setTimeout').and.callFake(()=>{});
spyOn(window, 'clearTimeout').and.callThrough();
clock = jasmine.clock();
clock.install();
spyOn(clock, 'setTimeout').and.callThrough();
runMyCode();
expect(window.setTimeout).toHaveBeenCalled(); // no
expect(global.setTimeout).toHaveBeenCalled(); // nope
expect(window.clearTimeout).toHaveBeenCalled(); // no again
expect(clock.setTimeout).toHaveBeenCalled(); // and no
</code></pre>
<p>In every case, I can confirm that <code>setTimeout</code> and <code>clearTimeout</code> have been invoked in <code>runMyCode</code>, but instead I always get <code>Expected spy setTimeout to have been called.</code></p>
<p>For <code>window</code>, clearly this is because the test and the runner (the Karma window) are in different frames (so why should I expect anything different). But because of this, I can't see any way to confirm that these global functions have been invoked.</p>
<p>I know that I can use <code>jasmine.clock()</code> to confirm that timeout/interval callbacks have been invoked, but it looks like I can't watch <code>setTimeout</code> itself. And confirming that <code>clearTimeout</code> has been called simply isn't possible.</p>
<p>At this point, the only thing I can think of is to add a separate layer of abstraction to wrap <code>setTimeout</code> and <code>clearTimeout</code> or to inject the functions as dependencies, which I've done before, but I think is weird.</p>
| 0debug |
i have table formatted data and wanted to convert into tuple format : <p>I have a csv file mentioned as below screen shot ...</p>
<p><a href="https://i.stack.imgur.com/WAVzb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WAVzb.png" alt="enter image description here"></a></p>
<p>and i want to convert the whole file in the below format in python.</p>
<p><a href="https://i.stack.imgur.com/ladmh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ladmh.png" alt="enter image description here"></a></p>
| 0debug |
Check if a date is in between collection of Date Periods : <p>I'm trying to find if a given date falls between a collection of periods
I have a period class with start and end dates, and a date to check if it is in the collection of periods. Here is the sample code to work with.</p>
<pre><code>public class Period
{
public Guid PeriodId { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
}
...
// main class
public Collection<Period> Periods = Collection of Periods ;
public DateTime TimeToCheck = somedatevalue;
public bool IsTimeInGivenPeriods(TimeToCheck, Periods)
{
if(TimeToCheck is in Periods)
return true;
else
retrun false;
}
</code></pre>
| 0debug |
Javascript re-assign let variable with destructuring : <p>In my React app I am using airbnb's eslint style guide which will throw an error if I do not use destructuing.</p>
<p>In the situation below, I first use <code>let</code> to assign the two variables <code>latitude</code> and <code>longitude</code> to the coordinates of the first item in an array of location objects. Then I try to use destructuring to re-assign their values if the user has given me access to their location.</p>
<pre><code>let latitude = locations[0].coordinates[1];
let longitude = locations[0].coordinates[0];
if (props.userLocation.coords) {
// doesn't work - unexpected token
{ latitude, longitude } = props.userLocation.coords;
// causes linting errors
// latitude = props.userLocation.coords.latitude;
// longitude = props.userLocation.coords.longitude;
}
</code></pre>
<p>Destructuring inside the <code>if</code> statement causes an <code>unexpected token</code> error.</p>
<p>Re-assigning the variables the old fashioned way causes an <code>ESlint: Use object destructuring</code> error.</p>
| 0debug |
static void pnv_chip_realize(DeviceState *dev, Error **errp)
{
PnvChip *chip = PNV_CHIP(dev);
Error *error = NULL;
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
char *typename = pnv_core_typename(pcc->cpu_model);
size_t typesize = object_type_get_instance_size(typename);
int i, core_hwid;
if (!object_class_by_name(typename)) {
error_setg(errp, "Unable to find PowerNV CPU Core '%s'", typename);
pnv_chip_core_sanitize(chip, &error);
chip->cores = g_malloc0(typesize * chip->nr_cores);
for (i = 0, core_hwid = 0; (core_hwid < sizeof(chip->cores_mask) * 8)
&& (i < chip->nr_cores); core_hwid++) {
char core_name[32];
void *pnv_core = chip->cores + i * typesize;
if (!(chip->cores_mask & (1ull << core_hwid))) {
continue;
object_initialize(pnv_core, typesize, typename);
snprintf(core_name, sizeof(core_name), "core[%d]", core_hwid);
object_property_add_child(OBJECT(chip), core_name, OBJECT(pnv_core),
&error_fatal);
object_property_set_int(OBJECT(pnv_core), smp_threads, "nr-threads",
&error_fatal);
object_property_set_int(OBJECT(pnv_core), core_hwid,
CPU_CORE_PROP_CORE_ID, &error_fatal);
object_property_set_int(OBJECT(pnv_core),
pcc->core_pir(chip, core_hwid),
"pir", &error_fatal);
object_property_set_bool(OBJECT(pnv_core), true, "realized",
&error_fatal);
object_unref(OBJECT(pnv_core));
i++;
g_free(typename); | 1threat |
How to use PhpSpreadsheet without installation (like PHPExcel) : <p>According to the <a href="https://phpspreadsheet.readthedocs.io/en/develop/#installation" rel="noreferrer">PhpSpreadsheet Doc</a> it's neccessary to install it with composer.
In my case I just have a webspace without Terminal but Plesk. Is it anyway possible to use PhpSpreadsheet, like it is with <a href="https://github.com/PHPOffice/PHPExcel/blob/1.8/install.txt" rel="noreferrer">PHPExcel</a> where you just have to place the files in any location?
What do I have to do to get it run? I found no further information how to with only FTP webserver access.</p>
| 0debug |
Access OBDC Connection to SQL SERVER : I setup a new user with a new computer and installed MS Office. When I open the link to the access DB I get the error "OBDC - connection to SQL Server Native Client 11.0Path/of/Accessdb"
Unfortunately I did not develop the Access DB and have no documentation on how to configure it from the developer | 0debug |
static void test_tco_timeout(void)
{
TestData d;
const uint16_t ticks = TCO_SECS_TO_TICKS(4);
uint32_t val;
int ret;
d.args = NULL;
d.noreboot = true;
test_init(&d);
stop_tco(&d);
clear_tco_status(&d);
reset_on_second_timeout(false);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
clock_step(ticks * TCO_TICK_NSEC);
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
ret = val & TCO_TIMEOUT ? 1 : 0;
g_assert(ret == 1);
val |= TCO_TIMEOUT;
qpci_io_writew(d.dev, d.tco_io_base + TCO1_STS, val);
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
ret = val & TCO_TIMEOUT ? 1 : 0;
g_assert(ret == 0);
clock_step(ticks * TCO_TICK_NSEC);
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
ret = val & TCO_TIMEOUT ? 1 : 0;
g_assert(ret == 1);
val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);
ret = val & TCO_SECOND_TO_STS ? 1 : 0;
g_assert(ret == 1);
stop_tco(&d);
qtest_end();
}
| 1threat |
static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
ahci_populate_sglist(ad, &s->sg, 0);
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
return s->io_buffer_size != 0;
}
| 1threat |
div inside form-group does not display with correct width : thanks for the help. I have the following `developers_controller` and I want to perform a query based on the `location_params`.
In the `index_update` action I create a variable `location` with the `location_params` that the user gave as input for the research, I want to perform an each loop on this variable to filter the data from `@locations = Location.all` based on the user request.
This is my private method location_params
def location_params
params.require(:location).permit(:country, :location, :surfspot, :barbecue, :villa, :swimmingpool, :skiresort, :singleroom )
end
this is my `index_update` action
def index_update
location = Location.new(location_params)
locations = Location.all
location.each do |param, value|
if value != nil
locations = locations.where(param => value)
end
end
end
I have been working pretty hard today and I can not find out how to loop the location variable.
Thanks a lot for your help and have a good day. | 0debug |
Explain please need help understanding code : ap = argparse.ArgumentParser()
ap.add_argument("--image", "-i", required = True, help = "Path to input image")
ap.add_argument("--template", "-t", required = True, help = "Path to template image")
args = vars(ap.parse_args())
--Could somone help me understand what i need to execute the code i get the following error
usage: [-h] -i IMAGE -p PROTOTXT -m MODEL -l LABELS
: error: the following arguments are required: -i/--image
Is it that i need to get the path to the imagine where is says help?
| 0debug |
static inline void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst1[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst2[i]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
| 1threat |
void qemu_bh_cancel(QEMUBH *bh)
{
QEMUBH **pbh;
if (bh->scheduled) {
pbh = &first_bh;
while (*pbh != bh)
pbh = &(*pbh)->next;
*pbh = bh->next;
bh->scheduled = 0;
}
}
| 1threat |
static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
Error **errp)
{
VirtIOBlock *s = VIRTIO_BLK(vdev);
virtio_add_feature(&features, VIRTIO_BLK_F_SEG_MAX);
virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY);
virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
if (__virtio_has_feature(features, VIRTIO_F_VERSION_1)) {
if (s->conf.scsi) {
error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0");
return 0;
}
} else {
virtio_clear_feature(&features, VIRTIO_F_ANY_LAYOUT);
virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
}
if (s->conf.config_wce) {
virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE);
}
if (blk_enable_write_cache(s->blk)) {
virtio_add_feature(&features, VIRTIO_BLK_F_WCE);
}
if (blk_is_read_only(s->blk)) {
virtio_add_feature(&features, VIRTIO_BLK_F_RO);
}
return features;
}
| 1threat |
static void pc_init1(MachineState *machine)
{
PCMachineState *pc_machine = PC_MACHINE(machine);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
qemu_irq *cpu_irq;
qemu_irq *gsi;
qemu_irq *i8259;
qemu_irq *smi_irq;
GSIState *gsi_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
ISADevice *floppy;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
DeviceState *icc_bridge;
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
ram_addr_t lowmem;
if (machine->ram_size >= 0xe0000000) {
lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
} else {
lowmem = 0xe0000000;
}
if (lowmem > pc_machine->max_ram_below_4g) {
lowmem = pc_machine->max_ram_below_4g;
if (machine->ram_size - lowmem > lowmem &&
lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
") not a multiple of 1G; possible bad performance.",
pc_machine->max_ram_below_4g);
}
}
if (machine->ram_size >= lowmem) {
above_4g_mem_size = machine->ram_size - lowmem;
below_4g_mem_size = lowmem;
} else {
above_4g_mem_size = 0;
below_4g_mem_size = machine->ram_size;
}
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
object_property_add_child(qdev_get_machine(), "icc-bridge",
OBJECT(icc_bridge), NULL);
pc_cpus_init(machine->cpu_model, icc_bridge);
if (kvm_enabled() && kvmclock_enabled) {
kvmclock_create();
}
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = system_memory;
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
guest_info->has_acpi_build = has_acpi_build;
guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
guest_info->isapc_ram_fw = !pci_enabled;
guest_info->has_reserved_memory = has_reserved_memory;
guest_info->rsdp_in_ram = rsdp_in_ram;
if (smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
mc->name, smbios_legacy_mode, smbios_uuid_encoded);
}
if (!xen_enabled()) {
fw_cfg = pc_memory_init(machine, system_memory,
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
} else if (machine->kernel_filename != NULL) {
fw_cfg = xen_load_linux(machine->kernel_filename,
machine->kernel_cmdline,
machine->initrd_filename,
below_4g_mem_size,
guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
kvm_pc_setup_irq_routing(pci_enabled);
gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, machine->ram_size,
below_4g_mem_size,
above_4g_mem_size,
pci_memory, ram_memory);
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, get_system_memory(), system_io);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, gsi);
if (kvm_irqchip_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
cpu_irq = pc_allocate_cpu_irq();
i8259 = i8259_init(isa_bus, cpu_irq[0]);
}
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
if (pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
qdev_init_nofail(icc_bridge);
pc_register_ferr_irq(gsi[13]);
pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}
pc_basic_device_init(isa_bus, gsi, &rtc_state, true, &floppy,
(pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, ARRAY_SIZE(hd));
if (pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
char busname[] = "ide.0";
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
busname[4] = '0' + i;
idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
}
}
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
machine, floppy, idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled()) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
if (pci_enabled && acpi_enabled) {
DeviceState *piix4_pm;
I2CBus *smbus;
smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
gsi[9], *smi_irq,
kvm_enabled(), fw_cfg, &piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
(Object **)&pc_machine->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
}
if (pci_enabled) {
pc_pci_device_init(pci_bus);
}
}
| 1threat |
What is the difference between Object[] obj and Object obj[] in java? : <p>I wrote a code using two type of Object styles. Both are working properly. I just want to know what is the difference between these both types.</p>
<pre><code>PatientsTabData ob[] = {new PatientsTabData().SetPatientId(
Integer.parseInt(String.valueOf(jsonObject.get("PatientId"))))
.SetRxId(Integer.parseInt(String.valueOf(jsonObject.get("TrackingNumber"))))};
PatientsTabData[] ob = {new PatientsTabData().SetPatientId(
Integer.parseInt(String.valueOf(jsonObject.get("PatientId"))))
.SetRxId(Integer.parseInt(String.valueOf(jsonObject.get("TrackingNumber"))))};
</code></pre>
<p>Both types are working.</p>
| 0debug |
How to upload/access database online : <p>I have a small POS system in my store, and i want to create a new app and install it to my laptop, the problem is how to access the database even im far away. Where can i upload my database to be accesible through internet?</p>
<p>I am using MySQL and C# windows form application.</p>
| 0debug |
C++ map with custom comparator not inserting all elements : <p>I have created the following comparator to test the map:</p>
<pre><code>struct comparator{
bool operatior() (int a,int b){
return 1;
}
}
</code></pre>
<p>then the following algorthim:</p>
<pre><code>int main(){
// imports string to currentString
...
std::map<int,char> default_map;
std::map<int,char,comparator> test_map;
while(i < stringSize){
if(currentString[i] == '(' || currentString[i] == ')'){
default_map[i]=currentString[i];
test_map[i]=currentString[i];
}
}
auto currentIterator = default_map.begin();
while(currentIterator != default_map.end()){
printf("%d %c\n",currentIterator->first,currentIterator->second);
}
auto currentIterator = test_map.begin();
while(currentIterator != test_map.end()){
printf("%d %c\n",currentIterator->first,currentIterator->second);
}
return 0;
}
</code></pre>
<p>Here the default_map prints all of the parenthesis, while the test_map with the custom comparitor only prints the first two parenthesis.</p>
<p>Is this a bug in the map code?
I originally wanted to have class as the key with a custom comparator, but it isn't even working with a custom int key.</p>
<p>My make file does use the -std=c++1y tag so maybe that is effecting it?
I don't know what to do. I am considering to see if the SGI map will work better than the std one.</p>
| 0debug |
TranslationBlock *tb_gen_code(CPUState *cpu,
target_ulong pc, target_ulong cs_base,
uint32_t flags, int cflags)
{
CPUArchState *env = cpu->env_ptr;
TranslationBlock *tb;
tb_page_addr_t phys_pc, phys_page2;
target_ulong virt_page2;
tcg_insn_unit *gen_code_buf;
int gen_code_size, search_size;
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
phys_pc = get_page_addr_code(env, pc);
if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) {
cflags |= CF_USE_ICOUNT;
}
tb = tb_alloc(pc);
if (unlikely(!tb)) {
buffer_overflow:
tb_flush(cpu);
tb = tb_alloc(pc);
assert(tb != NULL);
tcg_ctx.tb_ctx.tb_invalidated_flag = 1;
}
gen_code_buf = tcg_ctx.code_gen_ptr;
tb->tc_ptr = gen_code_buf;
tb->cs_base = cs_base;
tb->flags = flags;
tb->cflags = cflags;
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count1++;
ti = profile_getclock();
#endif
tcg_func_start(&tcg_ctx);
gen_intermediate_code(env, tb);
trace_translate_block(tb, tb->pc, tb->tc_ptr);
tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID;
tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID;
tcg_ctx.tb_jmp_reset_offset = tb->jmp_reset_offset;
#ifdef USE_DIRECT_JUMP
tcg_ctx.tb_jmp_insn_offset = tb->jmp_insn_offset;
tcg_ctx.tb_jmp_target_addr = NULL;
#else
tcg_ctx.tb_jmp_insn_offset = NULL;
tcg_ctx.tb_jmp_target_addr = tb->jmp_target_addr;
#endif
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count++;
tcg_ctx.interm_time += profile_getclock() - ti;
tcg_ctx.code_time -= profile_getclock();
#endif
gen_code_size = tcg_gen_code(&tcg_ctx, tb);
if (unlikely(gen_code_size < 0)) {
goto buffer_overflow;
}
search_size = encode_search(tb, (void *)gen_code_buf + gen_code_size);
if (unlikely(search_size < 0)) {
goto buffer_overflow;
}
#ifdef CONFIG_PROFILER
tcg_ctx.code_time += profile_getclock();
tcg_ctx.code_in_len += tb->size;
tcg_ctx.code_out_len += gen_code_size;
tcg_ctx.search_out_len += search_size;
#endif
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
qemu_log_in_addr_range(tb->pc)) {
qemu_log("OUT: [size=%d]\n", gen_code_size);
log_disas(tb->tc_ptr, gen_code_size);
qemu_log("\n");
qemu_log_flush();
}
#endif
tcg_ctx.code_gen_ptr = (void *)
ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size,
CODE_GEN_ALIGN);
assert(((uintptr_t)tb & 3) == 0);
tb->jmp_list_first = (uintptr_t)tb | 2;
tb->jmp_list_next[0] = (uintptr_t)NULL;
tb->jmp_list_next[1] = (uintptr_t)NULL;
if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 0);
}
if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 1);
}
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_page_addr_code(env, virt_page2);
}
tb_link_page(tb, phys_pc, phys_page2);
return tb;
}
| 1threat |
Accessing varibles inside Self-Executing Anonymous Function :
as per my knowledge varibles inside Self-Executing Anonymous Function are not accessible from outside but how come var q is accessible outside and y not var p then
(function(){
var p = q= 20;
})()
alert(q) --> 10
alert(p) --> p is undefined is the result im getting,`
| 0debug |
void pcspk_init(PITState *pit)
{
PCSpkState *s = &pcspk_state;
s->pit = pit;
register_ioport_read(0x61, 1, 1, pcspk_ioport_read, s);
register_ioport_write(0x61, 1, 1, pcspk_ioport_write, s);
}
| 1threat |
Load images from internal memory to imageview android : [enter image description here][1][2]How to display images from internal storage of phone to imageview android?
no image is loaded in imageview.my phone's version is Marshmallow.
[1]: https://i.stack.imgur.com/J7b1L.png
[2]: https://i.stack.imgur.com/koStx.png | 0debug |
How to debug Fable using Visual Studio (not Code) : <p>I know it is possible to debug Fable apps in VS Code and hit breakpoints, but I haven't seen any examples of such when using Visual Studio. How can one debug Fable apps using Visual Studio, being able to hit breakpoints, inspect variables, etc.?</p>
| 0debug |
How to pass a data from a link and then print it in a controller in Codeigniter : <p>I want to pass a data from a link and then print it in a controller.
This is my View:</p>
<pre><code><a href="<?php echo site_url("Main_controller/show_chronicles/".$row->chronicles_no); ?>">Chronicles</a>
</code></pre>
<p>and this is my controller function:</p>
<pre><code>function show_chronicles()
{
echo $row->chronicles_no;
}
</code></pre>
| 0debug |
Spring boot validation annotations @Valid and @NotBlank not working : <p>Given below is my main controller from which i am calling getPDFDetails method.</p>
<pre><code>@RequestMapping(value=PATH_PRINT_CONTRACTS, method=RequestMethod.POST)
public ResponseEntity<?> printContracts(@RequestBody final UpdatePrintContracts updatePrintContracts) throws Exception {
System.out.println("contracts value is "+ updatePrintContracts);
Integer cancellationReasons = service.getPDFDetails(updatePrintContracts);
System.out.println("success!");
return ResponseEntity.ok(cancellationReasons);
}
</code></pre>
<p>Below is the UpdatePrintContracts class where i have defined all the variables with validation annotations and corresponding getter/setter methods.</p>
<pre><code>public class UpdatePrintContracts {
@Valid
@NotBlank
@Pattern(regexp = "\\p{Alnum}{1,30}")
String isReprint;
@Valid
@NotBlank
Integer dealerId;
@Valid
@NotBlank
@Pattern(regexp = "\\p{Alnum}{1,30}")
String includeSignatureCoordinates;
@Valid
@NotBlank
java.util.List<Integer> contractNumbers;
public String getIsReprint() {
return isReprint;
}
public void setIsReprint(String isReprint) {
this.isReprint = isReprint;
}
public Integer getDealerId() {
return dealerId;
}
public void setDealerId(Integer dealerId) {
this.dealerId = dealerId;
}
public String getIncludeSignatureCoordinates() {
return includeSignatureCoordinates;
}
public void setIncludeSignatureCoordinates(String includeSignatureCoordinates) {
this.includeSignatureCoordinates = includeSignatureCoordinates;
}
public java.util.List<Integer> getContractNumbers() {
return contractNumbers;
}
public void setContractNumbers(java.util.List<Integer> contractNumbers) {
this.contractNumbers = contractNumbers;
}
}
</code></pre>
<p>I am trying to Run the application as Spring boot app by right clicking on the project (Run As) and passing blank values for variables isReprint and includeSignatureCoordinates thru Soap UI. However the validation doesn't seem to work and not throwing any validation error on the Soap UI. What am i missing? Any help is appreciated!</p>
| 0debug |
Pass command line args to npm scripts in package.json : <p>I have the below scripts in my package.json:</p>
<pre><code>"scripts": {
"vumper": "node node_modules/vumper/index.js",
"format": "prettier --single-quote -width=80 --write package.json"
},
</code></pre>
<p>The 'vumper' package takes in a command line argument (such as 'dv'). What I would like to be able to do is have a command that runs both of these in succession.</p>
<p>Essentially, I would like to be able to run:</p>
<pre><code>npm run vumber dv
</code></pre>
<p>and then</p>
<pre><code>npm run format
</code></pre>
<p>but in one command, something like </p>
<pre><code>npm run my-build dv
</code></pre>
<p>which would run both of the above commands, correctly accepting the command line argument 'dv' and passing it to the first npm run vumper. Is this possible?</p>
| 0debug |
How to use OpenCV in the Flutter SDK? : <p>I have been trying to find a Flutter OpenCV library. I'm looking to handle facial recognition through eye positioning. I need this to be for both android and iOS. I found one for C++ which I think Flutter compiles to as well as Swift/Objective C libraries. I am wondering which route would be the best to go or if there is a better option. </p>
| 0debug |
static void ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=16; i<16+8; i++){
if(nnzc[ scan8[i] ] || block[i*16])
ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
}
}
| 1threat |
Multi Array Sorting : <p>My Array is like this</p>
<pre><code>Array (
[0] => Array (
[salesID] => 7
[creditID] => 9
[amount] => 80400.00
[due_date] => 2018-12-12
[status] => no
[given_date] => 2018-09-30
[av_class] => table-warning
[name] => Kumaari
[contact] => 0
)
[1] => Array (
[salesID] => 3
[creditID] => 8
[amount] => 500.00
[due_date] => 2019-06-25
[status] => yes
[given_date] => 2018-09-30
[av_class] => table-success
[name] => Zayan
[contact] => 0765894520
)
)
</code></pre>
<p>I want to short / re-order main array by sub array's value : [due_date]
Please help me. Main array key is not necessary, but sub array keys cannot be changed. </p>
| 0debug |
pandas: groupby and aggregate without losing the column which was grouped : <p>I have a pandas dataframe as below. For each Id I can have multiple Names and Sub-ids.</p>
<pre><code>Id NAME SUB_ID
276956 A 5933
276956 B 5934
276956 C 5935
287266 D 1589
</code></pre>
<p>I want to condense the dataframe such that there is only one row for each id and all the names and sub_ids under each id appear as a singular set on that row</p>
<pre><code>Id NAME SUB_ID
276956 set(A,B,C) set(5933,5934,5935)
287266 set(D) set(1589)
</code></pre>
<p>I tried to groupby id and then aggregate over all the other columns </p>
<pre><code>df.groupby('Id').agg(lambda x: set(x))
</code></pre>
<p>But in doing so the resulting dataframe does not have the Id column. When you do groupby the id is returned as the first value of the tuple but I guess when you aggregate that is lost. Is there a way to get the dataframe that I am looking for. That is to groupby and aggregate without losing the column which was grouped.</p>
| 0debug |
what's the different with using $scope and explicitly using ctrl as namespace? : <p>We can use <code>$scope</code> as a namespace in angularJS</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code> angular.module('myApp',[])
.controller("myController", function($scope){
$scope.info = "Hello";
})</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="myController">
<input type="text" ng-model="info">
{{info}}
</div>
</body></code></pre>
</div>
</div>
</p>
<p>or we can use <code>this</code> explicitly in <code>controller</code> and use the controller name as namespace in view like:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code> angular.module('myApp',[])
.controller("myController", function(){
this.info = "Hello";
})</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="myController as ctrl">
<input type="text" ng-model="ctrl.info">
{{ctrl.info}}
</div>
</body></code></pre>
</div>
</div>
</p>
<p>My question is what's the difference and what choose to use? </p>
| 0debug |
How to make WebStorm format code according to eslint? : <p>I've specified eslint configuration for my WebStorm project. But it does not seem to apply to code reformat feature. For example, it continues to format <code>import { something } from 'somewhere'</code> as <code>import {something} from 'somewhere'</code>.</p>
<p>Is there a way to make WebStorm to format code according to eslint configuration?</p>
| 0debug |
static int vfio_set_resample_eventfd(VFIOINTp *intp)
{
VFIODevice *vbasedev = &intp->vdev->vbasedev;
struct vfio_irq_set *irq_set;
int argsz, ret;
int32_t *pfd;
argsz = sizeof(*irq_set) + sizeof(*pfd);
irq_set = g_malloc0(argsz);
irq_set->argsz = argsz;
irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK;
irq_set->index = intp->pin;
irq_set->start = 0;
irq_set->count = 1;
pfd = (int32_t *)&irq_set->data;
*pfd = event_notifier_get_fd(&intp->unmask);
qemu_set_fd_handler(*pfd, NULL, NULL, NULL);
ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set);
g_free(irq_set);
if (ret < 0) {
error_report("vfio: Failed to set resample eventfd: %m");
}
return ret;
}
| 1threat |
How do I do strikethrough (line-through) in asciidoc? : <p>How do I render a strikethrough (or line-through) in an <code>adoc</code> file?</p>
<p>Let's presume I want to write "That technology is -c-r-a-p- not perfect."</p>
| 0debug |
static void rng_random_finalize(Object *obj)
{
RndRandom *s = RNG_RANDOM(obj);
qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
if (s->fd != -1) {
qemu_close(s->fd);
}
g_free(s->filename);
}
| 1threat |
Window batch / DOS script to remove duplicate words in a string : <p>Can anyone help me with window batch / DOS script to remove in a string. </p>
<p>If the string is -</p>
<p>test1 test2 test1 test3 test2 test3</p>
<p>I need a script to display as </p>
<p>test1 test2 test3</p>
| 0debug |
which namespace is need to add for mathematical functions like sin,asin in c# : i need to calculate the following equation.which namespace is needed to add?.I used using.System but its not detected my code and contains error
double n= arcsin(sin(0.1570) / cos(_savedPosition.Latitude)); | 0debug |
RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data)
{
RTPDemuxContext *s;
s = av_mallocz(sizeof(RTPDemuxContext));
if (!s)
return NULL;
s->payload_type = payload_type;
s->last_rtcp_ntp_time = AV_NOPTS_VALUE;
s->first_rtcp_ntp_time = AV_NOPTS_VALUE;
s->ic = s1;
s->st = st;
s->rtp_payload_data = rtp_payload_data;
rtp_init_statistics(&s->statistics, 0);
if (!strcmp(ff_rtp_enc_name(payload_type), "MP2T")) {
s->ts = ff_mpegts_parse_open(s->ic);
if (s->ts == NULL) {
av_free(s);
return NULL;
}
} else {
av_set_pts_info(st, 32, 1, 90000);
switch(st->codec->codec_id) {
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
case CODEC_ID_MP2:
case CODEC_ID_MP3:
case CODEC_ID_MPEG4:
case CODEC_ID_H263:
case CODEC_ID_H264:
st->need_parsing = AVSTREAM_PARSE_FULL;
break;
default:
if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
av_set_pts_info(st, 32, 1, st->codec->sample_rate);
}
break;
}
}
s->rtp_ctx = rtpc;
gethostname(s->hostname, sizeof(s->hostname));
return s;
}
| 1threat |
Decimal Separated String List as Tree in Java : Please consider the following data, which i am getting as list.
<code>{"20.01","20.01.01","20.01.01.01","20.01.02","20.01.02.01","20.01.02.02","20.02","20.02.01","20.02.01.01","20.02.02","20.02.02.01","20.02.02.02","20.02.02.02.01","20.02.02.02.01.01","20.02.02.02.02","20.02.02.02.03"}</code>
I want to organize it tree shape using core java like as follows.
<code>
20.01
20.01.01
20.01.01.01
20.01.02
20.01.02.01
20.01.02.02
20.02
20.02.01
20.02.01.01
20.02.02
20.02.02.01
20.02.02.02
20.02.02.02.01
20.02.02.02.01.01
20.02.02.02.02
20.02.02.02.03
</code>
Please let us know any simpler solution in java. | 0debug |
void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size)
{
PCICirrusVGAState *d;
uint8_t *pci_conf;
CirrusVGAState *s;
int device_id;
device_id = CIRRUS_ID_CLGD5446;
d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
sizeof(PCICirrusVGAState),
-1, NULL, NULL);
pci_conf = d->dev.config;
pci_conf[0x00] = (uint8_t) (PCI_VENDOR_CIRRUS & 0xff);
pci_conf[0x01] = (uint8_t) (PCI_VENDOR_CIRRUS >> 8);
pci_conf[0x02] = (uint8_t) (device_id & 0xff);
pci_conf[0x03] = (uint8_t) (device_id >> 8);
pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;
pci_conf[0x0a] = PCI_CLASS_SUB_VGA;
pci_conf[0x0b] = PCI_CLASS_BASE_DISPLAY;
pci_conf[0x0e] = PCI_CLASS_HEADERTYPE_00h;
s = &d->cirrus_vga;
vga_common_init((VGAState *)s,
ds, vga_ram_base, vga_ram_offset, vga_ram_size);
cirrus_init_common(s, device_id, 1);
s->console = graphic_console_init(s->ds, s->update, s->invalidate,
s->screen_dump, s->text_update, s);
s->pci_dev = (PCIDevice *)d;
pci_register_io_region((PCIDevice *)d, 0, 0x2000000,
PCI_ADDRESS_SPACE_MEM_PREFETCH, cirrus_pci_lfb_map);
if (device_id == CIRRUS_ID_CLGD5446) {
pci_register_io_region((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map);
}
}
| 1threat |
Invalid maximum heap size : <p>I have copied a jdk directory from another location. Since then, I get the following error message.</p>
<pre><code>Your environment has been set.
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode, sharing)
PROPS=-Xms1024m -Xmx5096m -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -Djava.ext.dirs=..;.;..\lib;..\classes -Dfile.encoding=UTF-8
CLASSPATH=C:\Oracle\MIDDLE~1\patch_wls1211\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\PROGRA~1\Java\JDK15~1.0_2\lib\tools.jar;C:\Oracle\MIDDLE~1\WLSERV~1.1\server\lib\weblogic_sp.jar;C:\Oracle\MIDDLE~1\WLSERV~1.1\server\lib\weblogic.jar;C:\Oracle\MIDDLE~1\modules\features\weblogic.server.modules_12.1.1.0.jar;C:\Oracle\MIDDLE~1\WLSERV~1.1\server\lib\webservices.jar;C:\Oracle\MIDDLE~1\modules\ORGAPA~1.1/lib/ant-all.jar;C:\Oracle\MIDDLE~1\modules\NETSFA~1.0_1/lib/ant-contrib.jar;
Invalid maximum heap size: -Xmx5096m
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.
</code></pre>
<p>Does this mean I will have to re-install the jdk, and not just copy any installation directory? <strong>I'm asking this and not trying it out myself because</strong> this exercise will have to be done in a client machine.</p>
<p>The current machine is a Windows 2008 server and has <strong>12GB</strong> of RAM.</p>
| 0debug |
Integrating SVN with kwallet : <p>I can't for my life make SVN read the password stored at kwallet and use it to stop asking when I do anything. Google has not helped finding the answer, so I turn back to you. </p>
<p>I'm running right now Kubuntu 16.04 fully upgraded, SVN is version 1.9.3 (r1718519), and it says that it has support for KWALLET</p>
<p>The following authentication credential caches are available:</p>
<pre><code>* Plaintext cache in /home/ssol/.subversion
* Gnome Keyring
* GPG-Agent
* KWallet (KDE)
</code></pre>
<p>My <code>.subversion/config</code> has the following configuration:</p>
<pre><code>[auth]
password-stores = kwallet
</code></pre>
<p>My <code>.subversion/servers</code> has the following configuration:</p>
<pre><code>[global]
store-passwords = yes
</code></pre>
<p>KWallet is installed, the Wallet manager says Version 15.12.3. I only have 1 wallet, the default <code>kdewallet</code> with a bunch of folders there. I know it works because I use it with <code>ksshaskpass</code> and it works flawless. On Subversion, something is not working right. </p>
<p>After I added the configurations, I did an svn update on a project I have, it asked for the password. After typing it, the annexed prompt popped, to allow subversion to connect to the wallet. I type the wallet password and allowed it. But no entry was update inside the wallet. </p>
<p>I tried a second type, it asked again for the same prompt. And, this time, SVN saved the password as a <strong>plain-text inside the .subversion/auth/svn.simple/</strong>.</p>
<p>So, what am I doing wrong?</p>
| 0debug |
Cant call javascript function : I cant seem call the function formValidation from my form. I tried everything but Im pretty sure I'm over-looking something minor
I have to add more text to post this question and hopefully this much is enough
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function formValidation(){
var user = document.getElementById("username").value;
var password = document.getElementById("password").value;
var userValid = /^[a-zA-Z0-9]{5,10}$/;
// username must be between 5 to 10 characters and shouldn't contain special characters
var passwordValid = /^{8,18}$/;
//password must be atleast 8 characters
if(!userValid.match(user)){
alert('Invalid username');
return false;
}
echo('test');
return true;
}
</script>
<h3>Register New User</h3>
<form name = "form1" onsubmit="return formValidation() " action="process.php" method="POST" >
<!-- Order matters, first JS script run then the next php page visited -->
Username:<input type="text" id="username" placeholder="Enter" value="" name="username"> <br>
Email ID:<input type="text" name= "email"><br>
Password: <input type="password" id="password" ><br>
Confirm Password: <input type="password" id="password" ><br>
<input type="submit" name="button" value="Click here">
</form>
</body>
</html> | 0debug |
"‘CLOCK_PER_SEC’ was not declared in this scope" error even after including <time.h> : <p>I'm getting "‘CLOCK_PER_SEC’ was not declared in this scope" error even after including time.h.
I'm very newbie to c++, so this will be related to simple mistakes, but i sadly can't figure out. please help me.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 1024*1024*1
#define REPEAT 10
using namespace std;
.......
int main()
{
const int n = SIZE;
int* arr = (int*)malloc(n * sizeof(int));
for (int i = 0; i < n; i++)
{
arr[i] = n - i;
}
double totalSeiralTime = 0;
clock_t clock_s, clock_e;
for(int i = 0; i < REPEAT ; i++)
{
clock_s = clock();
radixsort(arr, n);
clock_e = clock();
double cpu_time_used = ((double)(clock_e-clock_s))/CLOCK_PER_SEC;
printf("gpu parallel time : %f\n", cpu_time_used);
totalSeiralTime += cpu_time_used;
}
printf("cpu serial time mean : %f\n", totalSeiralTime / REPEAT);
return 0;
}
</code></pre>
<p>how i compile</p>
<pre><code>gcc -std=c++11 ./cpuRadix.cpp -o ./cpuRadix.out
./cpuRadix.out
</code></pre>
<p>I also have tried without std option. But It didn't make change.</p>
| 0debug |
how can i make {0} and {1} variables in python? : <p>in C# it was Possible to Use a Code Like This:</p>
<pre><code>Console.WriteLine ("hello{0}" ,Hello);
</code></pre>
<p>i Want to do Same Thing in Python,i Want to Call Variable With {0} and {1} Way.
How Can I Do This ?</p>
| 0debug |
START_TEST(qdict_del_test)
{
const char *key = "key test";
qdict_put(tests_dict, key, qstring_from_str("foo"));
fail_unless(qdict_size(tests_dict) == 1);
qdict_del(tests_dict, key);
fail_unless(qdict_size(tests_dict) == 0);
fail_unless(qdict_haskey(tests_dict, key) == 0);
}
| 1threat |
service is not being called in angular 2 aplication : need urgent help i am new to angular 2 need help in calling service.
here is the plnkr i made
`App.ts`**https://plnkr.co/edit/wss2Jy41pYyjQUOk47es?p=preview)** | 0debug |
Why if else is different form guard let and if let? : <p>Because we can identify nil value using if else. Same thing we do using guard let and if let. What is the use of these..</p>
| 0debug |
static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
{
OutputFile *of = output_files[ost->file_index];
int64_t ost_tb_start_time = av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);
AVPacket opkt;
av_init_packet(&opkt);
if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) &&
!ost->copy_initial_nonkeyframes)
return;
if (of->recording_time != INT64_MAX &&
ist->last_dts >= of->recording_time + of->start_time) {
ost->is_past_recording_time = 1;
return;
}
if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
audio_size += pkt->size;
else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
video_size += pkt->size;
ost->sync_opts++;
}
if (pkt->pts != AV_NOPTS_VALUE)
opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time;
else
opkt.pts = AV_NOPTS_VALUE;
if (pkt->dts == AV_NOPTS_VALUE)
opkt.dts = av_rescale_q(ist->last_dts, AV_TIME_BASE_Q, ost->st->time_base);
else
opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base);
opkt.dts -= ost_tb_start_time;
opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);
opkt.flags = pkt->flags;
if ( ost->st->codec->codec_id != AV_CODEC_ID_H264
&& ost->st->codec->codec_id != AV_CODEC_ID_MPEG1VIDEO
&& ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO
&& ost->st->codec->codec_id != AV_CODEC_ID_VC1
) {
if (av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY))
opkt.destruct = av_destruct_packet;
} else {
opkt.data = pkt->data;
opkt.size = pkt->size;
}
write_frame(of->ctx, &opkt, ost);
ost->st->codec->frame_number++;
av_free_packet(&opkt);
}
| 1threat |
i want to do something when i close console VB window is that possible? : <p>I want to call function or execute some code when i <code>close</code> the window in console vb is that possible?</p>
<p>thanks in advance </p>
| 0debug |
Graph multicolor area line : <p>i need to create graph as <a href="https://i.stack.imgur.com/BGAO6.png" rel="nofollow noreferrer">showed on image</a>.</p>
<p>One line with color filled area,
if point value is more than zero than color of line and area is green, else red.</p>
<p>How can i do this? JS (some plugin?) or PHP (imagick, gd) </p>
| 0debug |
Rewriting "do while" loop from java to python : <p>I am trying to rewrite the following piece of java code to python:</p>
<pre><code>class pcp {
public static void main(String[] args) {
final int b = 13;
final int m = 1000;
int a0 = 1;
int mas[] = new int[10];
int a = a0, T = 0;
do {
System.out.print(a + " ");
a = (b * a) % m;
T++;
mas[a * 10 / m]++;
} while (a != a0);
System.out.print("\n" + T + "\n");
for (int i = 0; i < mas.length; i++)
System.out.print(mas[i] + " ");
}
}
</code></pre>
<p>It's a simple pseudo random number generator with the following output:</p>
<pre><code>1 13 169 197 561 293 809 517 721 373 849 37 481 253 289 757 841 933 129 677 801 413 369 797 361 693 9 117 521 773 49 637 281 653 489 357 641 333 329 277 601 813 569 397 161 93 209 717 321 173 249 237 81 53 689 957 441 733 529 877 401 213 769 997 961 493 409 317 121 573 449 837 881 453 889 557 241 133 729 477 201 613 969 597 761 893 609 917 921 973 649 437 681 853 89 157 41 533 929 77
100
11 9 11 9 11 9 11 9 11 9
</code></pre>
<p>Here's my Python code:</p>
<pre><code>b = 13
m = 1000
a0 = 1
mas = [0] * 10
a = a0
T = 0
while not (a != a0):
print(a)
a = (b * a) % m
T = T + 1
mas[int(a * 10 / m)] = mas[int(a * 10 / m)] + 1
print(T)
i = 0
while (i < len(mas)):
print(mas[i])
i = i + 1
</code></pre>
<p>It simply won't enter the loop an I'm kinda at loss about how rewrite it in the correct way for python.</p>
<p>Thank you for reading and your help.</p>
| 0debug |
Volume binding using docker compose on Windows : <p>I recently upgraded my Docker Toolbox on Windows 10, and now my volume mounts no longer work. I've tried everything. Here is the current mount path:</p>
<pre><code>volumes:
- C:\Users\Joey\Desktop\backend:/var/www/html
</code></pre>
<p>I receive an invalid bind mount error.</p>
| 0debug |
How to split a date from String by using slenium...? i trie with below way, but , i am not able to store : The client start date is 13/10/2018.
In above string i want to keep date in separate varible.
String[] effectiveDateText=driver.findElement(By.xpath(xpath)).getText().split(" ");
for(int i=0;i<effectiveDateText.length;i++){
String effectiveDate=effectiveDateText.length-1;
}
| 0debug |
Traefik Forward Authentication in k8s ingress controller : <p>Hello I tried looking at the auth options in the annotations for kubernetes traefik ingress. I couldn't find anything where I could configure Forward Authentication as documented here: <a href="https://docs.traefik.io/configuration/entrypoints/#forward-authentication" rel="noreferrer">https://docs.traefik.io/configuration/entrypoints/#forward-authentication</a></p>
<p>I would like to be able to configure forward authentication per ingress resource. This is possible in the nginx ingress controller.</p>
<p>Is that supported currently?</p>
| 0debug |
guys i have below test code. How can I made this condition to be True : guys i have below test code. How can I made this condition to be True. I know a.split is method in Str() but when I put it on a variable it sees it as a list.
a="1.1.1.1/29"
aa=a.split('/')
>>aa == "29"
>>False | 0debug |
Swift, polare circle : I have to draw 12 points in a circle with different radiant. From point 1, draw a line to point 2, from point 2 to 3, etc.
I can not find a formula, but I think it's something with polar circle?
Is anyone working with it and maybe want to share with me?
See the picture, which might explain better than I can?
[1]: https://i.stack.imgur.com/1DgpN.jpg | 0debug |
CPUState *ppc405cr_init (target_phys_addr_t ram_bases[4],
target_phys_addr_t ram_sizes[4],
uint32_t sysclk, qemu_irq **picp,
int do_init)
{
clk_setup_t clk_setup[PPC405CR_CLK_NB];
qemu_irq dma_irqs[4];
CPUState *env;
qemu_irq *pic, *irqs;
memset(clk_setup, 0, sizeof(clk_setup));
env = ppc4xx_init("405cr", &clk_setup[PPC405CR_CPU_CLK],
&clk_setup[PPC405CR_TMR_CLK], sysclk);
ppc4xx_plb_init(env);
ppc4xx_pob_init(env);
ppc4xx_opba_init(0xef600600);
irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
*picp = pic;
ppc4xx_sdram_init(env, pic[14], 1, ram_bases, ram_sizes, do_init);
ppc405_ebc_init(env);
dma_irqs[0] = pic[26];
dma_irqs[1] = pic[25];
dma_irqs[2] = pic[24];
dma_irqs[3] = pic[23];
ppc405_dma_init(env, dma_irqs);
if (serial_hds[0] != NULL) {
serial_mm_init(0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE,
serial_hds[0], 1, 1);
}
if (serial_hds[1] != NULL) {
serial_mm_init(0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE,
serial_hds[1], 1, 1);
}
ppc405_i2c_init(0xef600500, pic[2]);
ppc405_gpio_init(0xef600700);
ppc405cr_cpc_init(env, clk_setup, sysclk);
return env;
}
| 1threat |
Build laravel from framework kernel : <p>I have started a project to convert some parts of laravel framework to compiled php extensions to improve the performance. I have created a git repository for the migrated parts and another for the laravel modification that will use that extension.</p>
<p>My question is how to build completly all laravel from framework kernel modified?</p>
<p>Do you think that I'm doing well?</p>
| 0debug |
static inline int available_samples(AVFrame *out)
{
int bytes_per_sample = av_get_bytes_per_sample(out->format);
int samples = out->linesize[0] / bytes_per_sample;
if (av_sample_fmt_is_planar(out->format)) {
return samples;
} else {
int channels = av_get_channel_layout_nb_channels(out->channel_layout);
return samples / channels;
}
}
| 1threat |
Beautify JSON when stringify : <p>When I'm saving JSON with stringify and <code>fs</code> package it looks like this:</p>
<pre><code>{"\"name:\"":"\"Alice\"","\"age\"": 18}
</code></pre>
<p>I don't understand why. Is there any way to prettify it like this?</p>
<pre><code>{"name:":"Alice","age": 18}
</code></pre>
| 0debug |
def month_season(month,days):
if month in ('January', 'February', 'March'):
season = 'winter'
elif month in ('April', 'May', 'June'):
season = 'spring'
elif month in ('July', 'August', 'September'):
season = 'summer'
else:
season = 'autumn'
if (month == 'March') and (days > 19):
season = 'spring'
elif (month == 'June') and (days > 20):
season = 'summer'
elif (month == 'September') and (days > 21):
season = 'autumn'
elif (month == 'October') and (days > 21):
season = 'autumn'
elif (month == 'November') and (days > 21):
season = 'autumn'
elif (month == 'December') and (days > 20):
season = 'winter'
return season | 0debug |
My program cant run accountType as a variable : #include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int accountNumber;
float minimumBalance, currentBalance;
char accountType;
const float SAVINGS_SERVICE_CHARGE = 10.00;
const float CHECKING_SERVICE_CHARGE = 25.00;
const float SAVINGS_INTEREST_RATE = 0.04;
const float CHECKING_LOW_INTEREST_RATE = 0.03;
const float CHECKING_AVERAGE_INTEREST_RATE = 0.05;
cout <<"Please the details of your account"<< endl;
cin >> accountNumber,accountType,minimumBalance,currentBalance;
switch (accountType){
case 's':
case 'S':
cout <<"Account number"<<accountNumber<<endl;
cout <<fixed<<showpoint<<setprecision(2);
cout <<"Account type:Savings"<<endl;
cout <<"Minimum Balance: $"<<minimumBalance << endl;
cout <<"Current Balance: $"<<currentBalance << endl;
if (currentBalance < minimumBalance) {
cout <<"Service Fee:$"<<SAVINGS_SERVICE_CHARGE<<endl;}
else {
cout <<"Interest Earned:$"<<currentBalance * SAVINGS_INTEREST_RATE << "at" << SAVINGS_INTEREST_RATE*100<<"p%.a"<<endl;
}
break;
case 'c':
case 'C':
cout <<"Account number"<<accountNumber<<endl;
cout <<fixed<<showpoint<<setprecision(2);
cout <<"Account type:Checking"<<endl;
cout <<"Minimum Balance:$"<<minimumBalance<<endl;
cout <<"Current Balance:$"<<currentBalance<<endl;
if (currentBalance < minimumBalance) {
cout <<"Service fee:$"<<CHECKING_SERVICE_CHARGE<<endl;}
else if (currentBalance <= (minimumBalance+5000.00)){
cout <<"Interest Earned:$"<<currentBalance * CHECKING_LOW_INTEREST_RATE <<"at"<<CHECKING_LOW_INTEREST_RATE*100 <<"%p.a"<<endl;
}else {
cout <<"Interest Earned:$"<<currentBalance * CHECKING_AVERAGE_INTEREST_RATE<< "at"<< CHECKING_AVERAGE_INTEREST_RATE*100 <<"%p.a"<<endl;
}
break;
default:
cout <<"ERROR"<<endl;
return 1;
break;
}
system ("pause");
return 0;
}
My program cant read accountType as a variable what should i do to make it run as a variable? Please tell me what to do step by step and what is my error and what to do to make it work thanks in advance.
| 0debug |
Generate 6 digits pin code using python : <p>I want to build python algorithm that generates 6 digits pin code. I had many ideas like : based on time, on id .... etc, but non sounded secure once the algorithm is exposed. Now I am trying to generate that using <code>random.randint(a, b)</code>, however I want to know how it really works and python documentation don't provide much about it. So can you please provide more about this or any other suggestions to generate 6 digits pin code.</p>
| 0debug |
static uint64_t ppc_hash64_page_shift(ppc_slb_t *slb)
{
uint64_t epnshift;
if ((slb->vsid & SLB_VSID_LLP_MASK) == SLB_VSID_4K) {
epnshift = TARGET_PAGE_BITS;
} else if ((slb->vsid & SLB_VSID_LLP_MASK) == SLB_VSID_64K) {
epnshift = TARGET_PAGE_BITS_64K;
} else {
epnshift = TARGET_PAGE_BITS_16M;
}
return epnshift;
}
| 1threat |
Should Health Checks call other App Health Checks : <p>I have two API's A and B that I control and both have readiness and liveness health checks. A has a dependency on B.</p>
<pre><code>A
/foo - This endpoint makes a call to /bar in B
/status/live
/status/ready
B
/bar
/status/live
/status/ready
</code></pre>
<p>Should the readiness health check for A make a call to the readiness health check for API B because of the dependency?</p>
| 0debug |
How to diff in a comment on github? : <p>I've seen people show diffs of their code from other forks to illustrate a point in github like on this pull request thread: <a href="https://github.com/osTicket/osTicket/pull/3035" rel="noreferrer">https://github.com/osTicket/osTicket/pull/3035</a></p>
<p>I think it would be really helpful to show the diff of the commit from the current branch. How do you do it?</p>
| 0debug |
def highest_Power_of_2(n):
res = 0;
for i in range(n, 0, -1):
if ((i & (i - 1)) == 0):
res = i;
break;
return res; | 0debug |
How can I pause the azure storage sync service : Azure Storage Sync Service[enter image description here][1]
[1]: https://i.stack.imgur.com/9ns2C.jpg
[1]: https://i.stack.imgur.com/9ns2C.jpg | 0debug |
static int vhost_net_start_one(struct vhost_net *net,
VirtIODevice *dev)
{
struct vhost_vring_file file = { };
int r;
net->dev.nvqs = 2;
net->dev.vqs = net->vqs;
r = vhost_dev_enable_notifiers(&net->dev, dev);
if (r < 0) {
goto fail_notifiers;
}
r = vhost_dev_start(&net->dev, dev);
if (r < 0) {
goto fail_start;
}
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, false);
}
if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
file.fd = net->backend;
for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
const VhostOps *vhost_ops = net->dev.vhost_ops;
r = vhost_ops->vhost_net_set_backend(&net->dev, &file);
if (r < 0) {
r = -errno;
goto fail;
}
}
}
return 0;
fail:
file.fd = -1;
if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
while (file.index-- > 0) {
const VhostOps *vhost_ops = net->dev.vhost_ops;
int r = vhost_ops->vhost_net_set_backend(&net->dev, &file);
assert(r >= 0);
}
}
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, true);
}
vhost_dev_stop(&net->dev, dev);
fail_start:
vhost_dev_disable_notifiers(&net->dev, dev);
fail_notifiers:
return r;
}
| 1threat |
def sum_nums(x, y,m,n):
sum_nums= x + y
if sum_nums in range(m, n):
return 20
else:
return sum_nums | 0debug |
Angular-CLI: unable to display API response : Hey Stackoverflow Angular guys, it's me again ;-)
So, my API is getting a json response (hooray!). Now, I'm trying to just display it however possible in one of my components just to understand and observe how the data is being transferred and displayed, so I can build over it later.
For some reason, I cannot get anything to show, even though my component is working (I keep some other stuff in it to keep track of it showing or not).
Any suggestion what am I doing wrong or how to try to get it working? I've ran out of ideas and my internet search has been highly unfruitful.
contact.service.ts
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/Http';
import { Observable } from 'rxjs/Observable';
import { map } from "rxjs/operator/map";
import { environment } from '../environments/environment';
import { IContact } from './icontact';
import './rxjs-operators';
const API_URL = environment.apiUrl;
@Injectable()
export class ContactService {
constructor(private http: Http) { }
public getContacts(): Observable<IContact[]> {
return this.http.get(API_URL)
.map(response => <IContact[]>response.json());
}
}
contact.component.ts
import { Component, OnInit } from '@angular/core';
import { ContactService } from '../contact.service';
import { Http, Response } from '@angular/Http';
import { IContact } from '../icontact';
@Component({
selector: 'app-contact',
templateUrl: './contact.component.html',
styleUrls: ['./contact.component.css'],
providers: [ContactService]
})
export class ContactComponent implements OnInit {
private contactlist: IContact[];
constructor(private contactService: ContactService) {
}
public ngOnInit() {
this.contactService.getContacts().subscribe(
(contacts) => { this.contactlist = contacts; },
(error) => { console.log(error); }
);
}
}
contact.component.html - if I get it right, below template should be able to display stuff from my API but it comes back empty.
<div *ngFor="let contact of contacts">
{{contact}}
</div> | 0debug |
Best Multithread Global Variable Management : <p>I've looked at things like <code>std::atomic</code> (which doesn't work) and <code>std::mutex</code> (which is too much to manage) but nothing is working :( I'm using <code>std::thread</code> to create my threads, but I'm open to using <code>CreateThread()</code></p>
<p>Here is the scenario: I have a variable that is constantly being updated in one thread. (say it's an int which reflects some value like number of dollars the user has) In the other threads, I access this variable, but do not write to it (just read). What can I do for this?</p>
<p><code>std::atomic</code> doesn't store the information fast enough in the first thread, which results in really really broken values (say the user has $10, if I write $10 twice before <code>std::atomic</code> actually updates it, it'll be some obscure value like 28 million) - there's no "variable save queue" of any sort.</p>
<p><code>std::mutex</code> just requires too much attention and ruins code readability.</p>
<p>What is the best way to manage these global variables? I'd love something as intuitive as <code>std::atomic</code>, since it manages everything for me, but preferably one that will satisfy my current dilemma.</p>
| 0debug |
Convert date to timestamp for storing into firebase firestore in javascript : <p>I'm currently using <code>Math.floor(Date.now() / 1000)</code> to get the correct timestamp format to add into a document in Firebase, however, the timestamp gets inserted as a number, and not as a timestamp.</p>
<p><a href="https://i.stack.imgur.com/pE1ph.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pE1ph.png" alt="number"></a></p>
<p>I would like to have it inserted as shown below (as a timestamp, not as a number).</p>
<p><a href="https://i.stack.imgur.com/0JeaX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0JeaX.png" alt="enter image description here"></a></p>
<p>Is this possible?</p>
| 0debug |
static void colo_compare_finalize(Object *obj)
{
CompareState *s = COLO_COMPARE(obj);
qemu_chr_fe_deinit(&s->chr_pri_in);
qemu_chr_fe_deinit(&s->chr_sec_in);
qemu_chr_fe_deinit(&s->chr_out);
g_queue_free(&s->conn_list);
if (qemu_thread_is_self(&s->thread)) {
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
qemu_thread_join(&s->thread);
}
g_free(s->pri_indev);
g_free(s->sec_indev);
g_free(s->outdev);
}
| 1threat |
finding the number of pixels : I have a simple green fluorescent image. I want to find the total number of pixels that are above a specific value using MATLAB. I don't know where the pixel values are stored in an image. Please help me. | 0debug |
How would you convert this C++ program to a C program? : <p>Thank you for your time in advance, I'm struggling on how to turn this code into C language, I'm just starting in the programming world, so if you have any doubt, I can answer, this is the code... </p>
<pre><code>// C++ program for implementation of Heap Sort
#include <iostream>
using namespace std;
// To heapify a subtree rooted with node i which is
// an index in arr[]. n is size of heap
void heapify(int arr[], int n, int i)
{
int largest = i; // Initialize largest as root
int l = 2*i + 1; // left = 2*i + 1
int r = 2*i + 2; // right = 2*i + 2
// If left child is larger than root
if (l < n && arr[l] > arr[largest])
largest = l;
// If right child is larger than largest so far
if (r < n && arr[r] > arr[largest])
largest = r;
// If largest is not root
if (largest != i)
{
swap(arr[i], arr[largest]);
// Recursively heapify the affected sub-tree
heapify(arr, n, largest);
}
}
// main function to do heap sort
void heapSort(int arr[], int n)
{
// Build heap (rearrange array)
for (int i = n / 2 - 1; i >= 0; i--)
heapify(arr, n, i);
// One by one extract an element from heap
for (int i=n-1; i>=0; i--)
{
// Move current root to end
swap(arr[0], arr[i]);
// call max heapify on the reduced heap
heapify(arr, i, 0);
}
}
/* A utility function to print array of size n */
void printArray(int arr[], int n)
{
for (int i=0; i<n; ++i)
cout << arr[i] << " ";
cout << "\n";
}
// Driver program
int main()
{
int arr[] = {12, 11, 13, 5, 6, 7};
int n = sizeof(arr)/sizeof(arr[0]);
heapSort(arr, n);
cout << "Sorted array is \n";
printArray(arr, n);
}
</code></pre>
<p>After that, I would have to add another function, but thats a story for another day, being able to convert it would help me a lot on starting to use C++. Also, which one should I try to specialize on first? English isn't my main language, sorry if I have some mistakes.</p>
| 0debug |
How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"? : <p>When I run <code>composer install</code> on command promp, there exist error like this : </p>
<pre><code> Problem 1
- Installation request for laravel/horizon v1.1.0 -> satisfiable by laravel/horizon[v1.1.0].
- laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
To enable extensions, verify that they are enabled in your .ini files:
- C:\xampp-7.1\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
</code></pre>
<p>How can I solve this error?</p>
| 0debug |
Is there a macro for creating fast Iterators from generator-like functions in julia? : <p>Coming from python3 to Julia one would love to be able to write <strong>fast</strong> iterators as a function with produce/yield syntax or something like that.</p>
<p>Julia's macros seem to suggest that one could build a macro which transforms such a "generator" function into an julia iterator.
[It even seems like you could easily <strong>inline</strong> iterators written in function style, which is a feature the Iterators.jl package also tries to provide for its specific iterators <a href="https://github.com/JuliaCollections/Iterators.jl#the-itr-macro-for-automatic-inlining-in-for-loops" rel="noreferrer">https://github.com/JuliaCollections/Iterators.jl#the-itr-macro-for-automatic-inlining-in-for-loops</a> ]</p>
<p>Just to give an example of what I have in mind:</p>
<pre><code>@asiterator function myiterator(as::Array)
b = 1
for (a1, a2) in zip(as, as[2:end])
try
@produce a1[1] + a2[2] + b
catch exc
end
end
end
for i in myiterator([(1,2), (3,1), 3, 4, (1,1)])
@show i
end
</code></pre>
<p>where <code>myiterator</code> should ideally create a fast iterator with as low overhead as possible. And of course this is only one specific example. I ideally would like to have something which works with all or almost all generator functions.</p>
<p>The currently recommended way to transform a generator function into an iterator is via Julia's Tasks, at least to my knowledge. However they also seem to be way slower then pure iterators. For instance if you can express your function with the simple iterators like <code>imap</code>, <code>chain</code> and so on (provided by <a href="https://github.com/JuliaCollections/Iterators.jl" rel="noreferrer"><code>Iterators.jl</code></a> package) this seems to be highly preferable.</p>
<p>Is it theoretically possible in julia to build a macro converting generator-style functions into flexible <strong>fast</strong> iterators?</p>
<p>Extra-Point-Question: If this is possible, could there be a generic macro which inlines such iterators?</p>
| 0debug |
Easy C++ for newbie function of the '<<' : <pre><code>#import <iostream>
using namespace std;
int main()
{
cout << 123 <<'\n';
cout <<"$100 recived \n";
cout <<"see you tomorrow \n";
return 0;
}
</code></pre>
<p>in this C++ program line, i dunno the function of the '<<' here; (i'm a newbie)</p>
<p>for example, an error occurs when i remove the '<<'in the first line</p>
<pre><code>#import <iostream>
using namespace std;
int main()
{
**cout << 123 '\n';**
cout <<"$100 recived \n";
cout <<"see you tomorrow \n";
return 0;
}
</code></pre>
<p>i dunno why I need the '<<' please help me :(</p>
| 0debug |
match(n)-[r:LIKES]->(m) with count(n) as cnt, m where cnt = max(cnt) return m : match(n)-[r:LIKES]->(m) with count(n) as cnt, m where cnt = max(cnt) return m
above query gives following error:
Invalid use of aggregating function max(...) in this context (line 1, column 61 (offset: 60)) | 0debug |
C2248 - From to 2 inheritances : <p>I have 3 classes, 1 inherited by another. A->B->C. A has a protected member function that I'm trying to set using C.</p>
<p>I'm getting C2248 -
Error C2248 'A::status': cannot access inaccessible member declared in class 'A' Associations </p>
<p>Am I not allowed to access to the variable in class C?</p>
<pre><code> class A {
public:
A();
~A();
protected:
char status[4];
};
class B: class A {
public:
B();
~B();
};
class C: class B {
public:
C(char newStatus[4]);
};
C::C(char newStatus[4])
{
this.status = newStatus;
}
</code></pre>
| 0debug |
void bdrv_init_with_whitelist(void)
{
use_bdrv_whitelist = 1;
bdrv_init();
}
| 1threat |
static abi_long target_to_host_data_route(struct nlmsghdr *nlh)
{
struct ifinfomsg *ifi;
struct ifaddrmsg *ifa;
struct rtmsg *rtm;
switch (nlh->nlmsg_type) {
case RTM_GETLINK:
break;
case RTM_NEWLINK:
case RTM_DELLINK:
ifi = NLMSG_DATA(nlh);
ifi->ifi_type = tswap16(ifi->ifi_type);
ifi->ifi_index = tswap32(ifi->ifi_index);
ifi->ifi_flags = tswap32(ifi->ifi_flags);
ifi->ifi_change = tswap32(ifi->ifi_change);
target_to_host_link_rtattr(IFLA_RTA(ifi), nlh->nlmsg_len -
NLMSG_LENGTH(sizeof(*ifi)));
break;
case RTM_GETADDR:
case RTM_NEWADDR:
case RTM_DELADDR:
ifa = NLMSG_DATA(nlh);
ifa->ifa_index = tswap32(ifa->ifa_index);
target_to_host_addr_rtattr(IFA_RTA(ifa), nlh->nlmsg_len -
NLMSG_LENGTH(sizeof(*ifa)));
break;
case RTM_GETROUTE:
break;
case RTM_NEWROUTE:
case RTM_DELROUTE:
rtm = NLMSG_DATA(nlh);
rtm->rtm_flags = tswap32(rtm->rtm_flags);
target_to_host_route_rtattr(RTM_RTA(rtm), nlh->nlmsg_len -
NLMSG_LENGTH(sizeof(*rtm)));
break;
default:
return -TARGET_EOPNOTSUPP;
}
return 0;
}
| 1threat |
Ruby on Rails Developed Applications : <p>I'm looking to develop a desktop (not server) web application and I have been comparing Ruby on Rails vs Django. Question is, with Django the client needs to install Python 2.5, does the client need to install anything to execute a Ruby on Rails application?
Thanks....</p>
| 0debug |
what is the meaning of tslint: "Warning: The 'no-use-before-declare' rule requires type information"? : <p>What is the meaning of tslint: "Warning: The 'no-use-before-declare' rule requires type information."? I did some basic googling but I'm not clear on what this means or its implications.</p>
| 0debug |
int DMA_read_memory (int nchan, void *buf, int pos, int len)
{
struct dma_regs *r = &dma_controllers[nchan > 3].regs[nchan & 3];
target_phys_addr_t addr = ((r->pageh & 0x7f) << 24) | (r->page << 16) | r->now[ADDR];
if (r->mode & 0x20) {
int i;
uint8_t *p = buf;
cpu_physical_memory_read (addr - pos - len, buf, len);
for (i = 0; i < len >> 1; i++) {
uint8_t b = p[len - i - 1];
p[i] = b;
}
}
else
cpu_physical_memory_read (addr + pos, buf, len);
return len;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.