problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void test_flush(void)
{
QPCIDevice *dev;
QPCIBar bmdma_bar, ide_bar;
uint8_t data;
ide_test_start(
"-drive file=blkdebug::%s,if=ide,cache=writeback,format=raw",
tmp_path);
dev = get_pci_device(&bmdma_bar, &ide_bar);
qtest_irq_intercept_in(global_qtest, "ioapic");
make_dirty(0);
g_free(hmp("qemu-io ide0-hd0 \"break flush_to_os A\""));
qpci_io_writeb(dev, ide_bar, reg_device, 0);
qpci_io_writeb(dev, ide_bar, reg_command, CMD_FLUSH_CACHE);
data = qpci_io_readb(dev, ide_bar, reg_status);
assert_bit_set(data, BSY | DRDY);
assert_bit_clear(data, DF | ERR | DRQ);
g_free(hmp("qemu-io ide0-hd0 \"resume A\""));
data = qpci_io_readb(dev, ide_bar, reg_device);
g_assert_cmpint(data & DEV, ==, 0);
do {
data = qpci_io_readb(dev, ide_bar, reg_status);
} while (data & BSY);
assert_bit_set(data, DRDY);
assert_bit_clear(data, BSY | DF | ERR | DRQ);
ide_test_quit();
}
| 1threat
|
Integrate row information with previous rows sql : Hi I need to integrate row information with previous rows
---------------------------------------------
| ID | no| number |
-----------------------------------------
| 1 | 40| 10 |
| 2 | 32| 12 |
| 3 | 40| 15 |
| 4 | 45| 23 |
| 5 | 32| 15 |
| 6 | 12| 14
| 7 | 40| 20
| 8 | 32| 18
| 9 | 45| 27
| 10 | 12| 16
------------------------------
result
---------------------------------------------
| ID | no| number |last number
-----------------------------------------
| 1 | 40| 10 |0
| 3 | 32| 12 |0
| 3 | 40| 15 |0
| 4 | 45| 23 |0
| 5 | 32| 15 |12
| 6 | 12| 14 |0
| 7 | 40| 20 |15
| 8 | 32| 18 |15
| 9 | 45| 27 |23
| 10 | 12| 16 |14
------------------------------
thanks for your help..
| 0debug
|
static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size,
AVPacket *avpkt)
{
struct LATMContext *latmctx = avctx->priv_data;
int muxlength, err;
GetBitContext gb;
if (avpkt->size == 0)
return 0;
init_get_bits(&gb, avpkt->data, avpkt->size * 8);
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
return AVERROR_INVALIDDATA;
muxlength = get_bits(&gb, 13) + 3;
if (muxlength > avpkt->size)
return AVERROR_INVALIDDATA;
if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
return err;
if (!latmctx->initialized) {
if (!avctx->extradata) {
*out_size = 0;
return avpkt->size;
} else {
if ((err = aac_decode_init(avctx)) < 0)
return err;
latmctx->initialized = 1;
}
}
if (show_bits(&gb, 12) == 0xfff) {
av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
"ADTS header detected, probably as result of configuration "
"misparsing\n");
return AVERROR_INVALIDDATA;
}
if ((err = aac_decode_frame_int(avctx, out, out_size, &gb)) < 0)
return err;
return muxlength;
}
| 1threat
|
Is there elseIf in Angular 4 : <p>I have a number of statements</p>
<pre><code><ng-template [ngIf]="xyz== 1">First</ng-template>
<ng-template [ngIf]="pqr == 2">Second</ng-template>
<ng-template [ngIf]="abc == 3">Third</ng-template>
</code></pre>
<p>Multiple conditions in above statement can be true.</p>
<p>But what i want is, first check for first statement if true then display and leave the rest</p>
<p>If false, then check for second and so on</p>
<p>how to achieve this?</p>
| 0debug
|
How to get Id of selected value in Mat-Select Option in Angular 5 : <p>How to get the id of selected option value in mat-select angular 5. Get only value of selected option in onchangeevent. but how can get id of selected option value.</p>
<pre><code> client.component.html
<mat-form-field>
<mat-select placeholder="Client*" #clientValue (change)="changeClient($event)">
<mat-option *ngFor="let client of clientDetails" [value]="client.clientName">
{{client.clientName | json}}
</mat-option>
</mat-select>
</mat-form-field>
client.component.ts file
export class Client{
changeClient(event){
console.log(event);
}
}
</code></pre>
| 0debug
|
static int no_run_out (HWVoiceOut *hw, int live)
{
NoVoiceOut *no = (NoVoiceOut *) hw;
int decr, samples;
int64_t now;
int64_t ticks;
int64_t bytes;
now = qemu_get_clock (vm_clock);
ticks = now - no->old_ticks;
bytes = muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ());
bytes = audio_MIN (bytes, INT_MAX);
samples = bytes >> hw->info.shift;
no->old_ticks = now;
decr = audio_MIN (live, samples);
hw->rpos = (hw->rpos + decr) % hw->samples;
return decr;
}
| 1threat
|
In Express.js why does code after res.json() still execute? : <p>In Node with Express, I have a piece of code like this. </p>
<pre><code> if (req.body.var1 >= req.body.var2){
res.json({success: false, message: "End time must be AFTER start time"});
console.log('Hi')
}
console.log('Hi2')
//other codes
</code></pre>
<p>I expected that if var1 is >= var2, the response would be sent and the execution would end. Like return statements in Java/C#</p>
<p>But appearantly that's not the case. After the response is sent, both 'Hi' and 'Hi2' and all the other code after that continues to get executed.</p>
<p>I was wondering how I would stop this from happening? </p>
<p>Also, I was wondering under what circumstances would you actually want code to keep on executing after a response has already been sent.</p>
<p>Cheers</p>
| 0debug
|
How does one ignore extra arguments passed to a data class? : <p>I'd like to create a <code>config</code> <code>dataclass</code> in order to simplify whitelisting of and access to specific environment variables (typing <code>os.environ['VAR_NAME']</code> is tedious relative to <code>config.VAR_NAME</code>). I therefore need to ignore unused environment variables in my <code>dataclass</code>'s <code>__init__</code> function, but I don't know how to extract the default <code>__init__</code> in order to wrap it with, e.g., a function that also includes <code>*_</code> as one of the arguments.</p>
<pre><code>import os
from dataclasses import dataclass
@dataclass
class Config:
VAR_NAME_1: str
VAR_NAME_2: str
config = Config(**os.environ)
</code></pre>
<p>Running this gives me <code>TypeError: __init__() got an unexpected keyword argument 'SOME_DEFAULT_ENV_VAR'</code>.</p>
| 0debug
|
Project Euler task #8, code starts returning wrong answers after certain point : <p>I am having some sort of a problem in a task from
<a href="https://projecteuler.net/problem=8" rel="nofollow">https://projecteuler.net/problem=8</a>, (finding highest product of 13 consecutive numbers from a 1000-number string) where up to some point the program gives me predictable results and then the function returns a number very close to the <strong><em>unsigned long long int</em></strong> range. The point where it occurs depends on the values which were read, for instance if the string of numbers consisted mostly of 8s and 9s, it would happen sooner than it would if it had only 5s and 6s. Why does it happen?</p>
<pre><code>#include <iostream>
#include <fstream>
using namespace std;
int product (int res, int a, char buffer[]){
for (int i = 0; i < a; i++){
//simple char to int conversion
res*=(buffer[i] - '0');
}
return res;
}
int main () {
char check;
int res = 1;
fstream plik;
plik.open ("8.txt");
unsigned long long int high;
unsigned long long int result;
//main function in the program
if (plik.good()){
char buffer [13];
for (int i = 0; i < 13; i++){
plik >> buffer[i];
}
result = product (res, 13, buffer);
high = result;
cout << high << endl;
//the main checking loop
while (!plik.eof()){
//just an interruption to make it possible to view consecutive products
//the iteration in the buffer
for (int i = 0; i < 12; i++){
buffer[i] = buffer[i+1];
}
plik >> buffer[12];
result = product (res, 13, buffer);
//comparison between the current product and highest one
if (high < result){
high = result;
}
cin >> check;
cout << high << endl;
//again a tool for checking where the problem arises
for (int i = 0; i < 13; i++){
cout << buffer[i] << " ";
}
cout << endl;
}
plik.close();
cout << high << endl;
}
return 0;
}
</code></pre>
<p>The program prints out the currently highest product and all the numbers currently contained in the array.
It looks like this:
<a href="http://i.stack.imgur.com/E9FaK.png" rel="nofollow">The error</a></p>
| 0debug
|
static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
const uint8_t *src, int src_size)
{
int width, height;
int hdr, zsize, npal, tidx = -1, ret;
int i, j;
const uint8_t *src_end = src + src_size;
uint8_t pal[768], transp[3];
uLongf dlen = (c->tile_width + 1) * c->tile_height;
int sub_type;
int nblocks, cblocks, bstride;
int bits, bitbuf, coded;
uint8_t *dst = c->framebuf + tile_x * c->tile_width * 3 +
tile_y * c->tile_height * c->framebuf_stride;
if (src_size < 2)
return AVERROR_INVALIDDATA;
width = FFMIN(c->width - tile_x * c->tile_width, c->tile_width);
height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
hdr = *src++;
sub_type = hdr >> 5;
if (sub_type == 0) {
int j;
memcpy(transp, src, 3);
src += 3;
for (j = 0; j < height; j++, dst += c->framebuf_stride)
for (i = 0; i < width; i++)
memcpy(dst + i * 3, transp, 3);
return 0;
} else if (sub_type == 1) {
return jpg_decode_data(&c->jc, width, height, src, src_end - src,
dst, c->framebuf_stride, NULL, 0, 0, 0);
}
if (sub_type != 2) {
memcpy(transp, src, 3);
src += 3;
}
npal = *src++ + 1;
memcpy(pal, src, npal * 3); src += npal * 3;
if (sub_type != 2) {
for (i = 0; i < npal; i++) {
if (!memcmp(pal + i * 3, transp, 3)) {
tidx = i;
break;
}
}
}
if (src_end - src < 2)
return 0;
zsize = (src[0] << 8) | src[1]; src += 2;
if (src_end - src < zsize)
return AVERROR_INVALIDDATA;
ret = uncompress(c->kempf_buf, &dlen, src, zsize);
if (ret)
return AVERROR_INVALIDDATA;
src += zsize;
if (sub_type == 2) {
kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
NULL, 0, width, height, pal, npal, tidx);
return 0;
}
nblocks = *src++ + 1;
cblocks = 0;
bstride = FFALIGN(width, 16) >> 4;
bits = 0;
for (i = 0; i < (FFALIGN(height, 16) >> 4); i++) {
for (j = 0; j < (FFALIGN(width, 16) >> 4); j++) {
if (!bits) {
bitbuf = *src++;
bits = 8;
}
coded = bitbuf & 1;
bits--;
bitbuf >>= 1;
cblocks += coded;
if (cblocks > nblocks)
return AVERROR_INVALIDDATA;
c->kempf_flags[j + i * bstride] = coded;
}
}
memset(c->jpeg_tile, 0, c->tile_stride * height);
jpg_decode_data(&c->jc, width, height, src, src_end - src,
c->jpeg_tile, c->tile_stride,
c->kempf_flags, bstride, nblocks, 0);
kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
c->jpeg_tile, c->tile_stride,
width, height, pal, npal, tidx);
return 0;
}
| 1threat
|
give id in decimal sql : I have a table name content_details and want to print id in decimal like this:
<pre>id contents
1.1 vegetarian
1.2 non-vegetarian</pre>
I have used this query to <pre>
`ALTER TABLE content_details
ADD COLUMN id decimal(4,2)`
then used this to save data in column <br>
`ALTER TABLE content_details
ADD id_sub = 1.1000
WHERE contents_details= 'vegetarian'`
But getting error
| 0debug
|
How two flask app accessing same database : <p>I am going to build two flask REST API accessing same database.
Both 2 app have access to same table. For example I have Order table. Should i create OrderModel class on both of that 2 app or just one of them?</p>
<p>Thanks.</p>
| 0debug
|
Navigableset vs Navigablemap : <p>I am new to JAVA and i am really confused about the difference between the two data structures navigableset and navigablemap in terms of both structure and implementation.
Where should we use each of them?</p>
| 0debug
|
How to restrict recycler row in UI in android : When recycler view is shown I need to show only first 4 list from array list. how to restrict recycler view row in android?
Any help is appreciated
| 0debug
|
Close a windows form but it still running in the task bar : <p>I am trying to close a winform "Splash Screen" and running another form.</p>
<pre><code>private void timer1_Tick(object sender, EventArgs e)
{
rectangleShape2.Width += 5;
if (rectangleShape2.Width >= 473)
{
timer1.Stop();
HomeScreen H = new HomeScreen();
H.ShowDialog();
//to close current form
this.Close();
}
}
</code></pre>
<p>The problem is that: the Splash Screen form still working in the task bar<br>
how can i close it and hide it from the task bar? </p>
<p>Thanks.</p>
| 0debug
|
static int dash_init(AVFormatContext *s)
{
DASHContext *c = s->priv_data;
int ret = 0, i;
char *ptr;
char basename[1024];
if (c->single_file_name)
c->single_file = 1;
if (c->single_file)
c->use_template = 0;
av_strlcpy(c->dirname, s->filename, sizeof(c->dirname));
ptr = strrchr(c->dirname, '/');
if (ptr) {
av_strlcpy(basename, &ptr[1], sizeof(basename));
ptr[1] = '\0';
} else {
c->dirname[0] = '\0';
av_strlcpy(basename, s->filename, sizeof(basename));
}
ptr = strrchr(basename, '.');
if (ptr)
*ptr = '\0';
c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams);
if (!c->streams)
return AVERROR(ENOMEM);
if ((ret = parse_adaptation_sets(s)) < 0)
return ret;
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
AdaptationSet *as = &c->as[os->as_idx - 1];
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
char filename[1024];
os->bit_rate = s->streams[i]->codecpar->bit_rate;
if (os->bit_rate) {
snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
" bandwidth=\"%d\"", os->bit_rate);
} else {
int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
AV_LOG_ERROR : AV_LOG_WARNING;
av_log(s, level, "No bit rate set for stream %d\n", i);
if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
return AVERROR(EINVAL);
}
dict_copy_entry(&as->metadata, s->streams[i]->metadata, "language");
dict_copy_entry(&as->metadata, s->streams[i]->metadata, "role");
ctx = avformat_alloc_context();
if (!ctx)
return AVERROR(ENOMEM);
if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
s->streams[i]->codecpar->codec_id == AV_CODEC_ID_VP9 ||
s->streams[i]->codecpar->codec_id == AV_CODEC_ID_OPUS ||
s->streams[i]->codecpar->codec_id == AV_CODEC_ID_VORBIS) {
snprintf(os->format_name, sizeof(os->format_name), "webm");
} else {
snprintf(os->format_name, sizeof(os->format_name), "mp4");
}
ctx->oformat = av_guess_format(os->format_name, NULL, NULL);
if (!ctx->oformat)
return AVERROR_MUXER_NOT_FOUND;
os->ctx = ctx;
ctx->interrupt_callback = s->interrupt_callback;
ctx->opaque = s->opaque;
ctx->io_close = s->io_close;
ctx->io_open = s->io_open;
if (!(st = avformat_new_stream(ctx, NULL)))
return AVERROR(ENOMEM);
avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
st->time_base = s->streams[i]->time_base;
st->avg_frame_rate = s->streams[i]->avg_frame_rate;
ctx->avoid_negative_ts = s->avoid_negative_ts;
ctx->flags = s->flags;
if ((ret = avio_open_dyn_buf(&ctx->pb)) < 0)
return ret;
if (c->single_file) {
if (c->single_file_name)
ff_dash_fill_tmpl_params(os->initfile, sizeof(os->initfile), c->single_file_name, i, 0, os->bit_rate, 0);
else
snprintf(os->initfile, sizeof(os->initfile), "%s-stream%d.m4s", basename, i);
} else {
ff_dash_fill_tmpl_params(os->initfile, sizeof(os->initfile), c->init_seg_name, i, 0, os->bit_rate, 0);
}
snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
ret = s->io_open(s, &os->out, filename, AVIO_FLAG_WRITE, NULL);
if (ret < 0)
return ret;
os->init_start_pos = 0;
if (!strcmp(os->format_name, "mp4")) {
av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
} else {
av_dict_set_int(&opts, "cluster_time_limit", c->min_seg_duration / 1000, 0);
av_dict_set_int(&opts, "cluster_size_limit", 5 * 1024 * 1024, 0);
av_dict_set_int(&opts, "dash", 1, 0);
av_dict_set_int(&opts, "dash_track_number", i + 1, 0);
av_dict_set_int(&opts, "live", 1, 0);
}
if ((ret = avformat_init_output(ctx, &opts)) < 0)
return ret;
os->ctx_inited = 1;
avio_flush(ctx->pb);
av_dict_free(&opts);
av_log(s, AV_LOG_VERBOSE, "Representation %d init segment will be written to: %s\n", i, filename);
if (strcmp(os->format_name, "mp4")) {
flush_init_segment(s, os);
}
s->streams[i]->time_base = st->time_base;
s->avoid_negative_ts = ctx->avoid_negative_ts;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
AVRational avg_frame_rate = s->streams[i]->avg_frame_rate;
if (avg_frame_rate.num > 0) {
if (av_cmp_q(avg_frame_rate, as->min_frame_rate) < 0)
as->min_frame_rate = avg_frame_rate;
if (av_cmp_q(as->max_frame_rate, avg_frame_rate) < 0)
as->max_frame_rate = avg_frame_rate;
} else {
as->ambiguous_frame_rate = 1;
}
c->has_video = 1;
}
set_codec_str(s, st->codecpar, os->codec_str, sizeof(os->codec_str));
os->first_pts = AV_NOPTS_VALUE;
os->max_pts = AV_NOPTS_VALUE;
os->last_dts = AV_NOPTS_VALUE;
os->segment_index = 1;
}
if (!c->has_video && c->min_seg_duration <= 0) {
av_log(s, AV_LOG_WARNING, "no video stream and no min seg duration set\n");
return AVERROR(EINVAL);
}
return 0;
}
| 1threat
|
How to force `.andExpect(jsonPath()` to return Long/long instead int for int number for jackson parser : <p>I have a simple test to my RestController. I expect that <code>$[1].parent_id</code>returns Long as an object and not integer primitive. It will return Long if <code>parent_id</code> is in a long number range and > integer number range (such as : 2147483650L).</p>
<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@WebAppConfiguration
public class TransactionServiceControllerTest {
@Before
public void setup() throws Exception {
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
// I copy this from my RestController class
this.transactions = Arrays.asList(
new Transaction(100d, "car", null),
new Transaction(100d, "table", 12L)
);
}
@Test
public void readSingleBookmark() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/transaction/"))
.andExpect(content().contentType(contentType)) // ok
.andExpect(jsonPath("$", hasSize(2))) // ok
//omitted
andExpect(jsonPath("$[1].parent_id",is(this.transactions.get(1).getParentId())));
} //assertion fail
Expected: is <12L>
but: was <12>
</code></pre>
<p>Result from another test :</p>
<pre><code>Expected: is <12L>
but: was <2147483650L> //return Long instead int
</code></pre>
<p>this is my JacksonConfiguration</p>
<pre><code>@Configuration
public class JacksonConfiguration {
@Bean
@Primary
public ObjectMapper objectMapper() {
final ObjectMapper objectMapper = new ObjectMapper();
//supposed to be this is the magic trick but it seems not..
objectMapper.enable(DeserializationFeature.USE_LONG_FOR_INTS);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
return objectMapper;
}
}
</code></pre>
<p>And my POJO</p>
<pre><code>public class Transaction {
private double ammount;
private String type;
private Long parentId;
public Transaction(Double ammount, String type, Long parentId) {
//omitted
}
//setter and getter omitted
}
</code></pre>
<p>MyRestController</p>
<pre><code>@RestController
@RequestMapping("transaction")
public class TransactionServiceController {
@RequestMapping(method = RequestMethod.GET)
List<Transaction> getTransaction() {
return
Arrays.asList(
new Transaction(100d, "car", null),
new Transaction(100d, "table", 12L)
);
}
}
</code></pre>
<p>And Application.java</p>
<pre><code>@SpringBootApplication
public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class,args);
}
}
</code></pre>
| 0debug
|
int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence)
{
if (whence == SEEK_SET) {
} else if (whence == SEEK_CUR) {
pos += qemu_ftell(f);
} else {
return -1;
}
if (f->is_writable) {
qemu_fflush(f);
f->buf_offset = pos;
} else {
f->buf_offset = pos;
f->buf_index = 0;
f->buf_size = 0;
}
return pos;
}
| 1threat
|
static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
PCIDevice *d = (PCIDevice *)dev;
const pci_class_desc *desc;
char ctxt[64];
PCIIORegion *r;
int i, class;
class = pci_get_word(d->config + PCI_CLASS_DEVICE);
desc = pci_class_descriptions;
while (desc->desc && class != desc->class)
desc++;
if (desc->desc) {
snprintf(ctxt, sizeof(ctxt), "%s", desc->desc);
} else {
snprintf(ctxt, sizeof(ctxt), "Class %04x", class);
}
monitor_printf(mon, "%*sclass %s, addr %02x:%02x.%x, "
"pci id %04x:%04x (sub %04x:%04x)\n",
indent, "", ctxt, pci_bus_num(d->bus),
PCI_SLOT(d->devfn), PCI_FUNC(d->devfn),
pci_get_word(d->config + PCI_VENDOR_ID),
pci_get_word(d->config + PCI_DEVICE_ID),
pci_get_word(d->config + PCI_SUBSYSTEM_VENDOR_ID),
pci_get_word(d->config + PCI_SUBSYSTEM_ID));
for (i = 0; i < PCI_NUM_REGIONS; i++) {
r = &d->io_regions[i];
if (!r->size)
continue;
monitor_printf(mon, "%*sbar %d: %s at 0x%"FMT_PCIBUS
" [0x%"FMT_PCIBUS"]\n",
indent, "",
i, r->type & PCI_BASE_ADDRESS_SPACE_IO ? "i/o" : "mem",
r->addr, r->addr + r->size - 1);
}
}
| 1threat
|
What are some good learning resources? : <p>I was wondering if there where any good resources like books or programs for learning how to code. I've been trying to learn by watching tutorials but I end up just fallowing the instructions without really knowing how and why things go together the way they do. So I get lost when trying to make my own projects. </p>
<p>I was wondering what are the recommended resources? preferably with plenty of exercises so I could get a lot of practice.</p>
<p>Thank you!</p>
| 0debug
|
I've got no idea what this specific part means : I've got this code and i've got the answer for it as well, but I don't understand how they come out like that, specifically what does (x+" "+y) part means as well as the changeUs(x, y), can anyone explain?
public class ChangeParam {
public static void main(String[] args) {
int x = 1;
double y = 3.4;
System.out.println(x+" "+y);
changeUs(x, y);
System.out.println(x+" "+y);
}
public static void changeUs(int x, double y) {
x = 0;
y = 0.0;
System.out.println(x +" "+y);
}
}
the answers are:
1 3.4
0 0.0
1 3.4
| 0debug
|
hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address, int rw)
{
hwaddr physical;
int prot;
int access_type;
int ret = 0;
access_type = ACCESS_INT;
ret = get_physical_address(env, &physical, &prot,
address, rw, access_type);
if (ret != TLBRET_MATCH) {
raise_mmu_exception(env, address, rw, ret);
return -1LL;
} else {
return physical;
}
}
| 1threat
|
C program to find sum of odd elements of matrix : What is the c program to find the sum of the odd elements of the matrix of m*n order? Please, reply fast.
kind regards,
Kabita
| 0debug
|
import sys
def find_closet(A, B, C, p, q, r):
diff = sys.maxsize
res_i = 0
res_j = 0
res_k = 0
i = 0
j = 0
k = 0
while(i < p and j < q and k < r):
minimum = min(A[i], min(B[j], C[k]))
maximum = max(A[i], max(B[j], C[k]));
if maximum-minimum < diff:
res_i = i
res_j = j
res_k = k
diff = maximum - minimum;
if diff == 0:
break
if A[i] == minimum:
i = i+1
elif B[j] == minimum:
j = j+1
else:
k = k+1
return A[res_i],B[res_j],C[res_k]
| 0debug
|
Check Ansible version from inside of a playbook : <p>I have a playbook that is running in different way in Ansible 1.9.x and 2.0. I would like to check currently running ansible version in my playbook to avoid someone running it with old one. </p>
<p>I don't think that this is the best solution: </p>
<pre><code>- local_action: command ansible --version
register: version
</code></pre>
<p>What would you suggest?</p>
| 0debug
|
How-to migrate Wpf projects to the new VS2017 format : <p>I'm migrating my projects to the new visual studio 2017 format which is working nicely for all standard libraries only now I run into problems with my UI libraries where I use Wpf / Xaml.</p>
<p>I cannot figure out howto do this for my user controls. The old item doesn't seem to be valid anymore.</p>
<p>Anybody has an idea howto do this or if it's even possible.</p>
| 0debug
|
What is the java equivalent for Perl's require command? : <p>I am completely new to cgi concepts.</p>
<p>I'm given a task to convert a Perl cgi script to Java program.</p>
<p>I understood that the <code>require 'file.ext'</code> command in Perl includes the file available for code in the Perl script.</p>
<p>Because of the very limited resources and improper documentation I couldn't find any proper info.</p>
<p>Is there any Java equivalent to do the same action that <code>require</code> in Perl does?</p>
| 0debug
|
Java , to change the iso date format to required format : <p>I need to convert the current ISO Date to the required format . How ?
Mongodb iso date: 2016-08-31T08:30:17.795Z</p>
<p>required format type: Aug 31,2016 08:30 AM</p>
| 0debug
|
static void clipper_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
AlphaCPU *cpus[4];
PCIBus *pci_bus;
ISABus *isa_bus;
qemu_irq rtc_irq;
long size, i;
char *palcode_filename;
uint64_t palcode_entry, palcode_low, palcode_high;
uint64_t kernel_entry, kernel_low, kernel_high;
memset(cpus, 0, sizeof(cpus));
for (i = 0; i < smp_cpus; ++i) {
cpus[i] = cpu_alpha_init(cpu_model ? cpu_model : "ev67");
}
cpus[0]->env.trap_arg0 = ram_size;
cpus[0]->env.trap_arg1 = 0;
cpus[0]->env.trap_arg2 = smp_cpus;
pci_bus = typhoon_init(ram_size, &isa_bus, &rtc_irq, cpus,
clipper_pci_map_irq);
rtc_init(isa_bus, 1900, rtc_irq);
pit_init(isa_bus, 0x40, 0, NULL);
isa_create_simple(isa_bus, "i8042");
pci_vga_init(pci_bus);
serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], pci_bus, "e1000", NULL);
}
{
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
ide_drive_get(hd, ARRAY_SIZE(hd));
pci_cmd646_ide_init(pci_bus, hd, 0);
}
palcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
bios_name ? bios_name : "palcode-clipper");
if (palcode_filename == NULL) {
error_report("no palcode provided");
exit(1);
}
size = load_elf(palcode_filename, cpu_alpha_superpage_to_phys,
NULL, &palcode_entry, &palcode_low, &palcode_high,
0, EM_ALPHA, 0, 0);
if (size < 0) {
error_report("could not load palcode '%s'", palcode_filename);
exit(1);
}
g_free(palcode_filename);
for (i = 0; i < smp_cpus; ++i) {
cpus[i]->env.pc = palcode_entry;
cpus[i]->env.palbr = palcode_entry;
}
if (kernel_filename) {
uint64_t param_offset;
size = load_elf(kernel_filename, cpu_alpha_superpage_to_phys,
NULL, &kernel_entry, &kernel_low, &kernel_high,
0, EM_ALPHA, 0, 0);
if (size < 0) {
error_report("could not load kernel '%s'", kernel_filename);
exit(1);
}
cpus[0]->env.trap_arg1 = kernel_entry;
param_offset = kernel_low - 0x6000;
if (kernel_cmdline) {
pstrcpy_targphys("cmdline", param_offset, 0x100, kernel_cmdline);
}
if (initrd_filename) {
long initrd_base, initrd_size;
initrd_size = get_image_size(initrd_filename);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
initrd_filename);
exit(1);
}
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
address_space_stq(&address_space_memory, param_offset + 0x100,
initrd_base + 0xfffffc0000000000ULL,
MEMTXATTRS_UNSPECIFIED,
NULL);
address_space_stq(&address_space_memory, param_offset + 0x108,
initrd_size, MEMTXATTRS_UNSPECIFIED, NULL);
}
}
}
| 1threat
|
static void set_palette(AVFrame * frame, const uint8_t * palette_buffer)
{
uint32_t * palette = (uint32_t *)frame->data[1];
int a;
for(a = 0; a < 256; a++){
palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;
}
frame->palette_has_changed = 1;
}
| 1threat
|
void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
for(i=0;i<8;i++) {
pixels[0] = cm[pixels[0] + block[0]];
pixels[1] = cm[pixels[1] + block[1]];
pixels[2] = cm[pixels[2] + block[2]];
pixels[3] = cm[pixels[3] + block[3]];
pixels[4] = cm[pixels[4] + block[4]];
pixels[5] = cm[pixels[5] + block[5]];
pixels[6] = cm[pixels[6] + block[6]];
pixels[7] = cm[pixels[7] + block[7]];
pixels += line_size;
block += 8;
}
}
| 1threat
|
android sqlite qury is'nt execute . it is gona crash on button click : application launch successfully but on button click it crash
in CustomListView behinde imagebutton this is code
**this code form listView Custom adapter**
holder.submitAttendance.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String Lt,teacherName,status = null,startTime,endTime;
if(holder.radioButtonPresent.isChecked())
{
status=holder.radioButtonPresent.getText().toString();
}
else if(holder.radioButtonAbsent.isChecked())
{
status=holder.radioButtonAbsent.getText().toString();
}
startTime=holder.etxtStart_time_Picker.getText().toString();
endTime=holder.etxtEnd_time_Picker.getText().toString();
Lt=holder.txtlt.getText().toString();
teacherName=holder.txtteacher.getText().toString();
dataBaseHelper1.insertData(Lt,teacherName,status,startTime,endTime);
}
});
**this form sqlite database helper class**
public class DataBaseHelper extends SQLiteOpenHelper
{
public static String DATABASE_NAME = "Teacher.db";
public static String TABLE_NAME = "Teacher_Table";
public static String Col_1_LT = "LT";
public static String Col_2_TName = "Teacher_Name";
public static String Col_3_Status = "Status";
public static String Col_4_StartTime = "StartTime";
public static String Col_5_EndTime = "EndTime";
public DataBaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
String qury="create table" + TABLE_NAME +"( LT TEXT PRIMARY
KEY,Teacher_Name TEXT, Status TEXT, StartTime TEXT, EndTime TEXT)";
db.execSQL(qury);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
ContentValues contentValues = new ContentValues();
public boolean insertData(String Lt, String TeacherName, String Status,String StartTime, String EndTime)
{
SQLiteDatabase db = this.getWritableDatabase();
contentValues.put(Col_1_LT, Lt);
contentValues.put(Col_2_TName, TeacherName);
contentValues.put(Col_3_Status, Status);
contentValues.put(Col_4_StartTime, StartTime);
contentValues.put(Col_5_EndTime, EndTime);
long result = db.insert(TABLE_NAME, null, contentValues);
db.close();
//to check whether Data is Inserted in Database
if (result == -1) {
{
return false;
}
} else
{
return true;
}
}}
| 0debug
|
static void slow_bar_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
AssignedDevRegion *d = opaque;
uint8_t *out = d->u.r_virtbase + addr;
DEBUG("slow_bar_writeb addr=0x" TARGET_FMT_plx " val=0x%02x\n", addr, val);
*out = val;
}
| 1threat
|
Problems with mount cifs : <p>It is a couple of days I'm struggling in mounting a samba shared directory in Ubuntu 16. I read all the relative posts but still cannot find a solution.</p>
<p>Here is the command I use:</p>
<pre><code>e sudo mount -vt cifs -o username=sdea,sec=ntlmssp,vers=1.0 //130.226.50.5/sdea/ /home/sdea/jess
</code></pre>
<p>and the error i get:</p>
<pre><code>mount.cifs kernel mount options: ip=130.226.50.5,unc=\\130.226.50.5\sdea,sec=ntlmssp,vers=1.0,user=sdea,pass=********
</code></pre>
<p>mount error(13): Permission denied</p>
<p>I can mount this directory on my Mac and on Ubuntu 14 (on another machine), without any sort of problem. So, I'm sure my credentials are right. I also tried to include different "sec" options like sec=nltm,nltmv2 etc.. but nothing. I always get permission denied. </p>
<p>The version of the cifs-utils installed is 6.3, the linux kernel is 4.13.0-26-generic. I don't have sudo privileges on the server, but the configuration should be right since I can mount the share on different machines. </p>
<p>Do some of you have some clue on what the problem could be?</p>
| 0debug
|
Using git with ssh-agent on Windows : <p>I'm on Windows. I installed git and posh-git (some helpers for Windows PowerShell). I can add keys with <code>ssh-add</code> and can authenticate with github and my webserver. I can also use git from the PowerShell to interact with my repositories.</p>
<p>But there is one thing I can't do: I use git-plus for the Atom editor. And I don't get it to push to my repo. What is my problem?</p>
| 0debug
|
How do I inject a html template into a div using JavaScript : <p>How do I inject a html template into a div using JavaScript only and not jquery</p>
| 0debug
|
How to merge data sets of unequal size : <p>I have 4 data sets that aren't the same size. The datasets of some overlapping data that I want to merge into the same column but each dataset also has some unique data that I was to keep as well. Maybe it will make a bit more sense with an example. </p>
<pre><code>Glucose Fructose Ox_Phos
CACNA1I PIK3CA FYN
PLCB2 FGFR1 ITGA2B
CACNG1 PIK3R1 PIK3CA
CACNA2D2 PIK3C2G PIK3R1
MAP3K11 PIK3R5 PIK3R5
TCA Ox_Phos Sucrose ATP
GYG1 FYN MAP3k11 CACNA1I
NA ITGA2B CACNA2D2 ITGA2B
NA FGFR1 PIK3R5 NA
NA NA CACNG1 NA
Fructose Galactose
PIK3CA CACNG1
FGFR1 NA
PIK3R1 NA
PIK3C2G NA
PIK3R5 NA
ADP
PIK3CA
CACNG1
PIK3C2G
NA
NA
</code></pre>
<p>So as I said before, I am trying to merge these 4 data sets into one set of data. I want to merge columns with similar colnames but then also have the unique columns become a new column.. if that makes sense? Here is what I hope the data will look like. </p>
<pre><code>Glucose Fructose Ox_Phos ADP TCA Sucrose ATP Galactose
CACNA1I PIK3CA FYN PIK3CA GYG1 MAP3k11 CACNA1I CACNG2
PLCB2 FGFR1 ITGA2B CACNG1 FYN CACNA2D2 ITGA2B NA
CACNG1 PIK3R1 PIK3CA PIK3C2G NA PIK3R5 NA NA
CACNA2D2 PIK3C2G PIK3R1 NA NA CACNG1 NA NA
MAP3K11 PIK3R5 PIK3R5 NA NA NA NA NA
NA NA MAP3k11 NA NA NA NA NA
NA NA CACNA1I NA NA NA NA NA
NA NA ITGA2B NA NA NA NA NA
NA NA FGFR1 NA NA NA NA NA
NA NA NA NA NA NA NA NA
NA PIK4CA NA NA NA NA NA NA
NA FGFR7 NA NA NA NA NA NA
NA PIK4R2 NA NA NA NA NA NA
NA PIK5C3G NA NA NA NA NA NA
NA PIK4R6 NA NA NA NA NA NA
</code></pre>
<p>I think this can be done easily with dplyr but I am just not sure how to keep the unique column. Thanks in advance. Any help would be amazing</p>
| 0debug
|
How to sumplify this json array? : {
"Questions": [{
"Question": "Which is the largest fresh water lake in Kerala?",
"CorrectAnswer": 2,
"Answers": [{
"Answer": "Vembanad Lake"
}, {
"Answer": "Pookode Lake"
}, {
"Answer": "Sasthamcotta Lake"
}, {
"Answer": "Vellayani Lake"
}]
}, {
"Question": "Chennara, the birth place of Mahakavi Vallathol is in:",
"CorrectAnswer": 1,
"Answers": [{
"Answer": "Thrissur District"
}, {
"Answer": "Malappuram District"
}, {
"Answer": "Palakkad District"
}, {
"Answer": "Alappuzha District"
}]
}]}
| 0debug
|
assign a default value to a variable and change into database : i have a method
getlisting(string url,int ID)
i am passing this parameter ID to another function in another class
Controller __cc = new Controller();
int Status = 1;
__cc.UpdatePaging(ID, Status);
i am passing this to update function and want to assign a default value of zero to ID and 1 to status and then return it and make changes in database,
public void UpdatePaging(int ID,int Status)
{
if (ID != null)
{
ID = 0;
}
else
{
ID = 0;
}
SqlCommand cmd = new SqlCommand("UPDATE Paging SET Status='1' WHERE ID = @ID", obj.openConnection());
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@Status", SqlDbType.Int).Value = 1;
cmd.Parameters.AddWithValue("@ID", SqlDbType.Int).Value = ID;
cmd.ExecuteNonQuery();
}
but i can't do it, is there something wrong with my code? or tell me how to assign a 0 value to int and update it in Database, whenever i get any value from getlisting method it should be assigned zero and update in DB any help?
| 0debug
|
In C#, when does Type.FullName return null? : <p>The <a href="https://msdn.microsoft.com/en-us/library/system.type.fullname(v=vs.110).aspx">MSDN for Type.FullName</a> says that this property return</p>
<blockquote>
<p><strong>null</strong> if the current instance represents a generic type parameter, an array type, pointer type, or <strong>byref</strong>type based on a type parameter, or a generic type that is not a generic type definition but contains unresolved type parameters.</p>
</blockquote>
<p>I count five cases, and I find each one more unclear than the last. Here is my attempt to construct examples of each case.</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication {
public static class Program {
public static void Main(string[] args) {
GenericTypeParameter();
ArrayType();
PointerType();
ByRefTypeBasedOnTypeParameter();
NongenericTypeDefinitionWithUnresolvedTypeParameters();
Console.ReadKey();
}
public static void GenericTypeParameter() {
var type = typeof(IEnumerable<>)
.GetGenericArguments()
.First();
PrintFullName("Generic type parameter", type);
}
public static void ArrayType() {
var type = typeof(object[]);
PrintFullName("Array type", type);
}
public static void PointerType() {
var type = typeof(int*);
PrintFullName("Pointer type", type);
}
public static void ByRefTypeBasedOnTypeParameter() {
var type = null;
PrintFullName("ByRef type based on type parameter", type);
}
private static void NongenericTypeDefinitionWithUnresolvedTypeParameters() {
var type = null;
PrintFullName("Nongeneric type definition with unresolved type parameters", type);
}
public static void PrintFullName(string name, Type type) {
Console.WriteLine(name + ":");
Console.WriteLine("--Name: " + type.Name);
Console.WriteLine("--FullName: " + (type.FullName ?? "null"));
Console.WriteLine();
}
}
}
</code></pre>
<p>Which has this output.</p>
<pre><code>Generic type parameter:
--Name: T
--FullName: null
Array type:
--Name: Object[]
--FullName: System.Object[]
Pointer type:
--Name: Int32*
--FullName: System.Int32*
ByRef type based on type parameter:
--Name: Program
--FullName: ConsoleApplication.Program
Nongeneric type definition with unresolved type parameters:
--Name: Program
--FullName: ConsoleApplication.Program
</code></pre>
<p>I am only one for five with two "blanks".</p>
<h2>Question</h2>
<blockquote>
<p>Can someone modify my code to give simple examples of each way in which Type.FullName can be null?</p>
</blockquote>
| 0debug
|
concatenation issue adding static string to dynamic string C# : In the following code 'Application1' is the static value,its working fine.
mailMsg.Headers.Add("X-SMTPAPI", "{ \"category\": [ \"Application1\" ] }");
but i want to replace 'Application1' with dynamic value.
So i implemented the follwoing code,here Dtls.Category is the dynamic value.
string xsmtpCategory = "{\"category\":\""+Dtls.Category +"\" ] }";
mailMsg.Headers.Add("X-SMTPAPI", xsmtpCategory);//im getting error here ,not in correct format
How can i use dynamic value in here instead of static value(Application1 is static value)
"{ \"category\": [ \"Application1\" ] }"
| 0debug
|
static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
ChardevStdio *stdio;
stdio = backend->u.stdio = g_new0(ChardevStdio, 1);
qemu_chr_parse_common(opts, qapi_ChardevStdio_base(stdio));
stdio->has_signal = true;
stdio->signal = qemu_opt_get_bool(opts, "signal", true);
}
| 1threat
|
void memory_region_init(MemoryRegion *mr,
const char *name,
uint64_t size)
{
mr->ops = NULL;
mr->parent = NULL;
mr->size = int128_make64(size);
if (size == UINT64_MAX) {
mr->size = int128_2_64();
}
mr->addr = 0;
mr->subpage = false;
mr->enabled = true;
mr->terminates = false;
mr->ram = false;
mr->romd_mode = true;
mr->readonly = false;
mr->rom_device = false;
mr->destructor = memory_region_destructor_none;
mr->priority = 0;
mr->may_overlap = false;
mr->alias = NULL;
QTAILQ_INIT(&mr->subregions);
memset(&mr->subregions_link, 0, sizeof mr->subregions_link);
QTAILQ_INIT(&mr->coalesced);
mr->name = g_strdup(name);
mr->dirty_log_mask = 0;
mr->ioeventfd_nb = 0;
mr->ioeventfds = NULL;
mr->flush_coalesced_mmio = false;
}
| 1threat
|
static void test_acpi_one(const char *params, test_data *data)
{
char *args;
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int i;
const char *device = "";
if (!g_strcmp0(data->machine, MACHINE_Q35)) {
device = ",id=hd -device ide-hd,drive=hd";
}
args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
params ? params : "", disk, device);
qtest_start(args);
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)
for (i = 0; i < TEST_CYCLES; ++i) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
test_acpi_rsdt_table(data);
test_acpi_fadt_table(data);
test_acpi_facs_table(data);
test_acpi_dsdt_table(data);
test_acpi_tables(data);
if (iasl) {
if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
dump_aml_files(data, true);
} else {
test_acpi_asl(data);
}
}
test_smbios_ep_address(data);
test_smbios_ep_table(data);
test_smbios_structs(data);
qtest_quit(global_qtest);
g_free(args);
}
| 1threat
|
void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
{
if (h&3)
ff_avg_dirac_pixels16_c(dst, src, stride, h);
else
ff_avg_pixels16_sse2(dst, src[0], stride, h);
}
| 1threat
|
void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
{
int64_t value;
if (!error_is_set(errp)) {
if (v->type_int32) {
v->type_int32(v, obj, name, errp);
} else {
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT32_MIN || value > INT32_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"int32_t");
return;
}
*obj = value;
}
}
}
| 1threat
|
static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in saddr;
int newfd;
socklen_t saddr_len;
NetClientState *nc;
NetSocketState *s;
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
if (saddr.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
newfd = net_socket_mcast_create(&saddr, NULL);
if (newfd < 0) {
goto err;
}
dup2(newfd, fd);
close(newfd);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
if (is_connected) {
s->dgram_dst = saddr;
}
return s;
err:
closesocket(fd);
return NULL;
}
| 1threat
|
Does lodash have a one-line method for calling a function if it exists? : <p>Given I have this code:</p>
<pre><code>if (_.isFunction(this.doSomething)) {
this.doSomething();
}
</code></pre>
<p>Whereby loadingComplete is a directive attribute passed in from a parent controller that may not always be provided, is there a cleaner one-line way to call the method if it exists, without repeating the method name?</p>
<p>Something like:</p>
<pre><code>_.call(this, 'doSomething');
</code></pre>
| 0debug
|
Close react native modal by clicking on overlay? : <p>Is it possible to close <a href="https://facebook.github.io/react-native/docs/modal.html#transparent" rel="noreferrer">react native modal</a> by clicking on overlay when <code>transparent</code> option is <code>true</code>? Documentation doesn't provide anything about it. Is it possible?</p>
| 0debug
|
void OPPROTO op_POWER_sraq (void)
{
env->spr[SPR_MQ] = rotl32(T0, 32 - (T1 & 0x1FUL));
if (T1 & 0x20UL)
T0 = -1L;
else
T0 = Ts0 >> T1;
RETURN();
}
| 1threat
|
How to Parse Nested Json Array to dataset : "Data": [
{
"Code": "DEMO",
"Name": "DEMO",
"UserId": "B27A68AD-7C21-4DDB-8A1D-8932459CF53B",
"RoleDetails": [{
"ViewId": "B27A68AD-7C21-4DDB-8A1D-8932459CF53B",
"IsAddAllowed": true,
"IsEditAllowed": true,
"IsDeleteAllowed": true
}],
"RoleDetails1":[ {
"ViewId": "B27A68AD-7C21-4DDB-8A1D-8932459CF53B",
"IsAddAllowed": true,
"IsEditAllowed": true,
"IsDeleteAllowed": true
}]
}
]
i have this Json Array i want to convert this to DataSet Having DataTable for Each Property in Json
| 0debug
|
Is there a way to have table name automatically added to Eloquent query methods? : <p>I'm developing an app on Laravel 5.5 and I'm facing an issue with a specific query scope. I have the following table structure (some fields omitted):</p>
<pre><code>orders
---------
id
parent_id
status
</code></pre>
<p>The <code>parent_id</code> column references the <code>id</code> from the same table. I have this query scope to filter records that don't have any children:</p>
<pre><code>public function scopeNoChildren(Builder $query): Builder
{
return $query->select('orders.*')
->leftJoin('orders AS children', function ($join) {
$join->on('orders.id', '=', 'children.parent_id')
->where('children.status', self::STATUS_COMPLETED);
})
->where('children.id', null);
}
</code></pre>
<p>This scope works fine when used alone. However, if I try to combine it with any another condition, it throws an SQL exception:</p>
<pre><code>Order::where('status', Order::STATUS_COMPLETED)
->noChildren()
->get();
</code></pre>
<p>Leads to this:</p>
<blockquote>
<p>SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous</p>
</blockquote>
<p>I found two ways to avoid that error:</p>
<h2>Solution #1: Prefix all other conditions with the table name</h2>
<p>Doing something like this works:</p>
<pre><code>Order::where('orders.status', Order::STATUS_COMPLETED)
->noChildren()
->get();
</code></pre>
<p>But I don't think this is a good approach since it's not clear the table name is required in case other dev or even myself try to use that scope again in the future. They'll probably end up figuring that out, but it doesn't seem a good practice.</p>
<h2>Solution #2: Use a subquery</h2>
<p>I can keep the ambiguous columns apart in a subquery. Still, in this case and as the table grows, the performance will degrade.</p>
<p>This is the strategy I'm using, though. Because it doesn't require any change to other scopes and conditions. At least not in the way I'm applying it right now.</p>
<pre><code>public function scopeNoChildren(Builder $query): Builder
{
$subQueryChildren = self::select('id', 'parent_id')
->completed();
$sqlChildren = DB::raw(sprintf(
'(%s) AS children',
$subQueryChildren->toSql()
));
return $query->select('orders.*')
->leftJoin($sqlChildren, function ($join) use ($subQueryChildren) {
$join->on('orders.id', '=', 'children.parent_id')
->addBinding($subQueryChildren->getBindings());
})->where('children.id', null);
}
</code></pre>
<h2>The perfect solution</h2>
<p>I think that having the ability to use queries without prefixing with table name without relying on subqueries would be the perfect solution.</p>
<p>That's why I'm asking: <strong>Is there a way to have table name automatically added to Eloquent query methods?</strong></p>
| 0debug
|
Windows Defender might be impacting your build performance : <p>After I updated my Pycharm IDE to 19.2.0 from the 19.1.2. I am getting the following warning:</p>
<pre><code>"Windows Defender might be impacting your build performance. PyCharm checked
thefollowing directories:
C:\Workspace\Projects\576_UniversityTwitter
C:\Users\Burak\.PyCharmCE2019.2\system
C:\Users\Burak\.gradle
</code></pre>
<p>Do you think that it is secure, necessary and really improve the performance?</p>
| 0debug
|
How can i search the public post in facebook ? which api i can used to filter the post? : **How can i search the public post in facebook ?which api i can used to filter the post?**
`$q = "Facebook";
$search = $fb->get('/search?q='.$q.'&type=user&limit=10');
$search = $search->getGraphEdge()->asArray();
echo "<pre>";
print_r($search);
echo "</pre>";`
i cant able to use the post in type attribute.Please help me.
| 0debug
|
Do stuffs inside a for in a thread android : @Override
public void run() {
act.runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < randomNumber.size(); i++) {
Log.d("N",randomNumber.get(i).toString());
if (randomNumber.get(i).intValue() == 1) imgColor.setBackgroundColor(Color.RED);
if (randomNumber.get(i).intValue() == 2) imgColor.setBackgroundColor(Color.GREEN);
if (randomNumber.get(i).intValue() == 3) imgColor.setBackgroundColor(Color.BLUE);
if (randomNumber.get(i).intValue() == 4) imgColor.setBackgroundColor(Color.YELLOW);
try {
Thread.sleep(1750);
} catch (Exception e) {
Thread.currentThread().interrupt();
}
imgColor.setBackgroundColor(Color.BLACK);
try {
Thread.sleep(400);
} catch (Exception e) {
Thread.currentThread().interrupt();
}
}
Toast.makeText(act, "Ripeti la sequenza", Toast.LENGTH_SHORT).show();
}
});
}
I'm trying to have imgColor ImageView colored each 1,75 second with a different color according to the value of the number in the randomColor ArrayList, but it doesn't work ! What should I do ?
Thanks in advance
| 0debug
|
VB.net Cannot access a disposed object on form close : I am trying to make some code for a game that has a grid and a tick counter but the grid just tries to fill the window instead of stopping and does not display the tick counter. The Error that keeps coming up is "A first chance exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll". I have no idea what this means and i don't know how to fix it please help.
Heres the code:
Public Class Form1
Dim G As Graphics
Dim BBG As Graphics
Dim BB As Bitmap
Dim r As Rectangle
Dim tSec As Integer = TimeOfDay.Second
Dim tTicks As Integer = 0
Dim MaxTicks As Integer = 0
Dim IsRunning As Boolean = True
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Show()
Me.Focus()
G = Me.CreateGraphics
BB = New Bitmap(Me.Width, Me.Height)
StartGameLoop()
End Sub
Private Sub DrawGraphics()
For X = 0 To 19
For Y = 0 To 14
r = New Rectangle(X * 32, Y * 32, 32, 32)
G.FillRectangle(Brushes.BurlyWood, r)
G.DrawRectangle(Pens.Black, r)
Next
Next
G.DrawString("Ticks: " & tTicks & vbCrLf & _
"TPS: " & MaxTicks, Me.Font, Brushes.Black, 650, 0)
G = Graphics.FromImage(BB)
BBG = Me.CreateGraphics
BBG.DrawImage(BB, 0, 0, Me.Width, Me.Height)
G.Clear(Color.Wheat)
End Sub
Private Sub StartGameLoop()
Do While IsRunning = True
Application.DoEvents()
DrawGraphics()
TickCounter()
Loop
End Sub
Private Sub TickCounter()
If tSec = TimeOfDay.Second And IsRunning = True Then
tTicks = tTicks + 1
Else
MaxTicks = tTicks
tTicks = 0
tSec = TimeOfDay.Second
End If
End Sub
End Class
| 0debug
|
How to use table name as parameter in storeprocedure : CREATE PROCEDURE twork
@wl_id_m int,
@wl_id_e int,
@wl_id_n int,
@tbl_name nvarchar(20),
@day_no nvarchar(10),
@day_month nvarchar(10),
@day_years nvarchar(10)
AS
BEGIN
declare @Work_Status nvarchar(20),
@tbl nvarchar(20)
DECLARE ENS_cursor cursor for
select wl_id
from [SKTH_ENS].[dbo].[tblWorkList]
where wl_id_m = @wl_id_m and wl_id_e = @wl_id_e and wl_id_n = @wl_id_n
OPEN ENS_cursor
FETCH NEXT FROM ENS_cursor
INTO @Work_Status
WHILE @@FETCH_STATUS = 0
BEGIN
update [SKTH_ENSUSER].[dbo].[tblP30006] --instead with @tbl_name
set t_work_status = @Work_Status
where t_day_no = @day_no and t_month_no = @day_month and t_year_no = @day_years
FETCH NEXT FROM ENS_cursor
INTO @Work_Status
END
CLOSE ENS_cursor
DEALLOCATE ENS_cursor
END
how to use parameter instead the table name?
| 0debug
|
How to set default parameters for a graphical device? : <p>I like to read white on black. So, in R I would do something along the lines of:</p>
<pre><code>par (bg = "black")
par (fg = "ivory1")
</code></pre>
<p>I would like these options to be set by default. However, one does not simply write these lines in <code>.Rprofile</code> because, as I understand, at the time it gets executed, the graphical device is not yet initialized. Rather, as suggested in <a href="https://stackoverflow.com/a/13480570/2108477">another answer</a>, one should re-assign <code>options()$device</code> to include the necessary option setting. I did not have success in that.</p>
<p> </p>
<p>This is what I tried:</p>
<p><em><code>~/.Rprofile</code></em></p>
<pre><code>f_device <- options()$device
blackdevice <- function (...) {
f_device(...)
par (bg = "black")
par (fg = "ivory1")
}
options (device = blackdevice)
</code></pre>
<p>The idea here is to save the original <code>device</code> function to another variable, and then call it from my new <code>device</code> function. What I get is:</p>
<pre><code>Error in f_device(...) : could not find function "f_device"
</code></pre>
<p>— At the time I run <code>plot (something)</code>.</p>
<p> </p>
<p>Another idea I had is to go like that:</p>
<p><em><code>~/.Rprofile</code></em></p>
<pre><code>.First <- function () {
options(f_device = options()$device)
blackdevice <- function (...) {
options()$f_device(...)
par (bg = "black")
par (fg = "ivory1")
}
options (device = blackdevice)
}
</code></pre>
<p>— Assigning the original <code>device</code> someplace else in <code>options</code>. But this leads to:</p>
<pre><code>Error in (function (...) : attempt to apply non-function
</code></pre>
<p> </p>
<p>I'm out of ideas. Can you help me figure this out?</p>
| 0debug
|
DOS script to replace line feeds : Looking to remove the incorrect carriage returns "CRLF" in a file but retain the correct ones. I think I have some logic that will work but can't quite nail the script.
Where ^p represents a “carriage return”
Replace Yes^p with yestemp
Replace No^p with notemp
Replace Inactive^p with inactivetemp
Replace ^p with “” (ie null)
Replace Yestemp with Yes^p
Replace notempwith No^p
Replace inactivetemp with Inactive^p
| 0debug
|
C++ stuck in while loop : <p>Hello I am doing a very simple while loop in C++ and I can not figure out why I am stuck in it even when the proper input is give.</p>
<pre><code>string itemType = "";
while(!(itemType == "b") || !(itemType == "m") || !(itemType == "d") || !(itemType == "t") || !(itemType == "c")){
cout<<"Enter the item type-b,m,d,t,c:"<<endl;
cin>>itemType;
cout<<itemType<<endl;
}
cout<<itemType;
</code></pre>
<p>if someone can point out what I am over looking I'd very much appreciate it. It is suppossed to exit when b,m,d,t or c is entered.</p>
| 0debug
|
Merging a simple array with a more complex one without concat for React App : > I need to merge this array -
[
0
:
"Basket Abandonment"
1
:
"Downloads"
2
:
"App Version"
3
:
"Last Push Performance"
]
> with this array -
[
0
:
bottom
:
{value: "£3,456", title: "Revenue Influence", status: "neutral",
comp:
"same", details: "Direct Revenue £1,567"}
top
:
{details: "Average 32%", status: "neutral", comp: "same", title:
"Most Recent Response Rate", value: "35%", …}
__proto__
:
Object
1
:
bottom
:
{value: "8.7%", title: "Previous Version", status: "", comp: "", details: "3.1.39 22nd Jul 2015"}
top
:
{details: "3.1.40 25th August 2015", status: "", comp: "", title: "Latest Version", value: "86%", …}
__proto__
:
Object
2
:
bottom
:
{value: "469", title: "Total Reviews", status: "neutral", comp:
"same", details: "2 New This Week"}
top
:
{details: "Version 3.1.40", status: "neutral", comp: "same", title:
"Average Rating", value: "4.0", …}
__proto__
:
Object
3
:
bottom
:
{value: "4 min 00 sec", title: "Average Session Length", status:
"positive", comp: "up", details: "was 3 min 20 sec"}
top
:
{details: "was 178,958", status: "negative", comp: "down", title:
"Number of Visits", value: "145,789", …}
__proto__
:
Object
]
> The nested objects in the second array are what i can't get my head
> around. I need to get the 3 values from the first array added to each
> object instance of the second so that I have a main-title: "eg.
> Downloads","App version" as well as the contents of "top" and "bottom".
> If that makes sense....
>
> This is basically for a React application that i'm trying to combine
> the results from one axios call into the results of another axios call
> so that they can be dynamically passed down to props on the last
> component. Each instance of the component will have a different Title
> ie. "downloads" from the first array that can't be hard-coded in - and
> the other details will come from the 2nd array.
| 0debug
|
fatal error: unexpectedly found nil while unwrapping an Optional value (Swift 3) : <p>this question has been asked a million times, but it still confuses me.
I have the app which connects to the server to in order to login and everything is fine until the user input is incorrect and the server returns nil. How can I prevent my app from crashing</p>
<pre><code> // A method for the login button
@IBAction func loginButton(_ sender: UIButton) {
parameters["email"] = email?.text
parameters["password"] = password?.text
Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.httpBody, headers: token).responseJSON {
(response) in
print(response.result.value!)
// Check if the servers return token and go to the next page
if response.result.value != nil {
self.performSegue(withIdentifier: "loginSegue", sender: nil)
}
if let tokenString = response.result.value as? String {
self.token["X-Auth-Token"] = tokenString
}
}
}
</code></pre>
| 0debug
|
static int vmdk_is_cid_valid(BlockDriverState *bs)
{
BDRVVmdkState *s = bs->opaque;
uint32_t cur_pcid;
if (!s->cid_checked && bs->backing) {
BlockDriverState *p_bs = bs->backing->bs;
cur_pcid = vmdk_read_cid(p_bs, 0);
if (s->parent_cid != cur_pcid) {
return 0;
}
}
s->cid_checked = true;
return 1;
}
| 1threat
|
How should I interpret the output of numpy.fft.rfft2? : <p>Obviously the rfft2 function simply computes the discrete fft of the input matrix. However how do I interpret a given index of the output? Given an index of the output, which Fourier coefficient am I looking at?<br>
I am especially confused by the sizes of the output. For an n by n matrix, the output seems to be an n by (n/2)+1 matrix (for even n). Why does a square matrix ends up with a non-square fourier transform?</p>
| 0debug
|
Mouse Click Events on JTable -Java : I want to get the Index of Selected row when user double clicks on a row.
here is my code
tab.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int selectedRow = tab.getSelectedRow();
try {
String file=rows[selectedRow][2];
String path="C:\\Users\\raj kumar\\Gallery\\"+file;
JLabel fileLable=new JLabel();
fileLable.setBounds(500,600,300,300);
fileLable.setIcon(new ImageIcon(path));
pan.add(fileLable);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
});
But the tab.getSelectedRow() return -1 eventhough i double clicked the row in table.
ThankYou.
| 0debug
|
HTML/CSS | checkboxes postions in picture : I have a short question to our web developer.
How is it possible to drop a few checkboxes inside a picutre at a specific postion?!
It would be very nice if I can drop the 11 checkboxes at the led position of the palm picture ;)
[LED-Palm][1]
<div class="container">
<img alt="palm" src="palme.png" />
<input type="checkbox" class="led" id="led1" />
<input type="checkbox" class="led" id="led2" />
<input type="checkbox" class="led" id="led3" />
<input type="checkbox" class="led" id="led4" />
<input type="checkbox" class="led" id="led5" />
<input type="checkbox" class="led" id="led6" />
<input type="checkbox" class="led" id="led7" />
<input type="checkbox" class="led" id="led8" />
<input type="checkbox" class="led" id="led9" />
<input type="checkbox" class="led" id="led10" />
<input type="checkbox" class="led" id="led11" />
</div>
[The idea goes back to Christian Hascheks LED-Cactus.][2]
I´am a web newbie and it would be very great if someone can help me :)
Many thanks in advance!
[1]: https://i.stack.imgur.com/PMXEe.jpg
[2]: https://blog.haschek.at/2018/raspberry-pi-controlled-cactus.html
| 0debug
|
static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)
{
int status;
AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context;
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
av_buffer_unref(&frame->buf[0]);
if (!videotoolbox->session || !vtctx->bitstream)
return AVERROR_INVALIDDATA;
status = videotoolbox_session_decode_frame(avctx);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
return AVERROR_UNKNOWN;
}
if (!vtctx->frame)
return AVERROR_UNKNOWN;
return ff_videotoolbox_buffer_create(vtctx, frame);
}
| 1threat
|
how to do properly discard similar element from the list? : <p>I have list like this:</p>
<pre><code>a = [1,2,3,4,5,6,7]
b = [10,11,13,2,14,7]
</code></pre>
<p>I want output like this:</p>
<pre><code>b = [10,11,13,14]
</code></pre>
<p>if an element of a is in b then it has been discarded.
please, anyone can tell me how to do this?</p>
| 0debug
|
Is it backwards-compatible to replace raw type like Collection with wildcard like Collection<?>? : <p>I'm the author of a certain open-source library. One of the public interfaces has methods which use raw types like <code>Collection</code>, for instance:</p>
<pre><code>public StringBuilder append(..., Collection value);
</code></pre>
<p>I get <code>Collection is a raw type. References to generic type Collection<E> should be parameterized</code> warnings.</p>
<p>I'm thinking about fixing these warnings. Implementations actually don't care about the types of the elements in collections. So I was thinking about replacing <code>Collection<?></code>.</p>
<p>However, these methods are parts of public interface of my library. Client code may call these methods or provide own implementations of these public interfaces thus implementing these methods. I am afraid that changing <code>Collection</code> to <code>Collection<?></code> will break client code. So here is my question.</p>
<p>If I change <code>Collection</code> -> <code>Collection<?></code> in my public interfaces, may this lead to:</p>
<ul>
<li>compilation errors in the client code?</li>
<li>runtime errors in the already compiled existing client code?</li>
</ul>
| 0debug
|
xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,
hwaddr cfg_base, uint64_t cfg_size,
hwaddr mmio_base, uint64_t mmio_size,
qemu_irq irq, bool link_up)
{
DeviceState *dev;
MemoryRegion *cfg, *mmio;
dev = qdev_create(NULL, TYPE_XILINX_PCIE_HOST);
qdev_prop_set_uint32(dev, "bus_nr", bus_nr);
qdev_prop_set_uint64(dev, "cfg_base", cfg_base);
qdev_prop_set_uint64(dev, "cfg_size", cfg_size);
qdev_prop_set_uint64(dev, "mmio_base", mmio_base);
qdev_prop_set_uint64(dev, "mmio_size", mmio_size);
qdev_prop_set_bit(dev, "link_up", link_up);
qdev_init_nofail(dev);
cfg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
memory_region_add_subregion_overlap(sys_mem, cfg_base, cfg, 0);
mmio = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1);
memory_region_add_subregion_overlap(sys_mem, 0, mmio, 0);
qdev_connect_gpio_out_named(dev, "interrupt_out", 0, irq);
return XILINX_PCIE_HOST(dev);
}
| 1threat
|
PHP Syntax Error with unexpected 'true' (T_STRING), expecting ')' : <p>I get this error when using php code</p>
<blockquote>
<p>PHP Syntax Check: Parse error: syntax error, unexpected 'true' (T_STRING), expecting ')' in your code on line 3568</p>
</blockquote>
<p>please help me i dont understand whats wrong here php code line</p>
<pre><code>static $true = array('1xtracts'true', 'True', 'TRUExtracts'y', 'Yxtracts'yes', 'Yes', 'YESxtracts'on', 'On', 'ONxtract);
</code></pre>
| 0debug
|
Python convert seconds to datetime date and time : <p>How do I convert an int like <code>1485714600</code> such that my result ends up being <code>Monday, January 30, 2017 12:00:00 AM</code>?</p>
<p>I've tried using <code>datetime.datetime</code> but it gives me results like '5 days, 13:23:07'</p>
| 0debug
|
jQuery get the value from from checked radio input which wasn't checked before : I got follow HTML:
<input type="radio" name="eingangstuer_pfostenbefestigung" value="Zum Einbetonieren" />
<input type="radio" name="eingangstuer_pfostenbefestigung" value="Zum Einduebeln" />
Ater I check one of them and try to get the value with:
$("input[name=eingangstuer_pfostenbefestigung]:checked").val();
I get NaN, it only works when one of the the values is checked BEFORE. Are there any solutions for the js bug nr. 666?
| 0debug
|
How to detect browser country in client site? : <p>I found the following website can detect my country and currency even in the private mode</p>
<p><a href="http://www.innisfreeworld.com/" rel="noreferrer">http://www.innisfreeworld.com/</a></p>
<p>It records in cookie, How do it do that?</p>
<p><a href="https://i.stack.imgur.com/e1x3I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/e1x3I.png" alt="enter image description here"></a></p>
<p>Is that possible fulfill in client site ? navigator?</p>
| 0debug
|
Chat storage in MySQL : <p>My friend and I run an IRC chat for a group of our friends, problem is that the history deletes when you log in, and doesn't store it anywhere, so when we try to reference something said earlier, the other user cannot see it, plus we often post links for us all to refer to later. </p>
<p>I would like to start archiving the chat on my personal site into the mySQL, but I'm not sure exactly how to go about doing this other than manually. Is there a way to have a persistent scraper add to my database whenever someone posts?</p>
| 0debug
|
Short running background task in .NET Core : <p>I just discovered <code>IHostedService</code> and .NET Core 2.1 <code>BackgroundService</code> class. I think idea is awesome. <a href="https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/background-tasks-with-ihostedservice" rel="noreferrer">Documentation</a>.</p>
<p>All examples I found are used for long running tasks (until application die).
But I need it for short time. Which is the correct way of doing it?</p>
<p><strong>For example:</strong><br>
I want to execute a few queries (they will take approx. 10 seconds) after application starts. And only if in development mode. I do not want to delay application startup so <code>IHostedService</code> seems good approach. I can not use <code>Task.Factory.StartNew</code>, because I need dependency injection.</p>
<p>Currently I am doing like this:</p>
<pre><code>public class UpdateTranslatesBackgroundService: BackgroundService
{
private readonly MyService _service;
public UpdateTranslatesBackgroundService(MyService service)
{
//MService injects DbContext, IConfiguration, IMemoryCache, ...
this._service = service;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await ...
}
}
</code></pre>
<p>startup:</p>
<pre><code>public static IServiceProvider Build(IServiceCollection services, ...)
{
//.....
if (hostingEnvironment.IsDevelopment())
services.AddSingleton<IHostedService, UpdateTranslatesBackgroundService>();
//.....
}
</code></pre>
<p>But this seems overkill. Is it? Register singleton (that means class exists while application lives). I don't need this. Just create class, run method, dispose class. All in background task.</p>
| 0debug
|
GitKraken : fetching pull requests failed : <p>I've just installed a free version of GitKraken and logged myself on github.
The software is working but when I pull a branch, I've always a red warning popup telling me "fetching pull requests failed"</p>
<p><a href="https://i.stack.imgur.com/VeXyc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VeXyc.png" alt="enter image description here"></a></p>
<p>Have you ever experienced that? Did I miss something in the configuration?</p>
<p>PS: my repositories are private</p>
| 0debug
|
How to pass a PHP variable to ajax jquery : <p>I want to pass a PHP variable to Jquery AJAX. How can I achieve this? I tried the below script.</p>
<pre><code>$query_sess="select id from users where username='".$_SESSION['username']."'";
$result_sess = mysqli_query($con,$query_sess) or die('error');
$row_sess= mysqli_fetch_assoc($result_sess);
$userID = $row_sess['id'];
</code></pre>
<p>I need to pass this $userID to the ajax. My ajax script is as follows:</p>
<pre><code>$(document).ready(function(){
function load_unseen_notification(view = '')
{
$.ajax({
url:"fetch_notification.php",
method:"POST",
data:{view:view, userID: <?php echo $userID; ?>},
dataType:"json",
success:function(data)
{
$('.dropdown-menunot').html(data.notification);
if(data.unseen_notification > 0)
{
$('.count').html(data.unseen_notification);
}
}
});
}
</code></pre>
| 0debug
|
Why do clang and g++ print 0 for a1.v and a2.v in this example in C++1z? : <p>See this example in <a href="http://eel.is/c++draft/class.init#class.base.init-11" rel="nofollow noreferrer">[class.base.init]/11</a></p>
<pre><code>struct A {
A() = default; // OK
A(int v) : v(v) { } // OK
const int& v = 42; // OK
};
A a1; // error: ill-formed binding of temporary to reference
A a2(1); // OK, unfortunately
</code></pre>
<p>Both clang and g++ compile the code (clang with a warning), but I'd like to understand why do they print <code>0</code> for the members <code>a1.v</code> and <code>a2.v</code>? See <a href="http://coliru.stacked-crooked.com/a/1df5b497e582732e" rel="nofollow noreferrer">demo</a>.</p>
| 0debug
|
static void x86_cpu_apic_init(X86CPU *cpu, Error **errp)
{
static int apic_mapped;
CPUX86State *env = &cpu->env;
APICCommonState *apic;
const char *apic_type = "apic";
if (kvm_irqchip_in_kernel()) {
apic_type = "kvm-apic";
} else if (xen_enabled()) {
apic_type = "xen-apic";
}
env->apic_state = qdev_try_create(NULL, apic_type);
if (env->apic_state == NULL) {
error_setg(errp, "APIC device '%s' could not be created", apic_type);
return;
}
object_property_add_child(OBJECT(cpu), "apic",
OBJECT(env->apic_state), NULL);
qdev_prop_set_uint8(env->apic_state, "id", env->cpuid_apic_id);
apic = APIC_COMMON(env->apic_state);
apic->cpu = cpu;
if (qdev_init(env->apic_state)) {
error_setg(errp, "APIC device '%s' could not be initialized",
object_get_typename(OBJECT(env->apic_state)));
return;
}
if (apic_mapped == 0) {
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(env->apic_state), 0,
APIC_DEFAULT_ADDRESS, 0x1000);
apic_mapped = 1;
}
}
| 1threat
|
Cordova android emulator "cannot read property 'replace' of undefined" : <p>Have just installed the latest version of Apache Cordova (7.0.1) on Windows, the Android SDK, added the android platform, and when trying to run the android emulator it compiles everything ok but then shows a:</p>
<blockquote>
<p>Cannot read property 'replace' of undefined</p>
</blockquote>
<p>Without indication or anything else to trace the error.</p>
| 0debug
|
static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, int width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %2, %%"REG_a" \n\t"
"movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd 3(%0, %%"REG_b"), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"movd 6(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%0, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm1, %%mm0 \n\t"
"packssdw %%mm3, %%mm2 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"packssdw %%mm2, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 15(%0, %%"REG_b"), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"movd 18(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%0, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm1, %%mm4 \n\t"
"packssdw %%mm3, %%mm2 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm2, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"packuswb %%mm4, %%mm0 \n\t"
"paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t"
"movq %%mm0, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src+width*3), "r" (dst+width), "g" ((long)-width)
: "%"REG_a, "%"REG_b
);
#else
int i;
for(i=0; i<width; i++)
{
int b= src[i*3+0];
int g= src[i*3+1];
int r= src[i*3+2];
dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
}
#endif
}
| 1threat
|
Version conflict updating to play-services 9.4.0 Android studio 2.2 : <p>I get an error saying </p>
<pre><code> Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.
</code></pre>
<p>I tried looking at <a href="https://bintray.com/android/android-tools/com.google.gms.google-services/">https://bintray.com/android/android-tools/com.google.gms.google-services/</a> and com.google.gms:google-services:3.0.0 seems to be the latest. This is my project gradle</p>
<pre><code>dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
</code></pre>
<p>And this is how my app gradle looks like</p>
<pre><code>buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.myapp.preburn"
minSdkVersion 10
targetSdkVersion 24
versionCode 14
versionName "2.0.1"
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.parse.bolts:bolts-android:1.2.0'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.mcxiaoke.volley:library:1.0.9'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.android.gms:play-services-plus:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'me.leolin:ShortcutBadger:1.1.3@aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile files('libs/jsoup-1.7.3.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile files('libs/InMobi-5.2.2.jar')
compile files('libs/libadapterinmobi.jar')
compile files('libs/StartAppAdMobMediation-1.0.1.jar')
compile files('libs/StartAppInApp-3.3.1.jar')
compile 'org.adw.library:discrete-seekbar:1.0.1'
compile 'com.pnikosis:materialish-progress:1.0'
}
</code></pre>
<p>If I change the play services to 9.0.0 everything compiles fine. What am I missing here?</p>
| 0debug
|
Why is the default Ubuntu boot partition so small? How can I increase it? : <p>Recently I created a Ubuntu server. During install I accepted the default options. Installer creates a 236M <code>/boot</code> partition as shown below. After only a few months the partition is full. Is this partition not awfully small? How can I increase it?</p>
<pre><code>$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 16G 4.0K 16G 1% /dev
tmpfs 3.2G 524K 3.2G 1% /run
/dev/mapper/ci--vg-root 95G 80G 11G 89% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 16G 0 16G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 236M 225M 0 100% /boot
</code></pre>
| 0debug
|
target_ulong helper_add_suov(CPUTriCoreState *env, target_ulong r1,
target_ulong r2)
{
int64_t t1 = extract64(r1, 0, 32);
int64_t t2 = extract64(r2, 0, 32);
int64_t result = t1 + t2;
return suov32(env, result);
}
| 1threat
|
static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)
{
char layout_name[256];
AVCodecContext *enc = ost->st->codec;
AVCodecContext *dec = ist->st->codec;
if (!dec->channel_layout) {
if (enc->channel_layout && dec->channels == enc->channels) {
dec->channel_layout = enc->channel_layout;
} else {
dec->channel_layout = av_get_default_channel_layout(dec->channels);
if (!dec->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel "
"layout for Input Stream #%d.%d\n", ist->file_index,
ist->st->index);
exit_program(1);
}
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
dec->channels, dec->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
"#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
}
if (!enc->channel_layout) {
if (dec->channels == enc->channels) {
enc->channel_layout = dec->channel_layout;
return;
} else {
enc->channel_layout = av_get_default_channel_layout(enc->channels);
}
if (!enc->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel layout "
"for Output Stream #%d.%d\n", ost->file_index,
ost->st->index);
exit_program(1);
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
enc->channels, enc->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Output Stream "
"#%d.%d : %s\n", ost->file_index, ost->st->index, layout_name);
}
}
| 1threat
|
How do i validate data inserted from asp.net to sql server : I have a web form already connected to SQL Server, i can insert but i dont know how to do the validation to not Insert data if the table already has the same information.
How can this process be done?
using (SqlConnection con = new SqlConnection("Data Source=hans-pc;Initial Catalog=CntExp;Integrated Security=True"))
{
SqlCommand cmd = new SqlCommand("INSERT INTO PreExp1 (Expe, Usuario) values (@Expe, @Usuario)", con);
cmd.Parameters.AddWithValue("@Expe", TextBox1.Text);
cmd.Parameters.AddWithValue("@Usuario", TextBox2.Text);
//cmd.Parameters.AddWithValue("@Fecha", Datenow());
con.Open();
int insertar = cmd.ExecuteNonQuery();
Response.Write("Inserted" + insertar.ToString());
}
| 0debug
|
calculate array values by key : <p>i have a array problem can i calculate same integer value.
my example arrays on the bottom please </p>
<pre><code>int = -21;
</code></pre>
<hr>
<p>my first array</p>
<blockquote>
<pre><code>Array
(
[580] => 13.000000
[582] => 8.000000
[485] => 7.000000
)
</code></pre>
</blockquote>
<p>and i need is algoritm</p>
<pre><code>Array
(
[580] => 13.000000+int // sum -8
[582] => 8.000000+(-8) // 0
[485] => 7.000000
)
</code></pre>
<p>after result</p>
<pre><code>Array
(
[580] => 8
[582] => 0
[485] => 7.000000
)
</code></pre>
| 0debug
|
int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
int sock, const char *export, Error **errp)
{
int ret;
logout("session init %s\n", export);
qemu_set_block(sock);
ret = nbd_receive_negotiate(sock, export,
&client->nbdflags, &client->size,
&client->blocksize, errp);
if (ret < 0) {
logout("Failed to negotiate with the NBD server\n");
closesocket(sock);
return ret;
}
qemu_co_mutex_init(&client->send_mutex);
qemu_co_mutex_init(&client->free_sema);
client->bs = bs;
client->sock = sock;
qemu_set_nonblock(sock);
nbd_client_session_attach_aio_context(client, bdrv_get_aio_context(bs));
logout("Established connection with NBD server\n");
return 0;
}
| 1threat
|
Calculating 1/2 on Python : <p>That's just basic math, 1/2 = 0.5, but it seems on Python the result is 0?</p>
<p>I thought that the result is in int format, but I've also tried float(1/2) and the result is still the same. Does anyone know why is this happening? </p>
<p>(Sorry for the bad English, not my native language. Also, I just got learning Python:D)</p>
| 0debug
|
Convert Interface to different type : <p>How would I convert an interface to another type?</p>
<p>Let's say i have an interface of type 'Cars' and
another one of type 'trucks'.
I would like to convert this interface to type 'Vehicles'.</p>
<p>How would i go about solving that?</p>
| 0debug
|
static void quantize_and_encode_band_cost_UPAIR12_mips(struct AACEncContext *s,
PutBitContext *pb, const float *in, float *out,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits, const float ROUNDING)
{
const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
int i;
int qc1, qc2, qc3, qc4;
uint8_t *p_bits = (uint8_t*) ff_aac_spectral_bits[cb-1];
uint16_t *p_codes = (uint16_t*)ff_aac_spectral_codes[cb-1];
float *p_vec = (float *)ff_aac_codebook_vectors[cb-1];
abs_pow34_v(s->scoefs, in, size);
scaled = s->scoefs;
for (i = 0; i < size; i += 4) {
int curidx1, curidx2, sign1, count1, sign2, count2;
int *in_int = (int *)&in[i];
uint8_t v_bits;
unsigned int v_codes;
int t0, t1, t2, t3, t4;
const float *vec1, *vec2;
qc1 = scaled[i ] * Q34 + ROUND_STANDARD;
qc2 = scaled[i+1] * Q34 + ROUND_STANDARD;
qc3 = scaled[i+2] * Q34 + ROUND_STANDARD;
qc4 = scaled[i+3] * Q34 + ROUND_STANDARD;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"ori %[t4], $zero, 12 \n\t"
"ori %[sign1], $zero, 0 \n\t"
"ori %[sign2], $zero, 0 \n\t"
"slt %[t0], %[t4], %[qc1] \n\t"
"slt %[t1], %[t4], %[qc2] \n\t"
"slt %[t2], %[t4], %[qc3] \n\t"
"slt %[t3], %[t4], %[qc4] \n\t"
"movn %[qc1], %[t4], %[t0] \n\t"
"movn %[qc2], %[t4], %[t1] \n\t"
"movn %[qc3], %[t4], %[t2] \n\t"
"movn %[qc4], %[t4], %[t3] \n\t"
"lw %[t0], 0(%[in_int]) \n\t"
"lw %[t1], 4(%[in_int]) \n\t"
"lw %[t2], 8(%[in_int]) \n\t"
"lw %[t3], 12(%[in_int]) \n\t"
"slt %[t0], %[t0], $zero \n\t"
"movn %[sign1], %[t0], %[qc1] \n\t"
"slt %[t2], %[t2], $zero \n\t"
"movn %[sign2], %[t2], %[qc3] \n\t"
"slt %[t1], %[t1], $zero \n\t"
"sll %[t0], %[sign1], 1 \n\t"
"or %[t0], %[t0], %[t1] \n\t"
"movn %[sign1], %[t0], %[qc2] \n\t"
"slt %[t3], %[t3], $zero \n\t"
"sll %[t0], %[sign2], 1 \n\t"
"or %[t0], %[t0], %[t3] \n\t"
"movn %[sign2], %[t0], %[qc4] \n\t"
"slt %[count1], $zero, %[qc1] \n\t"
"slt %[t1], $zero, %[qc2] \n\t"
"slt %[count2], $zero, %[qc3] \n\t"
"slt %[t2], $zero, %[qc4] \n\t"
"addu %[count1], %[count1], %[t1] \n\t"
"addu %[count2], %[count2], %[t2] \n\t"
".set pop \n\t"
: [qc1]"+r"(qc1), [qc2]"+r"(qc2),
[qc3]"+r"(qc3), [qc4]"+r"(qc4),
[sign1]"=&r"(sign1), [count1]"=&r"(count1),
[sign2]"=&r"(sign2), [count2]"=&r"(count2),
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3),
[t4]"=&r"(t4)
: [in_int]"r"(in_int)
: "memory"
);
curidx1 = 13 * qc1;
curidx1 += qc2;
v_codes = (p_codes[curidx1] << count1) | sign1;
v_bits = p_bits[curidx1] + count1;
put_bits(pb, v_bits, v_codes);
curidx2 = 13 * qc3;
curidx2 += qc4;
v_codes = (p_codes[curidx2] << count2) | sign2;
v_bits = p_bits[curidx2] + count2;
put_bits(pb, v_bits, v_codes);
if (out) {
vec1 = &p_vec[curidx1*2];
vec2 = &p_vec[curidx2*2];
out[i+0] = copysignf(vec1[0] * IQ, in[i+0]);
out[i+1] = copysignf(vec1[1] * IQ, in[i+1]);
out[i+2] = copysignf(vec2[0] * IQ, in[i+2]);
out[i+3] = copysignf(vec2[1] * IQ, in[i+3]);
}
}
}
| 1threat
|
static int handle_packets(MpegTSContext *ts, int nb_packets)
{
AVFormatContext *s = ts->stream;
uint8_t packet[TS_PACKET_SIZE];
int packet_num, ret = 0;
if (avio_tell(s->pb) != ts->last_pos) {
int i;
av_dlog(ts->stream, "Skipping after seek\n");
for (i = 0; i < NB_PID_MAX; i++) {
if (ts->pids[i]) {
if (ts->pids[i]->type == MPEGTS_PES) {
PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
av_freep(&pes->buffer);
pes->data_index = 0;
pes->state = MPEGTS_SKIP;
}
ts->pids[i]->last_cc = -1;
}
}
}
ts->stop_parse = 0;
packet_num = 0;
for(;;) {
if (ts->stop_parse>0)
break;
packet_num++;
if (nb_packets != 0 && packet_num >= nb_packets)
break;
ret = read_packet(s, packet, ts->raw_packet_size);
if (ret != 0)
break;
ret = handle_packet(ts, packet);
if (ret != 0)
break;
}
ts->last_pos = avio_tell(s->pb);
return ret;
}
| 1threat
|
Facing an issue while fetching data in sqlite in ios : - (NSMutableArray*)getAllDataFromTableUSERINFO:(NSString *)fetchQuery {
NSMutableArray *resultArray1 =[[NSMutableArray alloc]init];
@autoreleasepool {
if (sqlite3_open([[self getDBPath]UTF8String],&database)==SQLITE_OK){
sqlite3_stmt *stmt;
const char *sqlfetch=[fetchQuery UTF8String];
if (sqlite3_prepare(database, sqlfetch, -1,&stmt, NULL)==SQLITE_OK) {
while (sqlite3_step(stmt)==SQLITE_ROW){
RM_USER_INFO *UserInfo = [[RM_USER_INFO alloc]init];
UserInfo.uid=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,0)];
UserInfo.username=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,1)];
UserInfo.password=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,2)];
UserInfo.fname=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,3)];
UserInfo.mname=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,4)];
UserInfo.lname=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,5)];
UserInfo.nickname=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,6)];
UserInfo.email=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,7)];
UserInfo.phone=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,8)];
UserInfo.city=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,9)];
UserInfo.state=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,10)];
UserInfo.country=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,11)];
UserInfo.zip=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,12)];
UserInfo.gender=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,13)];
UserInfo.income=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,14)];
UserInfo.age=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,15)];
UserInfo.socialnetworktype=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,16)];
UserInfo.reallymake_points=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,17)];
UserInfo.create_date=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,18)];
UserInfo.update_date=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,19)];
UserInfo.lastsync_date=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,20)];
UserInfo.encrypt_key=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,21)];
UserInfo.session_hash_key=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,22)];
UserInfo.websocket_key=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,23)];
UserInfo.device=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,24)];
UserInfo.max_model_id=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,25)];
UserInfo.ads_status=[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt,26)];
[resultArray1 addObject:UserInfo];
}
}
sqlite3_finalize(stmt);
stmt=nil;
sqlite3_close(database);
sqlite3_release_memory(120);
}
}
return resultArray1;
}
| 0debug
|
Traversing,Insertion and Deletion in LinkedList data structure in java : <p>I am new to data structures. I am very curious to learn data structures, but i didnt find any healthy tutorial for that so I am posting it here thinking someone would help me. I know theory of linked list but m totally blank while implementation. If Someone can make me understand how it works that would be really helpful for me.Like, how to traverse through Linked List ,insert and delete. Please provide me a running code so that its easy for me to understand.
<strong>I KNOW there are lot of peoples who will think to mark this question as a duplicate and downvote this. Rather than finding mistakes if you guys provide me a good solution that would be really Helpful. Thanks.</strong> </p>
| 0debug
|
Spliting a number like 15 into these(0, 1, 2, 4, 8) Python : <p>I need to split a number like 15 into these(0, 1, 2, 4, 8) different numbers that one is used only once.</p>
<p>For example, 15 would output (8, 4, 2, 1).</p>
<p>I am a beginner programmer so I apologize for my lack of understanding in advance.</p>
<p>Thank you.</p>
| 0debug
|
How to import .XML code style into IntelliJ Idea 15 : <p>I want to use a specific code style in my editor defined in an XML file, which looks something like this:</p>
<pre><code><code_scheme name="CustomStyleName">
<option name="JAVA_INDENT_OPTIONS">
<value>
...
</code></pre>
<p>How is it possible to import this style into IntelliJ Idea.
When I go to Preferences->Editor->Code Style->Manage it is only possible to import an Eclipse XML Profile.</p>
<p><a href="https://i.stack.imgur.com/eo3ke.png"><img src="https://i.stack.imgur.com/eo3ke.png" alt="screenshot of the import dialog"></a></p>
| 0debug
|
why doesn't it print the string?my code is below: : it prints only FG and other characters are garbage
enter code here
#include<stdio.h>
void putstr(char *s1[])
{
while(*s1!='\0')
{
printf("%c",*s1);s1++;
}
}
int main()
{
char s1[10]="fedfgh";
putstr(s1);
}
| 0debug
|
static void set_kernel_args(const struct arm_boot_info *info)
{
int initrd_size = info->initrd_size;
target_phys_addr_t base = info->loader_start;
target_phys_addr_t p;
p = base + KERNEL_ARGS_ADDR;
WRITE_WORD(p, 5);
WRITE_WORD(p, 0x54410001);
WRITE_WORD(p, 1);
WRITE_WORD(p, 0x1000);
WRITE_WORD(p, 0);
WRITE_WORD(p, 4);
WRITE_WORD(p, 0x54410002);
WRITE_WORD(p, info->ram_size);
WRITE_WORD(p, info->loader_start);
if (initrd_size) {
WRITE_WORD(p, 4);
WRITE_WORD(p, 0x54420005);
WRITE_WORD(p, info->loader_start + INITRD_LOAD_ADDR);
WRITE_WORD(p, initrd_size);
}
if (info->kernel_cmdline && *info->kernel_cmdline) {
int cmdline_size;
cmdline_size = strlen(info->kernel_cmdline);
cpu_physical_memory_write(p + 8, (void *)info->kernel_cmdline,
cmdline_size + 1);
cmdline_size = (cmdline_size >> 2) + 1;
WRITE_WORD(p, cmdline_size + 2);
WRITE_WORD(p, 0x54410009);
p += cmdline_size * 4;
}
if (info->atag_board) {
int atag_board_len;
uint8_t atag_board_buf[0x1000];
atag_board_len = (info->atag_board(info, atag_board_buf) + 3) & ~3;
WRITE_WORD(p, (atag_board_len + 8) >> 2);
WRITE_WORD(p, 0x414f4d50);
cpu_physical_memory_write(p, atag_board_buf, atag_board_len);
p += atag_board_len;
}
WRITE_WORD(p, 0);
WRITE_WORD(p, 0);
}
| 1threat
|
static void spitz_common_init(int ram_size, int vga_ram_size,
DisplayState *ds, const char *kernel_filename,
const char *kernel_cmdline, const char *initrd_filename,
enum spitz_model_e model, int arm_id)
{
uint32_t spitz_ram = 0x04000000;
uint32_t spitz_rom = 0x00800000;
struct pxa2xx_state_s *cpu;
struct scoop_info_s *scp;
cpu = pxa270_init(ds, (model == terrier) ? "c5" : "c0");
if (ram_size < spitz_ram + spitz_rom) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
spitz_ram + spitz_rom);
exit(1);
}
cpu_register_physical_memory(PXA2XX_RAM_BASE, spitz_ram, IO_MEM_RAM);
sl_flash_register(cpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
cpu_register_physical_memory(0, spitz_rom, spitz_ram | IO_MEM_ROM);
spitz_keyboard_register(cpu);
spitz_ssp_attach(cpu);
scp = spitz_scoop_init(cpu, (model == akita) ? 1 : 2);
spitz_scoop_gpio_setup(cpu, scp, (model == akita) ? 1 : 2);
spitz_gpio_setup(cpu, (model == akita) ? 1 : 2);
if (model == terrier)
spitz_microdrive_attach(cpu);
else if (model != akita)
spitz_microdrive_attach(cpu);
cpu->env->regs[15] = PXA2XX_RAM_BASE;
arm_load_kernel(cpu->env, ram_size, kernel_filename, kernel_cmdline,
initrd_filename, arm_id, PXA2XX_RAM_BASE);
sl_bootparam_write(SL_PXA_PARAM_BASE - PXA2XX_RAM_BASE);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.