problem
stringlengths
26
131k
labels
class label
2 classes
Merge / Combine two or more different StyleSheet components in React Native? : <p>I'm separating my styles in the following way:</p> <pre><code>styles / |-- base.js |-- base.ios.js |-- base.android.js </code></pre> <p>Each of them exports a StyleSheet component created as in this example:</p> <pre><code>import { StyleSheet } from 'react-native'; export default StyleSheet.create({ statusBar: { height: 20 }); </code></pre> <p>How can I merge them so I only have one base style object? I'm looking for something like:</p> <pre><code>const baseStyles = mergeStyles(baseStyle, platformStyle); </code></pre>
0debug
static void test_properties(const char *path) { char *child_path; QDict *response, *tuple; QList *list; QListEntry *entry; g_test_message("Obtaining properties of %s", path); response = qmp("{ 'execute': 'qom-list'," " 'arguments': { 'path': '%s' } }", path); g_assert(response); g_assert(qdict_haskey(response, "return")); list = qobject_to_qlist(qdict_get(response, "return")); QLIST_FOREACH_ENTRY(list, entry) { tuple = qobject_to_qdict(qlist_entry_obj(entry)); if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) { child_path = g_strdup_printf("%s/%s", path, qdict_get_str(tuple, "name")); test_properties(child_path); g_free(child_path); } else { const char *prop = qdict_get_str(tuple, "name"); g_test_message("Testing property %s.%s", path, prop); response = qmp("{ 'execute': 'qom-get'," " 'arguments': { 'path': '%s'," " 'property': '%s' } }", path, prop); g_assert(response); } } }
1threat
static int pdu_copy_sg(V9fsPDU *pdu, size_t offset, int rx, struct iovec *sg) { size_t pos = 0; int i, j; struct iovec *src_sg; unsigned int num; if (rx) { src_sg = pdu->elem.in_sg; num = pdu->elem.in_num; } else { src_sg = pdu->elem.out_sg; num = pdu->elem.out_num; } j = 0; for (i = 0; i < num; i++) { if (offset <= pos) { sg[j].iov_base = src_sg[i].iov_base; sg[j].iov_len = src_sg[i].iov_len; j++; } else if (offset < (src_sg[i].iov_len + pos)) { sg[j].iov_base = src_sg[i].iov_base; sg[j].iov_len = src_sg[i].iov_len; sg[j].iov_base += (offset - pos); sg[j].iov_len -= (offset - pos); j++; } pos += src_sg[i].iov_len; } return j; }
1threat
Can you declare a object literal type that allows unknown properties in typescript? : <p>Essentially I want to ensure that an object argument contains all of the required properties, but can contain any other properties it wants. For example:</p> <pre><code>function foo(bar: { baz: number }) : number { return bar.baz; } foo({ baz: 1, other: 2 }); </code></pre> <p>But this results in:</p> <pre><code>Object literal may only specify known properties, and 'other' does not exist in type '{ baz: number; }'. </code></pre>
0debug
One of my fonctions on the TicTacToe game in C++ : I have a little problem with the fonction " JOUER ". It's been a few days I'm working on it, but I can't see the problemS. I guess, there are a few (or a lot) of them. Here is te code: *********************************************************** #include <iostream> using namespace std; enum etat { victoire, continuer, null }; int qntMouv = 0; class TicTacToe { public: TicTacToe(); etat etatJeux (); void affichTab() const ; bool getXOMouv (char symbolMouv); bool mouvValid (int x, int y) const; void recommence (); void game(); private: char tableau[3][3]; }; // fin classe TicTacToe TicTacToe::TicTacToe() { for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) tableau[i][j] = ' '; qntMouv = 0; // le tableau est vide } // fin constructeur TicTacToe void jouer () { int joueur = 1, x, y; int tableau[x][y]; char reponse; while (reponse == 'O' || reponse =='o') { TicTacToe::affichTab(); if (etatJeux == continuer) { joueur = (joueur % 2) ? 1 : 2; if (joueur == 1) ? 'X' : 'O'; cout << " Joueur " << joueur << " Tappez la ligne: "; cin >> x; cout << " Joueur " << joueur << " Tappez la colomne: "; cin >> y; getXOMouv(); mouvValid(); joueur++; } // fin if else if ( mouvValid == 0 ) { cout<<" Movement n'est pas valide' "; joueur--; getXOMouv(); else if (etatJeux==victoire) cout<<"\a Joueur "<< --joueur<<" est le gagnant "; else cout<<"\a Null"; return 0; } // fin boucle while cout<< " Vouez-vous continuer? ( O / N )" << endl; cin >> reponse ; recommence () ; } // fin void jouer void TicTacToe::affichTab() const { cout<<endl;cout<<endl; cout << " *****Col 1"<<"**Col 2"<<"**Col 3"<<endl; cout<< endl; cout <<"**Lig 1"<<tableau[0][0]<< "____|"<<tableau[0][1]<<"____|"<<tableau[0][2]<<"____"<<endl; cout<<endl; cout <<"**Lig 2"<<tableau[1][0]<< "____|"<<tableau[1][1]<<"____|"<<tableau[1][2]<<"____"<<endl; cout<<endl; cout <<"**Lig 3"<<tableau[2][0]<< "____|"<<tableau[2][1]<<"____|"<<tableau[2][2]<<"____"<<endl; cout<<endl; } // fin affichTab bool TicTacToe::mouvValid (int x, int y) const{ int lig, col; if ( lig >= 0 && lig <= 2 && col >=0 && col <= 2 && tableau[x] [y] == ' ' ) return true; else return false; } // fin du bool mouvValid bool TicTacToe::getXOMouv (char symbolMouv) { qntMouv++; if ( symbolMouv == 'X') { symbolMouv = 'O'; return true; } // fin if else { symbolMouv = 'X'; return false; } // fin else } // fin du bool getXOMouv etat TicTacToe::etatJeux () { if ((tableau[0][0]) && (tableau[1][0]) && (tableau[2][0])) return victoire; //colomne else if ((tableau[0][1]) && (tableau[1][1]) && (tableau[2][1])) return victoire; //colomne else if ((tableau[0][2]) && (tableau[1][2]) && (tableau[2][2])) return victoire; // colomne else if((tableau[0][0] ) && (tableau[0][1] ) && (tableau[0][2]))return victoire; // lignme else if ((tableau[1][0]) && (tableau[1][1]) && (tableau[1][2])) return victoire; // ligne else if ((tableau[2][0]) && (tableau[2][1]) && (tableau[2][2])) return victoire; // ligne else if ((tableau[0][0]) && (tableau[1][1]) && (tableau[2][2])) return victoire; // diago else if ((tableau[0][2]) && (tableau[1][1]) && (tableau[2][0])) return victoire; // // diago else if (qntMouv < 9) return continuer; return null; } // fin etatJeux void TicTacToe::recommence () { qntMouv = 0; for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) tableau[i][j] = ' '; } // fin reccomence int main () { TicTacToe game; game.affichTab(); return 0; } // fin du main du programme
0debug
static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) { AppleHTTPContext *c = s->priv_data; int ret = 0, i, j, stream_offset = 0; if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0) goto fail; if (c->n_variants == 0) { av_log(NULL, AV_LOG_WARNING, "Empty playlist\n"); ret = AVERROR_EOF; goto fail; } if (c->n_variants > 1 || c->variants[0]->n_segments == 0) { for (i = 0; i < c->n_variants; i++) { struct variant *v = c->variants[i]; if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) goto fail; } } if (c->variants[0]->n_segments == 0) { av_log(NULL, AV_LOG_WARNING, "Empty playlist\n"); ret = AVERROR_EOF; goto fail; } if (c->finished) { int duration = 0; for (i = 0; i < c->variants[0]->n_segments; i++) duration += c->variants[0]->segments[i]->duration; s->duration = duration * AV_TIME_BASE; } c->min_end_seq = INT_MAX; for (i = 0; i < c->n_variants; i++) { struct variant *v = c->variants[i]; if (v->n_segments == 0) continue; c->max_start_seq = FFMAX(c->max_start_seq, v->start_seq_no); c->min_end_seq = FFMIN(c->min_end_seq, v->start_seq_no + v->n_segments); ret = av_open_input_file(&v->ctx, v->segments[0]->url, NULL, 0, NULL); if (ret < 0) goto fail; url_fclose(v->ctx->pb); v->ctx->pb = NULL; v->stream_offset = stream_offset; for (j = 0; j < v->ctx->nb_streams; j++) { AVStream *st = av_new_stream(s, i); if (!st) { ret = AVERROR(ENOMEM); goto fail; } avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); } stream_offset += v->ctx->nb_streams; } c->last_packet_dts = AV_NOPTS_VALUE; c->cur_seq_no = c->max_start_seq; if (!c->finished && c->min_end_seq - c->max_start_seq > 3) c->cur_seq_no = c->min_end_seq - 2; return 0; fail: free_variant_list(c); return ret; }
1threat
A way to build a web video chat with firebase : <p>I'm developing a firebase based web app (using angularjs framework). I want to add new features of real time communication so two users in the website could communicate one with each other.</p> <p>Is there is a way to create a good video chat using firebase?</p> <p>Thanks</p>
0debug
Can you lock notepad files? : <p>I am currently working on a little (quite bad) batch file password protected folder. To increase the security of my password and files what can I do to somehow make the file "un-viewable" to others?</p>
0debug
accesings protected variable in php : I have created protected variable in php and want to use in php function within same class.I have printed `$program_owner_id` > Undefined variable: project_owner_id <?php class userController extends Controller { protected $program_owner_id = array (); //protected variable public function mappingUserToRequest() { print_r($program_owner_id) /Expected to use here } } ?>
0debug
Replacing a String between 2 pipes c# : <p>I have a problem in C# to replace a string between two pipes or with an ending pipe.</p> <p>Example: I want to replace the second value</p> <p>Before: 0|<strong>1</strong>|2|3</p> <p>After Replace: 0|<strong>4</strong>|2|3</p> <p>How can I do this? The value can be also 2 digits or more.</p> <p>And a second question: how can i replace the first value where is no beginning pipe?</p> <p>It should be dynamicly to select which value I would like to change like "replaceString(string text, int valueindexToReplace, string replacewiht)"</p> <p>Thank you for your help.</p>
0debug
I want to delete very other items leaving the selected ones from the list of files at a shot : I have a file with many other unwanted items in it i want to delete them all automatically leaving behind the data needed i have around 100 of cells i need only the cell name and all the pin and direction for those 100 cells and delete every other item grep -A 41435 'cell' lib | grep -iE '(cell|pin|direction)'(41437 no of lines in lib file) output cell( FVOXY_O_W11X ) { pa_p ( vcc ) { direction : input; pb_p ( vss ) { direction : input; is_macro_cell : true; pin(measure) { related_p_pin : x ; related_g_pin : y ; direction : inout ; original :measure; } /* end of pin measure */ pin(pass) { related_p_pin : x ; related_g_pin :y ; direction : input ; original : pass; } /* end of pin pass */ what i need cell( FOVIO_NOM_D2DSYNC8X ) pin(measure) direction : inout pin(pass) direction : input Like such i have around 100 cell I want only the cell name and all the pin and direction of that cell can any one tell me how can
0debug
Install npm packages in Python virtualenv : <p>There are some npm packages which I would like to install in a Python virtualenv. For example: </p> <ul> <li><a href="https://www.npmjs.com/package/pdfjs-dist" rel="noreferrer">https://www.npmjs.com/package/pdfjs-dist</a></li> <li><a href="https://www.npmjs.com/package/jquery-ui" rel="noreferrer">https://www.npmjs.com/package/jquery-ui</a></li> </ul> <p>Up to now I only found the complicated way to get these installable in a virtualenv: Create a python package for them.</p> <p>Is there no simpler way to get npm packages installed in a Python virtualenv?</p>
0debug
static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num) { BDRVBochsState *s = bs->opaque; uint64_t offset = sector_num * 512; uint64_t extent_index, extent_offset, bitmap_offset; char bitmap_entry; extent_index = offset / s->extent_size; extent_offset = (offset % s->extent_size) / 512; if (s->catalog_bitmap[extent_index] == 0xffffffff) { return -1; } bitmap_offset = s->data_offset + (512 * (uint64_t) s->catalog_bitmap[extent_index] * (s->extent_blocks + s->bitmap_blocks)); if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8), &bitmap_entry, 1) != 1) { return -1; } if (!((bitmap_entry >> (extent_offset % 8)) & 1)) { return -1; } return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset)); }
1threat
int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi) { int bs_code, sr_code, bps_code; skip_bits(gb, 16); bs_code = get_bits(gb, 4); sr_code = get_bits(gb, 4); fi->ch_mode = get_bits(gb, 4); if (fi->ch_mode < FLAC_MAX_CHANNELS) { fi->channels = fi->ch_mode + 1; fi->ch_mode = FLAC_CHMODE_INDEPENDENT; } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) { fi->channels = 2; } else { av_log(avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", fi->ch_mode); return -1; } bps_code = get_bits(gb, 3); if (bps_code == 3 || bps_code == 7) { av_log(avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n", bps_code); return -1; } fi->bps = sample_size_table[bps_code]; if (get_bits1(gb)) { av_log(avctx, AV_LOG_ERROR, "broken stream, invalid padding\n"); return -1; } if (get_utf8(gb) < 0) { av_log(avctx, AV_LOG_ERROR, "utf8 fscked\n"); return -1; } if (bs_code == 0) { av_log(avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n"); return -1; } else if (bs_code == 6) { fi->blocksize = get_bits(gb, 8) + 1; } else if (bs_code == 7) { fi->blocksize = get_bits(gb, 16) + 1; } else { fi->blocksize = ff_flac_blocksize_table[bs_code]; } if (sr_code < 12) { fi->samplerate = ff_flac_sample_rate_table[sr_code]; } else if (sr_code == 12) { fi->samplerate = get_bits(gb, 8) * 1000; } else if (sr_code == 13) { fi->samplerate = get_bits(gb, 16); } else if (sr_code == 14) { fi->samplerate = get_bits(gb, 16) * 10; } else { av_log(avctx, AV_LOG_ERROR, "illegal sample rate code %d\n", sr_code); return -1; } skip_bits(gb, 8); if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer, get_bits_count(gb)/8)) { av_log(avctx, AV_LOG_ERROR, "header crc mismatch\n"); return -1; } return 0; }
1threat
how to make pairs using nested loop in lisp : I am trying to make pairs function in lisp. Pairs function gets 2 inputs then makes pair each other and make one list. Here is my code. (defun npair (s1 s2) (let ((result '())) (cond ((null s1) s2) ((null s2) s1) (t (loop (when (null s1) (return result)) (while (not (null s2)) (setq result (cons (list (car s1) (car s2)) result)) (setq s2 (cdr s2)) ) (setq s1 (cdr s1)) ) ) ) ) ) This function should have returned like (npair '(a b c) '(1 2)) -> ((a 1) (a 2) (b 1) (b 2) (c 1) (c 2)) But my result is only ((a 1) (a 2)) Please help!!
0debug
SocketAddressLegacy *socket_remote_address(int fd, Error **errp) { struct sockaddr_storage ss; socklen_t sslen = sizeof(ss); if (getpeername(fd, (struct sockaddr *)&ss, &sslen) < 0) { error_setg_errno(errp, errno, "%s", "Unable to query remote socket address"); return NULL; } return socket_sockaddr_to_address(&ss, sslen, errp); }
1threat
static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env = NULL, *envs[MAX_CPUS]; char buf[1024]; nvram_t nvram; m48t59_t *m48t59; int PPC_io_memory; int linux_boot, i, nb_nics1, bios_size; unsigned long bios_offset; uint32_t kernel_base, kernel_size, initrd_base, initrd_size; PCIBus *pci_bus; qemu_irq *i8259; int ppc_boot_device; sysctrl = qemu_mallocz(sizeof(sysctrl_t)); if (sysctrl == NULL) return; linux_boot = (kernel_filename != NULL); if (cpu_model == NULL) cpu_model = "default"; for (i = 0; i < smp_cpus; i++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); qemu_register_reset(&cpu_ppc_reset, env); register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); envs[i] = env; } cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); bios_offset = ram_size + vga_ram_size; if (bios_name == NULL) bios_name = BIOS_FILENAME; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); bios_size = load_image(buf, phys_ram_base + bios_offset); if (bios_size < 0 || bios_size > BIOS_SIZE) { cpu_abort(env, "qemu: could not load PPC PREP bios '%s'\n", buf); exit(1); } if (env->nip < 0xFFF80000 && bios_size < 0x00100000) { cpu_abort(env, "PowerPC 601 / 620 / 970 need a 1MB BIOS\n"); } bios_size = (bios_size + 0xfff) & ~0xfff; cpu_register_physical_memory((uint32_t)(-bios_size), bios_size, bios_offset | IO_MEM_ROM); if (linux_boot) { kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base); if (kernel_size < 0) { cpu_abort(env, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image(initrd_filename, phys_ram_base + initrd_base); if (initrd_size < 0) { cpu_abort(env, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; for (i = 0; boot_device[i] != '\0'; i++) { if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for Mac99 machine\n"); exit(1); } } isa_mem_base = 0xc0000000; if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { cpu_abort(env, "Only 6xx bus is supported on PREP machine\n"); exit(1); } i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]); pci_bus = pci_prep_init(i8259); PPC_io_memory = cpu_register_io_memory(0, PPC_prep_io_read, PPC_prep_io_write, sysctrl); cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory); pci_vga_init(pci_bus, ds, phys_ram_base + ram_size, ram_size, vga_ram_size, 0, 0); rtc_init(0x70, i8259[8]); serial_init(0x3f8, i8259[4], serial_hds[0]); nb_nics1 = nb_nics; if (nb_nics1 > NE2000_NB_MAX) nb_nics1 = NE2000_NB_MAX; for(i = 0; i < nb_nics1; i++) { if (nd_table[i].model == NULL || strcmp(nd_table[i].model, "ne2k_isa") == 0) { isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]); } else { pci_nic_init(pci_bus, &nd_table[i], -1); } } for(i = 0; i < 2; i++) { isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], bs_table[2 * i], bs_table[2 * i + 1]); } i8042_init(i8259[1], i8259[12], 0x60); DMA_init(1); fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table); register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL); register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL); sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET]; register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl); register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl); register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl); register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl); register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl); register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl); PPC_io_memory = cpu_register_io_memory(0, PPC_intack_read, PPC_intack_write, NULL); cpu_register_physical_memory(0xBFFFFFF0, 0x4, PPC_io_memory); #if 0 PPC_io_memory = cpu_register_io_memory(0, PPC_XCSR_read, PPC_XCSR_write, NULL); cpu_register_physical_memory(0xFEFF0000, 0x1000, PPC_io_memory); #endif if (usb_enabled) { usb_ohci_init_pci(pci_bus, 3, -1); } m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59); if (m48t59 == NULL) return; sysctrl->nvram = m48t59; nvram.opaque = m48t59; nvram.read_fn = &m48t59_read; nvram.write_fn = &m48t59_write; PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device, kernel_base, kernel_size, kernel_cmdline, initrd_base, initrd_size, 0, graphic_width, graphic_height, graphic_depth); register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); }
1threat
Disable pylint warning E1101 when using enums : <p>I recently came across <a href="http://anthonyfox.io/2017/02/choices-for-choices-in-django-charfields/#option-3" rel="noreferrer">this article</a> by Anthony Fox which shows how to use enums to create the choice set in django CharFields, which I thought was pretty neat.</p> <p>Basically, you create a subclass of Enum:</p> <pre><code>from enum import Enum class ChoiceEnum(Enum): @classmethod def choices(cls): return tuple((x.name, x.value) for x in cls) </code></pre> <p>Which can then be used in your models like so:</p> <pre><code>from .utils import ChoiceEnum class Car(models.Model): class Colors(ChoiceEnum): RED = 'red' WHITE = 'white' BLUE = 'blue' color = models.CharField(max_length=5, choices=Colors.choices(), default=Colors.RED.value) red_cars = Car.objects.filter(color=Car.Colors.RED.value) </code></pre> <p>However, pylint throws a warning whenever you try to access the enum value (<code>Colors.RED.value</code>)</p> <p><code>E1101:Instance of 'str' has no 'value' member</code></p> <p>Is there a way to avoid / disable this warning for every instance of ChoiceEnum?</p> <p><a href="https://stackoverflow.com/questions/35990313/avoid-pylint-warning-e1101-instance-of-has-no-member-for-class-with-dyn">This answer</a> only works on the subclass of <code>ChoiceEnum</code>, not <code>ChoiceEnum</code> itself.</p>
0debug
"sourceMaps is null" in Firefox Developer Edition : <p>In the debugging window of the developer console - I can see all my javascript resources listed, but in of them it just says <code>sourceMaps is null</code>. </p> <p>The resources I'm trying to fetch are some minified jquery, and unminified, but consolidated javascript. The javascript does not contain a sourcemaps comment. </p> <p>Any suggestions for how I'd resolve this?</p>
0debug
Why Xcode provide Tableview if collection view already exist to perform task : <p>why Xcode provide tableview if we perform same action in collectionview for development of app?</p>
0debug
Changing int.parse to int.tryparse C# : Ive been trying to change my int.parse to int.tryparse as I have heard it is a better approach. I keep getting errors I really dont know what I am doing wrong. int index = this.Controls.GetChildIndex(WorkflowStepPanel, false); this.Controls.SetChildIndex(WorkflowStepPanel, int.Parse(WorkflowStepPanel.indexBox.Text));
0debug
static int yuv4_read_header(AVFormatContext *s) { char header[MAX_YUV4_HEADER + 10]; char *tokstart, *tokend, *header_end; int i; AVIOContext *pb = s->pb; int width = -1, height = -1, raten = 0, rated = 0, aspectn = 0, aspectd = 0; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE; enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED; AVStream *st; enum AVFieldOrder field_order; for (i = 0; i < MAX_YUV4_HEADER; i++) { header[i] = avio_r8(pb); if (header[i] == '\n') { header[i + 1] = 0x20; header[i + 2] = 0; break; } } if (i == MAX_YUV4_HEADER) return -1; if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) return -1; header_end = &header[i + 1]; for (tokstart = &header[strlen(Y4M_MAGIC) + 1]; tokstart < header_end; tokstart++) { if (*tokstart == 0x20) continue; switch (*tokstart++) { case 'W': width = strtol(tokstart, &tokend, 10); tokstart = tokend; break; case 'H': height = strtol(tokstart, &tokend, 10); tokstart = tokend; break; case 'C': if (strncmp("420jpeg", tokstart, 7) == 0) { pix_fmt = AV_PIX_FMT_YUV420P; chroma_sample_location = AVCHROMA_LOC_CENTER; } else if (strncmp("420mpeg2", tokstart, 8) == 0) { pix_fmt = AV_PIX_FMT_YUV420P; chroma_sample_location = AVCHROMA_LOC_LEFT; } else if (strncmp("420paldv", tokstart, 8) == 0) { pix_fmt = AV_PIX_FMT_YUV420P; chroma_sample_location = AVCHROMA_LOC_TOPLEFT; } else if (strncmp("420p16", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV420P16; } else if (strncmp("422p16", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV422P16; } else if (strncmp("444p16", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV444P16; } else if (strncmp("420p14", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV420P14; } else if (strncmp("422p14", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV422P14; } else if (strncmp("444p14", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV444P14; } else if (strncmp("420p12", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV420P12; } else if (strncmp("422p12", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV422P12; } else if (strncmp("444p12", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV444P12; } else if (strncmp("420p10", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV420P10; } else if (strncmp("422p10", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV422P10; } else if (strncmp("444p10", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_YUV444P10; } else if (strncmp("420p9", tokstart, 5) == 0) { pix_fmt = AV_PIX_FMT_YUV420P9; } else if (strncmp("422p9", tokstart, 5) == 0) { pix_fmt = AV_PIX_FMT_YUV422P9; } else if (strncmp("444p9", tokstart, 5) == 0) { pix_fmt = AV_PIX_FMT_YUV444P9; } else if (strncmp("420", tokstart, 3) == 0) { pix_fmt = AV_PIX_FMT_YUV420P; chroma_sample_location = AVCHROMA_LOC_CENTER; } else if (strncmp("411", tokstart, 3) == 0) { pix_fmt = AV_PIX_FMT_YUV411P; } else if (strncmp("422", tokstart, 3) == 0) { pix_fmt = AV_PIX_FMT_YUV422P; } else if (strncmp("444alpha", tokstart, 8) == 0 ) { av_log(s, AV_LOG_ERROR, "Cannot handle 4:4:4:4 " "YUV4MPEG stream.\n"); return -1; } else if (strncmp("444", tokstart, 3) == 0) { pix_fmt = AV_PIX_FMT_YUV444P; } else if (strncmp("mono16", tokstart, 6) == 0) { pix_fmt = AV_PIX_FMT_GRAY16; } else if (strncmp("mono", tokstart, 4) == 0) { pix_fmt = AV_PIX_FMT_GRAY8; } else { av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown " "pixel format.\n"); return -1; } while (tokstart < header_end && *tokstart != 0x20) tokstart++; break; case 'I': switch (*tokstart++){ case '?': field_order = AV_FIELD_UNKNOWN; break; case 'p': field_order = AV_FIELD_PROGRESSIVE; break; case 't': field_order = AV_FIELD_TT; break; case 'b': field_order = AV_FIELD_BB; break; case 'm': av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed " "interlaced and non-interlaced frames.\n"); default: av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); return AVERROR(EINVAL); } break; case 'F': sscanf(tokstart, "%d:%d", &raten, &rated); while (tokstart < header_end && *tokstart != 0x20) tokstart++; break; case 'A': sscanf(tokstart, "%d:%d", &aspectn, &aspectd); while (tokstart < header_end && *tokstart != 0x20) tokstart++; break; case 'X': if (strncmp("YSCSS=", tokstart, 6) == 0) { tokstart += 6; if (strncmp("420JPEG", tokstart, 7) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P; else if (strncmp("420MPEG2", tokstart, 8) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P; else if (strncmp("420PALDV", tokstart, 8) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P; else if (strncmp("420P9", tokstart, 5) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P9; else if (strncmp("422P9", tokstart, 5) == 0) alt_pix_fmt = AV_PIX_FMT_YUV422P9; else if (strncmp("444P9", tokstart, 5) == 0) alt_pix_fmt = AV_PIX_FMT_YUV444P9; else if (strncmp("420P10", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P10; else if (strncmp("422P10", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV422P10; else if (strncmp("444P10", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV444P10; else if (strncmp("420P12", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P12; else if (strncmp("422P12", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV422P12; else if (strncmp("444P12", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV444P12; else if (strncmp("420P14", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P14; else if (strncmp("422P14", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV422P14; else if (strncmp("444P14", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV444P14; else if (strncmp("420P16", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV420P16; else if (strncmp("422P16", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV422P16; else if (strncmp("444P16", tokstart, 6) == 0) alt_pix_fmt = AV_PIX_FMT_YUV444P16; else if (strncmp("411", tokstart, 3) == 0) alt_pix_fmt = AV_PIX_FMT_YUV411P; else if (strncmp("422", tokstart, 3) == 0) alt_pix_fmt = AV_PIX_FMT_YUV422P; else if (strncmp("444", tokstart, 3) == 0) alt_pix_fmt = AV_PIX_FMT_YUV444P; } while (tokstart < header_end && *tokstart != 0x20) tokstart++; break; } } if (width == -1 || height == -1) { av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); return -1; } if (pix_fmt == AV_PIX_FMT_NONE) { if (alt_pix_fmt == AV_PIX_FMT_NONE) pix_fmt = AV_PIX_FMT_YUV420P; else pix_fmt = alt_pix_fmt; } if (raten <= 0 || rated <= 0) { unknown raten = 25; rated = 1; } if (aspectn == 0 && aspectd == 0) { unknown aspectd = 1; } st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->width = width; st->codec->height = height; av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1); avpriv_set_pts_info(st, 64, rated, raten); st->avg_frame_rate = av_inv_q(st->time_base); st->codec->pix_fmt = pix_fmt; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; st->sample_aspect_ratio = (AVRational){ aspectn, aspectd }; st->codec->chroma_sample_location = chroma_sample_location; st->codec->field_order = field_order; return 0; }
1threat
how to print only rgb value in console.log in nodejs get-image colors library? : <p>It's an array of object.I want to print only rgb value so that i can match it with other rgb value in if else statement. plz help.</p> <pre><code> Color { _rgb: [ 4, 4, 4, 1, _clipped: false ] } </code></pre>
0debug
How do I generate .d.ts typings from Flow code? : <p>I have enabled Flow on a JavaScript project I am developing. Since I am putting in the effort to providing type annotations, I would really like to generate <strong>*.d.ts</strong> files so the broader TypeScript community can also have type information.</p> <p>How can I generate <strong>*.d.ts</strong> type definition files from Flow-annotated JavaScript?</p>
0debug
Backpropagation in Pooling Layer (Subsamplig layer) in CNN : <p>My doubt is how do I backpropagate error in the Pooling layer, because when I calculate the derivative, there is only 1 element of 4 (for example, when using a 2x2 pooling kernel) that affects the result of the feedforward.</p>
0debug
static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, TCGMemOpIdx oi, bool is_64) { TCGMemOp memop = get_memop(oi); #ifdef CONFIG_SOFTMMU unsigned memi = get_mmuidx(oi); TCGReg addrz, param; tcg_insn_unit *func; tcg_insn_unit *label_ptr; addrz = tcg_out_tlb_load(s, addr, memi, memop & MO_SIZE, offsetof(CPUTLBEntry, addr_read)); label_ptr = s->code_ptr; tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT | (TARGET_LONG_BITS == 64 ? BPCC_XCC : BPCC_ICC), 0); tcg_out_ldst_rr(s, data, addrz, TCG_REG_O1, qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); param = TCG_REG_O1; if (!SPARC64 && TARGET_LONG_BITS == 64) { param++; } tcg_out_mov(s, TCG_TYPE_REG, param++, addr); if ((memop & MO_SSIZE) == MO_SL) { func = qemu_ld_trampoline[memop & (MO_BSWAP | MO_SIZE)]; } else { func = qemu_ld_trampoline[memop & (MO_BSWAP | MO_SSIZE)]; } assert(func != NULL); tcg_out_call_nodelay(s, func); tcg_out_movi(s, TCG_TYPE_I32, param, oi); if (SPARC64) { if (is_64 && (memop & MO_SSIZE) == MO_SL) { tcg_out_arithi(s, data, TCG_REG_O0, 0, SHIFT_SRA); } else { tcg_out_mov(s, TCG_TYPE_REG, data, TCG_REG_O0); } } else { if ((memop & MO_SIZE) == MO_64) { tcg_out_arithi(s, TCG_REG_O0, TCG_REG_O0, 32, SHIFT_SLLX); tcg_out_arithi(s, TCG_REG_O1, TCG_REG_O1, 0, SHIFT_SRL); tcg_out_arith(s, data, TCG_REG_O0, TCG_REG_O1, ARITH_OR); } else if (is_64) { tcg_out_arithi(s, data, TCG_REG_O1, 0, memop & MO_SIGN ? SHIFT_SRA : SHIFT_SRL); } else { tcg_out_mov(s, TCG_TYPE_I32, data, TCG_REG_O1); } } *label_ptr |= INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #else if (SPARC64 && TARGET_LONG_BITS == 32) { tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL); addr = TCG_REG_T1; } tcg_out_ldst_rr(s, data, addr, (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0), qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); #endif }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *k) { if (keysym < MAX_NORMAL_KEYCODE) { trace_keymap_add("normal", keysym, keycode, line); k->keysym2keycode[keysym] = keycode; } else { if (k->extra_count >= MAX_EXTRA_COUNT) { fprintf(stderr, "Warning: Could not assign keysym %s (0x%x)" " because of memory constraints.\n", line, keysym); } else { trace_keymap_add("extra", keysym, keycode, line); k->keysym2keycode_extra[k->extra_count]. keysym = keysym; k->keysym2keycode_extra[k->extra_count]. keycode = keycode; k->extra_count++; } } }
1threat
When i am creating trigger for finding the grade of Student based on is AVG (SQL SERVER) : [enter image description here][1] [1]: https://i.stack.imgur.com/DFxKR.png Error Kindly help me out !! Urgent
0debug
what is the error in the following fectorial find c program? : my logic is entered num store into temp variable and find factorial using temp = temp * (num-i) in side while until num is grater than 0 and initially i =1 , but I get problem that my loop goes in to infinite loop how to solve this problem ? #include <stdio.h> int main() { int num,temp,i; printf("Enter a Num who's factorial is need to be find : "); scanf("%d",&num); printf("num = %d\n",num); temp = num; printf("temp = %d\n",temp); i=1; while(num > 0) { temp = temp * (num-i); i++; printf(" i = %d\n ",i); } printf("fact = %d \n ",temp); return 0; }
0debug
OpenCV Python: Normalize image : <p>I'm new to OpenCV. I want to do some preprocessing related to normalization. I want to normalize my image to a certain size. The result of the following code gives me a black image. Can someone point me to what exactly am I doing wrong? The image I am inputting is a black/white image</p> <pre><code>import cv2 as cv import numpy as np img = cv.imread(path) normalizedImg = np.zeros((800, 800)) cv.normalize(img, normalizedImg, 0, 255, cv.NORM_MINMAX) cv.imshow('dst_rt', self.normalizedImg) cv.waitKey(0) cv.destroyAllWindows() </code></pre>
0debug
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags, off_t *size, Error **errp) { char buf[256]; uint64_t magic, s; int rc; TRACE("Receiving negotiation."); rc = -EINVAL; if (read_sync(ioc, buf, 8) != 8) { error_setg(errp, "Failed to read data"); goto fail; } buf[8] = '\0'; if (strlen(buf) == 0) { error_setg(errp, "Server connection closed unexpectedly"); goto fail; } TRACE("Magic is %c%c%c%c%c%c%c%c", qemu_isprint(buf[0]) ? buf[0] : '.', qemu_isprint(buf[1]) ? buf[1] : '.', qemu_isprint(buf[2]) ? buf[2] : '.', qemu_isprint(buf[3]) ? buf[3] : '.', qemu_isprint(buf[4]) ? buf[4] : '.', qemu_isprint(buf[5]) ? buf[5] : '.', qemu_isprint(buf[6]) ? buf[6] : '.', qemu_isprint(buf[7]) ? buf[7] : '.'); if (memcmp(buf, "NBDMAGIC", 8) != 0) { error_setg(errp, "Invalid magic received"); goto fail; } if (read_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to read magic"); goto fail; } magic = be64_to_cpu(magic); TRACE("Magic is 0x%" PRIx64, magic); if (magic == NBD_OPTS_MAGIC) { uint32_t clientflags = 0; uint32_t opt; uint32_t namesize; uint16_t globalflags; uint16_t exportflags; if (read_sync(ioc, &globalflags, sizeof(globalflags)) != sizeof(globalflags)) { error_setg(errp, "Failed to read server flags"); goto fail; } *flags = be16_to_cpu(globalflags) << 16; if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { TRACE("Server supports fixed new style"); clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE; } if (write_sync(ioc, &clientflags, sizeof(clientflags)) != sizeof(clientflags)) { error_setg(errp, "Failed to send clientflags field"); goto fail; } if (!name) { error_setg(errp, "Server requires an export name"); goto fail; } magic = cpu_to_be64(magic); if (write_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to send export name magic"); goto fail; } opt = cpu_to_be32(NBD_OPT_EXPORT_NAME); if (write_sync(ioc, &opt, sizeof(opt)) != sizeof(opt)) { error_setg(errp, "Failed to send export name option number"); goto fail; } namesize = cpu_to_be32(strlen(name)); if (write_sync(ioc, &namesize, sizeof(namesize)) != sizeof(namesize)) { error_setg(errp, "Failed to send export name length"); goto fail; } if (write_sync(ioc, (char *)name, strlen(name)) != strlen(name)) { error_setg(errp, "Failed to send export name"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, &exportflags, sizeof(exportflags)) != sizeof(exportflags)) { error_setg(errp, "Failed to read export flags"); goto fail; } *flags |= be16_to_cpu(exportflags); } else if (magic == NBD_CLIENT_MAGIC) { if (name) { error_setg(errp, "Server does not support export names"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, flags, sizeof(*flags)) != sizeof(*flags)) { error_setg(errp, "Failed to read export flags"); goto fail; } *flags = be32_to_cpup(flags); } else { error_setg(errp, "Bad magic received"); goto fail; } if (read_sync(ioc, &buf, 124) != 124) { error_setg(errp, "Failed to read reserved block"); goto fail; } rc = 0; fail: return rc; }
1threat
Unity c# Array vs Static List : <p>I'm working on a Unity game and I'm trying to write some idiomatic c# code.</p> <p>What's the preferable way to write a collection of objects whose size will never change?</p> <p><code> static List&lt;int&gt; myList = new List&lt;int&gt;(new List&lt;int&gt; { 1, 2, 3 }); </code></p> <p>or </p> <p><code> myList[int]= new int[] { 1, 2, 3 }; </code></p>
0debug
set initial react component state in constructor or componentWillMount? : <p>In react components is it preferred to set the initial state in the constructor() or componentWillMount()?</p> <pre><code>export default class MyComponent extends React.Component{ constructor(props){ super(props); this.setState({key: value}); } } </code></pre> <p>or</p> <pre><code>export default class MyComponent extends React.Component{ componentWillMount(props){ this.setState({key: value}); } } </code></pre>
0debug
WATSON - BLUEMIX - CONVERSATION : SOY NUEVO CON ESTA TECNOLOGIA. Quiero utlizar la API Conversation de WATSON en una aplicacion .NET. ¿Donde puedo conseguir ejemplos de llamadas a WATSON CLOUD SERVICES desde .NET? Gracias
0debug
What does ** mean in Python? : <p>I have looked all over Ecosia and SO. I cannot find the answer to this question:</p> <p>What is <code>**</code> used for in Python?</p> <p>Like, <code>exampleVariable = 5 ** 5</code></p> <p>Thanks for any help!</p>
0debug
int socket_connect(SocketAddress *addr, Error **errp, NonBlockingConnectHandler *callback, void *opaque) { QemuOpts *opts; int fd; opts = qemu_opts_create_nofail(&socket_optslist); switch (addr->kind) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); fd = inet_connect_opts(opts, errp, callback, opaque); break; case SOCKET_ADDRESS_KIND_UNIX: qemu_opt_set(opts, "path", addr->q_unix->path); fd = unix_connect_opts(opts, errp, callback, opaque); break; case SOCKET_ADDRESS_KIND_FD: fd = monitor_get_fd(cur_mon, addr->fd->str, errp); if (callback) { callback(fd, opaque); } break; default: abort(); } qemu_opts_del(opts); return fd; }
1threat
static int qemu_paio_submit(struct qemu_paiocb *aiocb, int type) { aiocb->aio_type = type; aiocb->ret = -EINPROGRESS; aiocb->active = 0; mutex_lock(&lock); if (idle_threads == 0 && cur_threads < max_threads) spawn_thread(); TAILQ_INSERT_TAIL(&request_list, aiocb, node); mutex_unlock(&lock); cond_signal(&cond); return 0; }
1threat
Testing a @KafkaListener using Spring Embedded Kafka : <p>I am trying to write a unit test for a Kafka listener that I am developing using Spring Boot 2.x. Being a unit test, I don't want to start up a full Kafka server an instance of Zookeeper. So, I decided to use Spring Embedded Kafka.</p> <p>The definition of my listener is very basic.</p> <pre><code>@Component public class Listener { private final CountDownLatch latch; @Autowired public Listener(CountDownLatch latch) { this.latch = latch; } @KafkaListener(topics = "sample-topic") public void listen(String message) { latch.countDown(); } } </code></pre> <p>Also the test, that verifies the <code>latch</code> counter to be equal to zero after receiving a message, is very easy.</p> <pre><code>@RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @EmbeddedKafka(topics = { "sample-topic" }) @TestPropertySource(properties = { "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}" }) public class ListenerTest { @Autowired private KafkaEmbedded embeddedKafka; @Autowired private CountDownLatch latch; private KafkaTemplate&lt;Integer, String&gt; producer; @Before public void setUp() { this.producer = buildKafkaTemplate(); this.producer.setDefaultTopic("sample-topic"); } private KafkaTemplate&lt;Integer, String&gt; buildKafkaTemplate() { Map&lt;String, Object&gt; senderProps = KafkaTestUtils.producerProps(embeddedKafka); ProducerFactory&lt;Integer, String&gt; pf = new DefaultKafkaProducerFactory&lt;&gt;(senderProps); return new KafkaTemplate&lt;&gt;(pf); } @Test public void listenerShouldConsumeMessages() throws InterruptedException { // Given producer.sendDefault(1, "Hello world"); // Then assertThat(latch.await(10L, TimeUnit.SECONDS)).isTrue(); } } </code></pre> <p>Unfortunately, the test fails and I cannot understand why. Is it possible to use an instance of <code>KafkaEmbedded</code> to test a method marked with the annotation <code>@KafkaListener</code>?</p> <p>All the code is shared in my GitHub repository <a href="https://github.com/rcardin/kafka-listener" rel="noreferrer">kafka-listener</a>.</p> <p>Thanks to all.</p>
0debug
def specified_element(nums, N): result = [i[N] for i in nums] return result
0debug
Android getMaxAddressLineIndex returns 0 for line 1 : <p>For some reason the implementation of getMaxAddressLineIndex has recently changed. Now this method returns 0 for line 1. </p> <p>I have an existing code, which used to work: <code>i&lt;address.getMaxAddressLineIndex(</code>). However, it is broken somehow. </p> <p><a href="https://i.stack.imgur.com/HbEEp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HbEEp.png" alt="enter image description here"></a></p> <p>I don't know if it is due to the new Google Api or something else. </p> <p>Can someone please confirm me here what is going on?</p>
0debug
Angular2: convert array to Observable : <p>I have a component that gets the data from a service via http, the problem is that I don't want to hit the API backend every time I show this component. I want my service to check if the data is in memory, if it is, return an observable with the array in memory, and if not, make the http request.</p> <p>My component</p> <pre><code>import {Component, OnInit } from 'angular2/core'; import {Router} from 'angular2/router'; import {Contact} from './contact'; import {ContactService} from './contact.service'; @Component({ selector: 'contacts', templateUrl: 'app/contacts/contacts.component.html' }) export class ContactsComponent implements OnInit { contacts: Contact[]; errorMessage: string; constructor( private router: Router, private contactService: ContactService) { } ngOnInit() { this.getContacts(); } getContacts() { this.contactService.getContacts() .subscribe( contacts =&gt; this.contacts = contacts, error =&gt; this.errorMessage = &lt;any&gt;error ); } } </code></pre> <p>My service</p> <pre><code>import {Injectable} from 'angular2/core'; import {Http, Response, Headers, RequestOptions} from 'angular2/http'; import {Contact} from './contact'; import {Observable} from 'rxjs/Observable'; @Injectable() export class ContactService { private contacts: Array&lt;Contact&gt; = null; constructor (private http: Http) { } getContacts() { // Check first if contacts == null // if not, return Observable(this.contacts)? &lt;-- How to? return this.http.get(url) .map(res =&gt; &lt;Contact[]&gt; res.json()) .do(contacts =&gt; { this.contacts = contacts; console.log(contacts); }) // eyeball results in the console .catch(this.handleError); } private handleError (error: Response) { // in a real world app, we may send the server to some remote logging infrastructure // instead of just logging it to the console console.error(error); return Observable.throw(error.json().error || 'Server error'); } } </code></pre>
0debug
"Syntax error: missing )" on jQuery listener : <p>Why do I get <code>SyntaxError: missing ) after argument list</code> with the following code?:</p> <pre><code>$('#login-form').on('submit', function(event){ event.preventDefault(); console.log("form submitted!"); // sanity check $('#table').load('http://127.0.0.1:8000/results',function(){ $('#go_back').remove(); }}); </code></pre>
0debug
how to create this UI in xml : I'm working on a recyclerView and there is a problem for me to make it's view: in the view I have an imageView but righ-top corner and left-bottom corner have cuts. How can I do this? Thank you. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/4hieJ.png
0debug
how to get the key of an item of the array inside foreach loop in php : <p>Below is the example of the array that I have. </p> <pre><code> Array ( [952] =&gt; Array ( [Date] =&gt; 2016-06-23 01:55:17 [SValues] =&gt; Array ( [total] =&gt; 1 [Name] =&gt; Name [OverAge] =&gt; No)) [91] =&gt; Array ( [Date] =&gt; 2016-06-23 01:55:17 [SValues] =&gt; Array ( [total] =&gt; 1 [Name] =&gt; Name [OverAge] =&gt; No)) [83] =&gt; Array ( [Date] =&gt; 2016-06-23 01:55:17 [SValues] =&gt; Array ( [total] =&gt; 1 [Name] =&gt; Name [OverAge] =&gt; No))) </code></pre> <p>And then, I put this array inside the foreach loop.</p> <pre><code>foreach($the-main-array as $item) { //I want to get the key of the item here (952,91,83) } </code></pre> <p>So how can I get the key of the item inside the loop?</p> <p>Please help me. Thanks in advance.</p>
0debug
static void reschedule_dma(void *opaque) { DMAAIOCB *dbs = (DMAAIOCB *)opaque; qemu_bh_delete(dbs->bh); dbs->bh = NULL; dma_bdrv_cb(dbs, 0); }
1threat
static int vhdx_create(const char *filename, QEMUOptionParameter *options, Error **errp) { int ret = 0; uint64_t image_size = (uint64_t) 2 * GiB; uint32_t log_size = 1 * MiB; uint32_t block_size = 0; uint64_t signature; uint64_t metadata_offset; bool use_zero_blocks = false; gunichar2 *creator = NULL; glong creator_items; BlockDriverState *bs; const char *type = NULL; VHDXImageType image_type; Error *local_err = NULL; while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { image_size = options->value.n; } else if (!strcmp(options->name, VHDX_BLOCK_OPT_LOG_SIZE)) { log_size = options->value.n; } else if (!strcmp(options->name, VHDX_BLOCK_OPT_BLOCK_SIZE)) { block_size = options->value.n; } else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) { type = options->value.s; } else if (!strcmp(options->name, VHDX_BLOCK_OPT_ZERO)) { use_zero_blocks = options->value.n != 0; } options++; } if (image_size > VHDX_MAX_IMAGE_SIZE) { error_setg_errno(errp, EINVAL, "Image size too large; max of 64TB"); ret = -EINVAL; goto exit; } if (type == NULL) { type = "dynamic"; } if (!strcmp(type, "dynamic")) { image_type = VHDX_TYPE_DYNAMIC; } else if (!strcmp(type, "fixed")) { image_type = VHDX_TYPE_FIXED; } else if (!strcmp(type, "differencing")) { error_setg_errno(errp, ENOTSUP, "Differencing files not yet supported"); ret = -ENOTSUP; goto exit; } else { ret = -EINVAL; goto exit; } if (block_size == 0) { if (image_size > 32 * TiB) { block_size = 64 * MiB; } else if (image_size > (uint64_t) 100 * GiB) { block_size = 32 * MiB; } else if (image_size > 1 * GiB) { block_size = 16 * MiB; } else { block_size = 8 * MiB; } } log_size = ROUND_UP(log_size, MiB); block_size = ROUND_UP(block_size, MiB); block_size = block_size > VHDX_BLOCK_SIZE_MAX ? VHDX_BLOCK_SIZE_MAX : block_size; ret = bdrv_create_file(filename, options, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } ret = bdrv_file_open(&bs, filename, NULL, NULL, BDRV_O_RDWR, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } creator = g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL, &creator_items, NULL); signature = cpu_to_le64(VHDX_FILE_SIGNATURE); bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature)); if (ret < 0) { goto delete_and_exit; } if (creator) { bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET + sizeof(signature), creator, creator_items * sizeof(gunichar2)); if (ret < 0) { goto delete_and_exit; } } ret = vhdx_create_new_headers(bs, image_size, log_size); if (ret < 0) { goto delete_and_exit; } ret = vhdx_create_new_region_table(bs, image_size, block_size, 512, log_size, use_zero_blocks, image_type, &metadata_offset); if (ret < 0) { goto delete_and_exit; } ret = vhdx_create_new_metadata(bs, image_size, block_size, 512, metadata_offset, image_type); if (ret < 0) { goto delete_and_exit; } delete_and_exit: bdrv_unref(bs); exit: g_free(creator); return ret; }
1threat
static void gen_rdhwr(DisasContext *ctx, int rt, int rd, int sel) { TCGv t0; #if !defined(CONFIG_USER_ONLY) check_insn(ctx, ISA_MIPS32R2); #endif t0 = tcg_temp_new(); switch (rd) { case 0: gen_helper_rdhwr_cpunum(t0, cpu_env); gen_store_gpr(t0, rt); break; case 1: gen_helper_rdhwr_synci_step(t0, cpu_env); gen_store_gpr(t0, rt); break; case 2: if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_rdhwr_cc(t0, cpu_env); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); } gen_store_gpr(t0, rt); gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; break; case 3: gen_helper_rdhwr_ccres(t0, cpu_env); gen_store_gpr(t0, rt); break; case 4: check_insn(ctx, ISA_MIPS32R6); if (sel != 0) { generate_exception(ctx, EXCP_RI); } gen_helper_rdhwr_performance(t0, cpu_env); gen_store_gpr(t0, rt); break; case 5: check_insn(ctx, ISA_MIPS32R6); gen_helper_rdhwr_xnp(t0, cpu_env); gen_store_gpr(t0, rt); break; case 29: #if defined(CONFIG_USER_ONLY) tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUMIPSState, active_tc.CP0_UserLocal)); gen_store_gpr(t0, rt); break; #else if ((ctx->hflags & MIPS_HFLAG_CP0) || (ctx->hflags & MIPS_HFLAG_HWRENA_ULR)) { tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUMIPSState, active_tc.CP0_UserLocal)); gen_store_gpr(t0, rt); } else { generate_exception_end(ctx, EXCP_RI); } break; #endif default: MIPS_INVAL("rdhwr"); generate_exception_end(ctx, EXCP_RI); break; } tcg_temp_free(t0); }
1threat
static void dump_json_image_check(ImageCheck *check, bool quiet) { QString *str; QObject *obj; Visitor *v = qmp_output_visitor_new(&obj); visit_type_ImageCheck(v, NULL, &check, &error_abort); visit_complete(v, &obj); str = qobject_to_json_pretty(obj); assert(str != NULL); qprintf(quiet, "%s\n", qstring_get_str(str)); qobject_decref(obj); visit_free(v); QDECREF(str); }
1threat
Royal Free Flash Case Study 3–Pleuritic Chest Pa is showing ''Royal Free Flash Case Study 3 – Pleuritic Chest Pa'' at the time of excel export : When I am tring to download Project Name, i m getting different character for Special charter at the time excel export. protected void lnkExportToExcel_Click(object sender, EventArgs e) { //INS1-219 DataTable dt1 = DataHelper.ExecuteQuery(Session["strForExcelReport"].ToString()); DataTable dt3 = new DataTable(); dt3.Columns.Add("Project Code"); dt3.Columns.Add("Project Name"); dt3.Columns.Add("Client"); dt3.Columns.Add("Status"); dt3.Columns.Add("Sale Date"); dt3.Columns.Add("Project Type"); dt3.Columns.Add("Sales Agent"); dt3.Columns.Add("Project Incharge"); dt3.Columns.Add("Project Cost"); dt3.Columns.Add("Planned Cost"); dt3.Columns.Add("Additional Cost"); dt3.Columns.Add("Payment Raised"); dt3.Columns.Add("Payment Received"); dt3.Columns.Add("Planned Start Date"); dt3.Columns.Add("Revised Start Date"); dt3.Columns.Add("Actual Start Date"); dt3.Columns.Add("Planned End Date"); dt3.Columns.Add("Revised End Date"); dt3.Columns.Add("Actual End Date"); dt3.Columns.Add("Planned Efforts(Hrs.)"); dt3.Columns.Add("Revised Efforts(Hrs.)"); dt3.Columns.Add("Actual Efforts(Hrs.)"); dt3.Columns.Add("% TimeLine"); dt3.Columns.Add("% Effort Plan"); dt3.Columns.Add("% Revised"); dt3.Columns.Add("% Overall"); dt3.Columns.Add("Profitibility Number"); foreach (DataRow dr in dt1.Rows) { DateTime dtNullDate = new DateTime(2008, 1, 1); DateTime dtPlannedStart, dtPlannedEnd, dtActualStart, dtActualEnd; double dblPlanedDays = 0, dblActualDays = 0; double dblPlannedEffort = 0, dblCalculatedEffort = 0, dblPercentCompleteEffort = 0, dblPercentCompleteTimeLine = 0, dblPercentCompleteOverAll = 0, dblRevisedEffort = 0; DataRow drnew = dt3.NewRow(); TimeSpan oPlannedSpan = TimeSpan.Zero; TimeSpan oActualSpan = TimeSpan.Zero; string[] strArr = null; drnew["Project Code"] = dr["ProjectCode"].ToString(); drnew["Project Name"] = dr["ProjectName"].ToString(); drnew["Client"] = dr["OrganizationName"].ToString(); string PercentOverallComplete = dr["PercentageComplete_Overall"].ToString(); drnew["Status"] = dr["ProjectStatus"].ToString(); DateTime SaleDate = Convert.ToDateTime(dr["CreatedOn"]); drnew["Sale Date"] = SaleDate.ToString("dd-MMM-yyyy"); drnew["Project Type"] = dr["CustomProjectTypeName"].ToString(); drnew["Sales Agent"] = dr["SalesAgentFullName"].ToString(); drnew["Project Incharge"] = dr["UserFullName"].ToString(); drnew["Project Cost"] = TypeConvert.IsNullDecimal(dr["ProjectCost"], 0).ToString("N", en); drnew["Planned Cost"] = dr["ProjectCost"].ToString(); string sql = "EXEC SPGetProjectCostClassification " + dr["ProjectID"].ToString(); DataTable dtProjCost = DataHelper.ExecuteQuery(sql); if (dtProjCost != null) { drnew["Planned Cost"] = TypeConvert.IsNullDecimal(dtProjCost.Rows[0]["ProjectCostInitial"], 0).ToString("N", en); drnew["Additional Cost"] = TypeConvert.IsNullDecimal(dtProjCost.Rows[0]["AdditionalCost"], 0).ToString("N", en); } string RaisedAmt = dr["InvoiceRasiedAmount"].ToString(); drnew["Payment Raised"] = RaisedAmt; string receivedAmt = dr["PaymentReceived"].ToString(); strArr = TypeConvert.IsNullString(RaisedAmt, string.Empty).Split(' '); if (strArr.Length > 1) { drnew["Payment Received"] = strArr[0] + ' ' + receivedAmt; } else { drnew["Payment Received"] = receivedAmt; } DateTime PlannedStartDate = Convert.ToDateTime(dr["PlannedStartDate"]); drnew["Planned Start Date"] = PlannedStartDate.ToString("dd-MMM-yyyy"); if (drnew["Planned Start Date"].ToString() == "01-Jan-2008") { drnew["Planned Start Date"] = ""; } DateTime RevisedStartDate = Convert.ToDateTime(dr["AllocatedStartDate"]); drnew["Revised Start Date"] = RevisedStartDate.ToString("dd-MMM-yyyy"); if (drnew["Revised Start Date"].ToString() == "01-Jan-2008") { drnew["Revised Start Date"] = ""; } DateTime ActualStartDate = Convert.ToDateTime(dr["ActualStartDate"]); drnew["Actual Start Date"] = ActualStartDate.ToString("dd-MMM-yyyy"); if (drnew["Actual Start Date"].ToString() == "01-Jan-2008") { drnew["Actual Start Date"] = ""; } DateTime PlannedEndDate = Convert.ToDateTime(dr["PlannedEndDate"]); drnew["Planned End Date"] = PlannedEndDate.ToString("dd-MMM-yyyy"); if (drnew["Planned End Date"].ToString() == "01-Jan-2008") { drnew["Planned End Date"] = ""; } DateTime RevisedEndDate = Convert.ToDateTime(dr["AllocatedEndDate"]); drnew["Revised End Date"] = RevisedEndDate.ToString("dd-MMM-yyyy"); if (drnew["Revised End Date"].ToString() == "01-Jan-2008") { drnew["Revised End Date"] = ""; } DateTime ActualEndDate = Convert.ToDateTime(dr["ActualEndDate"]); drnew["Actual End Date"] = ActualEndDate.ToString("dd-MMM-yyyy"); if (drnew["Actual End Date"].ToString() == "01-Jan-2008") { drnew["Actual End Date"] = ""; } drnew["Planned Efforts(Hrs.)"] = dr["PlannedEfforts"].ToString(); drnew["Revised Efforts(Hrs.)"] = dr["AllocatedEfforts"].ToString(); string ActualEfforts = dr["ActualTime"].ToString(); if (ActualEfforts != "" && ActualEfforts != "0") { string[] tokens = ActualEfforts.Split(':'); if (tokens.Length == 2) { int HourValue = Convert.ToInt32(tokens[0]); int MinuteValue = Convert.ToInt32(tokens[1]); double MinutesInDecimalFormat = Convert.ToDouble(MinuteValue)/60; if (MinutesInDecimalFormat != 0) { string Minute = String.Format("{0:0.00}", MinutesInDecimalFormat); string[] tokensExcel = Minute.ToString().Split('.'); drnew["Actual Efforts(Hrs.)"] = HourValue + "." + tokensExcel[1]; } else { drnew["Actual Efforts(Hrs.)"] = HourValue + "." + MinutesInDecimalFormat; } } } dblPlanedDays = Convert.ToDateTime(dr["PlannedEndDate"]).Subtract(Convert.ToDateTime(dr["PlannedStartDate"])).TotalDays; oPlannedSpan = Convert.ToDateTime(dr["PlannedEndDate"]).Subtract(Convert.ToDateTime(dr["PlannedStartDate"])); dtActualStart = (dr["ActualStartDate"] is DBNull) ? DateTime.Now : Convert.ToDateTime(dr["ActualStartDate"]); if (dr["ActualEndDate"] is DBNull || (!(dr["ActualEndDate"] is DBNull) && Convert.ToDateTime(dr["ActualEndDate"]) == MiscConstants.DEFAULT_DATE)) dtActualEnd = DateTime.Now; else dtActualEnd = Convert.ToDateTime(dr["ActualEndDate"]); if (dtActualStart != dtNullDate) { oActualSpan = dtActualEnd.Subtract(dtActualStart); if (oPlannedSpan.Ticks != 0) { if (oActualSpan.Ticks >= oPlannedSpan.Ticks) dblPercentCompleteTimeLine = (100 + (((oActualSpan.Ticks - oPlannedSpan.Ticks)*100)/ oPlannedSpan.Ticks)); else dblPercentCompleteTimeLine = ((oActualSpan.Ticks*100)/oPlannedSpan.Ticks); } } else { dblPercentCompleteTimeLine = 0; } drnew["% TimeLine"] = dblPercentCompleteTimeLine.ToString("F"); dblPlannedEffort = Convert.ToDouble(dr["PlannedEfforts"]); dblRevisedEffort = Convert.ToDouble(dr["AllocatedEfforts"]); dblCalculatedEffort = Convert.ToDouble(dr["ActualTime"].ToString().Replace(':', '.'));// Convert.ToDouble(actualTime); double dblPercentCompleteEffortRevised = 0; if (dblPlannedEffort > 0) { if (dblCalculatedEffort > dblPlannedEffort) dblPercentCompleteEffort = (100 + (((dblCalculatedEffort - dblPlannedEffort) * 100) / dblPlannedEffort)); else dblPercentCompleteEffort = ((dblCalculatedEffort * 100) / dblPlannedEffort); } else { dblPercentCompleteEffort = 100; } drnew["% Effort Plan"] = dblPercentCompleteEffort.ToString("F"); if (dblRevisedEffort > 0) { if (dblCalculatedEffort > dblRevisedEffort) dblPercentCompleteEffortRevised = (100 + (((dblCalculatedEffort - dblRevisedEffort) * 100) / dblRevisedEffort)); else dblPercentCompleteEffortRevised = ((dblCalculatedEffort * 100) / dblRevisedEffort); } else { dblPercentCompleteEffortRevised = 100; } drnew["% Revised"] = dblPercentCompleteEffortRevised.ToString("F"); drnew["% Overall"] = PercentOverallComplete; decimal totResourceCost = TypeConvert.IsNullDecimal(dr["ResourceCostOffshore"].ToString(), 0) + TypeConvert.IsNullDecimal(dr["ResourceCostOnSite"].ToString(), 0); decimal vmsCost = TypeConvert.IsNullDecimal(dr["OutSourcingCost"].ToString(), 0) + TypeConvert.IsNullDecimal(dr["DirectCost"].ToString(), 0); decimal grandTotalCogs = totResourceCost + vmsCost; if ((TypeConvert.IsNullDecimal(dr["ProjectCost"].ToString(), 0)).ToString("0.00") == "0.00") { drnew["Profitibility Number"] = "0.00%"; } else { decimal currentCOGS = (((grandTotalCogs) / (TypeConvert.IsNullDecimal(dr["ProjectCost"].ToString(), 0))) * 100); decimal percentComplete = TypeConvert.IsNullDecimal(PercentOverallComplete, 0); drnew["Profitibility Number"] = ((percentComplete > 0) ? currentCOGS * ((Convert.ToDecimal(100)) - percentComplete) / percentComplete + currentCOGS : 0).ToString("0.00") + "%"; } dt3.Rows.Add(drnew); } string attachment = "attachment; filename=ProjectInHandDetailsList_" + DateTime.Now.ToString("dd MMM yyyy") + ".xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/vnd.ms-excel"; string tab = ""; foreach (DataColumn dc in dt3.Columns) { Response.Write(tab + dc.ColumnName); tab = "\t"; } Response.Write("\n"); int i; foreach (DataRow dr in dt3.Rows) { tab = ""; for (i = 0; i < dt3.Columns.Count; i++) { Response.Write(tab + dr[i].ToString()); tab = "\t"; } Response.Write("\n"); } Response.End(); //END INS1-219 }
0debug
Installation failed with message Invalid File : <blockquote> <p>Installation failed with message Invalid File: K:\project\app\build\intermediates\split-apk\with_ImageProcessor\debug\slices\slice_0.apk. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.</p> <p>WARNING: Uninstalling will remove the application data!</p> <p>Do you want to uninstall the existing application?</p> </blockquote> <p>i am running my project in android studio 2.3 beta 3 .</p>
0debug
How to calculate sum of a specific model(attributes) in collection in Backbone : I am new to Backbone and facing one issue in which i need to calculate the specific values of my models inside my collection. For the reference i am pasting the collection of accounts, from which i need to calculate the sum of acquisitionCost, units and netGainLoss of all the models, i.e after calulating the acquisitionCost i should get: 1900 and one thing we need to take care is the values are coming in string form like shown in the json. { "accounts": [{ "accountNumber": "AS10000642", "assets": { "assetName": "ABCDEF GHIJKLM", "isin": "GB0008533564", "grossProfit": { "acquisitionCost": "500", "units": "10", "netGainLoss": "20" } } }, { "accountNumber": "AS10000642", "assets": { "assetName": "ABCDEF GHIJKLM", "isin": "GB0008533564", "grossProfit": { "acquisitionCost": "1000", "units": "10", "netGainLoss": "20" } } }, { "accountNumber": "AS10000407", "assets": { "assetName": "ABCDEF GHIJKLM", "isin": "GB0008533564", "grossProfit": { "acquisitionCost": "400", "units": "10", "netGainLoss": "20" } } } ] } Please assist me with this . thanks in advance.
0debug
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_shops' in 'where clause' (SQL: select * from `shops` where `user_shops` = 233 limit 1) : [Error Image ][1]**Working on a Multi vendor website . Suddenly got this error when shop/vendor user want to login no problem normal user** Here two type user one is vendor or ShopOwner/ another one normal Customer when vendor want to logging got this error. But normal user no Problem facing for login. Added new column but problem is continue SQL integrity Error. **Here is Login Controller.** > Details for Login Controller public function userlogin(Request $request){ $data = Cart::getContent(); $this->validate($request, [ 'email' => 'required', 'password' => 'required', ],[ 'email.required' => 'Email not matched with Database!', 'password.required' => 'Password not matched with Database!', ]); $checkUserInput = filter_var($request->input('email'), FILTER_VALIDATE_EMAIL)?'email': 'username'; $user = Auth::guard('web')->attempt([$checkUserInput => $request->email,'password'=>$request->password]); if($user == 'true'){ if(Auth::user()->is_activated == 1){ if(count($data)>0){ if(count(Cart::session(Auth::user()->id)->getContent())>0){ foreach ($data as $key => $value) { if(!Cart::session(Auth::user()->id)->get($value->id) ){ Cart::session(Auth::user()->id)->add($value->id, $value->name,$value->price,$value->quantity, $value->image,array('color' => $value->attributes->color)); }else{ Cart::session(Auth::user()->id)->update($value->id, array( 'quantity' => array( 'relative' => false, 'value' => $request->quantity ), 'attributes' => array( 'color' => $value->attributes->color ), )); } } }else{ foreach ($data as $key => $value) { Cart::session(Auth::user()->id)->add($value->id, $value->name,$value->price,$value->quantity, $value->image,array('color' => $value->attributes->color)); } } } if(Auth::user()->user_type == 2){ $model = Shop::where('user_id',Auth::user()->$user_id)->first(); if($model){ if($request->previous){ return redirect()->route('neneMart.dashboard'); }else{ return Redirect::to($request->previous); } }else{ if(empty($request->previous)){ return redirect()->route('create-shop'); }else{ return Redirect::to($request->previous); } } }else{ if(empty($request->previous)){ return redirect()->route('home'); }else{ return Redirect::to($request->previous); } } } else{ return redirect()->route('user-login')->with(Auth::logout())->with('error', 'User email has not been activated yet!'); } }else{ return redirect()->route('user-login')->with('error', 'Whoops! Wrong Email or Username or Password !'); } }` > ROUTE Route:: get('user-login', 'Auth\LoginController@usershowLoginForm')->name('user-login'); Route:: post('userLogin', 'Auth\LoginController@userlogin')->name('userLogin'); > Shop Management Controller public function index() { $shop = Shop::where('user_id',Auth::user()->id)->first(); $model = ShopManagement::where('shop_id','Nenemart-'.$shop->id)->first(); $shopid = 'Nenemart-'.$shop->id; $agent = new Agent(); if($agent->isMobile() || $agent->isTablet()){ return view('mobile.mart.shopmanagemnt',compact('model','shopid')); }else{ return view('frontend.mart.shopmanagemnt',compact('model','shopid')); } } public function vendorShop(){ $shop = Shop::where('user_id',Auth::user()->id)->first(); $model = ShopManagement::where('shop_id','Nenemart-'.$shop->id)->first(); $vendorProducts = Product::orderBy('id', 'dese')->where('created_by', $shop->id)->where('type', 1)->get(); $agent = new Agent(); if($agent->isMobile() || $agent->isTablet()){ return view('mobile.mart.vendorShop',compact('model', 'vendorProducts')); }else{ return view('frontend.mart.vendorShop',compact('model', 'vendorProducts')); } } **Error** [1]: https://i.stack.imgur.com/CtD6W.jpg
0debug
static int mpegvideo_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { ParseContext1 *pc1 = s->priv_data; ParseContext *pc= &pc1->pc; int next; if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ next= buf_size; }else{ next= ff_mpeg1_find_frame_end(pc, buf, buf_size); if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { *poutbuf = NULL; *poutbuf_size = 0; return buf_size; } } mpegvideo_extract_headers(s, avctx, buf, buf_size); #if 0 printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict); #endif *poutbuf = buf; *poutbuf_size = buf_size; return next; }
1threat
I have problems with finding how many odd numbers or even numbers are in an array : <p>Given an array of integer numbers, compute how many values from the array are odd and how many of them are even.</p> <p>Example: for array [1,4,7,11,12] the returned result will be:</p> <p>Odd values: 3</p> <p>Even values: 2</p>
0debug
static void coroutine_fn sd_finish_aiocb(SheepdogAIOCB *acb) { qemu_coroutine_enter(acb->coroutine, NULL); qemu_aio_unref(acb); }
1threat
How to get the list of all ismlaic events of current year using eventkit.framwork in ios : I want to get the list of all Islamic events of current year using Eventkit framework. Used the given below code from stackoverflow: NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]]; NSArray *calendarArray1 = [NSArray arrayWithObject:calendar]; NSPredicate *fetchCalendarEvents = [eventStore predicateForEventsWithStartDate:[NSDate date] endDate:endDate calendars:calendarArray1]; NSArray *eventList = [eventStore eventsMatchingPredicate:fetchCalendarEvents]; for(int i=0; i < eventList.count; i++){ NSLog(@"Event Title:%@", [[eventList objectAtIndex:i] title]); } but app crashes at NSPredicate line. Thanks.
0debug
static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt) { int ret; HEVCContext *s = avctx->priv_data; if (!avpkt->size) { ret = ff_hevc_output_frame(s, data, 1); if (ret < 0) return ret; *got_output = ret; return 0; } s->ref = NULL; ret = decode_nal_units(s, avpkt->data, avpkt->size); if (ret < 0) return ret; if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded && avctx->err_recognition & AV_EF_EXPLODE && s->is_md5) { ret = verify_md5(s, s->ref->frame); if (ret < 0) { ff_hevc_unref_frame(s, s->ref, ~0); return ret; } } s->is_md5 = 0; if (s->is_decoded) { av_log(avctx, AV_LOG_DEBUG, "Decoded frame with POC %d.\n", s->poc); s->is_decoded = 0; } if (s->output_frame->buf[0]) { av_frame_move_ref(data, s->output_frame); *got_output = 1; } return avpkt->size; }
1threat
Bug in SQLAlchemy Rollback after DB Exception? : <p>My SQLAlchemy application (running on top of MariaDB) includes two models <code>MyModelA</code> and <code>MyModelB</code> where the latter is a child-record of the former:</p> <pre><code>class MyModelA(db.Model): a_id = db.Column(db.Integer, nullable=False, primary_key=True) my_field1 = db.Column(db.String(1024), nullable=True) class MyModelB(db.Model): b_id = db.Column(db.Integer, nullable=False, primary_key=True) a_id = db.Column(db.Integer, db.ForeignKey(MyModelA.a_id), nullable=False) my_field2 = db.Column(db.String(1024), nullable=True) </code></pre> <p>These are the instances of <code>MyModelA</code> and <code>MyModelB</code> that I create:</p> <pre><code>&gt;&gt;&gt; my_a = MyModelA(my_field1="A1") &gt;&gt;&gt; my_a.aid 1 &gt;&gt;&gt; MyModelB(a_id=my_a.aid, my_field2="B1") </code></pre> <p>I have the following code that deletes the instance of <code>MyModelA</code> where <code>a_id==1</code>:</p> <pre><code>db.session.commit() try: my_a = MyModelA.query.get(a_id=1) assert my_a is not None print "#1) Number of MyModelAs: %s\n" % MyModelA.query.count() db.session.delete(my_a) db.session.commit() except IntegrityError: print "#2) Cannot delete instance of MyModelA because it has child record(s)!" db.session.rollback() print "#3) Number of MyModelAs: %s\n" % MyModelA.query.count() </code></pre> <p>When I run this code look at the unexpected results I get:</p> <pre><code>#1) Number of MyModelAs: 1 #2) Cannot delete instance of MyModelA because it has child record(s)! #3) Number of MyModelAs: 0 </code></pre> <p>The delete supposedly fails and the DB throws an exception which causes a rollback. However even after the rollback, the number of rows in the table indicates that the row -- which supposedly wasn't deleted -- is actually gone!!!</p> <p>Why is this happening? How can I fix this? It seems like a bug in SQLAlchemy.</p>
0debug
Java program to identify whether a given line is a comment or not : <p>I'm creating a java program to test if the given string is a comment or not and here's my code so far:</p> <pre><code>public class comment { public static void main(String args[]){ String[] com = new String[50]; Scanner scan = new Scanner(System.in); int i = 2 ,a=0; System.out.println("Enter comment"); com[i] = scan.nextLine(); if(com[0].equals("/")){ if(com[1].equals("/")){ System.out.println("comment"); } else if (com[1].equals("*")){ for(i=2;i&lt;=50; i++){ if(com[1].equals("*") &amp;&amp; com[i+1].equals("/") ){ System.out.println("comment"); a=1; break; } else{ continue;}} if(a==0){System.out.println("not");} } else{System.out.println("not"); } } else{System.out.println("not"); } } } </code></pre> <p>I'm getting an error on this line of code: </p> <pre><code> if(com[0].equals("/")) </code></pre> <p>Error says: java.lang.NullPointerException</p> <p>Any explanation on why is this occuring ?</p>
0debug
Error: cannot find symbol variable DaggerAppComponent : <p>While trying to integrate latest Dagger 2 version, I am facing problem of Dagger auto generation. Dagger is not auto generating DaggerAppComponent in spite of several Rebuilds and Make Module App process.</p> <p><strong>Application class:</strong> </p> <pre><code>public class BaseApplication extends Application { private AppComponent appComponent; @Override public void onCreate() { super.onCreate(); initAppComponent(); } private void initAppComponent() { DaggerAppComponent.builder() .appModule(new AppModule(this)) .build(); } public AppComponent getAppComponent() { return appComponent; } } </code></pre> <p><strong>AppComponent</strong></p> <pre><code>@Singleton @Component(modules = AppModule.class) public interface AppComponent { void inject(BaseApplication application); } </code></pre> <p><strong>AppModule:</strong></p> <pre><code>@Module public class AppModule { private BaseApplication application; public AppModule(BaseApplication app) { application = app; } @Provides @Singleton Context provideContext() { return application; } @Provides Application provideApplication() { return application; } } </code></pre> <p><strong>Dependency used:</strong></p> <pre><code>compile 'com.google.dagger:dagger-android:2.11' compile 'com.google.dagger:dagger-android-support:2.11' annotationProcessor 'com.google.dagger:dagger-android-processor:2.11' androidTestCompile 'com.google.code.findbugs:jsr305:3.0.1' </code></pre> <p>Any help in this regard will be highly appreciated.</p>
0debug
C# Methods and Properties : <p>When to use Methods and Properties in C#? They can do same thing but when to use both of them. And also is it possible to set a whole object via C# Property instead of single value.?</p>
0debug
Django TemplateSyntaxError - 'staticfiles' is not a registered tag library : <p>After upgrading to Django 3.0, I get the following <code>TemplateSyntaxError</code>:</p> <pre><code>In template /Users/alasdair//myproject/myapp/templates/index.html, error at line 1 'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz </code></pre> <p>Here is my template</p> <pre><code>{% load staticfiles %} &lt;img src="{% static 'my_image.html' %}"&gt; </code></pre>
0debug
static int is_intra_more_likely(MpegEncContext *s){ int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y; if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1; undamaged_count=0; for(i=0; i<s->mb_num; i++){ const int mb_xy= s->mb_index2xy[i]; const int error= s->error_status_table[mb_xy]; if(!((error&DC_ERROR) && (error&MV_ERROR))) undamaged_count++; } if(s->codec_id == CODEC_ID_H264){ H264Context *h= (void*)s; if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0]) return 1; } if(undamaged_count < 5) return 0; if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration && s->pict_type == AV_PICTURE_TYPE_I) return 1; skip_amount= FFMAX(undamaged_count/50, 1); is_intra_likely=0; j=0; for(mb_y= 0; mb_y<s->mb_height-1; mb_y++){ for(mb_x= 0; mb_x<s->mb_width; mb_x++){ int error; const int mb_xy= mb_x + mb_y*s->mb_stride; error= s->error_status_table[mb_xy]; if((error&DC_ERROR) && (error&MV_ERROR)) continue; j++; if((j%skip_amount) != 0) continue; if(s->pict_type==AV_PICTURE_TYPE_I){ uint8_t *mb_ptr = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize; uint8_t *last_mb_ptr= s->last_picture.f.data [0] + mb_x*16 + mb_y*16*s->linesize; if (s->avctx->codec_id == CODEC_ID_H264) { } else { ff_thread_await_progress((AVFrame *) s->last_picture_ptr, mb_y, 0); } is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16); need await_progress() here is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16); }else{ if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) is_intra_likely++; else is_intra_likely--; } } } return is_intra_likely > 0; }
1threat
static void qed_commit_l2_update(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); CachedL2Table *l2_table = acb->request.l2_table; qed_commit_l2_cache_entry(&s->l2_cache, l2_table); acb->request.l2_table = qed_find_l2_cache_entry(&s->l2_cache, l2_table->offset); assert(acb->request.l2_table != NULL); qed_aio_next_io(opaque, ret); }
1threat
void kqemu_flush_page(CPUState *env, target_ulong addr) { LOG_INT("kqemu_flush_page: addr=" TARGET_FMT_lx "\n", addr); if (nb_pages_to_flush >= KQEMU_MAX_PAGES_TO_FLUSH) nb_pages_to_flush = KQEMU_FLUSH_ALL; else pages_to_flush[nb_pages_to_flush++] = addr; }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples) { int i, nb_samples1; short *bufin[2]; short *bufout[2]; short *buftmp2[2], *buftmp3[2]; short *output_bak = NULL; int lenout; if (s->input_channels == s->output_channels && s->ratio == 1.0 && 0) { memcpy(output, input, nb_samples * s->input_channels * sizeof(short)); return nb_samples; } if (s->sample_fmt[0] != SAMPLE_FMT_S16) { int istride[1] = { s->sample_size[0] }; int ostride[1] = { 2 }; const void *ibuf[1] = { input }; void *obuf[1]; unsigned input_size = nb_samples*s->input_channels*s->sample_size[0]; if (!s->buffer_size[0] || s->buffer_size[0] < input_size) { av_free(s->buffer[0]); s->buffer_size[0] = input_size; s->buffer[0] = av_malloc(s->buffer_size[0]); if (!s->buffer[0]) { av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n"); return 0; } } obuf[0] = s->buffer[0]; if (av_audio_convert(s->convert_ctx[0], obuf, ostride, ibuf, istride, nb_samples*s->input_channels) < 0) { av_log(s, AV_LOG_ERROR, "Audio sample format conversion failed\n"); return 0; } input = s->buffer[0]; } lenout= 4*nb_samples * s->ratio + 16; if (s->sample_fmt[1] != SAMPLE_FMT_S16) { output_bak = output; if (!s->buffer_size[1] || s->buffer_size[1] < lenout) { av_free(s->buffer[1]); s->buffer_size[1] = lenout; s->buffer[1] = av_malloc(s->buffer_size[1]); if (!s->buffer[1]) { av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n"); return 0; } } output = s->buffer[1]; } for(i=0; i<s->filter_channels; i++){ bufin[i]= av_malloc( (nb_samples + s->temp_len) * sizeof(short) ); memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short)); buftmp2[i] = bufin[i] + s->temp_len; } bufout[0]= av_malloc( lenout * sizeof(short) ); bufout[1]= av_malloc( lenout * sizeof(short) ); if (s->input_channels == 2 && s->output_channels == 1) { buftmp3[0] = output; stereo_to_mono(buftmp2[0], input, nb_samples); } else if (s->output_channels >= 2 && s->input_channels == 1) { buftmp3[0] = bufout[0]; memcpy(buftmp2[0], input, nb_samples*sizeof(short)); } else if (s->output_channels >= 2) { buftmp3[0] = bufout[0]; buftmp3[1] = bufout[1]; stereo_split(buftmp2[0], buftmp2[1], input, nb_samples); } else { buftmp3[0] = output; memcpy(buftmp2[0], input, nb_samples*sizeof(short)); } nb_samples += s->temp_len; nb_samples1 = 0; for(i=0;i<s->filter_channels;i++) { int consumed; int is_last= i+1 == s->filter_channels; nb_samples1 = av_resample(s->resample_context, buftmp3[i], bufin[i], &consumed, nb_samples, lenout, is_last); s->temp_len= nb_samples - consumed; s->temp[i]= av_realloc(s->temp[i], s->temp_len*sizeof(short)); memcpy(s->temp[i], bufin[i] + consumed, s->temp_len*sizeof(short)); } if (s->output_channels == 2 && s->input_channels == 1) { mono_to_stereo(output, buftmp3[0], nb_samples1); } else if (s->output_channels == 2) { stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1); } else if (s->output_channels == 6) { ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1); } if (s->sample_fmt[1] != SAMPLE_FMT_S16) { int istride[1] = { 2 }; int ostride[1] = { s->sample_size[1] }; const void *ibuf[1] = { output }; void *obuf[1] = { output_bak }; if (av_audio_convert(s->convert_ctx[1], obuf, ostride, ibuf, istride, nb_samples1*s->output_channels) < 0) { av_log(s, AV_LOG_ERROR, "Audio sample format convertion failed\n"); return 0; } } for(i=0; i<s->filter_channels; i++) av_free(bufin[i]); av_free(bufout[0]); av_free(bufout[1]); return nb_samples1; }
1threat
python: classes with multiple files : I have 2 files, one named data.py and the other main.py Code data.py: class data24: w = 75 code main.py: import data lala = data24 print(lala.w) It is giving me two errors: 'data' imported but unused and 'data24' undefined. I've already put an empty __init__.py file in the directory. what am i doing wrong? BTW, it is printing the correct information.
0debug
Powershell script to look for particular word in the file and add “4” at the beginning of the line. : I am the best. Page I am good. Page I am funny. Page Out put: 4 I am the best. Page 4 I am good. Page 4 I am funny. Page Powershell script need to look for “page” and add “4” at the beginning of the line.
0debug
In Kubernetes, how to set pods' names when using replication controllers? : <p>I have a simple replication controller yaml file which looks like this:</p> <pre><code>apiVersion: v1 kind: ReplicationController metadata: name: nginx spec: replicas: 3 selector: app: nginx template: spec: containers: - image: library/nginx:3.2 imagePullPolicy: IfNotPresent name: nginx ports: - containerPort: 80 metadata: labels: app: nginx </code></pre> <p>And after running this replication controller, I will get 3 different pods whose names are "nginx-xxx", where "xxx" represents a random string of letters and digits.</p> <p>What I want is to specify names for the pods created by the replication controller, so that the pods' name can be "nginx-01", "nginx-02", "nginx-03". And further more, for say if pod "nginx-02" is down for some reason, and replication controller will automatically create another nginx pod, and I want this new nginx pod's name to remain as "nginx-02".</p> <p>I wonder if this is possible? Thanks in advance.</p>
0debug
Why should optional<T&> rebind on assignment? : <p>There is an ongoing debate about what <code>optional</code> and <code>variant</code> should do with reference types, particularly with regards to assignment. I would like to better understand the debate around this issue. </p> <pre><code>optional&lt;T&amp;&gt; opt; opt = i; opt = j; // should this rebind or do i=j? </code></pre> <p>Currently, the decision is to make <code>optional&lt;T&amp;&gt;</code> ill-formed and make <code>variant::operator=</code> ill-formed if any of the types is a reference type - to sidestep the argument and still give us most of the functionality. </p> <p>What is the argument that <code>opt = j</code> <em>should</em> rebind the underlying reference? In other words, why <em>should</em> we implement <code>optional</code> like this:</p> <pre><code>template &lt;class T&gt; struct optional&lt;T&amp;&gt; { T* ptr = nullptr; optional&amp; operator=(T&amp; rhs) { ptr = &amp;rhs; return *this; } }; </code></pre>
0debug
Python 3 type hint for a factory method on a base class returning a child class instance : <p>Let's say I have two classes <code>Base</code> and <code>Child</code> with a factory method in <code>Base</code>. The factory method calls another classmethod which may be overriden by <code>Base</code>'s child classes.</p> <pre><code>class Base(object): @classmethod def create(cls, *args: Tuple) -&gt; 'Base': value = cls._prepare(*args) return cls(value) @classmethod def _prepare(cls, *args: Tuple) -&gt; Any: return args[0] if args else None def __init__(self, value: Any) -&gt; None: self.value = value class Child(Base): @classmethod def _prepare(cls, *args: Tuple) -&gt; Any: return args[1] if len(args) &gt; 1 else None def method_not_present_on_base(self) -&gt; None: pass </code></pre> <p>Is there a way to annotate <code>Base.create</code> so that a static type checker could infer that <code>Base.create()</code> returned an instance of <code>Base</code> and <code>Child.create()</code> returned an instance of <code>Child</code>, so that the following example would pass static analysis?</p> <pre><code>base = Base.create(1) child = Child.create(2, 3) child.method_not_present_on_base() </code></pre> <p>In the above example a static type checker would rightfully complain that the <code>method_not_present_on_base</code> is, well, not present on the <code>Base</code> class.</p> <hr> <p>I thought about turning <code>Base</code> into a generic class and having the child classes specify themselves as type arguments, i.e. bringing the <a href="https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern" rel="noreferrer">CRTP</a> to Python.</p> <pre><code>T = TypeVar('T') class Base(Generic[T]): @classmethod def create(cls, *args: Tuple) -&gt; T: ... class Child(Base['Child']): ... </code></pre> <p>But this feels rather unpythonic with CRTP coming from C++ and all...</p>
0debug
How can I add an object to an arraylist of objects : <p>The purpose is to add teams to an arraylist. Each team is an object with a String name, String division, int wins, and int losses. </p> <pre><code>import java.util.ArrayList; import java.util.Arrays; public class Default { ArrayList&lt;team&gt; teams = new ArrayList&lt;team&gt;(); team Mavericks = new team("Mavericks","Southwest",50,32); team Rockets = new team("Rockets","Southwest",56,26); team Grizzlies = new team("Memphis","Southwest",55,27); teams.add(team Mavericks); teams.add(team Rockets); teams.add(team Grizzlies); } class team { String name, division; int win,loss; public team(String n,String d, int w, int l) { this.name = n; this.division = d; this.win = w; this.loss = l; } } </code></pre>
0debug
def get_median(arr1, arr2, n): i = 0 j = 0 m1 = -1 m2 = -1 count = 0 while count < n + 1: count += 1 if i == n: m1 = m2 m2 = arr2[0] break elif j == n: m1 = m2 m2 = arr1[0] break if arr1[i] <= arr2[j]: m1 = m2 m2 = arr1[i] i += 1 else: m1 = m2 m2 = arr2[j] j += 1 return (m1 + m2)/2
0debug
Javascript for loop add a number x times : Hi could need som help with this problem. Exercise: * Use a for-loop to increment 399 with the value 8, 13 times. My Code so far. When i run it i get Error, could any one help me in the right direction? thank you! > var a = 399; > var b = 8; > > for (i = 0; i < 13; i++) { > a += b; > } > > ANSWER = a;
0debug
Print the key for the maximum out of data set : <p>Currently my data set is:</p> <pre><code>{('NSW', '06'): 0.4, ('QLD', '06'): 0.2, ('VIC', '06'): 0.0, ('NSW', '07'): 0.2, ('QLD', '07'): 0.4, ('VIC', '07'): 0.0, ('NSW', '08'): 0.2, ('QLD', '08'): 0.2, ('VIC', '08'): 0.0, ('NSW', '09'): 0.2, ('QLD', '09'): 0.2, ('VIC', '09'): 0.0, ('NSW', '10'): 0.2, ('QLD', '10'): 0.2, ('VIC', '10'): 0.0, ('NSW', '11'): 0.2, ('QLD', '11'): 0.6, ('VIC', '11'): 0.0} </code></pre> <p>I have achieved this from doing:</p> <pre><code>key = (state,month) if key not in rainfall_and_month: rainfall_and_month[key] = rainfall if key in rainfall_and_month: rainfall_and_month[key] = min(rainfall, rainfall_and_month[key]) </code></pre> <p>I wish to print out the largest value out of the key-value pairs. So basically I would like to make the code find "('QLD', '11'): 0.6", and then print out,</p> <pre><code>A-value: QLD B-value: 11 </code></pre> <p>separately, so I would probably end up doing</p> <pre><code>print("A-value:", state) print("B-value:", month) </code></pre> <p>However I'm not sure as to how to find the largest value then extract those data points.</p>
0debug
Electron Manipulate/Intercept WebView Requests and Responses : <p>I want to create an Electron app that will use <a href="https://electronjs.org/docs/api/webview-tag" rel="noreferrer">webview</a> to display 3rd party content.</p> <p>I would like to be able to intercept all requests and responses from this webview. Sometimes I would like to manipulate this content, other times I would like to log it, and other times I’d like to do nothing.</p> <p>As one example for the responses, maybe a web server will respond with TypeScript code, maybe I want to take that response, and compile it to standard JavaScript.</p> <p>I have looked into <a href="https://discuss.atom.io/t/electron-intercept-http-request-response-on-browserwindow/21868/6?u=fishcharlie" rel="noreferrer">this page</a> but it looks like it is only possible to cancel requests, and manipulate the headers. The <a href="https://electronjs.org/docs/api/web-request" rel="noreferrer">WebRequest API</a> doesn't look to fit the needs of my use case since it only allows very minor manipulations of requests and responses.</p> <p>I have also considered setting up some time of web server that can act as a proxy, but I have concerns about that. I want to maintain user privacy, and I want to ensure that to the web servers that host the 3rd party content it looks like the request is coming from a browser like environment (ex. Electron webview) instead of a server. I know I can manipulate requests with the headers I send and such, but this whole solution is getting to be a lot more complicated, then I would like, but might be the only option.</p> <p>Any better ways to achieve this, and have more control over the Electron webview?</p>
0debug
CPUX86State *cpu_x86_init(const char *cpu_model) { CPUX86State *env; static int inited; env = qemu_mallocz(sizeof(CPUX86State)); cpu_exec_init(env); env->cpu_model_str = cpu_model; if (!inited) { inited = 1; optimize_flags_init(); #ifndef CONFIG_USER_ONLY prev_debug_excp_handler = cpu_set_debug_excp_handler(breakpoint_handler); #endif } if (cpu_x86_register(env, cpu_model) < 0) { cpu_x86_close(env); return NULL; } mce_init(env); cpu_reset(env); #ifdef CONFIG_KQEMU kqemu_init(env); #endif qemu_init_vcpu(env); return env; }
1threat
Open Form with Button : <p>I want to open from an other Form with a button a Form. How can i do this?</p> <pre><code>private void button1_Click(object sender, EventArgs e) { Form Grondstoffen = new Form(); Grondstoffen.Show(); } } </code></pre> <p>I have tried to write this code but that opeens a Total different Form.</p>
0debug
Converting Json output from API to CSV : I am using weather Api to extract data and it give me in json file like this {'data': {'request': [{'type': 'City', 'query': 'Karachi, Pakistan'}], 'weather': [{'date': '2019-03-10', 'astronomy': [{'sunrise': '06:46 AM', 'sunset': '06:38 PM', 'moonrise': '09:04 AM', 'moonset': '09:53 PM', 'moon_phase': 'Waxing Crescent', 'moon_illumination': '24'}], 'maxtempC': '27', 'maxtempF': '80', 'mintempC': '22', 'mintempF': '72', 'totalSnow_cm': '0.0', 'sunHour': '11.6', 'uvIndex': '7', 'hourly': [{'time': '24', 'tempC': '27', 'tempF': '80', 'windspeedMiles': '10', 'windspeedKmph': '16', 'winddirDegree': '234', 'winddir16Point': 'SW', 'weatherCode': '116', 'weatherIconUrl': [{'value': 'http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png'}], 'weatherDesc': [{'value': 'Partly cloudy'}], 'precipMM': '0.0', 'humidity': '57', 'visibility': '10', 'pressure': '1012', 'cloudcover': '13', 'HeatIndexC': '25', 'HeatIndexF': '78', 'DewPointC': '15', 'DewPointF': '59', 'WindChillC': '24', 'WindChillF': '75', 'WindGustMiles': '12', 'WindGustKmph': '19', 'FeelsLikeC': '25', 'FeelsLikeF': '78', 'uvIndex': '0'}]}]}} i want to convert it into csv file
0debug
How can I randomize an array without repeating objects? : <p>I have 3 arrays ( questions, answers and correct answers ) and I want to pick a random question that hasn't been already picked. I used Random(), but the questions are repeating, how can i solve this problem ? Thanks ! </p>
0debug
How to save the items that a user bought in the database and prevent him to buy it again : <p>I need some help storing the files a user bought and downloaded. I have a table with files and their ID. When users buy and file it's just redirecting him to the download link. But I want to make PHP script insert into the database the ID of the files that user bought. But how to do it with multiple files and store their ID in 1 field for each user. For example I have 10 files and the user bought files 1,2,3,8,9. I want to store in the database these numbers and do a while to show the link that corresponds to these ID's.</p>
0debug
static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride) { long y; const long chromWidth= width>>1; for(y=0; y<height; y+=2) { #ifdef HAVE_MMX asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $8, %%mm7 \n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_a", 4) \n\t" "movq (%0, %%"REG_a", 4), %%mm0 \n\t" "movq 8(%0, %%"REG_a", 4), %%mm1\n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm2, (%1, %%"REG_a", 2)\n\t" "movq 16(%0, %%"REG_a", 4), %%mm1\n\t" "movq 24(%0, %%"REG_a", 4), %%mm2\n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm2, %%mm4 \n\t" "psrlw $8, %%mm1 \n\t" "psrlw $8, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "pand %%mm7, %%mm4 \n\t" "packuswb %%mm2, %%mm1 \n\t" "packuswb %%mm4, %%mm3 \n\t" MOVNTQ" %%mm3, 8(%1, %%"REG_a", 2)\n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%3, %%"REG_a") \n\t" MOVNTQ" %%mm2, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%"REG_a ); ydst += lumStride; src += srcStride; asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_a", 4) \n\t" "movq (%0, %%"REG_a", 4), %%mm0 \n\t" "movq 8(%0, %%"REG_a", 4), %%mm1\n\t" "movq 16(%0, %%"REG_a", 4), %%mm2\n\t" "movq 24(%0, %%"REG_a", 4), %%mm3\n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%1, %%"REG_a", 2)\n\t" MOVNTQ" %%mm2, 8(%1, %%"REG_a", 2)\n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%"REG_a ); #else long i; for(i=0; i<chromWidth; i++) { ydst[2*i+0] = src[4*i+0]; udst[i] = src[4*i+1]; ydst[2*i+1] = src[4*i+2]; vdst[i] = src[4*i+3]; } ydst += lumStride; src += srcStride; for(i=0; i<chromWidth; i++) { ydst[2*i+0] = src[4*i+0]; ydst[2*i+1] = src[4*i+2]; } #endif udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } #ifdef HAVE_MMX asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
1threat
AZURE Active Directory - What is the difference between a Service Principal and an Enterprise Application? : <p>Three topics in Azure AD I'm constantly confused on:</p> <ol> <li>Service Principal</li> <li>Enterprise Application</li> <li>App Registration</li> </ol> <p>What is the difference?</p> <p>I can easily go into "App Registrations" and register an "app" while that "app" doesn't even need to exist. All it requires is a URL which can also be totally random. This app registration then becomes a service principal which you can use to connect to Azure to from PowerShell for instance? Why? I don't understand this.</p> <p>Please advise, and as you can probably tell, I'm new to Azure :)</p>
0debug
static void pci_host_config_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned len) { PCIHostState *s = opaque; PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n", __func__, addr, len, val); s->config_reg = val;
1threat
static inline int _find_pte(CPUState *env, mmu_ctx_t *ctx, int is_64b, int h, int rw, int type, int target_page_bits) { target_phys_addr_t pteg_off; target_ulong pte0, pte1; int i, good = -1; int ret, r; ret = -1; pteg_off = get_pteg_offset(env, ctx->hash[h], is_64b ? HASH_PTE_SIZE_64 : HASH_PTE_SIZE_32); for (i = 0; i < 8; i++) { #if defined(TARGET_PPC64) if (is_64b) { if (env->external_htab) { pte0 = ldq_p(env->external_htab + pteg_off + (i * 16)); pte1 = ldq_p(env->external_htab + pteg_off + (i * 16) + 8); } else { pte0 = ldq_phys(env->htab_base + pteg_off + (i * 16)); pte1 = ldq_phys(env->htab_base + pteg_off + (i * 16) + 8); } if (target_page_bits != TARGET_PAGE_BITS) pte1 |= (ctx->eaddr & (( 1 << target_page_bits ) - 1)) & TARGET_PAGE_MASK; r = pte64_check(ctx, pte0, pte1, h, rw, type); LOG_MMU("Load pte from " TARGET_FMT_lx " => " TARGET_FMT_lx " " TARGET_FMT_lx " %d %d %d " TARGET_FMT_lx "\n", pteg_base + (i * 16), pte0, pte1, (int)(pte0 & 1), h, (int)((pte0 >> 1) & 1), ctx->ptem); } else #endif { if (env->external_htab) { pte0 = ldl_p(env->external_htab + pteg_off + (i * 8)); pte1 = ldl_p(env->external_htab + pteg_off + (i * 8) + 4); } else { pte0 = ldl_phys(env->htab_base + pteg_off + (i * 8)); pte1 = ldl_phys(env->htab_base + pteg_off + (i * 8) + 4); } r = pte32_check(ctx, pte0, pte1, h, rw, type); LOG_MMU("Load pte from " TARGET_FMT_lx " => " TARGET_FMT_lx " " TARGET_FMT_lx " %d %d %d " TARGET_FMT_lx "\n", pteg_base + (i * 8), pte0, pte1, (int)(pte0 >> 31), h, (int)((pte0 >> 6) & 1), ctx->ptem); } switch (r) { case -3: return -1; case -2: ret = -2; good = i; break; case -1: default: break; case 0: ret = 0; good = i; goto done; } } if (good != -1) { done: LOG_MMU("found PTE at addr " TARGET_FMT_lx " prot=%01x ret=%d\n", ctx->raddr, ctx->prot, ret); pte1 = ctx->raddr; if (pte_update_flags(ctx, &pte1, ret, rw) == 1) { #if defined(TARGET_PPC64) if (is_64b) { if (env->external_htab) { stq_p(env->external_htab + pteg_off + (good * 16) + 8, pte1); } else { stq_phys_notdirty(env->htab_base + pteg_off + (good * 16) + 8, pte1); } } else #endif { if (env->external_htab) { stl_p(env->external_htab + pteg_off + (good * 8) + 4, pte1); } else { stl_phys_notdirty(env->htab_base + pteg_off + (good * 8) + 4, pte1); } } } } return ret; }
1threat
Tools to compress images to pagespeed standard : <p>I've been using Photoshop's "Save for web" option to save images that go on my website.</p> <p>I keep the quality level at 60 which reduces picture quality slightly. When I increase the level pagespeed tells me that the images can further be compressed without loss.</p> <p>I've also tried to do the same with Irfan View which has batch resize and compress which is great but results in the same pagespeed warning.</p> <p>What can I do here? Is there any other tool I can use?</p>
0debug
Laravel 5.5 . How can I validate date using laravel validater : I have some fields which defines passport_issued_date and and passport_expiration_date. I need to check activity of given passport by comparing with current time. I would do it by using native php, however I would like to know if there is some way to make a validation using laravel 5.5 validation on dates.
0debug
C: Why does semi-colon after a macro cause illegal else compile error : I'm relatively new to C, and apparently I have a fundamental misunderstanding of how macros work. I thought a macro just caused the preprocessor to replace the `@define`d macro with the replacement text. But apparently that's not always the case. My code follows: **TstBasInc.h** #pragma once #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> #include <stdint.h> #include <stdbool.h> #include <stdarg.h> #include <time.h> // copy macro #define Cpy(ToVar, FrmVar) do { \ errno = strncpy_s(ToVar, sizeof(ToVar), FrmVar, _TRUNCATE); \ if (errno == STRUNCATE) \ fprintf(stderr, "string '%s' was truncated to '%s'\n", FrmVar, ToVar); \ } while(0); // clear numeric array macro #define ClrNumArr(ArrNam, ArrCnt) \ for (s = 0; s < ArrCnt; s++) \ ArrNam[s] = 0; uint32_t s; // subscript typedef struct { short C; short YY; short MM; short DD; } SysDat; **TstMacCmpErr:** #include "stdafx.h" #include "TstBasInc.h" // test basic include file #define ARRCNT 3 int main() { char Cnd = 'E'; // define to use 'else' path char ToVar[7 + 1]; // Cpy To-Variable int IntArr[ARRCNT]; // integer array Cpy(ToVar, "short") // compiles with or without the semi-colon if (Cnd != 'E') // Cpy(ToVar, "short string"); // won't compile: illegal else without matching if Cpy(ToVar, "short string") // will compile else Cpy(ToVar, "extra long string"); // compiles with or without the semi-colon { \ errno = strncpy_s(ToVar, sizeof(ToVar), "short str", _TRUNCATE); \ if (errno == STRUNCATE) \ fprintf(stderr, "string '%s' was truncated to '%s'\n", "short str", ToVar); \ } if (Cnd == 'E') { ClrNumArr(IntArr, ARRCNT) // compiles with or without the semi-colon printf("intarr[0] = %d\n", IntArr[0]); } else printf("intarr[0] is garbage\n"); return 0; } The results follow: string 'extra long string' was truncated to 'extra l' string 'short str' was truncated to 'short s' intarr[0] = 0; As the comments say, when I have a semi-colon after `Cpy(ToVar, "short string");` it won't even compile because I get an `"C2181 illegal else without matching if"` error. As you see, I tried adding a do-while in the macro as suggested [in this post][1], but it didn't make any difference. When the macro code is copied directly (even without the do-while) that code works okay. I would have thought just adding the braces in the macro would have fixed the problem but it didn't. It must have something to do with the `Cpy` ending in an `if` because the `ClrNumArr` macro compiles with or without the semi-colon. So can someone tell me why the `Cpy` macro doesn't just replace the text? I must be missing something simple. I apologize in advance if that's so. I'm using VS 2015 Community Edition Update 1. [1]: http://stackoverflow.com/questions/154136/do-while-and-if-else-statements-in-c-c-macros
0debug
Angular 5 ng-select how to add two values to 'bindLabel'? : <p>I want to have ng-select with two values in property bindLabel. I have something like this:</p> <pre><code>&lt;ng-select placeholder="{{'TASKS.FOR_WHO' | translate }}" name="users" [items]="users" bindLabel="firstName" &gt; &lt;/ng-select&gt; </code></pre> <p>But in <strong>bind label</strong> i want to have <strong>bindLabel=</strong> firstName + lastName. Like this:</p> <pre><code>&lt;ng-select placeholder="{{'TASKS.FOR_WHO' | translate }}" name="users" [items]="users" bindLabel="firstName+lastName"&gt; &lt;/ng-select&gt; </code></pre> <p>How to achieve this?</p>
0debug
static void ipvideo_decode_opcodes(IpvideoContext *s, AVFrame *frame) { int x, y; unsigned char opcode; int ret; GetBitContext gb; bytestream2_skip(&s->stream_ptr, 14); if (!s->is_16bpp) { memcpy(frame->data[1], s->pal, AVPALETTE_SIZE); s->stride = frame->linesize[0]; } else { s->stride = frame->linesize[0] >> 1; s->mv_ptr = s->stream_ptr; bytestream2_skip(&s->mv_ptr, bytestream2_get_le16(&s->stream_ptr)); } s->line_inc = s->stride - 8; s->upper_motion_limit_offset = (s->avctx->height - 8) * frame->linesize[0] + (s->avctx->width - 8) * (1 + s->is_16bpp); init_get_bits(&gb, s->decoding_map, s->decoding_map_size * 8); for (y = 0; y < s->avctx->height; y += 8) { for (x = 0; x < s->avctx->width; x += 8) { opcode = get_bits(&gb, 4); ff_tlog(s->avctx, " block @ (%3d, %3d): encoding 0x%X, data ptr offset %d\n", x, y, opcode, bytestream2_tell(&s->stream_ptr)); if (!s->is_16bpp) { s->pixel_ptr = frame->data[0] + x + y*frame->linesize[0]; ret = ipvideo_decode_block[opcode](s, frame); } else { s->pixel_ptr = frame->data[0] + x*2 + y*frame->linesize[0]; ret = ipvideo_decode_block16[opcode](s, frame); } if (ret != 0) { av_log(s->avctx, AV_LOG_ERROR, "decode problem on frame %d, @ block (%d, %d)\n", s->avctx->frame_number, x, y); } } } if (bytestream2_get_bytes_left(&s->stream_ptr) > 1) { av_log(s->avctx, AV_LOG_DEBUG, "decode finished with %d bytes left over\n", bytestream2_get_bytes_left(&s->stream_ptr)); } }
1threat
static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { H264Context * const h = avctx->priv_data; MpegEncContext * const s = &h->s; VASliceParameterBufferH264 *slice_param; dprintf(avctx, "decode_slice(): buffer %p, size %d\n", buffer, size); slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size); if (!slice_param) return -1; slice_param->slice_data_bit_offset = get_bits_count(&h->s.gb) + 8; slice_param->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x; slice_param->slice_type = ff_h264_get_slice_type(h); slice_param->direct_spatial_mv_pred_flag = h->slice_type == FF_B_TYPE ? h->direct_spatial_mv_pred : 0; slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0; slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0; slice_param->cabac_init_idc = h->cabac_init_idc; slice_param->slice_qp_delta = s->qscale - h->pps.init_qp; slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter; slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2; slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2; slice_param->luma_log2_weight_denom = h->luma_log2_weight_denom; slice_param->chroma_log2_weight_denom = h->chroma_log2_weight_denom; fill_vaapi_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0); fill_vaapi_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0); fill_vaapi_plain_pred_weight_table(h, 0, &slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0, &slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0); fill_vaapi_plain_pred_weight_table(h, 1, &slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1, &slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1); return 0; }
1threat
static int local_create_mapped_attr_dir(FsContext *ctx, const char *path) { int err; char attr_dir[PATH_MAX]; char *tmp_path = g_strdup(path); snprintf(attr_dir, PATH_MAX, "%s/%s/%s", ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR); err = mkdir(attr_dir, 0700); if (err < 0 && errno == EEXIST) { err = 0; } g_free(tmp_path); return err; }
1threat
how Fix this Error Operand type clash: date is incompatible with int : INSERT INTO Buy SELECT Title,Type1,Tedat,DATEADD(DAY,-2,DATEADD(YEAR,-1,Tarikh)),Descrip FROM Buy WHERE(Tarikh BETWEEN 2019-03-21 AND 2020-03-19 )
0debug
static inline void RENAME(rgb24to16)(const uint8_t *src, uint8_t *dst, unsigned src_size) { const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif uint16_t *d = (uint16_t *)dst; end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm __volatile( "movq %0, %%mm7\n\t" "movq %1, %%mm6\n\t" ::"m"(red_16mask),"m"(green_16mask)); mm_end = end - 11; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "movd 3%1, %%mm3\n\t" "punpckldq 6%1, %%mm0\n\t" "punpckldq 9%1, %%mm3\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm3, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "psrlq $3, %%mm0\n\t" "psrlq $3, %%mm3\n\t" "pand %2, %%mm0\n\t" "pand %2, %%mm3\n\t" "psrlq $5, %%mm1\n\t" "psrlq $5, %%mm4\n\t" "pand %%mm6, %%mm1\n\t" "pand %%mm6, %%mm4\n\t" "psrlq $8, %%mm2\n\t" "psrlq $8, %%mm5\n\t" "pand %%mm7, %%mm2\n\t" "pand %%mm7, %%mm5\n\t" "por %%mm1, %%mm0\n\t" "por %%mm4, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "por %%mm5, %%mm3\n\t" "psllq $16, %%mm3\n\t" "por %%mm3, %%mm0\n\t" MOVNTQ" %%mm0, %0\n\t" :"=m"(*d):"m"(*s),"m"(blue_16mask):"memory"); d += 4; s += 12; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { const int b= *s++; const int g= *s++; const int r= *s++; *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8); } }
1threat
A iOS File Browser Alternative For Android Exist? : <p>I have an app, this app should open the file browser popup (in iOS), I never had an android, so i dont know if there is a native app like the iOS 11 File Browser. So When The popup shows, the user can select a file from the android native file browser</p>
0debug
Using multiple sequences in trigger to generate unique identity : <p>I am entering rows to my equipment table and if it is an antenna, I want to add prefix 'A' for antenna(antennas have foot number 1 to 4) and this prefix has a sequence for numbering. Also if it is not an antenna, it will take foot number -1 and have a prefix starts with 'E' for equipments. </p> <p>*Using ORACLE db.</p> <pre><code>CREATE OR REPLACE TRIGGER AFM.INV_SEQ_EQ_TOY_T BEFORE INSERT ON AFM.EQ REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW WHEN (new.antenna_foot_number in (-1,1,2,3,4)) BEGIN IF :new.antenna_foot_number = -1 THEN :new.eq_id := 'E'|| INV_SEQ_EQ_TOY.nextval; else :new.eq_id := 'A'|| INV_SEQ_EQ_ANTENNA_TOY.nextval; END IF; END; </code></pre>
0debug
Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) - Wercker : <p>I'm using wercker for running specs of my rails app. I have problem with setting up redis on wercker. In my rails app I have <code>redis.rb</code> which looks like this:</p> <pre><code>if Figaro.env.rediscloud_url uri = URI.parse(Figaro.env.rediscloud_url) REDIS = Redis.new(host: uri.host, port: uri.port, password: uri.password) elsif ENV['WERCKER_REDIS_HOST'] &amp;&amp; ENV['WERCKER_REDIS_PORT'] REDIS = Redis.new(host: ENV['WERCKER_REDIS_HOST'], port: ENV['WERCKER_REDIS_PORT']) else REDIS = Redis.new end </code></pre> <p>In wercker I set <code>WERCKER_REDIS_HOST</code> enviromental variable to: <code>127.0.0.1</code> and <code>WERCKER_REDIS_PORT</code> to <code>6379</code></p> <p>When I start my specs it returns:</p> <pre><code> Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:332:in `rescue in establish_connection' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:318:in `establish_connection' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:94:in `block in connect' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:280:in `with_reconnect' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:93:in `connect' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:351:in `ensure_connected' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:208:in `block in process' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:293:in `logging' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:207:in `process' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:178:in `call_pipelined' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:150:in `block in call_pipeline' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:280:in `with_reconnect' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:148:in `call_pipeline' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:2245:in `block in multi' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:57:in `block in synchronize' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:57:in `synchronize' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:2237:in `multi' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/client.rb:171:in `block in raw_push' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:64:in `block (2 levels) in with' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `handle_interrupt' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `block in with' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `handle_interrupt' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `with' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/client.rb:170:in `raw_push' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/client.rb:67:in `push' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/worker.rb:115:in `client_push' # /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/extensions/generic_proxy.rb:19:in `method_missing' # ./app/models/user.rb:26:in `send_reset_password_instructions' # ./spec/models/user_spec.rb:43:in `block (3 levels) in &lt;top (required)&gt;' # ------------------ # --- Caused by: --- # IO::EINPROGRESSWaitWritable: # Operation now in progress - connect(2) would block # /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/connection/ruby.rb:122:in `connect_addrinfo' </code></pre> <p>How can I fix that?</p>
0debug
After you create a class in C#, what must you do before you can use it in your code? : <p>After you create a class in C#, what must you do before you can use it in your code?</p>
0debug