problem
stringlengths
26
131k
labels
class label
2 classes
static int fdctrl_connect_drives(FDCtrl *fdctrl) { unsigned int i; FDrive *drive; for (i = 0; i < MAX_FD; i++) { drive = &fdctrl->drives[i]; drive->fdctrl = fdctrl; if (drive->bs) { if (bdrv_get_on_error(drive->bs, 0) != BLOCK_ERR_STOP_ENOSPC) { error_report("fdc doesn't support drive option werror"); return -1; } if (bdrv_get_on_error(drive->bs, 1) != BLOCK_ERR_REPORT) { error_report("fdc doesn't support drive option rerror"); return -1; } } fd_init(drive); fd_revalidate(drive); if (drive->bs) { bdrv_set_dev_ops(drive->bs, &fdctrl_block_ops, drive); } } return 0; }
1threat
Find csv lines by word similarity : <p>I have a csv file with thousands of lines. I would like to retrieve only the lines with some similarity regarding a specific word. In this case I am expecting to catch the line 1, 2 and 4.</p> <p>Any idea how to achieve that?</p> <pre><code>import csv a='Microsoft' f = open("testing.csv") reader = csv.reader(f, delimiter='\n') for row in reader: if a in row[0]: print row[0] </code></pre> <p><strong>testing.csv</strong> </p> <pre><code>I like very much the Microsoft products Me too, I like Micrsoft I prefer Apple products microfte here </code></pre>
0debug
Usage of "else" in python : <p>i am wondering how to get this else statement to work correctly. Using python</p> <pre><code>Dice = int(input("Please select number of dice you would like to use between 1 and 5")) if (Dice &gt;= 1): else: condition == "Start" </code></pre>
0debug
def filter_evennumbers(nums): even_nums = list(filter(lambda x: x%2 == 0, nums)) return even_nums
0debug
which By element to be used in selenium for this tag : I would like to which By xpath or css to be used for the below tag <div class="title HamMenuItem__Title-kxnncH gMjAMA">Pay &amp; transfer</div>
0debug
static void tcg_out_r(TCGContext *s, TCGArg t0) { assert(t0 < TCG_TARGET_NB_REGS); tcg_out8(s, t0); }
1threat
Error running docker container: No space left on device: "/data/db/journal" : <p>Running containers form docker-compose on a Mac, this is the file</p> <pre><code>api: build: . volumes: - .:/src - /src/node_modules links: - mongo - redis ports: - "3015:3015" - "5858:5858" mongo: image: mongo:3.3 ports: - "27017:27017" redis: image: redis ports: - "6379:6379" </code></pre> <p>Running docker-compose up the mongo container fails and exit. this is the log file:</p> <pre><code>MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=7115a6cce706 db version v3.3.14 git version: 507a5b4d334c1b4bea8fa232fa6b882849608e97 OpenSSL version: OpenSSL 1.0.1t 3 May 2016 allocator: tcmalloc modules: none build environment: distmod: debian81 distarch: x86_64 target_arch: x86_64 options: {} ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine See http://dochub.mongodb.org/core/prodnotes-filesystem error creating journal dir /data/db/journal boost::filesystem::create_directory: No space left on device: "/data/db/journal" exception in initAndListen std::exception: boost::filesystem::create_directory: No space left on device: "/data/db/journal", terminating shutdown: going to close listening sockets... removing socket file: /tmp/mongodb-27017.sock shutdown: going to flush diaglog... now exiting shutting down with code:100 </code></pre> <p>The main complain it's about no space left for creating a dir but I can't figured out how to fix it.</p>
0debug
void put_no_rnd_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, int stride, int h, int x, int y) { DECLARE_ALIGNED_16(signed int, ABCD[4]) = {((8 - x) * (8 - y)), ((x) * (8 - y)), ((8 - x) * (y)), ((x) * (y))}; register int i; vec_u8 fperm; const vec_s32 vABCD = vec_ld(0, ABCD); const vec_s16 vA = vec_splat((vec_s16)vABCD, 1); const vec_s16 vB = vec_splat((vec_s16)vABCD, 3); const vec_s16 vC = vec_splat((vec_s16)vABCD, 5); const vec_s16 vD = vec_splat((vec_s16)vABCD, 7); LOAD_ZERO; const vec_s16 v28ss = vec_sub(vec_sl(vec_splat_s16(1),vec_splat_u16(5)),vec_splat_s16(4)); const vec_u16 v6us = vec_splat_u16(6); register int loadSecond = (((unsigned long)src) % 16) <= 7 ? 0 : 1; register int reallyBadAlign = (((unsigned long)src) % 16) == 15 ? 1 : 0; vec_u8 vsrcAuc, vsrcBuc, vsrcperm0, vsrcperm1; vec_u8 vsrc0uc, vsrc1uc; vec_s16 vsrc0ssH, vsrc1ssH; vec_u8 vsrcCuc, vsrc2uc, vsrc3uc; vec_s16 vsrc2ssH, vsrc3ssH, psum; vec_u8 vdst, ppsum, fsum; if (((unsigned long)dst) % 16 == 0) { fperm = (vec_u8){0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; } else { fperm = (vec_u8){0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}; } vsrcAuc = vec_ld(0, src); if (loadSecond) vsrcBuc = vec_ld(16, src); vsrcperm0 = vec_lvsl(0, src); vsrcperm1 = vec_lvsl(1, src); vsrc0uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm0); if (reallyBadAlign) vsrc1uc = vsrcBuc; else vsrc1uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm1); vsrc0ssH = (vec_s16)vec_mergeh(zero_u8v, (vec_u8)vsrc0uc); vsrc1ssH = (vec_s16)vec_mergeh(zero_u8v, (vec_u8)vsrc1uc); if (!loadSecond) { for (i = 0 ; i < h ; i++) { vsrcCuc = vec_ld(stride + 0, src); vsrc2uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm0); vsrc3uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm1); vsrc2ssH = (vec_s16)vec_mergeh(zero_u8v, (vec_u8)vsrc2uc); vsrc3ssH = (vec_s16)vec_mergeh(zero_u8v, (vec_u8)vsrc3uc); psum = vec_mladd(vA, vsrc0ssH, vec_splat_s16(0)); psum = vec_mladd(vB, vsrc1ssH, psum); psum = vec_mladd(vC, vsrc2ssH, psum); psum = vec_mladd(vD, vsrc3ssH, psum); psum = vec_add(v28ss, psum); psum = vec_sra(psum, v6us); vdst = vec_ld(0, dst); ppsum = (vec_u8)vec_packsu(psum, psum); fsum = vec_perm(vdst, ppsum, fperm); vec_st(fsum, 0, dst); vsrc0ssH = vsrc2ssH; vsrc1ssH = vsrc3ssH; dst += stride; src += stride; } } else { vec_u8 vsrcDuc; for (i = 0 ; i < h ; i++) { vsrcCuc = vec_ld(stride + 0, src); vsrcDuc = vec_ld(stride + 16, src); vsrc2uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm0); if (reallyBadAlign) vsrc3uc = vsrcDuc; else vsrc3uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm1); vsrc2ssH = (vec_s16)vec_mergeh(zero_u8v, (vec_u8)vsrc2uc); vsrc3ssH = (vec_s16)vec_mergeh(zero_u8v, (vec_u8)vsrc3uc); psum = vec_mladd(vA, vsrc0ssH, vec_splat_s16(0)); psum = vec_mladd(vB, vsrc1ssH, psum); psum = vec_mladd(vC, vsrc2ssH, psum); psum = vec_mladd(vD, vsrc3ssH, psum); psum = vec_add(v28ss, psum); psum = vec_sr(psum, v6us); vdst = vec_ld(0, dst); ppsum = (vec_u8)vec_pack(psum, psum); fsum = vec_perm(vdst, ppsum, fperm); vec_st(fsum, 0, dst); vsrc0ssH = vsrc2ssH; vsrc1ssH = vsrc3ssH; dst += stride; src += stride; } } }
1threat
static void init_types(void) { static int inited; int i; if (inited) { return; } for (i = 0; i < MODULE_INIT_MAX; i++) { TAILQ_INIT(&init_type_list[i]); } inited = 1; }
1threat
While loop inside a function : The problem Write a function add_up that adds integers provided by the user, stopping when the user writes "Stop". Conditions: - it has to be user input, so no parameters - nothing is told about what to do with other strings that cannot be converted to integers My answer: def add_up(): `string = 0` total = 0 `while string is not "Stop":` `string = int(input())` `total += string` `print(total) add_up()
0debug
void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr) { tlb_set_page(cpu_single_env, addr & ~(TARGET_PAGE_SIZE - 1), addr & ~(TARGET_PAGE_SIZE - 1), PAGE_READ | PAGE_WRITE | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); }
1threat
static void nvdimm_init(Object *obj) { object_property_add(obj, "label-size", "int", nvdimm_get_label_size, nvdimm_set_label_size, NULL, NULL, NULL); }
1threat
Check if Python input contains a specific word : <p>This is just INPUT/OUTPUT coding What is does: You type in "Area" or "perimeter" or "volume" and it will ask for certain strings and calculates it. This code checks for the length and if the input contains numbers, and if it is over the length It will print the error.</p> <p>OBJECTIVE: If "Area", "perimeter" or "volume" is in the input, proceed to the next function..</p> <pre><code>print ("This program will find the area, perimeter and volume of the Rectangle!") find = input ("Type in one to calculate "area", "perimeter" and volume": ") if len(find) == 4 and find.isalpha(): #This is area, people can type 4 chars and can get away with it, is there a way to fix it? w = int (input ("What is the Width of the rectangle: ")) l = int (input ("What is the Length of the rectangle: ")) a = w*l ans = "The area of the rectangle is %s units!" print (ans%(a)) elif len (find) == 6 and find.isalpha(): # This is Volume w = int(input ("What is the Width of the rectangle: ")) l = int(input ("What is the Length of the rectangle: ")) h = int(input ("What is the Height of the rectangle: ")) v = l*w*h ans = "The volume of the rectangle is %s units!" print (ans%(v)) elif len (find) == 9 and find.isalpha(): #This is Perimeter w = int (input ("What is the Width of the rectangle: ")) l = int (input ("What is the Length of the rectangle: ")) p = 2*(l+w) ans = "The primeter of the rectangle is %s units!" print (ans%(p)) else: print ("You spelled area, perimeter or volume wrong, or what you typed in includes NUMBERS!") </code></pre>
0debug
in linux how would I copy files that file names partially match a list strings in a text file? : eg. filenames.csv contains a list of product codes PROD111, PROD222, ... that partially match file names in a folder: PROD111a.jpg, PROD111b.jpg, ... How would i copy the files that match into a new folder?
0debug
static void vtd_realize(DeviceState *dev, Error **errp) { MachineState *ms = MACHINE(qdev_get_machine()); MachineClass *mc = MACHINE_GET_CLASS(ms); PCMachineState *pcms = PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE)); PCIBus *bus; IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev); X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev); if (!pcms) { error_setg(errp, "Machine-type '%s' not supported by intel-iommu", mc->name); return; } bus = pcms->bus; x86_iommu->type = TYPE_INTEL; if (!vtd_decide_config(s, errp)) { return; } QLIST_INIT(&s->notifiers_list); memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem); s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal, g_free, g_free); s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal, g_free, g_free); vtd_init(s); sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR); pci_setup_iommu(bus, vtd_host_dma_iommu, dev); pcms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC); }
1threat
strdup(str) const char *str; { char *bptr; bptr = (char *)malloc(strlen(str)+1); strcpy(bptr, str); return bptr; }
1threat
i want to create a table with all records and column names from tableA to tableB in sql server : <blockquote> <p>create table tableB as ( select * from tableA) --this works in oracle but not in sql server</p> </blockquote>
0debug
Excel help me with a basic formula : So I have a spreadsheet with hundreds of lines. For Example: A1=E, A2=E, A3=S, A4=E, A5=S, A6=C, A7=C, A8=E I am looking for help if it's even possible to have a formula that I can drag down and based on the sequence it can determine the category for me. For example if E then E only, if E followed by S then result shows as "E + S", if E followed by S and C or multiple Cs then "FM" to indicate family. Please help as it is truly appreciated.
0debug
How to handle internationalization/localization with Gatsby JS? : <p>I would like to publish my static site in various locals around the world with localized content.</p> <p>How does one accomplish this?</p>
0debug
void qmp_cont(Error **errp) { Error *local_err = NULL; if (runstate_check(RUN_STATE_INMIGRATE)) { error_set(errp, QERR_MIGRATION_EXPECTED); return; } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) || runstate_check(RUN_STATE_SHUTDOWN)) { error_set(errp, QERR_RESET_REQUIRED); return; } else if (runstate_check(RUN_STATE_SUSPENDED)) { return; } bdrv_iterate(iostatus_bdrv_it, NULL); bdrv_iterate(encrypted_bdrv_it, &local_err); if (local_err) { error_propagate(errp, local_err); return; } vm_start(); }
1threat
How can i print a line of an html with python keeping the right format? : I have this code: ENSG00000001461'&nbsp';'&nbsp';'&nbsp';'&nbsp';ENST00000432012'&nbsp';'&nbsp';'&nbsp';'&nbsp';NIPAL3'&nbsp';'&nbsp';'&nbsp';'&nbsp';5'&nbsp';'&nbsp';'&nbsp';'&nbsp';1'&nbsp';'&nbsp';'&nbsp';'&nbsp';Forward'&nbsp';'&nbsp';'&nbsp';'&nbsp';NIPA-like domain containing 3 [Source:HGNC Symbol;Acc:HGNC:25233]<'br /'> I want this output: ENSG00000001461 ENST00000432012 NIPAL3 5 1 Forward NIPA-like domain containing 3 [Source:HGNC Symbol;Acc:HGNC:25233] But the output is only: ENSG00000001461 Thanks, Federico
0debug
Build processing, Build first appears like bellow after that its not appears in iTunes connect : I'm facing this problem, Build successfully Uploaded in Xcode But Build first appears like bellow after that its not appears in iTunes connect.Why I'm facing this problem? [enter image description here][1] [1]: https://i.stack.imgur.com/dwKep.png
0debug
Why do need to use new Random() instead of just Random Randomnum? : <p>I'm currently doing the mooc java course and I'm not able to understand why exactly we need to include new Random() part after declaring a new new variable randomVar with the class type Random?</p> <pre><code> private Random randomNum = new Random(); // Why this? private Random randomNum; //Instead of this? </code></pre>
0debug
How to set a default port for ASP.NET Core Angular app : <p>I created a dotnet core project with the template <strong>ASP.NET Core with Angular</strong> using the dotnet CLI</p> <p><code>dotnet new angular</code></p> <p>Now, whenever I run the application using <code>dotnet run</code> command, angular serves with a different port each time.</p> <p>I tried setting the default serve port in angular-cli.json</p> <pre><code>"defaults": { .. "serve": { "port": 4200 } } </code></pre> <p>doesn't work though. </p> <p>I couldn't find any documentation online, so where can I set the default port?</p>
0debug
Error in creating SEQUENCEs when restoring the PostgreSQL database : <p><em>UserX</em> has following grants:</p> <pre><code>CREATE ROLE "UserX" LOGIN PASSWORD 'pass'; CREATE DATABASE "DBX" WITH OWNER="UserX" ENCODING='UTF8' TABLESPACE=pg_default CONNECTION LIMIT=-1; GRANT CONNECT ON DATABASE "DBX" TO "UserX"; GRANT USAGE ON SCHEMA public TO "UserX"; GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA public TO "UserX"; ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO "UserX"; ALTER DEFAULT PRIVILEGES GRANT ALL ON SEQUENCES TO "UserX"; </code></pre> <p>I get following errors when trying to restore its dump to other database:</p> <pre><code>pg_restore: creating SEQUENCE "public.tblX_Id_seq" pg_restore: [archiver (db)] Error from TOC entry 218; 1259 438745 SEQUENCE tblX_Id_seq UserX pg_restore: [archiver (db)] could not execute query: ERROR: syntax error at or near "AS" LINE 2: AS integer ^ Command was: CREATE SEQUENCE "tblX_Id_seq" AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACH... pg_restore: [archiver (db)] could not execute query: ERROR: relation "tblX_Id_seq" does not exist Command was: ALTER TABLE "tblX_Id_seq" OWNER TO "UserX"; pg_restore: creating SEQUENCE OWNED BY "public.tblX_Id_seq" pg_restore: [archiver (db)] Error from TOC entry 3569; 0 0 SEQUENCE OWNED BY tblX_Id_seq UserX pg_restore: [archiver (db)] could not execute query: ERROR: relation "tblX_Id_seq" does not exist Command was: ALTER SEQUENCE "tblX_Id_seq" OWNED BY "tblX"."Id"; ... pg_restore: creating DEFAULT "public.tblX Id" pg_restore: [archiver (db)] Error from TOC entry 2995; 2604 438750 DEFAULT tblX Id UserX pg_restore: [archiver (db)] could not execute query: ERROR: relation "tblX_Id_seq" does not exist Command was: ALTER TABLE ONLY "tblX" ALTER COLUMN "Id" SET DEFAULT nextval('"tblX_Id_seq"'::regclass); ... pg_restore: executing SEQUENCE SET tblX_Id_seq pg_restore: [archiver (db)] Error from TOC entry 3607; 0 0 SEQUENCE SET tblX_Id_seq UserX pg_restore: [archiver (db)] could not execute query: ERROR: relation "tblX_Id_seq" does not exist LINE 1: SELECT pg_catalog.setval('"tblX_Id_seq"', 1573, true); ^ Command was: SELECT pg_catalog.setval('"tblX_Id_seq"', 1573, true); </code></pre> <p>Any suggestion on what I do wrong?</p>
0debug
Does a "null" node in a list count as an item in the list? : <p>As part of some coursework I have to write a program that returns the number of nodes in a list. If the list exists but it contains only 1 null node, should the number returned be 0 or 1 ?</p>
0debug
static void gen_slbia(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } gen_helper_slbia(cpu_env); #endif }
1threat
int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height) { AVPicture dummy_pict; if(av_image_check_size(width, height, 0, NULL)) return -1; switch (pix_fmt) { case PIX_FMT_RGB8: case PIX_FMT_BGR8: case PIX_FMT_RGB4_BYTE: case PIX_FMT_BGR4_BYTE: case PIX_FMT_GRAY8: return width * height; } return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height); }
1threat
python double colon with -1 as third parameter : <p>Take <code>a = [1,2,3,4,5]</code> as an example. From my instinct, I think <code>a[::-1]</code> is the same as <code>a[0:len(a):-1]</code>. But the result turns to be wrong:</p> <pre><code>&gt;&gt;&gt; a = [1,2,3,4,5] &gt;&gt;&gt; print a[::-1] [5, 4, 3, 2, 1] &gt;&gt;&gt; print a[0:len(a):-1] [] &gt;&gt;&gt; print a[0:3:-1] [] &gt;&gt;&gt; print a[0:2:-1] [] &gt;&gt;&gt; print a[:2:-1] [5, 4] &gt;&gt;&gt; print a[:0:-1] [5, 4, 3, 2] &gt;&gt;&gt; print a[0:-1] [1, 2, 3, 4] </code></pre> <p>I actually can't understand the last 6 attempt's output. Could anyone give me some idea? Thanks tons.</p>
0debug
static int blk_free(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); struct ioreq *ioreq; while (!LIST_EMPTY(&blkdev->freelist)) { ioreq = LIST_FIRST(&blkdev->freelist); LIST_REMOVE(ioreq, list); qemu_iovec_destroy(&ioreq->v); qemu_free(ioreq); } qemu_free(blkdev->params); qemu_free(blkdev->mode); qemu_free(blkdev->type); qemu_free(blkdev->dev); qemu_free(blkdev->devtype); qemu_bh_delete(blkdev->bh); return 0; }
1threat
PHP SQL update using variables posted into form : <p>I have a form that takes variables from another form like so:</p> <pre><code>$employeeid = $_POST['modifyid']; $fname = $_POST['modifyfn']; $lname = $_POST['modifyln']; $staffno = $_POST['modifysn']; $empusername = $_POST['modifyeu']; &lt;/br&gt; &lt;td&gt;&lt;form action="empmodify.php" method="post"&gt; &lt;?php echo "&lt;div class='form-group'&gt; &lt;tr&gt;&lt;td&gt;ID:&lt;/td&gt;&lt;td&gt; &lt;input type='text' class='form-control' name='modid' value='" . $employeeid . "'/&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/div&gt; &lt;div class='form-group'&gt; &lt;tr&gt;&lt;td&gt;First Name:&lt;/td&gt;&lt;td&gt; &lt;input type='text' class='form-control' name='modfn' value='" . $fname . "'/&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/div&gt; &lt;div class='form-group'&gt; &lt;tr&gt;&lt;td&gt;Surname Name:&lt;/td&gt;&lt;td&gt; &lt;input type='text' class='form-control' name='modln' value='" . $lname . "'/&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/div&gt; &lt;div class='form-group'&gt; &lt;tr&gt;&lt;td&gt;Staff number:&lt;/td&gt;&lt;td&gt; &lt;input type='text' class='form-control' name='modsn' value='" . $staffno . "'/&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/div&gt; &lt;div class='form-group'&gt; &lt;tr&gt;&lt;td&gt;Username:&lt;/td&gt;&lt;td&gt; &lt;input type='text' class='form-control' name='modeu' value='" . $empusername . "'/&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/div&gt; &lt;button type='submit' class='btn btn-default'&gt;Modify this Employee&lt;/button&gt;"?&gt; &lt;/form&gt;&lt;/td&gt; &lt;/div&gt; </code></pre> <p>These variables are already in the database - This part is working. What I would like is that when the user clicks submit it updates the record with anything they have changed in this form. Here is my empmodify.php:</p> <pre><code>$employeeid = $_POST['modid']; $fname = $_POST['modfn']; $lname = $_POST['modln']; $staffno = $_POST['modsn']; $empusername = $_POST['modeu']; $result = mysql_query("UPDATE employee SET fname = '$fname', lname = '$lname', staffno = '$staffno', empusername = '$empusername' WHERE employeeid = '$employeeid'"); </code></pre> <p>I have tried so many things with my variables but the update statement just doesn't seem to be working. I tried single quotes, double quotes, post, and concatenating them but nothing.. any ideas? :)</p>
0debug
static void virtio_pci_config_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { VirtIOPCIProxy *proxy = opaque; uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); if (addr < config) { virtio_ioport_write(proxy, addr, val); return; } addr -= config; switch (size) { case 1: virtio_config_writeb(vdev, addr, val); break; case 2: if (virtio_is_big_endian()) { val = bswap16(val); } virtio_config_writew(vdev, addr, val); break; case 4: if (virtio_is_big_endian()) { val = bswap32(val); } virtio_config_writel(vdev, addr, val); break; } }
1threat
I have to hide part of main form in winForm : <p>I have to change main form's height when state of checkbox changes. Is there any way I can change main form's height or hide part of main form??</p>
0debug
void av_force_cpu_flags(int arg){ if ( (arg & ( AV_CPU_FLAG_3DNOW | AV_CPU_FLAG_3DNOWEXT | AV_CPU_FLAG_MMXEXT | AV_CPU_FLAG_SSE | AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_SSE2SLOW | AV_CPU_FLAG_SSE3 | AV_CPU_FLAG_SSE3SLOW | AV_CPU_FLAG_SSSE3 | AV_CPU_FLAG_SSE4 | AV_CPU_FLAG_SSE42 | AV_CPU_FLAG_AVX | AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_XOP | AV_CPU_FLAG_FMA3 | AV_CPU_FLAG_FMA4 | AV_CPU_FLAG_AVX2 )) && !(arg & AV_CPU_FLAG_MMX)) { av_log(NULL, AV_LOG_WARNING, "MMX implied by specified flags\n"); arg |= AV_CPU_FLAG_MMX; } cpu_flags = arg; }
1threat
static int qemu_loadvm_state(QEMUFile *f) { SaveStateEntry *se; int len, ret, instance_id, record_len, version_id; int64_t total_len, end_pos, cur_pos; unsigned int v; char idstr[256]; v = qemu_get_be32(f); if (v != QEMU_VM_FILE_MAGIC) goto fail; v = qemu_get_be32(f); if (v != QEMU_VM_FILE_VERSION) { fail: ret = -1; goto the_end; } total_len = qemu_get_be64(f); end_pos = total_len + qemu_ftell(f); for(;;) { if (qemu_ftell(f) >= end_pos) break; len = qemu_get_byte(f); qemu_get_buffer(f, (uint8_t *)idstr, len); idstr[len] = '\0'; instance_id = qemu_get_be32(f); version_id = qemu_get_be32(f); record_len = qemu_get_be32(f); #if 0 printf("idstr=%s instance=0x%x version=%d len=%d\n", idstr, instance_id, version_id, record_len); #endif cur_pos = qemu_ftell(f); se = find_se(idstr, instance_id); if (!se) { fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n", instance_id, idstr); } else { ret = se->load_state(f, se->opaque, version_id); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", instance_id, idstr); } } qemu_fseek(f, cur_pos + record_len, SEEK_SET); } ret = 0; the_end: return ret; }
1threat
void usb_wakeup(USBEndpoint *ep, unsigned int stream) { USBDevice *dev = ep->dev; USBBus *bus = usb_bus_from_device(dev); if (dev->remote_wakeup && dev->port && dev->port->ops->wakeup) { dev->port->ops->wakeup(dev->port); if (bus->ops->wakeup_endpoint) { bus->ops->wakeup_endpoint(bus, ep, stream);
1threat
HOW TO PREVENT CKEDITOR NOT SAVING HTML TAGS , BUT JUST THE RICH TEXT : Please find attached the html code and the printscreen of my problem . When i write something in ckeditor , and apply styling with html tags , it saved the text with html tags , and not just the text itself , in this case just CONTENT SAMPLE TEXT, and to apply the styling for html certain tags , and not show &lt;p&gt;&lt;/p&gt; [Result][1] [1]: https://i.stack.imgur.com/XdPct.png <div class="form-group"> @Html.LabelFor(model => model.LongDescription1, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.TextAreaFor(model => model.LongDescription1, new { @id = "LongDescription1", @class = "form-control", @rows = "200" }) @Html.ValidationMessageFor(model => model.LongDescription1, "", new { @class = "text-danger" }) <script>CKEDITOR.replace("LongDescription1", { htmlEncodeOutput: true });</script> </div> </div>
0debug
creating index on table : What index would be created for this syntax ''CREATE **INDEX** IDX_NAME ON TABLE(Column name)''
0debug
Problems while setting up vue-cli : <p>I'm trying to install Vue-cli environemnt via NPM.</p> <pre><code>npm install --global vue-cli </code></pre> <p>After that I want to create project </p> <pre><code>vue init webpack my-project </code></pre> <p>And I get an error</p> <pre><code>'vue' is not recognized as an internal or external command, operable program or batch file. </code></pre> <p>I've read some solutions, most of them concern changing </p> <p><strong>PATH to C:\Users{YourUser}\AppData\Roaming\npm</strong></p> <p>Didn't work for me. Can anyone help.</p>
0debug
How can I pass a generic type parameter to an Angular2 component? : <p>Let's say I got a component with a fixed input parameter type,</p> <pre><code>@Component({ selector: 'fixed', template: '&lt;div&gt;{{value}}&lt;/div&gt;' }) export class FixedComponent { @Input() value: string; } </code></pre> <p>How do I go about making that parameter type generic, i.e.</p> <pre><code>@Component({ selector: 'generic', template: '&lt;div&gt;{{value}}&lt;/div&gt;' }) export class GenericComponent&lt;T&gt; { @Input() value: T; } </code></pre> <p>That is, how do I pass the type in the template of the parent component?</p> <pre><code>&lt;generic ...&gt;&lt;/generic&gt; </code></pre>
0debug
static void spapr_core_release(DeviceState *dev, void *opaque) { HotplugHandler *hotplug_ctrl; hotplug_ctrl = qdev_get_hotplug_handler(dev); hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); }
1threat
For loop java not executing properly? : <pre><code>//Declared here the atributes int id and int [9][5] array. public String getPos(int id){ String res = ""; for(int i = 0; i &lt;9 ;i++ ){ for(int j = 0; j&lt;5 ;j++){ if(this.arr[i][j] == id) res = res + i + "," + j; } } return res; } </code></pre> <p>When I run getPos(1); the result is 8,2 but i want it to print 9,3. How i do that?</p>
0debug
static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule) { BDRVBlkdebugState *s = bs->opaque; BlkdebugSuspendedReq r; r = (BlkdebugSuspendedReq) { .co = qemu_coroutine_self(), .tag = g_strdup(rule->options.suspend.tag), }; remove_rule(rule); QLIST_INSERT_HEAD(&s->suspended_reqs, &r, next); printf("blkdebug: Suspended request '%s'\n", r.tag); qemu_coroutine_yield(); printf("blkdebug: Resuming request '%s'\n", r.tag); QLIST_REMOVE(&r, next); g_free(r.tag); }
1threat
Python - Can I import variables from another file as class variables ? : I am trying to find a way to import variables ( dicts) from a file, which will be used inside as class , as class variables. Since I can't use **from myVarFile import *** inside a class, only at the module level, how would I import them as class variables eg from myVarFile import * class myClass(): #class variables here #should be the data from imported files print someImportedVariable def __init__(self): #init here def someClassFunction(self): #needs to access class variables self.someImportedVariable As a test I have tried assigning 'global' to all the variables in myVarFile, and adding global variable names inside the class, this works at the class level. But I cannot get any methods to work at all, eg class myClass(): #class variables here #should be the data from imported files global someImportedVariable print someImportedVariable #this works def __init__(self): #init here def someClassFunction(self): #needs to access class variables self.someImportedVariable #this does not I wanted to avoid having to globally declare all the variables in each class method, that seems wrong. Do methods inherit the class variables if they are globally declared from an imported file ?
0debug
int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { AVFrame frame; int ret, got_frame = 0; if (avctx->get_buffer != avcodec_default_get_buffer) { av_log(avctx, AV_LOG_ERROR, "A custom get_buffer() cannot be used with " "avcodec_decode_audio3()\n"); return AVERROR(EINVAL); } ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt); if (ret >= 0 && got_frame) { int ch, plane_size; int planar = av_sample_fmt_is_planar(avctx->sample_fmt); int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels, frame.nb_samples, avctx->sample_fmt, 1); if (*frame_size_ptr < data_size) { av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for " "the current frame (%d < %d)\n", *frame_size_ptr, data_size); return AVERROR(EINVAL); } memcpy(samples, frame.extended_data[0], plane_size); if (planar && avctx->channels > 1) { uint8_t *out = ((uint8_t *)samples) + plane_size; for (ch = 1; ch < avctx->channels; ch++) { memcpy(out, frame.extended_data[ch], plane_size); out += plane_size; } } *frame_size_ptr = data_size; } else { *frame_size_ptr = 0; } return ret; }
1threat
int unix_socket_outgoing(const char *path) { Error *local_err = NULL; int fd = unix_connect(path, &local_err); if (local_err != NULL) { qerror_report_err(local_err); error_free(local_err); } return fd; }
1threat
Measure the length of an svg path? : <p>I am playing with Scrollmagic and want to use the effect here: <a href="http://scrollmagic.io/examples/advanced/svg_drawing.html" rel="noreferrer">http://scrollmagic.io/examples/advanced/svg_drawing.html</a></p> <p>I created a squiggle svg to test it out and need to insert the length of the path in to stroke-dasharray: 2000px; stroke-dashoffset: 2000px; </p> <p>How can I find the length of the path?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> function pathPrepare ($el) { var lineLength = $el[0].getTotalLength(); $el.css("stroke-dasharray", lineLength); $el.css("stroke-dashoffset", lineLength); } var $word = $("path#word"); var $dot = $("path#dot"); // prepare SVG pathPrepare($word); // init controller var controller = new ScrollMagic.Controller(); // build tween var tween = new TimelineMax() .add(TweenMax.to($word, 0.9, {strokeDashoffset: 0, ease:Linear.easeNone})) // draw word for 0.9 .add(TweenMax.to("path", 1, {stroke: "#33629c", ease:Linear.easeNone}), 0); // change color during the whole thing // build scene var scene = new ScrollMagic.Scene({triggerElement: "#trigger1", duration: 200, tweenChanges: true}) .setTween(tween) .addIndicators() // add indicators (requires plugin) .addTo(controller); &lt;/script&gt;</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.js"&gt;&lt;/script&gt; &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.16.1/TweenMax.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.2/plugins/animation.gsap.js"&gt;&lt;/script&gt; &lt;div style="height: 400px;"&gt;&lt;/div&gt; &lt;div class="spacer s2"&gt;&lt;/div&gt; &lt;div id="trigger1" class="spacer s0"&gt;&lt;/div&gt; &lt;svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 841.9 595.3" xml:space="preserve" width="1000px"&gt; &lt;style type="text/css"&gt; .st0{fill:none;stroke:#000000;stroke-width:12;stroke-miterlimit:10;} &lt;/style&gt; &lt;path id="word" style="stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2000px; stroke-dashoffset: 2000px;" fill="none" class="st0" d="M29.7,6.4c-42,87.9,34.6,16.4,96.4,12.1s346,145.7,192.8,110.4S40.8,9.8,66.8,128s179.2,218.1,281.7,122.4 s10.2-115.2,215-94c465.8,48.3,233.5,90.1,90.2,85.4c-247-8.1,299.2,110.9-259.5,138C46.5,396.6-33.3,439.2,145.8,491 s171.8-83.6,431.3-18.1s96.4,107.8-79.1,122.4"/&gt; &lt;/svg&gt; &lt;div style="height: 400px;"&gt;&lt;/div&gt; &lt;div class="spacer s2"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
0debug
Is this type aliasing syntax n Go? : <p>I did not get the below syntax in <code>../go/src/net/http/server.go</code>:</p> <pre><code>var defaultServeMux ServeMux </code></pre> <p>where</p> <p><code>ServeMux</code> is a struct</p> <pre><code>type ServeMux struct { mu sync.RWMutex m map[string]muxEntry es []muxEntry hosts bool } </code></pre> <hr> <p>In GO, type aliasing looks like <code>type T1 = T2</code>. </p> <p>Is the above syntax(used for <code>defaultServeMux</code>) anything to do with type aliasing?</p>
0debug
mysql trigger error when declaration : i try to create a trigger but i get this error after execute the SQL; #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DECLARE temp INT' at line 4 here is my trigger CREATE TRIGGER hesap AFTER INSERT ON uber DECLARE temp INT; BEGIN IF uber.il='ANKARA' THEN temp=5+(uber.mesafe*0.5); ELSEIF uber.il='ISTANBUL' THEN temp=10+(uber.mesafe*0.5); ELSEIF uber.il='IZMIR' THEN temp=3+(uber.mesafe*0.5); END IF; INSERT INTO fatura VALUES(uber.uid,temp) END;
0debug
Flutter: Shared Preferences null on Startup : <p>Problem: Shared preference bool value is <code>null</code> on startup even though I have given it a value if <code>prefs.getBool('myBool')</code> returns <code>null</code> (though my shared preferences value should already be set and saved). It does, however, work by the time I press a button (I assume because it has finished running the async code).</p> <p>Question: How can I force shared preferences to load on startup (so my value is not <code>null</code>) without having to press the print button?</p> <p>Example Code:</p> <pre><code>import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() =&gt; runApp(new MyApp()); class MyApp extends StatefulWidget { MyApp({Key key}) : super(key: key); @override createState() =&gt; new MyAppState(); } class MyAppState extends State&lt;MyApp&gt; { final padding = const EdgeInsets.all(50.0); @override void initState() { super.initState(); MySharedPreferences.load(); MySharedPreferences.printMyBool(); } @override Widget build(BuildContext context) { return new MaterialApp( home: new Scaffold( body: new Padding( padding: padding, child: new Column( children: &lt;Widget&gt;[ new Padding( padding: padding, child: new RaisedButton( child: new Text('Save True'), onPressed: () =&gt; MySharedPreferences.save(myBool: true), ), ), new Padding( padding: padding, child: new RaisedButton( child: new Text('Save False'), onPressed: () =&gt; MySharedPreferences.save(myBool: false), ), ), new Padding( padding: padding, child: new RaisedButton( child: new Text('Print myBool'), onPressed: () =&gt; MySharedPreferences.printMyBool(), ), ), ], ), ), ), ); } } class MySharedPreferences { static bool _myBool; static void load() async { SharedPreferences prefs = await SharedPreferences.getInstance(); _myBool = prefs.getBool('myBool') ?? false; } static void save({myBool: bool}) async { SharedPreferences prefs = await SharedPreferences.getInstance(); _myBool = myBool; await prefs.setBool('myBool', _myBool); } static void printMyBool() { print('myBool: ${_myBool.toString()}'); } } </code></pre> <p>Results: On startup, <code>myBool: null</code> is printed. Once the button is pressed, <code>myBool: false/true</code> is then printed.</p>
0debug
PutItem in DynamoDB table by CloudFormation : <p>Is there any way to put items in a DynamoDB table using CloudFormation ? Something similar to the code in this <a href="http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html" rel="noreferrer">doc</a></p> <p>In the parameter of the template I give the user the possibility to put the values, then I need to insert these values into the table.</p>
0debug
Creating a new syntax for Sublime text 3 on the basis exists : I'm trying to create the syntax highlighting for [Flex][1]. I'm using [PackageDev][2] and YAML. So, I want find a blocks, starting with `%{` and ending with `%}`, then I need highlight everything inside this block as C++ code. I thought about two variants, both of them don't work: # ... # first - begin: '%\{' end: '%\}' contentName: patterns: - include: source.c++ # that's doesn't work # second - match: '%\{((?:.|\n)*)%\}' # regexpr works correctly name: source.c++ captures: '1': - include: source.c++ # that's doesn't work too If someone knows how do that or know some good manual for sublime syntax - say me, please. [1]: https://www.google.ru/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&cad=rja&uact=8&ved=0ahUKEwiUuOXZnuHKAhXDNpoKHep-Cs8QFghAMAQ&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFlex_(lexical_analyser_generator)&usg=AFQjCNFt5KoQZ6HIa9Av-WU07RNLb6lBHw&sig2=jaQkTfZBvGt37rckwYXLGw [2]: https://packagecontrol.io/packages/PackageDev
0debug
int monitor_fdset_dup_fd_remove(int dupfd) { return -1; }
1threat
panic: runtime error: invalid memory address or nil pointer dereference only on the GAE : I am working on the golang app using gin framework. Basically it just fetch the data from firestore as json. Localy it works perfectly but when I deploy it to the GAE (gcloud app deploy) there is no error during deployment but when access the page it does not work and in the logs provide an error: "panic: runtime error: invalid memory address or nil pointer dereference" Can you please help me to resolve this frustrating problem. Thank you in advance Here is my go page: package listcollections import ( "fmt" "log" "net/http" "cloud.google.com/go/firestore" "github.com/gin-gonic/gin" "google.golang.org/api/iterator" "google.golang.org/appengine" ) func main() { } //GetListCollections function func GetListCollections(c *gin.Context) { var coll []string ctx := appengine.NewContext(c.Request) projectID := "XXX" client, err := firestore.NewClient(ctx, projectID) if err != nil { log.Fatalf("Failed to create client: %v", err) } defer client.Close() iter := client.Collection("collection").Documents(ctx) for { doc, err := iter.Next() if err == iterator.Done { break } if err != nil { fmt.Println("ERROR") } coll = append(coll, doc.Data()["Title"].(string)) } c.JSON(http.StatusOK, gin.H{ "collections": coll, }) }
0debug
static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { PS2KbdState *s = (PS2KbdState *)dev; int scancodes[3], i, count; qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); count = qemu_input_key_value_to_scancode(evt->key->key, evt->key->down, scancodes); for (i = 0; i < count; i++) { ps2_put_keycode(s, scancodes[i]); } }
1threat
How do you set the value of an input field by complex selector? : <ul> <li><a href="http://p3rl.org/WWW::Mechanize::Chrome" rel="noreferrer">WWW::Mechanize::Chrome</a> 0.10</li> <li>Iridium 2017.11 in a headed desktop session</li> </ul> <p>I want to set the value of a certain <strong>formless</strong> input field.</p> <pre><code>my $field = $w-&gt;selector('tr.edit td[data-attribute="name"] input', single =&gt; 1); </code></pre> <p>finds it.</p> <pre><code>$field-&gt;attributes-&gt;{value} = 'test'; </code></pre> <p>has no apparent effect.</p> <p>Both</p> <pre><code>$w-&gt;field($field =&gt; 'test'); </code></pre> <p>and</p> <pre><code>$w-&gt;field('tr.edit td[data-attribute="name"] input' =&gt; 'test'); </code></pre> <p>error out with <code>No elements found for form number 1</code>.</p>
0debug
Select two columns with different where clause : I want to select two columns, for the example one name x and the other one is y for to get x data I need to write in the where clause IsTure='no' and count the the id by grouping by date. and for y in need to count the id by different where clause and group by date also. and the date field is different for x and y It should like this : Id Date x y How can I implement this kind of query ? Thanks
0debug
static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s) { uint64_t value = 0; value = vtd_get_quad_raw(s, DMAR_IRTA_REG); s->intr_size = 1UL << ((value & VTD_IRTA_SIZE_MASK) + 1); s->intr_root = value & VTD_IRTA_ADDR_MASK; VTD_DPRINTF(CSR, "int remap table addr 0x%"PRIx64 " size %"PRIu32, s->intr_root, s->intr_size); }
1threat
static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs, int64_t offset, unsigned int bytes, QEMUIOVector *qiov) { void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_offset; unsigned int cluster_bytes; size_t skip_bytes; int ret; bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes); trace_bdrv_co_do_copy_on_readv(bs, offset, bytes, cluster_offset, cluster_bytes); iov.iov_len = cluster_bytes; iov.iov_base = bounce_buffer = qemu_try_blockalign(bs, iov.iov_len); if (bounce_buffer == NULL) { ret = -ENOMEM; goto err; } qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = bdrv_driver_preadv(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); if (ret < 0) { goto err; } if (drv->bdrv_co_pwrite_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, cluster_bytes, 0); } else { ret = bdrv_driver_pwritev(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); } if (ret < 0) { goto err; } skip_bytes = offset - cluster_offset; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, bytes); err: qemu_vfree(bounce_buffer); return ret; }
1threat
what *first is printing here in this code ? : please tell what *first is printing here please tell what *first is printing here [output of the following code ][1] struct Node{ int info; struct Node *next; }; void main() { struct Node* first=NULL; struct Node* second=NULL; struct Node* third=NULL; first=(struct Node*) malloc(sizeof(struct Node)); second=(struct Node*) malloc(sizeof(struct Node)); third=(struct Node*) malloc(sizeof(struct Node)); first->info=1; first->next=second; printf("*first %d ->\n ",*first); //6487584 ?? what is *first is here should it be same as first->info? printf("first %d ->\n",first); //13439936 printf("&first %d ->\n",&first); //6487608 printf("&first->info %d ->\n",&first->info); //13439936 printf("&first->next %d ->\n",&first->next); //13439944 } [1]: https://i.stack.imgur.com/5gtUe.png
0debug
Merge, Union, Intersect C# List of Objects : <p>I am trying to solve this problem:</p> <p>I have multiple array of string with some having duplicate items. I need to come up with a final list that has most items in each list</p> <pre><code>a1 = Array{"A", "B", "C","D","E","F"}; a2 = Array{"A", "B", "B", "C","D","D","D","E","F"}; a3 = Array{"A", "B", "B", "C","D","D","E","F"}; a4 = Array{"A", "B", "B", "B", "C","D","D","E","F"}; a5 = Array{"A", "B", "B", ","D","D","E","E","F"}; </code></pre> <p>Final result should be:</p> <pre><code>FinalArray = {"A", "B", "B", "B", "C","D","D","D","E","E""F"}; </code></pre> <p>Max. occurrence each items accounted in the final result.</p> <p>How can I achieve this?</p>
0debug
ruby convert a string to a plain text? : I am trying to implement a mongo query. I wrote a function that returns one of the query's parameter. "'Week Of': {'$in': [02/13/17]}" However, when I dont want the double quotes at the front and back of the string. I understand it is a string and it needs it but when I inject it into my query, it will not work because it has those double quotes. Is there any way to convert the string to a plain text so it would only be `'Week Of': {'$in': [02/13/17]}` ?
0debug
static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, float *x, float z[320], float W[2][32][32][2]) { int i, k; memcpy(W[0], W[1], sizeof(W[0])); memcpy(x , x+1024, (320-32)*sizeof(x[0])); memcpy(x+288, in, 1024*sizeof(x[0])); for (i = 0; i < 32; i++) { dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); for (k = 0; k < 64; k++) { float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; z[k] = f; } z[64] = z[0]; for (k = 1; k < 32; k++) { z[64+2*k-1] = z[ k]; z[64+2*k ] = -z[64-k]; } z[64+63] = z[32]; mdct->imdct_half(mdct, z, z+64); for (k = 0; k < 32; k++) { W[1][i][k][0] = -z[63-k]; W[1][i][k][1] = z[k]; } x += 32; } }
1threat
static PCIIDEState *pci_from_bm(BMDMAState *bm) { return bm->pci_dev; }
1threat
Convert list of lists with different lengths to a numpy array : <p>I have list of lists with different lengths (e.g. <code>[[1, 2, 3], [4, 5], [6, 7, 8, 9]]</code>) and want to convert it into a <code>numpy</code> array of integers. I understand that 'sub' arrays in <code>numpy</code> multidimensional array must be the same length. So what is the most efficient way to convert such a list as in example above into a <code>numpy</code> array like this <code>[[1, 2, 3, 0], [4, 5, 0, 0], [6, 7, 8, 9]]</code>, i.e. completed with zeros?</p>
0debug
Java - Why can you call a method before it has been defined? : public class MainClass { public static void main(String[] args) { anotherTest(); test(); } public static void test() { System.out.println("Printed from the test method."); } public static void anotherTest() { System.out.println("Printed from the anotherTest method."); } } Hello, Sorry if this is a basic question but this has been puzzling me for quite some time. I would like to know why you can call a method before it has been defined like the code above. The code above shows two methods at the bottom of the page but I am calling them in the main method before they have been loaded. If I were to do something similar in Python I would get an error. Thanks, Test.
0debug
javascript: loop add number : <p>How to loop like this one in javascript? 11 21 32 43</p> <p>I have this code already.</p> <pre><code>for(var i=11; i &lt;= 43; i += 10){ document.write(i+'&lt;br&gt;'); } </code></pre>
0debug
How to generate a random sequence of numbers in python? : <p>I need to create a short unique ID which is a random sequence of numbers in python. So i need to allocate the short sequence to a user and also store it in a text file</p> <p>Can some one please help me with this and give me an example??</p>
0debug
Inconsistent Line Endings Visual Studio Community 2017 : <p>In 2015 you could change this from File -> Advanced Save, however this is no longer a menu option.</p> <p>Where is it located now? I mean the option to actually change what the line endings are, not disable the message.</p>
0debug
Unboxing Integer cast from null : <p>What is the value of <code>i</code> when you execute the code below and why?</p> <pre><code>int i = (Integer)null; </code></pre>
0debug
static const TPMDriverOps *tpm_driver_find_by_type(enum TpmType type) { int i; for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) { if (be_drivers[i]->type == type) { return be_drivers[i]; } } return NULL; }
1threat
SQL select multiple rows into one row : <p>I have a table with related data across multiple rows that I need to query as one row IF the meta_key value is in <code>('A', 'B', 'C')</code>.</p> <pre><code>meta_id | post_id | meta_key | meta_value --------+---------+----------+----------- 1 | 1234 | A | Foo 2 | 1234 | B | Bar 3 | 1234 | C | Baz 4 | 1234 | D | junk </code></pre> <p>What I am looking to end up with is a query that gives me results</p> <p><strong>Output</strong></p> <pre><code> A | B | C ----+-----+---- Foo | Bar | Baz </code></pre>
0debug
static int scsi_generic_initfn(SCSIDevice *dev) { SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, dev); int sg_version; struct sg_scsi_id scsiid; if (!s->qdev.conf.dinfo || !s->qdev.conf.dinfo->bdrv) { error_report("scsi-generic: drive property not set"); return -1; } s->bs = s->qdev.conf.dinfo->bdrv; if (!bdrv_is_sg(s->bs)) { error_report("scsi-generic: not /dev/sg*"); return -1; } if (bdrv_ioctl(s->bs, SG_GET_VERSION_NUM, &sg_version) < 0 || sg_version < 30000) { error_report("scsi-generic: scsi generic interface too old"); return -1; } if (bdrv_ioctl(s->bs, SG_GET_SCSI_ID, &scsiid)) { error_report("scsi-generic: SG_GET_SCSI_ID ioctl failed"); return -1; } s->lun = scsiid.lun; DPRINTF("LUN %d\n", s->lun); s->qdev.type = scsiid.scsi_type; DPRINTF("device type %d\n", s->qdev.type); if (s->qdev.type == TYPE_TAPE) { s->qdev.blocksize = get_stream_blocksize(s->bs); if (s->qdev.blocksize == -1) s->qdev.blocksize = 0; } else { s->qdev.blocksize = get_blocksize(s->bs); if (s->qdev.blocksize <= 0) { if (s->qdev.type == TYPE_ROM || s->qdev.type == TYPE_WORM) s->qdev.blocksize = 2048; else s->qdev.blocksize = 512; } } DPRINTF("block size %d\n", s->qdev.blocksize); s->driver_status = 0; memset(s->sensebuf, 0, sizeof(s->sensebuf)); return 0; }
1threat
remove repeated numbers without set python 3 : <p>i want to remove repeated numbers without set. i want to used def functions,There is something in the way?</p> <pre><code>x =[1,3,4,5,5,5,5,6,8,9] print(x) output:[1,3,4,5,6,8,9] </code></pre>
0debug
Github Webhook With Jenkins return 302 NotFound : <p>I set up localhost jenkins, using ngrok to expose my jenkins to github. I didn't set up any credentials. When I test delivery from webhook, it shows 302 not found. Response: </p> <pre><code>Content-Length: 0 Date: Mon, 16 Apr 2018 02:09:22 GMT Location: http://056b05cb.ngrok.io/github-webhook/ Server: Jetty(9.4.z-SNAPSHOT) X-Content-Type-Options: nosniff </code></pre> <p>Request:</p> <pre><code>Headers Request URL: http://056b05cb.ngrok.io/github-webhook Request method: POST content-type: application/json Expect: User-Agent: GitHub-Hookshot/d5b13bc X-GitHub-Delivery: bdc31e52-4115-11e8-9e6b-c7d083151290 X-GitHub-Event: push Payload { "ref": "refs/heads/master", "before": "14e1265dc10ef64c93ee7791db7fa9ccef63279f", "after": "1f51b991d10af7c2b8fb4bc4c44417a57cf7bb56", "created": false, "deleted": false, "forced": false, "base_ref": null, ..... } </code></pre>
0debug
iOS 10 bug: UICollectionView received layout attributes for a cell with an index path that does not exist : <p>Running my app in a device with iOS 10 I get this error:</p> <p><em>UICollectionView received layout attributes for a cell with an index path that does not exist</em></p> <p>In iOS 8 and 9 works fine. I have been researching and I have found that is something related to invalidate the collection view layout. I tried to implement that solution with no success, so I would like to ask for direct help. This is my hierarchy view:</p> <pre><code>-&gt;Table view -&gt;Each cell of table is a custom collection view [GitHub Repo][1] -&gt;Each item of collection view has another collection view </code></pre> <p>What I have tried is to insert</p> <pre><code> [self.collectionView.collectionViewLayout invalidateLayout]; </code></pre> <p>In the</p> <pre><code>- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView </code></pre> <p>of both collection views. </p> <p>Also I have tried to invalidate layout before doing a reload data, does not work...</p> <p>Could anyone give me some directions to take?</p>
0debug
static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, uint32_t event, uint32_t reason) { VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); VirtIOSCSIReq *req; VirtIOSCSIEvent *evt; VirtIODevice *vdev = VIRTIO_DEVICE(s); int in_size; if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { return; } req = virtio_scsi_pop_req(s, vs->event_vq); if (!req) { s->events_dropped = true; return; } if (req->elem.out_num || req->elem.in_num != 1) { virtio_scsi_bad_req(); } if (s->events_dropped) { event |= VIRTIO_SCSI_T_EVENTS_MISSED; s->events_dropped = false; } in_size = req->elem.in_sg[0].iov_len; if (in_size < sizeof(VirtIOSCSIEvent)) { virtio_scsi_bad_req(); } evt = req->resp.event; memset(evt, 0, sizeof(VirtIOSCSIEvent)); evt->event = event; evt->reason = reason; if (!dev) { assert(event == VIRTIO_SCSI_T_EVENTS_MISSED); } else { evt->lun[0] = 1; evt->lun[1] = dev->id; if (dev->lun >= 256) { evt->lun[2] = (dev->lun >> 8) | 0x40; } evt->lun[3] = dev->lun & 0xFF; } virtio_scsi_complete_req(req); }
1threat
static int config_props(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; LutContext *lut = ctx->priv; const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format]; int min[4], max[4]; int val, comp, ret; lut->hsub = desc->log2_chroma_w; lut->vsub = desc->log2_chroma_h; lut->var_values[VAR_W] = inlink->w; lut->var_values[VAR_H] = inlink->h; switch (inlink->format) { case PIX_FMT_YUV410P: case PIX_FMT_YUV411P: case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: case PIX_FMT_YUV440P: case PIX_FMT_YUV444P: case PIX_FMT_YUVA420P: min[Y] = min[U] = min[V] = 16; max[Y] = 235; max[U] = max[V] = 240; min[A] = 0; max[A] = 255; break; default: min[0] = min[1] = min[2] = min[3] = 0; max[0] = max[1] = max[2] = max[3] = 255; } lut->is_yuv = lut->is_rgb = 0; if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1; else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1; if (lut->is_rgb) { switch (inlink->format) { case PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break; case PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break; case PIX_FMT_RGBA: case PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break; case PIX_FMT_BGRA: case PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break; } lut->step = av_get_bits_per_pixel(desc) >> 3; } for (comp = 0; comp < desc->nb_components; comp++) { double res; ret = av_expr_parse(&lut->comp_expr[comp], lut->comp_expr_str[comp], var_names, funcs1_names, funcs1, NULL, NULL, 0, ctx); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Error when parsing the expression '%s' for the component %d.\n", lut->comp_expr_str[comp], comp); return AVERROR(EINVAL); } lut->var_values[VAR_MAXVAL] = max[comp]; lut->var_values[VAR_MINVAL] = min[comp]; for (val = 0; val < 256; val++) { lut->var_values[VAR_VAL] = val; lut->var_values[VAR_CLIPVAL] = av_clip(val, min[comp], max[comp]); lut->var_values[VAR_NEGVAL] = av_clip(min[comp] + max[comp] - lut->var_values[VAR_VAL], min[comp], max[comp]); res = av_expr_eval(lut->comp_expr[comp], lut->var_values, lut); if (isnan(res)) { av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s' for the value %d for the component #%d.\n", lut->comp_expr_str[comp], val, comp); return AVERROR(EINVAL); } lut->lut[comp][val] = av_clip((int)res, min[comp], max[comp]); av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[comp][val]); } } return 0; }
1threat
int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; int i = 0; u32 temp; if (!userKey || !key) return -1; if (bits != 128 && bits != 192 && bits != 256) return -2; rk = key->rd_key; if (bits==128) key->rounds = 10; else if (bits==192) key->rounds = 12; else key->rounds = 14; rk[0] = GETU32(userKey ); rk[1] = GETU32(userKey + 4); rk[2] = GETU32(userKey + 8); rk[3] = GETU32(userKey + 12); if (bits == 128) { while (1) { temp = rk[3]; rk[4] = rk[0] ^ (AES_Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp ) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[5] = rk[1] ^ rk[4]; rk[6] = rk[2] ^ rk[5]; rk[7] = rk[3] ^ rk[6]; if (++i == 10) { return 0; } rk += 4; } } rk[4] = GETU32(userKey + 16); rk[5] = GETU32(userKey + 20); if (bits == 192) { while (1) { temp = rk[ 5]; rk[ 6] = rk[ 0] ^ (AES_Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp ) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[ 7] = rk[ 1] ^ rk[ 6]; rk[ 8] = rk[ 2] ^ rk[ 7]; rk[ 9] = rk[ 3] ^ rk[ 8]; if (++i == 8) { return 0; } rk[10] = rk[ 4] ^ rk[ 9]; rk[11] = rk[ 5] ^ rk[10]; rk += 6; } } rk[6] = GETU32(userKey + 24); rk[7] = GETU32(userKey + 28); if (bits == 256) { while (1) { temp = rk[ 7]; rk[ 8] = rk[ 0] ^ (AES_Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp ) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[ 9] = rk[ 1] ^ rk[ 8]; rk[10] = rk[ 2] ^ rk[ 9]; rk[11] = rk[ 3] ^ rk[10]; if (++i == 7) { return 0; } temp = rk[11]; rk[12] = rk[ 4] ^ (AES_Te4[(temp >> 24) ] & 0xff000000) ^ (AES_Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp ) & 0xff] & 0x000000ff); rk[13] = rk[ 5] ^ rk[12]; rk[14] = rk[ 6] ^ rk[13]; rk[15] = rk[ 7] ^ rk[14]; rk += 8; } } return 0; }
1threat
Get only the latest builds of a module in the same table using mysql and node.js : <p>Let's say I have this kind of table:</p> <p><a href="https://i.stack.imgur.com/ubscr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ubscr.png" alt="enter image description here"></a></p> <p>How would I only get these values:</p> <pre><code>ID | NAME | BUILD 2 | Module1 | 2 4 | Module2 | 2 </code></pre>
0debug
How can I get access_token from auth-module, Nuxt.js : <p>I try to build Facebook login with auth-module the link below with Nuxt.js.</p> <p><a href="https://github.com/nuxt-community/auth-module" rel="noreferrer">https://github.com/nuxt-community/auth-module</a></p> <p>I can not get "access_token". the code is follows.</p> <pre><code>// pages/login.vue export default { methods: { this.$auth.loginWith('facebook') } } </code></pre> <p>the call back URI is like this.</p> <pre><code>https://localhost:3000/facebook/oauth_callback/?#access_token=***&amp;data_access_expiration_time=1561715202&amp;expires_in=4398&amp;reauthorize_required_in=7776000&amp;state=MC4xOTU3MDM2ODIxMzIzOTA5OA </code></pre> <pre><code>// pages/facebook/oauth_callback/index.vue &lt;template&gt; &lt;section&gt; &lt;p&gt;{{ this.$auth.$state }}&lt;/p&gt; &lt;p&gt;{{ this.$route.query }}&lt;/p &lt;/section&gt; &lt;/template&gt; </code></pre> <p>this.$auth.$state don't include "access_token". How can I get "access_token"? I don't also understand why the URI include "#" in get parameter field. because of it, I can't get access_token from "this.$route.query".</p>
0debug
alert('Hello ' + user_input);
1threat
Auto update isn't working in VSCode: Could not create temporary directory: Permission denied : <p>From certain point I started getting this error from time to time(I suppose it fires when editor tries to check for updates), and manual/auto update doesn't work. The only way I can update the editor is re-download the app and replace it manually.</p> <p>Does someone face same issue and successfully resolved? </p> <p><a href="https://i.stack.imgur.com/8tpAO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8tpAO.png" alt="Screenshot"></a></p>
0debug
void object_property_add_link(Object *obj, const char *name, const char *type, Object **child, Error **errp) { gchar *full_type; full_type = g_strdup_printf("link<%s>", type); object_property_add(obj, name, full_type, object_get_link_property, object_set_link_property, NULL, child, errp); g_free(full_type); }
1threat
static void gen_spr_vtb(CPUPPCState *env) { spr_register(env, SPR_VTB, "VTB", SPR_NOACCESS, SPR_NOACCESS, &spr_read_tbl, SPR_NOACCESS, 0x00000000); }
1threat
How to hide ImageView when scrolls down text in android studio : how can i create a layout like this picture. When scrolls down texts, it hides imageview. What kind of layout should I use for this? [Start][1] [ Result][2] [1]: https://i.stack.imgur.com/jxliS.png [2]: https://i.stack.imgur.com/QyssO.png
0debug
random code generater for android application email verification : I am writing a new android application that require the user to register and provide email. I need to send email and give them a code for verification. I need to generate a 6-digit random code that consisting numbers with uppercase alphabet, for example, 6H94BA. I have done some research and cannot find anything. How to do that?
0debug
static int local_renameat(FsContext *ctx, V9fsPath *olddir, const char *old_name, V9fsPath *newdir, const char *new_name) { int ret; int odirfd, ndirfd; odirfd = local_opendir_nofollow(ctx, olddir->data); if (odirfd == -1) { return -1; } ndirfd = local_opendir_nofollow(ctx, newdir->data); if (ndirfd == -1) { close_preserve_errno(odirfd); return -1; } ret = renameat(odirfd, old_name, ndirfd, new_name); if (ret < 0) { goto out; } if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { int omap_dirfd, nmap_dirfd; ret = mkdirat(ndirfd, VIRTFS_META_DIR, 0700); if (ret < 0 && errno != EEXIST) { goto err_undo_rename; } omap_dirfd = openat(odirfd, VIRTFS_META_DIR, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); if (omap_dirfd == -1) { goto err; } nmap_dirfd = openat(ndirfd, VIRTFS_META_DIR, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); if (nmap_dirfd == -1) { close_preserve_errno(omap_dirfd); goto err; } ret = renameat(omap_dirfd, old_name, nmap_dirfd, new_name); close_preserve_errno(nmap_dirfd); close_preserve_errno(omap_dirfd); if (ret < 0 && errno != ENOENT) { goto err_undo_rename; } ret = 0; } goto out; err: ret = -1; err_undo_rename: renameat_preserve_errno(ndirfd, new_name, odirfd, old_name); out: close_preserve_errno(ndirfd); close_preserve_errno(odirfd); return ret; }
1threat
static int get_physical_address (CPUState *env, target_ulong *physical, int *prot, target_ulong address, int rw, int access_type) { int user_mode = (env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM; int supervisor_mode = (env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_SM; int kernel_mode = !user_mode && !supervisor_mode; #if defined(TARGET_MIPS64) int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0; int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0; int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0; #endif int ret = TLBRET_MATCH; #if 0 if (logfile) { fprintf(logfile, "user mode %d h %08x\n", user_mode, env->hflags); } #endif if (address <= (int32_t)0x7FFFFFFFUL) { if (env->CP0_Status & (1 << CP0St_ERL)) { *physical = address & 0xFFFFFFFF; *prot = PAGE_READ | PAGE_WRITE; } else { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } #if defined(TARGET_MIPS64) } else if (address < 0x4000000000000000ULL) { if (UX && address < (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else if (address < 0x8000000000000000ULL) { if ((supervisor_mode || kernel_mode) && SX && address < (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else if (address < 0xC000000000000000ULL) { if (kernel_mode && KX && (address & 0x07FFFFFFFFFFFFFFULL) < 0x0000000FFFFFFFFFULL) { *physical = address & 0x0000000FFFFFFFFFULL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < 0xFFFFFFFF80000000ULL) { if (kernel_mode && KX && address < (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } #endif } else if (address < (int32_t)0xA0000000UL) { if (kernel_mode) { *physical = address - (int32_t)0x80000000UL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < (int32_t)0xC0000000UL) { if (kernel_mode) { *physical = address - (int32_t)0xA0000000UL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < (int32_t)0xE0000000UL) { if (supervisor_mode || kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else { if (kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } #if 0 if (logfile) { fprintf(logfile, TARGET_FMT_lx " %d %d => " TARGET_FMT_lx " %d (%d)\n", address, rw, access_type, *physical, *prot, ret); } #endif return ret; }
1threat
static void swap_sample_fmts_on_filter(AVFilterContext *filter) { AVFilterLink *link = NULL; int format, bps; int i, j; for (i = 0; i < filter->nb_inputs; i++) { link = filter->inputs[i]; if (link->type == AVMEDIA_TYPE_AUDIO && link->out_formats->format_count == 1) break; } if (i == filter->nb_inputs) return; format = link->out_formats->formats[0]; bps = av_get_bytes_per_sample(format); for (i = 0; i < filter->nb_outputs; i++) { AVFilterLink *outlink = filter->outputs[i]; int best_idx, best_score = INT_MIN; if (outlink->type != AVMEDIA_TYPE_AUDIO || outlink->in_formats->format_count < 2) continue; for (j = 0; j < outlink->in_formats->format_count; j++) { int out_format = outlink->in_formats->formats[j]; int out_bps = av_get_bytes_per_sample(out_format); int score; if (av_get_packed_sample_fmt(out_format) == format || av_get_planar_sample_fmt(out_format) == format) { best_idx = j; break; } if (bps == 4 && out_bps == 8) { best_idx = j; break; } score = -abs(out_bps - bps); if (out_bps >= bps) score += INT_MAX/2; if (score > best_score) { best_score = score; best_idx = j; } } FFSWAP(int, outlink->in_formats->formats[0], outlink->in_formats->formats[best_idx]); } }
1threat
Are modern compilers actually better at optimization? : <p>How much of a difference do modern compiler optimization techniques make? Do they actually provide a noticeable speedup? </p> <p>For example: Are there any examples of C++11 code that will run faster with gcc 8.1, rather than gcc 4.9, or an even older compiler? How much is the speedup?</p>
0debug
Mounting a windows share in Windows Subsystem for Linux : <p>I'd like to mount a windows server from within <a href="https://github.com/Microsoft/BashOnWindows" rel="noreferrer">WSL</a> (Windows Subsystem for Linux). On Ubuntu (with unity interface) I can just type</p> <pre><code>gvfs-mount smb://domain\;user@server/share </code></pre> <p>and everything mounts just fine.</p> <p>If I try this in WSL then I get the following error:</p> <pre><code>Error mounting location: volume doesn't implement mount </code></pre>
0debug
How can I matlab from a matrix on matlab? : so I have a matrix: a = [16 456 22 85 93;11 78 310 62 36;1 66 23 67 405]; Whis is the command to graph the 3rd row of the matrix - the grid of the graph should be set to visable and the x (sample) and Y (value) axis labels should be included. thank you guys :)
0debug
static void run_test(void) { unsigned int remaining; int i; while (atomic_read(&n_ready_threads) != n_rw_threads + n_rz_threads) { cpu_relax(); } atomic_mb_set(&test_start, true); do { remaining = sleep(duration); } while (remaining); atomic_mb_set(&test_stop, true); for (i = 0; i < n_rw_threads; i++) { qemu_thread_join(&rw_threads[i]); } for (i = 0; i < n_rz_threads; i++) { qemu_thread_join(&rz_threads[i]); } }
1threat
static int decode_mb(MadContext *s, AVFrame *frame, int inter) { int mv_map = 0; int mv_x, mv_y; int j; if (inter) { int v = decode210(&s->gb); if (v < 2) { mv_map = v ? get_bits(&s->gb, 6) : 63; mv_x = decode_motion(&s->gb); mv_y = decode_motion(&s->gb); } } for (j=0; j<6; j++) { if (mv_map & (1<<j)) { int add = 2*decode_motion(&s->gb); if (s->last_frame->data[0]) comp_block(s, frame, s->mb_x, s->mb_y, j, mv_x, mv_y, add); } else { s->dsp.clear_block(s->block); if(decode_block_intra(s, s->block) < 0) return -1; idct_put(s, frame, s->block, s->mb_x, s->mb_y, j); } } return 0; }
1threat
Why does this code results in compilation error?[C,Global Varibales,2D Array] : #include<stdio.h> int arr[12][5]; int score[12][5]; int n; void chk(){ int score = 0; for(int i=11;i<=0;i++){ for(int j = 0;j<5;j++){ scanf("%d",&(arr[i][j])); } } for(int i = 12;i<0;i++){ for(int j=0;j<5;j++){ if(i==12) score[i][j] = arr[i][j]; else{ int mx = score[i+1][j]; if(j>0 && score[i+1][j-1]>mx) mx = score[i+1][j-1]; else if(j<4 && score[i+1][j+1]>mx) mx = score[i+1][j-1]; score[i][j] = arr[i][j] + mx; } } } int mx_score = score[0][2]; if(score[0][1]>mx_score){ mx_score = score[0][1]; } else if(score[0][3]>mx_score){ mx_score = score[0][3]; } printf("%d",mx_score); } int main(){ int T; scanf("%d",&T); for(int i = 0;i<T;i++){ scanf("%d",&n); chk(n); } return 0; } Compilation error: Subscripted value is not an array,pointer or vector. Variable that causes the error is score. I don't understand why arr works fine but score doesn't. And how would you write this code better?
0debug
Reading or Writing Excel (xlsx) file from java : <p>What is the best api or library to read Excel (xlsx) files from java?</p>
0debug
Flutter: How do you make a card clickable? : <p>I just have a simple Card like <code>new Card(child: new Text('My cool card'))</code> and I want to be able to click anywhere on it to run some function, except there's no <code>onPressed</code> method for a Card. I could add a button to the bottom, but that's not ideal for this situation.</p> <p>Anyone know how to make the whole card clickable?</p>
0debug
static void invalidate_and_set_dirty(hwaddr addr, hwaddr length) { if (cpu_physical_memory_range_includes_clean(addr, length)) { tb_invalidate_phys_range(addr, addr + length, 0); cpu_physical_memory_set_dirty_range_nocode(addr, length); } xen_modified_memory(addr, length); }
1threat
How to hide button and disable button in swift -4? : I'm new to iOS swift code, trying to create small restaurant app for employees. There I have table numbers as a button if the user clicks that button I want that clicked button to be disabled and I want textfield and another ok button to appear. And if I click on disable button I want that to be enabled. import UIKit class ViewController: UIViewController { var total = 0 @IBOutlet weak var okButton: UIButton! @IBOutlet weak var userInput: UILabel! @IBOutlet weak var userValue: UITextField! @IBAction func okButton(_ sender: UIButton) { if userValue.text != nil{ userInput.text = String(0) let userValueint: Int? = Int(userValue.text!) total = total + userValueint! let convertText = String(total) userInput.text = convertText userValue.text = String(0) userValue.isHidden = true okButton!.isHidden = true } else{ print("Please Inter values") } } @IBAction func buttenPressed(_ sender: UIButton) { userValue.isHidden = false okButton.isEnabled = true } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. userValue.isHidden = true } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) okButton.isHidden = false } } So far I'm able to hide textField at the beginning and able to enabled when table button is clicked, but I can't hide ok button and disable the table button. Any suggestion?
0debug