problem
stringlengths
26
131k
labels
class label
2 classes
How to add fonts for different font weights for react-native android project? : <p>I've managed to add a custom font by:</p> <ul> <li><p>putting *.ttf files in <code>ProjectName/android/app/src/main/assets/fonts/</code> like this:</p> <ul> <li>Open Sans.ttf</li> <li>Open Sans_italic.ttf</li> <li>Open Sans_bold.ttf</li> <li>Open Sans_bold_italic.ttf</li> </ul></li> <li><p>and setting font family by <code>fontFamily: "Open Sans"</code></p></li> </ul> <p>But there are extra font weights I want to use like 'Semi Bold', 'Extra Bold'. I tried adding them as 'Open Sans_900.ttf' and setting <code>fontWeight: 900</code> but that didn't work, it displayed bold version of the font.</p> <p>Is there a way to add these additional font weights?</p>
0debug
static void nvdimm_dsm_get_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in, hwaddr dsm_mem_addr) { NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm); NvdimmFuncGetLabelDataIn *get_label_data; NvdimmFuncGetLabelDataOut *get_label_data_out; uint32_t status; int size; get_label_data = (NvdimmFuncGetLabelDataIn *)in->arg3; le32_to_cpus(&get_label_data->offset); le32_to_cpus(&get_label_data->length); nvdimm_debug("Read Label Data: offset %#x length %#x.\n", get_label_data->offset, get_label_data->length); status = nvdimm_rw_label_data_check(nvdimm, get_label_data->offset, get_label_data->length); if (status != 0 ) { nvdimm_dsm_no_payload(status, dsm_mem_addr); return; } size = sizeof(*get_label_data_out) + get_label_data->length; assert(size <= 4096); get_label_data_out = g_malloc(size); get_label_data_out->len = cpu_to_le32(size); get_label_data_out->func_ret_status = cpu_to_le32(0 ); nvc->read_label_data(nvdimm, get_label_data_out->out_buf, get_label_data->length, get_label_data->offset); cpu_physical_memory_write(dsm_mem_addr, get_label_data_out, size); g_free(get_label_data_out); }
1threat
how to convert foreach to parrallel.foreach in c# : i have a foreach loop like shown below ArrayList list; list = ftp.GetFileList(remotepath<ftp://ftp.getfilelist(remotepath/>); //GExport_EI_DN_G_6542_StarMetroDeiraHotel&Apartment_10.235.155.37_20161120003108.xml.gz foreach (string item in list) { if (item.StartsWith("GExport_") &&(!item.ToUpper().Contains("DUM"))) { path = item; //path = "GExport_EI_DN_G_6542_StarMetroDeiraHotel&Apartment_10.235.155.37_20161120003108.xml.gz"; ftp.Get(dtr["REMOTE_FILE_PATH"].ToString() + path, @localDestnDir + "\\" + dtr["SOURCE_PATH"].ToString()); download_location_hw = dtr["LOCAL_FILE_PATH"].ToString(); // ExtractZipfiles(download_location_hw + "//" + path, dtr["REMOTE_FILE_PATH"].ToString(), dtr["FTP_SERVER"].ToString(), dtr["FTP_USER_ID"].ToString(), dtr["TECH_CODE"].ToString(), dtr["VENDOR_CODE"].ToString()); } } ftp.Close(); i converted in to foreach like shown below without luck ArrayList list; list = ftp.GetFileList(remotepath<ftp://ftp.getfilelist(remotepath/>); //GExport_EI_DN_G_6542_StarMetroDeiraHotel&Apartment_10.235.155.37_20161120003108.xml.gz Parallel.ForEach(list.ToArra(), item => { if (item.StartsWith("GExport_") &&(!item.ToUpper().Contains("DUM"))) { path = item; //path = "GExport_EI_DN_G_6542_StarMetroDeiraHotel&Apartment_10.235.155.37_20161120003108.xml.gz"; ftp.Get(dtr["REMOTE_FILE_PATH"].ToString() + path, @localDestnDir + "\\" + dtr["SOURCE_PATH"].ToString()); download_location_hw = dtr["LOCAL_FILE_PATH"].ToString(); // ExtractZipfiles(download_location_hw + "//" + path, dtr["REMOTE_FILE_PATH"].ToString(), dtr["FTP_SERVER"].ToString(), dtr["FTP_USER_ID"].ToString(), dtr["TECH_CODE"].ToString(), dtr["VENDOR_CODE"].ToString()); } } ftp.Close(); It throws error like item doesnot contain StartsWith() extension methods.How to solve it
0debug
What is the difference between glide and picasso image libraries in android?which is the best? : I am new to this image loading concept.Can u please explain internal implementation of image loading while considering performance issue?
0debug
How do we split with and without dates and hours in java? : Currently i am getting all the below URL's from the list using the java. 1. Input - /folder1/folder2/folder3/folder4/folder5/dt=2017-10-05/hour=00/ 2. Input - /folder1/folder2/folder3/folder4/folder5/dt=2017-10-05/ 3. Input - /folder1/folder2/folder3/folder4/folder5/done_dt=2017-10-05.lst 4. Input - /folder1/folder2/folder3/folder4/folder5/20171005/00/ 5. Input - /folder1/folder2/folder3/folder4/folder5/20171005/ 6. Input - hdfs://location-one/mnt/hadoop/abc/cded/2017-10-05/ 7. Input - /folder1/folder2/folder3/folder4/folder5/folder6/20171005/ 8. Input - /folder1/folder2/folder3/folder4/folder5/dt=2017-10-05/hour=00/_done 9. Input - /folder1/folder2/folder3/folder4/folder5/ How do i remove the dates, hours if it presents and finally pass this values to the database to the exact match. Required value is: 1. Input - /folder1/folder2/folder3/folder4/folder5/ 2. Input - /folder1/folder2/folder3/folder4/folder5/ 3. Input - /folder1/folder2/folder3/folder4/folder5/ 4. Input - /folder1/folder2/folder3/folder4/folder5/ 5. Input - /folder1/folder2/folder3/folder4/folder5/ 6. Input - hdfs://location-one/mnt/hadoop/abc/cded/ 7. Input - /folder1/folder2/folder3/folder4/folder5/folder6/ 8. Input - /folder1/folder2/folder3/folder4/folder5/ 9. Input - /folder1/folder2/folder3/folder4/folder5/ Suggest any ideas.
0debug
static inline int opsize_bytes(int opsize) { switch (opsize) { case OS_BYTE: return 1; case OS_WORD: return 2; case OS_LONG: return 4; case OS_SINGLE: return 4; case OS_DOUBLE: return 8; default: qemu_assert(0, "bad operand size"); return 0; } }
1threat
Feature Importance with XGBClassifier : <p>Hopefully I'm reading this wrong but in the XGBoost library <a href="http://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn" rel="noreferrer">documentation</a>, there is note of extracting the feature importance attributes using <code>feature_importances_</code> much like sklearn's random forest.</p> <p>However, for some reason, I keep getting this error: <code>AttributeError: 'XGBClassifier' object has no attribute 'feature_importances_'</code></p> <p>My code snippet is below:</p> <pre><code>from sklearn import datasets import xgboost as xg iris = datasets.load_iris() X = iris.data Y = iris.target Y = iris.target[ Y &lt; 2] # arbitrarily removing class 2 so it can be 0 and 1 X = X[range(1,len(Y)+1)] # cutting the dataframe to match the rows in Y xgb = xg.XGBClassifier() fit = xgb.fit(X, Y) fit.feature_importances_ </code></pre> <p>It seems that you can compute feature importance using the <code>Booster</code> object by calling the <code>get_fscore</code> attribute. The only reason I'm using <code>XGBClassifier</code> over <code>Booster</code> is because it is able to be wrapped in a sklearn pipeline. Any thoughts on feature extractions? Is anyone else experiencing this?</p>
0debug
I am not being able to get the selected value from the select in php, below I have dropped my code. Someone please help me out on this : while($row=mysqli_fetch_assoc($res)) { echo " <form method='POST' action='booking_feed.php'> <tr class=responstable> <td><select name='from' style=width:90%> <option value=$row[beginning]>$row[beginning]</option> <option value=$row[ms1]>$row[ms1]</option> <option value=$row[ms2]>$row[ms2]</option> <option value=$row[ms3]>$row[ms3]</option> <option value=$row[end]>$row[end]</option> </select> </td> <td><select name='to' style=width:90%> <option value=$row[ms1]>$row[ms1]</option> <option value=$row[ms2]>$row[ms2]</option> <option value=$row[ms3]>$row[ms3]</option> <option value=$row[end]>$row[end]</option> </select> </td> </tr> "; $i++; } My Other file named booking_feed.php is as follows, I am getting the value of the last option in return of $_POST['from']/$_POST['to'] irrespective of whichever option I choose. Please help! <?php $from=$_POST['from']; $to=$_POST['to']; echo $from.$to; ?>
0debug
static uint32_t set_allocation_state(sPAPRDRConnector *drc, sPAPRDRAllocationState state) { sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); DPRINTFN("drc: %x, set_allocation_state: %x", get_index(drc), state); if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) { if (!drc->dev) { return RTAS_OUT_NO_SUCH_INDICATOR; } } if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) { drc->allocation_state = state; if (drc->awaiting_release && drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) { DPRINTFN("finalizing device removal"); drck->detach(drc, DEVICE(drc->dev), drc->detach_cb, drc->detach_cb_opaque, NULL); } } return RTAS_OUT_SUCCESS; }
1threat
Regex for specific characters : <p>I'm trying to refactor this piece of code:</p> <pre><code>if(!RenamePCTextBox.Text.Any(c =&gt; c == '\\' || c == '/' || c == ':' || c == '*' || c == '?' || c == '"' || c == '&lt;' || c == '&gt;' || c == '|' || c == '.' || c == ' ' || c == ',' || c == '~' || c == '!' || c == '@' || c == '#' || c == '$' || c == '%' || c == '^' || c == '&amp;' || c == '\'' || c == '(' || c == ')' || c == '{' || c == '}' || c == '_' || c == '[' || c == ']') &amp;&amp; !String.IsNullOrEmpty(RenamePCTextBox.Text)) { LabelCanUsePCName.Content = "You can use this name"; LabelCanUsePCName.Foreground = Brushes.DarkGreen; } </code></pre> <p>I would like to know if there is way to write it in regex expression? I think this code looks realy ugly this way. Or what would be better aproach for this?</p> <p>I need to disable only characters above, another other character wanna leave for usage (like "-" for example).</p>
0debug
Find where a certain string of numbers occurs using Regex and python : Out of a large text file I want to extract all the places where "RA"+6 numbers after it occur. How would I do this? For instance, I want the new txt file to look like RA000000 RA111111 RA222222 RA333333 RA444444 Where other instances of RA do not show up either.
0debug
After "iptables -P INPUT DROP in Ubuntu, How can apply my additional rule? : In Ubuntu 16.04LTS, I typed next lines. iptables -F iptables -X iptables -A INPUT -m mac --mac-source 1C:**:2C:**:72:**:78 -j ACCEPT and the result of "iptables -L -nvx" is [the result of it][1] [1]: http://i.stack.imgur.com/DeZ48.jpg but when I access to port 80 for accessing web-page with the PC(1C:**:2C:**:72:**:78), I cannot connect to the web-server. When I try to the web-server with "iptables -P INPUT ACCESS", it works well. Could anyone give me any solution or advicies for this? Thank you for reading. Have a good daay.
0debug
I want to stop print() from printing space while using , : <p>I am a noob so this question maybe a crap for you.</p> <p>As written in title, I want to stop <code>print()</code> from printing space while using <code>,</code>.</p> <p>I have code for that :</p> <pre><code>i = 1 print (i,"2") </code></pre> <blockquote> <p><strong>Output</strong> = 1 2</p> <p><strong>Expected Output</strong> = 12</p> </blockquote>
0debug
C P.L., using goto statement for temperature conversion. Need to learn :) : #include <stdio.h> int main() { char choice; float x,y; start: printf("[c] Converts Celsius -> Fahrenheit\n[f] Converts Fahrenheit -> Celsius\n\n\n"); printf("Enter Choice: "); scanf("%c",&choice); if (choice!='c' || choice!='f' || choice!='x') { printf("Wrong Choice: Try Again!"); goto start; } if (choice!=x) printf("Input Value: "); scanf("%f",&x); if (choice =='c') y = 1.8 * x + 32 else y = (x-32) * (5/9) printf("Result: %.2f",y); exit: return 0; } My instructor posted this but when I tried it, it have errors, need help to fix it :) Any help will do :)
0debug
how to insert an image into an sql query. : so i'm working on a side project, and practicing my sql queries. my question is how do i insert an image file into this query i have? never had to or been shown how to do it before. INSERT INTO products (prod_category,prod_title,image,conditions,in_stock,price,description) VALUES ("gaming tower", ,"used","yes",500,"new gaming tower");
0debug
static void vnc_dpy_copy(DisplayChangeListener *dcl, int src_x, int src_y, int dst_x, int dst_y, int w, int h) { VncDisplay *vd = container_of(dcl, VncDisplay, dcl); VncState *vs, *vn; uint8_t *src_row; uint8_t *dst_row; int i, x, y, pitch, inc, w_lim, s; int cmp_bytes; vnc_refresh_server_surface(vd); QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) { if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) { vs->force_update = 1; vnc_update_client(vs, 1, true); pitch = vnc_server_fb_stride(vd); src_row = vnc_server_fb_ptr(vd, src_x, src_y); dst_row = vnc_server_fb_ptr(vd, dst_x, dst_y); y = dst_y; inc = 1; if (dst_y > src_y) { src_row += pitch * (h-1); dst_row += pitch * (h-1); pitch = -pitch; y = dst_y + h - 1; inc = -1; w_lim = w - (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % VNC_DIRTY_PIXELS_PER_BIT)); if (w_lim < 0) { w_lim = w; } else { w_lim = w - (w_lim % VNC_DIRTY_PIXELS_PER_BIT); for (i = 0; i < h; i++) { for (x = 0; x <= w_lim; x += s, src_row += cmp_bytes, dst_row += cmp_bytes) { if (x == w_lim) { if ((s = w - w_lim) == 0) break; } else if (!x) { s = (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % VNC_DIRTY_PIXELS_PER_BIT)); s = MIN(s, w_lim); } else { s = VNC_DIRTY_PIXELS_PER_BIT; cmp_bytes = s * VNC_SERVER_FB_BYTES; if (memcmp(src_row, dst_row, cmp_bytes) == 0) continue; memmove(dst_row, src_row, cmp_bytes); QTAILQ_FOREACH(vs, &vd->clients, next) { if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) { set_bit(((x + dst_x) / VNC_DIRTY_PIXELS_PER_BIT), vs->dirty[y]); src_row += pitch - w * VNC_SERVER_FB_BYTES; dst_row += pitch - w * VNC_SERVER_FB_BYTES; y += inc; QTAILQ_FOREACH(vs, &vd->clients, next) { if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) { vnc_copy(vs, src_x, src_y, dst_x, dst_y, w, h);
1threat
Count the number of occurance of a value in a column for an object in psql : [Problem statement- Users can have any number of notifications. Need to count and print. Please click on it to find the attached image ][1] [1]: https://i.stack.imgur.com/2PUCV.jpg
0debug
Javascript: Can anyone explain me this block of code? : <p>i dont understand this two functions down below. They use an argument that is a function (done) and then they call the function inside of that function? Please tell me what type of function is this and how it works. Thank you!</p> <pre><code>beforeEach((done) =&gt; { Todo.remove({}).then(() =&gt; done()); }); describe('POST /todos', () =&gt; { it('should creat a new todo', (done) =&gt; { var text = 'Test todo text'; request(app) .post('/todos') .send({text}) .expect(200) .expect((res) =&gt; { expect(res.body.text).toBe(text); }) .end((err, res) =&gt; { if (err) { return done(err); } Todo.find().then((todos) =&gt; { expect(todos.length).toBe(1); expect(todos[0].text).toBe(text); done(); }).catch((e) =&gt; done(e)); }) }) }); </code></pre>
0debug
static unsigned int dec_move_r(DisasContext *dc) { int size = memsize_zz(dc); DIS(fprintf (logfile, "move.%c $r%u, $r%u\n", memsize_char(size), dc->op1, dc->op2)); cris_cc_mask(dc, CC_MASK_NZ); if (size == 4) { dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, cpu_R[dc->op2]); cris_cc_mask(dc, CC_MASK_NZ); cris_update_cc_op(dc, CC_OP_MOVE, 4); cris_update_cc_x(dc); cris_update_result(dc, cpu_R[dc->op2]); } else { TCGv t0; t0 = tcg_temp_new(TCG_TYPE_TL); dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, t0); cris_alu(dc, CC_OP_MOVE, cpu_R[dc->op2], cpu_R[dc->op2], t0, size); tcg_temp_free(t0); } return 2; }
1threat
How can I download a file using copy through an ntlm proxy on php? : <p>I have a qemu linux virtual machine and I'm trying to install composer on it using the commands on the composer page. I'm on a windows network accessing the internet through a proxy that uses ntlm, so I use cntlm to authenticate linux and other programs on my PC (thanks to the people that created cntlm). I added the context to the copy command needed to access the proxy but it doesn't work.</p> <p>This are the command used so far:</p> <pre class="lang-bash prettyprint-override"><code>$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php', stream_context_create(['https' =&gt; ['proxy' =&gt; 'http://10.0.2.2:3128/']]));" # a variant $ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php', stream_context_create(['https' =&gt; ['proxy' =&gt; 'tcp://10.0.2.2:3128/']]));" </code></pre> <p>The answer is:</p> <pre class="lang-bash prettyprint-override"><code>PHP Warning: copy(https://getcomposer.org/installer): failed to open stream: Connection timed out in Command line code on line 1 </code></pre> <p>Download the file using wget works fine. </p> <pre class="lang-bash prettyprint-override"><code>$ env | grep "proxy" https_proxy=http://10.0.2.2:3128/ http_proxy=http://10.0.2.2:3128/ $ wget -O composer-setup.php https://getcomposer.org/installer --2017-09-XX XX:XX:XX-- https://getcomposer.org/installer Connecting to 10.0.2.2:3128 ... conected Request send ... 200 OK ... etc 2017-09-XX XX:XX:XX (XX KB/s) - composer-setup.php saved [305728/305728] </code></pre> <p>The sites used as reference:</p> <ul> <li><a href="https://getcomposer.org/download/" rel="noreferrer">https://getcomposer.org/download/</a></li> <li><a href="http://php.net/manual/en/function.copy.php" rel="noreferrer">http://php.net/manual/en/function.copy.php</a></li> <li><a href="http://php.net/manual/en/function.stream-context-create.php" rel="noreferrer">http://php.net/manual/en/function.stream-context-create.php</a></li> <li><a href="http://php.net/manual/en/context.http.php" rel="noreferrer">http://php.net/manual/en/context.http.php</a></li> </ul> <p>I know there is a manual way to install composer, but I'm just a bit curious, How can make this work?</p>
0debug
Struts 1 NullPointer EXception : My Struts Config XML [enter image description here][1] Login Form Class [enter image description here][2] LoginAction class [enter image description here][3] MyLogin JSP [enter image description here][4] Error [enter image description here][5] please help me to solve this matter [1]: https://i.stack.imgur.com/svv0z.jpg [2]: https://i.stack.imgur.com/5x8jS.jpg [3]: https://i.stack.imgur.com/gVLjX.jpg [4]: https://i.stack.imgur.com/vPomD.jpg [5]: https://i.stack.imgur.com/khs3W.jpg
0debug
static void FUNCC(pred4x4_horizontal)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; int stride = _stride/sizeof(pixel); ((pixel4*)(src+0*stride))[0]= PIXEL_SPLAT_X4(src[-1+0*stride]); ((pixel4*)(src+1*stride))[0]= PIXEL_SPLAT_X4(src[-1+1*stride]); ((pixel4*)(src+2*stride))[0]= PIXEL_SPLAT_X4(src[-1+2*stride]); ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(src[-1+3*stride]); }
1threat
Google login error: "popup_closed_by_user" : <p>After setting up and running with my own client id I go through the login process and select the needed google account in the popup.</p> <p>Once this has been selected the login fails with the error in the console being:</p> <pre><code>err = {error: "popup_closed_by_user"} </code></pre> <p>can anybody help me to solve this</p>
0debug
Is there any JS method to parse date only by providing month and year as arguments? : <p>I'm working in a JavaScript date picker. I need to parse date by providing month and year. For example, if I'm giving argument as '01/2019', the output should be <code>Tue Jan 1 2019 00:00:00 GMT 05 30</code>. I'm aware this can be achieved by using <code>.toUTCString()</code> only if the argument should be a valid date i.e., it should be in the format of <code>dd mm yyyy</code>. But in my case, the format should be <code>mm yyyy</code>. Is there any JS built-in method to achieve this?</p> <p><strong>Additional Info</strong>: Since date(dd) is not provided, the first date of the input month(mm) can be taken. 01/2019 - Tue Jan 1 2019 00:00:00 GMT 05 30</p>
0debug
Where is executable file after compiling a c program in ubuntu? : <p>While compiling a C file in windows I get three files a .c file a .o file and a .exe file, now if i want to distribute my program I will give .exe file. But after compiling a .c in ubuntu I can't find the executable file which will run directly on other system by just clicking it.</p>
0debug
Pug/ Jade - input is a self closing element: <input/> but contains nested content? : <p>I want to create the html like this:</p> <pre><code>&lt;label class="radio-inline"&gt; &lt;input type="radio" name="hidden" checked="" value="Visible"&gt; Visible &lt;/label&gt; </code></pre> <p>Pug/ Jade:</p> <pre><code>label.radio-inline input(type="radio", name="hidden", value="0", checked="") Visible </code></pre> <p>But I get an error:</p> <blockquote> <p>input is a self closing element: but contains nested content.</p> </blockquote> <p>What does it mean? How I can fix this?</p>
0debug
Pip is not recognized in command prompt bu working in Anaconda prompt : <p>I know if I add <code>pip</code> path to env variables, this would resolve. But I am not able to find the directory where <code>pip.exe</code> is located.</p> <p>Attached are the snapshots of working in <code>Anaconda prompt</code> but not working in <code>command prompt</code>.</p> <p><a href="https://i.stack.imgur.com/WAMpL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WAMpL.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/5mdtj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5mdtj.png" alt="enter image description here"></a></p>
0debug
vu_queue_fill(VuDev *dev, VuVirtq *vq, const VuVirtqElement *elem, unsigned int len, unsigned int idx) { struct vring_used_elem uelem; if (unlikely(dev->broken)) { return; } vu_log_queue_fill(dev, vq, elem, len); idx = (idx + vq->used_idx) % vq->vring.num; uelem.id = elem->index; uelem.len = len; vring_used_write(dev, vq, &uelem, idx); }
1threat
bool memory_region_is_unassigned(MemoryRegion *mr) { return mr != &io_mem_ram && mr != &io_mem_rom && mr != &io_mem_notdirty && !mr->rom_device && mr != &io_mem_watch; }
1threat
How do I warn a user of unsaved changes before leaving a page in Vue : <p>I have an <code>UnsavedChangesModal</code> as a component that needs to be launched when the user tries to leave the page when he has unsaved changes in the input fields (I have three input fields in the page).</p> <pre><code>components: { UnsavedChangesModal }, mounted() { window.onbeforeunload = ''; }, methods: { alertChanges() { } } </code></pre>
0debug
static int output_frame(H264Context *h, AVFrame *dst, AVFrame *src) { int i; int ret = av_frame_ref(dst, src); if (ret < 0) return ret; if (!h->sps.crop) return 0; for (i = 0; i < 3; i++) { int hshift = (i > 0) ? h->chroma_x_shift : 0; int vshift = (i > 0) ? h->chroma_y_shift : 0; int off = ((h->sps.crop_left >> hshift) << h->pixel_shift) + (h->sps.crop_top >> vshift) * dst->linesize[i]; dst->data[i] += off; } return 0; }
1threat
why there is different output for below two codes? : <p>The below program outputs false</p> <pre><code> String s1="a"; String s2="b"; String s3=s1+s2; String s4="ab"; if(s3==s4) { System.out.println("true"); } else { System.out.println("false"); } </code></pre> <p>and this code outputs true</p> <pre><code>String s3="a"+"b"; String s4="ab"; if(s3==s4) { System.out.println("true"); } else { System.out.println("false"); } </code></pre> <p>Shouldn't the output in first case be true? As while creating String s4="ab" there is already an object with value "ab" in the string constant pool.</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
Cards with different sizes in Bootstrap 4 card-group : <p>Is it possible to mix card of different sizes within a card-group in Bootstrap 4. I want to have a large card (double width) on the left size, and two smaller cards on the right, with the same height of all three.</p> <pre><code>&lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div class="card-group"&gt; &lt;div class="card col-md-6"&gt; &lt;div class="card-block"&gt; &lt;h4 class="card-title"&gt;Card 1&lt;/h4&gt; &lt;p class="card-text"&gt;Text 1&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="card col-md-3"&gt; &lt;div class="card-block"&gt; &lt;h4 class="card-title"&gt;Card 2&lt;/h4&gt; &lt;p class="card-text"&gt;Text 2&lt;/p&gt; &lt;p class="card-text"&gt;More text 2&lt;/p&gt; &lt;p class="card-text"&gt;More text 2&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="card col-md-3"&gt; &lt;div class="card-block"&gt; &lt;h4 class="card-title"&gt;Card 3&lt;/h4&gt; &lt;p class="card-text"&gt;Text 3&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
0debug
require_once inside of a function : <p>for self exercise and training I am building my own CMS from the ground up. Part of this exercise is to enable custom html, css templates</p> <p>Security wise, is it better if I open the PHP template file with require_once inside of a function to protect outside variables like the Database Handler and such?</p> <p>Or should I make this entirely diffrent than this?</p>
0debug
Need of multiple Routes in Asp.net MVC : <p>What is the actual need for multiple routes in an Asp.net MVC application? We can done all using the default route</p>
0debug
static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed) { int dir; size_t len = 0, pktlen = 0; #ifdef DEBUG_PACKET const char *str = NULL; #endif int pid; int ret; int i; USBDevice *dev; struct ohci_td td; uint32_t addr; int flag_r; int completion; addr = ed->head & OHCI_DPTR_MASK; completion = (addr == ohci->async_td); if (completion && !ohci->async_complete) { #ifdef DEBUG_PACKET DPRINTF("Skipping async TD\n"); #endif return 1; } if (!ohci_read_td(ohci, addr, &td)) { fprintf(stderr, "usb-ohci: TD read error at %x\n", addr); return 0; } dir = OHCI_BM(ed->flags, ED_D); switch (dir) { case OHCI_TD_DIR_OUT: case OHCI_TD_DIR_IN: break; default: dir = OHCI_BM(td.flags, TD_DP); break; } switch (dir) { case OHCI_TD_DIR_IN: #ifdef DEBUG_PACKET str = "in"; #endif pid = USB_TOKEN_IN; break; case OHCI_TD_DIR_OUT: #ifdef DEBUG_PACKET str = "out"; #endif pid = USB_TOKEN_OUT; break; case OHCI_TD_DIR_SETUP: #ifdef DEBUG_PACKET str = "setup"; #endif pid = USB_TOKEN_SETUP; break; default: fprintf(stderr, "usb-ohci: Bad direction\n"); return 1; } if (td.cbp && td.be) { if ((td.cbp & 0xfffff000) != (td.be & 0xfffff000)) { len = (td.be & 0xfff) + 0x1001 - (td.cbp & 0xfff); } else { len = (td.be - td.cbp) + 1; } pktlen = len; if (len && dir != OHCI_TD_DIR_IN) { pktlen = (ed->flags & OHCI_ED_MPS_MASK) >> OHCI_ED_MPS_SHIFT; if (pktlen > len) { pktlen = len; } if (!completion) { ohci_copy_td(ohci, &td, ohci->usb_buf, pktlen, 0); } } } flag_r = (td.flags & OHCI_TD_R) != 0; #ifdef DEBUG_PACKET DPRINTF(" TD @ 0x%.8x %" PRId64 " of %" PRId64 " bytes %s r=%d cbp=0x%.8x be=0x%.8x\n", addr, (int64_t)pktlen, (int64_t)len, str, flag_r, td.cbp, td.be); if (pktlen > 0 && dir != OHCI_TD_DIR_IN) { DPRINTF(" data:"); for (i = 0; i < pktlen; i++) { printf(" %.2x", ohci->usb_buf[i]); } DPRINTF("\n"); } #endif if (completion) { ret = ohci->usb_packet.result; ohci->async_td = 0; ohci->async_complete = 0; } else { if (ohci->async_td) { #ifdef DEBUG_PACKET DPRINTF("Too many pending packets\n"); #endif return 1; } usb_packet_setup(&ohci->usb_packet, pid, OHCI_BM(ed->flags, ED_FA), OHCI_BM(ed->flags, ED_EN)); usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, pktlen); dev = ohci_find_device(ohci, ohci->usb_packet.devaddr); ret = usb_handle_packet(dev, &ohci->usb_packet); #ifdef DEBUG_PACKET DPRINTF("ret=%d\n", ret); #endif if (ret == USB_RET_ASYNC) { ohci->async_td = addr; return 1; } } if (ret >= 0) { if (dir == OHCI_TD_DIR_IN) { ohci_copy_td(ohci, &td, ohci->usb_buf, ret, 1); #ifdef DEBUG_PACKET DPRINTF(" data:"); for (i = 0; i < ret; i++) printf(" %.2x", ohci->usb_buf[i]); DPRINTF("\n"); #endif } else { ret = pktlen; } } if (ret == pktlen || (dir == OHCI_TD_DIR_IN && ret >= 0 && flag_r)) { if (ret == len) { td.cbp = 0; } else { if ((td.cbp & 0xfff) + ret > 0xfff) { td.cbp = (td.be & ~0xfff) + ((td.cbp + ret) & 0xfff); } else { td.cbp += ret; } } td.flags |= OHCI_TD_T1; td.flags ^= OHCI_TD_T0; OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_NOERROR); OHCI_SET_BM(td.flags, TD_EC, 0); if ((dir != OHCI_TD_DIR_IN) && (ret != len)) { goto exit_no_retire; } ed->head &= ~OHCI_ED_C; if (td.flags & OHCI_TD_T0) ed->head |= OHCI_ED_C; } else { if (ret >= 0) { DPRINTF("usb-ohci: Underrun\n"); OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAUNDERRUN); } else { switch (ret) { case USB_RET_NODEV: OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DEVICENOTRESPONDING); case USB_RET_NAK: DPRINTF("usb-ohci: got NAK\n"); return 1; case USB_RET_STALL: DPRINTF("usb-ohci: got STALL\n"); OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_STALL); break; case USB_RET_BABBLE: DPRINTF("usb-ohci: got BABBLE\n"); OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAOVERRUN); break; default: fprintf(stderr, "usb-ohci: Bad device response %d\n", ret); OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_UNDEXPETEDPID); OHCI_SET_BM(td.flags, TD_EC, 3); break; } } ed->head |= OHCI_ED_H; } ed->head &= ~OHCI_DPTR_MASK; ed->head |= td.next & OHCI_DPTR_MASK; td.next = ohci->done; ohci->done = addr; i = OHCI_BM(td.flags, TD_DI); if (i < ohci->done_count) ohci->done_count = i; exit_no_retire: ohci_put_td(ohci, addr, &td); return OHCI_BM(td.flags, TD_CC) != OHCI_CC_NOERROR; }
1threat
static int libschroedinger_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int64_t pts = avpkt->pts; SchroTag *tag; SchroDecoderParams *p_schro_params = avctx->priv_data; SchroDecoder *decoder = p_schro_params->decoder; SchroBuffer *enc_buf; SchroFrame* frame; AVFrame *avframe = data; int state; int go = 1; int outer = 1; SchroParseUnitContext parse_ctx; LibSchroFrameContext *framewithpts = NULL; int ret; *got_frame = 0; parse_context_init(&parse_ctx, buf, buf_size); if (!buf_size) { if (!p_schro_params->eos_signalled) { state = schro_decoder_push_end_of_stream(decoder); p_schro_params->eos_signalled = 1; } } do { if ((enc_buf = find_next_parse_unit(&parse_ctx))) { enc_buf->tag = schro_tag_new(av_malloc(sizeof(int64_t)), av_free); if (!enc_buf->tag->value) { av_log(avctx, AV_LOG_ERROR, "Unable to allocate SchroTag\n"); return AVERROR(ENOMEM); } AV_WN(64, enc_buf->tag->value, pts); if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) && SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0) avctx->has_b_frames = 1; state = schro_decoder_push(decoder, enc_buf); if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT) libschroedinger_handle_first_access_unit(avctx); go = 1; } else outer = 0; while (go) { state = schro_decoder_wait(decoder); switch (state) { case SCHRO_DECODER_FIRST_ACCESS_UNIT: libschroedinger_handle_first_access_unit(avctx); break; case SCHRO_DECODER_NEED_BITS: go = 0; break; case SCHRO_DECODER_NEED_FRAME: frame = ff_create_schro_frame(avctx, p_schro_params->frame_format); if (!frame) return AVERROR(ENOMEM); schro_decoder_add_output_picture(decoder, frame); break; case SCHRO_DECODER_OK: tag = schro_decoder_get_picture_tag(decoder); frame = schro_decoder_pull(decoder); if (frame) { framewithpts = av_malloc(sizeof(LibSchroFrameContext)); if (!framewithpts) { av_log(avctx, AV_LOG_ERROR, "Unable to allocate FrameWithPts\n"); return AVERROR(ENOMEM); } framewithpts->frame = frame; framewithpts->pts = AV_RN64(tag->value); ff_schro_queue_push_back(&p_schro_params->dec_frame_queue, framewithpts); } break; case SCHRO_DECODER_EOS: go = 0; p_schro_params->eos_pulled = 1; schro_decoder_reset(decoder); outer = 0; break; case SCHRO_DECODER_ERROR: return -1; break; } } } while (outer); framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue); if (framewithpts && framewithpts->frame && framewithpts->frame->components[0].stride) { if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0) { goto end; } memcpy(avframe->data[0], framewithpts->frame->components[0].data, framewithpts->frame->components[0].length); memcpy(avframe->data[1], framewithpts->frame->components[1].data, framewithpts->frame->components[1].length); memcpy(avframe->data[2], framewithpts->frame->components[2].data, framewithpts->frame->components[2].length); avframe->pts = framewithpts->pts; #if FF_API_PKT_PTS FF_DISABLE_DEPRECATION_WARNINGS avframe->pkt_pts = avframe->pts; FF_ENABLE_DEPRECATION_WARNINGS #endif avframe->linesize[0] = framewithpts->frame->components[0].stride; avframe->linesize[1] = framewithpts->frame->components[1].stride; avframe->linesize[2] = framewithpts->frame->components[2].stride; *got_frame = 1; } else { data = NULL; *got_frame = 0; } ret = buf_size; end: if (framewithpts && framewithpts->frame) libschroedinger_decode_frame_free(framewithpts->frame); av_freep(&framewithpts); return ret; }
1threat
def is_undulating(n): if (len(n) <= 2): return False for i in range(2, len(n)): if (n[i - 2] != n[i]): return False return True
0debug
static int coroutine_fn cow_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { BDRVCowState *s = bs->opaque; int ret, n; while (nb_sectors > 0) { if (cow_co_is_allocated(bs, sector_num, nb_sectors, &n)) { ret = bdrv_pread(bs->file, s->cow_sectors_offset + sector_num * 512, buf, n * 512); if (ret < 0) { return ret; } } else { if (bs->backing_hd) { ret = bdrv_read(bs->backing_hd, sector_num, buf, n); if (ret < 0) { return ret; } } else { memset(buf, 0, n * 512); } } nb_sectors -= n; sector_num += n; buf += n * 512; } return 0; }
1threat
i ceated a password validation and i want to encrypt the password after validation completed.and print that password in console : package praveen; import java.util.Scanner; public class passwordencrypt { static String password; static String pattern="^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$"; public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter your password: "); while(true){ password = input.nextLine(); if (password.matches(pattern)) { System.out.println("Valid Password"); break; } else { System.out.println("Invalid Passowrd"); System.out.println("Re enter your password"); } } } } in the above code i created a validation for the password, now the password validated but how can i encript the valid password
0debug
What is the most efficient way of freeing the memory allocated to a massive vector? : <p>I have a massive <code>std::vector&lt;strc&gt; V</code> filled with more than 100M elements, which I use as the input of some function <code>foo</code>. Here, <code>strc</code> is simply a <code>struct</code> containing three primitives. After the call to <code>foo</code> finishes, I don't have any purpose for <code>V</code>, so I want to reclaim as much memory from it as possible. Clearly <code>V.clear()</code> doesn't do the job as <code>V</code> retains its capacity. </p> <p>I have read some suggestion advocating for the trick <code>std::vector&lt;strc&gt;().swap(V)</code>, but it looks rather gimmicky an not good practice. I'm not even sure if it does what I need!. Is there a standard way of doing this? If indeed <code>swap</code> is the best option, should I call <code>clear</code> first? Since the complexity of <code>swap</code> is constant, it seems that <code>swap</code> is literally exchanging the address of <code>V</code> with that of an empty, nameless vector. Then, what happens with all the stuff that was originally in <code>V</code>? I expect it to remain in memory but no longer accessible. Does that chunk of memory gets directly marked as free after the swap? i.e., gets somehow deallocated?</p> <p>Other sources suggest <code>V.clear()</code> and then <code>V.shrink_to_fit()</code>. Is this a better option?</p>
0debug
static int virtio_ccw_rng_init(VirtioCcwDevice *ccw_dev) { VirtIORNGCcw *dev = VIRTIO_RNG_CCW(ccw_dev); DeviceState *vdev = DEVICE(&dev->vdev); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); if (qdev_init(vdev) < 0) { return -1; } object_property_set_link(OBJECT(dev), OBJECT(dev->vdev.conf.default_backend), "rng", NULL); return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev)); }
1threat
converting a string to a readable sentence : <p>say you have a list like so:</p> <pre><code>lst = ['my', 'name', 'is', 'jack.'] </code></pre> <p>If I convert to a string doing this:</p> <pre><code>''.join(lst) </code></pre> <p><strong>output</strong></p> <pre><code>'mynameisjack.' </code></pre> <p>How do I make the list print out:</p> <pre><code> "my name is jack." </code></pre> <p>instead of all together.</p>
0debug
Delphi convert Currency : <p>Hi I would like to covert a certain currency to another, like say from USD to EUR but also any other currency, I have no idea how to do this, can someone please help me?</p>
0debug
mongoose getting `TypeError: user.save is not a function` - what is wrong : <p>I am trying to post the user data to <code>mongodb</code> but I am getting an error as : </p> <p>`TypeError: user.save is not a function' - how to fix this?</p> <p>here is my code :</p> <pre><code>var express = require('express'), app = express(), bodyParser = require('body-parser'), mongoose = require('mongoose'), PORT = process.env.PORT || 8080; //connect to db mongoose.connect('mongodb://3gwebtrain:[email protected]:47975/family'); app.use( bodyParser.urlencoded({extended : true })); app.use( bodyParser.json() ); app.get('/', function( req, res ) { res.json({message:'works'}) }); var Schema = mongoose.Schema; var User = new Schema({ name:String, username:{type:String, required:true, index:{unique:true}}, password:{type:String, required:true, select:false} }) var apiRouter = express.Router(); apiRouter .get('/users', function( req, res ){ res.send( "yet to get users!"); }) .post('/users', function( req, res ) { var user = User; user.name = req.body.name; user.username = req.body.username; user.password = req.body.password; user.save(function(err) { if( err ) { console.log( err ); //TypeError: user.save is not a function } res.send("user created!"); }) }) app.use('/api', apiRouter); app.listen( PORT ); console.log( 'app listens at ' + PORT ); </code></pre>
0debug
void OPPROTO op_udivx_T1_T0(void) { T0 /= T1; FORCE_RET();
1threat
somebody help me how to change dialog backgound color in tabcontrol? : BOOL CTabControlDlg::OnEraseBkgnd(CDC* pDC) { CRect rect; GetClientRect(rect); pDC->FillSolidRect(rect, RGB(255, 255, 255)); return CDialog::OnEraseBkgnd(pDC); } CTabControlDlg is dialog in the tabcontrol.
0debug
Docker-in-Docker with Gitlab Shared runner for building and pushing docker images to registry : <p>Been trying to set-up Gitlab CI which can build a docker image, and came across that DinD was enabled initially only for separate runners and <a href="https://about.gitlab.com/2016/05/23/gitlab-container-registry/" rel="noreferrer">Blog Post</a> suggest it would be enabled soon for shared runners, </p> <p>Running DinD requires enabling privileged mode in runners, which is set as a flag while registering runner, but couldn't find an equivalent mechanism for Shared Runners</p>
0debug
How to find all links to pictures from an html file : How to find all links to pictures from an html file REGEX notepad++; "Http://www.../abc.jpg", "http://www.../xyz.jpeg", "http://www.../123.gif" extension of Internet addresses to separate the links !? visual image links contained within html file I want to parse command with REGEX --- sample ; index.html file ,,,, aa bb cc html:\\www.com **http://www…/abc.jpg** abc123 **http://www…/xyz.jpeg** 123 abc **http://www…/123.gif** xxx ,,, wherein examples of desired results; as follows ;; **http: //www.../abc.jpg http: //www.../xyz.jpeg http: //www.../123.gif**
0debug
How to properly setup custom handler404 in django? : <p>According to the <a href="https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views" rel="noreferrer">documentation</a> this should be fairly simple: I just need to define <code>handler404</code>. Currently I am doing, in my top <code>urls.py</code>:</p> <pre><code>urlpatterns = [ ... ] handler404 = 'myapp.views.handle_page_not_found' </code></pre> <p>The application is installed. The corresponding view is just (for the time being I just want to redirect to the homepage in case of 404):</p> <pre><code>def handle_page_not_found(request): return redirect('homepage') </code></pre> <p>But this has no effect: the standard (debug) <code>404</code> page is shown.</p> <p>The documentation is a bit ambiguous:</p> <ul> <li>where should <code>handler404</code> be defined? The documentation says in the <code>URLconf</code> but, where exactly? I have several applications, each with a different <code>urls.py</code>. Can I put it in any of them? In the top <code>URLconf</code>? Why? Where is this documented?</li> <li>what will be catched by this handler? Will it catch <code>django.http.Http404</code>, <code>django.http.HttpResponseNotFound</code>, <code>django.http.HttpResponse</code> (with <code>status=404</code>)?</li> </ul>
0debug
static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { int i; int s; const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0}; vector unsigned char perm1 = vec_lvsl(0, pix1); vector unsigned char perm2 = vec_lvsl(0, pix2); vector unsigned char t1, t2, t3,t4, t5; vector unsigned int sad; vector signed int sumdiffs; sad = (vector unsigned int)vec_splat_u32(0); for (i = 0; i < h; i++) { vector unsigned char pix1l = vec_ld( 0, pix1); vector unsigned char pix1r = vec_ld(15, pix1); vector unsigned char pix2l = vec_ld( 0, pix2); vector unsigned char pix2r = vec_ld(15, pix2); t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear); t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear); t3 = vec_max(t1, t2); t4 = vec_min(t1, t2); t5 = vec_sub(t3, t4); sad = vec_sum4s(t5, sad); pix1 += line_size; pix2 += line_size; } sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); sumdiffs = vec_splat(sumdiffs, 3); vec_ste(sumdiffs, 0, &s); return s; }
1threat
How can i set black color to my label background color when dark mode is OFF ?(SWIF) : I want the background color of the label to be black when dark mode is OFF and background color of the label to be white when dark mode is ON (IOS13) What color should I use ?
0debug
MemoryRegion *iotlb_to_region(hwaddr index) { return address_space_memory.dispatch->sections[index & ~TARGET_PAGE_MASK].mr; }
1threat
.gql or .graphql file types with Node : <p>I'm using Apollo's <code>graphql-server-express</code> with Node and I would like to turn my "typedef" schema definition files into <code>.graphql or .gql</code> files for clarity and syntax highlighting.</p> <p>What is the best way to do this? I cannot find any good resources online beyond Babel(?) which seems to be the only choice.</p> <p>Thanks so much for the help!</p>
0debug
Uplload video on twiter in java : Hi i am trting to upload a video on twitter i am using following code private UploadedMedia uploadMediaChunkedInit(long size) throws TwitterException { return new UploadedMedia(post( conf.getUploadBaseURL() + "media/upload.json", new HttpParameter[] { new HttpParameter("command", CHUNKED_INIT), new HttpParameter("media_type", "video/mp4"), new HttpParameter("total_bytes", size) }) .asJSONObject()); } Where i am geting following error: Method post is not defined i got code from here. [https://github.com/yusuke/twitter4j/pull/226/commits/73b43c1ae4511d3712118f61f983bcbca4ef0c59][1] if any one can help me plz Thanks
0debug
Purpose of PreAuthenticatedAuthenticationToken in Spring Security? : <p>I am authenticating a User using <a href="http://docs.spring.io/spring-security/site/docs/3.2.2.RELEASE/apidocs/org/springframework/security/authentication/UsernamePasswordAuthenticationToken.html" rel="noreferrer">UsernamePasswordAuthenticationToken</a> in SpringBoot.</p> <p>I am generating a token using <a href="https://github.com/jwtk/jjwt" rel="noreferrer">JJWT</a> for that User and returning it back.</p> <p>Now the User uses that token to send any further requests to me. After decrypting the token should I be using <a href="http://docs.spring.io/spring-security/site/docs/3.2.2.RELEASE/apidocs/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationToken.html" rel="noreferrer">PreAuthenticatedAuthenticationToken</a> and set it to <code>SecurityContextHolder.getContext().setAuthentication()</code>?</p> <p>What is the purpose of <code>PreAuthenticatedAuthenticationToken</code>?</p>
0debug
static int hls_mux_init(AVFormatContext *s) { HLSContext *hls = s->priv_data; AVFormatContext *oc; AVFormatContext *vtt_oc; int i, ret; ret = avformat_alloc_output_context2(&hls->avf, hls->oformat, NULL, NULL); if (ret < 0) return ret; oc = hls->avf; oc->oformat = hls->oformat; oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; av_dict_copy(&oc->metadata, s->metadata, 0); if(hls->vtt_oformat) { ret = avformat_alloc_output_context2(&hls->vtt_avf, hls->vtt_oformat, NULL, NULL); if (ret < 0) return ret; vtt_oc = hls->vtt_avf; vtt_oc->oformat = hls->vtt_oformat; av_dict_copy(&vtt_oc->metadata, s->metadata, 0); } for (i = 0; i < s->nb_streams; i++) { AVStream *st; AVFormatContext *loc; if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) loc = vtt_oc; else loc = oc; if (!(st = avformat_new_stream(loc, NULL))) return AVERROR(ENOMEM); avcodec_copy_context(st->codec, s->streams[i]->codec); st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->time_base = s->streams[i]->time_base; } hls->start_pos = 0; return 0; }
1threat
How to Make a HTML Form Where Files can be Submitted.\ : <p>I'm kind of new to HTML, (not totally) and I was wondering the easiest way to create an HTML form page where users can submit files to. I have tried looking up many pages and tutorials, but they don't seem like what I need. I would want something where someone can submit a file and give it a name and it sends it to a database or something. Does anyone have a webpage where I can find a tutorial (or a video)? </p> <p>Sorry if this is off-topic in anyway.</p>
0debug
static int local_rename(FsContext *ctx, const char *oldpath, const char *newpath) { int err; char *buffer, *buffer1; if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { err = local_create_mapped_attr_dir(ctx, newpath); if (err < 0) { return err; } buffer = local_mapped_attr_path(ctx, oldpath); buffer1 = local_mapped_attr_path(ctx, newpath); err = rename(buffer, buffer1); g_free(buffer); g_free(buffer1); if (err < 0 && errno != ENOENT) { return err; } } buffer = rpath(ctx, oldpath); buffer1 = rpath(ctx, newpath); err = rename(buffer, buffer1); g_free(buffer); g_free(buffer1); return err; }
1threat
Whats the difference between a test set and a train set in Data Mining? : Whats the difference between a test set and a train set in Data Mining ? Thanks in advanve and best regards
0debug
static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { hwaddr phys_addr; target_ulong page_size; int prot; int ret, is_user = ri->opc2 & 2; int access_type = ri->opc2 & 1; ret = get_phys_addr(env, value, access_type, is_user, &phys_addr, &prot, &page_size); if (extended_addresses_enabled(env)) { uint64_t par64 = (1 << 11); if (ret == 0) { par64 |= phys_addr & ~0xfffULL; } else { par64 |= 1; par64 |= (ret & 0x3f) << 1; } env->cp15.par_el1 = par64; } else { if (ret == 0) { if (page_size == (1 << 24) && arm_feature(env, ARM_FEATURE_V7)) { env->cp15.par_el1 = (phys_addr & 0xff000000) | 1 << 1; } else { env->cp15.par_el1 = phys_addr & 0xfffff000; } } else { env->cp15.par_el1 = ((ret & (1 << 10)) >> 5) | ((ret & (1 << 12)) >> 6) | ((ret & 0xf) << 1) | 1; } } }
1threat
static bool cmd_read_dma(IDEState *s, uint8_t cmd) { bool lba48 = (cmd == WIN_READDMA_EXT); if (!s->bs) { ide_abort_command(s); return true; } ide_cmd_lba48_transform(s, lba48); ide_sector_start_dma(s, IDE_DMA_READ); return false; }
1threat
qemu_irq *armv7m_init(int flash_size, int sram_size, const char *kernel_filename, const char *cpu_model) { CPUState *env; DeviceState *nvic; static qemu_irq pic[64]; qemu_irq *cpu_pic; uint32_t pc; int image_size; uint64_t entry; uint64_t lowaddr; int i; flash_size *= 1024; sram_size *= 1024; if (!cpu_model) cpu_model = "cortex-m3"; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } #if 0 if (ram_size > (512 + 32) * 1024 * 1024) ram_size = (512 + 32) * 1024 * 1024; sram_size = (ram_size / 2) & TARGET_PAGE_MASK; if (sram_size > 32 * 1024 * 1024) sram_size = 32 * 1024 * 1024; code_size = ram_size - sram_size; #endif cpu_register_physical_memory(0, flash_size, qemu_ram_alloc(flash_size) | IO_MEM_ROM); cpu_register_physical_memory(0x20000000, sram_size, qemu_ram_alloc(sram_size) | IO_MEM_RAM); armv7m_bitband_init(); nvic = qdev_create(NULL, "armv7m_nvic"); qdev_set_prop_ptr(nvic, "cpu", env); qdev_init(nvic); cpu_pic = arm_pic_init_cpu(env); sysbus_connect_irq(sysbus_from_qdev(nvic), 0, cpu_pic[ARM_PIC_CPU_IRQ]); for (i = 0; i < 64; i++) { pic[i] = qdev_get_gpio_in(nvic, i); } image_size = load_elf(kernel_filename, 0, &entry, &lowaddr, NULL); if (image_size < 0) { image_size = load_image_targphys(kernel_filename, 0, flash_size); lowaddr = 0; } if (image_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (lowaddr == 0) { env->regs[13] = ldl_phys(0); pc = ldl_phys(4); } else { pc = entry; } env->thumb = pc & 1; env->regs[15] = pc & ~1; cpu_register_physical_memory(0xfffff000, 0x1000, qemu_ram_alloc(0x1000) | IO_MEM_RAM); return pic; }
1threat
VBA: create condition based loop, copy part of row and use header title : I have been trying to create a VBA which converts a raw data source into a usefull dashboard for reporting. The challenges I encountered: - Loop across columns, dismiss empty cells and continue loop afterwards - Copy multiple sections of input table into destination table - Use column heading of input table as column item in destination table Thanks in advance for your help [Snippet of problem][1] [1]: https://i.stack.imgur.com/Tp43c.png
0debug
Why isn't `std::mem::drop` exactly the same as the closure |_|() in higher-ranked trait bounds? : <p>The implementation of <a href="https://doc.rust-lang.org/std/mem/fn.drop.html" rel="noreferrer"><code>std::mem::drop</code></a> is documented to be the following:</p> <pre class="lang-rust prettyprint-override"><code>pub fn drop&lt;T&gt;(_x: T) { } </code></pre> <p>As such, I would expect the closure <code>|_| ()</code> (colloquially known as the <a href="https://enet4.github.io/rust-tropes/#toilet-closure" rel="noreferrer">toilet closure</a>) to be a potential 1:1 replacement to <code>drop</code>, in both directions. However, the code below shows that <code>drop</code> isn't compatible with a higher ranked trait bound on the function's parameter, whereas the toilet closure is.</p> <pre class="lang-rust prettyprint-override"><code>fn foo&lt;F, T&gt;(f: F, x: T) where for&lt;'a&gt; F: FnOnce(&amp;'a T), { dbg!(f(&amp;x)); } fn main() { foo(|_| (), "toilet closure"); // this compiles foo(drop, "drop"); // this does not! } </code></pre> <p>The compiler's error message:</p> <pre class="lang-none prettyprint-override"><code>error[E0631]: type mismatch in function arguments --&gt; src/main.rs:10:5 | 1 | fn foo&lt;F, T&gt;(f: F, x: T) | --- 2 | where 3 | for&lt;'a&gt; F: FnOnce(&amp;'a T), | ------------- required by this bound in `foo` ... 10 | foo(drop, "drop"); // this does not! | ^^^ | | | expected signature of `for&lt;'a&gt; fn(&amp;'a _) -&gt; _` | found signature of `fn(_) -&gt; _` error[E0271]: type mismatch resolving `for&lt;'a&gt; &lt;fn(_) {std::mem::drop::&lt;_&gt;} as std::ops::FnOnce&lt;(&amp;'a _,)&gt;&gt;::Output == ()` --&gt; src/main.rs:10:5 | 1 | fn foo&lt;F, T&gt;(f: F, x: T) | --- 2 | where 3 | for&lt;'a&gt; F: FnOnce(&amp;'a T), | ------------- required by this bound in `foo` ... 10 | foo(drop, "drop"); // this does not! | ^^^ expected bound lifetime parameter 'a, found concrete lifetime </code></pre> <p>Considering that <code>drop</code> is supposedly generic with respect to any sized <code>T</code>, it sounds unreasonable that the "more generic" signature <code>fn(_) -&gt; _</code> is not compatible with <code>for&lt;'a&gt; fn (&amp;'a _) -&gt; _</code>. Why is the compiler not admitting the signature of <code>drop</code> here, and what makes it different when the toilet closure is placed in its stead?</p>
0debug
c# Getting variable from private : Im a noob to c# as my code is about to prove... namespace ClassLibrary6 { public partial class Form1 : Form { public static List<string> IList() //get title name for playlist { List<string> iList = new List<string>(); foreach (var playlist in PluginHelper.DataManager.GetAllPlaylists()) { iList.Add(playlist.Name); } return iList; } public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { CreateTheButtons(); } private void CreateTheButtons() //create buttons { List<string> hostList = IList(); int var1 = 0; foreach (var playlist in PluginHelper.DataManager.GetAllPlaylists()) //count playlists { ++var1; } myButton[] BooTon = new myButton[var1]; //add button on playlist count for (int i = 0; i < BooTon.Length; i++) { BooTon[i] = new myButton(); BooTon[i].Size = new Size(250, 50); BooTon[i].Location = new Point( 0 ,i * 60); BooTon[i].Text = (hostList[i]); BooTon[i].SetNum1(i); BooTon[i].Click += new EventHandler(ButtonClick); this.Controls.Add(BooTon[i]); } } private void ButtonClick(object sender, EventArgs e) { myButton btn = sender as myButton; List<string> hostList = IList(); MessageBox.Show(hostList[btn.GetNum1()]); //messagebox selected button playlist title //MessageBox.Show(btn.Num1 + ", " + iList[1] + "Button Clicked"); } } public class myButton : Button { private int num1; public int GetNum1() { return num1; } public void SetNum1(int value) { num1 = value; } } } What my code is trying to do. Create a list of playlist titles. Count how many playlists and add a windows form button for each playlist. Add playlist title to the button. When button is selected, match button number to playlist... do stuff My question is... how would i display " MessageBox.Show(hostList[btn.GetNum1()])" outside of the private void ButtonClick. I cant change it to public without errors. Is my get/set right? Would someone mind placing my messagebox outside private but still have it show on button press please. If you also have any tips for better practices please share. I have googled and searched but hit a wall. Any help would be appreciated.
0debug
In microservices should i use pub/sub instead RPC to get more loosely couple architecture? : <p>I current using a RPC call to another microservice via TCP and getting the response, but I think I can do it in this way:</p> <p>whithout make a RPC call, can I use a pub/sub to send to one service, publishing some channel like <em>request_user</em> and subscribed to a channel like <em>object_user_response</em>, and then the other service that is subscribed to this <em>request_user</em>, publish <em>object_user_response</em>.</p> <p>Like that:</p> <pre><code>Service A &lt;-- (sub)object_user_response &lt;------ Redis Service A --&gt; (pub)request_user -------------&gt; Redis Service B &lt;-- (sub)request_user &lt;--------------- Redis Service B --&gt; (pub) object_user_response ------&gt; Redis </code></pre> <p>On receive a object_user_response, the service A checks if the id of user is the same that the function have requested. </p> <p>Should I use RPC or Pub/sub for that? What is the most correct way to send data to a microservice and get response from there in terms of loosely coupled architecture, is using a RPC call or using two pub/sub, on for the request and another for the response? </p>
0debug
my program runs fine and i am able copy the object however when i used the copy assignment (=) it still runs fine .why is it not giving error? : this is my code.i didnt overload the (=) operator but still it runs fine in codeblocks.however when i ran this code on c++ shell it compiled succesfully however the output was blank .can somebody please explain me that why is it running fine in codeblocks even though i didnt write the code for the copy assignment . also another question... if in line 1 i change the return type to string instead of string& it displays an error (about temporary variable) but if i change the code of line 2 to dummy(dummy& abc : ptr(new string (abc.print())) the program runs fine (despite the return type of line 1 being string) why is it so? class dummy{ string *ptr; public: dummy(string ab) {ptr=new string; ptr=&ab;} ~dummy (){delete ptr;} string& print(){return *ptr;} //line1 dummy (dummy& abc){ptr= new string; ptr=&(abc.print());} //line2 dummy (){}; }; int main() { dummy x("manzar"); dummy y; y=x; cout<<x.print(); cout<<"\n"<<y.print (); } i didnt expected it to run fine however it is working fine.it is copying the content from x to y.
0debug
Long and wide data – when to use what? : <p>I'm in the process of compiling data from different data sets into one data set for analysis. I'll be doing data exploration, trying different things to find out what regularities may be hidden in the data, so I don't currently have a specific method in mind. Now I'm wondering if I should compile my data into long or wide format.</p> <p><strong>Which format should I use, and why?</strong></p> <p>I understand that data can be reshaped from long to wide or vice versa, but the mere existence of this functionality implies that the need to reshape sometimes arises and this need in turn implies that a specific format might be better suited for a certain task. So when do I need which format, and why?</p> <p>I'm not asking about performance. That has been covered in other questions.</p>
0debug
static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) { BDRVSheepdogState *s = bs->opaque; SheepdogReq req; int fd, nr = 1024, ret, max = BITS_TO_LONGS(SD_NR_VDIS) * sizeof(long); QEMUSnapshotInfo *sn_tab = NULL; unsigned wlen, rlen; int found = 0; static SheepdogInode inode; unsigned long *vdi_inuse; unsigned int start_nr; uint64_t hval; uint32_t vid; vdi_inuse = g_malloc(max); fd = connect_to_sdog(s->addr, s->port); if (fd < 0) { ret = fd; goto out; } rlen = max; wlen = 0; memset(&req, 0, sizeof(req)); req.opcode = SD_OP_READ_VDIS; req.data_length = max; ret = do_req(fd, (SheepdogReq *)&req, vdi_inuse, &wlen, &rlen); closesocket(fd); if (ret) { goto out; } sn_tab = g_malloc0(nr * sizeof(*sn_tab)); hval = fnv_64a_buf(s->name, strlen(s->name), FNV1A_64_INIT); start_nr = hval & (SD_NR_VDIS - 1); fd = connect_to_sdog(s->addr, s->port); if (fd < 0) { error_report("failed to connect"); ret = fd; goto out; } for (vid = start_nr; found < nr; vid = (vid + 1) % SD_NR_VDIS) { if (!test_bit(vid, vdi_inuse)) { break; } ret = read_object(fd, (char *)&inode, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE - sizeof(inode.data_vdi_id), 0, s->cache_enabled); if (ret) { continue; } if (!strcmp(inode.name, s->name) && is_snapshot(&inode)) { sn_tab[found].date_sec = inode.snap_ctime >> 32; sn_tab[found].date_nsec = inode.snap_ctime & 0xffffffff; sn_tab[found].vm_state_size = inode.vm_state_size; sn_tab[found].vm_clock_nsec = inode.vm_clock_nsec; snprintf(sn_tab[found].id_str, sizeof(sn_tab[found].id_str), "%u", inode.snap_id); pstrcpy(sn_tab[found].name, MIN(sizeof(sn_tab[found].name), sizeof(inode.tag)), inode.tag); found++; } } closesocket(fd); out: *psn_tab = sn_tab; g_free(vdi_inuse); if (ret < 0) { return ret; } return found; }
1threat
Learning xcode functions and getting wrong output : i am doing a homework assignment, learning how to use functions. i have created a function. and my output is coming out as (function) and not as what it should be ("Stuff") I'm more then positive my code is written correctly but my output is not coming out as the result i need but as (function) not sure what else to try func printsStuff() { prints("Stuff") } print(printsStuff) my output is "function" instead of "stuff"
0debug
TypeScript exports is not defined : <p>I'm trying to use export and import but it not working I get an error</p> <p>Here is my code HTML :</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;/head&gt; &lt;body&gt; @RenderBody() &lt;script src="~/scripts/user.js"&gt;&lt;/script&gt; &lt;script src="~/scripts/main.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>User.ts :</p> <pre><code>export class User { firstName: string; lastName: string; } </code></pre> <p>main.ts</p> <pre><code>import { User } from "./user"; </code></pre> <p>Here is also screenshot of exception :</p> <p><a href="https://i.stack.imgur.com/9DeNr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9DeNr.png" alt="enter image description here"></a></p>
0debug
How to add new column in existing View in SQL-Server 2014 using Alter : <p>I have created a view that is based on another view and a table. I want to add new column of type varchar. I did like below, But getting syntax error? I am new to SQL, So,could not understand</p> <pre><code>ALTER VIEW [dbo].[MyView] ADD New_Col varchar(10) null GO </code></pre>
0debug
void rgb24tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size) { unsigned i; for(i=0; 3*i<src_size; i++) { dst[4*i + 0] = src[3*i + 2]; dst[4*i + 1] = src[3*i + 1]; dst[4*i + 2] = src[3*i + 0]; dst[4*i + 3] = 0; } }
1threat
Extract strings from another string beginning and ending with a special char : <p>let's say I have a string like </p> <blockquote> <p>This {is} a new {test} {string} from me.</p> </blockquote> <p>My intention is to get all the strings surrounded by the <code>{</code> and <code>}</code> in a array, or a list. So I want to get: </p> <blockquote> <p>{is} {test} {string}</p> </blockquote> <p>Substring won't work here. Probably 'regex' is the solution, but I just can't get it to work for me. Can someone help?</p>
0debug
Get DateTime From Internet in C# : <p>I am new in programming and I'm practicing with a project and I need a DateTime for it. But as you know windows DateTime can be changed by user so I need a more solid time. So far I found this two different codes. (I don't need local time. I need a time that no matter where your location is it gives you the same time.)</p> <p><strong>So here is first way to get time :</strong></p> <pre><code>private void button1_Click(object sender, EventArgs e) { DateTime dateTime = DateTime.MinValue; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://nist.time.gov/actualtime.cgi?lzbc=siqm9b"); request.Method = "GET"; request.Accept = "text/html, application/xhtml+xml, */*"; request.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"; request.ContentType = "application/x-www-form-urlencoded"; request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { StreamReader stream = new StreamReader(response.GetResponseStream()); string html = stream.ReadToEnd(); string time = Regex.Match(html, @"(?&lt;=\btime="")[^""]*").Value; double milliseconds = Convert.ToInt64(time) / 1000.0; textBox1.Text = new DateTime(1970, 1, 1).AddMilliseconds(milliseconds).ToString(); } </code></pre> <p><strong>Here is the second way :</strong></p> <pre><code>private void button2_Click(object sender, EventArgs e) { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); var response = myHttpWebRequest.GetResponse(); string todaysDates = response.Headers["date"]; DateTime dateTime = DateTime.ParseExact(todaysDates, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal); textBox2.Text = dateTime.ToString(); response.Close(); } </code></pre> <p><strong>So here is the questions :</strong></p> <p>Which one of this codes you recommend me to use? (I really appreciate it if you give me a better code)</p> <p>Is that code requires any changes?</p> <p>Is the code no matter what your location is it still gives you the same time?</p> <p>Is the code always and on every computer works? (I'v read some comments about port 13 and how the code might not work depends on its status)</p>
0debug
An error while finding standart deviation of an image in MATLAB : [enter image description here][1] [1]: https://i.stack.imgur.com/Gz89O.jpg Hi, firstly i want to find standart deviation of this image. Secondly i want to find standart deviation of all lines in this image. But, at the first step somethings going wrong and i see this fault. >> A = imread('C:\Users\PC\Desktop\deneme.jpg'); >> std (A); Error using var (line 65) First argument must be single or double. Error in std (line 38) y = sqrt(var(varargin{:})); line 65: error(message('MATLAB:var:integerClass')); line 38: y = sqrt(var(varargin{:})); How can i solve this problem and what is the code of finding standart deviation of all lines in this image. Thank you.
0debug
static inline uint32_t ne2000_mem_readl(NE2000State *s, uint32_t addr) { addr &= ~1; if (addr < 32 || (addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) { return ldl_le_p(s->mem + addr); } else { return 0xffffffff; } }
1threat
int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot) { int fd; int64_t size; struct cow_header_v2 cow_header; #ifndef _WIN32 char template[] = "/tmp/vl.XXXXXX"; int cow_fd; struct stat st; #endif bs->read_only = 0; bs->fd = -1; bs->cow_fd = -1; bs->cow_bitmap = NULL; strcpy(bs->filename, filename); #ifdef _WIN32 fd = open(filename, O_RDWR | O_BINARY); #else fd = open(filename, O_RDWR | O_LARGEFILE); #endif if (fd < 0) { #ifdef _WIN32 fd = open(filename, O_RDONLY | O_BINARY); #else fd = open(filename, O_RDONLY | O_LARGEFILE); #endif if (fd < 0) { perror(filename); goto fail; } if (!snapshot) bs->read_only = 1; } bs->fd = fd; if (read(fd, &cow_header, sizeof(cow_header)) != sizeof(cow_header)) { fprintf(stderr, "%s: could not read header\n", filename); goto fail; } #ifndef _WIN32 if (be32_to_cpu(cow_header.magic) == COW_MAGIC && be32_to_cpu(cow_header.version) == COW_VERSION) { size = cow_header.size; #ifndef WORDS_BIGENDIAN size = bswap64(size); #endif bs->total_sectors = size / 512; bs->cow_fd = fd; bs->fd = -1; if (cow_header.backing_file[0] != '\0') { if (stat(cow_header.backing_file, &st) != 0) { fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow_header.backing_file); goto fail; } if (st.st_mtime != be32_to_cpu(cow_header.mtime)) { fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow_header.backing_file); goto fail; } fd = open(cow_header.backing_file, O_RDONLY | O_LARGEFILE); if (fd < 0) goto fail; bs->fd = fd; } bs->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header); bs->cow_bitmap_addr = mmap(get_mmap_addr(bs->cow_bitmap_size), bs->cow_bitmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, bs->cow_fd, 0); if (bs->cow_bitmap_addr == MAP_FAILED) goto fail; bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow_header); bs->cow_sectors_offset = (bs->cow_bitmap_size + 511) & ~511; snapshot = 0; } else #endif { size = lseek64(fd, 0, SEEK_END); bs->total_sectors = size / 512; bs->fd = fd; } #ifndef _WIN32 if (snapshot) { cow_fd = mkstemp64(template); if (cow_fd < 0) goto fail; bs->cow_fd = cow_fd; unlink(template); bs->cow_bitmap_size = (bs->total_sectors + 7) >> 3; bs->cow_bitmap_addr = mmap(get_mmap_addr(bs->cow_bitmap_size), bs->cow_bitmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (bs->cow_bitmap_addr == MAP_FAILED) goto fail; bs->cow_bitmap = bs->cow_bitmap_addr; bs->cow_sectors_offset = 0; } #endif bs->inserted = 1; if (bs->change_cb) bs->change_cb(bs->change_opaque); return 0; fail: bdrv_close(bs); return -1; }
1threat
static void test_nop(gconstpointer data) { QTestState *s; const char *machine = data; char *args; args = g_strdup_printf("-display none -machine %s", machine); s = qtest_start(args); if (s) { qtest_quit(s); } g_free(args); }
1threat
static void print_track_chunks(FILE *out, struct Tracks *tracks, int main, const char *type) { int i, j; struct Track *track = tracks->tracks[main]; for (i = 0; i < track->chunks; i++) { for (j = main + 1; j < tracks->nb_tracks; j++) { if (tracks->tracks[j]->is_audio == track->is_audio && track->offsets[i].duration != tracks->tracks[j]->offsets[i].duration) fprintf(stderr, "Mismatched duration of %s chunk %d in %s and %s\n", type, i, track->name, tracks->tracks[j]->name); } fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n", i, track->offsets[i].duration); } }
1threat
static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int y) { int shift1 = ctx->bit_depth == 10; int dct_linesize_luma = frame->linesize[0]; int dct_linesize_chroma = frame->linesize[1]; uint8_t *dest_y, *dest_u, *dest_v; int dct_y_offset, dct_x_offset; int qscale, i; qscale = get_bits(&ctx->gb, 11); skip_bits1(&ctx->gb); if (qscale != ctx->last_qscale) { for (i = 0; i < 64; i++) { ctx->luma_scale[i] = qscale * ctx->cid_table->luma_weight[i]; ctx->chroma_scale[i] = qscale * ctx->cid_table->chroma_weight[i]; } ctx->last_qscale = qscale; } for (i = 0; i < 8; i++) { ctx->bdsp.clear_block(ctx->blocks[i]); ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale); } if (ctx->is_444) { for (; i < 12; i++) { ctx->bdsp.clear_block(ctx->blocks[i]); ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale); } } if (frame->interlaced_frame) { dct_linesize_luma <<= 1; dct_linesize_chroma <<= 1; } dest_y = frame->data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 + shift1)); dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444)); dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444)); if (ctx->cur_field) { dest_y += frame->linesize[0]; dest_u += frame->linesize[1]; dest_v += frame->linesize[2]; } dct_y_offset = dct_linesize_luma << 3; dct_x_offset = 8 << shift1; if (!ctx->is_444) { ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]); ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]); ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]); if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) { dct_y_offset = dct_linesize_chroma << 3; ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]); ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]); ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]); ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]); } } else { ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]); ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]); ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[6]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]); if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) { dct_y_offset = dct_linesize_chroma << 3; ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]); ctx->idsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, ctx->blocks[3]); ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[8]); ctx->idsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[9]); ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[4]); ctx->idsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, ctx->blocks[5]); ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[10]); ctx->idsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[11]); } } return 0; }
1threat
Map in java - getting wrong map size : <p>I am trying to understand how Map interface works in Java. What I am trying to do is: run through the array of strings and for each name in the array <code>name[]</code> put a random <code>grade</code>between 0 to 5. Then map the <code>grade</code>to <code>name[i]</code>. However, the map size gets weird, although I have 10 elements in array, the <code>map.size()</code>is 5 after mapping. Why does the program count the same size several times (see output)? Here is the code and output below:</p> <pre><code> import java.util.*; class MapInterfaceExample{ public static void main(String[] args){ int grade = 0; String[] name = {"Lisa", "Dan", "John", "Adam", "George", "Amanda", "Sarah", "James", "Derek", "Sam"}; Map&lt;Integer,String&gt; map=new HashMap&lt;Integer,String&gt;(); for(int i=0; i&lt;name.length; i++){ grade = (int)(Math.random()*5+1); map.put(grade, name[i]); //System.out.println(grade + "\t"+ name[i]); System.out.println("Size of map "+ map.size());} } } </code></pre> <p>Output:</p> <p>Size of map 1</p> <p>Size of map 2</p> <p>Size of map 2</p> <p>Size of map 2</p> <p>Size of map 2</p> <p>Size of map 3</p> <p>Size of map 3</p> <p>Size of map 4</p> <p>Size of map 4</p> <p>Size of map 5</p>
0debug
ERROR in multi (webpack)-dev-server/client : <p>I'm new to webpack / reactjs, just follow the tutorial here: <a href="https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm" rel="noreferrer">https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm</a></p> <p>Then after I 'npm start', I got error:</p> <pre><code>ERROR in multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js Module not found: Error: Can't resolve 'babel' in '/var/www/jay/reactjs/react-app' BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders. You need to specify 'babel-loader' instead of 'babel'. @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js </code></pre> <p>Any ideas?</p>
0debug
Overloading Concept : public class Class2 extends Class1{ public static void main(String[] args) { Class2 c2 = new Class2(); c2.m3(10); c2.m3(10.5f); c2.m3('a'); c2.m3(10l); c2.m3(10.5); } public void m2(){ System.out.println("M1 method of class2"); } public void m3(int i){ System.out.println("int argument"); } public void m3(float j){ System.out.println("float argument"); } } Getting error when trying to call c2.m3(10.5); Could you please assist why this is happening?
0debug
What is the difference in Kafka between a Consumer Group Coordinator and a Consumer Group Leader? : <p>I see references to Kafka Consumer Group Coordinators and Consumer Group Leaders... </p> <ol> <li><p>What is the difference?</p></li> <li><p>What is the benefit from separating group management into two different sets of responsibilities?</p></li> </ol>
0debug
alert('Hello ' + user_input);
1threat
Bootstrap navbar-toggler-icon not visible but functioning normally : <p>I am trying to get my bootstrap navbar implemented into my handlebars layout file. I've noticed some weird things happening with bootstrap and this is no exception. Once I shrink my window to a size where the navbar-toggler-icon should show, it is not visible, but it is still functioning there like it should, I just can't see it.</p> <p>Here is my entire layout.hbs class:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;!-- Required meta tags --&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt; &lt;!-- Bootstrap CSS --&gt; &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"&gt; &lt;link rel="stylesheet" href="/stylesheets/style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;nav id="navigation" class="navbar navbar-inverse"&gt; &lt;a class="navbar-brand" href="#"&gt;Navbar&lt;/a&gt; &lt;button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"&gt; &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt; &lt;/button&gt; &lt;div class="collapse navbar-collapse" id="navbarSupportedContent"&gt; &lt;ul class="navbar-nav mr-auto"&gt; &lt;li class="nav-item active"&gt; &lt;a class="nav-link" href="#"&gt;Home &lt;span class="sr-only"&gt;(current)&lt;/span&gt;&lt;/a&gt; &lt;/li&gt; &lt;/div&gt; &lt;/nav&gt; {{{body}}} &lt;script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is an example of whats happening: <a href="https://i.stack.imgur.com/HZafG.png" rel="noreferrer">Picture of whats happening</a> I was told changing my navbar class to <code>navbar-inverse</code> would make it appear but I had no luck with this either.</p>
0debug
com.google.firebase.database.DatabaseException: Calls to setPersistenceEnabled() must be made before any other usage of FirebaseDatabase instance : <p>I am having a problem when I try to setPersistence in fIREBASE,can someone please explain on how to go about it,</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_meal_details); if (mDatabase == null) { mDatabase = FirebaseDatabase.getInstance().getReference(); FirebaseDatabase.getInstance().setPersistenceEnabled(true); // ... } // FirebaseDatabase.getInstance().setPersistenceEnabled(true); mDatabase = FirebaseDatabase.getInstance().getReference(); </code></pre>
0debug
to display date by calculating : how can i dispaly the date to exactly after 2 years depending on the user entered date.....by the way i am using "input type=date" method......can you just provide me ideas of dispalying the exact 2 years after date example: if a users enters the date in the text box using the calender i need the date to be exactly 2 years after to be displayed in the otheer text box example 1: if i enter date in the text box (lets just take its as some product manufacture date), i want it to automatically calculate the the entered date and display the 2 years later on date(the expiry date) by the i am using javascript.......i am happy if i get any ideas based on html, jquery
0debug
Flutter: Test that a specific exception is thrown : <p>in short, <code>throwsA(anything)</code> does not suffice for me while unit testing in dart. How to I test for a <strong>specific error message or type</strong>?</p> <p>Here is the error I would like to catch:</p> <pre><code>class MyCustErr implements Exception { String term; String errMsg() =&gt; 'You have already added a container with the id $term. Duplicates are not allowed'; MyCustErr({this.term}); } </code></pre> <p>here is the current assertion that passes, but would like to check for the error type above:</p> <p><code>expect(() =&gt; operations.lookupOrderDetails(), throwsA(anything));</code></p> <p>This is what I want to do:</p> <p><code>expect(() =&gt; operations.lookupOrderDetails(), throwsA(MyCustErr));</code></p>
0debug
getting the SUM() of claps and at the same time counting bookmarks in one query : I TRIED A LOT OF SOLUTION THAT LOOKS SIMILAR TO MY PROBLEM BUT NO ONE WORKED FOR ME . i have 5 tables (USERS, POSTS, BOOKMARKS, CLAPS, COMMENTS) **USERS** TABLE: ``` +----+-------+----------------+-------------+------------+ | id | name | email | password | register | +----+-------+----------------+-------------+------------+ | 1 | lofy | [email protected] | 123 | 2019-05-06 | | 2 | jake | [email protected] | 123 | 2019-06-22 | | 3 | moly | [email protected] | 123 | 2019-05-15 | +----+-------+----------------+-------------+------------+ ``` **POSTS** TABLE: ``` +----+-------+-------------------+--------------+------------+ | id | title | body | writer_id | date | +----+-------+-------------------+--------------+------------+ | 1 | lofy | blah blah blah.. | 1 | 2019-05-06 | | 2 | jake | blah blah blah.. | 2 | 2019-06-22 | | 3 | moly | blah blah blah.. | 2 | 2019-05-15 | +----+-------+-------------------+--------------+------------+ ``` **BOOKMARKED** TABLE: ``` +---------+-----------+ | user_id | post_id | +---------+-----------+ | 1 | 1 | | 2 | 2 | | 3 | 2 | +---------+-----------+ ``` **CLAPS** TABLE: ``` +---------+-----------+------------+ | user_id | post_id | claps_times| +---------+-----------+------------+ | 1 | 1 | 5 | | 2 | 2 | 13 | | 3 | 2 | 7 | +---------+-----------+------------+ ``` i used this query to get the posts details + the user name and avatar + how many times this post is bookmarked by the users ```SELECT posts.*, users.name, users.avatar , count(bookmarks.post_id) as bookmarksCount FROM posts LEFT JOIN users ON users.id = posts.owner LEFT Join bookmarks ON bookmarks.post_id = posts.id GROUP BY posts.id ; ``` EVERY THING IS GOOD TILL NOW . **THE PROBLEM:** i wanted to get the SUM() of the claps for each post so i added 2 more lines to the previous query , this is the query now: ``` SELECT posts.*, users.name, users.avatar , count(bookmarks.post_id) as bookmarksCount , SUM(claps.claps_count) AS totalClaps FROM posts LEFT JOIN users ON users.id = posts.owner LEFT Join bookmarks ON bookmarks.post_id = posts.id LEFT JOIN claps ON claps.post_id = posts.id GROUP BY posts.id ; ``` THE PROBLEM IS THAT THE RESULT OF THE CLAPS OF THE POST.ID "2" IS DOUBLED IT'S 40 INSTEAD OF 20, ITS LIKE THE JOIN OF THE COUNT() OF THE BOOKMARKS OF THE POST IS CAUSING THE PROBLEM , IN OTHER WORDS IF THE SUM() OF THE CLAPS ARE 10 AND THE POST IS BOOKMARKED 5 TIMES AFTER COUNT() THAN THE RESULT OF THE CLAPS WILL BE 50 INSTEAD OF 5. I TRYIED TO SUBQUERY THE SUM() OF THE CLAPS BUT I DIDN'T KNOW HOW TO DO IT . **CAN YOU PLEASE GIVE ME THE SOLUTION IN SUBQUERY WAY WITH A SOME EXPLANATION CAUSE I WILL ADD THE COUNT() OF THE COMMENTS LATER ON AND MAYBE MORE SUBQUEERIES TOO** **TY IN ADVANCE**
0debug
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) { MJpegDecodeContext *s = avctx->priv_data; int ret; if (!s->picture_ptr) { s->picture = av_frame_alloc(); if (!s->picture) return AVERROR(ENOMEM); s->picture_ptr = s->picture; } s->avctx = avctx; ff_blockdsp_init(&s->bdsp, avctx); ff_hpeldsp_init(&s->hdsp, avctx->flags); ff_idctdsp_init(&s->idsp, avctx); ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_zigzag_direct); s->buffer_size = 0; s->buffer = NULL; s->start_code = -1; s->first_picture = 1; s->org_height = avctx->coded_height; avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; avctx->colorspace = AVCOL_SPC_BT470BG; if ((ret = build_basic_mjpeg_vlc(s)) < 0) return ret; if (s->extern_huff) { av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n"); if ((ret = init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8)) < 0) return ret; if ((ret = ff_mjpeg_decode_dht(s))) { av_log(avctx, AV_LOG_ERROR, "mjpeg: error using external huffman table\n"); return ret; } } if (avctx->field_order == AV_FIELD_BB) { s->interlace_polarity = 1; av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n"); } if (avctx->codec->id == AV_CODEC_ID_AMV) s->flipped = 1; return 0; }
1threat
Why instance variables are not initialized before constructor creation. What happens if they are initialized at the class loading itself : <p>As we know Constructor purpose is to initialize instance variables, what if they are initialized before itself...does that effect the code..</p>
0debug
Facebook-passport with JWT : <p>I've been using <strong>Passport</strong> on my server for user authentication. When a user is signing in locally (using a username and password), the server sends them a <strong>JWT</strong> which is stored in localstorage, and is sent back to server for every api call that requires user authentication.</p> <p>Now I want to support <strong>Facebook and Google login</strong> as well. Since I began with Passport I thought it would be best to continue with Passport strategies, using <strong>passport-facebook</strong> and <strong>passport-google-oauth</strong>.</p> <p>I'll refer to Facebook, but both strategies behave the same. They both require redirection to a server route (<strong>'/auth/facebook'</strong> and <strong>'/auth/facebook/callback'</strong> for that matter). The process is successful to the point of saving users including their facebook\google ids and tokens on the DB.</p> <p>When the user is created on the server, a JWT is created (without any reliance on the token received from facebook\google). </p> <pre><code> ... // Passport facebook startegy var newUser = new User(); newUser.facebook = {}; newUser.facebook.id = profile.id; newUser.facebook.token = token; // token received from facebook newUser.facebook.name = profile.displayName; newUser.save(function(err) { if (err) throw err; // if successful, return the new user newUser.jwtoken = newUser.generateJwt(); // JWT CREATION! return done(null, newUser); }); </code></pre> <p>The problem is that after its creation, <strong>I don't find a proper way to send the JWT to the client</strong>, since I should also redirect to my app.</p> <pre><code>app.get('/auth/facebook/callback', passport.authenticate('facebook', { session: false, successRedirect : '/', failureRedirect : '/' }), (req, res) =&gt; { var token = req.user.jwtoken; res.json({token: token}); }); </code></pre> <p>The code above <strong>redirects me to my app main page, but I don't get the token</strong>. If I remove the successRedirect, <strong>I do get the token, but I'm not redirected to my app</strong>.</p> <p>Any solution for that? Is my approach wrong? Any suggestions will do. </p>
0debug
static int bochs_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVBochsState *s = bs->opaque; int i; struct bochs_header bochs; struct bochs_header_v1 header_v1; int ret; bs->read_only = 1; ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); if (ret < 0) { return ret; } if (strcmp(bochs.magic, HEADER_MAGIC) || strcmp(bochs.type, REDOLOG_TYPE) || strcmp(bochs.subtype, GROWING_TYPE) || ((le32_to_cpu(bochs.version) != HEADER_VERSION) && (le32_to_cpu(bochs.version) != HEADER_V1))) { error_setg(errp, "Image not in Bochs format"); return -EINVAL; } if (le32_to_cpu(bochs.version) == HEADER_V1) { memcpy(&header_v1, &bochs, sizeof(bochs)); bs->total_sectors = le64_to_cpu(header_v1.extra.redolog.disk) / 512; } else { bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512; } s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog); s->catalog_bitmap = g_malloc(s->catalog_size * 4); ret = bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap, s->catalog_size * 4); if (ret < 0) { goto fail; } for (i = 0; i < s->catalog_size; i++) le32_to_cpus(&s->catalog_bitmap[i]); s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4); s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512; s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512; s->extent_size = le32_to_cpu(bochs.extra.redolog.extent); qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->catalog_bitmap); return ret; }
1threat
CanActivate vs. CanActivateChild with component-less routes : <p>The angular2 documentation about <a href="https://angular.io/docs/ts/latest/guide/router.html#!#guards" rel="noreferrer">Route Guards</a> left me unclear about when it is appropriate to use a <code>CanActivate</code> guards vs. a <code>CanActivateChild</code> guard in combination with component-less routes. </p> <p><strong>TL;DR:</strong> what's the point in having <code>canActivateChild</code> when I can use a component-less routes with <code>canActivate</code> to achieve the same effect?</p> <p>Long version: </p> <blockquote> <p>We can have multiple guards at every level of a routing hierarchy. The router checks the CanDeactivate and CanActivateChild guards first, from deepest child route to the top. Then it checks the CanActivate guards from the top down to the deepest child route.</p> </blockquote> <p>I get that <code>CanActivateChild</code> is checked bottom up and <code>CanActivate</code> is checked top down. What doesn't make sense to me is the following example given in the docs: </p> <pre><code>@NgModule({ imports: [ RouterModule.forChild([ { path: 'admin', component: AdminComponent, canActivate: [AuthGuard], children: [ { path: '', canActivateChild: [AuthGuard], children: [ { path: 'crises', component: ManageCrisesComponent }, { path: 'heroes', component: ManageHeroesComponent }, { path: '', component: AdminDashboardComponent } ] } ] } ]) ], exports: [ RouterModule ] }) export class AdminRoutingModule {} </code></pre> <p>So the <code>admin</code> path has a component-less route: </p> <blockquote> <p>Looking at our child route under the AdminComponent, we have a route with a path and a children property but it's not using a component. We haven't made a mistake in our configuration, because we can use a component-less route.</p> </blockquote> <p>Why is the code in this case inserting the <code>AuthGuard</code> in the child and in the root component (path <code>admin</code>)? Wouldn't is suffice to guard at the root? </p> <p>I have created a <a href="http://plnkr.co/edit/B6s8H17q3pGDp2QAqKIU" rel="noreferrer">plunkr</a> based on the sample that removes the <code>canActivateChild: [AuthGuard]</code> and adds a logout button on the <code>AdminDashboard</code>. Sure enough, the <code>canActivate</code> of the parent route still guards, so what's the point in having <code>canActivateChild</code> when I can use component-less routes with <code>canActivate</code>?</p>
0debug
Getting Rows values into Column where Column values start with Integer in SQL Server : Below is my SQL Server table structure with sample data. DateValue Status EmpId 2018-05-28 8:00 01 2000347 2018-05-28 20:18 02 2000347 2018-05-28 8:00 01 2000348 2018-05-28 17:18 02 2000348 I want output like sEmpId Status (1)INTime Status(2)OutTime 2000347 2018-05-28 08:00:00.000 2018-05-28 20:18:00.000 2000348 2018-05-28 08:00:00.000 2018-05-28 17:18:00.000 You can find my try here - [**Row To Column**][1] I am getting the following error > Error(s), warning(s): Incorrect syntax near '01'. [1]: https://rextester.com/JFP40613
0debug
How to execute scripts after docker-compose up? : <p>I'm trying to make my dev process easier/maintainable using docker(-compose). I do not want to use any volumes (if that's possible). Why does import.sh not get executed after I run 'docker-compose up -d'?</p> <p>I have the following files:</p> <pre><code>docker-compose.yml mysql ---- import.sh ---- db.sql ---- Dockerfile </code></pre> <p>in <strong>docker-compose.yml</strong> there is:</p> <pre><code>version: '2' services: database: image: mysql build: context: ./mysql/ dockerfile: Dockerfile container_name: mysqltest ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: 123456 </code></pre> <p>in <strong>/mysql/Dockerfile</strong> there is:</p> <pre><code>ADD import.sh /tmp/import.sh ADD db.sql /tmp/db.sql RUN /tmp/import.sh </code></pre> <p>in <strong>/mysql/db.sql</strong> there is:</p> <pre><code>CREATE DATABASE test1; CREATE DATABASE test2; CREATE DATABASE test3; </code></pre>
0debug