problem
stringlengths
26
131k
labels
class label
2 classes
static int mov_rewrite_dvd_sub_extradata(AVStream *st) { char pal_s[256]; char buf[256]; int pal_s_pos = 0; uint8_t *src = st->codec->extradata; int i; if (st->codec->extradata_size != 64) return 0; for (i = 0; i < 16; i++) { uint32_t yuv = AV_RB32(src + i * 4); uint32_t rgba = yuv_to_rgba(yuv); snprintf(pal_s + pal_s_pos, sizeof(pal_s) - pal_s_pos, "%06x%s", rgba, i != 15 ? ", " : ""); pal_s_pos = strlen(pal_s); if (pal_s_pos >= sizeof(pal_s)) return 0; } snprintf(buf, sizeof(buf), "size: %dx%d\npalette: %s\n", st->codec->width, st->codec->height, pal_s); av_freep(&st->codec->extradata); st->codec->extradata_size = 0; st->codec->extradata = av_mallocz(strlen(buf) + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = strlen(buf); memcpy(st->codec->extradata, buf, st->codec->extradata_size); return 0; }
1threat
Uncaught SyntaxError: missing, ) after argument list : <p>im bulding a search box for movies using an API any time onkeyup event takes place a function is called which in turn prepare an ajax and display the responsed json in li tags. of course it displays 20 results i want to be able to store the result the user clicked on and displayed on div id="target" here is my code:</p> <p><a href="http://jsfiddle.net/bkj2z39y/" rel="nofollow">http://jsfiddle.net/bkj2z39y/</a></p> <p>every thing is working except the clicking </p> <pre><code> function func(str) { $('#here').html(''); document.getElementById("here").style.border = "0px"; $('#movie').val(''); alert(str); $('#target').html(str); console.log(str); } </code></pre> <p>i have tried several methods, this last one gives me an error </p> <p>Uncaught SyntaxError: missing ) after argument list</p>
0debug
static void virtio_balloon_set_config(VirtIODevice *vdev, const uint8_t *config_data) { VirtIOBalloon *dev = VIRTIO_BALLOON(vdev); struct virtio_balloon_config config; uint32_t oldactual = dev->actual; memcpy(&config, config_data, 8); dev->actual = le32_to_cpu(config.actual); if (dev->actual != oldactual) { qemu_balloon_changed(ram_size - (dev->actual << VIRTIO_BALLOON_PFN_SHIFT)); } }
1threat
I wonder about list of python. two questions : first, I would like to remove the outer list of the doubled lists. [[1,2,3,4,5]] -> [1,2,3,4,5] second, I want to count the elements in the list. [[1,2,3,4,2,1,4]] -> 7 thank you.
0debug
How to extract the beginning and end date from a text file with a specific keyword with pyhton : This is an example text: Jan 1 11:22:33 DHCPDISCOVER from 00:11:22:33:44:55 Jan 1 11:22:34 DHCPOFFER on 10.0.0.5 to 00:11:22:33:44:55 Jan 1 11:22:35 DHCPREQUEST for 10.0.0.5 from 00:11:22:33:44:55 Jan 1 11:22:36 DHCPACK on 10.0.0.5 to 00:11:22:33:44:55 Jan 1 11:22:37 DHCPNACK on 10.0.0.5 to 00:11:22:33:44:55 I want to extract for the specific mac address when it was first registered with a date and time and the last time it was registered. The output has to be something like this: for the given mac address: 00:11:22:33:44:55 Start: Jan 1 11:22:33 End: Jan 2 22:33:44
0debug
WHY CAN'T I PLAY MY VIDEO IN ANDROID STUDIO? : DO I HAVE TO CHANGE THE FILE TYPE? BECAUSE WHEN I WATCH YOUTUBE VIDS I NOTICED THAT ALL THE ICONS HAVE A QUESTION MARK, WHILE MINE HAS LIKE A TEXT FILE.[][1] [enter image description here][2] [1]: https://i.stack.imgur.com/JjwAB.png [2]: https://i.stack.imgur.com/e1L7o.png
0debug
// , Can I use aiozmq with aiohttp? : // , I want to offer an asynchronous http server to clients, and use asynchronous pub-sub on an internal network of peers to which those clients connect. It looks like the best libraries for this, respectively, are aiohttp and aiozmq: import aiohttp import aiozmq If I do the above, am I already doing it wrong? It is like using different asynchronous frameworks at once...
0debug
static int decode_tilehdr(WmallDecodeCtx *s) { uint16_t num_samples[WMALL_MAX_CHANNELS] = { 0 }; uint8_t contains_subframe[WMALL_MAX_CHANNELS]; int channels_for_cur_subframe = s->num_channels; int fixed_channel_layout = 0; int min_channel_len = 0; int c, tile_aligned; for (c = 0; c < s->num_channels; c++) s->channel[c].num_subframes = 0; tile_aligned = get_bits1(&s->gb); if (s->max_num_subframes == 1 || tile_aligned) fixed_channel_layout = 1; do { int subframe_len, in_use = 0; for (c = 0; c < s->num_channels; c++) { if (num_samples[c] == min_channel_len) { if (fixed_channel_layout || channels_for_cur_subframe == 1 || (min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) { contains_subframe[c] = in_use = 1; } else { if (get_bits1(&s->gb)) contains_subframe[c] = in_use = 1; } } else contains_subframe[c] = 0; } if (!in_use) { av_log(s->avctx, AV_LOG_ERROR, "Found empty subframe\n"); return AVERROR_INVALIDDATA; } if ((subframe_len = decode_subframe_length(s, min_channel_len)) <= 0) return AVERROR_INVALIDDATA; min_channel_len += subframe_len; for (c = 0; c < s->num_channels; c++) { WmallChannelCtx *chan = &s->channel[c]; if (contains_subframe[c]) { if (chan->num_subframes >= MAX_SUBFRAMES) { av_log(s->avctx, AV_LOG_ERROR, "broken frame: num subframes > 31\n"); return AVERROR_INVALIDDATA; } chan->subframe_len[chan->num_subframes] = subframe_len; num_samples[c] += subframe_len; ++chan->num_subframes; if (num_samples[c] > s->samples_per_frame) { av_log(s->avctx, AV_LOG_ERROR, "broken frame: " "channel len(%d) > samples_per_frame(%d)\n", num_samples[c], s->samples_per_frame); return AVERROR_INVALIDDATA; } } else if (num_samples[c] <= min_channel_len) { if (num_samples[c] < min_channel_len) { channels_for_cur_subframe = 0; min_channel_len = num_samples[c]; } ++channels_for_cur_subframe; } } } while (min_channel_len < s->samples_per_frame); for (c = 0; c < s->num_channels; c++) { int i, offset = 0; for (i = 0; i < s->channel[c].num_subframes; i++) { s->channel[c].subframe_offsets[i] = offset; offset += s->channel[c].subframe_len[i]; } } return 0; }
1threat
How to get day of year, week of year from a DateTime Dart object : <p>I need to get day of year (day1 is 1rst of january), week of year, and month of year from a dart DateTime object.</p> <p>I did not find any available library for this. Any idea ?</p>
0debug
void hmp_info_vnc(Monitor *mon, const QDict *qdict) { VncInfo *info; Error *err = NULL; VncClientInfoList *client; info = qmp_query_vnc(&err); if (err) { monitor_printf(mon, "%s\n", error_get_pretty(err)); error_free(err); return; } if (!info->enabled) { monitor_printf(mon, "Server: disabled\n"); goto out; } monitor_printf(mon, "Server:\n"); if (info->has_host && info->has_service) { monitor_printf(mon, " address: %s:%s\n", info->host, info->service); } if (info->has_auth) { monitor_printf(mon, " auth: %s\n", info->auth); } if (!info->has_clients || info->clients == NULL) { monitor_printf(mon, "Client: none\n"); } else { for (client = info->clients; client; client = client->next) { monitor_printf(mon, "Client:\n"); monitor_printf(mon, " address: %s:%s\n", client->value->base->host, client->value->base->service); monitor_printf(mon, " x509_dname: %s\n", client->value->x509_dname ? client->value->x509_dname : "none"); monitor_printf(mon, " username: %s\n", client->value->has_sasl_username ? client->value->sasl_username : "none"); } } out: qapi_free_VncInfo(info); }
1threat
How to see at what time does each python operation runs? : <p>I'm new to Python. I'm working on a script on Python3 which sends different requests and I want to see at what time does each request is being sent and it got shown on my terminal. I tried looking into time docs but couldn't find what I am looking for. Hope it is clear</p> <p>Thank you</p>
0debug
static uint32_t arm_v7m_load_vector(ARMCPU *cpu) { CPUState *cs = CPU(cpu); CPUARMState *env = &cpu->env; MemTxResult result; hwaddr vec = env->v7m.vecbase + env->v7m.exception * 4; uint32_t addr; addr = address_space_ldl(cs->as, vec, MEMTXATTRS_UNSPECIFIED, &result); if (result != MEMTX_OK) { cpu_abort(cs, "Failed to read from exception vector table " "entry %08x\n", (unsigned)vec); } return addr; }
1threat
shorthand to add an attribute to multiple variables : <p>I haven't been able to find anywhere in which you can add/remove an attribute to multiple variables.</p> <pre><code>var sub = $('#sub'); var sub1 = $('#sub1'); $(sub, sub1).removeClass('error'); </code></pre>
0debug
ionic change default font : <p>I know this question is asked and answered before in the links below. I want to change the default font without having to add to every css. </p> <p>Things I have tried:</p> <ol> <li>Changing the .tff, .eot, .woff, .svg file directly to merge my fonts and ionicons </li> <li>Tried to implement the font by specifying it in html and css file (it works, but i want it to be default)</li> <li>Overwrite the www/lib/ionic/fonts with open-sans font (the ionicons disappear)</li> <li>When i use the first link (all formatting is gone, only left with text and buttons) I also tried placing the font-face on top and bottom in scss/ionic.app.scss</li> </ol> <p>Please help! The answers i have seen are instructions but no explanation how it works. I don't know how "ionic setup sass" works/what it does. How gulp plays a part in this.</p> <p><a href="https://forum.ionicframework.com/t/how-to-change-the-font-of-all-texts-in-ionic/30459" rel="noreferrer">https://forum.ionicframework.com/t/how-to-change-the-font-of-all-texts-in-ionic/30459</a></p> <p><a href="https://forum.ionicframework.com/t/change-font-family-and-use-ionicons-icons/26729" rel="noreferrer">https://forum.ionicframework.com/t/change-font-family-and-use-ionicons-icons/26729</a></p>
0debug
CodeIgniter giving error of "endif" : I setup this if condition for validation but endif giving ma errors I give you guys screen short of error 19 . <?php if($this->session->flashdata('errors')); ?> 20 . <?= $this->session->flashdata('errors'); ?> 21 . <?php endif; ?> [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/AqxXV.png
0debug
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit) { const char *driver; DeviceState *dev; driver = bdrv_is_sg(dinfo->bdrv) ? "scsi-generic" : "scsi-disk"; dev = qdev_create(&bus->qbus, driver); qdev_prop_set_uint32(dev, "scsi-id", unit); qdev_prop_set_drive(dev, "drive", dinfo); qdev_init(dev); return DO_UPCAST(SCSIDevice, qdev, dev); }
1threat
Ruby on Rail, Haml::SyntaxError at / : I am a newbee for ruby on rails. When I compile, on the browser, it just keeps me same error on index.haml Haml::SyntaxError at / Illegal nesting: nesting within plain text is illegal. [![enter image description here][1]][1] This is the code, %h1.text-center All images .row %ul.list-unstyled @images.each do |image| %li %h2=image.title %p %a.thumbnail{href: image.file, data:{ lightbox: "gallery", title: image.title } } %img{src: image.file.url(:small), width: "100%"} %p %span(class='st_facebook_hcount' displayText='Facebook' st_url="#{request.base_url}/images/#{image.id}") %span(class='st_twitter_hcount' displayText='Tweet' st_url="#{request.base_url}/images/#{image.id}") [1]: http://i.stack.imgur.com/UeH0n.png Thank you in advance.
0debug
static void eth_send(mv88w8618_eth_state *s, int queue_index) { uint32_t desc_addr = s->tx_queue[queue_index]; mv88w8618_tx_desc desc; uint8_t buf[2048]; int len; do { eth_tx_desc_get(desc_addr, &desc); if (desc.cmdstat & MP_ETH_TX_OWN) { len = desc.bytes; if (len < 2048) { cpu_physical_memory_read(desc.buffer, buf, len); qemu_send_packet(s->vc, buf, len); } desc.cmdstat &= ~MP_ETH_TX_OWN; s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index); eth_tx_desc_put(desc_addr, &desc); } desc_addr = desc.next; } while (desc_addr != s->tx_queue[queue_index]); }
1threat
convert string to Dom in vuejs : <p>recently I want to convert a stirng to Dom in a vue component, but it does't work as my expectation. My code looks like this:</p> <pre><code> // what I wrote in the template &lt;div id="log"&gt; {{libText}} &lt;/div&gt; // what I wrote in js Vue.component(... , { template: ... , data: function () { return ... } }, computed: { libText:function(){ var str="&lt;p&gt;some html&lt;/p&gt;"; var div = document.createElement('div'); div.innerHTML = str; return div; } }, methods:{...} }) </code></pre> <p>The result I get is a string "[object HTMLDivElement]" rather than a Dom. It would be greatful if anyone can help me solve this problem</p>
0debug
static void monitor_parse(const char *optarg, const char *mode, bool pretty) { static int monitor_device_index = 0; Error *local_err = NULL; QemuOpts *opts; const char *p; char label[32]; int def = 0; if (strstart(optarg, "chardev:", &p)) { snprintf(label, sizeof(label), "%s", p); } else { snprintf(label, sizeof(label), "compat_monitor%d", monitor_device_index); if (monitor_device_index == 0) { def = 1; } opts = qemu_chr_parse_compat(label, optarg); if (!opts) { fprintf(stderr, "parse error: %s\n", optarg); exit(1); } } opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, &local_err); if (!opts) { error_report_err(local_err); exit(1); } qemu_opt_set(opts, "mode", mode, &error_abort); qemu_opt_set(opts, "chardev", label, &error_abort); qemu_opt_set_bool(opts, "pretty", pretty, &error_abort); if (def) qemu_opt_set(opts, "default", "on", &error_abort); monitor_device_index++; }
1threat
RxJs: Incrementally push stream of data to BehaviorSubject<[]> : <p>Basically I'm trying to inflate <code>BehaviorSubject&lt;[]&gt;</code> with array of data which will be loaded in chunks.</p> <p><code>BehaviorSubject&lt;[]&gt;</code> will be added with new chunk of data (like <code>Array.push</code>) but I don't want to use another array to store and add to <code>BehaviorSubject.next</code> because this will cause rendering to take too long as the data grow over time.</p> <p>Any suggestion?</p>
0debug
Window width doesn't fit to device fit : <p>I'm trying to make a Bootstrap 3 navbar and it should collapse at the 768px width size. But it doesn't work. I checked it why it's happening and I realized it sees window width as 980px whatever its size is. </p> <p>My site is: <a href="http://dev.semcoled.com" rel="nofollow noreferrer">http://dev.semcoled.com</a></p> <p>I console.log'ged and alerted the window width, it always prompts 980px even if the device is smaller than it.</p> <p>I don't know why does that happen.</p> <p>Thanks</p>
0debug
CLion indexer does not resolve some includes in the project directory : <p>I have a CLion C++ project that has the following structure:</p> <pre><code> project ----&gt;my_includes | ----&gt; my_own.hpp ----&gt;source ----&gt; my_app ----&gt; my_src.cpp </code></pre> <p>The first line of my_src.cpp is </p> <pre><code>#include "my_includes/my_own.hpp" </code></pre> <p>I use an external build system that requires this inclusion format. The problem is if I use a function in my source file defined in the included header, CLion says "Cannot find my_own.hpp" if I try to hover over the inclusion.</p> <p>I tried marking the include directory as containing Project Source or Headers but this didn't fix it. Any ideas?</p>
0debug
Add bind mount to Dockerfile just like volume : <p>I want to add the bind mount to docker file just like I initialise a volume inside Dockefile. Is there any way for it? </p>
0debug
Textbox,Database,Gridview,Error or succes messages : <p>if user inserted value in textbox present in database then show to gridview(display in grid view) else error message in c#.. If successfully found then show else show that data not found as you inserted in textbox.....Hlep me<a href="http://i.stack.imgur.com/RRO7w.png" rel="nofollow">enter image description here</a></p>
0debug
how put value 0x00 to a dynamically allocated char* array in c? : <p>How can I put 0x00 value to an array that created by malloc. I tried the below code ,but it didn't work. any response is appreciated!</p> <pre><code>char* a = malloc(3 * sizeof(char)); *a= 0x20; *(a+1)= 0x00; *(a+2) = 0x32; </code></pre>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
How can I search by emoji in MySQL using utf8mb4? : <p>Please help me understand how multibyte characters like emoji's are handled in MySQL utf8mb4 fields.</p> <p>See below for a simple test SQL to illustrate the challenges.</p> <pre><code>/* Clear Previous Test */ DROP TABLE IF EXISTS `emoji_test`; DROP TABLE IF EXISTS `emoji_test_with_unique_key`; /* Build Schema */ CREATE TABLE `emoji_test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `string` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `status` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `emoji_test_with_unique_key` ( `id` int(11) NOT NULL AUTO_INCREMENT, `string` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `status` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `idx_string_status` (`string`,`status`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /* INSERT data */ # Expected Result is successful insert for each of these. # However some fail. See comments. INSERT INTO emoji_test (`string`, `status`) VALUES ('๐ŸŒถ', 1); # SUCCESS INSERT INTO emoji_test (`string`, `status`) VALUES ('๐ŸŒฎ', 1); # SUCCESS INSERT INTO emoji_test (`string`, `status`) VALUES ('๐ŸŒฎ๐ŸŒถ', 1); # SUCCESS INSERT INTO emoji_test (`string`, `status`) VALUES ('๐ŸŒถ๐ŸŒฎ', 1); # SUCCESS INSERT INTO emoji_test_with_unique_key (`string`, `status`) VALUES ('๐ŸŒถ', 1); # SUCCESS INSERT INTO emoji_test_with_unique_key (`string`, `status`) VALUES ('๐ŸŒฎ', 1); # FAIL: Duplicate entry '?-1' for key 'idx_string_status' INSERT INTO emoji_test_with_unique_key (`string`, `status`) VALUES ('๐ŸŒฎ๐ŸŒถ', 1); # SUCCESS INSERT INTO emoji_test_with_unique_key (`string`, `status`) VALUES ('๐ŸŒถ๐ŸŒฎ', 1); # FAIL: Duplicate entry '??-1' for key 'idx_string_status' /* Test data */ /* Simple Table */ SELECT * FROM emoji_test WHERE `string` IN ('๐ŸŒถ','๐ŸŒฎ','๐ŸŒฎ๐ŸŒถ','๐ŸŒถ๐ŸŒฎ'); # SUCCESS (all 4 are found) SELECT * FROM emoji_test WHERE `string` IN ('๐ŸŒถ'); # FAIL: Returns both ๐ŸŒถ and ๐ŸŒฎ SELECT * FROM emoji_test WHERE `string` IN ('๐ŸŒฎ'); # FAIL: Returns both ๐ŸŒถ and ๐ŸŒฎ SELECT * FROM emoji_test; # SUCCESS (all 4 are found) /* Table with Unique Key */ SELECT * FROM emoji_test_with_unique_key WHERE `string` IN ('๐ŸŒถ','๐ŸŒฎ','๐ŸŒฎ๐ŸŒถ','๐ŸŒถ๐ŸŒฎ'); # FAIL: Only 2 are found (due to insert errors above) SELECT * FROM emoji_test_with_unique_key WHERE `string` IN ('๐ŸŒถ'); # SUCCESS SELECT * FROM emoji_test_with_unique_key WHERE `string` IN ('๐ŸŒฎ'); # FAIL: ๐ŸŒถ found instead of ๐ŸŒฎ SELECT * FROM emoji_test_with_unique_key; # FAIL: Only 2 records found (๐ŸŒถ and ๐ŸŒฎ๐ŸŒถ) </code></pre> <p>I'm interested in learning what causes the <code>FAIL</code>s above and how I can get around this.</p> <p>Specifically:</p> <ol> <li>Why do selects for one multibyte character return results for <em>any</em> multibyte character?</li> <li>How can I configure an index to handle multibyte characters instead of <code>?</code>?</li> <li>Can you recommend changes to the second <code>CREATE TABLE</code> (the one with a unique key) above in such a way that makes all the test queries return successfully?</li> </ol>
0debug
Regular Expression : Can anyone help me with creating a regular expression for except these five symbols ?~^|* all symbols should accept My scenario: I have one textbox. I am entering some text into the text box if the text contains these ?~^|* symbols it should through error validation.
0debug
C++ (int getopt(argc, (char **)argv, optstring) : <p>I'm beginner in C++ and using ubuntu 12. I'm having problem in using the getopt function particularly matching the command line arguments (int main(int argc, char *argv[]) with optstr in getopt. can anyone explain what is the format of command line arguments which can be matched in getopt function.</p>
0debug
static av_cold int a64multi_close_encoder(AVCodecContext *avctx) { A64Context *c = avctx->priv_data; av_frame_free(&avctx->coded_frame); av_free(c->mc_meta_charset); av_free(c->mc_best_cb); av_free(c->mc_charset); av_free(c->mc_charmap); av_free(c->mc_colram); return 0; }
1threat
How to validate TextInput values in react native? : <p>for example, While entering an email in the TextInput, it should validate and display the error message. where the entered email is valid or not </p> <p><a href="https://i.stack.imgur.com/bVIha.png"><img src="https://i.stack.imgur.com/bVIha.png" alt="enter image description here"></a> </p>
0debug
how to get check a proper data type has been given by the user : <p>suppose I have a variable of integer type 'a'</p> <p>now ill ask user to enter an input after he gave an input i want to check weather he entered an integer type or anything else</p> <p>for the above question what should i have to do</p>
0debug
int qcrypto_cipher_decrypt(QCryptoCipher *cipher, const void *in, void *out, size_t len, Error **errp) { QCryptoCipherNettle *ctx = cipher->opaque; switch (cipher->mode) { case QCRYPTO_CIPHER_MODE_ECB: ctx->alg_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt, len, out, in); break; case QCRYPTO_CIPHER_MODE_CBC: cbc_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt, ctx->alg_decrypt, ctx->niv, ctx->iv, len, out, in); break; default: error_setg(errp, "Unsupported cipher algorithm %d", cipher->alg); return -1; } return 0; }
1threat
static void qemu_co_queue_next_bh(void *opaque) { Coroutine *next; trace_qemu_co_queue_next_bh(); while ((next = QTAILQ_FIRST(&unlock_bh_queue))) { QTAILQ_REMOVE(&unlock_bh_queue, next, co_queue_next); qemu_coroutine_enter(next, NULL); } }
1threat
Custom loss function in PyTorch : <p>I have three simple questions.</p> <ol> <li>What will happen if my custom loss function is not differentiable? Will pytorch through error or do something else?</li> <li>If I declare a loss variable in my custom function which will represent the final loss of the model, should I put <code>requires_grad = True</code> for that variable? or it doesn't matter? If it doesn't matter, then why?</li> <li>I have seen people sometimes write a separate layer and compute the loss in the <code>forward</code> function. Which approach is preferable, writing a function or a layer? Why?</li> </ol> <p>I need a clear and nice explanation to these questions to resolve my confusions. Please help.</p>
0debug
create a php array from another multidensional array : <p>So i have the following array:</p> <pre><code>Array ( [22] =&gt; Array ( [price] =&gt; 35 [qty] =&gt; 2 ) [21] =&gt; Array ( [price] =&gt; 18 [qty] =&gt; 1 ) [49] =&gt; Array ( [price] =&gt; 12 [qty] =&gt; 2 ) ) </code></pre> <p>I would like to create an array like so, from the above data:</p> <pre><code> Array ( [0] =&gt; 35 [1] =&gt; 35 [2] =&gt; 18 [3] =&gt; 12 [4] =&gt; 12 ) </code></pre> <p>This basically gets the "price" key value and adds it to the new array the amount of times stated in the "qty" key value. Whats the best way of achieving this?</p>
0debug
Which way is more efficient to learn data structures? : <p>My programming knowledge is up to OOP since that was the last thing we covered in the university. However, I am taking 2 courses this summer and I am constantly under pressure, but I am planning to learn data structures along the way too, to be prepared for it next semester.</p> <p>I had two plans to learn it but I am not sure which one will be more efficient:</p> <p>-The first one is to skim through and learn about all the types of data structures and how they are implemented.</p> <p>-The second one is to try instead of just reading and knowing about a data structure, I will go and try to implement it. However, the drawbacks are that its slow and time consuming, so I might not be able to learn all of the data structures in time</p>
0debug
use app.use() instead of script tag in node express : <p>I want to use bootstrap with nodejs, express how to use</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>app.use('/scripts', express.static(__dirname + '/node_modules/jquery/dist/js/jquery.min.js')); app.use('/link', express.static(__dirname + '/node_modules/bootstrap/dist/css/bootstrap.min.css')); app.use('/scripts', express.static(__dirname + '/node_modules/bootstrap/dist/js/bootstrap.min.js'));</code></pre> </div> </div> </p> <p>instead of</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-html lang-html prettyprint-override"><code> &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"&gt; &lt;script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p> <p>Please help me, thanks!</p>
0debug
Calling javascript function with php variable as parameter from php code block : <p>I have tried all the post of stack overflow and from google but none of those seem to work for me. This is my php code:</p> <pre><code>echo $firstPar; echo $secondPar; $tab_str.="&lt;td width=\"20%\"&gt;&lt;a href=\"#\" onclick = \"functionCall(".$firstPar.", ".$secondPar.")\" class=\"previous round\"&gt;&amp;#8249;&lt;/a&gt;"; </code></pre> <p>This is the Javascript code:</p> <pre><code>function functionCall(firstPar, secondPar) { alert(firstPar); alert(secondPar); } </code></pre> <p>If I am passing string values directly on the php call rather than passing the variables, I am getting the values inside the function. But the variable values are coming as null. Whereas the echo displays the variable values.</p>
0debug
void avcodec_init(void) { static int inited = 0; if (inited != 0) return; inited = 1; dsputil_static_init(); }
1threat
void qed_acquire(BDRVQEDState *s) { aio_context_acquire(bdrv_get_aio_context(s->bs)); }
1threat
static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, int (*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped) { MpegEncContext *s = opaque; s->mv_dir = mv_dir; s->mv_type = mv_type; s->mb_intra = mb_intra; s->mb_skipped = mb_skipped; s->mb_x = mb_x; s->mb_y = mb_y; memcpy(s->mv, mv, sizeof(*mv)); ff_init_block_index(s); ff_update_block_index(s); s->bdsp.clear_blocks(s->block[0]); s->dest[0] = s->current_picture.f->data[0] + s->mb_y * 16 * s->linesize + s->mb_x * 16; s->dest[1] = s->current_picture.f->data[1] + s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + s->mb_x * (16 >> s->chroma_x_shift); s->dest[2] = s->current_picture.f->data[2] + s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + s->mb_x * (16 >> s->chroma_x_shift); if (ref) av_log(s->avctx, AV_LOG_DEBUG, "Interlaced error concealment is not fully implemented\n"); ff_mpv_reconstruct_mb(s, s->block); }
1threat
static void coroutine_fn commit_run(void *opaque) { CommitBlockJob *s = opaque; BlockDriverState *active = s->active; BlockDriverState *top = s->top; BlockDriverState *base = s->base; BlockDriverState *overlay_bs; int64_t sector_num, end; int ret = 0; int n = 0; void *buf; int bytes_written = 0; int64_t base_len; ret = s->common.len = bdrv_getlength(top); if (s->common.len < 0) { goto exit_restore_reopen; } ret = base_len = bdrv_getlength(base); if (base_len < 0) { goto exit_restore_reopen; } if (base_len < s->common.len) { ret = bdrv_truncate(base, s->common.len); if (ret) { goto exit_restore_reopen; } } end = s->common.len >> BDRV_SECTOR_BITS; buf = qemu_blockalign(top, COMMIT_BUFFER_SIZE); for (sector_num = 0; sector_num < end; sector_num += n) { uint64_t delay_ns = 0; bool copy; wait: block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); if (block_job_is_cancelled(&s->common)) { break; } ret = bdrv_is_allocated_above(top, base, sector_num, COMMIT_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n); copy = (ret == 1); trace_commit_one_iteration(s, sector_num, n, ret); if (copy) { if (s->common.speed) { delay_ns = ratelimit_calculate_delay(&s->limit, n); if (delay_ns > 0) { goto wait; } } ret = commit_populate(top, base, sector_num, n, buf); bytes_written += n * BDRV_SECTOR_SIZE; } if (ret < 0) { if (s->on_error == BLOCKDEV_ON_ERROR_STOP || s->on_error == BLOCKDEV_ON_ERROR_REPORT|| (s->on_error == BLOCKDEV_ON_ERROR_ENOSPC && ret == -ENOSPC)) { goto exit_free_buf; } else { n = 0; continue; } } s->common.offset += n * BDRV_SECTOR_SIZE; } ret = 0; if (!block_job_is_cancelled(&s->common) && sector_num == end) { ret = bdrv_drop_intermediate(active, top, base, s->backing_file_str); } exit_free_buf: qemu_vfree(buf); exit_restore_reopen: if (s->base_flags != bdrv_get_flags(base)) { bdrv_reopen(base, s->base_flags, NULL); } overlay_bs = bdrv_find_overlay(active, top); if (overlay_bs && s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) { bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL); } g_free(s->backing_file_str); block_job_completed(&s->common, ret); }
1threat
static int read_rle_sgi(uint8_t *out_buf, SgiState *s) { uint8_t *dest_row; unsigned int len = s->height * s->depth * 4; GetByteContext g_table = s->g; unsigned int y, z; unsigned int start_offset; if (len * 2 > bytestream2_get_bytes_left(&s->g)) { return AVERROR_INVALIDDATA; } for (z = 0; z < s->depth; z++) { dest_row = out_buf; for (y = 0; y < s->height; y++) { dest_row -= s->linesize; start_offset = bytestream2_get_be32(&g_table); bytestream2_seek(&s->g, start_offset, SEEK_SET); if (expand_rle_row(s, dest_row + z, dest_row + FFABS(s->linesize), s->depth) != s->width) { return AVERROR_INVALIDDATA; } } } return 0; }
1threat
Postman: How do you delete cookies in the pre-request script? : <p>All the postman cookie-management answers I've seen refer to either the browser extension (open chrome, delete cookies viz interceptor etc) or with the app, using the UI to manually manage cookies.</p> <p>I would like to delete certain cookies in my pre-request code as part of scripting my API tests. (delete them programmatically)</p> <p>The Sandobx API docs mention <code>pm.cookies</code> so I tried</p> <pre><code>if (pm.cookies !== null) { console.log("cookies!"); console.log(pm.cookies); } </code></pre> <p>But the <code>pm.cookies</code> array is empty. Yet in the console, the GET call then passes a cookie.</p> <p>There's also <code>postman.getResponseCookies</code>, which is null (I assume because we're in the pre-request section, not in the test section)</p> <p><a href="https://stackoverflow.com/a/44639513/1916341">One answer</a> suggested calling the postman-echo service to delete the cookie. I haven't investigated this yet, but it doesn't feel right.</p>
0debug
retrieve data from one to many relationship using entity framework : this is my model i want to retrieve all students with each attendances list when class =value and month =November[my model][1] [1]: https://i.stack.imgur.com/BasIC.png
0debug
pg.connect not a function? : <p>There appears to be a lot of documentation (e.g. <a href="https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js" rel="noreferrer">https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js</a>, but also elsewhere including this site) indicating that the proper method of connecting with the pg.js Node package is using pg.connect. However, I attempted (after previous problems with my actual code) to test by using the exact code shown on the aforementioned Heroku documentation:</p> <pre><code>var pg = require('pg'); pg.defaults.ssl = true; pg.connect(process.env.DATABASE_URL, function(err, client) { if (err) throw err; console.log('Connected to postgres! Getting schemas...'); client .query('SELECT table_schema,table_name FROM information_schema.tables;') .on('row', function(row) { console.log(JSON.stringify(row)); }); }); </code></pre> <p>And I got the error message "pg.connect is not a function". What is going on, and how do I fix it?</p>
0debug
iOS Swift4.0 Return Value : I am new to the swift programming so have a question on the return value. Suppose I have this code block: @IBAction func verifyItemPressed() { if pinTextField.text?.isEmpty ?? true { UIAlertController.showAlertWith(title: "Test", message: "Empty entry!!") return } In this case, what return value I can expect here. Since, what I know is that it should return either 0 or 1 and true or false (if I have defined bool) Thanks in advance
0debug
SQL-Statement to calculate time between to days : I have some data's in my mySQL Database. I try to get all informationen between to timestamps. Everytime the status change, i got a new timestamp and new number of Status. Someting like this: Status_List Status Time_Start Time_End 2 14:00:12 14:13:33 5 14:13:33 15:33:41 9 15:33:41 16:02:11 When i search: select * from Status_List where Time_Start between (15:00:00 and 16:00:00) Output: 9 15:33:41 16:02:11 But i need: Output: 5 15:00:00 15:33:41 9 15:33:41 16:00:00 Is this possible?
0debug
Convert SVG vector to Android multi-density png drawables : <p>I have some icons in SVG format, and want to convert them to Android png drawables, in the following sizes: <code>drawable-mdpi</code>, <code>drawable-hdpi</code>, <code>drawable-xhdpi</code>, <code>drawable-xxhdpi</code> and <code>drawable-xxxhdpi</code>.</p> <p>What's the easiest way to convert an SVG to drawable pngs?</p>
0debug
typescript interface require one of two properties to exist : <p>I'm trying to create an interface that could have </p> <pre><code>export interface MenuItem { title: string; component?: any; click?: any; icon: string; } </code></pre> <ol> <li>Is there a way to require <code>component</code> or <code>click</code> to be set</li> <li>Is there a way to require that both properties can't be set? </li> </ol>
0debug
Why is .gitignore not ignoring my files? : <p>See the image below. My .gitignore file should be ignoring all files in src/dist, but isn't.</p> <p><a href="https://i.stack.imgur.com/1qVzG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1qVzG.png" alt="enter image description here"></a></p>
0debug
How to call an activity from on Itemclick listener : I am trying to call an activity when ever an element from my gridview is clicked it will open in a swiping activity but I am getting an error on setting as 2829-2829/com.union.project E/AndroidRuntime: FATAL EXCEPTION: main Process: com.union.project, PID: 2829 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.union.project/com.union.project.Swipeview.Main3Activity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:302) at android.app.Activity.requestWindowFeature(Activity.java:3605) at com.union.project.Swipeview.Main3Activity.onCreate(Main3Activity.java:19) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)ย  at android.app.ActivityThread.access$800(ActivityThread.java:151)ย  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)ย  at android.os.Handler.dispatchMessage(Handler.java:102)ย  at android.os.Looper.loop(Looper.java:135)ย  at android.app.ActivityThread.main(ActivityThread.java:5254)ย  at java.lang.reflect.Method.invoke(Native Method)ย  at java.lang.reflect.Method.invoke(Method.java:372)ย  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)ย  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)ย  04-27 00:39:27.626 2829-2829/com.union.pro this is the error I am getting when I click on anyitem it show the toast but then crashes my fragment code @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view= inflater.inflate(R.layout.fragment_two, container, false); GridView gridView=(GridView)view.findViewById(R.id.gridView2); gridView.setAdapter(new UAdapter(getActivity())); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getActivity(),"Pic"+(position)+"Selected",Toast.LENGTH_SHORT).show(); Intent intent= new Intent(view.getContext(),Main4Activity.class); intent.putExtra("pic",position); startActivity(intent); } }); return view; } my swipe view code ` protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main4); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); viewPager =(ViewPager)findViewById(R.id.viewpager1); adapter =new CustomeSwipeAdapter2(this); viewPager.setAdapter(adapter); viewPager.setCurrentItem(getIntent().getIntExtra("pic", 0)); }` this is the activity that I want to start but getting the error can some one tell me how to fix this .
0debug
def perimeter_triangle(a,b,c): perimeter=a+b+c return perimeter
0debug
SurfaceFlinger: Failed to find layer FullScreenFragmentActivity in layer parent (no-parent) : <p>I have a <code>BottomSheetFragmentActivity</code> which <a href="https://issuetracker.google.com/issues/68454482#comment37" rel="noreferrer">causes this crash on Android 8.0 devices</a>. I am looking for a workaround, without setting targetSDK back to 26.</p> <p>I solved this <a href="https://stackoverflow.com/questions/46992843/interstitial-admob-ads-illegalstateexception-only-fullscreen-activities-can-r/48665610#48665610">as described here</a>: But this in turn causes</p> <blockquote> <p>SurfaceFlinger: Failed to find layer BottomSheetFragmentActivity#0 in layer parent (no-parent).</p> </blockquote> <p><strong>Is there a solution?</strong></p>
0debug
Where does `ng serve` output files to? : <p><code>ng serve</code> is not building to the path that I have set in my angular-cli.json in <code>apps[0].outDir</code>.</p> <p><code>ng build</code> works correctly and builds to the path that I have specified.</p>
0debug
static int parse_picture_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { PGSSubContext *ctx = avctx->priv_data; uint8_t sequence_desc; unsigned int rle_bitmap_len, width, height; uint16_t picture_id; if (buf_size <= 4) return -1; buf_size -= 4; picture_id = bytestream_get_be16(&buf); buf++; sequence_desc = bytestream_get_byte(&buf); if (!(sequence_desc & 0x80)) { if (buf_size > ctx->pictures[picture_id].rle_remaining_len) return -1; memcpy(ctx->pictures[picture_id].rle + ctx->pictures[picture_id].rle_data_len, buf, buf_size); ctx->pictures[picture_id].rle_data_len += buf_size; ctx->pictures[picture_id].rle_remaining_len -= buf_size; return 0; } if (buf_size <= 7) return -1; buf_size -= 7; rle_bitmap_len = bytestream_get_be24(&buf) - 2*2; width = bytestream_get_be16(&buf); height = bytestream_get_be16(&buf); if (avctx->width < width || avctx->height < height) { av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n"); return -1; } if (buf_size > rle_bitmap_len) { av_log(avctx, AV_LOG_ERROR, "too much RLE data\n"); return AVERROR_INVALIDDATA; } ctx->pictures[picture_id].w = width; ctx->pictures[picture_id].h = height; av_fast_malloc(&ctx->pictures[picture_id].rle, &ctx->pictures[picture_id].rle_buffer_size, rle_bitmap_len); if (!ctx->pictures[picture_id].rle) return -1; memcpy(ctx->pictures[picture_id].rle, buf, buf_size); ctx->pictures[picture_id].rle_data_len = buf_size; ctx->pictures[picture_id].rle_remaining_len = rle_bitmap_len - buf_size; return 0; }
1threat
static void cpu_4xx_pit_cb (void *opaque) { CPUState *env; ppc_tb_t *tb_env; ppcemb_timer_t *ppcemb_timer; env = opaque; tb_env = env->tb_env; ppcemb_timer = tb_env->opaque; env->spr[SPR_40x_TSR] |= 1 << 27; if ((env->spr[SPR_40x_TCR] >> 26) & 0x1) ppc_set_irq(env, PPC_INTERRUPT_PIT, 1); start_stop_pit(env, tb_env, 1); LOG_TB("%s: ar %d ir %d TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx " " "%016" PRIx64 "\n", __func__, (int)((env->spr[SPR_40x_TCR] >> 22) & 0x1), (int)((env->spr[SPR_40x_TCR] >> 26) & 0x1), env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR], ppcemb_timer->pit_reload); }
1threat
void ff_id3v1_read(AVFormatContext *s) { int ret; uint8_t buf[ID3v1_TAG_SIZE]; int64_t filesize, position = avio_tell(s->pb); if (s->pb->seekable) { filesize = avio_size(s->pb); if (filesize > 128) { avio_seek(s->pb, filesize - 128, SEEK_SET); ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE); if (ret == ID3v1_TAG_SIZE) { parse_tag(s, buf); } avio_seek(s->pb, position, SEEK_SET); } } }
1threat
Python and Google App Engine : How can I use as "NOT LIKE" SQL operator in Python and Google App Engine data store? I want to filter string in database. Please help me Best regard!
0debug
Error: "Double colon in host identifer" : <p>I am trying to connect to a database that I have hosted at MLab. I am using the StrongLoop API. I've placed the config information for my hosted databases into my datasources.json and config.json files, but whenever I run the directory with <code>npm start</code>, I get <code>throw new Error ('double colon in host identifier';)</code> at api\node_modules\mongodb\lib\url_parser.js:45.</p> <p>I have also made sure to install the loopback-connecter-mongodb npm package.</p> <p>Here is a snippet of <strong>datasources.json</strong> (without the actual database details, of course):</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>{ "db": { "name": "db", "connector": "mongodb", "host": "ds047355.mlab.com", "database": "dbtest", "username": "user", "password": "fakepassword", "port": 47355 } }</code></pre> </div> </div> </p> <p>Here is the <strong>config.json</strong> file:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>{ "restApiRoot": "/api", "host": "ds047355.mlab.com", "port": 47355, "remoting": { "context": { "enableHttpContext": false }, "rest": { "normalizeHttpPath": false, "xml": false }, "json": { "strict": false, "limit": "100kb" }, "urlencoded": { "extended": true, "limit": "100kb" }, "cors": false, "errorHandler": { "disableStackTrace": false } }, "legacyExplorer": false }</code></pre> </div> </div> </p> <p>Got any ideas?</p>
0debug
C# How to Open HEIC Image : <p>I have an image upload form in ASP.NET that supports JPG/PNG/GIF and I thought it would be enough. Until Apple introduced their new HEIC image format. How do I handle that in C#?</p> <p>Searching for C# and HEIC shows nothing in Google, so it seems this issue hasn't been addressed yet.</p> <p>Does the .NET Framework support HEIC out-of-the-box? Probably not since it's so new. Is there any 3rd party library that supports it? I want to convert HEIC to JPG for storage.</p> <p>Thanks</p>
0debug
static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaMuxContext *mkv = s->priv_data; int codec_type = s->streams[pkt->stream_index]->codec->codec_type; int keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY); int cluster_size; int cluster_size_limit; int64_t cluster_time; int64_t cluster_time_limit; AVIOContext *pb; int ret; if (mkv->tracks[pkt->stream_index].write_dts) cluster_time = pkt->dts - mkv->cluster_pts; else cluster_time = pkt->pts - mkv->cluster_pts; if (s->pb->seekable) { pb = s->pb; cluster_size = avio_tell(pb) - mkv->cluster_pos; cluster_time_limit = 5000; cluster_size_limit = 5 * 1024 * 1024; } else { pb = mkv->dyn_bc; cluster_size = avio_tell(pb); cluster_time_limit = 1000; cluster_size_limit = 32 * 1024; } if (mkv->cluster_pos && (cluster_size > cluster_size_limit || cluster_time > cluster_time_limit || (codec_type == AVMEDIA_TYPE_VIDEO && keyframe && cluster_size > 4 * 1024))) { av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64 " bytes, pts %" PRIu64 "dts %" PRIu64 "\n", avio_tell(pb), pkt->pts, pkt->dts); end_ebml_master(pb, mkv->cluster); mkv->cluster_pos = 0; if (mkv->dyn_bc) mkv_flush_dynbuf(s); } if (mkv->cur_audio_pkt.size > 0) { ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt); av_free_packet(&mkv->cur_audio_pkt); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Could not write cached audio packet ret:%d\n", ret); return ret; } } if (codec_type == AVMEDIA_TYPE_AUDIO) { mkv->cur_audio_pkt = *pkt; if (pkt->buf) { mkv->cur_audio_pkt.buf = av_buffer_ref(pkt->buf); ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM); } else ret = av_dup_packet(&mkv->cur_audio_pkt); } else ret = mkv_write_packet_internal(s, pkt); return ret; }
1threat
static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { WMACodecContext *s = avctx->priv_data; int i, total_gain, ret, error; s->block_len_bits= s->frame_len_bits; s->block_len = 1 << s->block_len_bits; apply_window_and_mdct(avctx, frame); if (s->ms_stereo) { float a, b; int i; for(i = 0; i < s->block_len; i++) { a = s->coefs[0][i]*0.5; b = s->coefs[1][i]*0.5; s->coefs[0][i] = a + b; s->coefs[1][i] = a - b; if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * MAX_CODED_SUPERFRAME_SIZE)) < 0) return ret; total_gain= 128; for(i=64; i; i>>=1){ error = encode_frame(s, s->coefs, avpkt->data, avpkt->size, total_gain - i); if(error<=0) total_gain-= i; while(total_gain <= 128 && error > 0) error = encode_frame(s, s->coefs, avpkt->data, avpkt->size, total_gain++); av_assert0((put_bits_count(&s->pb) & 7) == 0); i= avctx->block_align - (put_bits_count(&s->pb)+7)/8; av_assert0(i>=0); while(i--) put_bits(&s->pb, 8, 'N'); flush_put_bits(&s->pb); av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == avctx->block_align); if (frame->pts != AV_NOPTS_VALUE) avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay); avpkt->size = avctx->block_align; *got_packet_ptr = 1; return 0;
1threat
Extraction of ssn no.,date,email address from a file in Python : 1.**My file contains below contents: rexp.txt** `adf fdsf hh h fg h 1995-11-23 dasvsbh 2000-04-12 gnym,mnbv 2001-02-17 dascvfbsn bjhmndgfh xgfdjnfhm244-44-2255 fgfdsg gfjhkh fsgfdh 455-44-6577 dkjgjfkld sgf dgfdhj sdg 192.6.8.02 fdhdlk dfnfghr fisdhfih dfhghihg 154.56.2.6 fdhusdgv aff fjhgdf fdfdnfjgkpg fdf hgj fdnbk gjdhgj dfdfg raeh95@gmail.com efhidhg fdfuga reg@gmail.com ergudfi rey@gmail.com iugftudfh dgufidjfdg teeeee@gmail.comugfuhlfhs fgufif p` 2.I want to extract ssn number,date,email line by line.I'm expeccting codings which loops throughout every line and returns expected string 3.***correct the coding in python*** `import re def cfor_date(str): t=re.search(r'(\d{4}-\d{2}-\d{2})',str) return t def cfor_ssn(str): f=re.search(r'(\d{3}-\d{2}-\d{4})',str) return f def cfor_gm(str): g=re.search(r'([\w\.-]+@gmail[\w{3}\.-]+)',str) return g f = open("rexp.txt","r").read() lines = f.splitlines() for line in iter(lines): x=line.split(" ") print x if (cfor_date(x)) != None: # i feel problem here r=cfor_ssn(x) print r`
0debug
static av_cold void RENAME(sws_init_swScale)(SwsContext *c) { enum PixelFormat srcFormat = c->srcFormat, dstFormat = c->dstFormat; if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { if (!(c->flags & SWS_BITEXACT)) { if (c->flags & SWS_ACCURATE_RND) { c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); c->yuv2yuvX = RENAME(yuv2yuvX_ar ); if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break; case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break; case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break; case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break; case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break; default: break; } } } else { c->yuv2yuv1 = RENAME(yuv2yuv1 ); c->yuv2yuvX = RENAME(yuv2yuvX ); if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break; case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break; case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break; default: break; } } } } if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packed1 = RENAME(yuv2rgb32_1); c->yuv2packed2 = RENAME(yuv2rgb32_2); break; case PIX_FMT_BGR24: c->yuv2packed1 = RENAME(yuv2bgr24_1); c->yuv2packed2 = RENAME(yuv2bgr24_2); break; case PIX_FMT_RGB555: c->yuv2packed1 = RENAME(yuv2rgb555_1); c->yuv2packed2 = RENAME(yuv2rgb555_2); break; case PIX_FMT_RGB565: c->yuv2packed1 = RENAME(yuv2rgb565_1); c->yuv2packed2 = RENAME(yuv2rgb565_2); break; case PIX_FMT_YUYV422: c->yuv2packed1 = RENAME(yuv2yuyv422_1); c->yuv2packed2 = RENAME(yuv2yuyv422_2); break; default: break; } } } #if !COMPILE_TEMPLATE_MMX2 c->hScale = RENAME(hScale ); #endif #if COMPILE_TEMPLATE_MMX2 if (c->flags & SWS_FAST_BILINEAR && c->canMMX2BeUsed) { c->hyscale_fast = RENAME(hyscale_fast); c->hcscale_fast = RENAME(hcscale_fast); } else { #endif c->hyscale_fast = NULL; c->hcscale_fast = NULL; #if COMPILE_TEMPLATE_MMX2 } #endif #if !COMPILE_TEMPLATE_MMX2 switch(srcFormat) { case PIX_FMT_YUYV422 : c->chrToYV12 = RENAME(yuy2ToUV); break; case PIX_FMT_UYVY422 : c->chrToYV12 = RENAME(uyvyToUV); break; case PIX_FMT_NV12 : c->chrToYV12 = RENAME(nv12ToUV); break; case PIX_FMT_NV21 : c->chrToYV12 = RENAME(nv21ToUV); break; case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: case PIX_FMT_YUV444P16BE: c->chrToYV12 = RENAME(BEToUV); break; case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: c->chrToYV12 = RENAME(LEToUV); break; default: break; } #endif if (!c->chrSrcHSubSample) { switch(srcFormat) { case PIX_FMT_BGR24 : c->chrToYV12 = RENAME(bgr24ToUV); break; case PIX_FMT_RGB24 : c->chrToYV12 = RENAME(rgb24ToUV); break; default: break; } } switch (srcFormat) { #if !COMPILE_TEMPLATE_MMX2 case PIX_FMT_YUYV422 : case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: case PIX_FMT_YUV444P16BE: case PIX_FMT_Y400A : case PIX_FMT_GRAY16BE : c->lumToYV12 = RENAME(yuy2ToY); break; case PIX_FMT_UYVY422 : case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: case PIX_FMT_GRAY16LE : c->lumToYV12 = RENAME(uyvyToY); break; #endif case PIX_FMT_BGR24 : c->lumToYV12 = RENAME(bgr24ToY); break; case PIX_FMT_RGB24 : c->lumToYV12 = RENAME(rgb24ToY); break; default: break; } #if !COMPILE_TEMPLATE_MMX2 if (c->alpPixBuf) { switch (srcFormat) { case PIX_FMT_Y400A : c->alpToYV12 = RENAME(yuy2ToY); break; default: break; } } #endif }
1threat
How to search for a string in another Postgresql : This bellow is result of the two comand Explain select .... ---------------------------------------- Sort (cost=399301.55..399301.57 rows=6 width=36) (actual time=18749.397..18749.398 rows=4 loops=1) Sort Key: l_returnflag, l_linestatus Sort Method: quicksort Memory: 25kB -> HashAggregate (cost=399301.21..399301.48 rows=6 width=36) (actual time=18749.130..18749.143 rows=4 loops=1)" -> Seq Scan on h_lineitem (cost=0.00..250095.98 rows=5968209 width=36) (actual time=0.048..8643.529 rows=5996518 loops=1)" Filter: (l_shipdate <= (to_date('1998/12/01'::text, 'YYYY/MM/DD'::text) - '10 days'::interval day))" > Total runtime: 18749.680 ms > ----------------------------------- > ---------------------------------- Aggregate (cost=7922058.70..7922058.71 rows=1 width=16)" -> Hash Join > (cost=1899763.92..7922058.69 rows=1 width=16)" > Hash Cond: (h_lineitem.l_partkey = h_part.p_partkey)" > Join Filter: (((h_part.p_brand = 'Brand#13'::bpchar) AND (h_part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM > PKG"}'::bpchar[])) AND (h_lineitem.l_quantity >= 4::double precision) > AND (h_lineitem.l_quantity <= 14::double precision) AND (h_ (...)" > -> Seq Scan on h_lineitem (cost=0.00..235156.84 rows=211094 width=32)" > Filter: ((l_shipmode = ANY ('{AIR,"AIR REG"}'::bpchar[])) AND (l_shipinstruct = 'DELIVER IN > PERSON'::bpchar))" > -> Hash (cost=1183158.46..1183158.46 rows=35278997 width=33)" > -> Seq Scan on h_part (cost=0.00..1183158.46 rows=35278997 width=33)" > Filter: (p_size >= 1)" ------------------------------------------- I need to capture only string cost=399301.55 (for sample 1nd result). The good news is that the string "COST" is always at the beginning (first line) of the result. I try fuctions of string manipulation, but not working. The problem is that the field "cost" is not always in the same position (see samples). It is necessary to find what your position is always. The expected result is : select (.... ) ----------------- cost=399301 (only this)
0debug
How Does Javascript if statement indentation work? : <p>How many spaces should be used for each line of if statement at the beginning of the line? suppose we have 10 lines of nested if statements, what is the formula to determine how many lines to be used? Also can a programmer use the tab key instead to obtain proper indentation for a statement.</p> <pre><code>if (a !== 0) { if (b &gt; 1) { if (c &lt; 1) { </code></pre>
0debug
static int decode_residual_block(AVSContext *h, GetBitContext *gb, const struct dec_2dvlc *r, int esc_golomb_order, int qp, uint8_t *dst, int stride) { int i, level_code, esc_code, level, run, mask; DCTELEM level_buf[65]; uint8_t run_buf[65]; DCTELEM *block = h->block; for(i=0;i<65;i++) { level_code = get_ue_code(gb,r->golomb_order); if(level_code >= ESCAPE_CODE) { run = ((level_code - ESCAPE_CODE) >> 1) + 1; esc_code = get_ue_code(gb,esc_golomb_order); level = esc_code + (run > r->max_run ? 1 : r->level_add[run]); while(level > r->inc_limit) r++; mask = -(level_code & 1); level = (level^mask) - mask; } else { level = r->rltab[level_code][0]; if(!level) break; run = r->rltab[level_code][1]; r += r->rltab[level_code][2]; } level_buf[i] = level; run_buf[i] = run; } if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp], ff_cavs_dequant_shift[qp], i)) return -1; h->cdsp.cavs_idct8_add(dst,block,stride); h->s.dsp.clear_block(block); return 0; }
1threat
Delphi Error : Equals.Caption := ; Expresion expected but ';' found : I do not know where it is wrong, im new learning Delphi. I followed this : http://delphi.wikia.com/wiki/Simple_Calculator_Tutorial This My Coding delphi, please help me master unit Unit3; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm3 = class(TForm) Addition: TButton; Subtraction: TButton; Multiplication: TButton; Division: TButton; One: TButton; Two: TButton; Three: TButton; Four: TButton; Five: TButton; Six: TButton; Seven: TButton; Eight: TButton; Nine: TButton; Zero: TButton; Decimal: TButton; Enter: TButton; ClearValue: TButton; Panel1: TPanel; Negative: TButton; Reset: TButton; NumberEdit: TEdit; Equals: TLabel; procedure NegativeClick(Sender: TObject); procedure AdditionClick(Sender: TObject); procedure SubtractionClick(Sender: TObject); procedure MultiplicationClick(Sender: TObject); procedure DivisionClick(Sender: TObject); procedure EnterClick(Sender: TObject); procedure ClearValueClick(Sender: TObject); procedure ResetClick(Sender: TObject); procedure NumberEditChange(Sender: TObject); procedure NumberButtonClick (Sender: TObject); private { Private declarations } public { Public declarations } end; var Form3: TForm3; implementation {$R *.DFM} var FNumber : real; Math : string; procedure TForm3.NumberButtonClick(Sender: TObject); begin NumberEdit.Text := NumberEdit.Text + (Sender as TButton).Caption; end; procedure TForm3.NegativeClick(Sender: TObject); var OriginalNumber: real; TextNumber: string; begin OriginalNumber := -(StrToFloat(NumberEdit.Text)); TextNumber := FormatFloat('0.##########', OriginalNumber); NumberEdit.Text := TextNumber end; procedure TForm3.AdditionClick(Sender: TObject); begin Math := 'Add'; FNumber := StrToFloat(NumberEdit.Text); NumberEdit.Clear; end; procedure TForm3.SubtractionClick(Sender: TObject); begin Math := 'Subtract'; FNumber := StrToFloat(NumberEdit.Text); NumberEdit.Clear; end; procedure TForm3.MultiplicationClick(Sender: TObject); begin Math := 'Multiply'; FNumber := StrToFloat(NumberEdit.Text); NumberEdit.Clear; end; procedure TForm3.DivisionClick(Sender: TObject); begin Math := 'Divide'; FNumber := StrToFloat(NumberEdit.Text); NumberEdit.Clear; end; procedure TForm3.EnterClick(Sender: TObject); var Answer, SNumber : real; Text : string; begin SNumber := StrToFloat(NumberEdit.Text); begin if Math = 'Add' then Answer := FNumber + SNumber; Text := FormatFloat('0.#####', Answer); Equals.Caption := '= ' + Text; NumberEdit.Clear; end; begin if Math = 'Subtract' then Answer := FNumber - SNumber; Text := FormatFloat('0.#####', Answer); Equals.Caption := '= ' + Text; NumberEdit.Clear; end; begin if Math = 'Multiply' then Answer := FNumber * SNumber; Text := FormatFloat('0.#####', Answer); Equals.Caption := '= ' + Text; NumberEdit.Clear; end; begin if Math = 'Divide' then Answer := FNumber / SNumber; Text := FormatFloat('0.#####', Answer); Equals.Caption := '= ' + Text; NumberEdit.Clear; end; end; procedure TForm3.ClearValueClick(Sender: TObject); begin NumberEdit.Clear; end; procedure TForm3.ResetClick(Sender: TObject); begin Equals.Caption := ; NumberEdit.Clear; FNumber := 0; SNumber := 0; Math := 'Default'; end; end. This is the task of the university, This screenshot of the error [This Screenshot Errors][1] [1]: https://i.stack.imgur.com/NS7AD.png
0debug
static void dct_unquantize_mpeg1_mmx(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int nCoeffs; const UINT16 *quant_matrix; if(s->alternate_scan) nCoeffs= 64; else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ]; if (s->mb_intra) { int block0; if (n < 4) block0 = block[0] * s->y_dc_scale; else block0 = block[0] * s->c_dc_scale; quant_matrix = s->intra_matrix; asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $15, %%mm7 \n\t" "movd %2, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "movl %3, %%eax \n\t" ".balign 16\n\t" "1: \n\t" "movq (%0, %%eax), %%mm0 \n\t" "movq 8(%0, %%eax), %%mm1 \n\t" "movq (%1, %%eax), %%mm4 \n\t" "movq 8(%1, %%eax), %%mm5 \n\t" "pmullw %%mm6, %%mm4 \n\t" "pmullw %%mm6, %%mm5 \n\t" "pxor %%mm2, %%mm2 \n\t" "pxor %%mm3, %%mm3 \n\t" "pcmpgtw %%mm0, %%mm2 \n\t" "pcmpgtw %%mm1, %%mm3 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "pmullw %%mm4, %%mm0 \n\t" *q "pmullw %%mm5, %%mm1 \n\t" *q "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" "pcmpeqw (%0, %%eax), %%mm4 \n\t" "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" "psraw $3, %%mm0 \n\t" "psraw $3, %%mm1 \n\t" "psubw %%mm7, %%mm0 \n\t" "psubw %%mm7, %%mm1 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%mm1 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "pandn %%mm0, %%mm4 \n\t" "pandn %%mm1, %%mm5 \n\t" "movq %%mm4, (%0, %%eax) \n\t" "movq %%mm5, 8(%0, %%eax) \n\t" "addl $16, %%eax \n\t" "js 1b \n\t" ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) : "%eax", "memory" ); block[0]= block0; } else { quant_matrix = s->non_intra_matrix; asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $15, %%mm7 \n\t" "movd %2, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "movl %3, %%eax \n\t" ".balign 16\n\t" "1: \n\t" "movq (%0, %%eax), %%mm0 \n\t" "movq 8(%0, %%eax), %%mm1 \n\t" "movq (%1, %%eax), %%mm4 \n\t" "movq 8(%1, %%eax), %%mm5 \n\t" "pmullw %%mm6, %%mm4 \n\t" "pmullw %%mm6, %%mm5 \n\t" "pxor %%mm2, %%mm2 \n\t" "pxor %%mm3, %%mm3 \n\t" "pcmpgtw %%mm0, %%mm2 \n\t" "pcmpgtw %%mm1, %%mm3 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "paddw %%mm0, %%mm0 \n\t" *2 "paddw %%mm1, %%mm1 \n\t" *2 "paddw %%mm7, %%mm0 \n\t" *2 + 1 "paddw %%mm7, %%mm1 \n\t" *2 + 1 "pmullw %%mm4, %%mm0 \n\t" "pmullw %%mm5, %%mm1 \n\t" "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" "pcmpeqw (%0, %%eax), %%mm4 \n\t" "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" "psraw $4, %%mm0 \n\t" "psraw $4, %%mm1 \n\t" "psubw %%mm7, %%mm0 \n\t" "psubw %%mm7, %%mm1 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%mm1 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "pandn %%mm0, %%mm4 \n\t" "pandn %%mm1, %%mm5 \n\t" "movq %%mm4, (%0, %%eax) \n\t" "movq %%mm5, 8(%0, %%eax) \n\t" "addl $16, %%eax \n\t" "js 1b \n\t" ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) : "%eax", "memory" ); } }
1threat
HTACCESS rules error : In my htaccess file I have added a rule to redirect url/abc/xyz to url/abc/xyz.php so now even when I try to access url/abc.php it redirects me to url/abc/ Help me with this.. My code now : # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\s [NC] RewriteRule ^ %1 [R,L] ## To internally forward /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{QUERY_STRING} ^$ RewriteRule ^(.*?)/?$ $1.php [L]
0debug
Convert Spritekit Game to Android? : <p>Are there any new options for converting a spritekit game to android? It seems the only options are to recode everything in Java or to use Cocos2D, LibGDX, etc.</p>
0debug
tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti) { uint16_t mss; int opt, optlen; DEBUG_CALL("tcp_dooptions"); DEBUG_ARGS((dfd," tp = %lx cnt=%i \n", (long )tp, cnt)); for (; cnt > 0; cnt -= optlen, cp += optlen) { opt = cp[0]; if (opt == TCPOPT_EOL) break; if (opt == TCPOPT_NOP) optlen = 1; else { optlen = cp[1]; if (optlen <= 0) break; } switch (opt) { default: continue; case TCPOPT_MAXSEG: if (optlen != TCPOLEN_MAXSEG) continue; if (!(ti->ti_flags & TH_SYN)) continue; memcpy((char *) &mss, (char *) cp + 2, sizeof(mss)); NTOHS(mss); (void) tcp_mss(tp, mss); break; } } }
1threat
Create XMl file in particular format in c# : <p>i want to create xml file in c# in below format.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;custom&gt; &lt;text1&gt; &lt;value name="sample1"&gt;hello&lt;/value&gt; &lt;/text1&gt; &lt;text1&gt;&lt;value name="sample2"&gt;world&lt;/value&gt; &lt;/text1&gt; &lt;/custom&gt;</code></pre> </div> </div> </p>
0debug
static void vscsi_send_request_sense(VSCSIState *s, vscsi_req *req) { SCSIDevice *sdev = req->sdev; uint8_t *cdb = req->iu.srp.cmd.cdb; int n; cdb[0] = 3; cdb[1] = 0; cdb[2] = 0; cdb[3] = 0; cdb[4] = 96; cdb[5] = 0; req->sensing = 1; n = sdev->info->send_command(sdev, req->qtag, cdb, req->lun); dprintf("VSCSI: Queued request sense tag 0x%x\n", req->qtag); if (n < 0) { fprintf(stderr, "VSCSI: REQUEST_SENSE wants write data !?!?!?\n"); sdev->info->cancel_io(sdev, req->qtag); vscsi_makeup_sense(s, req, HARDWARE_ERROR, 0, 0); vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0); vscsi_put_req(s, req); return; } else if (n == 0) { return; } sdev->info->read_data(sdev, req->qtag); }
1threat
static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al){ int i, mb_x, mb_y; uint8_t* data[MAX_COMPONENTS]; int linesize[MAX_COMPONENTS]; for(i=0; i < nb_components; i++) { int c = s->comp_index[i]; data[c] = s->picture.data[c]; linesize[c]=s->linesize[c]; s->coefs_finished[c] |= 1; if(s->flipped) { assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 )); linesize[c] *= -1; } } for(mb_y = 0; mb_y < s->mb_height; mb_y++) { for(mb_x = 0; mb_x < s->mb_width; mb_x++) { if (s->restart_interval && !s->restart_count) s->restart_count = s->restart_interval; for(i=0;i<nb_components;i++) { uint8_t *ptr; int n, h, v, x, y, c, j; n = s->nb_blocks[i]; c = s->comp_index[i]; h = s->h_scount[i]; v = s->v_scount[i]; x = 0; y = 0; for(j=0;j<n;j++) { ptr = data[c] + (((linesize[c] * (v * mb_y + y) * 8) + (h * mb_x + x) * 8) >> s->avctx->lowres); if(s->interlaced && s->bottom_field) ptr += linesize[c] >> 1; if(!s->progressive) { s->dsp.clear_block(s->block); if(decode_block(s, s->block, i, s->dc_index[i], s->ac_index[i], s->quant_matrixes[ s->quant_index[c] ]) < 0) { av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return -1; } s->dsp.idct_put(ptr, linesize[c], s->block); } else { int block_idx = s->block_stride[c] * (v * mb_y + y) + (h * mb_x + x); DCTELEM *block = s->blocks[c][block_idx]; if(Ah) block[0] += get_bits1(&s->gb) * s->quant_matrixes[ s->quant_index[c] ][0] << Al; else if(decode_dc_progressive(s, block, i, s->dc_index[i], s->quant_matrixes[ s->quant_index[c] ], Al) < 0) { av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return -1; } } if (++x == h) { x = 0; y++; } } } if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); for (i=0; i<nb_components; i++) s->last_dc[i] = 1024; } } } return 0; }
1threat
wp_mail() is not working for me in wordpress : <p>this is my template code and it is not sending mails to customers in wordpress. please anyone help me to make right this code. thanks</p> <pre><code>&lt;?php /* Template name: contact */ get_header(); $email="test@gmail.com"; $subject="testing"; $message = "hi this is test"; $headers = 'From:' . "testing@gmail.com"; if(wp_mail($email, $subject, $message, $headers)) { echo "sending mail test"; } else { echo "not"; } get_footer(); ?&gt; </code></pre>
0debug
Only if contains >< /!a-zA-Z or some of them with regular expression : <p>I need to check string if contains >&lt; /!a-zA-Z or some of them (Also contains space). The only thing I know is a-zA-Z i need an example in C# or Javascript.</p>
0debug
CQRS event store aggregate vs projection : <p><strong>In a CQRS event store, does an "aggregate" contain a summarized view of the events or simply a reference to the boundary of those events? (group id)</strong></p> <p>A projection is a view or representation of events so in the case of an aggregate representing a boundary that would make sense to me whereas if the aggregate contained the current summarized state I'd be confused about duplication between the two.</p>
0debug
Is it possible to insert a string without using Console.WriteLine directly? : <p>for exemple: </p> <pre><code> while (!incomingFiles.EndOfStream) { sLine = incomingFiles.ReadLine(); sLine.Insert(iCharacterIndicator , "something"); Console.WriteLine(sLine); } </code></pre> <p>I want to put a desired string at a specific spot using an indexOf pointing where I need to put my desired string, so i'm using the iCharacterIndicator to point out each new lines where I need to put my string, but the Insert wont show on my console except when I insert directly in a Console.WriteLine, thus, ruining my algorithm.</p>
0debug
foreach loop in scala : <p>In scala foreach loop if I have list</p> <pre><code>val a = List("a","b","c","d") </code></pre> <p>I can print them without a pattern matching like this</p> <pre><code>a.foreach(c =&gt; println(c)) </code></pre> <p>But, if I have a tuple like this</p> <pre><code>val v = Vector((1,9), (2,8), (3,7), (4,6), (5,5)) </code></pre> <p>why should I have to use </p> <pre><code>v.foreach{ case(i,j) =&gt; println(i, j) } </code></pre> <ol> <li>a pattern matching case</li> <li>{ brackets</li> </ol> <p>Please explain what happens when the two foreach loops are executed.</p>
0debug
Extract particular text data from string using R : I have a sample text like "0 zacapa ambar 40% 1l">I would require help to extract 2 different parts of this text. Output: 1) zacapa ambar 2) 40% 1l
0debug
static void sun4uv_init(MemoryRegion *address_space_mem, QEMUMachineInitArgs *args, const struct hwdef *hwdef) { SPARCCPU *cpu; M48t59State *nvram; unsigned int i; uint64_t initrd_addr, initrd_size, kernel_addr, kernel_size, kernel_entry; PCIBus *pci_bus, *pci_bus2, *pci_bus3; ISABus *isa_bus; qemu_irq *ivec_irqs, *pbm_irqs; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; FWCfgState *fw_cfg; cpu = cpu_devinit(args->cpu_model, hwdef); ram_init(0, args->ram_size); prom_init(hwdef->prom_addr, bios_name); ivec_irqs = qemu_allocate_irqs(cpu_set_ivec_irq, cpu, IVEC_MAX); pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, ivec_irqs, &pci_bus2, &pci_bus3, &pbm_irqs); pci_vga_init(pci_bus); isa_bus = pci_ebus_init(pci_bus, -1, pbm_irqs); i = 0; if (hwdef->console_serial_base) { serial_mm_init(address_space_mem, hwdef->console_serial_base, 0, NULL, 115200, serial_hds[i], DEVICE_BIG_ENDIAN); i++; } for(; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(isa_bus, i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { parallel_init(isa_bus, i, parallel_hds[i]); } } for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); ide_drive_get(hd, MAX_IDE_BUS); pci_cmd646_ide_init(pci_bus, hd, 1); isa_create_simple(isa_bus, "i8042"); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(isa_bus, fd); nvram = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); initrd_size = 0; initrd_addr = 0; kernel_size = sun4u_load_kernel(args->kernel_filename, args->initrd_filename, ram_size, &initrd_size, &initrd_addr, &kernel_addr, &kernel_entry); sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", args->ram_size, args->boot_device, kernel_addr, kernel_size, args->kernel_cmdline, initrd_addr, initrd_size, 0, graphic_width, graphic_height, graphic_depth, (uint8_t *)&nd_table[0].macaddr); fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_entry); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (args->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(args->kernel_cmdline) + 1); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, args->kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, args->boot_device[0]); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
1threat
how to NOT read_csv if csv is empty : <p>Using Python 2.7 and Pandas</p> <p>I have to parse through my directory and plot a bunch of CSVs. If the CSV is empty, the script breaks and produces the error message: </p> <pre><code>pandas.io.common.EmptyDataError: No columns to parse from file </code></pre> <p>If I have my file paths stored in </p> <pre><code>file_paths=[] </code></pre> <p>how do I read through each one and only plot the non empty CSVs? If I have an empty dataframe defined as df=[] I attempt the following code</p> <pre><code>for i in range(0,len(file_paths)): if pd.read_csv(file_paths[i] == ""): print "empty" else df.append(pd.read_csv(file_paths[i],header=None)) </code></pre>
0debug
Firebase Storage Video Streaming : <p>I'm working on an app that has video streaming functionality. I'm using firebase database and firebase storage. I'm trying to find some documentation on how firebase storage handles video files, but can't really find much.</p> <p>There's mentioning in the docs that firebase storage works with other google app services to allow for CDN and video streaming, but all searches seem to lead to a dead end. Any advice? </p>
0debug
static void sm501_palette_write(void *opaque, target_phys_addr_t addr, uint32_t value) { SM501State * s = (SM501State *)opaque; SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n", (int)addr, value); assert(0 <= addr && addr < 0x400 * 3); *(uint32_t*)&s->dc_palette[addr] = value; }
1threat
Can someone explain this Binary tree code to me : <p><a href="https://i.stack.imgur.com/XQUHZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XQUHZ.png" alt="enter image description here"></a></p> <p>I only understand the first step. Where it says that *tmp = the node containing the data (7).</p>
0debug
static uint64_t megasas_port_read(void *opaque, target_phys_addr_t addr, unsigned size) { return megasas_mmio_read(opaque, addr & 0xff, size); }
1threat
static int ram_find_and_save_block(RAMState *rs, bool last_stage) { PageSearchStatus pss; int pages = 0; bool again, found; ram_addr_t dirty_ram_abs; if (!ram_bytes_total()) { return pages; } pss.block = rs->last_seen_block; pss.offset = rs->last_offset; pss.complete_round = false; if (!pss.block) { pss.block = QLIST_FIRST_RCU(&ram_list.blocks); } do { again = true; found = get_queued_page(rs, &pss, &dirty_ram_abs); if (!found) { found = find_dirty_block(rs, &pss, &again, &dirty_ram_abs); } if (found) { pages = ram_save_host_page(rs, &pss, last_stage, dirty_ram_abs); } } while (!pages && again); rs->last_seen_block = pss.block; rs->last_offset = pss.offset; return pages; }
1threat
Failing to shoW UIAlertController due to - '''Application tried to present modally an active controller' : I have an application that displays documents in a UICollectionView. Each UICollectionViewCell has a button (distinct from that carried out by 'didSelectItemAt'). This button brings up a custom popup which I have created using a UIViewController. It is presented 'Over Current Context'. This popup presents a list of options, one including 'Delete document'. When a user selects this latter option, I would like a UIAlertController to appear to confirm delete. This is the issue that I am facing. Here is my code: The error that I am getting is: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <myApplication.CollectionViewFolder: 0x12e08f400>.' CUSTOM POPUP (UIVIEWCONTROLLER) protocol DismissOptionShowDeleteAlert { func showDeleteAlert() } class MoreOptionsOnPDFViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{ var showDeleteAlertDelegate: DismissOptionShowDeleteAlert! / TAP ON ROW func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){ ... }else if indexPath == [0,4]{ // DELETE DOCUMENT DispatchQueue.main.async { self.dismiss(animated: true) { self.showDeleteAlertDelegate.showDeleteAlert() } } } ... } UICOLLECTIONVIEW: class CollectionViewFolder: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate ,UICollectionViewDelegateFlowLayout, MoreInfoDocument, MoveFolder, ScanObjectMovedFolder, DismissOptionShowDeleteAlert{ // SHOW DELETE CONFIRMATION ALERT func showDeleteAlert() { Alerts.deleteDocumentConfirm(on: self) { // DELETE DOCUMENT FROM SERVER print("Delete document ...") } } } ALERT STRUCT: import Foundation import UIKit struct Alerts { private static func showBasicAlert(on vc: UIViewController, with title: String, message: String, action: @escaping (() -> ())){ let alert = UIAlertController.init(title: title, message: message, preferredStyle: .alert) let okAction = UIAlertAction.init(title: "OK", style: .default) { (UIActionAlert) in action() } let cancelAction = UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil) alert.addAction(okAction) alert.addAction(cancelAction) DispatchQueue.main.async { vc.present(vc, animated: true, completion: nil) } } static func deleteDocumentConfirm(on vc: UIViewController, action: @escaping (() -> ())){ showBasicAlert(on: vc, with: "Please Confirm Delete", message: "", action: action) } }
0debug
How do i play an animation on a button press : <p>Im making my first game but I am stuck. I am making the main menu. I want to make it that when I press the start game button an animation plays and it starts that game. I have no idea where to start. The button to start the game works and I have created the animation and that works but I don't know how to combine then.</p> <p>I have tried to make the button play the animation play with 'animation.play' but that does not work.</p> <p>Thanks in Advance.</p>
0debug
search string value with wild card in another string java : <p>Suppose I have string value</p> <pre><code>String strValue1 = "This is the 3TB value"; String strValue2 = "3TB is the value"; String strValue3 = "The value is 3TB"; </code></pre> <p>No when the user search for <code>3TB*</code> then it should match with the strValue2 same like for when user search for <code>*3TB*</code> then it should match with strValue1 and for <code>*3TB</code> it should match with strValue3</p> <p>I tried with so many examples but no luck. Is there any wildcard search for string? I can't use any external libraries</p>
0debug
scikit learn: train_test_split, can I ensure same splits on different datasets : <p>I understand that the train_test_split method splits a dataset into random train and test subsets. And using random_state=int can ensure we have the same splits on this dataset for each time the method is called.</p> <p>My problem is slightly different.</p> <p>I have two datasets, A and B, they contain identical sets of examples and the order of these examples appear in each dataset is also identical. But they key difference is that exmaples in each dataset uses a different sets of features. </p> <p>I would like to test to see if the features used in A leads to better performance than features used in B. So I would like to ensure that when I call train_test_split on A and B, I can get the same splits on both datasets so that the comparison is meaningful.</p> <p>Is this possible? Do I simply need to ensure the random_state in both method calls for both datasets are the same?</p> <p>Thanks</p>
0debug
void object_property_set_qobject(Object *obj, QObject *value, const char *name, Error **errp) { Visitor *v; v = qobject_input_visitor_new(value, false); object_property_set(obj, v, name, errp); visit_free(v); }
1threat
How to Check if the File Name is already exists or not? : <p>Before Storing a file i am checking if the file name already exists (to prevent overriding)</p> <p>For this i am using the following code</p> <p>The issue with the below code is that there is no guarantee that newimage does not already exist. </p> <pre><code> public static String ImageOverrideChecker(String image_name)throws IOException{ String newimage = ""; ArrayList&lt;String&gt; image_nameslist = new ArrayList&lt;String&gt;(); File file = new File("/Images/"); File[] files = file.listFiles(); for(File f: files){ image_nameslist.add(f.getName()); } if(image_nameslist.contains(image_name)) { Random randomGenerator = new Random(); int randomInt = randomGenerator.nextInt(1000); Matcher matcher = Pattern.compile("(.*)\\.(.*?)").matcher(image_name); if (matcher.matches()) { newimage = String.format("%s_%d.%s", matcher.group(1), randomInt,matcher.group(2)); } } else { newimage = image_name; } return newimage; } </code></pre>
0debug
Is there a Google Sheets formula to put the name of the sheet into a cell? : <p>The following illustration should help:</p> <p><a href="https://i.stack.imgur.com/RBjUB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RBjUB.png" alt="enter image description here"></a></p>
0debug
static uint16_t vring_used_idx(VirtQueue *vq) { VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches); hwaddr pa = offsetof(VRingUsed, idx); return virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); }
1threat
static void pl061_write(void *opaque, target_phys_addr_t offset, uint32_t value) { pl061_state *s = (pl061_state *)opaque; uint8_t mask; if (offset < 0x400) { mask = (offset >> 2) & s->dir; s->data = (s->data & ~mask) | (value & mask); pl061_update(s); return; } switch (offset) { case 0x400: s->dir = value; break; case 0x404: s->isense = value; break; case 0x408: s->ibe = value; break; case 0x40c: s->iev = value; break; case 0x410: s->im = value; break; case 0x41c: s->istate &= ~value; break; case 0x420: mask = s->cr; s->afsel = (s->afsel & ~mask) | (value & mask); break; case 0x500: s->dr2r = value; break; case 0x504: s->dr4r = value; break; case 0x508: s->dr8r = value; break; case 0x50c: s->odr = value; break; case 0x510: s->pur = value; break; case 0x514: s->pdr = value; break; case 0x518: s->slr = value; break; case 0x51c: s->den = value; break; case 0x520: s->locked = (value != 0xacce551); break; case 0x524: if (!s->locked) s->cr = value; break; default: hw_error("pl061_write: Bad offset %x\n", (int)offset); } pl061_update(s); }
1threat