problem
stringlengths
26
131k
labels
class label
2 classes
static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) { AlsaData *s = s1->priv_data; AVStream *st = s1->streams[0]; int res; snd_htimestamp_t timestamp; snd_pcm_uframes_t ts_delay; if (av_new_packet(pkt, s->period_size) < 0) { return AVERROR(EIO); } while ((res = snd_pcm_readi(s->h, pkt->data, pkt->size / s->frame_size)) < 0) { if (res == -EAGAIN) { av_free_packet(pkt); return AVERROR(EAGAIN); } if (ff_alsa_xrun_recover(s1, res) < 0) { av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n", snd_strerror(res)); av_free_packet(pkt); return AVERROR(EIO); } } snd_pcm_htimestamp(s->h, &ts_delay, &timestamp); ts_delay += res; pkt->pts = timestamp.tv_sec * 1000000LL + (timestamp.tv_nsec * st->codec->sample_rate - ts_delay * 1000000000LL + st->codec->sample_rate * 500LL) / (st->codec->sample_rate * 1000LL); pkt->size = res * s->frame_size; return 0; }
1threat
i have add /(slash) in last of link but css is not work proper why? : My Website is asp.net but problem is i have add **/(slash)** in last of link but not work css in proper why? **example:** `http://localhost:5022/Registration.aspx/` please help me
0debug
static void vc1_interp_mc(VC1Context *v) { MpegEncContext *s = &v->s; DSPContext *dsp = &v->s.dsp; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; int off, off_uv; int v_edge_pos = s->v_edge_pos >> v->field_mode; if (!v->field_mode && !v->s.next_picture.f.data[0]) return; mx = s->mv[1][0][0]; my = s->mv[1][0][1]; uvmx = (mx + ((mx & 3) == 3)) >> 1; uvmy = (my + ((my & 3) == 3)) >> 1; if (v->field_mode) { if (v->cur_field_type != v->ref_field_type[1]) my = my - 2 + 4 * v->cur_field_type; uvmy = uvmy - 2 + 4 * v->cur_field_type; } if (v->fastuvmc) { uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1)); uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1)); } srcY = s->next_picture.f.data[0]; srcU = s->next_picture.f.data[1]; srcV = s->next_picture.f.data[2]; src_x = s->mb_x * 16 + (mx >> 2); src_y = s->mb_y * 16 + (my >> 2); uvsrc_x = s->mb_x * 8 + (uvmx >> 2); uvsrc_y = s->mb_y * 8 + (uvmy >> 2); if (v->profile != PROFILE_ADVANCED) { src_x = av_clip( src_x, -16, s->mb_width * 16); src_y = av_clip( src_y, -16, s->mb_height * 16); uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); } else { src_x = av_clip( src_x, -17, s->avctx->coded_width); src_y = av_clip( src_y, -18, s->avctx->coded_height + 1); uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); } srcY += src_y * s->linesize + src_x; srcU += uvsrc_y * s->uvlinesize + uvsrc_x; srcV += uvsrc_y * s->uvlinesize + uvsrc_x; if (v->field_mode && v->ref_field_type[1]) { srcY += s->current_picture_ptr->f.linesize[0]; srcU += s->current_picture_ptr->f.linesize[1]; srcV += s->current_picture_ptr->f.linesize[2]; } if (s->flags & CODEC_FLAG_GRAY) { srcU = s->edge_emu_buffer + 18 * s->linesize; srcV = s->edge_emu_buffer + 18 * s->linesize; } if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3 || (unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) { uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize; srcY -= s->mspel * (1 + s->linesize); s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17 + s->mspel * 2, 17 + s->mspel * 2, src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, v_edge_pos); srcY = s->edge_emu_buffer; s->vdsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8 + 1, 8 + 1, uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); s->vdsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8 + 1, 8 + 1, uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); srcU = uvbuf; srcV = uvbuf + 16; if (v->rangeredfrm) { int i, j; uint8_t *src, *src2; src = srcY; for (j = 0; j < 17 + s->mspel * 2; j++) { for (i = 0; i < 17 + s->mspel * 2; i++) src[i] = ((src[i] - 128) >> 1) + 128; src += s->linesize; } src = srcU; src2 = srcV; for (j = 0; j < 9; j++) { for (i = 0; i < 9; i++) { src[i] = ((src[i] - 128) >> 1) + 128; src2[i] = ((src2[i] - 128) >> 1) + 128; } src += s->uvlinesize; src2 += s->uvlinesize; } } srcY += s->mspel * (1 + s->linesize); } if (v->field_mode && v->second_field) { off = s->current_picture_ptr->f.linesize[0]; off_uv = s->current_picture_ptr->f.linesize[1]; } else { off = 0; off_uv = 0; } if (s->mspel) { dxy = ((my & 3) << 2) | (mx & 3); v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd); v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd); srcY += s->linesize * 8; v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize , srcY , s->linesize, v->rnd); v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd); } else { dxy = (my & 2) | ((mx & 2) >> 1); if (!v->rnd) dsp->avg_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16); else dsp->avg_no_rnd_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, 16); } if (s->flags & CODEC_FLAG_GRAY) return; uvmx = (uvmx & 3) << 1; uvmy = (uvmy & 3) << 1; if (!v->rnd) { h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy); h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy); } else { v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy); v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy); } }
1threat
"EF BB BF" at the beginning of JSON files created in Visual Studio : <p>I have a bunch of <code>JSON</code> files set as <code>Embedded resource</code> in one of my projects. I'm using <code>Newtonsoft.Json</code> to parse these files:</p> <pre><code>public static string ReadStringFromStream(string streamName) { using (System.IO.Stream stream = new EmbeddedResourceReader().GetType().Assembly.GetManifestResourceStream(streamName)) { byte[] result = new byte[stream.Length]; stream.Read(result, 0, (int)stream.Length); var str = Encoding.UTF8.GetString(result); return str; } } ... var traits = JsonConvert.DeserializeObject&lt;Genre[]&gt;(EmbeddedResourceReader.ReadStringFromStream("LNTCore.Genres.json")); Genres = traits; </code></pre> <p>This throws an exception in Newtonsoft.Json because it can't parse the beginning of the file. What's the best practice in this case? How should I be handling this sort of situations?</p> <p>Thanks!</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Add <option> to <select> inside a <script> : <script type="text/html" id="tmpl-wp-travel-itinerary-items"> <div class="panel-wrap panel-wrap-itinerary"> <label><?php esc_html_e( 'Etape', 'wp-travel' ); ?></label> <select id="selectjs"></select> </div> </script> getElementById() on *selectjs* is NULL. How can I target this ID within a script tag ?
0debug
static void simple_string(void) { int i; struct { const char *encoded; const char *decoded; } test_cases[] = { { "\"hello world\"", "hello world" }, { "\"the quick brown fox jumped over the fence\"", "the quick brown fox jumped over the fence" }, {} }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded, NULL); str = qobject_to_qstring(obj); g_assert(str); g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0); qobject_decref(obj); QDECREF(str); } }
1threat
import cmath def len_complex(a,b): cn=complex(a,b) length=abs(cn) return length
0debug
when i manually execute the garbage collector, how can I tell when it's completed? : <p>I'm writing a web server application using NodeJS 6.3.0. the application is executed with <code>--expose-gc</code> parameter, so I have the <code>global.gc()</code> function available. the question is how can I know when the manual execution of the garbage collector completed.</p> <p>is global.gc() a synchronous function and that means that the next line of code will be executed when the function completed it task?</p> <p>can I somehow monitor when my specific execution of garbage collector completed?</p> <p>thanks!</p>
0debug
How to use a Proxy Server with Alamofire 4 and Swift 3 : <p><em>Please don't mark as duplicate, I haven't been able to solve my Issue with the existing threads.</em></p> <p>I'm trying to use my Proxy for an API request that needs a specified IP. To debug my issue, I'm requesting the IP from a webservice.</p> <p>This is my current code:</p> <pre><code>import UIKit import Alamofire class ViewController: UIViewController { var requestManager = Alamofire.SessionManager.default override func viewDidLoad() { super.viewDidLoad() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) var proxyConfiguration = [NSObject: AnyObject]() proxyConfiguration[kCFNetworkProxiesHTTPProxy] = "http://xxx@eu-west-static-01.quotaguard.com" as AnyObject? proxyConfiguration[kCFNetworkProxiesHTTPPort] = "9293" as AnyObject? proxyConfiguration[kCFNetworkProxiesHTTPEnable] = 1 as AnyObject? let cfg = Alamofire.SessionManager.default.session.configuration cfg.connectionProxyDictionary = proxyConfiguration let ip = URL(string: "https://api.ipify.org?format=json") requestManager = Alamofire.SessionManager(configuration: cfg) requestManager.request(ip!).response { response in print("Request: \(response.request)") print("Response: \(response.response)") print("Error: \(response.error)") if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) { print("Data: \(utf8Text)") } } } } </code></pre> <p>The problem: the responsed IP is the same with or without the <code>proxyConfiguration</code>. Any help is very appreciated.</p> <p>PS: physical device used.</p>
0debug
Java hexadecimal base double literal : <p>I am studying for java certification. And i'm curious about the java literals. I know it is possible to do something like this:</p> <pre><code>int i = 0xAA; long l = 0xAAL; </code></pre> <p>Also this is possible for floating-point variables:</p> <pre><code>double d = 123d; float f = 123f; </code></pre> <p>So I logically thought with these examples that the same would apply for hexadecimal. Just like i can add L for long literals, I could add 'd' or 'f' but the logic is flawed since 'F' and 'D' are valid hexadecimal values.</p> <p>It is not possible to do something like this:</p> <pre><code>double d = 0xAAAAAAAAAAAAAAAAAAd; </code></pre> <p>Is this just not allowed by Java or there is a simple way to do it that I don't know?</p>
0debug
How to show increment of counter in my ui in flutter? : <p>I have declared a variable called ticketCounter that is getting stored in SharedPrefs. This variable is getting incremented and decremented as needed. However I wanted to display this counter on my appBar and want its value to update. Although the value is getting stored in the variable it isn't showing up. </p> <pre><code> int tickets; void fetchTickets() async { SharedPreferences prefs = await SharedPreferences.getInstance(); tickets = prefs.getInt('ticketRW') ?? 0; } void initState() { portraitModeOnly(); fetchTickets(); super.initState(); } Widget build(BuildContext context) { return Material( child: Scaffold( appBar: AppBar( actions: &lt;Widget&gt;[ Padding( padding: const EdgeInsets.only(top: 14, right: 14), child: Text( tickets.toString(),//isn't getting updated style: TextStyle( fontSize: 22, fontFamily: "Netflix", color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ), ), } </code></pre>
0debug
How can I tell when a function was called for the first time in JavaScript? : <p>I'm working on a memory game, and need to start a timer after clicking the first card. How do you do that?</p> <p>Thanks</p>
0debug
static int sap_read_header(AVFormatContext *s) { struct SAPState *sap = s->priv_data; char host[1024], path[1024], url[1024]; uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; int port; int ret, i; AVInputFormat* infmt; if (!ff_network_init()) return AVERROR(EIO); av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, path, sizeof(path), s->filename); if (port < 0) port = 9875; if (!host[0]) { av_strlcpy(host, "224.2.127.254", sizeof(host)); } ff_url_join(url, sizeof(url), "udp", NULL, host, port, "?localport=%d", port); ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_READ, &s->interrupt_callback, NULL); if (ret) goto fail; while (1) { int addr_type, auth_len; int pos; ret = ffurl_read(sap->ann_fd, recvbuf, sizeof(recvbuf) - 1); if (ret == AVERROR(EAGAIN)) continue; if (ret < 0) goto fail; recvbuf[ret] = '\0'; if (ret < 8) { av_log(s, AV_LOG_WARNING, "Received too short packet\n"); continue; } if ((recvbuf[0] & 0xe0) != 0x20) { av_log(s, AV_LOG_WARNING, "Unsupported SAP version packet " "received\n"); continue; } if (recvbuf[0] & 0x04) { av_log(s, AV_LOG_WARNING, "Received stream deletion " "announcement\n"); continue; } addr_type = recvbuf[0] & 0x10; auth_len = recvbuf[1]; sap->hash = AV_RB16(&recvbuf[2]); pos = 4; if (addr_type) pos += 16; else pos += 4; pos += auth_len * 4; if (pos + 4 >= ret) { av_log(s, AV_LOG_WARNING, "Received too short packet\n"); continue; } #define MIME "application/sdp" if (strcmp(&recvbuf[pos], MIME) == 0) { pos += strlen(MIME) + 1; } else if (strncmp(&recvbuf[pos], "v=0\r\n", 5) == 0) { } else { av_log(s, AV_LOG_WARNING, "Unsupported mime type %s\n", &recvbuf[pos]); continue; } sap->sdp = av_strdup(&recvbuf[pos]); break; } av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sap->sdp); ffio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL, NULL, NULL); infmt = av_find_input_format("sdp"); if (!infmt) goto fail; sap->sdp_ctx = avformat_alloc_context(); if (!sap->sdp_ctx) { ret = AVERROR(ENOMEM); goto fail; } sap->sdp_ctx->max_delay = s->max_delay; sap->sdp_ctx->pb = &sap->sdp_pb; sap->sdp_ctx->interrupt_callback = s->interrupt_callback; av_assert0(!sap->sdp_ctx->codec_whitelist && !sap->sdp_ctx->format_whitelist); sap->sdp_ctx-> codec_whitelist = av_strdup(s->codec_whitelist); sap->sdp_ctx->format_whitelist = av_strdup(s->format_whitelist); ret = avformat_open_input(&sap->sdp_ctx, "temp.sdp", infmt, NULL); if (ret < 0) goto fail; if (sap->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER) s->ctx_flags |= AVFMTCTX_NOHEADER; for (i = 0; i < sap->sdp_ctx->nb_streams; i++) { AVStream *st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } st->id = i; avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec); st->time_base = sap->sdp_ctx->streams[i]->time_base; } return 0; fail: sap_read_close(s); return ret; }
1threat
System.NullReferenceException: Object reference not set to an instance of an object.. : <p>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <blockquote> <p>System.NullReferenceException: Object reference not set to an instance of an object.</p> </blockquote> <pre><code> contentpath = Server.MapPath("Message/" + rnd.Next() + contentfile.FileName); contentfile.PostedFile.SaveAs(contentpath); message = TextBox1.Text; </code></pre>
0debug
void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) { long i; for(i=0; i<num_pixels; i++) ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ]; }
1threat
Vuetify conditional dark theme : <p>I'm using Vuetify to create my social media website. The problem that I'm facing now is that I want to use dark attribute, so user can switch between normal and dark theme. The thing is that I can't use any of Vue's conditional rendering methods, as dark is not an attribute that you can bind. Below is the part of code that you use to apply dark theme:</p> <pre><code>&lt;v-app dark&gt; </code></pre>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
static int libkvazaar_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { int retval = 0; kvz_picture *img_in = NULL; kvz_data_chunk *data_out = NULL; uint32_t len_out = 0; kvz_frame_info frame_info; LibkvazaarContext *ctx = avctx->priv_data; *got_packet_ptr = 0; if (frame) { int i = 0; av_assert0(frame->width == ctx->config->width); av_assert0(frame->height == ctx->config->height); av_assert0(frame->format == avctx->pix_fmt); img_in = ctx->api->picture_alloc(frame->width, frame->height); if (!img_in) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate picture.\n"); retval = AVERROR(ENOMEM); goto done; } for (i = 0; i < 3; ++i) { uint8_t *dst = img_in->data[i]; uint8_t *src = frame->data[i]; int width = (i == 0) ? frame->width : (frame->width / 2); int height = (i == 0) ? frame->height : (frame->height / 2); int y = 0; for (y = 0; y < height; ++y) { memcpy(dst, src, width); src += frame->linesize[i]; dst += width; } } } if (!ctx->api->encoder_encode(ctx->encoder, img_in, &data_out, &len_out, NULL, NULL, &frame_info)) { av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n"); retval = AVERROR_EXTERNAL; goto done; } if (data_out) { kvz_data_chunk *chunk = NULL; uint64_t written = 0; retval = ff_alloc_packet(avpkt, len_out); if (retval < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n"); goto done; } for (chunk = data_out; chunk != NULL; chunk = chunk->next) { av_assert0(written + chunk->len <= len_out); memcpy(avpkt->data + written, chunk->data, chunk->len); written += chunk->len; } *got_packet_ptr = 1; ctx->api->chunk_free(data_out); data_out = NULL; avpkt->flags = 0; if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP && frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) { avpkt->flags |= AV_PKT_FLAG_KEY; } } done: ctx->api->picture_free(img_in); ctx->api->chunk_free(data_out); return retval; }
1threat
static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt, unsigned flags) { uint8_t *buf = NULL; uint8_t *buffer; size_t offset; ssize_t ret; if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { buf = g_new(uint8_t, NET_BUFSIZE); buffer = buf; offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE); } if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { ret = nc->info->receive_raw(nc, buffer, offset); } else { ret = nc->info->receive(nc, buffer, offset); } g_free(buf); return ret; }
1threat
Groovy script to change the svn url in jenkin jobs : hi we have around 200 jobs where svn url has to be updated can someone help me with groovy script please provide me insight about different methods of jenkins
0debug
Remove white spaces from properties in list of the objects? : <p>I have this list of object:</p> <pre><code>public class Location { public string area { get; set; } public string sensorId { get; set; } public string address { get; set; } } List&lt;Location&gt; items = List&lt;Location&gt;(){ new Location(){area = "london ", address ="king road", sensorId ="2134"}, new Location(){area = "moscow", address ="george str", sensorId ="2134"}, new Location(){area = "york ", address ="johnson str ", sensorId ="2134"}, new Location(){area = " tokyo", address ="king road 5", sensorId ="2134"}, new Location(){area = "paris", address ="elitom road", sensorId ="2134"} } </code></pre> <p>how can I remove white spaces in area and address properties in items variable using linq?</p>
0debug
Python 3.4 set returning duplicates : I'm pulling a list of URL's off a census website than putting them in a set to make sure I don't end up with duplicates, then exporting that list of non-duplicate URL's into a .csv file. However, my set continues to return duplicate values, which shouldn't be possible. Here's my code: import bs4 from bs4 import BeautifulSoup import requests import csv source_link = "https://www.census.gov/data/tables/2016/demo/popest/state-total.html" s = requests.get(source_link) usable_html = s.text setupsoup = BeautifulSoup(usable_html, 'lxml') silver = csv.writer(open("WGUCSV.csv", "r+")) silver.writerow(["URL"]) for set(gold) in setupsoup.findAll('a', href=True): gold.add['href'] print (gold) silver.writerow(gold) As a bonus question, I also need a way to convert my resulting relative URL's into absolute URL's, preferably BEFORE sorting them into a non-duplicated list. I really thought adding them all to a set would filter out duplicates on it's own.
0debug
GraphQL readiness for .net development : <p>I found GraphQL as an enticing option to decouple front-end development from APIs (potentially a great fit for our company, which does lots of API customization for each customer). However, I can't quite work out if it's ready for a .NET development environment, or whether it's still considered an early technology? I also can't tell if it has bigger problems under the covers (e.g. N+1 issue). Any experience and guidance for GraphQL with a .NET implementation?</p>
0debug
Input string was not in a correct format when converting value from database into integer C# : I have a problem in converting string from database to integer. When I look at Locals, that variable show the value but notification still says that there is something wrong. Anyone can help me, please ? OleDbConnection kon = new OleDbConnection(koneksi); OleDbCommand command1 = kon.CreateCommand(); kon.Open(); string selectkoordgaris = "select * from koordinatgaris where namakamera = '" + PilihKameraComboBox.Text + "'"; command1.CommandText = selectkoordgaris; OleDbDataReader bacakoordgaris = command1.ExecuteReader(); while (bacakoordgaris.Read()) { var templateGaris = Directory.GetFiles(@"D:\Dokumen\Alfon\TA Alfon\CobaFitur\Template\Garis\" + bacakoord["namakamera"].ToString()); foreach (var fileGaris in templateGaris) { counterbanyakgaris++; Image<Bgr, byte> garis = new Image<Bgr, byte>(fileGaris); for (cntgaris = 0; cntgaris < banyakgaris; cntgaris++) { int x1garis = int.Parse(bacakoordgaris["x" + ((cntgaris * 4) + 1) + "garis"].ToString()); //here the error. It says Input string was not in a correct format int x2garis = int.Parse(bacakoordgaris["x" + ((cntgaris * 4) + 2) + "garis"].ToString()); int y1garis = int.Parse(bacakoordgaris["y" + ((cntgaris * 4) + 1) + "garis"].ToString()); int y2garis = int.Parse(bacakoordgaris["y" + ((cntgaris * 4) + 2) + "garis"].ToString()); int y3garis = int.Parse(bacakoordgaris["y" + ((cntgaris * 4) + 3) + "garis"].ToString()); int gariswidth = x2garis - x1garis; int garisheight = y3garis - y2garis; } } }
0debug
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; uint64_t size; uint8_t *buf; int err; if (c->fc->nb_streams < 1) return 0; st= c->fc->streams[c->fc->nb_streams-1]; size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; if (size > INT_MAX || (uint64_t)atom.size > INT_MAX) return AVERROR_INVALIDDATA; if ((err = av_reallocp(&st->codec->extradata, size)) < 0) { st->codec->extradata_size = 0; return err; } buf = st->codec->extradata + st->codec->extradata_size; st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE; AV_WB32( buf , atom.size + 8); AV_WL32( buf + 4, atom.type); avio_read(pb, buf + 8, atom.size); return 0; }
1threat
How to access nested array which is in json response : { "token": "*********", "roles": [ { "id": 4, "name": "User", "pivot": { "user_id": 1, "role_id": 4 } } ] } I'm able to get the token from this json response by `const token = response.json().token;` I want to access roles->name from this and return in a
0debug
static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) { OutputStream *ost; AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; char *bsf = NULL, *next, *codec_tag = NULL; AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; double qscale = -1; char *buf = NULL, *arg = NULL, *preset = NULL; AVIOContext *s = NULL; if (!st) { av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); exit(1); } if (oc->nb_streams - 1 < o->nb_streamid_map) st->id = o->streamid_map[oc->nb_streams - 1]; output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams, nb_output_streams + 1); if (!(ost = av_mallocz(sizeof(*ost)))) exit(1); output_streams[nb_output_streams - 1] = ost; ost->file_index = nb_output_files; ost->index = idx; ost->st = st; st->codec->codec_type = type; choose_encoder(o, oc, ost); if (ost->enc) { ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st, ost->enc); } avcodec_get_context_defaults3(st->codec, ost->enc); st->codec->codec_type = type; MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { do { buf = get_line(s); if (!buf[0] || buf[0] == '#') { av_free(buf); continue; } if (!(arg = strchr(buf, '='))) { av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n"); exit(1); } *arg++ = 0; av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE); av_free(buf); } while (!s->eof_reached); avio_close(s); } if (ret) { av_log(NULL, AV_LOG_FATAL, "Preset %s specified for stream %d:%d, but could not be opened.\n", preset, ost->file_index, ost->index); exit(1); } ost->max_frames = INT64_MAX; MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st); while (bsf) { if (next = strchr(bsf, ',')) *next++ = 0; if (!(bsfc = av_bitstream_filter_init(bsf))) { av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf); exit(1); } if (bsfc_prev) bsfc_prev->next = bsfc; else ost->bitstream_filters = bsfc; bsfc_prev = bsfc; bsf = next; } MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); if (*next) tag = AV_RL32(codec_tag); st->codec->codec_tag = tag; } MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st); if (qscale >= 0) { st->codec->flags |= CODEC_FLAG_QSCALE; st->codec->global_quality = FF_QP2LAMBDA * qscale; } if (oc->oformat->flags & AVFMT_GLOBALHEADER) st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags); ost->pix_fmts[0] = ost->pix_fmts[1] = AV_PIX_FMT_NONE; return ost; }
1threat
void helper_xssubqp(CPUPPCState *env, uint32_t opcode) { ppc_vsr_t xt, xa, xb; float_status tstat; getVSR(rA(opcode) + 32, &xa, env); getVSR(rB(opcode) + 32, &xb, env); getVSR(rD(opcode) + 32, &xt, env); helper_reset_fpstatus(env); if (unlikely(Rc(opcode) != 0)) { abort(); } tstat = env->fp_status; set_float_exception_flags(0, &tstat); xt.f128 = float128_sub(xa.f128, xb.f128, &tstat); env->fp_status.float_exception_flags |= tstat.float_exception_flags; if (unlikely(tstat.float_exception_flags & float_flag_invalid)) { if (float128_is_infinity(xa.f128) && float128_is_infinity(xb.f128)) { float_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, 1); } else if (float128_is_signaling_nan(xa.f128, &tstat) || float128_is_signaling_nan(xb.f128, &tstat)) { float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); } } helper_compute_fprf_float128(env, xt.f128); putVSR(rD(opcode) + 32, &xt, env); float_check_status(env); }
1threat
How to use Notification service extension with UNNotification in iOS10 : <p>Apple introduce new extension names <a href="https://developer.apple.com/reference/usernotifications/unnotificationserviceextension" rel="noreferrer">"UNNotificationServiceExtension"</a>, but how to launch it from push notification ?</p> <p>I read that service extension provide end to end encryption for payload.</p> <p>Which key is required to set payload of push notification ?</p> <p>How to identify payload and how to launch service extension from push notification ?</p>
0debug
how to extract rows from excel file : <p>I have <a href="https://docs.google.com/spreadsheets/d/1S36yTdDyvfYyRuAbzi2v1YMmhSf030Gk_vdz1u6ohKM/edit?usp=sharing" rel="nofollow noreferrer">an excel file</a>. How can I extract data so that in python it looks like:</p> <pre><code>list = [['Igor', '20', 'SSU]'], ['Sergay', '19', 'SSTU'], ['Nadya', '21', 'SSAU']] </code></pre> <p>using <strong>import xlrd</strong> </p>
0debug
void mips_malta_init (ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { char *filename; pflash_t *fl; MemoryRegion *system_memory = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios, *bios_alias = g_new(MemoryRegion, 1); target_long bios_size; int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; CPUState *env; qemu_irq *isa_irq; qemu_irq *cpu_exit_irq; int piix4_devfn; i2c_bus *smbus; int i; DriveInfo *dinfo; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; int fl_idx = 0; int fl_sectors = 0; int be; DeviceState *dev = qdev_create(NULL, "mips-malta"); MaltaState *s = DO_UPCAST(MaltaState, busdev.qdev, dev); qdev_init_nofail(dev); for(i = 0; i < 3; i++) { if (!serial_hds[i]) { char label[32]; snprintf(label, sizeof(label), "serial%d", i); serial_hds[i] = qemu_chr_new(label, "null", NULL); } } if (cpu_model == NULL) { #ifdef TARGET_MIPS64 cpu_model = "20Kc"; #else cpu_model = "24Kf"; #endif } for (i = 0; i < smp_cpus; i++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); qemu_register_reset(main_cpu_reset, env); } env = first_cpu; if (ram_size > (256 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_init_ram(ram, "mips_malta.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(system_memory, 0, ram); #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif malta_fpga_init(system_memory, 0x1f000000LL, env->irq[2], serial_hds[2]); if (kernel_filename) { bios = g_new(MemoryRegion, 1); memory_region_init_ram(bios, "mips_malta.bios", BIOS_SIZE); vmstate_register_ram_global(bios); memory_region_set_readonly(bios, true); memory_region_init_alias(bios_alias, "bios.1fc", bios, 0, BIOS_SIZE); memory_region_add_subregion(system_memory, 0x1e000000LL, bios); memory_region_add_subregion(system_memory, 0x1fc00000LL, bios_alias); loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; kernel_entry = load_kernel(); write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry); } else { dinfo = drive_get(IF_PFLASH, 0, fl_idx); if (dinfo) { bios_size = 0x400000; fl_sectors = bios_size >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx " at " "addr %08llx '%s' %x\n", fl_idx, bios_size, 0x1e000000LL, bdrv_get_device_name(dinfo->bdrv), fl_sectors); #endif fl = pflash_cfi01_register(0x1e000000LL, NULL, "mips_malta.bios", BIOS_SIZE, dinfo->bdrv, 65536, fl_sectors, 4, 0x0000, 0x0000, 0x0000, 0x0000, be); bios = pflash_cfi01_get_memory(fl); memory_region_init_alias(bios_alias, "bios.1fc", bios, 0, BIOS_SIZE); memory_region_add_subregion(system_memory, 0x1fc00000LL, bios_alias); fl_idx++; } else { bios = g_new(MemoryRegion, 1); memory_region_init_ram(bios, "mips_malta.bios", BIOS_SIZE); vmstate_register_ram_global(bios); memory_region_set_readonly(bios, true); memory_region_init_alias(bios_alias, "bios.1fc", bios, 0, BIOS_SIZE); memory_region_add_subregion(system_memory, 0x1e000000LL, bios); memory_region_add_subregion(system_memory, 0x1fc00000LL, bios_alias); if (bios_name == NULL) bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE); g_free(filename); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) { fprintf(stderr, "qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n", bios_name); exit(1); } } #ifndef TARGET_WORDS_BIGENDIAN { uint32_t *addr = memory_region_get_ram_ptr(bios); uint32_t *end = addr + bios_size; while (addr < end) { bswap32s(addr); addr++; } } #endif } stl_p(memory_region_get_ram_ptr(bios) + 0x10, 0x00000420); cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); isa_irq = qemu_irq_proxy(&s->i8259, 16); pci_bus = gt64120_register(isa_irq); ide_drive_get(hd, MAX_IDE_BUS); piix4_devfn = piix4_init(pci_bus, &isa_bus, 80); s->i8259 = i8259_init(isa_bus, env->irq[2]); isa_bus_irqs(isa_bus, s->i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); usb_uhci_piix4_init(pci_bus, piix4_devfn + 2); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(NULL, 9), NULL, NULL, 0); smbus_eeprom_init(smbus, 8, NULL, 0); pit = pit_init(isa_bus, 0x40, 0); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); isa_create_simple(isa_bus, "i8042"); rtc_init(isa_bus, 2000, NULL); serial_isa_init(isa_bus, 0, serial_hds[0]); serial_isa_init(isa_bus, 1, serial_hds[1]); if (parallel_hds[0]) parallel_init(isa_bus, 0, parallel_hds[0]); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(isa_bus, fd); audio_init(isa_bus, pci_bus); network_init(); if (cirrus_vga_enabled) { pci_cirrus_vga_init(pci_bus); } else if (vmsvga_enabled) { if (!pci_vmsvga_init(pci_bus)) { fprintf(stderr, "Warning: vmware_vga not available," " using standard VGA instead\n"); pci_vga_init(pci_bus); } } else if (std_vga_enabled) { pci_vga_init(pci_bus); } }
1threat
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *pkt) { SANMVideoContext *ctx = avctx->priv_data; int i, ret; bytestream2_init(&ctx->gb, pkt->data, pkt->size); if (ctx->output->data[0]) avctx->release_buffer(avctx, ctx->output); if (!ctx->version) { int to_store = 0; while (bytestream2_get_bytes_left(&ctx->gb) >= 8) { uint32_t sig, size; int pos; sig = bytestream2_get_be32u(&ctx->gb); size = bytestream2_get_be32u(&ctx->gb); pos = bytestream2_tell(&ctx->gb); if (bytestream2_get_bytes_left(&ctx->gb) < size) { av_log(avctx, AV_LOG_ERROR, "incorrect chunk size %d\n", size); break; } switch (sig) { case MKBETAG('N', 'P', 'A', 'L'): if (size != 256 * 3) { av_log(avctx, AV_LOG_ERROR, "incorrect palette block size %d\n", size); return AVERROR_INVALIDDATA; } for (i = 0; i < 256; i++) ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb); break; case MKBETAG('F', 'O', 'B', 'J'): if (size < 16) return AVERROR_INVALIDDATA; if (ret = process_frame_obj(ctx)) return ret; break; case MKBETAG('X', 'P', 'A', 'L'): if (size == 6 || size == 4) { uint8_t tmp[3]; int j; for (i = 0; i < 256; i++) { for (j = 0; j < 3; j++) { int t = (ctx->pal[i] >> (16 - j * 8)) & 0xFF; tmp[j] = av_clip_uint8((t * 129 + ctx->delta_pal[i * 3 + j]) >> 7); } ctx->pal[i] = 0xFF << 24 | AV_RB24(tmp); } } else { if (size < 768 * 2 + 4) { av_log(avctx, AV_LOG_ERROR, "incorrect palette change block size %d\n", size); return AVERROR_INVALIDDATA; } bytestream2_skipu(&ctx->gb, 4); for (i = 0; i < 768; i++) ctx->delta_pal[i] = bytestream2_get_le16u(&ctx->gb); if (size >= 768 * 5 + 4) { for (i = 0; i < 256; i++) ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb); } else { memset(ctx->pal, 0, sizeof(ctx->pal)); } } break; case MKBETAG('S', 'T', 'O', 'R'): to_store = 1; break; case MKBETAG('F', 'T', 'C', 'H'): memcpy(ctx->frm0, ctx->stored_frame, ctx->buf_size); break; default: bytestream2_skip(&ctx->gb, size); av_log(avctx, AV_LOG_DEBUG, "unknown/unsupported chunk %x\n", sig); break; } bytestream2_seek(&ctx->gb, pos + size, SEEK_SET); if (size & 1) bytestream2_skip(&ctx->gb, 1); } if (to_store) memcpy(ctx->stored_frame, ctx->frm0, ctx->buf_size); if ((ret = copy_output(ctx, NULL))) return ret; memcpy(ctx->output->data[1], ctx->pal, 1024); } else { SANMFrameHeader header; if ((ret = read_frame_header(ctx, &header))) return ret; ctx->rotate_code = header.rotate_code; if ((ctx->output->key_frame = !header.seq_num)) { ctx->output->pict_type = AV_PICTURE_TYPE_I; fill_frame(ctx->frm1, ctx->npixels, header.bg_color); fill_frame(ctx->frm2, ctx->npixels, header.bg_color); } else { ctx->output->pict_type = AV_PICTURE_TYPE_P; } if (header.codec < FF_ARRAY_ELEMS(v1_decoders)) { if ((ret = v1_decoders[header.codec](ctx))) { av_log(avctx, AV_LOG_ERROR, "subcodec %d: error decoding frame\n", header.codec); return ret; } } else { av_log_ask_for_sample(avctx, "subcodec %d is not implemented\n", header.codec); return AVERROR_PATCHWELCOME; } if ((ret = copy_output(ctx, &header))) return ret; } if (ctx->rotate_code) rotate_bufs(ctx, ctx->rotate_code); *got_frame_ptr = 1; *(AVFrame*)data = *ctx->output; return pkt->size; }
1threat
Convert react JSX object to HTML : <p>I have a react application that generates HTML output based on some configuration. Like this:</p> <pre><code>export const getHtml = (config) =&gt; { const {classes, children} = config return (&lt;div className={classes.join(' ')}&gt;{children}&lt;/div&gt;); } </code></pre> <p>Inside the react app I can easily display the resulting DOM objects, but I want to save the HTML code to DB, to display it on a different page (without loading react/parsing the config again)</p> <p>I could not find a way to convert the JSX object to plain HTML...</p>
0debug
How can I ignore certain returned values from array destructuring? : <p>Can I avoid declaring a useless variable when array destructuring when I am only interested in array values beyond index 0?</p> <p>In the following, I want to avoid declaring <code>a</code>, I am only interested in index 1 and beyond.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>// How can I avoid declaring "a"? const [a, b, ...rest] = [1, 2, 3, 4, 5]; console.log(a, b, rest);</code></pre> </div> </div> </p>
0debug
write data from address field to mysql : I am trying to write data to mysql from address field. In the address field I write address [http://ortex.lt/esp.php?id=1&t=12&h=45][1] My esp.php file have this code: if ($id == '1') { $total = mysql_result(mysql_query("SELECT count(*) FROM `esp1`"),0); mysql_query("INSERT INTO `esp1` (temp,hum) values ('".$temp."','".$hum."') "); } I get mistake Fatal error: Uncaught Error: Call to undefined function mysql_result() in /home/orexlt/domains/ortex.lt/public_html/esp.php:13 Stack trace: #0 {main} thrown in /home/orexlt/domains/ortex.lt/public_html/esp.php on line 13 where are could be mistake? [1]: http://ortex.lt/esp.php?id=1&t=12&h=45
0debug
from operator import itemgetter def index_on_inner_list(list_data, index_no): result = sorted(list_data, key=itemgetter(index_no)) return result
0debug
static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn, PCIConfigReadFunc *config_read, PCIConfigWriteFunc *config_write) { if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) { if (!bus->devices[devfn]) goto found; } return NULL; found: ; } else if (bus->devices[devfn]) { return NULL; } pci_dev->bus = bus; pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state)); pci_config_alloc(pci_dev); pci_set_default_subsystem_id(pci_dev); pci_init_cmask(pci_dev); pci_init_wmask(pci_dev); if (!config_read) config_read = pci_default_read_config; if (!config_write) config_write = pci_default_write_config; pci_dev->config_read = config_read; pci_dev->config_write = config_write; bus->devices[devfn] = pci_dev; pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS); pci_dev->version_id = 2; return pci_dev; }
1threat
hello i want to open a file (pdf,docx) in the browser with nodejs ,can any one help me out please . for example with php i'can do it like bellow a : $doc = Document::findOrFail($id); $path = Storage::disk('local')->getDriver()->getAdapter()->applyPathPrefix($doc->file); $type = $doc->mimetype; Log::addToLog('Document ID '.$id.' à été consulté'); if ($type == 'application/pdf' || $type == 'image/jpeg' || $type == 'image/png' || $type == 'image/jpg' || $type == 'image/gif') { return response()->file($path, ['Content-Type' => $type]); } elseif ($type == 'video/mp4' || $type == 'audio/mpeg' || $type == 'audio/mp3' || $type == 'audio/x-m4a') { return view('documents.play',compact('doc')); } else { return response()->file($path, ['Content-Type' => $type]); } }
0debug
int qemu_cpu_self(void *_env) { CPUState *env = _env; QemuThread this; qemu_thread_self(&this); return qemu_thread_equal(&this, env->thread); }
1threat
PHP json_encode() and Javascipt JSON.parse() : I need to get data from server in JSON. The data set is very huge and has multi-level nesting. I use arrays. And some keys inside array are JSON strings (i need to store these strings inside database, in order to create JS objects from those strings later). Array( 'key1'=> 'value1', 'key2'=> 'string in JSON format', // json_encode('key2_value that may contain russian symbols', JSON_UNESCAPED_UNICODE) 'key3'=> array( 'key1'=> array( key1=> 'string in JSON format' ) ) ) The nesting of elements may be arbitrary and any element may contain string in JSON format. I encode this huge array in JSON, using php json_encode($data, JSON_UNESCAPED_UNICODE) function. I use second param because data may contain russian symbols (i need to search some of those strings later). After that i receive data... 1 step: Decode all array with JSON strings using JS JSON.parse() function. 2 step: Save some JSON strings in database columns and after create JS objects using JSON.parse(). But some strings may contain disallowed JSON characters, in particular '\r'. And when i try to parse this string using JSON parse, i can get JSON.parse error for now in second step. But in theory it may occur also in first step. But PHP json_decode works Good! JS JSON.parse works Bad! Does anyone have any idea and suggestions? (Please don't forget, when i use json_encode in main array, nested json strings that may contain russian symbols also escaped - slashes, "" i.e).
0debug
Vector print duplicate Values : <p>I've written a program in C++ to print out a vector of pointers to my classes <code>Vehicle</code> is a parent class for <code>Car</code>. All the functions work properly yet the program itself prints wrong values, changing them after all iterations of the loop. Here's the code:</p> <pre><code>int main() { std::vector&lt;Vehicle *&gt; vehs; for (int i = 0; i &lt; 3; i++) { std::string Id; std::cout &lt;&lt; "Id: " &lt;&lt; std::endl; getline(std::cin, Id); std::string Marka; std::cout &lt;&lt; "Marka: " &lt;&lt; std::endl; getline(std::cin, Marka); double Par; std::cout &lt;&lt; "Parametr: " &lt;&lt; std::endl; std::cin &gt;&gt; Par; getchar(); Car car(Id, Marka, Par); vehs.push_back(&amp;car); std::cout &lt;&lt; to_string(vehs.cbegin(), vehs.cend()); } </code></pre> <p>And the result is as follows:</p> <pre><code>Id: A Marka: A Parametr: 1 A : A Id: B Marka: B Parametr: 2 B : B B : B Id: C Marka: C Parametr: 3 C : C C : C C : C </code></pre> <p>As you can see, the contents of <code>vehs</code> change even, if I do not want them to.</p> <p>The <code>to_string</code> looks like that:</p> <pre><code>std::string to_string (const Vehicle&amp; vehicle){ std::ostringstream oss; oss &lt;&lt; vehicle.getId() &lt;&lt; " : "&lt;&lt; vehicle.getBrand(); return oss.str(); } std::string to_string(std::vector&lt;Vehicle*&gt;::const_iterator vehicles_begin, std::vector&lt;Vehicle*&gt;::const_iterator vehicles_end){ std::ostringstream oss; for(auto it = vehicles_begin; it!= vehicles_end; it++ ){ oss &lt;&lt; to_string(**it) &lt;&lt; std::endl; } return oss.str(); } </code></pre>
0debug
static unsigned int dec_lz_r(DisasContext *dc) { TCGv t0; DIS(fprintf (logfile, "lz $r%u, $r%u\n", dc->op1, dc->op2)); cris_cc_mask(dc, CC_MASK_NZ); t0 = tcg_temp_new(TCG_TYPE_TL); dec_prep_alu_r(dc, dc->op1, dc->op2, 4, 0, cpu_R[dc->op2], t0); cris_alu(dc, CC_OP_LZ, cpu_R[dc->op2], cpu_R[dc->op2], t0, 4); tcg_temp_free(t0); return 2; }
1threat
Terraform: How to migrate state between projects? : <p>What is the least painful way to migrate state of resources from one project (i.e., move a module invocation) to another, particularly when using remote state storage? While refactoring is relatively straightforward within the same state file (i.e., take this resource and move it to a submodule or vice-versa), I don't see an alternative to JSON surgery for refactoring into different state files, particularly if we use remote (S3) state (i.e., take this submodule and move it to another project).</p>
0debug
i don`t know what is wrong with my code : #!/bin/sh read -p "Input a file or directory what you want " x for FILENAME in `ls` do if [ -e $FILENAME ] then echo "File exist" #if file exist, you should show me that is it a directory # or symboliclink ...for so on like that elif [ -d $FILENAME ] then echo " It is a directory" elif [ -L $FILENAME ] then echo " It is a symbolic link" elif [ -c $FILENAME ] then echo " It is a character tool file" elif [ -b $FILENAME ] then echo " It is a block tool" elif [ -p $FILENAME ] then echo " It is a pipe " elif [ -S $FILENAME ] then echo " It is a socket" elif [ -f $FILENAME ] then echo " It is a ordinary file" else echo " file isn`t exist" fi done //error message is ./fn: line 43: unexpected EOF while looking for matching ``' ./fn: line 48: syntax error: unexpected end of file
0debug
Cant Import Tenser flow python. : I cant import Tenserflow my gpu nvidia 940mx python 3.6 and installed oacages are . absl-py (0.2.0) astor (0.6.2) bleach (1.5.0) cycler (0.10.0) gast (0.2.0) grpcio (1.11.0) html5lib (0.9999999) kiwisolver (1.0.1) Markdown (2.6.11) matplotlib (2.2.2) numpy (1.14.2) opencv-python (3.4.0.12) pip (9.0.3) protobuf (3.5.2.post1) pyparsing (2.2.0) python-dateutil (2.7.2) pytz (2018.4) setuptools (39.0.1) six (1.11.0) tensorboard (1.7.0) tensorflow-gpu (1.7.0) termcolor (1.1.0) Werkzeug (0.14.1) wheel (0.31.0) **Error is ** import tensorflow as tf Traceback (most recent call last): File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in preload_check ctypes.WinDLL(build_info.cudart_dll_name) File "C:\Program Files\Python36\lib\ctypes\__init__.py", line 348, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 126] The specified module could not be found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module> from tensorflow.python import * # pylint: disable=redefined-builtin File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module> self_check.preload_check() File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\platform\self_check.py", line 82, in preload_check % (build_info.cudart_dll_name, build_info.cuda_version_number)) ImportError: Could not find 'cudart64_90.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit`enter code here`
0debug
setting display doesn't work : I am working with a captcha. Upon success I want to set the display of the div that includes the captcha to "none". In that success part I have: document.getElementById("mainForm").style.display="block"; document.getElementById("captcha").style.display="none"; alert("the captcha display is " + document.getElementById("captcha").style.display); The resulting alert says that it is block (how the div was defined above this code), even though I have just set it to none. Any idea why? (The alert was just for debugging purposes).
0debug
static void IRQ_local_pipe(OpenPICState *opp, int n_CPU, int n_IRQ) { IRQDest *dst; IRQSource *src; int priority; dst = &opp->dst[n_CPU]; src = &opp->src[n_IRQ]; if (src->output != OPENPIC_OUTPUT_INT) { src->ivpr |= IVPR_ACTIVITY_MASK; DPRINTF("%s: Raise OpenPIC output %d cpu %d irq %d\n", __func__, src->output, n_CPU, n_IRQ); qemu_irq_raise(opp->dst[n_CPU].irqs[src->output]); return; } priority = IVPR_PRIORITY(src->ivpr); if (priority <= dst->ctpr) { DPRINTF("%s: IRQ %d has too low priority on CPU %d\n", __func__, n_IRQ, n_CPU); return; } if (IRQ_testbit(&dst->raised, n_IRQ)) { DPRINTF("%s: IRQ %d was missed on CPU %d\n", __func__, n_IRQ, n_CPU); return; } src->ivpr |= IVPR_ACTIVITY_MASK; IRQ_setbit(&dst->raised, n_IRQ); if (priority < dst->raised.priority) { DPRINTF("%s: IRQ %d is hidden by raised IRQ %d on CPU %d\n", __func__, n_IRQ, dst->raised.next, n_CPU); return; } IRQ_check(opp, &dst->raised); if (IRQ_get_next(opp, &dst->servicing) != -1 && priority <= dst->servicing.priority) { DPRINTF("%s: IRQ %d is hidden by servicing IRQ %d on CPU %d\n", __func__, n_IRQ, dst->servicing.next, n_CPU); return; } DPRINTF("Raise OpenPIC INT output cpu %d irq %d\n", n_CPU, n_IRQ); qemu_irq_raise(opp->dst[n_CPU].irqs[OPENPIC_OUTPUT_INT]); }
1threat
How can I get already installed app bundle ID from my iPad. The app is not in App store yet. : My App certificate is expired and I didn't have access to this certificate any more. I need to know bundle id of my app to create new version with that bundle id and new certificate to save local db from old app. The app doesn't lunching anymore and I have very important data in this app db and I want to save it. I have created many versions of this app and every time i changed bundle id and I didn't know which one is it. I have tried iExplorer application, but it shows all apps bundle id except that app. Also I have crashlytics in that app, but it doesn't show crash. If there is no way to know bundle id :(, may be there is the way to know the installation date of this app?
0debug
MediaCodec getInputImage return null on Some Devices : <p>I want to encode using MediaCodec by setting color format to <code>COLOR_FormatYUV420Flexible</code>. My Input buffer's is yuv420p.When I input buffer like this :</p> <pre><code> int inputBufferIndex = mEncoder.dequeueInputBuffer(-1); mCurrentBufferIndex = inputBufferIndex; if (inputBufferIndex &gt;= 0) { ByteBuffer inputBuffer = inputBuffers[inputBufferIndex]; //if(VERBOSE) Log.i(TAG,"pos:"+inputBuffer.position()+"\tlimit:"+inputBuffer.limit()); inputBuffer.clear(); return inputBuffer; } </code></pre> <p>But some devices get wrong color. So I try this :</p> <pre><code> int inputBufferIndex = mEncoder.dequeueInputBuffer(-1); mCurrentBufferIndex = inputBufferIndex; if (inputBufferIndex &gt;= 0) { Image img = mEncoder.getInputImage(inputBufferIndex); if(img==null) return null; //mCurrentInputPlanes = img.getPlanes(); ByteBuffer buffers[]={img.getPlanes()[0].getBuffer(), img.getPlanes()[1].getBuffer(), img.getPlanes()[2].getBuffer()}; </code></pre> <p>I fill the buffer to YUV channels .It work on some devices. But moto X pro and huawei P7 get null when calling getInputImage. The documentation say the image doesn't contains raw data. But it also mentions <code>COLOR_FormatYUV420Flexible</code> is supported since API 21.So how should I fix this.</p>
0debug
Switch for specific type in TypeScript : <p>I have an interface <code>Action</code>:</p> <pre><code>interface Action {} </code></pre> <p>And an implementation of this <code>Action</code> <code>SpecificAction</code>:</p> <pre><code>class SpecificAction implements Action { payload?: Any } </code></pre> <p>Is it possible in TS to construct a switch operator, like this:</p> <pre><code>let action: Action switch (action) { case SpecificAction: //it works console.log(action.payload) // it doesn't } </code></pre> <p>Is it possible in that case to know, that action is already of <code>SpecificAction</code> type?</p>
0debug
Should I use rel="canonical" on my homepage for non www to www? : <p>I'm really confused about using the <code>rel="canonical"</code> on my homepage since my website is using www and non www. Should I be using</p> <p><code>&lt;link rel="canonical" href="https://www.example.com/" /&gt;</code></p> <p>on my homepage since i prefer www, for when someone accesses my domain using a non-www?</p>
0debug
Java if statement not working on a condition of a service : <p>I have created an app in android studio and it uses a background service which has a method which starts a counter of seconds. I have created an if statement to test if the seconds are at 0 and when i debug the value seems to be correct but the condition is jumping straight to the else statement and i can not figure out why. </p> <pre><code> public void checkService(){ long secs = seconds; String str = String.valueOf(secs); if(str == "0") { Toast.makeText(this, "Not started", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this, "Running", Toast.LENGTH_SHORT).show(); } } </code></pre> <p>It is jumping to the second esle even when the value is 0. The image shows the value of str when i was debugging. </p> <p><a href="https://i.stack.imgur.com/wSCIq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wSCIq.jpg" alt="enter image description here"></a></p>
0debug
FILE I/O: two file pointes : <p>I'm new to FILE I/O Stream and I want to write a program, which converts chars (read from "texti.txt") like "ä,Ä,ü,Ü,ö,Ö" to "ae,Ae,ue,Ue,oe,Oe" and write them in a new file called "texto.txt".</p> <p><strong>First Question:</strong> Is it ok to have two file pointers (on to each file) at the same time like i do?</p> <p><strong>Second Question:</strong> What am I doing wrong with character compare in the switch statement? VS2015 is warning that cases 2 and 3 already exist (reference to case 1)</p> <p><strong>Thirt Question</strong> Does <code>fpo</code> (file pointer to output-file) increment itself automatically by writig a char?</p> <p><strong>Question four:</strong> VS2015 is warning: </p> <p>C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.</p> <p>Is there another function I should use?</p> <pre><code>int main() { char c; FILE *fpi; FILE *fpo; fpi = fopen("texti.txt","r"); fpo = fopen("texto.txt", "w"); if (fpi == NULL) fprintf(stderr, "Fehler beim Lesen"); while (!feof(fpi)) { c = fgetc(fpi); switch (c) { case 'ä'||'Ä': fputc('a', fpo); fputc('e', fpo); break; case 'ö'||'Ö': fputc('o', fpo); fputc('e', fpo); break; case 'ü' || 'Ü': fputc('u', fpo); fputc('e', fpo); break; default: fputc((c), fpo); } fpi++; } fclose(fpi); fclose(fpo); </code></pre> <p>}</p>
0debug
Does it hurt performance/memory when swapping elements in a string array in C# : Let's say I have a string array which looks as below: ` string[] inputs = { "abc", "abb", "aba" // .... }; ` Does it hurt performance/memory if I swap two elements in this array as below: ` string tmp = inputs[i]; inputs[i] = inputs[j]; inputs[j] = tmp; ` Thanks in advance!
0debug
void HELPER(wer)(CPUXtensaState *env, uint32_t data, uint32_t addr) { address_space_stl(env->address_space_er, addr, data, (MemTxAttrs){0}, NULL); }
1threat
qemu_irq *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq, const char *kernel_filename, const char *cpu_model) { ARMCPU *cpu; CPUARMState *env; DeviceState *nvic; qemu_irq *pic = g_new(qemu_irq, num_irq); int image_size; uint64_t entry; uint64_t lowaddr; int i; int big_endian; MemoryRegion *hack = g_new(MemoryRegion, 1); if (cpu_model == NULL) { cpu_model = "cortex-m3"; } cpu = cpu_arm_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; armv7m_bitband_init(); nvic = qdev_create(NULL, "armv7m_nvic"); qdev_prop_set_uint32(nvic, "num-irq", num_irq); env->nvic = nvic; qdev_init_nofail(nvic); sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0, qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ)); for (i = 0; i < num_irq; i++) { pic[i] = qdev_get_gpio_in(nvic, i); } #ifdef TARGET_WORDS_BIGENDIAN big_endian = 1; #else big_endian = 0; #endif if (!kernel_filename && !qtest_enabled()) { fprintf(stderr, "Guest image must be specified (using -kernel)\n"); exit(1); } if (kernel_filename) { image_size = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr, NULL, big_endian, ELF_MACHINE, 1); if (image_size < 0) { image_size = load_image_targphys(kernel_filename, 0, mem_size); lowaddr = 0; } if (image_size < 0) { error_report("Could not load kernel '%s'", kernel_filename); exit(1); } } memory_region_init_ram(hack, NULL, "armv7m.hack", 0x1000, &error_abort); vmstate_register_ram_global(hack); memory_region_add_subregion(system_memory, 0xfffff000, hack); qemu_register_reset(armv7m_reset, cpu); return pic; }
1threat
How do I set prompt value using querySelector I want to set input value of max : **How do I set prompt value using querySelector** **I want to set input value of max** > **var max = prompt(""); // prompt value** > **> var selector = '#list > listitem > label[value=here i want prompt > value]';** var max = prompt(""); var selector = '#list > listitem > label[value=max]'; var node = document.querySelector(selector);
0debug
Allow implicit any only for definition files : <p>I am using TypeScript with the <code>"noImplicitAny": true</code> option set in my <code>tsconfig.json</code>.</p> <p>I am using <a href="https://www.npmjs.com/package/typings"><code>typings</code></a> to manage type definition files and am including them using a reference path directive in the entry point of my app:</p> <pre><code>/// &lt;reference path="./typings/index.d.ts" /&gt; </code></pre> <p>The problem is that some of the definition files rely on implicit any, so now I get a lot of compile errors from <code>.d.ts</code> files.</p> <p>Is there a way to disable/silence these errors, for example based on the path or the file type?</p>
0debug
binomial distribution with matlab : how can I calculate the binomial distribution with matlab through two parameters p and n?[![with this expression][1]][1] [1]: http://i.stack.imgur.com/HkibV.png
0debug
static void pci_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { AcpiPciHpState *s = opaque; switch (addr) { case PCI_EJ_BASE: if (s->hotplug_select >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { break; } acpi_pcihp_eject_slot(s, s->hotplug_select, data); ACPI_PCIHP_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, data); break; case PCI_SEL_BASE: s->hotplug_select = data; ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, data); default: break; } }
1threat
static int vaapi_encode_issue(AVCodecContext *avctx, VAAPIEncodePicture *pic) { VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodeSlice *slice; VAStatus vas; int err, i; char data[MAX_PARAM_BUFFER_SIZE]; size_t bit_len; av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" " "as type %s.\n", pic->display_order, pic->encode_order, picture_type_name[pic->type]); if (pic->nb_refs == 0) { av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n"); } else { av_log(avctx, AV_LOG_DEBUG, "Refers to:"); for (i = 0; i < pic->nb_refs; i++) { av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64, pic->refs[i]->display_order, pic->refs[i]->encode_order); } av_log(avctx, AV_LOG_DEBUG, ".\n"); } av_assert0(pic->input_available && !pic->encode_issued); for (i = 0; i < pic->nb_refs; i++) { av_assert0(pic->refs[i]); if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING) av_assert0(pic->refs[i]->encode_complete); else av_assert0(pic->refs[i]->encode_issued); } av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface); pic->recon_image = av_frame_alloc(); if (!pic->recon_image) { err = AVERROR(ENOMEM); goto fail; } err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0); if (err < 0) { err = AVERROR(ENOMEM); goto fail; } pic->recon_surface = (VASurfaceID)(uintptr_t)pic->recon_image->data[3]; av_log(avctx, AV_LOG_DEBUG, "Recon surface is %#x.\n", pic->recon_surface); pic->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool); if (!pic->output_buffer_ref) { err = AVERROR(ENOMEM); goto fail; } pic->output_buffer = (VABufferID)(uintptr_t)pic->output_buffer_ref->data; av_log(avctx, AV_LOG_DEBUG, "Output buffer is %#x.\n", pic->output_buffer); if (ctx->codec->picture_params_size > 0) { pic->codec_picture_params = av_malloc(ctx->codec->picture_params_size); if (!pic->codec_picture_params) goto fail; memcpy(pic->codec_picture_params, ctx->codec_picture_params, ctx->codec->picture_params_size); } else { av_assert0(!ctx->codec_picture_params); } pic->nb_param_buffers = 0; if (pic->encode_order == 0) { for (i = 0; i < ctx->nb_global_params; i++) { err = vaapi_encode_make_param_buffer(avctx, pic, VAEncMiscParameterBufferType, (char*)ctx->global_params[i], ctx->global_params_size[i]); if (err < 0) goto fail; } } if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) { err = vaapi_encode_make_param_buffer(avctx, pic, VAEncSequenceParameterBufferType, ctx->codec_sequence_params, ctx->codec->sequence_params_size); if (err < 0) goto fail; } if (ctx->codec->init_picture_params) { err = ctx->codec->init_picture_params(avctx, pic); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to initialise picture " "parameters: %d.\n", err); goto fail; } err = vaapi_encode_make_param_buffer(avctx, pic, VAEncPictureParameterBufferType, pic->codec_picture_params, ctx->codec->picture_params_size); if (err < 0) goto fail; } if (pic->type == PICTURE_TYPE_IDR) { if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE && ctx->codec->write_sequence_header) { bit_len = 8 * sizeof(data); err = ctx->codec->write_sequence_header(avctx, data, &bit_len); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to write per-sequence " "header: %d.\n", err); goto fail; } err = vaapi_encode_make_packed_header(avctx, pic, ctx->codec->sequence_header_type, data, bit_len); if (err < 0) goto fail; } } if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_PICTURE && ctx->codec->write_picture_header) { bit_len = 8 * sizeof(data); err = ctx->codec->write_picture_header(avctx, pic, data, &bit_len); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to write per-picture " "header: %d.\n", err); goto fail; } err = vaapi_encode_make_packed_header(avctx, pic, ctx->codec->picture_header_type, data, bit_len); if (err < 0) goto fail; } if (ctx->codec->write_extra_buffer) { for (i = 0;; i++) { size_t len = sizeof(data); int type; err = ctx->codec->write_extra_buffer(avctx, pic, i, &type, data, &len); if (err == AVERROR_EOF) break; if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to write extra " "buffer %d: %d.\n", i, err); goto fail; } err = vaapi_encode_make_param_buffer(avctx, pic, type, data, len); if (err < 0) goto fail; } } if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_MISC && ctx->codec->write_extra_header) { for (i = 0;; i++) { int type; bit_len = 8 * sizeof(data); err = ctx->codec->write_extra_header(avctx, pic, i, &type, data, &bit_len); if (err == AVERROR_EOF) break; if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to write extra " "header %d: %d.\n", i, err); goto fail; } err = vaapi_encode_make_packed_header(avctx, pic, type, data, bit_len); if (err < 0) goto fail; } } av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES); for (i = 0; i < pic->nb_slices; i++) { slice = av_mallocz(sizeof(*slice)); if (!slice) { err = AVERROR(ENOMEM); goto fail; } slice->index = i; pic->slices[i] = slice; if (ctx->codec->slice_params_size > 0) { slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size); if (!slice->codec_slice_params) { err = AVERROR(ENOMEM); goto fail; } } if (ctx->codec->init_slice_params) { err = ctx->codec->init_slice_params(avctx, pic, slice); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to initalise slice " "parameters: %d.\n", err); goto fail; } } if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SLICE && ctx->codec->write_slice_header) { bit_len = 8 * sizeof(data); err = ctx->codec->write_slice_header(avctx, pic, slice, data, &bit_len); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to write per-slice " "header: %d.\n", err); goto fail; } err = vaapi_encode_make_packed_header(avctx, pic, ctx->codec->slice_header_type, data, bit_len); if (err < 0) goto fail; } if (ctx->codec->init_slice_params) { err = vaapi_encode_make_param_buffer(avctx, pic, VAEncSliceParameterBufferType, slice->codec_slice_params, ctx->codec->slice_params_size); if (err < 0) goto fail; } } vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context, pic->input_surface); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to begin picture encode issue: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail_with_picture; } vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context, pic->param_buffers, pic->nb_param_buffers); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to upload encode parameters: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail_with_picture; } vas = vaEndPicture(ctx->hwctx->display, ctx->va_context); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); if (ctx->hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) goto fail; else goto fail_at_end; } if (ctx->hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) { for (i = 0; i < pic->nb_param_buffers; i++) { vas = vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to destroy " "param buffer %#x: %d (%s).\n", pic->param_buffers[i], vas, vaErrorStr(vas)); } } } pic->encode_issued = 1; if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING) return vaapi_encode_wait(avctx, pic); else return 0; fail_with_picture: vaEndPicture(ctx->hwctx->display, ctx->va_context); fail: for(i = 0; i < pic->nb_param_buffers; i++) vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]); fail_at_end: av_freep(&pic->codec_picture_params); av_frame_free(&pic->recon_image); return err; }
1threat
Hide multiple element from a column html table : I have html table, where span id is like spanitem_1_1, spanitem_2_1, spanitem_3_1 . I have tried this also $('[id^="spanitem_"]').hide(); but it will hide all span , that is not required.
0debug
static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s, MemoryRegion *address_space, MemoryRegion *io) { s->scratch_size = SVGA_SCRATCH_SIZE; s->scratch = g_malloc(s->scratch_size * 4); s->vga.con = graphic_console_init(dev, 0, &vmsvga_ops, s); s->fifo_size = SVGA_FIFO_SIZE; memory_region_init_ram(&s->fifo_ram, NULL, "vmsvga.fifo", s->fifo_size, &error_abort); vmstate_register_ram_global(&s->fifo_ram); s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram); vga_common_init(&s->vga, OBJECT(dev), true); vga_init(&s->vga, OBJECT(dev), address_space, io, true); vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga); s->new_depth = 32; }
1threat
Initialize Tree List View with Buttons : I have an TreeListView with three columns. The first displays the name of a file, and the other two must have buttons that allow to perform download and delete actions. However, to initialize this TreeListView, I first call a method that returns a list of strings with the file names. How do I get the names of these files to load in the first column of TreeListView, accompanied by the buttons in the other two columns? Thanks.
0debug
How to display list of databases present on your localhost server : <p>How to display list of databases present on your localhost server</p>
0debug
Android Recycler View with multiple Views : <p>I am making an app in which I want to put texts , images and videos all in separate ViewHolders (similar to Instagram and Facebook). I know that we have to use a Recycler View with multiple ViewTypes . I am using firebase as my storage . How do I retrieve the items from firebase and place them in the appropriate ViewHolder . Please help me.</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
altivec_yuv2packedX (SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, int dstW, int dstY) { int i,j; vector signed short X,X0,X1,Y0,U0,V0,Y1,U1,V1,U,V; vector signed short R0,G0,B0,R1,G1,B1; vector unsigned char R,G,B; vector unsigned char *out,*nout; vector signed short RND = vec_splat_s16(1<<3); vector unsigned short SCL = vec_splat_u16(4); unsigned long scratch[16] __attribute__ ((aligned (16))); vector signed short *YCoeffs, *CCoeffs; YCoeffs = c->vYCoeffsBank+dstY*lumFilterSize; CCoeffs = c->vCCoeffsBank+dstY*chrFilterSize; out = (vector unsigned char *)dest; for(i=0; i<dstW; i+=16){ Y0 = RND; Y1 = RND; for(j=0; j<lumFilterSize; j++) { X0 = vec_ld (0, &lumSrc[j][i]); X1 = vec_ld (16, &lumSrc[j][i]); Y0 = vec_mradds (X0, YCoeffs[j], Y0); Y1 = vec_mradds (X1, YCoeffs[j], Y1); } U = RND; V = RND; for(j=0; j<chrFilterSize; j++) { X = vec_ld (0, &chrSrc[j][i/2]); U = vec_mradds (X, CCoeffs[j], U); X = vec_ld (0, &chrSrc[j][i/2+2048]); V = vec_mradds (X, CCoeffs[j], V); } Y0 = vec_sra (Y0, SCL); Y1 = vec_sra (Y1, SCL); U = vec_sra (U, SCL); V = vec_sra (V, SCL); Y0 = vec_clip_s16 (Y0); Y1 = vec_clip_s16 (Y1); U = vec_clip_s16 (U); V = vec_clip_s16 (V); U0 = vec_mergeh (U,U); V0 = vec_mergeh (V,V); U1 = vec_mergel (U,U); V1 = vec_mergel (V,V); cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0); cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1); R = vec_packclp (R0,R1); G = vec_packclp (G0,G1); B = vec_packclp (B0,B1); switch(c->dstFormat) { case PIX_FMT_ABGR: out_abgr (R,G,B,out); break; case PIX_FMT_BGRA: out_bgra (R,G,B,out); break; case PIX_FMT_RGBA: out_rgba (R,G,B,out); break; case PIX_FMT_ARGB: out_argb (R,G,B,out); break; case PIX_FMT_RGB24: out_rgb24 (R,G,B,out); break; case PIX_FMT_BGR24: out_bgr24 (R,G,B,out); break; default: { static int printed_error_message; if(!printed_error_message) { av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n", sws_format_name(c->dstFormat)); printed_error_message=1; } return; } } } if (i < dstW) { i -= 16; Y0 = RND; Y1 = RND; for(j=0; j<lumFilterSize; j++) { X0 = vec_ld (0, &lumSrc[j][i]); X1 = vec_ld (16, &lumSrc[j][i]); Y0 = vec_mradds (X0, YCoeffs[j], Y0); Y1 = vec_mradds (X1, YCoeffs[j], Y1); } U = RND; V = RND; for(j=0; j<chrFilterSize; j++) { X = vec_ld (0, &chrSrc[j][i/2]); U = vec_mradds (X, CCoeffs[j], U); X = vec_ld (0, &chrSrc[j][i/2+2048]); V = vec_mradds (X, CCoeffs[j], V); } Y0 = vec_sra (Y0, SCL); Y1 = vec_sra (Y1, SCL); U = vec_sra (U, SCL); V = vec_sra (V, SCL); Y0 = vec_clip_s16 (Y0); Y1 = vec_clip_s16 (Y1); U = vec_clip_s16 (U); V = vec_clip_s16 (V); U0 = vec_mergeh (U,U); V0 = vec_mergeh (V,V); U1 = vec_mergel (U,U); V1 = vec_mergel (V,V); cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0); cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1); R = vec_packclp (R0,R1); G = vec_packclp (G0,G1); B = vec_packclp (B0,B1); nout = (vector unsigned char *)scratch; switch(c->dstFormat) { case PIX_FMT_ABGR: out_abgr (R,G,B,nout); break; case PIX_FMT_BGRA: out_bgra (R,G,B,nout); break; case PIX_FMT_RGBA: out_rgba (R,G,B,nout); break; case PIX_FMT_ARGB: out_argb (R,G,B,nout); break; case PIX_FMT_RGB24: out_rgb24 (R,G,B,nout); break; case PIX_FMT_BGR24: out_bgr24 (R,G,B,nout); break; default: av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n", sws_format_name(c->dstFormat)); return; } memcpy (&((uint32_t*)dest)[i], scratch, (dstW-i)/4); } }
1threat
int qemu_strtol(const char *nptr, const char **endptr, int base, long *result) { char *ep; int err = 0; if (!nptr) { if (endptr) { *endptr = nptr; } err = -EINVAL; } else { errno = 0; *result = strtol(nptr, &ep, base); err = check_strtox_error(nptr, ep, endptr, errno); } return err; }
1threat
Javascript Regex for decimal : <p>I need a regex for a 5 digit integer number with 2 decimals.</p> <p>These would be correct:</p> <ul> <li>12345.12</li> <li>09856.99</li> <li>45123.00</li> </ul> <p>These wouldn't:</p> <ul> <li>123.12</li> <li>12345.6</li> <li>98652</li> </ul>
0debug
android.database.sqlite.SQLiteException: near "s": syntax error (code 1): , : <p>android.database.sqlite.SQLiteException: near "s": syntax error (code 1): , while compiling: INSERT OR REPLACE INTO movies(backdrop_path,id,original_language,orginal_title,overview,poster_path,title,popularity,adult,video,vote_avg,vote_count,release_date,favourite) VALUES ('/tbhdm8UJAb4ViCTsulYFL3lxMCd.jpg','76341','en','null','An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order. There's Max, a man of action and a man of few words, who seeks peace of mind following the loss of his wife and child in the aftermath of the chaos. And Furiosa, a woman of action and a woman who believes her path to survival may be achieved if she can make it across the desert back to her childhood homeland.','/kqjL17yufvn9OVLyXYpvtyrFfak.jpg','Mad Max: Fury Road','19.132107','false','false','7','4359','-546474976','false' ); at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)</p>
0debug
Kotlin replacement for javah : <p><a href="http://openjdk.java.net/jeps/313" rel="noreferrer"><code>javah</code> has been deprecated since JDK 8 and will be/has been removed in JDK 10</a>, and according to JEP 313 and the deprecation text, <code>javac</code> with the <code>-h</code> flag should be used instead:</p> <blockquote> <p>Warning: The <code>javah</code> tool is planned to be removed in the next major JDK release. The tool has been superseded by the '-h' option added to <code>javac</code> in JDK 8. Users are recommended to migrate to using the <code>javac</code> '-h' option; see the javac man page for more information.</p> </blockquote> <p>The problem is, <code>javah</code> operates on compiled <code>.class</code> files, while <code>javac</code> operates on source files (i.e. <code>.java</code> files.)</p> <p><code>javah</code> works fine with Kotlin and <a href="https://stackoverflow.com/questions/35552834/what-is-the-purpose-of-external-keyword-in-kotlin"><code>external</code></a> functions, since everything ends up compiled as Java bytecode, but since there aren't any Java source files when using Kotlin, I don't see any way <code>javac -h</code> could work.</p> <p>Is there a <code>javah</code> replacement, or a workaround, for Kotlin?</p>
0debug
Clustering by minimum distance : I want to clustering my data by minimum distance between known centers. How to implement using R? the centers data > centers X 1 -0.78998176 2 2.40331380 3 0.77320007 4 -1.64054294 5 -0.05343331 6 -1.14982180 7 1.67658736 8 -0.44575567 9 0.36314671 10 1.18697840 the data wanted to be clustered > Y [1] -0.7071068 0.7071068 -0.3011463 -0.9128686 -0.5713978 NA the result I expected: 1. find the closest distance (minimum absolute difference value) between each items in Y and centers. 2. Assigns sequence number of centers to each items in Y expected result: > Y [1] 1 3 8 6 1 NA Y <- c(-0.707106781186548, 0.707106781186548, -0.301146296962689, -0.912868615826101, -0.571397763410073, NA) centers <- structure(c(-0.789981758587318, 2.40331380121291, 0.773200070034431, -1.64054294268215, -0.0534333085941505, -1.14982180092619, 1.67658736336158, -0.445755672120908, 0.363146708827924, 1.18697840480949), .Dim = c(10L, 1L), .Dimnames = list(c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"), "X"))
0debug
TypeScript require generic parameter to be provided : <p>I have the following function:</p> <pre><code>async function get&lt;U&gt;(url: string): Promise&lt;U&gt; { return getUrl&lt;u&gt;(url); } </code></pre> <p>However, it is possible to call it like this (U is set to any by TS):</p> <pre><code>get('/user-url'); </code></pre> <p>Is there a way to define this function such that it requires U to be provided explicitly, as in</p> <pre><code>get&lt;User&gt;('/user-url'); </code></pre>
0debug
Class inside a class in Python : <p>How can i call a class inside a class in Python? For example:</p> <pre><code>class POINT: def __init__(self, x, y): self.x = x self.y = y class CIRCLE: def __init__(self, x, y, radius): self.x = x self.y = y self.radius = radius </code></pre> <p>I want to call POINT class in CIRCLE. Thanks for answers.</p>
0debug
0% [Connecting to in.archive.ubuntu.com takes too long time : <p>whenever i run command who have to connect to archive.ubuntu.com, that command takes too long time to complete it task. </p> <pre><code>sudo apt install oracle-java8-installer -y Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: gsfonts-x11 java-common oracle-java8-set-default Suggested packages: binfmt-support visualvm ttf-baekmuk | ttf-unfonts | ttf-unfonts-core ttf-kochi-gothic | ttf-sazanami-gothic ttf-kochi-mincho | ttf-sazanami-mincho ttf-arphic-uming The following NEW packages will be installed: gsfonts-x11 java-common oracle-java8-installer oracle-java8-set-default 0 upgraded, 4 newly installed, 0 to remove and 29 not upgraded. Need to get 54.7 kB of archives. After this operation, 272 kB of additional disk space will be used. Get:1 http://ppa.launchpad.net/webupd8team/java/ubuntu artful/main amd64 oracle-java8-installer all 8u171-1~webupd8~0 [33.3 kB] Get:2 http://ppa.launchpad.net/webupd8team/java/ubuntu artful/main amd64 oracle-java8-set-default all 8u171-1~webupd8~0 [6,846 B] 0% [Connecting to in.archive.ubuntu.com (2001:67c:1360:8001::21)] </code></pre> <p>ping 8.8.8.8 :</p> <pre><code>ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=62.1 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=51.9 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=67.5 ms 64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=58.4 ms 64 bytes from 8.8.8.8: icmp_seq=5 ttl=56 time=71.9 ms 64 bytes from 8.8.8.8: icmp_seq=6 ttl=56 time=71.0 ms 64 bytes from 8.8.8.8: icmp_seq=7 ttl=56 time=60.5 ms 64 bytes from 8.8.8.8: icmp_seq=8 ttl=56 time=49.0 ms ^C --- 8.8.8.8 ping statistics --- 8 packets transmitted, 8 received, 0% packet loss, time 7005ms rtt min/avg/max/mdev = 49.028/61.584/71.951/7.865 ms </code></pre> <p>we can see above my speed is not slow .</p> <p><a href="https://i.stack.imgur.com/qca3s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qca3s.png" alt="and ipv4 is :"></a></p> <p>please help me to avoid this problem.every time i got stuck and have to wait until task completed.</p>
0debug
static void sigfd_handler(void *opaque) { int fd = (intptr_t)opaque; struct qemu_signalfd_siginfo info; struct sigaction action; ssize_t len; while (1) { do { len = read(fd, &info, sizeof(info)); } while (len == -1 && errno == EINTR); if (len == -1 && errno == EAGAIN) { break; } if (len != sizeof(info)) { printf("read from sigfd returned %zd: %m\n", len); return; } sigaction(info.ssi_signo, NULL, &action); if ((action.sa_flags & SA_SIGINFO) && action.sa_sigaction) { action.sa_sigaction(info.ssi_signo, (siginfo_t *)&info, NULL); } else if (action.sa_handler) { action.sa_handler(info.ssi_signo); } } }
1threat
Xcode keeps expanding all groups in the project navigator : <p>Since a couple days ago Xcode keeps expanding all the groups and subgroups in the project navigator.</p> <p>I have repeatedly collapsed them so I can focus on what I'm working on and then I go back and they're all expanded again.</p> <p>Has anyone else experienced this?</p> <p>I collapse a group, move to a different tab in Xcode and then back and the groups are all expanded again.</p> <p>It's really frustrating as I keep losing track of the files I'm working with.</p>
0debug
static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) { #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) asm volatile( "movq "MANGLE(bm01010101)", %%mm4\n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",4), %%mm0 \n\t" "movq 8(%1, %%"REG_a",4), %%mm1 \n\t" "movq (%2, %%"REG_a",4), %%mm2 \n\t" "movq 8(%2, %%"REG_a",4), %%mm3 \n\t" PAVGB(%%mm2, %%mm0) PAVGB(%%mm3, %%mm1) "pand %%mm4, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, %%mm1 \n\t" "psrlw $8, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "packuswb %%mm0, %%mm0 \n\t" "packuswb %%mm1, %%mm1 \n\t" "movd %%mm0, (%4, %%"REG_a") \n\t" "movd %%mm1, (%3, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((long)-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) : "%"REG_a ); #else int i; for(i=0; i<width; i++) { dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1; dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1; } #endif }
1threat
HTML WordPress Location - Stupid Questin : I am **not** a hardcore coding geek, although I wish I was... But from the little bit I learned in Collage in Electronics Engineering, I am able to handle most of my needs on my own.. and I did something but I forgot how I did it.... if you visit my website http://www.mozys.ca you will notice an "order online" button on the left bottom side.. I need to change the text to ORDERING IS OFFLINE.. and I forgot where I placed the HTML.. **What is the best way to find where an HTML code is placed?** I am able to disable the whole box from the styles.css, but I want to put ordering offline for now.. I know its embarrassing that I forgot where I placed my code.. but I currently run two restaurants and already spent two hours trying with no luck, if one of you guys can help me save some time I would really appreciate it Thank you
0debug
There is no dimens.xml in android studio project : <p>I have installed Android Studio 2.2.2 on my laptop. Then I updated it recently. But when I create an empty project, there is no dimens.xml on the project. Whereas when I used Android Studio 2.2.2 there is a dimens directory (with 2 dimens.xml). What happen to my Android Studio?</p>
0debug
static void nbd_coroutine_end(BlockDriverState *bs, NBDRequest *request) { NBDClientSession *s = nbd_get_client_session(bs); int i = HANDLE_TO_INDEX(s, request->handle); s->recv_coroutine[i] = NULL; s->in_flight--; qemu_co_queue_next(&s->free_sema); if (s->read_reply_co) { aio_co_wake(s->read_reply_co); } }
1threat
How to drag the iphoneX simulator? : <p>When moving the iPhoneX simulator I have tried <em>clicking and dragging</em> at the <strong>top, bottom and both sides and even all the corners</strong> but sometimes it works and other times it does not. </p> <p>Why is this so random? </p> <p>Where is there best place to click seeing as though there is no discernible bar like in other Mac applications</p> <p>Putting this question up because it has been frustrating me for ages and maybe it will alleviate someone else's stress out there in dev-land. </p>
0debug
Placeholder not working with angular2 (code attached in screenshot). My first post :) : [enter image description here][1] [1]: http://i.stack.imgur.com/lDQWf.png Plcaeholder not working with ANGULAR2. Please let me know if you require anything more?
0debug
int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx) { struct vaapi_context * const vactx = avctx->hwaccel_context; MpegEncContext *s = avctx->priv_data; int ret; ret = ff_vaapi_commit_slices(vactx); if (ret < 0) goto finish; ret = ff_vaapi_render_picture(vactx, ff_vaapi_get_surface_id(&s->current_picture_ptr->f)); if (ret < 0) goto finish; ff_mpeg_draw_horiz_band(s, 0, s->avctx->height); finish: ff_vaapi_common_end_frame(avctx); return ret; }
1threat
static int qemu_gluster_create(const char *filename, QEMUOptionParameter *options, Error **errp) { struct glfs *glfs; struct glfs_fd *fd; int ret = 0; int prealloc = 0; int64_t total_size = 0; GlusterConf *gconf = g_malloc0(sizeof(GlusterConf)); glfs = qemu_gluster_init(gconf, filename, errp); if (!glfs) { ret = -EINVAL; goto out; } while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { total_size = options->value.n / BDRV_SECTOR_SIZE; } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) { if (!options->value.s || !strcmp(options->value.s, "off")) { prealloc = 0; } else if (!strcmp(options->value.s, "full") && gluster_supports_zerofill()) { prealloc = 1; } else { error_setg(errp, "Invalid preallocation mode: '%s'" " or GlusterFS doesn't support zerofill API", options->value.s); ret = -EINVAL; goto out; } } options++; } fd = glfs_creat(glfs, gconf->image, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR); if (!fd) { ret = -errno; } else { if (!glfs_ftruncate(fd, total_size * BDRV_SECTOR_SIZE)) { if (prealloc && qemu_gluster_zerofill(fd, 0, total_size * BDRV_SECTOR_SIZE)) { ret = -errno; } } else { ret = -errno; } if (glfs_close(fd) != 0) { ret = -errno; } } out: qemu_gluster_gconf_free(gconf); if (glfs) { glfs_fini(glfs); } return ret; }
1threat
How to make a swift get query to specific url : <p>I am new to swift programming and need sam help. I want to know how I can make a get query to specific url and save the response data to variable. I am sorry that I can't show you the url but its a company secret. I can tell you that the response I a json. I really need help and I am going to be very happy if some helps me. If I am not explaining well, this is my first stack overflow account, just ask me for more info.</p>
0debug
how to link an image in my website to open in video player on another page? : <p>I want to link my image that is on my webpage to a video and I want that video will play on another page not on the same page. so can you help me with it.</p>
0debug
static void handle_output(VirtIODevice *vdev, VirtQueue *vq) { VirtIOSerial *vser; VirtIOSerialPort *port; VirtIOSerialPortInfo *info; vser = DO_UPCAST(VirtIOSerial, vdev, vdev); port = find_port_by_vq(vser, vq); info = port ? DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info) : NULL; if (!port || !port->host_connected || !info->have_data) { discard_vq_data(vq, vdev); return; } if (!port->throttled) { do_flush_queued_data(port, vq, vdev); return; } }
1threat
.NET CORE - DDD + CrossCutting + External API : <p>I am developing a .NET Core project using the DDD, IoC, CrossCutting.</p> <p>The CrossCutting.IoC project, the responsible for register the project dependencies and performing the inversion of control function and this project has the reference of the other projects.</p> <p>Now the need has come to do an external integration by calling an external API. I don't want to escape the design pattern.</p> <p>Which of the following is correct:</p> <ol> <li>Use an interface to integrate and register with IoC</li> <li>Create a project called CrossCutting.Integration</li> <li>None of the options. What is the best option?</li> </ol>
0debug
How get informations in javascript from API JSON ? : I need help ! Can you tell me how can I get informations from this in javascript : I would like to get the Third values from the fisrt array (121,73) and also the Fourth (99,25) . Thank you in advance ! ---------- { "error": [], "result": { "XETHZEUR": [ [ 1545955200, "100.76", "121.73", "99.25", "120.16", "111.15", "186385.05723331", 25420 ], [ 1546041600, "120.52", "130.00", "115.91", "117.89", "121.47", "154551.36751227", 23261 ], "last": 1546387200 } }
0debug
http POST not reaching backend : <p>I'm trying to pass an email value to the backend, but it never reaches the endpoint. I have the same url path being called, but <code>console.log("You've made it to the backend");</code> never outputs. Why is that? It's definitely hitting the angular service because Made It outputted to console no problem.</p> <p>angular service</p> <pre><code>import { Injectable } from "@angular/core"; import { HttpClient, HttpParams } from "@angular/common/http"; import { Router } from "@angular/router"; import { PasswordReset } from "./password.model"; @Injectable({ providedIn: "root" }) export class PasswordResetService { constructor(private http: HttpClient, private router: Router) {} sendEmail(email: string) { const password: PasswordReset = { email: email }; console.log("Made It"); return this.http.post( `http://localhost:3000/api/users/passwordreset`, password ); } } </code></pre> <p>app.js</p> <pre><code>app.post("/api/users/passwordreset", function(req, res) { console.log("You've made it to the backend"); let emailValue = req.body.email; if (req.body.email !== undefined) { User.findOne({ email: req.body.email }) .then(user =&gt; { if(user){ console.log("fetchedUser"); console.log(user._id); var payload = { id: user._id, email: user.email }; var secret = user.password + "-" + user.passwordCreated; console.log("THE SECRET IS: " + secret); var token = jwt.sign(payload, secret); console.log("payload"); console.log(payload); var ses_mail = "From: 'Auction Site' &lt;" + emailValue+ "&gt;\n"; ses_mail = ses_mail + "To: " +emailValue + "\n"; ses_mail = ses_mail + "Subject: Password Reset Request\n"; ses_mail = ses_mail + "MIME-Version: 1.0\n"; ses_mail = ses_mail + "Content-Type: multipart/mixed; boundary=\"NextPart\"\n\n"; ses_mail = ses_mail + "--NextPart\n"; ses_mail = ses_mail + "Content-Type: text/html; charset=us-ascii\n\n"; ses_mail = ses_mail + '&lt;a href="http://localhost:3000/resetpassword/' + payload.id + '/' + token + '"&gt;Click here to reset password&lt;/a&gt;'; // /:id/:token var params = { RawMessage: { Data: new Buffer.from(ses_mail) }, Destinations: [emailValue ], Source: "'AWS Tutorial Series' &lt;" + emailValue + "&gt;'" }; ses.sendRawEmail(params, function(err, data) { if(err) { res.send(err); console.log(err); } else { res.send(data); } }) } if (!user) { return res.status(401).json({ message: "Auth failed" }); } }); } else { res.send("Email address is missing."); } }); </code></pre>
0debug
Given an integer N. What is the smallest integer greater than N that only has 0 or 1 as its digits? : <p>I have an integer N. I have to find the smallest integer greater than N that doesn't contain any digit other than 0 or 1. For example: If <code>N = 12</code> then the answer is <code>100</code>. I have coded a brute force approach in C++. </p> <pre><code>int main() { long long n; cin &gt;&gt; n; for (long long i = n + 1; ; i++) { long long temp = i; bool ok = true; while (temp != 0) { if ( (temp % 10) != 0 &amp;&amp; (temp % 10) != 1) { ok = false; break; } temp /= 10; } if (ok == true) { cout &lt;&lt; i &lt;&lt; endl; break; } } } </code></pre> <p>The problem is, my approach is too slow. I believe there is a very efficient approach to solve this. How can I solve this problem efficiently?</p>
0debug
Android Architecture Components ViewModel Context : <p>I'm studying google's architecture components to implement ViewModel and LiveData to my app, and the official documentation says that:</p> <blockquote> <p>Note: Since the ViewModel outlives specific activity and fragment instantiations, it should never reference a View, or any class that may hold a reference to the activity context. If the ViewModel needs the Application context (for example, to find a system service), it can extend the AndroidViewModel class and have a constructor that receives the Application in the constructor (since Application class extends Context)</p> </blockquote> <p>Following that, I ended up with a code like that:</p> <pre><code>public class ViewModelTest extends AndroidViewModel { public ViewModelTest(Application application) { super(application); } public void test(){ Prefs.getCurrentCode(getApplication()); } </code></pre> <p>And should I instantiante it normally on the activity?</p> <pre><code> val viewModel2 = ViewModelProviders.of(this).get(ViewModelTest::class.java) viewModel2.test() </code></pre> <p>Isn't it bad? To use this application variable when need to access SharedPreferences or anything that need a context? And if it is, should I avoid using it on the ViewModel and use it only on the view? Specially if I want to update a UI component with a value that needs a context. I kinda don't know how to approach this issue, and I'm open for any suggestions.</p> <p>Thanks in advance</p>
0debug
How to add libraries in visual studio : <p>I will be going to university next year and I am trying to learn myself how to program in C#. I started with a new project on visual studio, and I pasted the program below from my textbook in a empty project. As you can see, in the first 2 sentences, there are a couple of libraries used that visual studio doesn't recognize. What am I doing wrong here?</p> <p>complete beginner btw.</p> <p><a href="https://i.stack.imgur.com/KZ8mE.png" rel="nofollow noreferrer">the pasted program from my textbook</a></p>
0debug
static void cchip_write(void *opaque, hwaddr addr, uint64_t v32, unsigned size) { TyphoonState *s = opaque; uint64_t val, oldval, newval; if (addr & 4) { val = v32 << 32 | s->latch_tmp; addr ^= 4; } else { s->latch_tmp = v32; return; } switch (addr) { case 0x0000: break; case 0x0040: break; case 0x0080: newval = oldval = s->cchip.misc; newval &= ~(val & 0x10000ff0); if (val & 0x100000) { newval &= ~0xff0000ull; } else { newval |= val & 0x00f00000; if ((newval & 0xf0000) == 0) { newval |= val & 0xf0000; } } newval |= (val & 0xf000) >> 4; newval &= ~0xf0000000000ull; newval |= val & 0xf0000000000ull; s->cchip.misc = newval; if ((newval ^ oldval) & 0xff0) { int i; for (i = 0; i < 4; ++i) { AlphaCPU *cpu = s->cchip.cpu[i]; if (cpu != NULL) { CPUState *cs = CPU(cpu); if (newval & (1 << (i + 8))) { cpu_interrupt(cs, CPU_INTERRUPT_SMP); } else { cpu_reset_interrupt(cs, CPU_INTERRUPT_SMP); } if ((newval & (1 << (i + 4))) == 0) { cpu_reset_interrupt(cs, CPU_INTERRUPT_TIMER); } } } } break; case 0x00c0: break; case 0x0100: case 0x0140: case 0x0180: case 0x01c0: break; case 0x0200: s->cchip.dim[0] = val; cpu_irq_change(s->cchip.cpu[0], val & s->cchip.drir); break; case 0x0240: s->cchip.dim[0] = val; cpu_irq_change(s->cchip.cpu[1], val & s->cchip.drir); break; case 0x0280: case 0x02c0: case 0x0300: break; case 0x0340: break; case 0x0380: s->cchip.iic[0] = val & 0xffffff; break; case 0x03c0: s->cchip.iic[1] = val & 0xffffff; break; case 0x0400: case 0x0440: case 0x0480: case 0x04c0: break; case 0x0580: break; case 0x05c0: break; case 0x0600: s->cchip.dim[2] = val; cpu_irq_change(s->cchip.cpu[2], val & s->cchip.drir); break; case 0x0640: s->cchip.dim[3] = val; cpu_irq_change(s->cchip.cpu[3], val & s->cchip.drir); break; case 0x0680: case 0x06c0: break; case 0x0700: s->cchip.iic[2] = val & 0xffffff; break; case 0x0740: s->cchip.iic[3] = val & 0xffffff; break; case 0x0780: break; case 0x0c00: case 0x0c40: case 0x0c80: case 0x0cc0: break; default: cpu_unassigned_access(current_cpu, addr, true, false, 0, size); return; } }
1threat
Python dictionary (key1, key2) append more than one value to same key pair : <p>Trying to create a dictionary of two keys and having more then one value.</p> <pre><code>myList = [[('2016-11-01', 'USD'), 'ECB News'], [('2016-11-01', 'USD'), 'FED News'], [('2016-11-02', 'EUR'), 'Brexit News'], [('2016-11-03', 'USD'), 'Yellen Speaking']] myDict = defaultdict(lambda: defaultdict(list)) for d, value in myList: print(d, value) myDict[d].append(value) #&lt;&lt;&lt;----- Error here print(myDict) </code></pre> <p>getting Error: </p> <pre><code> myDict[d].append(value) AttributeError: 'collections.defaultdict' object has no attribute 'append' </code></pre> <p>Expected output: Append same key pair values together.</p> <pre><code>{[('2016-11-01', 'USD'): 'ECB News', 'FED News'], [('2016-11-02', 'EUR'): 'Brexit News'], [('2016-11-03', 'USD'): 'Yellen Speaking']} </code></pre>
0debug
void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only) { QJSON *vmdesc; int vmdesc_len; SaveStateEntry *se; int ret; bool in_postcopy = migration_in_postcopy(); trace_savevm_state_complete_precopy(); cpu_synchronize_all_states(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || (in_postcopy && se->ops->save_live_complete_postcopy) || (in_postcopy && !iterable_only) || !se->ops->save_live_complete_precopy) { continue; } if (se->ops && se->ops->is_active) { if (!se->ops->is_active(se->opaque)) { continue; } } trace_savevm_section_start(se->idstr, se->section_id); save_section_header(f, se, QEMU_VM_SECTION_END); ret = se->ops->save_live_complete_precopy(f, se->opaque); trace_savevm_section_end(se->idstr, se->section_id, ret); save_section_footer(f, se); if (ret < 0) { qemu_file_set_error(f, ret); return; } } if (iterable_only) { return; } vmdesc = qjson_new(); json_prop_int(vmdesc, "page_size", qemu_target_page_size()); json_start_array(vmdesc, "devices"); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if ((!se->ops || !se->ops->save_state) && !se->vmsd) { continue; } if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) { trace_savevm_section_skip(se->idstr, se->section_id); continue; } trace_savevm_section_start(se->idstr, se->section_id); json_start_object(vmdesc, NULL); json_prop_str(vmdesc, "name", se->idstr); json_prop_int(vmdesc, "instance_id", se->instance_id); save_section_header(f, se, QEMU_VM_SECTION_FULL); vmstate_save(f, se, vmdesc); trace_savevm_section_end(se->idstr, se->section_id, 0); save_section_footer(f, se); json_end_object(vmdesc); } if (!in_postcopy) { qemu_put_byte(f, QEMU_VM_EOF); } json_end_array(vmdesc); qjson_finish(vmdesc); vmdesc_len = strlen(qjson_get_str(vmdesc)); if (should_send_vmdesc()) { qemu_put_byte(f, QEMU_VM_VMDESCRIPTION); qemu_put_be32(f, vmdesc_len); qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len); } qjson_destroy(vmdesc); qemu_fflush(f); }
1threat
long do_rt_sigreturn(CPUMIPSState *env) { struct target_rt_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_rt_sigreturn\n"); #endif frame_addr = env->active_tc.gpr[29]; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; target_to_host_sigset(&blocked, &frame->rs_uc.tuc_sigmask); sigprocmask(SIG_SETMASK, &blocked, NULL); if (restore_sigcontext(env, &frame->rs_uc.tuc_mcontext)) goto badframe; if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, rs_uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) goto badframe; env->active_tc.PC = env->CP0_EPC; mips_set_hflags_isa_mode_from_pc(env); env->CP0_EPC = 0; return -TARGET_QEMU_ESIGRETURN; badframe: force_sig(TARGET_SIGSEGV); return 0; }
1threat