problem
stringlengths
26
131k
labels
class label
2 classes
regex query text between < and > symbols : <p>I have a big list of email addresses in a format that I can't use for script them, I need help to build a regex that can match the email addresses.</p> <pre><code>name1 surname1 &lt;name1.surname1@domain.com&gt; name2 surname2 &lt;name2.surname2@domain.com&gt; </code></pre>
0debug
Selenium can't find chromedriver.exe : <p>We're upgrading to .NET Core, and we have a crawling engine that uses Selenium for some tasks. We use <code>chromedriver.exe</code> and it works just fine in .NET 4.6.1. </p> <p>For .NET Core, we created a console application, and added these packages:</p> <pre><code> &lt;ItemGroup&gt; &lt;PackageReference Include="Selenium.WebDriver" Version="3.8.0" /&gt; &lt;PackageReference Include="Selenium.Support" Version="3.7.0" /&gt; &lt;PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="2.34.0" /&gt; &lt;/ItemGroup&gt; </code></pre> <p>But when I run my code, I get this error:</p> <blockquote> <p>The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at <a href="http://chromedriver.storage.googleapis.com/index.html" rel="noreferrer">http://chromedriver.storage.googleapis.com/index.html</a>.</p> </blockquote> <p>I can see that after build, <code>chromedriver.exe</code> is getting copied to <code>bin\Debug\netcoreapp2.0</code> folder. I also copied it manually to <code>bin\Debug</code> folder. But in both cases it can't be found. </p> <p>What do I miss here?</p>
0debug
Why date value added from java to Sqlite database in Android is always null? : I am absolute beginner to Android. But I am having a problem with working with date in Android. Now I am inserting a value from EditText field to a Sqlite table column that is date database date. It is always null when it is added to database. Please help me. What is wrong with my code ? > My DatabaseHelper class public class DatabaseHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final String DATABASE_NAME = "todo.db"; private static final String TABLE_NAME = "task"; private static final String COLUMN_ID = "id"; private static final String COLUMN_DESCRIPTION = "description"; private static final String COLUMN_DATE ="date"; private static final String COLUMN_DONE = "done"; private static final String CREATE_TABLE = "CREATE TABLE "+TABLE_NAME+" ("+COLUMN_ID+" INTEGER PRIMARY KEY AUTOINCREMENT,"+COLUMN_DESCRIPTION+" TEXT,"+ COLUMN_DATE+" DATE,"+COLUMN_DONE+" BOOLEAN)"; SQLiteDatabase db; public DatabaseHelper(Context context) { super(context,DATABASE_NAME,null,DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { this.db = db; db.execSQL(CREATE_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { String query = "DROP TABLE IF EXISTS "+TABLE_NAME; db.execSQL(query); this.onCreate(db); } public void insertTask(Task task) { db = getWritableDatabase(); ContentValues values = new ContentValues(); values.put(COLUMN_DESCRIPTION,task.getDescription()); values.put(COLUMN_DATE,task.getDate().toString()); values.put(COLUMN_DONE,Boolean.FALSE.toString()); db.insert(TABLE_NAME, null, values); db.close(); } } > This is my save method in Fragment public void saveTask() { String description = tfDescription.getText().toString(); String date = tfDate.getText().toString(); if(description.isEmpty()) { Toast.makeText(getActivity().getBaseContext(),"Description is required",Toast.LENGTH_SHORT).show(); } else if(date.isEmpty()) { Toast.makeText(getActivity().getBaseContext(),"Date is required",Toast.LENGTH_SHORT).show(); } else if(description.length()<getResources().getInteger(R.integer.min_description_length)) { String minChar = String.valueOf(getResources().getInteger(R.integer.min_description_length)); Toast.makeText(getActivity().getBaseContext(),"Description should be minium "+minChar+" characters",Toast.LENGTH_SHORT).show(); } else{ //check date SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); boolean parseOk = false; Date taskDate = new Date(); try{ taskDate = format.parse(date); Task task = new Task(); task.setDescription(description); task.setDate(taskDate); dbHelper.insertTask(task); parseOk = true; } catch(ParseException e) { parseOk = false; } if(parseOk) { //insert task to database Toast.makeText(getActivity().getBaseContext(),"Task saved",Toast.LENGTH_SHORT).show(); } else{ Toast.makeText(getActivity().getBaseContext(),"Invalid date format",Toast.LENGTH_SHORT).show(); } } } > This is my Task class public class Task { private int Id; private String Description; private java.util.Date TaskDate; private boolean Done; public void setId(int Id) { this.Id = Id; } public int getId() { return this.Id; } public void setDescription(String Description) { this.Description = Description; } public String getDescription() { return this.Description; } public void setDate(Date taskDate) { this.TaskDate = taskDate; } public Date getDate(){ return this.TaskDate; } public void setDone(Boolean done) { this.Done = done; } public Boolean getDone() { return this.Done; } } Please help me why my date value is always null in database. The input format of the text field is MM/dd/yyyy for date. Please what is wrong with my code ?
0debug
static int init_input(AVFormatContext *s, const char *filename, AVDictionary **options) { int ret; AVProbeData pd = { filename, NULL, 0 }; int score = AVPROBE_SCORE_RETRY; if (s->pb) { s->flags |= AVFMT_FLAG_CUSTOM_IO; if (!s->iformat) return av_probe_input_buffer2(s->pb, &s->iformat, filename, s, 0, s->format_probesize); else if (s->iformat->flags & AVFMT_NOFILE) av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " "will be ignored with AVFMT_NOFILE format.\n"); return 0; } if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) || (!s->iformat && (s->iformat = av_probe_input_format2(&pd, 0, &score)))) return score; if ((ret = avio_open2(&s->pb, filename, AVIO_FLAG_READ | s->avio_flags, &s->interrupt_callback, options)) < 0) return ret; if (s->iformat) return 0; return av_probe_input_buffer2(s->pb, &s->iformat, filename, s, 0, s->format_probesize); }
1threat
static int ehci_init_transfer(EHCIQueue *q) { uint32_t cpage, offset, bytes, plen; target_phys_addr_t page; cpage = get_field(q->qh.token, QTD_TOKEN_CPAGE); bytes = get_field(q->qh.token, QTD_TOKEN_TBYTES); offset = q->qh.bufptr[0] & ~QTD_BUFPTR_MASK; qemu_sglist_init(&q->sgl, 5); while (bytes > 0) { if (cpage > 4) { fprintf(stderr, "cpage out of range (%d)\n", cpage); return USB_RET_PROCERR; } page = q->qh.bufptr[cpage] & QTD_BUFPTR_MASK; page += offset; plen = bytes; if (plen > 4096 - offset) { plen = 4096 - offset; offset = 0; cpage++; } qemu_sglist_add(&q->sgl, page, plen); bytes -= plen; } return 0; }
1threat
static void ss10_init(int ram_size, int vga_ram_size, int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { if (cpu_model == NULL) cpu_model = "TI SuperSparc II"; sun4m_common_init(ram_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, 1, PROM_ADDR); }
1threat
PLEASE help - HTML breaks in email : Good evening, I am having such an issue. I am formatting an HTML email and it all seems to work on several browsers - but of course it seems like Outlook is not playing nice on Chrome and IE. I have done a bit of research and know this is something I am missing - I have included the `border="0" style="display: block;">` on all of my images and included the table collapse command in the head: [table { border-collapse: collapse; }][1] Yet, it is still not working in Outlook on the above browsers. Can someone please tell me what I am doing wrong. I've included screenshots and a link to the HTML. If someone could please please help - I would be so grateful! Megan[HTML-Source\]\[1\ [1]: https://i.stack.imgur.com/70ejU.png
0debug
Get a human readable string from a URL in PHP : <p>Given:</p> <pre><code>$URL = "https://somedomain.com/these-are-words/"; </code></pre> <p>or</p> <pre><code>$URL = "http://somedomain.com/these-are-words/"; </code></pre> <p>How do I get?:</p> <pre><code>"these are words" </code></pre>
0debug
How to get a forwards slash url? : <p>I have a website with 000webhost, and I was wondering how I can get a url like this: <code>Website.com/ITCMDN</code> to forward to <code>Website.com/ITCMDN.html</code> Like I don't want people to have to type in the <code>.html</code> part, and I know this must be possible. Should I put something in my Index.html? Thanks!</p>
0debug
Which React lifecycle method can I use `this` in before the render function is called : <p>i was previously catching an error in my code using the component will mount method which is now being depreciated this was my code prevoiusly:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> componentWillMount() { if (!this.context) { throw new Error('Error'); } }</code></pre> </div> </div> </p> <ul> <li><p>I considered adding my code to the <code>constructor</code> but that would not work since i cant use <code>this.</code> in the constructor</p></li> <li><p>I also considered considered other lifecycle methods such as <code>componentDidMount</code> but this is called after the render function</p></li> </ul> <p>what would be the best way to solve this issue? would it be bad practice to add my error catching code in the render function?</p>
0debug
How to write a query with NULL for missing values : <p>Below, I have 2 tables. I want to write a query that will return each <code>NAME</code> and the corresponding <code>UIN</code> value. If there is no <code>UIN</code> value, I want to return <code>NULL</code> for that entry instead</p> <p><a href="https://i.stack.imgur.com/Do7pg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Do7pg.png" alt="enter image description here"></a></p> <p>For example, 2 entries should be like this for Samanta should be:</p> <p><code>Bob 49638-001</code></p> <p><code>Samantha NULL</code></p> <p>I've tried <code>SELECT NAME JOIN EMPLOYEE_UIN.UIN INSERT "NULL" WHERE UIN = NULL</code> but no luck. I'm a beginner with SQL and I couldn't find a similar example on SO about this.</p>
0debug
How do I transfer file data into Vector? : I splited the file to String lines and put them in array indexes. String fileString = readfromfile(fileEvents); String[] fileLines = fileString.split("\n"); assuming this is the first index in fileLines: 14 57 9 2 www.buytickets.com this is the constructor: Orders (int EventID, int SoldtoCustomerID, int SoldtoEmployeesID, int NumberOfTickets, String URL) the vector instance: Vector<Orders> myOrders = new Vector<Orders>(); how do I transfer this line to first index in the vecotr so it would be like this: (14,57,9,2,www.buytickets.com) thank you :)
0debug
static void test_copy(const AVCodec *c1, const AVCodec *c2) { AVCodecContext *ctx1, *ctx2; printf("%s -> %s\nclosed:\n", c1 ? c1->name : "NULL", c2 ? c2->name : "NULL"); ctx1 = avcodec_alloc_context3(c1); ctx2 = avcodec_alloc_context3(c2); ctx1->width = ctx1->height = 128; if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) { av_opt_set(ctx2->priv_data, "num", "667", 0); av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0); } avcodec_copy_context(ctx2, ctx1); test_copy_print_codec(ctx1); test_copy_print_codec(ctx2); if (ctx1->codec) { printf("opened:\n"); avcodec_open2(ctx1, ctx1->codec, NULL); if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) { av_opt_set(ctx2->priv_data, "num", "667", 0); av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0); } avcodec_copy_context(ctx2, ctx1); test_copy_print_codec(ctx1); test_copy_print_codec(ctx2); avcodec_close(ctx1); } avcodec_free_context(&ctx1); avcodec_free_context(&ctx2); }
1threat
Angular Cli pipe hide duplicates : Want to create a pipe to check specific object, not all. if object exists more than once only show once. Hide duplicates. Pipe `import { Pipe } from '@angular/core' @Pipe({ name: 'removeduplicates' }) export class RemovePipe { }` <tbody *ngFor="let dt of ash let i = index | removeduplicates: " > <tr> <td class="tg-yw4l nobord" style="border-left: inset;border-right: none;">{{dt.values}}</td> </tr> <tr> <td>{{dt.value2}}</td> </tr> </tbody>
0debug
What tools can i use to write a java script for facebook console panel : <p>I've seen java scripts've been used to do facebook tasks fast(by adding them through browser console panel) ,such as adding friends, sending messages, posting on groups....</p> <pre><code> ie: $$javascript:var inputs = document.getElementsByClassName('_54k8 _56bs _56bt'); for(var i=0; i&lt;inputs.length;i++) { inputs[i].click();} </code></pre> <p>(this's been used to cancel sent requests..) i need to know what are the tools/ides have been used to write these scripts..</p>
0debug
I'm new to Programming , Learning java from new boston but while practicing stuck here : Was trying to make a sorting program of integers entered by user and wanted it to take as many integer user wants, without first asking how many int he wanna sort , but while taking input it just crashes , **basically the problem is it is not storing values in array** import java.util.Scanner; class apple { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int j = 0; int[] arr; arr = new int[j]; while (true) { arr[j] = scan.nextInt(); if (arr[j]=='\n'){break;} j++; arr = new int[j]; } for(j = 0 ;j < arr.length ;j++){ System.out.print(arr[j] + " "); } } }
0debug
Swift How combine to Numeric Type : <p>I am kind of new to Swift, and wonder how to create a combined types.</p> <pre><code>typealisa Number = Int &amp; Float &amp; Double </code></pre> <p>Isnt work.</p> <pre><code>public protocol Number {} ; extension Int : Number {} ; extension Double : Number {} ; extension Float : Number {} ; </code></pre> <p>When you try </p> <pre><code>var a : Number = 1 ; var b : Number = 2 ; a * b //Binary operator '*' cannot be applied to two 'Number' operands </code></pre> <p>In TS, this cloud be simple as </p> <pre><code>type Number = Number = Int &amp; Float &amp; Double </code></pre> <p>Thank you so much!</p>
0debug
How would I create custom configurations - Java Minecraft Plugin : never really worked with custom .yml files before. I know, I know, dynamic is better and I'll agree. I have not coded in a very long time, and I'm getting back into it. If someone could provide assistance on my issue, that'd be great. Thanks! :) So, I basically made a little system to create a custom .yml file every time a player joins with some default values. Here's what I'm using to create the custom configs: https://hastebin.com/wibikegawa.cpp It does everything perfectly fine. But, when attempt to write to it, it creates a blank file. Code I'm using to write: https://hastebin.com/ovuxuzuzim.cpp Thanks! :) Some debugging to the console I did: https://hastebin.com/aveyegunen.vbs
0debug
static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, int frame_off) { int val, saved_val = 0; int tmplen = src_len; const uint8_t *src, *source_end = source + src_len; uint8_t *frame_end = frame + SCREEN_WIDE * SCREEN_HIGH; uint8_t *dst, *dst_end; int len, mask; int forward = (frame_off <= -SCREEN_WIDE) || (frame_off >= 0); int read_two_nibbles, flag; int advance_mode; int mode = 0; int i; if (src_len <= 0) return -1; if (forward) { src = source; dst = frame; dst_end = frame_end; } else { src = source + src_len - 1; dst = frame_end - 1; dst_end = frame - 1; } for (;;) { int shift = 0; flag = 0; if (!mode || (tmplen == 4)) { if (src < source || src >= source_end) return -1; val = *src; read_two_nibbles = 1; } else { val = saved_val; read_two_nibbles = 0; } if (!(val & 0xC)) { for (;;) { if (!read_two_nibbles) { if (src < source || src >= source_end) return -1; shift += 2; val |= *src << shift; if (*src & 0xC) break; } read_two_nibbles = 0; shift += 2; mask = (1 << shift) - 1; val = ((val >> 2) & ~mask) | (val & mask); NEXT_BYTE(src); if ((val & (0xC << shift))) { flag = 1; break; } } } else if (mode) { flag = tmplen != 4; } if (flag) { tmplen = 4; } else { saved_val = val >> (4 + shift); tmplen = 0; val &= (1 << (shift + 4)) - 1; NEXT_BYTE(src); } advance_mode = val & 1; len = (val >> 1) - 1; mode += 1 + advance_mode; if (mode >= 4) mode -= 3; if (FFABS(dst_end - dst) < len) return -1; switch (mode) { case 1: if (forward) { if (dst - frame + SCREEN_WIDE < frame_off || frame_end - dst < frame_off + len) return -1; for (i = 0; i < len; i++) dst[i] = dst[frame_off + i]; dst += len; } else { dst -= len; if (dst - frame + SCREEN_WIDE < frame_off || frame_end - dst < frame_off + len) return -1; for (i = len - 1; i >= 0; i--) dst[i] = dst[frame_off + i]; } break; case 2: if (forward) { if (source + src_len - src < len) return -1; memcpy(dst, src, len); dst += len; src += len; } else { if (src - source < len) return -1; dst -= len; src -= len; memcpy(dst, src, len); } break; case 3: val = forward ? dst[-1] : dst[1]; if (forward) { memset(dst, val, len); dst += len; } else { dst -= len; memset(dst, val, len); } break; default: break; } if (dst == dst_end) return 0; } return 0; }
1threat
Google map mileage function to return mileage between to addresses : For each loop quit working. public static function getMiles($to, $from) { $from = urlencode($from); $to = urlencode($to); $data = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=$from&destinations=$to&key=AIzaSyAX8D-kve7_xjQSkJP2tF_o2LxNl2McTNc"); $time = 0; $distance = 0; /* return as an object for easier notation */ $json=json_decode( $data, false ); $origins = $json->origin_addresses; $destinations=$json->destination_addresses; /* if there are multiple rows, use a loop and `$rows[$i]` etc */ $elements=$json->rows[0]->elements; foreach( $elements as $i => $obj ){ } //extract the mileage as meters $miles = $obj->distance->value; //converting the meters to miles $distance= round(($miles * '0.000621371192'), 1); //returning miles return $distance; } The end result is to return mileage between 2 addresses. Error message is "'Invalid argument supplied for foreach()'"
0debug
static int usbredir_handle_control(USBDevice *udev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev); struct usb_redir_control_packet_header control_packet; AsyncURB *aurb; switch (request) { case DeviceOutRequest | USB_REQ_SET_ADDRESS: DPRINTF("set address %d\n", value); dev->dev.addr = value; return 0; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: return usbredir_set_config(dev, p, value & 0xff); case DeviceRequest | USB_REQ_GET_CONFIGURATION: return usbredir_get_config(dev, p); case InterfaceOutRequest | USB_REQ_SET_INTERFACE: return usbredir_set_interface(dev, p, index, value); case InterfaceRequest | USB_REQ_GET_INTERFACE: return usbredir_get_interface(dev, p, index); } aurb = async_alloc(dev, p); DPRINTF("ctrl-out type 0x%x req 0x%x val 0x%x index %d len %d id %u\n", request >> 8, request & 0xff, value, index, length, aurb->packet_id); control_packet.request = request & 0xFF; control_packet.requesttype = request >> 8; control_packet.endpoint = control_packet.requesttype & USB_DIR_IN; control_packet.value = value; control_packet.index = index; control_packet.length = length; aurb->control_packet = control_packet; if (control_packet.requesttype & USB_DIR_IN) { usbredirparser_send_control_packet(dev->parser, aurb->packet_id, &control_packet, NULL, 0); } else { usbredir_log_data(dev, "ctrl data out:", data, length); usbredirparser_send_control_packet(dev->parser, aurb->packet_id, &control_packet, data, length); } usbredirparser_do_write(dev->parser); return USB_RET_ASYNC; }
1threat
static int check_features_against_host(x86_def_t *guest_def) { x86_def_t host_def; uint32_t mask; int rv, i; struct model_features_t ft[] = { {&guest_def->features, &host_def.features, ~0, feature_name, 0x00000000}, {&guest_def->ext_features, &host_def.ext_features, ~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x00000001}, {&guest_def->ext2_features, &host_def.ext2_features, ~PPRO_FEATURES, ext2_feature_name, 0x80000000}, {&guest_def->ext3_features, &host_def.ext3_features, ~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001}}; cpu_x86_fill_host(&host_def); for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i) for (mask = 1; mask; mask <<= 1) if (ft[i].check_feat & mask && *ft[i].guest_feat & mask && !(*ft[i].host_feat & mask)) { unavailable_host_feature(&ft[i], mask); rv = 1; } return rv; }
1threat
static void nested_struct_compare(UserDefNested *udnp1, UserDefNested *udnp2) { g_assert(udnp1); g_assert(udnp2); g_assert_cmpstr(udnp1->string0, ==, udnp2->string0); g_assert_cmpstr(udnp1->dict1.string1, ==, udnp2->dict1.string1); g_assert_cmpint(udnp1->dict1.dict2.userdef1->base->integer, ==, udnp2->dict1.dict2.userdef1->base->integer); g_assert_cmpstr(udnp1->dict1.dict2.userdef1->string, ==, udnp2->dict1.dict2.userdef1->string); g_assert_cmpstr(udnp1->dict1.dict2.string2, ==, udnp2->dict1.dict2.string2); g_assert(udnp1->dict1.has_dict3 == udnp2->dict1.has_dict3); g_assert_cmpint(udnp1->dict1.dict3.userdef2->base->integer, ==, udnp2->dict1.dict3.userdef2->base->integer); g_assert_cmpstr(udnp1->dict1.dict3.userdef2->string, ==, udnp2->dict1.dict3.userdef2->string); g_assert_cmpstr(udnp1->dict1.dict3.string3, ==, udnp2->dict1.dict3.string3); }
1threat
Flutter PageView - Show preview of page on left and right : <p>I am trying to create a pagiewView in flutter that shows preview of the next page and the a preview of the next page as is in the attached image. How can I achieve that?<a href="https://i.stack.imgur.com/qRaLO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qRaLO.jpg" alt="enter image description here"></a></p>
0debug
Capitalize first letter of a string using Angular or typescript : <p>How can I capitalize the first letter of a string using Angular or typescript? </p>
0debug
List of Button - Android Studio : So I got 100 ImageButton, I need to make a list of these button, I tried with a static list like the scrollview, It work but the app need 4 to 5 seconds to load all the ImageButtons, so I wanna try to make a list that load buttons when user scroll down. In this way the app does not have to load all the buttons at once, I've been looking for a solution for days but I can not find it, someone know how to achive this list of imagebutton?
0debug
Best data structor for a dynamic array : I look for a best data structure that alows me to: - create a dynamic array. - complexity of inserting is O(1). - complexity of check if an element exists or not is O(1).
0debug
int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) { int ret; ret = ff_framesync_dualinput_get(fs, f0, f1); if (ret < 0) return ret; ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0); if (ret < 0) { av_frame_free(f0); av_frame_free(f1); return ret; } return 0; }
1threat
Get Header from PHP cURL response : <p>I am new to PHP. I am trying to get the Header from the response after sending the php curl POST request. The client sends the request to the server and server sends back the response with Header. Here is how I sent my POST request.</p> <pre><code> $client = curl_init($url); curl_setopt($client, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($client, CURLOPT_POSTFIELDS, $data_string); curl_setopt($client, CURLOPT_HEADER, 1); $response = curl_exec($client); var_dump($response); </code></pre> <p>Here is the Header response from server that I get from the browser</p> <pre><code>HTTP/1.1 200 OK Date: Wed, 01 Feb 2017 11:40:59 GMT Authorization: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2Vycy9CYW9CaW5oMTEwMiIsIm5hbWUiOiJhZG1pbiIsInBhc3N3b3JkIjoiMTIzNCJ9.kIGghbKQtMowjUZ6g62KirdfDUA_HtmW-wjqc3ROXjc Content-Type: text/html;charset=utf-8 Transfer-Encoding: chunked Server: Jetty(9.3.6.v20151106) </code></pre> <p>How can I extract the Authorization part from the Header ?. I need to store it in the cookies </p>
0debug
static target_ulong h_enter(CPUPPCState *env, sPAPREnvironment *spapr, target_ulong opcode, target_ulong *args) { target_ulong flags = args[0]; target_ulong pte_index = args[1]; target_ulong pteh = args[2]; target_ulong ptel = args[3]; target_ulong page_shift = 12; target_ulong raddr; target_ulong i; uint8_t *hpte; if (pteh & HPTE_V_LARGE) { #if 0 if ((ptel & 0xf000) == 0x1000) { } else #endif if ((ptel & 0xff000) == 0) { page_shift = 24; if (pteh & 0x80) { return H_PARAMETER; } } else { return H_PARAMETER; } } raddr = (ptel & HPTE_R_RPN) & ~((1ULL << page_shift) - 1); if (raddr < spapr->ram_limit) { if ((ptel & HPTE_R_WIMG) != HPTE_R_M) { return H_PARAMETER; } } else { if ((ptel & (HPTE_R_W | HPTE_R_I | HPTE_R_M)) != HPTE_R_I) { return H_PARAMETER; } } pteh &= ~0x60ULL; if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) { return H_PARAMETER; } if (likely((flags & H_EXACT) == 0)) { pte_index &= ~7ULL; hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64); for (i = 0; ; ++i) { if (i == 8) { return H_PTEG_FULL; } if (((ldq_p(hpte) & HPTE_V_VALID) == 0) && lock_hpte(hpte, HPTE_V_HVLOCK | HPTE_V_VALID)) { break; } hpte += HASH_PTE_SIZE_64; } } else { i = 0; hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64); if (!lock_hpte(hpte, HPTE_V_HVLOCK | HPTE_V_VALID)) { return H_PTEG_FULL; } } stq_p(hpte + (HASH_PTE_SIZE_64/2), ptel); stq_p(hpte, pteh); assert(!(ldq_p(hpte) & HPTE_V_HVLOCK)); args[0] = pte_index + i; return H_SUCCESS; }
1threat
SQL query for updating two columns of a row while checking whether they overlap with other rows of the same table : The table below shows 3 selected rows from the session table which contains 3 sessions for the same doctor on the same day but with different, starting and ending times. I want to update the sessionStartTime and sessionEndTime columns of one row in this table while checking whether that sessionStartTime and sessionEndTime overlap other 2 rows. What I need is a correct SQL query for this. For example, I want to edit the sessionStartTime as 2018-07-08 9:30:00 and sessionEndTime as 2018-07-08 10:30:00 of the row with id=1091 and as the starting time and ending time of this session doesn't overlap with other two row values the two values should be updated.But if I entered the two values sessionStartTime as 2018-07-08 8:20:00 and sessionEndTime as 2018-07-08 9:00:00 of the id=1091 it should not allow it to edit the row as there is already another session with id=1090 which contains the starting and ending time duration. [enter image description here][1] [1]: https://i.stack.imgur.com/Xufof.png I would rather be thankful if a clear answer for this question is given sooner as I'm already stuck with the logic and query for a long period of time.
0debug
how can i use perl to calculate the frequency of : PASS AC=0;AF=0.048;AN=2;ASP;BaseQRankSum=0.572;CAF=[0.9605,.,0.03949];CLNACC=RCV000111759.1,RCV000034730 I'm a newer.I want to know how to match CAF = [0.9605,.,0.03949] using regular expression,thank you
0debug
C# Listview - How to change the color of each new item : I have a listview that I add items to it whenever I click a button. I want each **new** item to be colored **red** and the **older** item **white**. So that means only one item can be colored red which is the newest item added to the listview. I did something like this but this just alternates the colors red and white. for (int i = 0; i <= listView1.Items.Count - 1; i++) { if (listView1.Items[i].Index % 2 == 0) { listView1.Items[i].BackColor = Color.Red; } else { listView1.Items[i].BackColor = Color.White; } }
0debug
Dart - how _InternalLinkedHashMap<String, dynamic> convert to Map<String, dynamic>? : <p>I use <a href="https://pub.dev/packages/dio" rel="noreferrer">package dio</a> in my flutter app. A get response from my api question. response.data get type _InternalLinkedHashMap. I need convert this value to Map. I tried many options but this does not work.</p> <p>I have no way to change the server response. Any advice?</p>
0debug
How should a GRPC Service be hosted? : <p>I have created a GRPC Server in C# using the example given at <a href="http://www.grpc.io/docs/tutorials/basic/csharp.html" rel="noreferrer">Link</a>. Now I want to figure out as how should I be hosting this server so that I achieve following:</p> <ul> <li>Should I make this Server a Console application or a a Windows Service. If I make it a windows Service then updating the service will be cumbersome (which is a big negative) and if I make it a console app then updating will simply need shutting down exe. But that comes with the price of closing the same by mistake. Is there any other better way?</li> <li>With IIS this issue won't b there as I can simply remove the site from LB and stop the website to perform the update but since GRPC won't be a part of IIS, I am not sure what's the way to get this working.</li> </ul> <p>Any references for the better architecture are welcomed.</p>
0debug
How to pass parameter to java lamda : I am using Spring RetryTemplate and using this method. Wanted to pass some argument (vendor) it is giving me compilation error. I can create a another variable vendorName as final can send it. But I want to make use the the variable `vendor`. It must be simple one but not getting it. please help. public Token getToken(final String tokenId) { String vendor = getVendor(tokenId);//returns some vendor name RetryTemplate retryTemplate = getRetryTemplate(); Token token = retryTemplate.execute(context -> { logger.info("Attempted {} times", context.getRetryCount()); return retrieveToken(tokenId, vendor); }); } private RetryTemplate getRetryTemplate() { final FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy(); fixedBackOffPolicy.setBackOffPeriod(getRandomNumber() * 1000); final SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(); retryPolicy.setMaxAttempts(5); final RetryTemplate retryTemplate = new RetryTemplate(); retryTemplate.setBackOffPolicy(fixedBackOffPolicy); retryTemplate.setRetryPolicy(retryPolicy); return retryTemplate; }
0debug
void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) { if (QTAILQ_EMPTY(&address_spaces)) { memory_init(); } memory_region_transaction_begin(); as->root = root; as->current_map = g_new(FlatView, 1); flatview_init(as->current_map); as->ioeventfd_nb = 0; as->ioeventfds = NULL; QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); as->name = g_strdup(name ? name : "anonymous"); address_space_init_dispatch(as); memory_region_update_pending |= root->enabled; memory_region_transaction_commit(); }
1threat
Can web page be accessed using groovy in REST SOAP UI : I am new to groovy , Can it be possible that using groovy (in SOAP) we can open a webpage and do specific actions on that webpage
0debug
void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, VirtIOBlockDataPlane **dataplane, Error **errp) { VirtIOBlockDataPlane *s; Error *local_err = NULL; BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); *dataplane = NULL; if (!conf->data_plane && !conf->iothread) { return; } if (!k->set_guest_notifiers || !k->set_host_notifier) { error_setg(errp, "device is incompatible with x-data-plane " "(transport does not support notifiers)"); return; } if (bdrv_op_is_blocked(conf->conf.bs, BLOCK_OP_TYPE_DATAPLANE, &local_err)) { error_setg(errp, "cannot start dataplane thread: %s", error_get_pretty(local_err)); error_free(local_err); return; } s = g_new0(VirtIOBlockDataPlane, 1); s->vdev = vdev; s->conf = conf; if (conf->iothread) { s->iothread = conf->iothread; object_ref(OBJECT(s->iothread)); } else { object_initialize(&s->internal_iothread_obj, sizeof(s->internal_iothread_obj), TYPE_IOTHREAD); user_creatable_complete(OBJECT(&s->internal_iothread_obj), &error_abort); s->iothread = &s->internal_iothread_obj; } s->ctx = iothread_get_aio_context(s->iothread); s->bh = aio_bh_new(s->ctx, notify_guest_bh, s); error_setg(&s->blocker, "block device is in use by data plane"); bdrv_op_block_all(conf->conf.bs, s->blocker); bdrv_op_unblock(conf->conf.bs, BLOCK_OP_TYPE_RESIZE, s->blocker); bdrv_op_unblock(conf->conf.bs, BLOCK_OP_TYPE_DRIVE_DEL, s->blocker); *dataplane = s; }
1threat
How to do multiple polynomial regression in R? : <p>To do a [muliple] linear regression model, one uses lm</p> <p>Is it possible to derive a multiple polynomial regression model? Where each coefficient is a polynomial function?</p>
0debug
Why the Standard claims that containers are objects? : <p>Container's definition from the Standard:</p> <blockquote> <p>§23.2.1/1: <strong>Containers are objects</strong> that store other objects. They control allocation and deallocation of these objects through constructors, destructors, insert and erase operations.</p> </blockquote> <p>I think the container's definition above contradicts with the definition from C++ Primer book (which I prefer):</p> <blockquote> <p><strong>Container is a type</strong> whose objects hold a collection of objects of a given type. </p> </blockquote> <p>It's obvious that (abstract) type can't be an object (any object must occupy a region of storage). You can say that C++ <strong>container is a class template</strong>. But templates are not objects too. There is a note about it from <a href="http://en.cppreference.com/w/cpp/language/object" rel="nofollow noreferrer">cppreference</a>:</p> <blockquote> <p>The following entities are not objects: value, reference, function, enumerator, <strong>type</strong>, non-static class member, bit-field, <strong>template</strong>, class or function template specialization, namespace, parameter pack, and this.</p> </blockquote> <p>So why the Standard claims that containers are objects? Maybe there is a mistake somewhere?</p>
0debug
How to do it? I try to do it and i have no idea :/ : How to call form method from another object method? I tried to pass the Form throgh the reference but it giving: 'Form' does not contain a definition for and no extension method accepting a first argument of type 'Form' could be found (are you missing a using directive or an assembly reference?) public class Foo { public void FooVoid() { Form1.FormVoid(); } } public void FormVoid() { } public Program() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } Any ideas ?
0debug
static int theora_packet(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + idx; int duration; if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) { int seg; duration = 1; for (seg = os->segp; seg < os->nsegs; seg++) { if (os->segments[seg] < 255) duration ++; } os->lastpts = os->lastdts = theora_gptopts(s, idx, os->granule, NULL) - duration; if(s->streams[idx]->start_time == AV_NOPTS_VALUE) { s->streams[idx]->start_time = os->lastpts; if (s->streams[idx]->duration) s->streams[idx]->duration -= s->streams[idx]->start_time; } } if (os->psize > 0) { os->pduration = 1; } return 0; }
1threat
How to create a property using groovy script??? : In my automation script i am in need to create a property and store the value dynamically ,so that the value stored is used in upcoming steps for further process,Could anyone help in this. I tried online every article says on set and get property in groovy,but i need to create a property in groovy.
0debug
How do I make it if a certain json string will run a command : I'm making a level system for my discord bot, I want it so if I reach level 5, it will give me a role. How do I make it so it reads the json file to see if my level is level 5?
0debug
Mocking non-interface types in Go : <p>Let me preface this by saying I'm pretty new to Go, so I am looking for mocking techniques when working with other libraries. I am well aware that interfaces and dependency injection are the best way to keep code testable and mockable.</p> <p>While working with a 3rd party client library (Google Cloud Storage), I have run into a problem with attempting to mock the implementation of their client. The primary problem is that the types in the client library are not implemented with interfaces. I can generate interfaces to mimic the client implementation. However, the return values for some of the functions return pointers to underlying struct types which are tricky or impossible to mock due to private attributes. Here is a sample of the problem I am trying to solve:</p> <pre><code>package third_party type UnderlyingType struct { secret string } type ThirdPartyClient struct {} func (f *ThirdPartyClient) SomeFunction() *UnderlyingType { return &amp;UnderlyingType{ secret: "I can't mock this, it's a secret to the package" } } </code></pre> <p>Here is an annotated sample with the problem I'm trying to solve.</p> <pre><code>package mock // Create interface that matches third party client structure type MyClientInterface interface { SomeFunction() *third_party.UnderlyingType } type MockClient struct { third_party.Client } // Forced to return the third party non-interface type 'UnderlyingType' func (f *MockClient) SomeFunction() *UnderlyingType { // No way to mock the value of the 'secret' property outside // of the third-party package. Any underlying methods that // depend on a non-nil reference to 'secret' will explode // with the mock. // // TODO: Find a way to mock the 'secret' value return &amp;UnderlyingType{} } </code></pre> <p>Is this even a mockable scenario? Are there special techniques to work around the fact that the library provides no interfaces as return types?</p>
0debug
Syntex error while updating sqlite database in android : I have a error while updating data. The error is android.database.sqlite.SQLiteException: near "parth": syntax error (code 1): , while compiling: UPDATE income SET income_balance=? WHERE income_name=?parth. Please any one help me... public void update2( String name, String bal){ SQLiteDatabase db = getWritableDatabase(); ContentValues values = new ContentValues(); //values.put(INCOME_NAME, name); values.put(INCOME_BALANCE, bal); db.update(TABLE_INCOME, values, INCOME_NAME+"=?"+name, new String[]{String.valueOf(name)});
0debug
static void rtas_ibm_set_slot_reset(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { sPAPRPHBState *sphb; sPAPRPHBClass *spc; uint32_t option; uint64_t buid; int ret; if ((nargs != 4) || (nret != 1)) { goto param_error_exit; } buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); option = rtas_ld(args, 3); sphb = find_phb(spapr, buid); if (!sphb) { goto param_error_exit; } spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb); if (!spc->eeh_reset) { goto param_error_exit; } ret = spc->eeh_reset(sphb, option); rtas_st(rets, 0, ret); return; param_error_exit: rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); }
1threat
How make select2 placeholder for search input : <p>How to make placeholder for select2 jQuery plugin. On StackOverflow many answers how to make placeholder there, but they about element's placeholder. I need to specify a placeholder for the search box, see pic.<a href="https://i.stack.imgur.com/lGXnk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lGXnk.png" alt="enter image description here"></a></p>
0debug
static inline void do_rfi(CPUPPCState *env, target_ulong nip, target_ulong msr) { CPUState *cs = CPU(ppc_env_get_cpu(env)); msr &= ~(1ULL << MSR_POW); #if defined(TARGET_PPC64) if (!msr_is_64bit(env, msr)) { nip = (uint32_t)nip; } #else nip = (uint32_t)nip; #endif env->nip = nip & ~((target_ulong)0x00000003); hreg_store_msr(env, msr, 1); #if defined(DEBUG_OP) cpu_dump_rfi(env->nip, env->msr); #endif cs->interrupt_request |= CPU_INTERRUPT_EXITTB; check_tlb_flush(env); }
1threat
static void coroutine_fn v9fs_flush(void *opaque) { ssize_t err; int16_t tag; size_t offset = 7; V9fsPDU *cancel_pdu = NULL; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; err = pdu_unmarshal(pdu, offset, "w", &tag); if (err < 0) { pdu_complete(pdu, err); return; } trace_v9fs_flush(pdu->tag, pdu->id, tag); if (pdu->tag == tag) { error_report("Warning: the guest sent a self-referencing 9P flush request"); } else { QLIST_FOREACH(cancel_pdu, &s->active_list, next) { if (cancel_pdu->tag == tag) { break; } } } if (cancel_pdu) { cancel_pdu->cancelled = 1; qemu_co_queue_wait(&cancel_pdu->complete, NULL); if (!qemu_co_queue_next(&cancel_pdu->complete)) { cancel_pdu->cancelled = 0; pdu_free(cancel_pdu); } } pdu_complete(pdu, 7); }
1threat
Having trouble working with SelectWoo instances of Select2 within WooCommerce : <p>I am using Select2 within WooCommerce in some of my own custom areas and I am targeting it with some code to add and removes certain classes and it's working fine; however the <a href="https://github.com/woocommerce/selectWoo" rel="noreferrer">SelectWoo</a> instances used by WooCommerce themselves are not working.</p> <p>Example code:</p> <pre><code>(function($) { $('select').each(function(e) { handleSelectSelections($(this)); }); })( jQuery ); function handleSelectSelections(select) { var el = (select.next('.select2').length) ? jQuery(select.data('select2').$container) : select; if (select.val() !== "" &amp;&amp; select.val() !== null) { el.addClass('has-selection'); } else { el.removeClass('has-selection'); } } </code></pre> <p>Everything works fine, except when it gets to the actual part where it adds the class it doesn't work - no class is added.</p> <p>Am I missing something here?</p>
0debug
the js is not working on this code : <html> <head> <link rel="stylesheet" type="text/css" href="rise.css"> <script> function myFunction{ document.getElementById("bad").style.display="block"; } </script> </head> <body> <div id="good"> <div id="vahid"> <div id="one"> <img src="image1.jpg" id="boom"><br><br><br><br><br> <!--button--> <img src="button.jpg" onclick="myFunction()" id="button"><br><br><br><br> <!--icons--> <span class="local"> <img src="img.jpg"> <img src="img1.jpg"> <img src="img2.jpg"> <img src="img3.jpg"> </span><br><br><br><br> <span class="local"> <img src="img4.jpg"> <img src="img5.jpg"> <img src="img6.jpg"> <img src="img7.jpg"> </span> </div> </div> <div id="isnani"> <div id="third"> <p > <span class="fourth">Dashboard</span> <span class="fifth"> + New</span> </p> <!--<p class="fourth">&nbsp;</p> <p id="fort"><input type="text" placeholder="search your project here..." ></p> <div id="jump"><img src="search.jpg" height="20px" width="10px"></div>--> <p id="sixth"> Welcome to Flatkit</p> <p id="seventh"> Bootstrap 4 Web App Kit With Angular js</p> </div> </div> </div> <div id="bad"> </div> </body> </html> css: #good{ width: 100%; height: 100%; } #bad{ position:absolute; width: 15%; height: 100%; background-color: #023b3b; top:0%; display: none; } #vahid{ float: left; width: 7%; height: 100%; background-color: #023b3b; } #isnani{ float: left; width: 93%; height: 100%; background-color: bisque; } #one { display:block; background-color: #023b3b; /* width:60px; height: 867px;*/ } #boom{ margin-top: 30%; height: 5%; width: 35%; float: left; padding-left: 20px; } .local img { height: 2.5%; width:30%; margin :10px 0px 10px 20px; } /*isnani starts here*/ #third{ float:left; width:100%; height: 15%; border-color:white; border-style : solid; background-color : white; } .fourth{ margin-left: 2%; margin-top: 5%; font-family: sans-serif; } .fifth{ color: #808080; font-size: 80%; font-weight: 800; font-family: arial,sans-serif; margin-left: 1%; } #sixth{ font-family: sans-serif; font-size:150%; color:#666666; margin-top: 4%; margin-left: 2%; /*top: -2%;/ /* line-height: 3%; */ } #seventh{ position: absolute; top: 11%; color: #808080; font-family: sans-serif; font-size: 80%; margin-left: 1.8%; margin-top: 1.5%; /*line-height: 3%;*/ } #fort{ float: right; margin-top: -65px; margin-right: 80px; } #button{ margin-left: 80%; width: 20%; hyphens: 20%; } the java script is not working on this html page.look at the id "bad",initially it's value is none ,but when **click on** the image it need to be displayed.that is given inside the script document.getElementById("bad").style.display="block".
0debug
Can I use library that used android support with Androidx projects. : <p>I know, <a href="https://stackoverflow.com/questions/50387207/error-while-merging-dex-program-type-already-present-android-support-v4-os-resu">androidx and support dependency causing multidex error</a> We can not use androidx and android support at a same time. So I totally migrate to androidx. but one of my dependency lib used android support "lottie".</p> <p>What can we do in above situation? Should I remove 'lottie' from my project.</p> <p>below is my gradle</p> <pre><code>defaultConfig { minSdkVersion 19 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true multiDexEnabled true } ext{ lottieVersion = "2.5.4" } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" def androidx = "1.0.0-rc01" api "androidx.constraintlayout:constraintlayout:1.1.2" api "androidx.appcompat:appcompat:$androidx" api "androidx.recyclerview:recyclerview:$androidx" api "androidx.cardview:cardview:$androidx" api "androidx.core:core-ktx:$androidx" api "com.google.android.material:material:1.0.0-rc01" implementation "com.google.code.gson:gson:2.8.5" implementation "androidx.multidex:multidex:2.0.0" implementation "com.airbnb.android:lottie:$lottieVersion" } </code></pre>
0debug
static void mirror_complete(BlockJob *job, Error **errp) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); int ret; ret = bdrv_open_backing_file(s->target); if (ret < 0) { char backing_filename[PATH_MAX]; bdrv_get_full_backing_filename(s->target, backing_filename, sizeof(backing_filename)); error_set(errp, QERR_OPEN_FILE_FAILED, backing_filename); return; } if (!s->synced) { error_set(errp, QERR_BLOCK_JOB_NOT_READY, job->bs->device_name); return; } s->should_complete = true; block_job_resume(job); }
1threat
How to test type of thrown exception in Jest : <p>I'm working with some code where I need to test type of exception thrown by function (Is it TypeError, ReferenceError etc.).</p> <p>My current testing framework is AVA and I can test it as a second argument <code>t.throws</code> method, like here:</p> <pre class="lang-js prettyprint-override"><code>it('should throw Error with message \'UNKNOWN ERROR\' when no params were passed', (t) =&gt; { const error = t.throws(() =&gt; { throwError(); }, TypeError); t.is(error.message, 'UNKNOWN ERROR'); }); </code></pre> <p>I started rewriting my tests to Jest and couldn't find how to easily do that. Is it even possible?</p>
0debug
ListView is null, why? : <p>In a fragment I am trying to set up a list view. In <code>onCreateView()</code> :</p> <pre><code>mFindFriendsOptionsListView = (ListView) view.findViewById(R.id.find_friends_list_view); mFindFriendsOptionsAdapter = new FindFriendsOptionsAdapter(mFindFriendOptionIconIds, mFindFriendOptionTitles, mFindFriendOptionDescription); mFindFriendsOptionsListView.setAdapter(mFindFriendsOptionsAdapter); </code></pre> <p>Here is the xml for the list view:</p> <pre><code>&lt;ListView android:id="@+id/find_friends_options_list_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="32dp" android:layout_alignParentTop="true" android:divider="#999999" android:dividerHeight="1dp"/&gt; </code></pre> <p>Here is the list element xml file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;ImageView android:layout_width="60dp" android:layout_height="60dp" android:id="@+id/option_icon_image_view" android:layout_marginRight="16dp" android:layout_marginEnd="16dp" android:layout_marginStart="16dp" android:layout_marginLeft="16dp"/&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_vertical"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/option_title_text_view" tools:text="Contacts" android:textSize="18sp" android:layout_marginBottom="6dp"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/option_description_text_view" tools:text="Upload contacts to be your friends" android:textSize="14sp"/&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;ImageView android:layout_width="20dp" android:layout_height="20dp" android:id="@+id/arrow_image_view" android:layout_centerVertical="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_marginRight="8dp" android:layout_marginEnd="8dp" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Here is the stacktrace:</p> <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at com.hb.birthpay.fragment.FindFriendFragment.onCreateView(FindFriendFragment.java:66) </code></pre> <p>I have debugged and the field <code>mFindFriendOptionsListView</code> is <code>null</code> even though I set it using <code>findViewById()</code>. Why is the ListView field null and how do I fix this so that I no longer get a <code>java.lang.NullPointerException</code>?</p>
0debug
Convert string like "10/2" to integer value in swift : <p>How can I convert a string value like "100/2" or "-200/2" or "" to integer value.</p> <p>I have tried converting with Int("100/2")</p>
0debug
How can i remove the extra quotes from each column value using spark : **Removing extra quotes from each column values, following are my column values** Array[Array[String]] = Array(Array("58, ""management"", ""married"", ""tertiary"", ""no"", 2143, ""yes"", ""no"", ""unknown"", 5, ""may"", 261, 1, -1, 0, ""unknown"", ""no"""), Array("4 4, ""technician"", ""single"", ""secondary"", ""no"", 29, ""yes"", ""no"", ""unknown"", 5, ""may"", 151, 1, -1, 0, ""unknown"", ""no"""), Array("33, ""entrepreneur"", ""married"", ""secondary "", ""no"", 2, ""yes"", ""yes"", ""unknown"", 5, ""may"", 76, 1, -1, 0, ""unknown"", ""no"""), ... **Expected output:** Array[Array[String]] = Array(Array(58, management, married, tertiary, no, 2143, yes, no, unknown, 5, may, 261, 1, -1, 0, unknown, no), Array(44, technician, single, secondary, no, 29, yes, no, unknown, 5, may, 151, 1, -1, 0, unknown, no), Array(33, entrepreneur, married, secondary, no, 2, yes, yes, unknown, 5, may, 76, 1, -1, 0, unknown, no),.. Thanks in advance.
0debug
Android - How to add dynamic row Item in activity and able to access its ids : [After click on + icon , a new row should add dynamically and able to access its ids. Please give suggestions to implement it][1] [1]: https://i.stack.imgur.com/QFoQC.png
0debug
why is [ ]==0 in java script? : <pre><code>Code: a=[1,2]; b=[]; if(b==0){ console.log('0') } if(a==2){ console.log('2') } if([]==0){ console.log('3') } Output: 0 3 </code></pre> <p>in case if [ ] is considered as an array of length 0 and == is comparing [ ] to its length.Why is [1,2]==2 false?</p>
0debug
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame) { int ret; av_frame_unref(frame); if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec)) return AVERROR(EINVAL); if (avctx->codec->receive_frame) { if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) return AVERROR_EOF; return avctx->codec->receive_frame(avctx, frame); } if (!avctx->internal->buffer_frame->buf[0]) { if (!avctx->internal->buffer_pkt->size && !avctx->internal->draining) return AVERROR(EAGAIN); while (1) { if ((ret = do_decode(avctx, avctx->internal->buffer_pkt)) < 0) { av_packet_unref(avctx->internal->buffer_pkt); return ret; } if (avctx->internal->buffer_frame->buf[0] || !avctx->internal->buffer_pkt->size) break; } } if (!avctx->internal->buffer_frame->buf[0]) return avctx->internal->draining ? AVERROR_EOF : AVERROR(EAGAIN); av_frame_move_ref(frame, avctx->internal->buffer_frame); return 0; }
1threat
i have this method that converts bytes to String, can somebody help me modify it so that it can convert the String to bytes please? : private static String bytesToString(byte[] encrypted) { //above method converts bytes to string String test = ""; for (byte b : encrypted) { test += Byte.toString(b); } return test; } i have this method that converts bytes to String, can somebody help me modify it so that it can convert the String to bytes please?
0debug
How to use magnifying glass with Qualtrics? : <p>I want to implement magnifying glass logic with image in Qualtrics Survey.I tried some code but this is my first time trying this feature. </p>
0debug
Visual Basic (Using Visual Studio 2017) : I am brand new to Visual Basic and am a little lost. I was trying to import what I thought was correct to be able to use classes that seem to pop up when using VBA macro functions. Right now my code is not recognizing Workbooks. My main goal is to simply use a Visual Studio Windows Form in Visual Basic to open an excel file in a specific directory using a name that is typed in the text box, and save-as into a .txt file. It seems like I am missing a major import or COM reference. Any help? Imports Microsoft.Office.Interop Imports Microsoft.VisualBasic Public Class Form1 Dim path As String = "C:\Users\Dustin\Desktop\" Dim filename1 As String Private Sub txtBoxExcelFileNameString_TextChanged(sender As Object, e As EventArgs) Handles txtBoxExcelFileNameString.TextChanged filename1 = txtBoxExcelFileNameString.Text End Sub Private Sub btnExcelSaveAs_Click(sender As Object, e As EventArgs) Handles btnExcelSaveAs.Click Workbooks.Open Filename:=path & filename1 End Sub End Class [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/ApV7l.png
0debug
static void vhost_set_memory(MemoryListener *listener, MemoryRegionSection *section, bool add) { struct vhost_dev *dev = container_of(listener, struct vhost_dev, memory_listener); hwaddr start_addr = section->offset_within_address_space; ram_addr_t size = int128_get64(section->size); bool log_dirty = memory_region_is_logging(section->mr); int s = offsetof(struct vhost_memory, regions) + (dev->mem->nregions + 1) * sizeof dev->mem->regions[0]; void *ram; dev->mem = g_realloc(dev->mem, s); if (log_dirty) { add = false; } assert(size); ram = memory_region_get_ram_ptr(section->mr) + section->offset_within_region; if (add) { if (!vhost_dev_cmp_memory(dev, start_addr, size, (uintptr_t)ram)) { return; } } else { if (!vhost_dev_find_reg(dev, start_addr, size)) { return; } } vhost_dev_unassign_memory(dev, start_addr, size); if (add) { vhost_dev_assign_memory(dev, start_addr, size, (uintptr_t)ram); } else { vhost_dev_unassign_memory(dev, start_addr, size); } dev->mem_changed_start_addr = MIN(dev->mem_changed_start_addr, start_addr); dev->mem_changed_end_addr = MAX(dev->mem_changed_end_addr, start_addr + size - 1); dev->memory_changed = true; }
1threat
How do You write a code for Unit Testing winform keypress and Button Events : private void Phonenumber_KeyPress(object sender, KeyPressEventArgs e) { char ch = e.KeyChar; if (!char.IsDigit(ch) && (ch != 8)) { e.Handled = true; } }private void Submit_Click(object sender, EventArgs e) { //sql commands messagebox.show("data added successfully"); }
0debug
int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset) { struct kvm_signal_mask *sigmask; int r; if (!sigset) { return kvm_vcpu_ioctl(cpu, KVM_SET_SIGNAL_MASK, NULL); } sigmask = g_malloc(sizeof(*sigmask) + sizeof(*sigset)); sigmask->len = 8; memcpy(sigmask->sigset, sigset, sizeof(*sigset)); r = kvm_vcpu_ioctl(cpu, KVM_SET_SIGNAL_MASK, sigmask); g_free(sigmask); return r; }
1threat
static void pci_set_irq(void *opaque, int irq_num, int level) { PCIDevice *pci_dev = opaque; PCIBus *bus; int change; change = level - pci_dev->irq_state[irq_num]; if (!change) return; pci_dev->irq_state[irq_num] = level; for (;;) { bus = pci_dev->bus; irq_num = bus->map_irq(pci_dev, irq_num); if (bus->set_irq) break; pci_dev = bus->parent_dev; } bus->irq_count[irq_num] += change; bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0); }
1threat
static void restore_median_il(uint8_t *src, int step, int stride, int width, int height, int slices, int rmode) { int i, j, slice; int A, B, C; uint8_t *bsrc; int slice_start, slice_height; const int cmask = ~(rmode ? 3 : 1); const int stride2 = stride << 1; for (slice = 0; slice < slices; slice++) { slice_start = ((slice * height) / slices) & cmask; slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start; slice_height >>= 1; bsrc = src + slice_start * stride; bsrc[0] += 0x80; A = bsrc[0]; for (i = step; i < width * step; i += step) { bsrc[i] += A; A = bsrc[i]; } for (i = 0; i < width * step; i += step) { bsrc[stride + i] += A; A = bsrc[stride + i]; } bsrc += stride2; if (slice_height == 1) C = bsrc[-stride2]; bsrc[0] += C; A = bsrc[0]; for (i = step; i < width * step; i += step) { B = bsrc[i - stride2]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i]; } for (i = 0; i < width * step; i += step) { B = bsrc[i - stride]; bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[stride + i]; } bsrc += stride2; for (j = 2; j < slice_height; j++) { for (i = 0; i < width * step; i += step) { B = bsrc[i - stride2]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i]; } for (i = 0; i < width * step; i += step) { B = bsrc[i - stride]; bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i + stride]; } bsrc += stride2; } } }
1threat
unkown column in where clause? : MY CODE: drop table if exists HSstudents; create table HSstudents (HSsID int, vNAAM text, aNAAM text, LT int, GM float); insert into HSstudents values (1, 'Thomas', 'Jansen', 18, 7.0); insert into HSstudents values (2, 'Jesse', 'Bakker', 19, 6.5); insert into HSstudents values (3, 'Tom', 'Smit', 20, 7.1); insert into HSstudents values (4, 'Jelle', 'Visser', 17, 9.6); insert into HSstudents values (5, 'Sem', 'Dekker', 17, 8.1); insert into HSstudents values (6, 'Anna', 'Peters', 18, 6.8); insert into HSstudents values (7, 'Michelle', 'Hendriks', 19, 8.2); insert into HSstudents values (8, 'Senna', 'Mulder', 20, 5.9); insert into HSstudents values (9, 'Sven', 'Linden', 21, 6.0); insert into HSstudents values (10, 'Ilse', 'Jacobs', 21, 7.5); insert into HSstudents values (11, 'Harm', 'Schouten', 19, 7.0); insert into HSstudents values (12, 'Emma', 'Dijkstra', 18, 8.1); drop table if exists students; create table students (sID int, vNAAM text, aNAAM text, LT int); insert into students values (1, 'Thomas', 'Jansen', 18); insert into students values (2, 'Jesse', 'Bakker', 19); insert into students values (3, 'Tom', 'Smit', 20); insert into students values (4, 'Jelle', 'Visser', 17); insert into students values (5, 'Sem', 'Dekker', 17); insert into students values (6, 'Anna', 'Peters', 18); insert into students values (7, 'Michelle', 'Hendriks', 19); insert into students values (8, 'Senna', 'Mulder', 20); insert into students values (9, 'Sven', 'Linden', 21); insert into students values (10, 'Ilse', 'Jacobs', 21); insert into students values (11, 'Harm', 'Schouten', 19); insert into students values (12, 'Emma', 'Dijkstra', 18); drop table if exists applications; create table applications (sID int, aPROV text, sPROV text, taal text); insert into applications values (1, 'Overijssel', 'Drenthe', 'HTML'); insert into applications values (2, 'Gelderland', 'Overijssel', 'CSS'); insert into applications values (3, 'Groningen', 'Flevoland', 'CSS'); insert into applications values (4, 'Overijssel', 'Zuid-Holland', 'SQL'); insert into applications values (5, 'Noord-Holland', 'Drenthe', 'C#'); insert into applications values (6, 'Flevoland', 'Groningen', 'C#'); insert into applications values (7, 'Limburg', 'Groningen', 'JAVA'); insert into applications values (8, 'Limburg', 'Limburg', 'JAVASCRIPT'); insert into applications values (9, 'Drenthe', 'Noord-Brabant', 'CSS'); insert into applications values (10, 'Drenthe', 'Zeeland', 'Python'); insert into applications values (11, 'Zuid-Holland', 'Friesland', 'C++'); insert into applications values (12, 'Zeeland', 'Friesland', 'JAVA'); select S.sID, S.vNAAM, S.aNAAM, S.LT, aPROV, sPROV, taal from HSstudents HS, students S, applications A where HSstudents.HSsID = students.sID RESULT: Error Code: 1054. Unknown column 'HSstudents.HSsID' in 'where clause' How? Shouldn't it just work?
0debug
the intent is not opening,in both conditions the default one executes.i have tried from if else statement too but got the same result : StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Override public void onResponse(String response) { //If we are getting success from server switch (response) { case "success": { Intent intent = new Intent(getApplicationContext(), MainActivity.class); startActivity(intent); } default: Toast.makeText(getApplicationContext(),response,Toast.LENGTH_LONG).show(); } }
0debug
static void nested_struct_compare(UserDefTwo *udnp1, UserDefTwo *udnp2) { g_assert(udnp1); g_assert(udnp2); g_assert_cmpstr(udnp1->string0, ==, udnp2->string0); g_assert_cmpstr(udnp1->dict1->string1, ==, udnp2->dict1->string1); g_assert_cmpint(udnp1->dict1->dict2->userdef->base->integer, ==, udnp2->dict1->dict2->userdef->base->integer); g_assert_cmpstr(udnp1->dict1->dict2->userdef->string, ==, udnp2->dict1->dict2->userdef->string); g_assert_cmpstr(udnp1->dict1->dict2->string, ==, udnp2->dict1->dict2->string); g_assert(udnp1->dict1->has_dict3 == udnp2->dict1->has_dict3); g_assert_cmpint(udnp1->dict1->dict3->userdef->base->integer, ==, udnp2->dict1->dict3->userdef->base->integer); g_assert_cmpstr(udnp1->dict1->dict3->userdef->string, ==, udnp2->dict1->dict3->userdef->string); g_assert_cmpstr(udnp1->dict1->dict3->string, ==, udnp2->dict1->dict3->string); }
1threat
npm script, copy package.json to dist when bundling : <p>I am trying to add a second part to my npm bundle script. The first part runs great, however I am trying to copy in 3 files along with the bundle.</p> <p>So right now I have :</p> <pre><code>"bundle": "NODE_ENV=production webpack --output-file bundledFile.js &amp;&amp; cp package.json dist/", </code></pre> <p>The <code>NODE_ENV=production webpack --output-file bundledFile.js</code> works great by itself. The part that is not working is the <code>&amp;&amp; cp package.json dist/</code>, I would like the script to copy my package.json (along with 2 other files actually, but just starting with this one) to the dist folder. Brand new to these scripts, any idea how to fix? Appreciate any advice, thanks!</p>
0debug
void bareetraxfs_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) { DeviceState *dev; SysBusDevice *s; CPUState *env; qemu_irq irq[30], nmi[2], *cpu_irq; void *etraxfs_dmac; struct etraxfs_dma_client *eth[2] = {NULL, NULL}; int kernel_size; DriveInfo *dinfo; int i; ram_addr_t phys_ram; ram_addr_t phys_flash; ram_addr_t phys_intmem; if (cpu_model == NULL) { cpu_model = "crisv32"; } env = cpu_init(cpu_model); qemu_register_reset(main_cpu_reset, env); phys_ram = qemu_ram_alloc(ram_size); cpu_register_physical_memory(0x40000000, ram_size, phys_ram | IO_MEM_RAM); phys_intmem = qemu_ram_alloc(INTMEM_SIZE); cpu_register_physical_memory(0x38000000, INTMEM_SIZE, phys_intmem | IO_MEM_RAM); phys_flash = qemu_ram_alloc(FLASH_SIZE); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi02_register(0x0, phys_flash, dinfo ? dinfo->bdrv : NULL, (64 * 1024), FLASH_SIZE >> 16, 1, 2, 0x0000, 0x0000, 0x0000, 0x0000, 0x555, 0x2aa); cpu_irq = cris_pic_init_cpu(env); dev = qdev_create(NULL, "etraxfs,pic"); qdev_prop_set_ptr(dev, "interrupt_vector", &env->interrupt_vector); qdev_init(dev); s = sysbus_from_qdev(dev); sysbus_mmio_map(s, 0, 0x3001c000); sysbus_connect_irq(s, 0, cpu_irq[0]); sysbus_connect_irq(s, 1, cpu_irq[1]); for (i = 0; i < 30; i++) { irq[i] = qdev_get_gpio_in(dev, i); } nmi[0] = qdev_get_gpio_in(dev, 30); nmi[1] = qdev_get_gpio_in(dev, 31); etraxfs_dmac = etraxfs_dmac_init(0x30000000, 10); for (i = 0; i < 10; i++) { etraxfs_dmac_connect(etraxfs_dmac, i, irq + 7 + i, i & 1); } eth[0] = etraxfs_eth_init(&nd_table[0], 0x30034000, 1); if (nb_nics > 1) eth[1] = etraxfs_eth_init(&nd_table[1], 0x30036000, 2); etraxfs_dmac_connect_client(etraxfs_dmac, 0, eth[0]); etraxfs_dmac_connect_client(etraxfs_dmac, 1, eth[0] + 1); if (eth[1]) { etraxfs_dmac_connect_client(etraxfs_dmac, 6, eth[1]); etraxfs_dmac_connect_client(etraxfs_dmac, 7, eth[1] + 1); } sysbus_create_varargs("etraxfs,timer", 0x3001e000, irq[0x1b], nmi[1], NULL); sysbus_create_varargs("etraxfs,timer", 0x3005e000, irq[0x1b], nmi[1], NULL); for (i = 0; i < 4; i++) { sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000, irq[0x14 + i]); } if (kernel_filename) { uint64_t entry, high; int kcmdline_len; kernel_size = load_elf(kernel_filename, -0x80000000LL, &entry, NULL, &high, 0, ELF_MACHINE, 0); bootstrap_pc = entry; if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, 0x40004000, ram_size); bootstrap_pc = 0x40004000; env->regs[9] = 0x40004000 + kernel_size; } env->regs[8] = 0x56902387; if (kernel_cmdline && (kcmdline_len = strlen(kernel_cmdline))) { if (kcmdline_len > 256) { fprintf(stderr, "Too long CRIS kernel cmdline (max 256)\n"); exit(1); } env->regs[10] = 0x87109563; env->regs[11] = 0x40000000; pstrcpy_targphys(env->regs[11], 256, kernel_cmdline); } } env->pc = bootstrap_pc; printf ("pc =%x\n", env->pc); printf ("ram size =%ld\n", ram_size); }
1threat
npm test -- --coverage never exits : <p>I am using <strong>create-react-app</strong> to create a react application. When I executes <strong>npm test -- --coverage</strong> the test never exists. npm test actually runs <strong>react-scripts test</strong>. Any Idea?</p> <p><a href="https://i.stack.imgur.com/ooy7Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ooy7Y.png" alt="enter image description here"></a></p>
0debug
static int svq1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MpegEncContext *s = avctx->priv_data; uint8_t *current, *previous; int result, i, x, y, width, height; AVFrame *pict = data; svq1_pmv *pmv; init_get_bits(&s->gb, buf, buf_size * 8); s->f_code = get_bits(&s->gb, 22); if ((s->f_code & ~0x70) || !(s->f_code & 0x60)) return AVERROR_INVALIDDATA; if (s->f_code != 0x20) { uint32_t *src = (uint32_t *)(buf + 4); if (buf_size < 36) return AVERROR_INVALIDDATA; for (i = 0; i < 4; i++) src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i]; } result = svq1_decode_frame_header(&s->gb, s); if (result != 0) { av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n", result); return result; } avcodec_set_dimensions(avctx, s->width, s->height); if (s->pict_type == AV_PICTURE_TYPE_B && s->last_picture_ptr == NULL) return buf_size; if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return buf_size; if ((result = ff_MPV_frame_start(s, avctx)) < 0) return result; pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv)); if (!pmv) return AVERROR(ENOMEM); for (i = 0; i < 3; i++) { int linesize; if (i == 0) { width = FFALIGN(s->width, 16); height = FFALIGN(s->height, 16); linesize = s->linesize; } else { if (s->flags & CODEC_FLAG_GRAY) break; width = FFALIGN(s->width / 4, 16); height = FFALIGN(s->height / 4, 16); linesize = s->uvlinesize; } current = s->current_picture.f.data[i]; if (s->pict_type == AV_PICTURE_TYPE_B) previous = s->next_picture.f.data[i]; else previous = s->last_picture.f.data[i]; if (s->pict_type == AV_PICTURE_TYPE_I) { for (y = 0; y < height; y += 16) { for (x = 0; x < width; x += 16) { result = svq1_decode_block_intra(&s->gb, &current[x], linesize); if (result != 0) { av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n", result); goto err; } } current += 16 * linesize; } } else { memset(pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv)); for (y = 0; y < height; y += 16) { for (x = 0; x < width; x += 16) { result = svq1_decode_delta_block(s, &s->gb, &current[x], previous, linesize, pmv, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_decode_delta_block %i\n", result); goto err; } } pmv[0].x = pmv[0].y = 0; current += 16 * linesize; } } } *pict = s->current_picture.f; ff_MPV_frame_end(s); *data_size = sizeof(AVFrame); result = buf_size; err: av_free(pmv); return result; }
1threat
flask does not see change in .js file : <p>I made a change on one of the <code>.js</code> files that I use and no matter what I do, flask insists on picking up, from memory cache, the last version of the file, without the change.</p> <p>To clarify, I have the following structure. It all starts with <code>foo.html</code></p> <pre><code>return render_template foo.html </code></pre> <p><code>foo.html</code> has a form inside that calls flask with some data and then returns a second template <code>bar.html</code>:</p> <pre><code>return render_template bar.html </code></pre> <p>This second template calls some <code>.js</code> file, placed in the <code>static</code> folder, but it doesn't update when the code changes.</p> <p>I mention the structure above because if the <code>.js</code> file was placed on <code>foo.html</code> instead of <code>bar.html</code> then Flask <strong>would</strong> pick up the new changes on the file. But in <code>bar.html</code> Flask completely ignores them.</p> <p>What is happening? </p> <p>The only thing that worked was to click on "disable cache" on the browser and reload again.</p>
0debug
Find value of a Key in nested JSON using underscore : Hi I have a JSON object that look like this: var data={ req:{ id:1, name:"daniel", details:{ address:"201 sd f", city: "dshed" } }, ack:"Success" } Now I want to get the value of key "ack". Does anyone know how to get value of ack using underscore?
0debug
static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce) { return !(iova & ~(vtd_iova_limit(ce) - 1)); }
1threat
void virtio_queue_notify(VirtIODevice *vdev, int n) { if (n < VIRTIO_PCI_QUEUE_MAX) { virtio_queue_notify_vq(&vdev->vq[n]); } }
1threat
static void qobject_input_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); QObject *qobj = qobject_input_get_object(qiv, name, true, errp); QInt *qint; if (!qobj) { return; } qint = qobject_to_qint(qobj); if (!qint) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "integer"); return; } *obj = qint_get_int(qint); }
1threat
void do_mouse_set(Monitor *mon, const QDict *qdict) { QemuInputHandlerState *s; int index = qdict_get_int(qdict, "index"); int found = 0; QTAILQ_FOREACH(s, &handlers, node) { if (s->id == index) { found = 1; qemu_input_handler_activate(s); break; } } if (!found) { monitor_printf(mon, "Mouse at given index not found\n"); } qemu_input_check_mode_change(); }
1threat
Java stack and heap memory management : <p>I want to know how the memory is being allocated in the following program:</p> <pre><code>public class MemoryClass { public static void main(final String[] args) { int i = 0; MemoryClass memoryClass = new MemoryClass(); memoryClass.myMethod(memoryClass); } private void myMethod(final Object obj) { int i = 1; String s = "HelloWorld!"; } } </code></pre> <p>Now, as far as my understanding goes, the following diagram describes how the memory allocation takes place:<br> <a href="https://i.stack.imgur.com/4Ttvc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4Ttvc.png" alt="Basic runtime memory allocation"></a></p> <p><br> In the above diagram, <strong>memory</strong>,<strong>obj</strong> and <strong>s</strong>, which are in the stack memory, are actually the references to their "<strong>actual objects</strong>" which are placed inside the heap memory. <br> Here is the set of questions that come to my mind:</p> <ol> <li>Where are the methods of <strong>s</strong> stored?</li> <li>Had I created another object of <code>MemoryClass</code> inside <code>myMethod</code>, would JVM allocate memory for the same methods again inside the stack memory?</li> <li>Would JVM free the memory allocated to <code>myMethod</code> as soon as it's execution is completed, if so, how would it manage the situation mentioned in question 2(<em>only applicable if JVM allocates memory multiple times to the same method</em>).</li> <li>What would have been the case, if I had only declared <strong>s</strong> and did not initialize it, would JVM still allocate memory to all the methods of <code>java.lang.String</code> class,if so,why?</li> </ol>
0debug
How to access/expose kubernetes-dashboard service outside of a cluster? : <p>I have got the following services:</p> <pre><code>ubuntu@master:~$ kubectl get services --all-namespaces NAMESPACE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE default kubernetes 100.64.0.1 &lt;none&gt; 443/TCP 48m kube-system kube-dns 100.64.0.10 &lt;none&gt; 53/UDP,53/TCP 47m kube-system kubernetes-dashboard 100.70.83.136 &lt;nodes&gt; 80/TCP 47m </code></pre> <p>I am attempting to access kubernetes dashboard. The following response seems reasonable, taking into account curl is not a browser.</p> <pre><code>ubuntu@master:~$ curl 100.70.83.136 &lt;!doctype html&gt; &lt;html ng-app="kubernetesDashboard"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Kubernetes Dashboard&lt;/title&gt; &lt;link rel="icon" type="image/png" href="assets/images/kubernetes-logo.png"&gt; &lt;meta name="viewport" content="width=device-width"&gt; &lt;link rel="stylesheet" href="static/vendor.36bb79bb.css"&gt; &lt;link rel="stylesheet" href="static/app.d2318302.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;!--[if lt IE 10]&gt; &lt;p class="browsehappy"&gt;You are using an &lt;strong&gt;outdated&lt;/strong&gt; browser. Please &lt;a href="http://browsehappy.com/"&gt;upgrade your browser&lt;/a&gt; to improve your experience.&lt;/p&gt; &lt;![endif]--&gt; &lt;kd-chrome layout="column" layout-fill&gt; &lt;/kd-chrome&gt; &lt;script src="static/vendor.633c6c7a.js"&gt;&lt;/script&gt; &lt;script src="api/appConfig.json"&gt;&lt;/script&gt; &lt;script src="static/app.9ed974b1.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>According to the documentation the right access point is <a href="https://localhost/ui" rel="noreferrer">https://localhost/ui</a>. So, I am trying it and receive a bit worrying result. <strong>Is it expected response?</strong></p> <pre><code>ubuntu@master:~$ curl https://localhost/ui curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. </code></pre> <p>Trying the same without certificate validation. For curl it might be OK. but I have got the same in a browser, which is connecting though port forwarding via vagrant forwarded_port option.</p> <pre><code>ubuntu@master:~$ curl -k https://localhost/ui Unauthorized </code></pre> <p><strong>What I am doing wrong? and how to make sure I can access the UI?</strong> Currently it responds with Unauthorized.</p> <p>The docs for the dashboard tell the password is in the configuration:</p> <pre><code>ubuntu@master:~$ kubectl config view apiVersion: v1 clusters: [] contexts: [] current-context: "" kind: Config preferences: {} users: [] </code></pre> <p>but it seems I have got nothing... <strong>Is it expected behavior? How can I authorize with the UI?</strong></p>
0debug
Data analysis in python : <p>I have to make two data analysis reports using descriptive statistics, making plenty of informative plots etc. </p> <p>Problem is, I'm not sure what tools should I use? I started preparing one report in Jupyter Notebook using pandas, scipy.stats and matplotlib with intention to convert it somehow to pdf later on, so I can have report without code. After hour or two I realized it might not be the best idea. I even had problem with making good description of categorical data, since pandas <code>describe()</code> had limited functionality on this type of data.</p> <p>Could you suggest me some tools that would be best in this case? I want to prepare aesthetic, informative report. It's my first time doing data analysis including preparing report.</p>
0debug
static av_cold int pcx_end(AVCodecContext *avctx) { PCXContext *s = avctx->priv_data; if(s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); return 0; }
1threat
Counting sub-strings : <p>If you want to count the number of occurrences of one string inside another, which approach is better in terms of simplicity and/or performance? - </p> <ul> <li>using <code>indexOf</code> in a <code>for</code>/<code>while</code> loop</li> <li>using a regular expression</li> </ul> <p>And if it is the latter, then what is the best way to do it?</p>
0debug
Clean data in scala : <p>How to remove '[', ']' and white space from the following data -</p> <pre><code>val fileMat = Array("[1.0, 6.0]", "[2.0, 8.0]", "[3.0, 10.0]", "[3.0, 10.0]", "[4.0, 12.0]", "[5.0, 14.0]" ) </code></pre>
0debug
How to Add StockItem to list : <p>I have this code for my test, can you please help me</p> <p>1) A barcode label on a box in our warehouse has the following format HKGB43563PC5 The first 3 characters are always the country code, and the last 3 relate to the number of pieces. The value in the middle may vary in length, and may be a combination of letters and numbers in no particular order.</p> <p>A <code>List&lt;T&gt;</code> has already been declared in the main application, you can assume it is accessible from both the class and the method.</p> <pre><code>List&lt;StockItems&gt; stockList = new List&lt;StockItems&gt;(); </code></pre> <p>Write code that would replace the comments in the method and the class below to ensure that the list gets populated.</p> <pre><code>Private void AddStockItemToList(string barcode) { //ToDo Parse the string and add the items to the list. } public class StockItems { public int Quantity; public string OriginCountryCode; public string StockItemReference public Items(int qty, string country, string reference) { // } } </code></pre>
0debug
static void test_init(void) { uint64_t barsize; dev = get_device(); dev_base = qpci_iomap(dev, 0, &barsize); g_assert(dev_base != NULL); qpci_device_enable(dev); test_timer(); }
1threat
static int ogg_write_packet(AVFormatContext *avfcontext, int stream_index, const uint8_t *buf, int size, int64_t pts) { OggContext *context = avfcontext->priv_data ; AVCodecContext *avctx= &avfcontext->streams[stream_index]->codec; ogg_packet *op= &context->op; ogg_page og ; pts= av_rescale(pts, avctx->sample_rate, AV_TIME_BASE); if(!size){ return 0; } if(!context->header_handled) { while(ogg_stream_flush(&context->os, &og)) { put_buffer(&avfcontext->pb, og.header, og.header_len) ; put_buffer(&avfcontext->pb, og.body, og.body_len) ; put_flush_packet(&avfcontext->pb); } context->header_handled = 1 ; } op->packet = (uint8_t*) buf; op->bytes = size; op->b_o_s = op->packetno == 0; op->granulepos= pts; ogg_stream_packetin(&context->os, op); while(ogg_stream_pageout(&context->os, &og)) { put_buffer(&avfcontext->pb, og.header, og.header_len); put_buffer(&avfcontext->pb, og.body, og.body_len); put_flush_packet(&avfcontext->pb); } op->packetno++; return 0; }
1threat
static bool version_is_5(void *opaque, int version_id) { return version_id == 5; }
1threat
Webpack Express Cannot Resolve Module 'fs', Request Dependency is Expression : <p>When I include Express in my project I always get these errors when I try to build with webpack.</p> <p>webpack.config.dev.js</p> <pre><code>var path = require("path") module.exports = { entry: { "server": "./server/server.ts" }, output: { path: path.resolve(__dirname, "dist"), filename: "bundle.js", publicPath: "/public/" }, module: { loaders: [ { test: /\.ts(x?)$/, exclude: /node_modules/, loader: "ts-loader" }, { test: /\.js(x?)$/, exclude: /node_modules/, loader: "babel-loader" }, { test: /\.json$/, loader: "json-loader" }, { test: /\.scss$/, exclude: /node_modules/, loaders: ["style-loader", "css-loader", "postcss-loader", "sass-loader"] }, { test: /\.css$/, loader: ["style-loader", "css-loader", "postcss-loader"] }, { test: /\.(jpe?g|gif|png|svg)$/i, loader: 'url-loader?limit=10000' } ] } } </code></pre> <p>I've tried:</p> <ol> <li>Installing 'fs' but it doesn't work</li> <li><p>Read somewhere to change the node fs property. It removes the error warnings but I don't think this is a good permanent solution.</p> <pre><code>module.exports = { node: { fs: "empty" } } </code></pre> <p>Time: 2496ms Asset Size Chunks Chunk Names bundle.js 761 kB 0 [emitted] server bundle.js.map 956 kB 0 [emitted] server + 119 hidden modules</p> <p>WARNING in ./~/express/lib/view.js Critical dependencies: 78:29-56 the request of a dependency is an expression @ ./~/express/lib/view.js 78:29-56 ERROR in ./~/express/lib/view.js</p> <p>Module not found: Error: Cannot resolve module 'fs' in /Users/clementoh/Desktop/boilerplate2/node_modules/express/lib @ ./~/express/lib/view.js 18:9-22 ERROR in ./~/send/index.js</p> <p>Module not found: Error: Cannot resolve module 'fs' in /Users/clementoh/Desktop/boilerplate2/node_modules/send @ ./~/send/index.js 24:9-22 ERROR in ./~/etag/index.js</p> <p>Module not found: Error: Cannot resolve module 'fs' in /Users/clementoh/Desktop/boilerplate2/node_modules/etag @ ./~/etag/index.js 22:12-25 ERROR in ./~/destroy/index.js</p> <p>Module not found: Error: Cannot resolve module 'fs' in /Users/clementoh/Desktop/boilerplate2/node_modules/destroy @ ./~/destroy/index.js 14:17-30 ERROR in ./~/mime/mime.js</p> <p>Module not found: Error: Cannot resolve module 'fs' in /Users/clementoh/Desktop/boilerplate2/node_modules/mime @ ./~/mime/mime.js 2:9-22</p></li> </ol>
0debug
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, tcg_target_long arg2) { uint8_t *old_code_ptr = s->code_ptr; if (type == TCG_TYPE_I32) { tcg_out_op_t(s, INDEX_op_ld_i32); tcg_out_r(s, ret); tcg_out_r(s, arg1); tcg_out32(s, arg2); } else { assert(type == TCG_TYPE_I64); #if TCG_TARGET_REG_BITS == 64 tcg_out_op_t(s, INDEX_op_ld_i64); tcg_out_r(s, ret); tcg_out_r(s, arg1); assert(arg2 == (uint32_t)arg2); tcg_out32(s, arg2); #else TODO(); #endif } old_code_ptr[1] = s->code_ptr - old_code_ptr; }
1threat
make_setup_request (AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge) { RTSPState *rt = s->priv_data; int rtx, j, i, err, interleave = 0; RTSPStream *rtsp_st; RTSPMessageHeader reply1, *reply = &reply1; char cmd[2048]; const char *trans_pref; if (rt->transport == RTSP_TRANSPORT_RDT) trans_pref = "x-pn-tng"; else trans_pref = "RTP/AVP"; rt->timeout = 60; for(j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) { char transport[2048]; if (lower_transport == RTSP_LOWER_TRANSPORT_UDP && rt->server_type == RTSP_SERVER_WMS) { if (i == 0) { for (rtx = 0; rtx < rt->nb_rtsp_streams; rtx++) { int len = strlen(rt->rtsp_streams[rtx]->control_url); if (len >= 4 && !strcmp(rt->rtsp_streams[rtx]->control_url + len - 4, "/rtx")) break; } if (rtx == rt->nb_rtsp_streams) return -1; rtsp_st = rt->rtsp_streams[rtx]; } else rtsp_st = rt->rtsp_streams[i > rtx ? i : i - 1]; } else rtsp_st = rt->rtsp_streams[i]; if (lower_transport == RTSP_LOWER_TRANSPORT_UDP) { char buf[256]; if (rt->server_type == RTSP_SERVER_WMS && i > 1) { port = reply->transports[0].client_port_min; goto have_port; } if (RTSP_RTP_PORT_MIN != 0) { while(j <= RTSP_RTP_PORT_MAX) { snprintf(buf, sizeof(buf), "rtp: j += 2; if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) { goto rtp_opened; } } } rtp_opened: port = rtp_get_local_port(rtsp_st->rtp_handle); have_port: snprintf(transport, sizeof(transport) - 1, "%s/UDP;", trans_pref); if (rt->server_type != RTSP_SERVER_REAL) av_strlcat(transport, "unicast;", sizeof(transport)); av_strlcatf(transport, sizeof(transport), "client_port=%d", port); if (rt->transport == RTSP_TRANSPORT_RTP && !(rt->server_type == RTSP_SERVER_WMS && i > 0)) av_strlcatf(transport, sizeof(transport), "-%d", port + 1); } else if (lower_transport == RTSP_LOWER_TRANSPORT_TCP) { if (rt->server_type == RTSP_SERVER_WMS && s->streams[rtsp_st->stream_index]->codec->codec_type == CODEC_TYPE_DATA) continue; snprintf(transport, sizeof(transport) - 1, "%s/TCP;", trans_pref); if (rt->server_type == RTSP_SERVER_WMS) av_strlcat(transport, "unicast;", sizeof(transport)); av_strlcatf(transport, sizeof(transport), "interleaved=%d-%d", interleave, interleave + 1); interleave += 2; } else if (lower_transport == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) { snprintf(transport, sizeof(transport) - 1, "%s/UDP;multicast", trans_pref); } if (rt->server_type == RTSP_SERVER_REAL || rt->server_type == RTSP_SERVER_WMS) av_strlcat(transport, ";mode=play", sizeof(transport)); snprintf(cmd, sizeof(cmd), "SETUP %s RTSP/1.0\r\n" "Transport: %s\r\n", rtsp_st->control_url, transport); if (i == 0 && rt->server_type == RTSP_SERVER_REAL) { char real_res[41], real_csum[9]; ff_rdt_calc_response_and_checksum(real_res, real_csum, real_challenge); av_strlcatf(cmd, sizeof(cmd), "If-Match: %s\r\n" "RealChallenge2: %s, sd=%s\r\n", rt->session_id, real_res, real_csum); } rtsp_send_cmd(s, cmd, reply, NULL); if (reply->status_code == 461 && i == 0) { err = 1; goto fail; } else if (reply->status_code != RTSP_STATUS_OK || reply->nb_transports != 1) { err = AVERROR_INVALIDDATA; goto fail; } if (i > 0) { if (reply->transports[0].lower_transport != rt->lower_transport || reply->transports[0].transport != rt->transport) { err = AVERROR_INVALIDDATA; goto fail; } } else { rt->lower_transport = reply->transports[0].lower_transport; rt->transport = reply->transports[0].transport; } if (reply->transports[0].lower_transport != RTSP_LOWER_TRANSPORT_UDP && (lower_transport == RTSP_LOWER_TRANSPORT_UDP)) { url_close(rtsp_st->rtp_handle); rtsp_st->rtp_handle = NULL; } switch(reply->transports[0].lower_transport) { case RTSP_LOWER_TRANSPORT_TCP: rtsp_st->interleaved_min = reply->transports[0].interleaved_min; rtsp_st->interleaved_max = reply->transports[0].interleaved_max; break; case RTSP_LOWER_TRANSPORT_UDP: { char url[1024]; snprintf(url, sizeof(url), "rtp: host, reply->transports[0].server_port_min); if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) && rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { err = AVERROR_INVALIDDATA; goto fail; } } break; case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: { char url[1024]; struct in_addr in; int port, ttl; if (reply->transports[0].destination) { in.s_addr = htonl(reply->transports[0].destination); port = reply->transports[0].port_min; ttl = reply->transports[0].ttl; } else { in = rtsp_st->sdp_ip; port = rtsp_st->sdp_port; ttl = rtsp_st->sdp_ttl; } snprintf(url, sizeof(url), "rtp: inet_ntoa(in), port, ttl); if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { err = AVERROR_INVALIDDATA; goto fail; } } break; } if ((err = rtsp_open_transport_ctx(s, rtsp_st))) goto fail; } if (reply->timeout > 0) rt->timeout = reply->timeout; if (rt->server_type == RTSP_SERVER_REAL) rt->need_subscription = 1; return 0; fail: for (i=0; i<rt->nb_rtsp_streams; i++) { if (rt->rtsp_streams[i]->rtp_handle) { url_close(rt->rtsp_streams[i]->rtp_handle); rt->rtsp_streams[i]->rtp_handle = NULL; } } return err; }
1threat
How to reasing and increase the value of string variable : Thank you for your attention, I have the next example in C++: this->name=new char[strlen(nom)+1]; So, I want to know how can I implement this example in java? the class have a : private String name; and I want to implement this method: public void setNombre(String nom) I try to do: this.name= new String(nom.length()+1); In C++: this->name=new char[strlen(nom)+1]; I try to do: this.name= new String(nom.length()+1);
0debug
Can composer generate the `composer.lock` without actually download the packages? : <p>It does exist a command to generate the <code>composer.lock</code> from a <code>composer.json</code>?</p> <p>Something similar ruby's <code>bundler</code> : <code>$ bundle lock</code></p>
0debug
Removing a sublist from a main list without knowing its position in the list : <p>So say i have a 2D list of randomly generated sub lists containing random numbers like this </p> <pre><code>list = [(1,2),(2,3),(3,4),(4,5)] </code></pre> <p>How would I remove the sublist "(2,3)" from the main list if I didn't know its position in the list? I tried using .pop but couldn't make it work without knowing the position of the sublist within the list.</p>
0debug
Regarding recurssive if else block : I am trying to understand how recursive works. Below is a code of If-else block. public class Test { public void test(int count){ if(count ==1){ System.out.println("Inside IF"); } else{ System.out.println("Inside Else"); test(--count); System.out.println("TEST"); } } public static void main(String[] args) { Test t = new Test(); t.test(5); } } The Output for the above code is Inside Else Inside Else Inside Else Inside Else Inside IF TEST TEST TEST TEST Could someone please help me understand why the TEST has been printed 4 times. Thanks
0debug