problem
stringlengths
26
131k
labels
class label
2 classes
Weak' must not be applied to non-class-bound consider adding a protocol conformance that has a class bound : <p>I have a made a protocol in my VC in which i'm getting the location placemark from one my my swift file class. In my swift class i have declare the protocol like this,</p> <pre><code> weak var delegate: HandleMapSearch? </code></pre> <p>But the xcode is showing me error <code>'weak' must not be applied to non-class-bound 'HandleMapSearch'; consider adding a protocol conformance that has a class bound</code> . It was working fine before but now when i run the app it shows this error. What is this for and how can i remove this error? This is how i have created protocol in my VC class. </p> <pre><code>protocol HandleMapSearch { func dropPinZoomIn(placemark:MKPlacemark) } </code></pre>
0debug
Count the number of characters without len() and combine the variables : <h1>Q1</h1> <p>Write code that combines the following variables so that the sentence “You are doing a great job, keep it up!” is assigned to the variable message. Do not edit the values assigned to a, b, c, or d.</p> <h1>Q2</h1> <p>Count the number of characters in string str1. Do not use len(). Save the number in variable numbs</p> <p>I've tried some solutions as below. I wonder if there any faster way to solve it? </p> <h1>Q1</h1> <pre><code>a = "You are" b = "doing a great " c = "job" d = "keep it up!" seq1 = [a, b] seq2 = " ".join(seq1+[c]) message = ",".join(seq2 + [d]) </code></pre> <p>Is there any more simple way to deal with the problem? I hope I'm not hardcoding lol.</p> <h1>Q2</h1> <pre><code>str1 = "I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living." list1 = list(str1) print(list1) numbs = count(list1) print(numbs) </code></pre> <p>Should I use the count function like this in the code? Are there any modules or functions that I could apply? like loop function or Counter function?</p> <p>Thanks in advance!</p>
0debug
int avcodec_close(AVCodecContext *avctx) { entangled_thread_counter++; if(entangled_thread_counter != 1){ av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); entangled_thread_counter--; return -1; } if (ENABLE_THREADS && avctx->thread_opaque) avcodec_thread_free(avctx); if (avctx->codec->close) avctx->codec->close(avctx); avcodec_default_free_buffers(avctx); av_freep(&avctx->priv_data); avctx->codec = NULL; entangled_thread_counter--; return 0; }
1threat
Why is it bad practice to ask for full name in a form? : <p>In many many forms you see separate inputs for first and last name. I assume that asking for a users full name in one input is bad practice because you cannot rely on simply splitting the string by spaces to get the first and last names.</p> <p>Now I think about it i'm not sure if this would be a problem, can anyone shed any light on whether this is good or bad practice and if it is bad to ask for full name in a single input, why is it bad.</p> <p>Thanks</p>
0debug
no matching function for call : <p>i am new to c++ and i am currently trying to write a program that uses main to call functions which are seperately written and i tried to write the definitions for the header file declarations and i am getting errors with some functions which i have marked in the code</p> <p>Store.hpp</p> <pre><code>#ifndef STORE_HPP #define STORE_HPP class Product; class Customer; #include&lt;string&gt; #include "Customer.hpp" #include "Product.hpp" class Store { private: std::vector&lt;Product*&gt; inventory; std::vector&lt;Customer*&gt; members; public: void addProduct(Product* p); void addMember(Customer* c); Product* getProductFromID(std::string); Customer* getMemberFromID(std::string); void productSearch(std::string str); void addProductToMemberCart(std::string pID, std::string mID); void checkOutMember(std::string mID); }; #endif </code></pre> <p>i am having trouble writing the code for that function help me</p> <p>store.cpp</p> <pre><code>#include &lt;iostream&gt; #include &lt;string.h&gt; #include "Customer.hpp" #include "Store.hpp" #include "Product.hpp" using namespace std; string id; void Store::addProduct(Product* p) //error 1 no matching function { Product* p(std::string id, std::string t, std::string d, double p, int qa); inventory.push_back(p); } void Store:: addMember(Customer* c) { members.push_back(c-&gt;getAccountID()); } Product* Store::getProductFromID(std::string id) { for(int i = 0; i &lt; inventory.size(); i++) { Product* p=inventory.at(i); if(p-&gt;getIdCode()= id) { return p; } } return NULL; } Customer* Store:: getMemberFromID(std::string id) { for(int i = 0; i &lt; members.size(); i++) { Customer* c = members.at(i); if(c-&gt;getAccountID() == id) { return c; } } return NULL; } void std::Store productSearch(std::string str) { for(int i = 0; i &lt; inventory.size(); i++) { if(inventory[i] == str) { Product stud(inventory[i],inventory[i+1],inventory[i+2],inventory[i+3],inventory[i+4]); cout&lt;&lt;getIdCode(); cout&lt;&lt;getTitle(); cout&lt;&lt;getDescription(); cout&lt;&lt;getPrice(); cout&lt;&lt;getQuantityAvailable(); } } } void addProductToMemberCart(std::string pID, std::string mID) { cout&lt;&lt;"adding to cart"&lt;&lt;endl; getMemberFromID(mID)-&gt;addProductToCart(pID); } void checkOutMember(std::string mID) { Customer* c=getAccountID(mID) mID=getMemberFromID(std::string mID); if(mID=="NULL") { cout&lt;&lt;mID&lt;&lt;"is not found"&lt;&lt;endl; } } </code></pre> <p>customer.hpp</p> <pre><code>#ifndef CUSTOMER_HPP #define CUSTOMER_HPP #include&lt;vector&gt; #include "Product.hpp" class Customer { private: std::vector&lt;std::string&gt; cart; std::string name; std::string accountID; bool premiumMember; public: Customer(std::string n, std::string a, bool pm); std::string getAccountID(); //std::vector getCart(); void addProductToCart(std::string); bool isPremiumMember(); void emptyCart(); }; #endif </code></pre> <p>product.hpp</p> <pre><code>#ifndef PRODUCT_HPP #define PRODUCT_HPP #include&lt;vector&gt; class Product { private: std::string idCode; std::string title; std::string description; double price; int quantityAvailable; public: Product(std::string id, std::string t, std::string d, double p, int qa); std::string getIdCode(); std::string getTitle(); std::string getDescription(); double getPrice(); int getQuantityAvailable(); void decreaseQuantity(); }; #endif </code></pre>
0debug
static void generate_2_noise_channels(MLPDecodeContext *m, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int i; uint32_t seed = s->noisegen_seed; unsigned int maxchan = s->max_matrix_channel; for (i = 0; i < s->blockpos; i++) { uint16_t seed_shr7 = seed >> 7; m->sample_buffer[i][maxchan+1] = ((int8_t)(seed >> 15)) << s->noise_shift; m->sample_buffer[i][maxchan+2] = ((int8_t) seed_shr7) << s->noise_shift; seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5); } s->noisegen_seed = seed; }
1threat
how to call a subroutine of .pm file to another .pl file using perl : I have a script Attachments.pm which contains below package app::Attachments; use MIME::Lite; BEGIN{ use Exporter(); @ISA = qw(Exporter); @EXPORT = qw(&SendEMmsgAttachments); } sub SendEMmsgAttachments { $EM_SERVER = "1234.com"; $EM_FROM = "yyy@1234.com"; #hardcoded $EM_TIMEOUT = 120; my $mailMessage; my $mailToEmailAddress; my $mailSubject; my $mailBody; my $mailAttachmentFileName; my $mailAttachmentFullPath; $mailMessage = MIME::Lite->new ( From => $EM_FROM, To => $mailToEmailAddress, Subject => $mailSubject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; ### Add the text message part $mailMessage->attach ( Type => 'text/csv', Data => $mailBody ) or die "Error adding the text message part: $!\n"; ### Add the text file $mailMessage->attach ( Encoding => 'base64', Type => "text", I want to use "SendEMmsgAttachments" subroutine in my testscript.pl file so that i can send my excel attachment in email. Can anyone help me out in resolving the issue?
0debug
static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out) { OutputStream *ost = ofilter->ost; AVCodecContext *codec = ost->st->codec; AVFilterContext *last_filter = out->filter_ctx; int pad_idx = out->pad_idx; char *sample_fmts, *sample_rates, *channel_layouts; char name[255]; int ret; snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&ofilter->filter, avfilter_get_by_name("ffabuffersink"), name, NULL, NULL, fg->graph); if (ret < 0) return ret; #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \ AVFilterContext *filt_ctx; \ \ av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \ "similarly to -af " filter_name "=%s.\n", arg); \ \ ret = avfilter_graph_create_filter(&filt_ctx, \ avfilter_get_by_name(filter_name), \ filter_name, arg, NULL, fg->graph); \ if (ret < 0) \ return ret; \ \ ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \ if (ret < 0) \ return ret; \ \ last_filter = filt_ctx; \ pad_idx = 0; \ } while (0) if (ost->audio_channels_mapped) { int i; AVBPrint pan_buf; av_bprint_init(&pan_buf, 256, 8192); av_bprintf(&pan_buf, "0x%"PRIx64, av_get_default_channel_layout(ost->audio_channels_mapped)); for (i = 0; i < ost->audio_channels_mapped; i++) if (ost->audio_channels_map[i] != -1) av_bprintf(&pan_buf, ":c%d=c%d", i, ost->audio_channels_map[i]); AUTO_INSERT_FILTER("-map_channel", "pan", pan_buf.str); av_bprint_finalize(&pan_buf, NULL); } if (codec->channels && !codec->channel_layout) codec->channel_layout = av_get_default_channel_layout(codec->channels); sample_fmts = choose_sample_fmts(ost); sample_rates = choose_sample_rates(ost); channel_layouts = choose_channel_layouts(ost); if (sample_fmts || sample_rates || channel_layouts) { AVFilterContext *format; char args[256]; int len = 0; if (sample_fmts) len += snprintf(args + len, sizeof(args) - len, "sample_fmts=%s:", sample_fmts); if (sample_rates) len += snprintf(args + len, sizeof(args) - len, "sample_rates=%s:", sample_rates); if (channel_layouts) len += snprintf(args + len, sizeof(args) - len, "channel_layouts=%s:", channel_layouts); args[len - 1] = 0; av_freep(&sample_fmts); av_freep(&sample_rates); av_freep(&channel_layouts); snprintf(name, sizeof(name), "audio format for output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&format, avfilter_get_by_name("aformat"), name, args, NULL, fg->graph); if (ret < 0) return ret; ret = avfilter_link(last_filter, pad_idx, format, 0); if (ret < 0) return ret; last_filter = format; pad_idx = 0; } if (audio_volume != 256 && 0) { char args[256]; snprintf(args, sizeof(args), "%f", audio_volume / 256.); AUTO_INSERT_FILTER("-vol", "volume", args); } if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0) return ret; return 0; }
1threat
Passing value from ViewController to NSObject in Xcode : I need to pass value from a ViewController to NSObject as soon as the view loaded using Xcode with Objective c. I am using the code below but the value is null. -(void)viewDidAppear:(BOOL)animated { MyHomeModelNSObject *nsOb; nsOb.myString = self.userName.text; } The above code is working between Views when using segue, but it does not work with when passing the value to NSObject. Thanks
0debug
static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my, int i){ static const int tab_size = sizeof(s->direct_scale_mv[0])/sizeof(int16_t); static const int tab_bias = (tab_size/2); int xy= s->block_index[i]; uint16_t time_pp= s->pp_time; uint16_t time_pb= s->pb_time; int p_mx, p_my; p_mx= s->next_picture.motion_val[0][xy][0]; if((unsigned)(p_mx + tab_bias) < tab_size){ s->mv[0][i][0] = s->direct_scale_mv[0][p_mx + tab_bias] + mx; s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx : s->direct_scale_mv[1][p_mx + tab_bias]; }else{ s->mv[0][i][0] = p_mx*time_pb/time_pp + mx; s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx : p_mx*(time_pb - time_pp)/time_pp; } p_my= s->next_picture.motion_val[0][xy][1]; if((unsigned)(p_my + tab_bias) < tab_size){ s->mv[0][i][1] = s->direct_scale_mv[0][p_my + tab_bias] + my; s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my : s->direct_scale_mv[1][p_my + tab_bias]; }else{ s->mv[0][i][1] = p_my*time_pb/time_pp + my; s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my : p_my*(time_pb - time_pp)/time_pp; } }
1threat
static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx, PTLCommon *ptl) { int i; if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12) return -1; ptl->profile_space = get_bits(gb, 2); ptl->tier_flag = get_bits1(gb); ptl->profile_idc = get_bits(gb, 5); if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN) av_log(avctx, AV_LOG_DEBUG, "Main profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10) av_log(avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE) av_log(avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT) av_log(avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n"); else av_log(avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc); for (i = 0; i < 32; i++) ptl->profile_compatibility_flag[i] = get_bits1(gb); ptl->progressive_source_flag = get_bits1(gb); ptl->interlaced_source_flag = get_bits1(gb); ptl->non_packed_constraint_flag = get_bits1(gb); ptl->frame_only_constraint_flag = get_bits1(gb); skip_bits(gb, 16); skip_bits(gb, 16); skip_bits(gb, 12); return 0; }
1threat
create dictionary from lists in python : I have two lists in python of the following structure: [[x1,y1],[x2,y2],[x3,y3],[x4,y4],[x5,y5],[x6,y6],[x7,y7],[x8,y8]] , [1,1,2,2,3,3,3,4] And I want to create a dictionary with keys of the second list and values of the first list, that looks like this: {1: [[x1,y1], [x2,y2]], 2: [[x3,y3],[x4,y4]] , 3: [[x5,y5],[x6,y6],[x7,y7]], 4:[x8,y8]} What is the most efficient way to do this in python?
0debug
void qemu_console_resize(QEMUConsole *console, int width, int height) { if (console->g_width != width || console->g_height != height) { console->g_width = width; console->g_height = height; if (active_console == console) { dpy_resize(console->ds, width, height); } } }
1threat
how to replace last 5 digits with 99999 in update query, guide me how to do it : i have one column ,in that column all rows are having 10 digits '1234567890' By using update postgresql update sql i need to update last 5 digits to 99999. ie '1234599999' Can any one provide me update query for above requirement
0debug
How do I find the OS of a running EC2 instance? : <p>I looked at attributes of the EC2 instance, but did not get a clear attribute value that identifies the same.</p> <p>I also, saw the following discussion, but Im wondering whether identifying the os/platform has been simplified by aws since this disscusion. <a href="https://stackoverflow.com/questions/22950823/how-to-find-os-of-an-ec2-instance-using-aws-clia">How to find OS of an EC2 instance using AWS CLI</a></p>
0debug
static void vmsa_ttbcr_reset(CPUARMState *env, const ARMCPRegInfo *ri) { env->cp15.c2_base_mask = 0xffffc000u; env->cp15.c2_control = 0; env->cp15.c2_mask = 0; }
1threat
int opt_default(void *optctx, const char *opt, const char *arg) { const AVOption *o; int consumed = 0; char opt_stripped[128]; const char *p; const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); #if CONFIG_AVRESAMPLE const AVClass *rc = avresample_get_class(); #endif const AVClass *sc, *swr_class; if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) av_log_set_level(AV_LOG_DEBUG); if (!(p = strchr(opt, ':'))) p = opt + strlen(opt); av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); if ((o = opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) { av_dict_set(&codec_opts, opt, arg, FLAGS); consumed = 1; } if ((o = opt_find(&fc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { av_dict_set(&format_opts, opt, arg, FLAGS); if (consumed) av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt); consumed = 1; } #if CONFIG_SWSCALE sc = sws_get_class(); if (!consumed && (o = opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { struct SwsContext *sws = sws_alloc_context(); int ret = av_opt_set(sws, opt, arg, 0); sws_freeContext(sws); if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") || !strcmp(opt, "dstw") || !strcmp(opt, "dsth") || !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) { av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n"); return AVERROR(EINVAL); } if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; } av_dict_set(&sws_dict, opt, arg, FLAGS); consumed = 1; } #else if (!consumed && !strcmp(opt, "sws_flags")) { av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg); consumed = 1; } #endif #if CONFIG_SWRESAMPLE swr_class = swr_get_class(); if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { struct SwrContext *swr = swr_alloc(); int ret = av_opt_set(swr, opt, arg, 0); swr_free(&swr); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; } av_dict_set(&swr_opts, opt, arg, FLAGS); consumed = 1; } #endif #if CONFIG_AVRESAMPLE if ((o=opt_find(&rc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { av_dict_set(&resample_opts, opt, arg, FLAGS); consumed = 1; } #endif if (consumed) return 0; return AVERROR_OPTION_NOT_FOUND; }
1threat
How can I use variables with update query : <pre><code>$b=number_format($number[12],2); $sql01=mysql_query("UPDATE t_maindbfordashboard SET valueVar=".$a." WHERE managementName=dds"); </code></pre> <p>I am absolutely sure that there are no problems connecting to the database or such. This query works when I try "SELECT * FROM tableName". Where do you think I'm making a mistake?</p>
0debug
JS Bitwise Operato to Java : I'm trying to convert a js function to Java but i don't know how to work with JS Bitwise operator in java. I need to translate this: var r = '0x' + a.substring(j, 2) | 0 and ('0x' + a.substr(j, 2) ^ r) Anyone has ever done this? Thnaks!
0debug
Java Project Architecture Samples : <p>What is the best book, source for designing a good project architecture based on Java, JEE, Rest, Spring etc. I know all of the technologies and best practices pretty well, but there is no one who can give me a feed back on the architectural issues of my app. Especially when it comes to concurrency and multi threading part, I am always doubtful if this is the best way to solve the problems. Unfortunately, I search the INTERNET and can't find any sample, or reference projects that focuses on the architecture rather than a specific tech. only. E.g. you can find millions of articulates on rest, but nothing on how you should deal with multithreading in a restful env. etc. If you can suggest any books, materials, or reference code, I would really appreciate it. Thanks </p>
0debug
Abnormal mathematical operation in C : <p>I've found this question somewhere and couldn't understand it. Please help me out with this.</p> <pre><code>#include&lt;stdio.h&gt; int main(){ char x = 250; int ans = x + !x + ~x + ++x; printf("%d", ans); } </code></pre> <p>The output comes out to be -6. I don't understand how the compiler performs operation. </p> <p>Thanks in advance!</p>
0debug
I would like the tag not to change its style until it will be selected by id and class(NOT TAG NAME) : I create extension which create some div in that page where is it open...But in different site it's look different.Cuz it get website div's style.
0debug
Can't decrypt RSA data with open SSL : <p>I try to encrypt some data in matlab using a public key I created with openssl</p> <p>I created the keys using:</p> <pre><code>openssl genrsa -des3 -out private.pem 1024 openssl rsa -in private.pem -pubout -outform DER -out public.der </code></pre> <p>I encrypt my data using this matlab code (with Java libraries):</p> <pre><code>import java.security.spec.RSAPublicKeySpec import javax.crypto.Cipher; import java.security.KeyFactory import java.math.BigInteger fid = fopen('public.der'); a = fread(fid); key = java.security.spec.X509EncodedKeySpec(a); kf = KeyFactory.getInstance('RSA'); KEY = kf.generatePublic(key); cipher = Cipher.getInstance('RSA/ECB/PKCS1Padding'); cipher.init(Cipher.ENCRYPT_MODE, KEY) plaintextBytes = [24]; ciphertext = cipher.doFinal(plaintextBytes)' ; fid2 = fopen('msg.txt','w'); fwrite(fid2,ciphertext); fclose(fid2); </code></pre> <p>I try to decrypt it using:</p> <pre><code>openssl rsautl -decrypt -inkey private.pem -in msg.txt -keyform PEM -pkcs </code></pre> <p>Then I get this error:</p> <pre><code>RSA operation error 80305:error:0407109F:rsa routines:RSA_padding_check_PKCS1_type_2:pkcs decoding error:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59.40.2/src/crypto/rsa/rsa_pk1.c:267: 80305:error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failed:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59.40.2/src/crypto/rsa/rsa_eay.c:614: </code></pre>
0debug
ASP.NET Identity Bearer Token vs JWT Pros and Cons : <p>I have used ASP.NET Identity for a while now and have been looking at JWT (JSON Web Token) as they seem really interesting and easy to use.</p> <p><a href="https://jwt.io/" rel="noreferrer">JWT.IO</a> has a great example/tool of debugging the token.</p> <p>However, I'm not entirely sure how JWT's work on the back end, would you still use Identity?</p> <p>Also how do the tokens (Bearer vs JWT) compare? Which is more secure?</p>
0debug
Nuget CLI in Visual Studio 2017 - How to run? : <p>According to the page at: <a href="https://dist.nuget.org/index.html" rel="noreferrer">https://dist.nuget.org/index.html</a></p> <blockquote> <p>NuGet 4.x is included in the Visual Studio 2017 installation. Latest NuGet releases are delivered as part of Visual Studio updates.</p> <p>Batteries are included!</p> </blockquote> <p>No matter whether I open a Visual Studio 2017 command prompt or the Nuget console itself, running the 'nuget' command results in command not found.</p> <p>How can I run the nuget CLI with Visual Studio 2017? What am I missing?</p>
0debug
How to setup single Nuget packages folder for multiple solutions and projects in Visual Studio 2015 : <p>We are developing multiple solutions in Visual Studio 2015. The solutions share some core projects that need nuget packages. The nuget references cannot be resolved when the nuget package is added from one solution and is later opened by another solution.</p> <p>The folder structure is as follows:</p> <ul> <li>Codebase <ul> <li>SharedProjects <ul> <li>SharedProject1</li> </ul></li> <li>SolutionA <ul> <li>WebProjectA</li> <li>packages folder A</li> </ul></li> <li>SolutionB <ul> <li>WebProjectB</li> <li>packages folder B</li> </ul></li> </ul></li> </ul> <p>When I install a nuget package to <code>SharedProject1</code> when <code>SolutionA</code> is opened, the dll reference shows the path to the <code>packages folder A</code>. When <code>SolutionB</code> is opened in another computer, <code>SharedProject1</code> has a reference error since the <code>packages folder A</code> doesn't exist.</p> <p>I have read this solution: <a href="https://stackoverflow.com/questions/18376313/setting-up-a-common-nuget-packages-folder-for-all-solutions-when-some-projects-a">Setting up a common nuget packages folder for all solutions when some projects are included in multiple solutions</a> but this doesn't solve the problem since the <code>repositoryPath</code> key in the .nuget/NuGet.config file is not applied with <code>Visual Studio 2015</code> and <code>Nuget 3.4.3</code> </p>
0debug
static inline bool valid_ptex(PowerPCCPU *cpu, target_ulong ptex) { if (((ptex & ~7ULL) / HPTES_PER_GROUP) & ~cpu->env.htab_mask) { return false; } return true; }
1threat
document.write('<script src="evil.js"></script>');
1threat
Big Nerd Android GeoQuiz - answer not passed to CheatActivity : <p>I'm working on Big Nerd Android GeoQuiz Application, chapter 5. The correct solution is not passed to CheatActivity.</p> <p>This is cheat activity:</p> <pre><code>public class CheatActivity extends AppCompatActivity { private static final String EXTRA_ANSWER_IS_TRUE = "org.mydomain.geoquiz.answer_is_true"; private boolean mAnswerIsTrue; private TextView mAnswerTextView; private Button mShowAnswerButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cheat); mAnswerIsTrue = getIntent().getBooleanExtra("EXTRA_ANSWER_IS_TRUE", false); mAnswerTextView = (TextView) findViewById(R.id.answer_text_view); mShowAnswerButton = (Button) findViewById(R.id.show_answer_button); mShowAnswerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAnswerIsTrue) { mAnswerTextView.setText(R.string.true_button); } else { mAnswerTextView.setText(R.string.false_button); } } }); } public static Intent newIntent(Context packageContext, boolean answerIsTrue) { Intent intent = new Intent(packageContext, CheatActivity.class); intent.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue); return intent; } </code></pre> <p>}</p> <p>And it gets called by Quiz activity:</p> <pre><code> mCheatButton = (Button) findViewById(R.id.cheat_button); mCheatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue(); Intent intent = CheatActivity.newIntent(QuizActivity.this, answerIsTrue); startActivity(intent); } }); </code></pre> <p>Using the debugger I see that the correct value is passed. But in cheat activity when I set mAnswerIsTrue, it is always set as false. What am I doing wrong?</p> <p>Thanks.</p>
0debug
Verilog - re-using register valueon Edge vent : ---------- Consider the following code: Module Test (B, A CLK) Input A; CLK Output B Reg RA; Always @(Posedge CLK) Begin RA=A; B=RA; End EndModule Would that work properly to move the input to the register and then to the output on every positive edge? Can it be created with circuits?
0debug
static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { DPRINTF("ACMD%d 0x%08x\n", req.cmd, req.arg); sd->card_status |= APP_CMD; switch (req.cmd) { case 6: switch (sd->state) { case sd_transfer_state: sd->sd_status[0] &= 0x3f; sd->sd_status[0] |= (req.arg & 0x03) << 6; return sd_r1; default: break; } break; case 13: switch (sd->state) { case sd_transfer_state: sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0; return sd_r1; default: break; } break; case 22: switch (sd->state) { case sd_transfer_state: *(uint32_t *) sd->data = sd->blk_written; sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0; return sd_r1; default: break; } break; case 23: switch (sd->state) { case sd_transfer_state: return sd_r1; default: break; } break; case 41: if (sd->spi) { sd->state = sd_transfer_state; return sd_r1; } switch (sd->state) { case sd_idle_state: if (req.arg & ACMD41_ENQUIRY_MASK) { sd->state = sd_ready_state; } return sd_r3; default: break; } break; case 42: switch (sd->state) { case sd_transfer_state: return sd_r1; default: break; } break; case 51: switch (sd->state) { case sd_transfer_state: sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0; return sd_r1; default: break; } break; default: return sd_normal_command(sd, req); } fprintf(stderr, "SD: ACMD%i in a wrong state\n", req.cmd); return sd_illegal; }
1threat
Using local function outside it's scope : while(t!=0) { for(j=1;j <=3;j++) { cin>>size; int arrj[size] for(i=0;i<3;i++) { cin>>arrj [i]; } } } **How do i use arrj [] outside the while loop as the array is a local variable to while loop**
0debug
how to get socket.id of a connection on client side? : <p>Im using the following code in index.js</p> <pre><code>io.on('connection', function(socket){ console.log('a user connected'); console.log(socket.id); }); </code></pre> <p>the above code lets me print the socket.id in console.</p> <p>But when i try to print the socket.id on client side using the following code</p> <pre><code>&lt;script&gt; var socket = io(); var id = socket.io.engine.id; document.write(id); &lt;/script&gt; </code></pre> <p>it gives 'null' as output in the browser.</p>
0debug
static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size, int calculate_checksum) { put_flush_packet(bc); nut->packet_start[2]= url_ftell(bc) - 8; nut->written_packet_size = max_size; if(calculate_checksum) init_checksum(bc, update_adler32, 0); put_v(bc, nut->written_packet_size); return 0; }
1threat
Plotting a text file by using gnuplot in python : I have a text file called data.txt and it looks like this: 0 0.0025 sec 1 0.254 sec 2 0.5654 sec I want to plot it by using gnuplot in python. When I enter gnuplot my command line look like this; gnuplot > What do I have to do now to plot my text file and view it?
0debug
How you you assign the value of a char pointer to an integer : <p>Is there a way to assign the value of a char pointer to an integer</p>
0debug
What is best practice for sharing database between containers in docker? : <p>Is there anyone knows what is the best practice for sharing database between containers in docker? <br></p> <p>What I mean is I want to create multiple containers in docker. Then, these containers will execute CRUD on the same database with same identity. <br></p> <p>So far, I have two ideas. One is create an separate container to run database merely. Another one is install database directly on the host machine where installed docker. </p> <p>Which one is better? Or, is there any other best practice for this requirement?</p> <p>Thanks</p>
0debug
Angular2: Show activity indicator for every HTTP request and hide views until completed : <p>Im new to Angular2 and I was wondering if there is any way to show an activity indicator for every HTTP request and hide views until completed?</p>
0debug
static void get_sensor_type(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(3); if ((cmd[2] > MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = ibs->sensors + cmd[2]; IPMI_ADD_RSP_DATA(sens->sensor_type); IPMI_ADD_RSP_DATA(sens->evt_reading_type_code); }
1threat
Simple JavaScript. Why doesn't it work? : short and simple. yet it does not work, which makes me sad and angry. :( <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> window.onload = function() { var textonaut = { text: '', letters: [] }; textonaut.text = document.getElementById('textonaut-text').value; var go = document.getElementById('go-button'); go.addEventListener('click', function(e) { e.preventDefault(); textonaut.letters = textonaut.text.split(''); for(var i = 0; i < textonaut.letters.length; i++) { console.log(textonaut.letters[i]); }; }); } <!-- language: lang-html --> <input id="textonaut-text" type="text"><button id="go-button">go</button> <!-- end snippet -->
0debug
How to add Google Authenticator to my website? : <p>I have a web app that is Angular2 on the front-end and NodeJS on the back-end. I want to allow clients to use Google Authenticator to make their accounts more secure.</p> <p>How can I implement/use Google Authenticator in my website? I cannot find an API to use or and tutorials to follow or any libraries to use. Where can I find some resources to do this?</p>
0debug
void cpu_ppc_store_decr (CPUState *env, uint32_t value) { }
1threat
Example for multi user role having Admin, user by using CodeIgniter : I am new to codeigniter i want to learn how to create a different homepage and access controls for user and admin. Give me some basic examples for to learn this. Thank you
0debug
Uncaught exception thrown by finalizer java.lang.IllegalStateException: Binder has been finalized : <p>This code</p> <pre><code>soundPool.release(); soundPool = null; </code></pre> <p>sometimes produces this error:</p> <pre><code>Uncaught exception thrown by finalizer java.lang.IllegalStateException: Binder has been finalized! at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:503) at com.android.internal.app.IAppOpsService$Stub$Proxy.stopWatchingMode(IAppOpsService.java:431) at android.media.SoundPool.release(SoundPool.java:195) at android.media.SoundPool.finalize(SoundPool.java:204) at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:217) at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:200) at java.lang.Thread.run(Thread.java:818) </code></pre> <p>What can I do?</p>
0debug
AJAX functionality in WinForms : <p>I am looking for approach and not any code here - What is the best method to implement ajax like content fetch (from DB) in WinForms ?</p>
0debug
Is their a better way to write this code? : <p>I know that this code does what I need it to do for my assignment but I can't help but feel like there is a much more...refined way to get the same results. Note that the last few outputs should only display if there have been at least 1 number(s) that are greater or less than 0</p> <pre><code>//This program will take an unspecified number of //integers, determine how many of those integers are //positive and how many are negative, and finally //compute the total and average of the integers. import java.util.Scanner; public class exampleWork { public static void main(String[] args) { //create a scanner Scanner input = new Scanner(System.in); //create a variable to hold the positive integers int pos = 0; //create a variable to hold the negative integers int neg = 0; //create a variable to hold the total number of entries int total = 0; //create a variable to hold the average float avg = 0; //create a counter variable int count = 0; //prompt user to enter integer System.out.println("Enter an integer, the input ends if it is 0: "); int usrInput = input.nextInt(); //determine if the number is positive, negative, //or zero, and either place in relative variables, //or end the loop. if (usrInput == 0) System.out.print("Only zero was entered"); while (usrInput != 0) { if (usrInput &gt; 0){ pos++; total += usrInput; count++; System.out.println("Enter an integer, the input ends if it is 0: "); usrInput = input.nextInt(); } if (usrInput &lt; 0){ neg++; total += usrInput; count++; System.out.println("Enter an integer, the input ends if it is 0: "); usrInput = input.nextInt(); } } if (count &gt; 0){ avg = (total / count); System.out.println("The number of positives is " + pos); System.out.println("The number of negatives is " + neg); System.out.println("The total is " + total); System.out.println("The average is " + avg); } </code></pre> <p>}</p> <p>}</p>
0debug
Issue when opening zip file in python : Error when reading a zip file in python I have a problem where I have to read over the zip folder and read the zip files within. I am getting an error while reading one of the text files from the zipped folder. [![enter image description here][1]][1] ```with zipfile.ZipFile(file_name) as zipped: for filenames in zipped.namelist(): if not os.path.isdir(filenames): print(filenames) with open(filenames,"r",encoding="utf8") as file1: print(file1) ``` When I try to run this code I a getting an error that xxxx-005.txt file not found I have the zip file in the same folder as the code. [1]: https://i.stack.imgur.com/BOzeb.png
0debug
static int aiff_read_header(AVFormatContext *s, AVFormatParameters *ap) { int size, filesize; offset_t offset = 0; uint32_t tag; unsigned version = AIFF_C_VERSION1; ByteIOContext *pb = s->pb; AVStream * st = s->streams[0]; filesize = get_tag(pb, &tag); if (filesize < 0 || tag != MKTAG('F', 'O', 'R', 'M')) return AVERROR_INVALIDDATA; tag = get_le32(pb); if (tag == MKTAG('A', 'I', 'F', 'F')) version = AIFF; else if (tag != MKTAG('A', 'I', 'F', 'C')) return AVERROR_INVALIDDATA; filesize -= 4; st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); while (filesize > 0) { size = get_tag(pb, &tag); if (size < 0) return size; filesize -= size + 8; switch (tag) { case MKTAG('C', 'O', 'M', 'M'): st->nb_frames = get_aiff_header (pb, st->codec, size, version); if (st->nb_frames < 0) return st->nb_frames; if (offset > 0) goto got_sound; break; case MKTAG('F', 'V', 'E', 'R'): version = get_be32(pb); break; case MKTAG('N', 'A', 'M', 'E'): get_meta (pb, s->title, sizeof(s->title), size); break; case MKTAG('A', 'U', 'T', 'H'): get_meta (pb, s->author, sizeof(s->author), size); break; case MKTAG('(', 'c', ')', ' '): get_meta (pb, s->copyright, sizeof(s->copyright), size); break; case MKTAG('A', 'N', 'N', 'O'): get_meta (pb, s->comment, sizeof(s->comment), size); break; case MKTAG('S', 'S', 'N', 'D'): offset = get_be32(pb); get_be32(pb); offset += url_ftell(pb); if (st->codec->codec_id) goto got_sound; if (url_is_streamed(pb)) { av_log(s, AV_LOG_ERROR, "file is not seekable\n"); } url_fskip(pb, size - 8); break; case MKTAG('w', 'a', 'v', 'e'): st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = size; get_buffer(pb, st->codec->extradata, size); break; default: if (size & 1) size++; url_fskip (pb, size); } } return AVERROR_INVALIDDATA; got_sound: if (st->nb_frames) s->file_size = st->nb_frames * st->codec->block_align; av_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; st->duration = st->codec->frame_size ? st->nb_frames * st->codec->frame_size : st->nb_frames; url_fseek(pb, offset, SEEK_SET); return 0; }
1threat
How to relate a version of @types to the versions of the associated package in NodeJS Typescript? : <p>I am working on a nodejs project with typescript 2.2 that is using node 6.3.1 and I want to migrate from using typings to using @types. By doing so I ran into a set of questions related to whether there is a relationship between the version of the @types file and the corresponding npm package.</p> <p>If I use jasmine as an example, the existing versions of the types definitions are </p> <pre><code>npm show @types/jasmine@* version @types/jasmine@1.3.0 '1.3.0' @types/jasmine@1.3.1 '1.3.1' @types/jasmine@1.3.2 '1.3.2' @types/jasmine@2.2.29 '2.2.29' @types/jasmine@2.2.30 '2.2.30' @types/jasmine@2.2.31 '2.2.31' @types/jasmine@2.2.32 '2.2.32' @types/jasmine@2.2.33 '2.2.33' @types/jasmine@2.2.34 '2.2.34' @types/jasmine@2.5.35 '2.5.35' @types/jasmine@2.5.36 '2.5.36' @types/jasmine@2.5.37 '2.5.37' @types/jasmine@2.5.38 '2.5.38' @types/jasmine@2.5.39 '2.5.39' @types/jasmine@2.5.40 '2.5.40' @types/jasmine@2.5.41 '2.5.41' @types/jasmine@2.5.42 '2.5.42' @types/jasmine@2.5.43 '2.5.43' @types/jasmine@2.5.44 '2.5.44' @types/jasmine@2.5.45 '2.5.45' @types/jasmine@2.5.46 '2.5.46' </code></pre> <p>But if I examine the versions of the jasmine packages I have;</p> <pre><code>npm show jasmine@* version jasmine@2.0.1 '2.0.1' jasmine@2.1.0 '2.1.0' jasmine@2.1.1 '2.1.1' jasmine@2.2.0 '2.2.0' jasmine@2.2.1 '2.2.1' jasmine@2.3.0 '2.3.0' jasmine@2.3.1 '2.3.1' jasmine@2.3.2 '2.3.2' jasmine@2.4.0 '2.4.0' jasmine@2.4.1 '2.4.1' jasmine@2.5.0 '2.5.0' jasmine@2.5.1 '2.5.1' jasmine@2.5.2 '2.5.2' jasmine@2.5.3 '2.5.3' </code></pre> <p>Let’s say I am using version 2.4.0 of jasmine, which version of @types/jasmine should I pick? Because even if I use the latest of both, 2.5.46 does not match with 2.5.3. </p> <p>Another example would be node itself, there are basically 6.0 or 7.0 versions in @types, and typings has only the ones shown below, being 6.0 reported as obsolete. So, what version of node are those typings actually tied to?</p> <pre><code>typings view dt~node --versions TAG VERSION DESCRIPTION COMPILER LOCATION UPDATED 7.0.0+20170322231424 7.0.0 github:DefinitelyTyped/DefinitelyTyped/node/index.d.ts#a4a912a0cd1849fa7df0e5d909c8625fba04e49d 2017-03-22T23:14:24.000Z 6.0.0+20161121110008 6.0.0 github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#fb7fbd28b477f5e239467e69397ed020d92817e7 2016-11-21T11:00:08.000Z </code></pre> <p>Thanks</p>
0debug
Get mean of a distribution Pyhton : So, I generated a vector d of data that follows a normal distribution with some mean and variance. I want then to calculate a vector s such that each component of it is a function of the type si=f(di). Then I want to do the mean. Is there in Python any quick way to do that without any cycle?
0debug
Cycle does not work : <p>I was writing a simple program in Python. Firstly, user inputs some data. If the data equals to 'y', then the cycle starts</p> <pre><code>ans = raw_input() if ans.lower() == 'y': for path in mas[]: print("This is cycle") function() print("End of program") </code></pre> <p>The problem is that terminal outputs only "End of program". Neither the function nor the output of the text in the loop does not work.</p>
0debug
static void openpic_src_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) { OpenPICState *opp = opaque; int idx; DPRINTF("%s: addr %#" HWADDR_PRIx " <= %08" PRIx64 "\n", __func__, addr, val); if (addr & 0xF) { return; } addr = addr & 0xFFF0; idx = addr >> 5; if (addr & 0x10) { write_IRQreg_idr(opp, idx, val); } else { write_IRQreg_ivpr(opp, idx, val); } }
1threat
Discriminated Union of Generic type : <p>I'd like to be able to use <a href="https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html" rel="noreferrer">union discrimination</a> with a generic. However, it doesn't seem to be working:</p> <p>Example Code (<a href="http://www.typescriptlang.org/play/#src=interface%20Foo%7B%0D%0A%20%20%20%20type%3A%20&#39;foo&#39;%3B%0D%0A%20%20%20%20fooProp%3A%20string%0D%0A%7D%0D%0A%0D%0Ainterface%20Bar%7B%0D%0A%20%20%20%20type%3A%20&#39;bar&#39;%0D%0A%20%20%20%20barProp%3A%20number%0D%0A%7D%0D%0A%0D%0Ainterface%20GenericThing%3CT%3E%20%7B%0D%0A%20%20%20%20item%3A%20T%3B%0D%0A%7D%0D%0A%0D%0A%0D%0Alet%20func%20%3D%20(genericThing%3A%20GenericThing%3CFoo%20%7C%20Bar%3E)%20%3D%3E%20%7B%0D%0A%20%20%20%20if%20(genericThing.item.type%20%3D%3D%3D%20&#39;foo&#39;)%20%7B%0D%0A%0D%0A%20%20%20%20%20%20%20%20genericThing.item.fooProp%3B%20%2F%2F%20this%20works%2C%20but%20type%20of%20genericThing%20is%20still%20GenericThing%3CFoo%20%7C%20Bar%3E%0D%0A%0D%0A%20%20%20%20%20%20%20%20let%20fooThing%20%3D%20genericThing%3B%0D%0A%20%20%20%20%20%20%20%20fooThing.item.fooProp%3B%20%2F%2Ferror!%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A" rel="noreferrer">view on typescript playground)</a>:</p> <pre><code>interface Foo{ type: 'foo'; fooProp: string } interface Bar{ type: 'bar' barProp: number } interface GenericThing&lt;T&gt; { item: T; } let func = (genericThing: GenericThing&lt;Foo | Bar&gt;) =&gt; { if (genericThing.item.type === 'foo') { genericThing.item.fooProp; // this works, but type of genericThing is still GenericThing&lt;Foo | Bar&gt; let fooThing = genericThing; fooThing.item.fooProp; //error! } } </code></pre> <p>I was hoping that typescript would recognize that since I discriminated on the generic <code>item</code> property, that <code>genericThing</code> must be <code>GenericThing&lt;Foo&gt;</code>. </p> <p>I'm guess this just isn't supported? </p> <p>Also, kinda weird that after straight assignment, it <code>fooThing.item</code> loses it's discrimination.</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Adding Routing to a Vue.js cli 3.0 app : <p>The new Vue.js 3.0 plugin architecture is nice, but it seems to to be missing a router plugin. If I choose not to install routing when I first create the project (<code>vue create my-project</code>), I'd expect that I could change my mind later and add routing with something like <code>vue add @vue/router</code>, but that plugin doesn't appear to exist. Is there a way to add routing from the CLI after the fact?</p>
0debug
void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) { int ret; int status; pid_t pid; Error *local_err = NULL; struct timeval tv; if (has_time) { if (time_ns / 1000000000 != (time_t)(time_ns / 1000000000)) { error_setg(errp, "Time %" PRId64 " is too large", time_ns); return; } tv.tv_sec = time_ns / 1000000000; tv.tv_usec = (time_ns % 1000000000) / 1000; g_date_set_time_t(&date, tv.tv_sec); if (date.year < 1970 || date.year >= 2070) { error_setg_errno(errp, errno, "Invalid time"); return; } ret = settimeofday(&tv, NULL); if (ret < 0) { error_setg_errno(errp, errno, "Failed to set time to guest"); return; } } pid = fork(); if (pid == 0) { setsid(); reopen_fd_to_null(0); reopen_fd_to_null(1); reopen_fd_to_null(2); execle("/sbin/hwclock", "hwclock", has_time ? "-w" : "-s", NULL, environ); _exit(EXIT_FAILURE); } else if (pid < 0) { error_setg_errno(errp, errno, "failed to create child process"); return; } ga_wait_child(pid, &status, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (!WIFEXITED(status)) { error_setg(errp, "child process has terminated abnormally"); return; } if (WEXITSTATUS(status)) { error_setg(errp, "hwclock failed to set hardware clock to system time"); return; } }
1threat
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url) { const char *p, *ls, *ls2, *at, *col, *brk; if (port_ptr) *port_ptr = -1; if (proto_size > 0) proto[0] = 0; if (authorization_size > 0) authorization[0] = 0; if (hostname_size > 0) hostname[0] = 0; if (path_size > 0) path[0] = 0; if ((p = strchr(url, ':'))) { av_strlcpy(proto, url, FFMIN(proto_size, p + 1 - url)); p++; if (*p == '/') p++; if (*p == '/') p++; } else { av_strlcpy(path, url, path_size); return; } ls = strchr(p, '/'); ls2 = strchr(p, '?'); if(!ls) ls = ls2; else if (ls && ls2) ls = FFMIN(ls, ls2); if(ls) av_strlcpy(path, ls, path_size); else ls = &p[strlen(p)]; if (ls != p) { if ((at = strchr(p, '@')) && at < ls) { av_strlcpy(authorization, p, FFMIN(authorization_size, at + 1 - p)); p = at + 1; } if (*p == '[' && (brk = strchr(p, ']')) && brk < ls) { av_strlcpy(hostname, p + 1, FFMIN(hostname_size, brk - p)); if (brk[1] == ':' && port_ptr) *port_ptr = atoi(brk + 2); } else if ((col = strchr(p, ':')) && col < ls) { av_strlcpy(hostname, p, FFMIN(col + 1 - p, hostname_size)); if (port_ptr) *port_ptr = atoi(col + 1); } else av_strlcpy(hostname, p, FFMIN(ls + 1 - p, hostname_size)); } }
1threat
How to add multi users feature to a Delphi app? : <p>Am currently developing a Delphi app for desktop (Data Base: Access) that needs the multi users feature (each user will have his Permissions, history of transactions). </p> <p><strong>How can i do that ?</strong> </p> <p>I found <a href="http://sforsuresh.in/implemention-of-user-permission-with-php-mysql-bitwise-operators/" rel="nofollow noreferrer">this article</a>, they used MySQL and am not familiar with it, explaining the same method in Access will be appreciated. </p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
what does it do *((T**)m_ptr)? : <p>I see this in the code and can't understand what is going here:</p> <pre><code>T * ptr; // we have some pointer and it has proper adress ... // Later I see this and I can't understand what is going here ptr = *((T **)ptr); </code></pre> <p>Also, later in the code I see <code>*((T**)ptr) = m_address;</code></p> <p>What for this construction is used ? <code>*((T**)ptr)</code></p> <p>Thanks!</p>
0debug
void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg) { }
1threat
static int protocol_client_auth_sasl_mechname_len(VncState *vs, uint8_t *data, size_t len) { uint32_t mechlen = read_u32(data, 0); VNC_DEBUG("Got client mechname len %d\n", mechlen); if (mechlen > 100) { VNC_DEBUG("Too long SASL mechname data %d\n", mechlen); vnc_client_error(vs); return -1; } if (mechlen < 1) { VNC_DEBUG("Too short SASL mechname %d\n", mechlen); vnc_client_error(vs); return -1; } vnc_read_when(vs, protocol_client_auth_sasl_mechname,mechlen); return 0; }
1threat
Can I use jQuery UI 1.12.1 with jQuery 3.x? : <p>I changed my jQuery <code>1.7.2</code> to <code>3.1.1</code> and changed my jQuery UI from version <code>1.8.16</code> to version <code>1.12.1</code>.</p> <p>Quite a few of my existing JS stuff broke, like styling of buttons, and <code>dialog</code> behaves in unexpected manner, i.e. half of modal dialog is covered up by the mysterious <code>&lt;div class="ui-widget-overlay ui-front"&gt;&lt;/div&gt;</code></p> <p>I suspected jQuery UI to be at fault due to the covering above. I went to jQuery UI site and I see that stable version is for <code>jQuery 1.7+</code>.</p> <p>Does that mean that I should be using jQuery 1.x with jQuery UI, or can I use jQuery 3.x okay (plus ... try to figure out why my styling and functionality broke)?</p>
0debug
static int xen_pt_pci_config_access_check(PCIDevice *d, uint32_t addr, int len) { if (addr >= 0xFF) { XEN_PT_ERR(d, "Failed to access register with offset exceeding 0xFF. " "(addr: 0x%02x, len: %d)\n", addr, len); return -1; } if ((len != 1) && (len != 2) && (len != 4)) { XEN_PT_ERR(d, "Failed to access register with invalid access length. " "(addr: 0x%02x, len: %d)\n", addr, len); return -1; } if (addr & (len - 1)) { XEN_PT_ERR(d, "Failed to access register with invalid access size " "alignment. (addr: 0x%02x, len: %d)\n", addr, len); return -1; } return 0; }
1threat
NestJS enable cors in production : <p>I've enabled CORS in my NestJS app following <a href="https://docs.nestjs.com/techniques/cors" rel="noreferrer">the official tutorial</a>, so my <code>main.ts</code> looks like the following:</p> <pre><code>import { FastifyAdapter, NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule, new FastifyAdapter(), { cors: true }); await app.listen(3000); } bootstrap(); </code></pre> <p>and it works when I run the application using <code>npm run start:dev</code>.</p> <p>However when I try to first compile the application using <code>npm run webpack</code> and then running it using <code>node server.js</code>, the cors will not work.</p> <p>The http request from the client will fail with:</p> <blockquote> <p>Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:8000" rel="noreferrer">http://localhost:8000</a>' is therefore not allowed access. The response had HTTP status code 404.</p> </blockquote>
0debug
Print Kafka Stream Input out to console? : <p>I've been looking through a lot of the Kafka documentation for a java application that I am working on. I've tried getting into the lambda syntax introduced in Java 8, but I am a little sketchy on that ground and don't feel too confident that it should be what I use as of yet.</p> <p>I've a Kafka/Zookeeper Service running without any troubles, and what I want to do is write a small example program that based on the input will write it out, but not do a wordcount as there are so many examples of already.</p> <p>As for sample data I will be getting a string of following structure:</p> <h1>Example data</h1> <pre><code>This a sample string containing some keywords such as GPS, GEO and maybe a little bit of ACC. </code></pre> <h1>Question</h1> <p>I want to be able to extract the 3 letter keywords and print them with a <code>System.out.println</code>. How do I get a string variable containing the input? I know how to apply regular expressions or even just searching through the string to get the keywords.</p> <h1>Code</h1> <pre><code>public static void main(String[] args) { Properties props = new Properties(); props.put(StreamsConfig.APPLICATION_ID_CONFIG, "app_id"); props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "0:0:0:0:0:0:0:1:9092"); props.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, "0:0:0:0:0:0:0:1:2181"); props.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); props.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); final Serde&lt;String&gt; stringSerde = Serdes.String(); KStreamBuilder builder = new KStreamBuilder(); KStream&lt;String, String&gt; source = builder.stream(stringSerde, stringSerde, "in-stream"); KafkaStreams streams = new KafkaStreams(builder, props); streams.start(); //How do I assign the input from in-stream to the following variable? String variable = ? } </code></pre> <p>I have zookeeper, kafka, producer and consumer running all hooked up to the same topic so I want to basically see the same <code>String</code> appear on all of the instances (producer, consumer and stream).</p>
0debug
static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, QEMUIOVector *qiov, CoroutineEntry co_entry, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { BlkAioEmAIOCB *acb; Coroutine *co; bdrv_inc_in_flight(blk_bs(blk)); acb = blk_aio_get(&blk_aio_em_aiocb_info, blk, cb, opaque); acb->rwco = (BlkRwCo) { .blk = blk, .offset = offset, .qiov = qiov, .flags = flags, .ret = NOT_DONE, }; acb->bytes = bytes; acb->has_returned = false; co = qemu_coroutine_create(co_entry, acb); qemu_coroutine_enter(co); acb->has_returned = true; if (acb->rwco.ret != NOT_DONE) { aio_bh_schedule_oneshot(blk_get_aio_context(blk), blk_aio_complete_bh, acb); } return &acb->common; }
1threat
def find_exponentio(test_tup1, test_tup2): res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
0debug
how to save a string to the computer memory? : <p>I want to save a string to "copy" memory in computer (ctrl + c), after clicking a button. how can I save that string to the computer memory (ctrl c) in c#?</p>
0debug
static void notify_guest_bh(void *opaque) { VirtIOBlockDataPlane *s = opaque; unsigned nvqs = s->conf->num_queues; unsigned long bitmap[BITS_TO_LONGS(nvqs)]; unsigned j; memcpy(bitmap, s->batch_notify_vqs, sizeof(bitmap)); memset(s->batch_notify_vqs, 0, sizeof(bitmap)); for (j = 0; j < nvqs; j += BITS_PER_LONG) { unsigned long bits = bitmap[j]; while (bits != 0) { unsigned i = j + ctzl(bits); VirtQueue *vq = virtio_get_queue(s->vdev, i); if (virtio_should_notify(s->vdev, vq)) { event_notifier_set(virtio_queue_get_guest_notifier(vq)); } bits &= bits - 1; } } }
1threat
static int vhost_set_vring(struct vhost_dev *dev, unsigned long int request, struct vhost_vring_state *ring) { VhostUserMsg msg = { .request = request, .flags = VHOST_USER_VERSION, .state = *ring, .size = sizeof(*ring), }; vhost_user_write(dev, &msg, NULL, 0); return 0; }
1threat
Using if else statement with json values in jsoncpp : <p>I am trying to do something similar using <code>jsoncpp</code> inside a function which returns json values as strings.</p> <pre><code>std::string some_function(std::string val){ . . . if(val=="date") { Json::Value my=root["data"]["date"]; std::cout&lt;&lt;"Date"; } else if(val=="id") { Json::Value my=root["data"]["id"]; std::cout&lt;&lt;"ID"; } else if(val=="art") { Json::Value my=root["data"]["article"]; std::cout&lt;&lt;"Article"; } else { return "Error"; } //Json::Value my=root["data"]["date"]; //this works return my.toStyledString(); } </code></pre> <p>I am able to successfully run json values example: <code>Json::Value my=root["data"]["date"];</code> outside the if else statement(comment out code) but when i tried to run these json values inside an if-else-if statment it shows this error</p> <blockquote> <p>warning: control reaches end of non-void function [-Wreturn-type]</p> </blockquote>
0debug
How do you filter xunit tests by trait with "dotnet test"? : <p>I have a .NET Core test project that uses Xunit 2.2. Some of my tests are marked with traits.</p> <pre><code>[Fact] [Trait("Color", "Blue")] public void TestBlue() { } </code></pre> <p>What is the right command line syntax for "dotnet test" to only run tests where the trait Color == Blue ?</p> <p>I'm using .NET Core CLI 1.0.0-rc4 which uses csproj, not project.json.</p> <p>I'm trying to use <code>dotnet test --filter $something</code>, but whatever I use for $something, I see this error:</p> <blockquote> <p>Error: [xUnit.net 00:00:00.7800155] E2ETests: Exception filtering tests: No tests matched the filter because it contains one or more properties that are not valid ($something). Specify filter expression containing valid properties (DisplayName, FullyQualifiedName) and try again.</p> </blockquote>
0debug
static void tlb_info(Monitor *mon) { CPUState *env; int l1, l2; uint32_t pgd, pde, pte; env = mon_get_cpu(); if (!(env->cr[0] & CR0_PG_MASK)) { monitor_printf(mon, "PG disabled\n"); return; } pgd = env->cr[3] & ~0xfff; for(l1 = 0; l1 < 1024; l1++) { cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4); pde = le32_to_cpu(pde); if (pde & PG_PRESENT_MASK) { if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { print_pte(mon, (l1 << 22), pde, ~((1 << 20) - 1)); } else { for(l2 = 0; l2 < 1024; l2++) { cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, (uint8_t *)&pte, 4); pte = le32_to_cpu(pte); if (pte & PG_PRESENT_MASK) { print_pte(mon, (l1 << 22) + (l2 << 12), pte & ~PG_PSE_MASK, ~0xfff); } } } } } }
1threat
void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, bool smm_enabled, qemu_irq sci_irq) { memory_region_init(&pm->io, OBJECT(lpc_pci), "ich9-pm", ICH9_PMIO_SIZE); memory_region_set_enabled(&pm->io, false); memory_region_add_subregion(pci_address_space_io(lpc_pci), 0, &pm->io); acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io); acpi_pm1_evt_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io); acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io, pm->disable_s3, pm->disable_s4, pm->s4_val); acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN); memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm, "acpi-gpe0", ICH9_PMIO_GPE0_LEN); memory_region_add_subregion(&pm->io, ICH9_PMIO_GPE0_STS, &pm->io_gpe); memory_region_init_io(&pm->io_smi, OBJECT(lpc_pci), &ich9_smi_ops, pm, "acpi-smi", 8); memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi); pm->smm_enabled = smm_enabled; pm->irq = sci_irq; qemu_register_reset(pm_reset, pm); pm->powerdown_notifier.notify = pm_powerdown_req; qemu_register_powerdown_notifier(&pm->powerdown_notifier); acpi_cpu_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci), &pm->gpe_cpu, ICH9_CPU_HOTPLUG_IO_BASE); if (pm->acpi_memory_hotplug.is_enabled) { acpi_memory_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci), &pm->acpi_memory_hotplug); } }
1threat
static int dvbsub_parse_region_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int region_id, object_id; int av_unused version; DVBSubRegion *region; DVBSubObject *object; DVBSubObjectDisplay *display; int fill; int ret; if (buf_size < 10) return AVERROR_INVALIDDATA; region_id = *buf++; region = get_region(ctx, region_id); if (!region) { region = av_mallocz(sizeof(DVBSubRegion)); if (!region) return AVERROR(ENOMEM); region->id = region_id; region->version = -1; region->next = ctx->region_list; ctx->region_list = region; version = ((*buf)>>4) & 15; fill = ((*buf++) >> 3) & 1; region->width = AV_RB16(buf); buf += 2; region->height = AV_RB16(buf); buf += 2; if (region->width * region->height != region->buf_size) { av_free(region->pbuf); region->buf_size = region->width * region->height; region->pbuf = av_malloc(region->buf_size); if (!region->pbuf) { region->buf_size = region->width = region->height = 0; return AVERROR(ENOMEM); fill = 1; region->dirty = 0; region->depth = 1 << (((*buf++) >> 2) & 7); if(region->depth<2 || region->depth>8){ av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth); region->depth= 4; region->clut = *buf++; if (region->depth == 8) { region->bgcolor = *buf++; buf += 1; } else { buf += 1; if (region->depth == 4) region->bgcolor = (((*buf++) >> 4) & 15); else region->bgcolor = (((*buf++) >> 2) & 3); ff_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height); if (fill) { memset(region->pbuf, region->bgcolor, region->buf_size); ff_dlog(avctx, "Fill region (%d)\n", region->bgcolor); delete_region_display_list(ctx, region); while (buf + 5 < buf_end) { object_id = AV_RB16(buf); buf += 2; object = get_object(ctx, object_id); if (!object) { object = av_mallocz(sizeof(DVBSubObject)); if (!object) return AVERROR(ENOMEM); object->id = object_id; object->next = ctx->object_list; ctx->object_list = object; object->type = (*buf) >> 6; display = av_mallocz(sizeof(DVBSubObjectDisplay)); if (!display) return AVERROR(ENOMEM); display->object_id = object_id; display->region_id = region_id; display->x_pos = AV_RB16(buf) & 0xfff; buf += 2; display->y_pos = AV_RB16(buf) & 0xfff; buf += 2; if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) { display->fgcolor = *buf++; display->bgcolor = *buf++; display->region_list_next = region->display_list; region->display_list = display; display->object_list_next = object->display_list; object->display_list = display; return 0;
1threat
static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int* n) { BDRVVVFATState* s = bs->opaque; *n = s->sector_count - sector_num; if (*n > nb_sectors) { *n = nb_sectors; } else if (*n < 0) { return 0; } return BDRV_BLOCK_DATA; }
1threat
static void vnc_listen_read(void *opaque) { VncDisplay *vs = opaque; struct sockaddr_in addr; socklen_t addrlen = sizeof(addr); vga_hw_update(); int csock = qemu_accept(vs->lsock, (struct sockaddr *)&addr, &addrlen); if (csock != -1) { vnc_connect(vs, csock); } }
1threat
void commit_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, BlockDriverState *top, int64_t speed, BlockdevOnError on_error, BlockCompletionFunc *cb, void *opaque, const char *backing_file_str, Error **errp) { CommitBlockJob *s; BlockReopenQueue *reopen_queue = NULL; int orig_overlay_flags; int orig_base_flags; BlockDriverState *overlay_bs; Error *local_err = NULL; assert(top != bs); if (top == base) { error_setg(errp, "Invalid files for merge: top and base are the same"); return; } overlay_bs = bdrv_find_overlay(bs, top); if (overlay_bs == NULL) { error_setg(errp, "Could not find overlay image for %s:", top->filename); return; } s = block_job_create(job_id, &commit_job_driver, bs, speed, cb, opaque, errp); if (!s) { return; } orig_base_flags = bdrv_get_flags(base); orig_overlay_flags = bdrv_get_flags(overlay_bs); if (!(orig_overlay_flags & BDRV_O_RDWR)) { reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL, orig_overlay_flags | BDRV_O_RDWR); } if (!(orig_base_flags & BDRV_O_RDWR)) { reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL, orig_base_flags | BDRV_O_RDWR); } if (reopen_queue) { bdrv_reopen_multiple(reopen_queue, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); block_job_unref(&s->common); return; } } s->base = blk_new(); blk_insert_bs(s->base, base); s->top = blk_new(); blk_insert_bs(s->top, top); s->active = bs; s->base_flags = orig_base_flags; s->orig_overlay_flags = orig_overlay_flags; s->backing_file_str = g_strdup(backing_file_str); s->on_error = on_error; s->common.co = qemu_coroutine_create(commit_run); trace_commit_start(bs, base, top, s, s->common.co, opaque); qemu_coroutine_enter(s->common.co, s); }
1threat
static int check_refcounts_l1(BlockDriverState *bs, uint16_t *refcount_table, int refcount_table_size, int64_t l1_table_offset, int l1_size, int check_copied) { BDRVQcowState *s = bs->opaque; uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2; int l2_size, i, j, nb_csectors, refcount; l2_table = NULL; l1_size2 = l1_size * sizeof(uint64_t); inc_refcounts(bs, refcount_table, refcount_table_size, l1_table_offset, l1_size2); l1_table = qemu_malloc(l1_size2); if (bdrv_pread(s->hd, l1_table_offset, l1_table, l1_size2) != l1_size2) goto fail; for(i = 0;i < l1_size; i++) be64_to_cpus(&l1_table[i]); l2_size = s->l2_size * sizeof(uint64_t); l2_table = qemu_malloc(l2_size); for(i = 0; i < l1_size; i++) { l2_offset = l1_table[i]; if (l2_offset) { if (check_copied) { refcount = get_refcount(bs, (l2_offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits); if ((refcount == 1) != ((l2_offset & QCOW_OFLAG_COPIED) != 0)) { printf("ERROR OFLAG_COPIED: l2_offset=%llx refcount=%d\n", l2_offset, refcount); } } l2_offset &= ~QCOW_OFLAG_COPIED; if (bdrv_pread(s->hd, l2_offset, l2_table, l2_size) != l2_size) goto fail; for(j = 0; j < s->l2_size; j++) { offset = be64_to_cpu(l2_table[j]); if (offset != 0) { if (offset & QCOW_OFLAG_COMPRESSED) { if (offset & QCOW_OFLAG_COPIED) { printf("ERROR: cluster %lld: copied flag must never be set for compressed clusters\n", offset >> s->cluster_bits); offset &= ~QCOW_OFLAG_COPIED; } nb_csectors = ((offset >> s->csize_shift) & s->csize_mask) + 1; offset &= s->cluster_offset_mask; inc_refcounts(bs, refcount_table, refcount_table_size, offset & ~511, nb_csectors * 512); } else { if (check_copied) { refcount = get_refcount(bs, (offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits); if ((refcount == 1) != ((offset & QCOW_OFLAG_COPIED) != 0)) { printf("ERROR OFLAG_COPIED: offset=%llx refcount=%d\n", offset, refcount); } } offset &= ~QCOW_OFLAG_COPIED; inc_refcounts(bs, refcount_table, refcount_table_size, offset, s->cluster_size); } } } inc_refcounts(bs, refcount_table, refcount_table_size, l2_offset, s->cluster_size); } } qemu_free(l1_table); qemu_free(l2_table); return 0; fail: printf("ERROR: I/O error in check_refcounts_l1\n"); qemu_free(l1_table); qemu_free(l2_table); return -EIO; }
1threat
Why the function String.Equals(Object obj) compares the string with an object and not necessarily with a string : <p>I don't understand why would you want to compare a string with anything but another string, why <code>String.Equals(Object obj)</code> and not <code>String.Equals(String str)</code></p> <p>Is there a specific reason for that?</p>
0debug
querying on firebase database android : i'm a beginner in firebase and android i want to make a firebase database i have no problem in that but my problem that i want to take a string from edittext and querying about it in the firebase database . i couldn't understand guide of firebase very well but i noticed that they use Child EventListener() to make query should i use any event ? i just want to get a value by querying a string thanks that's my database [i want to search for a specific text then when it found i send url value to user ][1] [1]: http://res.cloudinary.com/dbntfbnzp/image/upload/v1485812719/test.png
0debug
How do I install Plugins in NeoVim Correctly : <p>Does <strong>NeoVim</strong> have it's own config file just like <strong>vim's</strong> <code>.vimrc</code> ? If so where can I get that file in the home directory to make my own custom changes.</p>
0debug
Is there a CloudFormation template for DC/OS, ElasticSearch, Kafka Streams and Kafka Streams? : There are a lot of examples of the [SMACK stack][1], but in my infrastructure I would like to use ElasticSearch and Confluent Kafka Connect and Kafka Streams. There is a [great turorial on deploying a CloudFormation-based SMACK stack environment][2] and another in [creating an IoT pipeline with SMACK][3] as well. Since I am working on a [Lambda architecture][4], I am first starting with my batch data using ElasticSearch (not Cassandra) and would like to know if there are CloudFormation templates that use Kafka Connect, ElasticSearch. Eventually we want to use Kafka Streams with InfluxDB? [1]: http://bigdata-madesimple.com/smackspark-mesos-akka-kafka/ [2]: https://blog.codecentric.de/en/2016/04/smack-stack-hands/ [3]: https://dcos.io/docs/1.8/usage/tutorials/iot_pipeline/ [4]: http://lambda-architecture.net/
0debug
backgound: linear-gradient() not working on mobile : I made a simple page on code pen but background: linear-gradinet not working on mobile. It is showing color in computer but not in mobile here is my code link : - `https://codepen.io/jjarus/full/OGwJqv`
0debug
how to include a csv file in matplotlib using pandas? : my csv file is very complex.. it contains numeric as well as string attributes. [enter image description here][1] this is how my csv file looks like I want to plot a histogram of processes versus the cpuid [1]: http://i.stack.imgur.com/EZOD8.png
0debug
How to transform a data frame to a row in R? : I have a very basic question about reshaping a table: pval Quality High 0.782 0.62 Low 0.782 1.58 I would like to change it to pval High Low 0.782 0.62 1.58 I am relatively new to R. Could someone help? Thanks!
0debug
Protocol Buffers 3: Enums as keys in a map : <p>Enums are not allowed to be used as keys in map. PaxType here is an enum and not allowed to be used as key.</p> <pre><code>enum PaxType { ADULT = 0 ; CHILD = 1 ; INFANT = 2 ; } message FlightData { map&lt;PaxType, FareType&gt; fareType = 1; } </code></pre>
0debug
Pass ajax data to another function : <p>I want to apply the <code>getStatus</code> function right here:</p> <pre><code>function getStatus(id) { $.ajax({ method: "POST", url: '&lt;?php echo base_url('marketplace/get_store_status'); ?&gt;/'+id, dataType: 'json', success: function(data){ return data.status; } }); } </code></pre> <p>Into this function right here:</p> <pre><code>$('#store-status').click(function() { var id = getStatus(&lt;?php echo $vendor-&gt;store_id; ?&gt;); if (id == 1) { $('#btn-status') .removeClass('btn-danger') .addClass('btn-primary') .text('Activate'); } else { $('#btn-status') .removeClass('btn-primary') .addClass('btn-danger') .text('Deactivate'); } console.log(id); $('#modal-status').modal('show'); }); </code></pre> <p>But when i log the <code>id</code> variable in the element click function into the console, it shows <code>undefined</code>. </p> <p>But when i log the success data from the getStatus function itself, it shows the correct data. What am I doing wrong in my code?</p>
0debug
static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, int is_write, sigset_t *old_set) { CPUState *cpu = current_cpu; CPUClass *cc; int ret; unsigned long address = (unsigned long)info->si_addr; if (helper_retaddr) { pc = helper_retaddr; } else { pc += GETPC_ADJ; } if (!cpu || !cpu->running) { printf("qemu:%s received signal outside vCPU context @ pc=0x%" PRIxPTR "\n", __func__, pc); abort(); } #if defined(DEBUG_SIGNAL) printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", pc, address, is_write, *(unsigned long *)old_set); #endif if (is_write && h2g_valid(address)) { switch (page_unprotect(h2g(address), pc)) { case 0: break; case 1: return 1; case 2: helper_retaddr = 0; cpu_exit_tb_from_sighandler(cpu, old_set); default: g_assert_not_reached(); } } address = h2g_nocheck(address); cc = CPU_GET_CLASS(cpu); g_assert(cc->handle_mmu_fault); ret = cc->handle_mmu_fault(cpu, address, is_write, MMU_USER_IDX); if (ret == 0) { return 1; } helper_retaddr = 0; if (ret < 0) { return 0; } cpu_restore_state(cpu, pc); sigprocmask(SIG_SETMASK, old_set, NULL); cpu_loop_exit(cpu); return 1; }
1threat
How to change password of AWS Cognito User? : <p>I'm developing a web application which uses the AWS services backend side. I'm using AWS Cognito to manage the users but I have a problem. When I create a new user (with a temporary password) it is required that I change this password manually to make it definitive. The only way I have to change the password is using AWS Cli, as explained here:</p> <p><a href="https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/change-password.html" rel="noreferrer">https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/change-password.html</a></p> <p>I have to type in the shell the old password, the new password and the Access Token. The problem is: where I find this "Access token"? I don't know what to type in the shell! The AWS Cognito console doen't help.</p>
0debug
about jquery - image gallery : $("#right").click(function(){ var nextIndex=currIndex.next(); var nextImg = nextIndex.children("img").attr("src"); $("#main").attr("src",nextImg); currIndex = nextIndex; }); $("#left").click(function(){ var prevIndex=currIndex.prev(); var prevImg = prevIndex.children("img").attr("src"); $("#main").attr("src",prevImg); currIndex = prevIndex; }); When I'm in the last image, the right or left arrow doest't work... hmm please help me
0debug
static int read_len_table(uint8_t *dst, GetBitContext *gb){ int i, val, repeat; for(i=0; i<256;){ repeat= get_bits(gb, 3); val = get_bits(gb, 5); if(repeat==0) repeat= get_bits(gb, 8); if(i+repeat > 256) { av_log(NULL, AV_LOG_ERROR, "Error reading huffman table\n"); return -1; } while (repeat--) dst[i++] = val; } return 0; }
1threat
Adding number if next value the same r : <p>I'm facing the following problem in R. I have a dataframe with values identifing a customer. There is a column with User ID. I need to add another column with a counter what is the occurence number of that particular customer in the data. The dataframe is sorted by User ID. So i have something like that:</p> <pre><code>&gt; niekonwersyjne[c(57:62,72:77),1] User_ID AMsySZa--1Og4WwseZJKRyABTWdh AMsySZa--1Og4WwseZJKRyABTWdh AMsySZa--1Og4WwseZJKRyABTWdh AMsySZa--1Og4WwseZJKRyABTWdh AMsySZa--1Og4WwseZJKRyABTWdh AMsySZa--1qZghdxj4gypoSQRt_F AMsySZa--2gL6xRCZFUCOXtpYxNs AMsySZa--2gL6xRCZFUCOXtpYxNs AMsySZa--2gL6xRCZFUCOXtpYxNs AMsySZa--2gL6xRCZFUCOXtpYxNs AMsySZa--2gL6xRCZFUCOXtpYxNs AMsySZa--2gL6xRCZFUCOXtpYxNs </code></pre> <p>But need something like this:</p> <pre><code>&gt; niekonwersyjne[c(57:62,72:77),c(1,11)] User_ID Counter AMsySZa--1Og4WwseZJKRyABTWdh 1 AMsySZa--1Og4WwseZJKRyABTWdh 2 AMsySZa--1Og4WwseZJKRyABTWdh 3 AMsySZa--1Og4WwseZJKRyABTWdh 4 AMsySZa--1Og4WwseZJKRyABTWdh 5 AMsySZa--1qZghdxj4gypoSQRt_F 1 AMsySZa--2gL6xRCZFUCOXtpYxNs 1 AMsySZa--2gL6xRCZFUCOXtpYxNs 2 AMsySZa--2gL6xRCZFUCOXtpYxNs 3 AMsySZa--2gL6xRCZFUCOXtpYxNs 4 AMsySZa--2gL6xRCZFUCOXtpYxNs 5 AMsySZa--2gL6xRCZFUCOXtpYxNs 6 </code></pre> <p>I can do this with a loop but the data frame has over 20 mil observations so the calculation time is defintely too high. Is there some other way to achieve this result?</p> <p>The loop that I am using right now looks like this:</p> <pre><code>niekonwersyjne$Counter&lt;-1 for (i in 2:nrow(niekonwersyjne)) { if (niekonwersyjne[i-1,"User_ID"]==niekonwersyjne[i,"User_ID"]) { niekonwersyjne[i,"Counter"]&lt;-niekonwersyjne[i-1,"Counter"]+1} else { niekonwersyjne[i,"Counter"]&lt;-1 } } </code></pre>
0debug
Validation errors in html site (Error) : I am in the last stages of development on my site. When I try to validate my page using w3cvalidator the following errors are displayed. However when I try to action the following below; closing the </nav tag this only creates more errors. Is there a quick fix for this? Ideally, I would like my page to validate 100%. W3c Validator Errors below. Error End tag nav seen, but there were open elements. From line 41, column 9; to line 41, column 14 >↩ </nav>↩ Error Unclosed element ul. From line 33, column 11; to line 33, column 43 <ul class="topnav" id="myTopnav">↩ **Here is my HTML** <!DOCTYPE html> <html lang="en"> <head> <title>DB Plumbing | Home</title> <link rel="stylesheet" type="text/css" href="style.css"> <script src="https://use.fontawesome.com/3a2264e344.js"></script> <script src="html9shiv.js"></script> <link rel="shortcut icon" type="image/png" href="wrench.png"/> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> <meta name="desciption" content = "Darran Brady Plumbing"> <meta name="keywords" content = "Plumbing, Boilers, Showers, Central Heating, Kitchens, Bathrooms, Installations, Landlord Services, Horsham, West Sussex, Sussex,Barns Green, Billingshurst,Broadbridge Heath,Christ's Hospital, Clemsfold, Copsale,Colgate,Cowfold, Faygate, Handcross, Horsham, Itchingfield, Kingsfold,Lambs Farm,Lower Beeding,Mannings Heath, Maplehurst, Monks Gate, Nuthurst, Partridge Green, Pease Pottage, Roffey, Rowhook, Rusper, Rudgwick, Southwater, Slinfold, Warnham "> <meta name = "author" content ="DB, Darran, Brady, Darran Brady"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> function myFunction() { var x = document.getElementById("myTopnav"); if (x.className === "topnav") { x.className += " responsive"; } else { x.className = "topnav"; } } </script> </head> <body> <header> <div class="container"> <div id="branding"> <h1><span class="highlight">DB</span> Plumbing</h1> </div> <nav> <ul class="topnav" id="myTopnav"> <li class="active"><a href="home9.html">Home</a></li> <li><a href="about9.html">About</a></li> <li><a href="services9.html">Services</a></li> <li><a href="coverage9.html">Coverage</a></li> <li><a href="contact9.html">Contact</a></li> <li class="icon"> <a href="javascript:void(0);" style="font-size:200%;" onclick="myFunction()">☰</a> </nav> </div> </header> <section id="showcase"> <div class="container"> <h1>Local Award Winning Trader</h1> <h2>Call Darren | <i class="fa fa-phone" aria-hidden="true"></i><a href="tel:+07756848657"> 07756848657</a></h2> <p>DB Plumbing provides a full range of general plumbing and repair services, from installing your new bathroom suite to fixing that leaking tap or joint that has been annoying you for ages. </p> <p>Our customer's individual requirements are important to us at DB Plumbing. We always provide quality service and products and combined with honesty has made us the first choice of many homes in the Horsham area</p> </div> </section> <section id="newsletter"> <div class="container"> <h1>Subscribe To Our Weekly Blog</h1> <form> <input type="email" placeholder="Subscribe today..."> <button type="submit" class="subscribe">Subscribe</button> </form> </div> </section> <section id="imagery"> <div class="container"> <div class="box"> <i class="fa fa-star" aria-hidden="true"></i> <h1>Accredited</h1> <p>Gas Safe Accreditted </p> </div> <div class="box"> <i class="fa fa-thumbs-up" aria-hidden="true"></i> <h1>Reputable</h1> <p>"25 years service experience "</p> </div> <div class="box"> <i class="fa fa-map-marker" aria-hidden="true"></i> <h1>Local</h1> <p>Sussex and Surrey Countywide</p> </div> </div> </section> <footer> <div> <p>Darren Brady Plumbing Copyright &copy; 2017</p> </div> </footer> </body> </html>
0debug
static void xlnx_ep108_init(MachineState *machine) { XlnxEP108 *s = g_new0(XlnxEP108, 1); int i; uint64_t ram_size = machine->ram_size; if (ram_size > XLNX_ZYNQMP_MAX_RAM_SIZE) { error_report("ERROR: RAM size 0x%" PRIx64 " above max supported of " "0x%llx", ram_size, XLNX_ZYNQMP_MAX_RAM_SIZE); exit(1); } if (ram_size < 0x08000000) { qemu_log("WARNING: RAM size 0x%" PRIx64 " is small for EP108", ram_size); } memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram", ram_size); object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP); object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), &error_abort); object_property_set_link(OBJECT(&s->soc), OBJECT(&s->ddr_ram), "ddr-ram", &error_abort); object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal); for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) { BusState *bus; DriveInfo *di = drive_get_next(IF_SD); BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL; DeviceState *carddev; char *bus_name; bus_name = g_strdup_printf("sd-bus%d", i); bus = qdev_get_child_bus(DEVICE(&s->soc), bus_name); g_free(bus_name); if (!bus) { error_report("No SD bus found for SD card %d", i); exit(1); } carddev = qdev_create(bus, TYPE_SD_CARD); qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, "realized", &error_fatal); } for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) { SSIBus *spi_bus; DeviceState *flash_dev; qemu_irq cs_line; DriveInfo *dinfo = drive_get_next(IF_MTD); gchar *bus_name = g_strdup_printf("spi%d", i); spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name); g_free(bus_name); flash_dev = ssi_create_slave_no_init(spi_bus, "sst25wf080"); if (dinfo) { qdev_prop_set_drive(flash_dev, "drive", blk_by_legacy_dinfo(dinfo), &error_fatal); } qdev_init_nofail(flash_dev); cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0); sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), 1, cs_line); } xlnx_ep108_binfo.ram_size = ram_size; xlnx_ep108_binfo.kernel_filename = machine->kernel_filename; xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline; xlnx_ep108_binfo.initrd_filename = machine->initrd_filename; xlnx_ep108_binfo.loader_start = 0; arm_load_kernel(s->soc.boot_cpu_ptr, &xlnx_ep108_binfo); }
1threat
An Error occurs when I was making a code to create a show list by ListView{in content_main.xml} like contact view. plz help me. : **I was making a code to create a show list by ListView{in content_main.xml} like contact view. I build a database in the (SQLite Expert Professional) with a table(name: "contact") that was contained a few name and family and numbers, with ID,NAME,fAMILY and PHONE NUMBER columns. ID was unique, auto increment and primary key...other were Text except number that was CHAR. then I calling them to my ListView as you see in below.(before it I made a row_list activity to made my listview , custom) but there was an Error and i can't find it. {I could find my database.db file with that's table in the source data files that means my mistake wasn't from creating database.} plz help me.I wanna learn android (as fast as i can) to get a JOB and I need it..** *Errors.Android Monitor.Logcat* 09-08 05:27:32.005 5692-5692/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x94c4fb20) 09-08 05:27:32.005 5692-5692/? E/AndroidRuntime: FATAL EXCEPTION: main Process: mizco.phonebook, PID: 5692 java.lang.RuntimeException: Unable to start activity ComponentInfo{mizco.phonebook/mizco.phonebook.Main}: android.database .CursorIndexOutOfBoundsException: Index 5 requested, with a size of 5 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2193) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2243) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5019) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: android.database.CursorIndexOutOfBoundsException: Index 5 requested, with a size of 5 at android.database.AbstractCursor.checkPosition(AbstractCursor.java:426) at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) at mizco.phonebook.database.getfulllist(database.java:97) at mizco.phonebook.Main.onCreate(Main.java:36) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2157) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2243) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5019) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) **Main.java** package mizco.phonebook; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; public class Main extends AppCompatActivity { private database db; private String [][] res ; private ListView list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); list = (ListView) findViewById(R.id.main_list); db = new database(this); db.startusing(); db.open(); res = db.getfulllist(); db.close(); list.setAdapter(new AA()); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); } class AA extends ArrayAdapter<String>{ public AA() { super(Main.this, R.layout.row_list, res[0]); } @NonNull @Override public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater in = getLayoutInflater(); View row = in.inflate(R.layout.row_list,parent,false); TextView name = (TextView) row.findViewById(R.id.row_name); TextView number = (TextView) row.findViewById(R.id.row_number); name.setText(res[0][position]+" "+res[1][position]); number.setText(res[2][position]); return row; } } } **Class : database.java** package mizco.phonebook; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; /** * Created by Mahdi on 9/2/2017. */ public class database extends SQLiteOpenHelper { public static String dbname= "database"; public static String dbpath=""; private Context mctxt; private SQLiteDatabase mydb; public database(Context context) { super(context, dbname, null, 1); mctxt = context; } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int i, int i1) { } private boolean existdatabase(){ File m312 = new File(dbpath+dbname); return m312.exists(); } private void copydatabase(){ try { InputStream IS = mctxt.getAssets().open(dbname); OutputStream OS = new FileOutputStream(dbpath+dbname); byte[] buffer = new byte[1024]; int length; while ((length = IS.read(buffer))>0){ OS.write(buffer,0,length); } OS.flush(); OS.close(); IS.close(); } catch (Exception e) { } } public void open(){ mydb = SQLiteDatabase.openDatabase(dbpath+dbname, null, SQLiteDatabase.OPEN_READWRITE); } public void close(){ mydb.close(); } public void startusing () { dbpath = mctxt.getFilesDir().getParent() + "/databases/"; if (!existdatabase()) { this.getWritableDatabase(); copydatabase(); } } public String[][] getfulllist(){ Cursor cu = mydb.rawQuery("select * from Contact",null); String [][] r = new String[3][cu.getCount()]; for (int i= 0;i<=cu.getCount();i++){ cu.moveToPosition(i); r[0][i]=cu.getString(1); r[1][i]=cu.getString(2); r[2][i]=cu.getString(3); } return r; } }
0debug
import re def change_date_format(dt): return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) return change_date_format(dt)
0debug
Last Login date for all users in linux : <p>How to find last login date for all users in Linux? I tried the last command but it retrieves only the recent last logins from wtmp. </p>
0debug
void eth_setup_vlan_headers(struct eth_header *ehdr, uint16_t vlan_tag, bool *is_new) { struct vlan_header *vhdr = PKT_GET_VLAN_HDR(ehdr); switch (be16_to_cpu(ehdr->h_proto)) { case ETH_P_VLAN: case ETH_P_DVLAN: *is_new = false; break; default: vhdr->h_proto = ehdr->h_proto; ehdr->h_proto = cpu_to_be16(ETH_P_VLAN); *is_new = true; break; } vhdr->h_tci = cpu_to_be16(vlan_tag); }
1threat