problem
stringlengths
26
131k
labels
class label
2 classes
Why this code is not giving the output as expected : <p>I was expecting the output as AB , ABCD but the output is ABCD , B. How's that possible?</p> <pre><code> public class Test { public static void main(String[] args) { StringBuffer a = new StringBuffer("A"); StringBuffer b = new StringBuffer("B"); operate(a, b); System.out.println(a + " " + " , " + " " + b); } static void operate(StringBuffer x, StringBuffer y) { x.append(y); y = x.append("C"); y.append("D"); } } </code></pre>
0debug
How to replace specific letters in multiple times in strings in python, : <p>#some times it will change" JR" as " II" that time this replace function not work</p>
0debug
How do you pronounce NGRX? : <p>My dev team is creating an application with Angular NGRX.</p> <p>When talking about it I'm not sure how to say it.</p> <p>Do I say each letter? N-G-R-X</p> <p>Or is it like "engrex"?</p> <p>Or maybe "Angular Redux"?</p> <blockquote> <p>How do you pronounce NGRX?</p> </blockquote>
0debug
dynamic sized multi line TextBox field in a PDF : <p>I have created a document in open office with a multi line form field:</p> <p><a href="https://i.stack.imgur.com/i1ZG2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/i1ZG2.png" alt="enter image description here"></a></p> <p>The issue I am having is when the dynamic content exceeds the initial size of the multi line text box:</p> <p><a href="https://i.stack.imgur.com/h3JF8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/h3JF8.png" alt="enter image description here"></a></p> <p>Sure I can re-size the Text Box in the original template but the dynamic content may be from 1 to 50 lines and I want the text after the Text Box to be close to the last line of dynamic content.</p> <p>Can someone suggest a way to solve this? </p>
0debug
Basic understanding of return function : <p>I'm having trouble of understanding the very basic concept of returning a value in functions (JS etc).</p> <p>Why should I use</p> <pre><code>function add(x,y){ result=x+y; return result; } add(5,3); </code></pre> <p>instead of</p> <pre><code>var result=0; function add(x,y){ result=x+y; } add(5,3); </code></pre> <p>I guess it's about saving memory, isn't it?</p>
0debug
static void RENAME(yuv2bgr24_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { const uint16_t *buf1= buf0; if (uvalpha < 2048) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } }
1threat
How print first and last row in an array using C : I have m x m array and i am trying to find out first and last row of a given matrix (using C) which is e.g mat[3][3]={1,2,3, 4,5,6, 7,8,9}; But i could not figure out how to get first and last row using c. If some have the algorithm then please share with me.
0debug
static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp) { const QDictEntry *ent; int has_exec_key = 0; QDict *input_dict; if (qobject_type(input_obj) != QTYPE_QDICT) { error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "object"); return NULL; } input_dict = qobject_to_qdict(input_obj); for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){ const char *arg_name = qdict_entry_key(ent); const QObject *arg_obj = qdict_entry_value(ent); if (!strcmp(arg_name, "execute")) { if (qobject_type(arg_obj) != QTYPE_QSTRING) { error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute", "string"); return NULL; } has_exec_key = 1; } else if (!strcmp(arg_name, "arguments")) { if (qobject_type(arg_obj) != QTYPE_QDICT) { error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "arguments", "object"); return NULL; } } else { error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name); return NULL; } } if (!has_exec_key) { error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute"); return NULL; } return input_dict; }
1threat
PCA on word2vec embeddings : <p>I am trying to reproduce the results of this paper: <a href="https://arxiv.org/pdf/1607.06520.pdf" rel="noreferrer">https://arxiv.org/pdf/1607.06520.pdf</a></p> <p>Specifically this part:</p> <blockquote> <p>To identify the gender subspace, we took the ten gender pair difference vectors and computed its principal components (PCs). As Figure 6 shows, there is a single direction that explains the majority of variance in these vectors. The first eigenvalue is significantly larger than the rest.</p> </blockquote> <p><a href="https://i.stack.imgur.com/EOJJK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EOJJK.png" alt="enter image description here"></a></p> <p>I am using the same set of word vectors as the authors (Google News Corpus, 300 dimensions), which I load into word2vec. </p> <p>The 'ten gender pair difference vectors' the authors refer to are computed from the following word pairs:</p> <p><a href="https://i.stack.imgur.com/7b6Dj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7b6Dj.png" alt="enter image description here"></a></p> <p>I've computed the differences between each normalized vector in the following way:</p> <pre><code>model = gensim.models.KeyedVectors.load_word2vec_format('GoogleNews-vectors- negative300.bin', binary = True) model.init_sims() pairs = [('she', 'he'), ('her', 'his'), ('woman', 'man'), ('Mary', 'John'), ('herself', 'himself'), ('daughter', 'son'), ('mother', 'father'), ('gal', 'guy'), ('girl', 'boy'), ('female', 'male')] difference_matrix = np.array([model.word_vec(a[0], use_norm=True) - model.word_vec(a[1], use_norm=True) for a in pairs]) </code></pre> <p>I then perform PCA on the resulting matrix, with 10 components, as per the paper:</p> <pre><code>from sklearn.decomposition import PCA pca = PCA(n_components=10) pca.fit(difference_matrix) </code></pre> <p>However I get very different results when I look at <code>pca.explained_variance_ratio_</code> :</p> <pre><code>array([ 2.83391436e-01, 2.48616155e-01, 1.90642492e-01, 9.98411858e-02, 5.61260498e-02, 5.29706681e-02, 2.75670634e-02, 2.21957722e-02, 1.86491774e-02, 1.99108478e-32]) </code></pre> <p>or with a chart:</p> <p><a href="https://i.stack.imgur.com/RuNEi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RuNEi.png" alt="enter image description here"></a></p> <p>The first component accounts for less than 30% of the variance when it should be above 60%! </p> <p>The results I get are similar to what I get when I try to do the PCA on randomly selected vectors, so I must be doing something wrong, but I can't figure out what.</p> <p>Note: I've tried without normalizing the vectors, but I get the same results.</p>
0debug
How to get the realtime output for a shell command in golang? : <p>I am trying to call shell command with os/exec in golang, that command will take some time, so I would like to retrieve the reatime output and print the processed output (a progressing ratio number).</p> <pre><code>package main import ( "bufio" "fmt" "io" "os" "os/exec" "strings" ) func main() { cmdName := "ffmpeg -i t.webm -acodec aac -vcodec libx264 cmd1.mp4" cmdArgs := strings.Fields(cmdName) cmd := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...) stdout, _ := cmd.StdoutPipe() cmd.Start() go print(stdout) cmd.Wait() } // to print the processed information when stdout gets a new line func print(stdout io.ReadCloser) { r := bufio.NewReader(stdout) line, _, err := r.ReadLine() fmt.Println("line: %s err %s", line, err) } </code></pre> <p>I want to have a function where can update the screen when the command print something, </p> <p>The ffmpeg command output is as follows:</p> <pre><code>frame= 101 fps=0.0 q=28.0 size= 91kB time=00:00:04.13 bitrate= 181.2kbits/ frame= 169 fps=168 q=28.0 size= 227kB time=00:00:06.82 bitrate= 272.6kbits/ frame= 231 fps=153 q=28.0 size= 348kB time=00:00:09.31 bitrate= 306.3kbits/ frame= 282 fps=140 q=28.0 size= 499kB time=00:00:11.33 bitrate= 360.8kbits/ </code></pre> <p>in fact, the above 4 line is the last line of ffmpeg command output which keeps changing, I want to print that change out, like </p> <pre><code>18% 44% 69% 100% </code></pre> <p>how could I achieve this?</p>
0debug
How to do data exploration before choosing any Machine Learning algorithms : <p>Any tools could help recognize the data distribution pattern, and then make the decision to choose ML algorithms?</p>
0debug
Some git commits are missing after creating git branch from another git branch : I am creating a git branch from another git branch, but somehow a few git commits are missing in the newly created git branch. Suppose I have **Branch1** having below commit ids, 09dc55 348e4df 9d4a7eb 3cfa1b1 3bd369f 1862ec0 0eedb34 e65ea57 7259a82 5f6c345 1c4d415 91f71ac a6136b9 And I have created **Branch2** from **Branch1**, but somehow I missed few commits from Branch1. These are the commit ids from **Branch2** 09dc55 348e4df 9d4a7eb 5f6c345 1c4d415 91f71ac a6136b9 Below listed commit ids are missing in Branch2 3cfa1b1 3bd369f 1862ec0 0eedb34 e65ea57 7259a82
0debug
Flutter: Filter list as per some condition : <p>I'm having list of Movies. That contains all Animated &amp; non Animated Movies. To identify whether its Animated or not there is one flag called as <strong>isAnimated</strong>.</p> <p>I want to show only Animated movies. I written code to filter out only Animated movies but getting some error.</p> <pre><code>import 'package:flutter/material.dart'; void main() =&gt; runApp(new MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter Demo', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new HomePage(), ); } } class Movie { Movie({this.movieName, this.isAnimated, this.rating}); final String movieName; final bool isAnimated; final double rating; } List&lt;Movie&gt; AllMovies = [ new Movie(movieName: "Toy Story",isAnimated: true,rating: 4.0), new Movie(movieName: "How to Train Your Dragon",isAnimated: true,rating: 4.0), new Movie(movieName: "Hate Story",isAnimated: false,rating: 1.0), new Movie(movieName: "Minions",isAnimated: true,rating: 4.0), ]; class HomePage extends StatefulWidget{ @override _homePageState createState() =&gt; new _homePageState(); } class _homePageState extends State&lt;HomePage&gt; { List&lt;Movie&gt; _AnimatedMovies = null; @override void initState() { super.initState(); _AnimatedMovies = AllMovies.where((i) =&gt; i.isAnimated); } @override Widget build(BuildContext context) { return new Scaffold( body: new Container( child: new Text( "All Animated Movies here" ), ), ); } } </code></pre> <p><a href="https://i.stack.imgur.com/MTiQ8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MTiQ8.png" alt="WhereIterable&lt;Object&gt; is not subtype of type List&lt;Object&gt;"></a> </p>
0debug
void ff_put_h264_qpel16_mc03_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_qrt_16w_msa(src - (stride * 2), stride, dst, stride, 16, 1); }
1threat
Can I shorten the proccess of adding multiple variables in Python : basically I have a list and from.that list every variable uses one index for a value. Example: val = [2, 4, 8, 6] var1 = val[0] var2 = val[1] var3 = val[2] var4 = val[3] Can I put this in a loop somehow? Because I have cca 20 values so it is long to write 20 variables. Thank you. PS ofcourse, the values from added variables must be usable.
0debug
static int get_video_frame(VideoState *is, AVFrame *frame) { int got_picture; if ((got_picture = decoder_decode_frame(&is->viddec, frame)) < 0) return -1; if (got_picture) { double dpts = NAN; if (frame->pts != AV_NOPTS_VALUE) dpts = av_q2d(is->video_st->time_base) * frame->pts; frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame); if (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) { if (frame->pts != AV_NOPTS_VALUE) { double diff = dpts - get_master_clock(is); if (!isnan(diff) && fabs(diff) < AV_NOSYNC_THRESHOLD && diff - is->frame_last_filter_delay < 0 && is->viddec.pkt_serial == is->vidclk.serial && is->videoq.nb_packets) { is->frame_drops_early++; av_frame_unref(frame); got_picture = 0; } } } } return got_picture; }
1threat
static void gen_doz(DisasContext *ctx) { int l1 = gen_new_label(); int l2 = gen_new_label(); tcg_gen_brcond_tl(TCG_COND_GE, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], l1); tcg_gen_sub_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(l2); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); }
1threat
Get all key paths from a struct in Swift 4 : <p>Let's say I have that struct:</p> <pre><code>struct MyStruct { let x: Bool let y: Bool } </code></pre> <p>In Swift 4 we can now access it's properties with the <code>myStruct[keyPath: \MyStruct.x]</code> interface.</p> <p>What I need is a way to access all it's key paths, something like:</p> <pre><code>extension MyStruct { static func getAllKeyPaths() -&gt; [WritableKeyPath&lt;MyStruct, Bool&gt;] { return [ \MyStruct.x, \MyStruct.y ] } } </code></pre> <p>But, obviously, without me having to manually declare every property in an array.</p> <p>How can I achieve that?</p>
0debug
Spelling Bee word randomizer : <p>I am a primary school teacher and want to create a program to randomly choose a word from a bank of spelling words that I will enter. I want to create this to insure that there can be no bias on the part of the judge choosing an easier or harder word due to personal feelings. I have no programming experience and I have tried to fins this information on google. I appreciate any help that you can offer.</p>
0debug
Set function data into variable using Javascript : <p>I'd like to set the width of an external image (from another url) into a variable, so I can use the newly assigned variable on another function.</p> <p>The problem is that I get <code>undefined</code> message on the variable, see the code below.</p> <pre><code>var site_url = 'http://fabricjs.com/assets/1.svg'; function getMeta(url, callback) { var img = new Image(); img.src = url; img.onload = function() { callback(this.width, this.height); } } var a = getMeta(site_url, function(width, height) { return width; }); alert(a); //undefined </code></pre> <p>What am I doing wrong, how should I proceed ?</p>
0debug
Find intersection of two columns in Python Pandas -> list of strings : <p>I would like to count how many instances of column A and B intersect. The rows in Column A and B are lists of strings. For example, column A may contain [car, passenger, truck] and column B may contain [car, house, flower, truck]. Since in this case, 2 strings overlap, column C should display -> 2</p> <p>I have tried (none of these work):</p> <pre><code>df['unique'] = np.unique(frame[['colA', 'colB']]) </code></pre> <p>or</p> <pre><code>def unique(colA, colB): unique1 = list(set(colA) &amp; set(colB)) return unique1 df['unique'] = df.apply(unique, args=(df['colA'], frame['colB'])) </code></pre> <p>TypeError: ('unique() takes 2 positional arguments but 3 were given', 'occurred at index article')</p>
0debug
Meteor is stuck at downloading meteor-tool@1.3.2_4 : <p>I have been using meteor framework for the past few days. Now, when i create a new project it downloads meteor-tool@1.3.2_4. But it does not complete download. It seems to be stuck at downloading and shows only following line:</p> <pre><code>Downloading meteor-tool@1.3.2_4... </code></pre> <p>How can i troubleshoot this issue.</p>
0debug
how to check which dns client is used on an external server? : <p>The issue is that i cannot determine what domain name system external servers use.</p> <p>I want to be able to spot which kind of domain name system client is a server using without having actually access to it.</p> <p>I have tried several commands on n map with domain name system searching script, but the result is not clear. </p> <p>For ports open i can use n map.</p> <p>Is there a solution for domain name system spotting too ?</p>
0debug
Hi.Refresh icon.Can some one help me to locate an element (xpath or CSS) which is displayed <svg class="ult-icon .....height: 20px;">.HTML below: : <div class="ult-dashboard-item grid-item" style="transform: translate(5px, 5px); width: 290px; height: 290px; left: 0px; top: 0px; position: absolute; cursor: default;"> <div class="ult-dashboard-item-header cf"> <h4 class="ult-dashboard-item-title"> Calendar </h4> <a class="ult-dashboard-item-refresh ult-cursor-pointer pull-right" placement="left"> <icon> <**svg class="ult-icon ult-dashboard-item-icon" style="width: 20px; height: 20px;"**> <use xlink:href="#ult-icon-refresh"/> </svg> </icon> </a> </div>
0debug
static int openfile(char *name, int flags, bool writethrough, bool force_share, QDict *opts) { Error *local_err = NULL; BlockDriverState *bs; if (qemuio_blk) { error_report("file open already, try 'help close'"); QDECREF(opts); return 1; } if (force_share) { if (!opts) { opts = qdict_new(); } if (qdict_haskey(opts, BDRV_OPT_FORCE_SHARE) && !qdict_get_bool(opts, BDRV_OPT_FORCE_SHARE)) { error_report("-U conflicts with image options"); QDECREF(opts); return 1; } qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true); } qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err); if (!qemuio_blk) { error_reportf_err(local_err, "can't open%s%s: ", name ? " device " : "", name ?: ""); return 1; } bs = blk_bs(qemuio_blk); if (bdrv_is_encrypted(bs) && bdrv_key_required(bs)) { char password[256]; printf("Disk image '%s' is encrypted.\n", name); if (qemu_read_password(password, sizeof(password)) < 0) { error_report("No password given"); goto error; } if (bdrv_set_key(bs, password) < 0) { error_report("invalid password"); goto error; } } blk_set_enable_write_cache(qemuio_blk, !writethrough); return 0; error: blk_unref(qemuio_blk); qemuio_blk = NULL; return 1; }
1threat
How to query records number in a joint query? : <p>for example,I have 2 tables student &amp; report, "student" log student info,"report" log every student's school report,a student has more than one reports so report table has a foreign key "sid" referenced to student table,now I want to query every student's info and his report number,so how can I do the query in one query? Currently I had to use two queries.</p>
0debug
How can find the label position in panell in winForm in during the vertical scrolling : Hello I have a question <br> I have a panel for example 1000 label controls that the height of each label is variable in win form app and I am going to when scrolling vertically the panel find the position of the first label is seen in the panel [enter image description here][1] [1]: http://i.stack.imgur.com/qstqD.jpg
0debug
Bash-script delete a specific line from a .txt file : <p>I want to learn how to delete from a txt file the line that contains a word that user typed in a variable I've tried grep -v but then clears the whole content of the file Help?!!! </p>
0debug
What are the differences between Decorator, Wrapper and Adapter patterns? : <p>I feel like I've been using these pattern families quite many times, however, for me it's hard to see the differences as their <em>definitions</em> are quite similar. Basicaly it seems like all of them is about <em>wrapping</em> another object or objects to extend or <em>wrap</em> their behavior with extra stuff. </p> <p>For a quick example implementing a caching mechanism over a repository pattern seems to be this situation. Here is a quick sample <code>C#</code> code I would probably start with.</p> <pre><code>public interface IRepository { IEnumerable&lt;T&gt; GetItems&lt;T&gt;(); } public class EntityFrameworkRepository : IRepository { ... } public class CachedRepository : IRepository { private IRepository _repository; private ICacheProvider _cache; public CachedRepository(IRepository repository, ICacheProvider cache) { this._repository = repository; this._cache = cache; } public IEnumerable&lt;T&gt; GetItems&lt;T&gt;() { ... } } </code></pre> <p>Which one of these patterns apply to this situation for example? Could anyone clarify briefly the differences in theory and in practice?</p>
0debug
middleware for one specific method in controller in Laravel : <p>I have middleware <code>Auth</code> that is in <code>App\Http\Middleware\</code></p> <p>In my kernel i added him like:</p> <pre><code>protected $routeMiddleware = [ 'auth' =&gt; \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' =&gt; \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' =&gt; \Illuminate\Routing\Middleware\SubstituteBindings::class, 'can' =&gt; \Illuminate\Auth\Middleware\Authorize::class, 'guest' =&gt; \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' =&gt; \Illuminate\Routing\Middleware\ThrottleRequests::class, 'Groups' =&gt; \App\Http\Middleware\Groups::class, 'Auth' =&gt; \App\Http\Middleware\Auth::class, ]; </code></pre> <p>This middleware contains</p> <pre><code>&lt;?php namespace App\Http\Middleware; use Closure; class Auth { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if( !auth()-&gt;check() ) { return abort(404); } return $next($request); } } </code></pre> <p>And in my controller method I use</p> <p><code>$this-&gt;middleware('Auth');</code></p> <p>But this doesn't work at all.</p> <p>And when I take my <code>'Auth' =&gt; \App\Http\Middleware\Auth::class,</code> and place it into <code>protected $middlewareGroups</code> like <code>\App\Http\Middleware\Auth::class,</code> it works. But for every single page. So when I am not logged it all time abort404.</p> <p>What is wrong here? I can't see, it looks fine to me.</p> <p>But this middleware doesn't work for this method in which I have <code>$this-&gt;middleware('Auth');</code></p> <p>I am not logged in but page appears as normal.</p> <p>And there should be abort404 fired cuz I am not logged</p> <p>What made I wrong?</p>
0debug
ASP.NET C# storing Session in DataBase : <p>i am new with ASP.NET and C#. I was trying to store details of a booking into the booking table including User ID using the session. My booking table is as follow</p> <pre><code>CREATE TABLE [dbo].[BookingTb] ( [Bid] INT IDENTITY (1, 1) NOT NULL, [Rid] VARCHAR (5) NOT NULL, [Price] MONEY NOT NULL, [nights] INT NOT NULL, [NoOfRooms] INT NOT NULL, [Uid] VARCHAR(50) NOT NULL, PRIMARY KEY CLUSTERED ([Bid] ASC)); </code></pre> <p>and the user table is as follow</p> <pre><code>CREATE TABLE [dbo].[UserTb] ( [Uid] VARCHAR (50) NOT NULL, [Uname] VARCHAR (15) NOT NULL, [Ubd] INT NOT NULL, [Ugender] VARCHAR (10) NOT NULL, [Uemail] VARCHAR (50) NOT NULL, [password] VARCHAR (50) NOT NULL, PRIMARY KEY CLUSTERED ([Uid] ASC)); </code></pre> <p>i created the session in the login form as follow</p> <pre><code>Session["Uid"] = TextBox1.Text.ToString(); </code></pre> <p>Now i want to store different details in the Booking table including the session after the user log in so i used the following code:</p> <pre><code>using System.Data; using System.Data.SqlClient; public partial class UserBooking : System.Web.UI.Page { DataClassesDataContext db = new DataClassesDataContext(); protected void Button1_Click(object sender, EventArgs e) { BookingTb b = new BookingTb(); Int32 rooms,nights, cap,price; rooms = Convert.ToInt32(TextBox1.Text); nights = Convert.ToInt32(TextBox2.Text); cap = Convert.ToInt32(DropDownList2.SelectedItem.Value); String type = DropDownList1.SelectedItem.Value; String Rid; String user =Convert.ToString(Session["Uid"]) ; if (type == "Normal" &amp;&amp; cap == 2) { Rid = "G01"; price = rooms * nights * 35; b.Rid = Rid; b.Price = price; b.nights = nights; b.Uid = user; b.NoOfRooms = rooms; db.BookingTbs.InsertOnSubmit(b); db.SubmitChanges(); Label3.Text = "Thank you for Booking with us!&lt;/br&gt; Total Payment= " + price; } </code></pre> <p>the problem is i keep getting this error:</p> <pre><code> Line 39:b.Uid = user; Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'int' </code></pre> <p>well, Uid is a varchar(50) not an int! how can i solve that? i tried many ways but non of them worked.</p>
0debug
HTML PHP get select value in same page : <p>I have a question about HTML select form.</p> <p>I have 5 select forms something like following picture. <a href="https://i.stack.imgur.com/uNHHB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uNHHB.png" alt="pic 1"></a></p> <p>You have to select from the first select form, and then the second select form will display the lists by value select from the previous select form.</p> <p>The lists are getting from MYSQL.</p> <p>How should I perform above function?</p>
0debug
static int flv_same_audio_codec(AVCodecContext *acodec, int flags) { int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8; int flv_codecid = flags & FLV_AUDIO_CODECID_MASK; int codec_id; if (!acodec->codec_id && !acodec->codec_tag) return 1; if (acodec->bits_per_coded_sample != bits_per_coded_sample) return 0; switch(flv_codecid) { case FLV_CODECID_PCM: codec_id = bits_per_coded_sample == 8 ? AV_CODEC_ID_PCM_U8 : #if HAVE_BIGENDIAN AV_CODEC_ID_PCM_S16BE; #else AV_CODEC_ID_PCM_S16LE; #endif return codec_id == acodec->codec_id; case FLV_CODECID_PCM_LE: codec_id = bits_per_coded_sample == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_S16LE; return codec_id == acodec->codec_id; case FLV_CODECID_AAC: return acodec->codec_id == AV_CODEC_ID_AAC; case FLV_CODECID_ADPCM: return acodec->codec_id == AV_CODEC_ID_ADPCM_SWF; case FLV_CODECID_SPEEX: return acodec->codec_id == AV_CODEC_ID_SPEEX; case FLV_CODECID_MP3: return acodec->codec_id == AV_CODEC_ID_MP3; case FLV_CODECID_NELLYMOSER_8KHZ_MONO: case FLV_CODECID_NELLYMOSER_16KHZ_MONO: case FLV_CODECID_NELLYMOSER: return acodec->codec_id == AV_CODEC_ID_NELLYMOSER; case FLV_CODECID_PCM_MULAW: return acodec->sample_rate == 8000 && acodec->codec_id == AV_CODEC_ID_PCM_MULAW; case FLV_CODECID_PCM_ALAW: return acodec->sample_rate = 8000 && acodec->codec_id == AV_CODEC_ID_PCM_ALAW; default: return acodec->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET); } }
1threat
Kubernetes: How to refer to one environment variable from another? : <p>I've a <code>Deployment</code> object where I expose the POD ID using the <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="noreferrer">Downward API</a>. That works fine. However, I want to set up another env variable, log path, with reference to the POD ID. But, setting that variable value to <code>/var/log/mycompany/${POD_ID}/logs</code> isn't working, no logs are created in the container. I can make the entrypoint script or the app aware of the POD ID, and build up the log path, but I'd rather not do that.</p>
0debug
Find string with certain lenght VBA : Im trying to use VBA code to find string with excaktly 4 letters/numbers without spaces within a column. There is more more strings in cells. I would like to avoid using formula. I would appreaciate any help.
0debug
static void gen_intermediate_code_internal(CPULM32State *env, TranslationBlock *tb, int search_pc) { struct DisasContext ctx, *dc = &ctx; uint16_t *gen_opc_end; uint32_t pc_start; int j, lj; uint32_t next_page_start; int num_insns; int max_insns; qemu_log_try_set_file(stderr); pc_start = tb->pc; dc->env = env; dc->tb = tb; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = env->singlestep_enabled; dc->nr_nops = 0; if (pc_start & 3) { cpu_abort(env, "LM32: unaligned PC=%x\n", pc_start); } if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("-----------------------------------------\n"); log_cpu_state(env, 0); } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; lj = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } gen_icount_start(); do { check_breakpoint(env, dc); if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } tcg_ctx.gen_opc_pc[lj] = dc->pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } LOG_DIS("%8.8x:\t", dc->pc); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } decode(dc, cpu_ldl_code(env, dc->pc)); dc->pc += 4; num_insns++; } while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !env->singlestep_enabled && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns); if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (unlikely(env->singlestep_enabled)) { if (dc->is_jmp == DISAS_NEXT) { tcg_gen_movi_tl(cpu_pc, dc->pc); } t_gen_raise_exception(dc, EXCP_DEBUG); } else { switch (dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; default: case DISAS_JUMP: case DISAS_UPDATE: tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: break; } } gen_icount_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } else { tb->size = dc->pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("\n"); log_target_disas(env, pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", dc->pc - pc_start, tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf); } #endif }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
I already asked , but how to access view page without id value in the url. : my view.php <?php echo Html::beginForm(['contactpersons/update'], 'post',['id' => 'update-form']) . '<input type="hidden" name="id" value="'.$model->id.'"> <a href="javascript:{}" onclick="document.getElementById(\'update-form\').submit(); return false;">Update</a>'. Html::endForm(); ?> <?= Html::a('Delete', ['delete', 'id' => $model->id], [ 'class' => 'btn btn-danger', 'data' => [ 'confirm' => 'Are you sure you want to delete this item?', 'method' => 'post', ], ]) ?> my controller is public function actionView($id) { $model = $this->findModel($id); return $this->render('view', [ 'model' => $model ]); } How to modify this for getting my view page without id value in the url. Thanks in advance.
0debug
No Individual User Accounts auth option in ASP.NET Core Web API template : <p>I am a bit confused as to why there is no Individual User Accounts authentication option in the latest ASP.NET Core Web API template.</p> <p>Is it still possible to implement individual user accounts the way that the MVC template does or would it not make sense?</p> <p>Let's say I am creating a stand-alone web API that is going to have all of my business logic and data layer that accesses the database which has the AspNet Identity tables. I plan on making calls to this API w/ an MVC app.</p> <p>I know one way of doing this is to create an asp.net MVC app w/ individual user accounts auth and simply build the API right within the MVC app using a controllers/api folder. However, I don't want to do it this way because I want the API to be its own standalone project that can be hosted on a completely different server and accessed by multiple applications, not just an MVC app.</p> <p>Can someone lead me in the right direction on how authentication typically works in this scenario since there is no template?</p>
0debug
What is the difference between Handle and HandleFunc? : <p>I'm trying to understand the differences between Handle and HandleFunc.</p> <p>Other than the differences, when would you use one over the other when building a Go web app?</p> <p><a href="https://golang.org/pkg/net/http/#Handle" rel="nofollow noreferrer">https://golang.org/pkg/net/http/#Handle</a></p>
0debug
Running two PHP versions on the same server : <p>I have two projects on the local server, one project is running PHP5.6 and the other one is running PHP7.0. Now would it be possible to enable this two versions based on the projects? I already tried adding <code>AddHandler application/x-httpd-php7 .php</code> in one of the project htaccess but its not working. Currently, PHP7.0 and PHP5.6-fpm already installed on the server. Below is the screenshot of the phpinfo.</p> <p><a href="https://i.stack.imgur.com/rCwFi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rCwFi.png" alt="enter image description here"></a></p>
0debug
What is the purpose of period (.) in the ~/.bashrc : <p>I've been studying the bash scripting then i noticed using the period wildcard in the bash script, in my sense the period treated as current directory, </p> <p>I have snippet </p> <pre><code>if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi </code></pre> <p><strong>. /etc/bash_completion</strong> In this script what is the use of the (.), period. </p>
0debug
update two tables with same values but different IDs : I'm trying to update two tables with one query with same value but different IDs. I have been looking for solution but all I have found doesnt work for me here is the code: $Image = $_SESSION["ImageName"]; $ImageID = $_POST['ImageID']; $GalleryID = $_POST['GalleryID']; $updateSQL = "UPDATE slideimage, gallery SET slideimage.ImageName='".$Image."', gallery.GalleryPoster='".$Image."' WHERE slideimage.ImageID='".$ImageID."' AND gallery.GalleryID='".$GalleryID."' "; Thank you all for any help
0debug
How to reset Android Studio to previous version : <p>I recently recklessly updated AS from 3.0.1 to 3.1, but project manager says 3.0.1 is the version to be worked with in our project. Is there a way to reset AS to version 3.0.1 without having to uninstall it?</p>
0debug
Best way to find how many times an item in a list repeats in a row, in C#? : <p>Given a list, for example: <code>List&lt;int&gt; _ = new List&lt;int&gt;() { 1, 1, 1, 3, 3, 4, 4, 1, 1, 8, 8, 8, 5, 6, 7, 7, 7, 7, 8, 8 };</code></p> <p>What would be the best / fastest / most efficient way to find how many times an item repeats in a row, in C#? For this list, the result I'd be looking for is something that looks like this:</p> <p>1 * 3</p> <p>3 * 2</p> <p>4 * 2</p> <p>1 * 2</p> <p>8 * 3</p> <p>5 * 1</p> <p>6 * 1</p> <p>7 * 4</p> <p>8 * 2</p> <p>Doesn't have to be in this odd multiplication format, I think it makes it a bit easier to understand.</p> <p>I've been trying looping over the List and comparing each item to the next, but I inevitably get stuck, and don't really know what to do.</p>
0debug
Using variables in Gradle build script : <p>I am using Gradle in my project. I have a task for doing some extra configuration with my war. I need to build a string to use in my task like, lets say I have:</p> <pre><code>task extraStuff{ doStuff 'org.springframework:spring-web:3.0.6.RELEASE@war' } </code></pre> <p>This works fine. What I need to do is define version (actually already defined in properties file) and use this in the task like:</p> <pre><code>springVersion=3.0.6.RELEASE task extraStuff{ doStuff 'org.springframework:spring-web:${springVersion}@war' } </code></pre> <p>My problem is spring version is not recognised as variable. So how can I pass it inside the string?</p>
0debug
How to get the content-length of the response from a request with fetch() : <p>I was getting an error when returning <code>response.json()</code> when I would do a request with an empty response body, so I'm trying to just return an empty object when there is an empty body. The approach I was going for is to check the <code>Content-Length</code> header of the response, however, somehow <code>response.headers.get('Content-Length')</code> somehow returns <code>null</code>. Here is my code:</p> <pre><code>function fetchJSON(url, options, state = null) { return fetch(url, Object.assign({}, options, { // TODO: Add options here that should be there for every API call // TODO: Add token if there is one })) .then(response =&gt; { // Pass the JSON formatted body to the next handler if (response.ok === true) { if (response.headers.get('Content-Length') === 0) return {}; return response.json(); } // If the response was not an 2xx code, throw the appropriate error if (response.status === 401) throw new AuthorizationError("You are not authorized to perform this action"); // If it is an error code that we did not expect, throw an regular error and hope that it gets noticed by // a developer throw new Error("Unexpected response: " + JSON.stringify(response)); }); } </code></pre> <p>Could you maybe help me to find the <code>Content-Length</code> of the response or help me to find another approach?</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
static void ipmi_init_sensors_from_sdrs(IPMIBmcSim *s) { unsigned int i, pos; IPMISensor *sens; for (i = 0; i < MAX_SENSORS; i++) { memset(s->sensors + i, 0, sizeof(*sens)); } pos = 0; for (i = 0; !sdr_find_entry(&s->sdr, i, &pos, NULL); i++) { struct ipmi_sdr_compact *sdr = (struct ipmi_sdr_compact *) &s->sdr.sdr[pos]; unsigned int len = sdr->header.rec_length; if (len < 20) { continue; } if (sdr->header.rec_type != IPMI_SDR_COMPACT_TYPE) { continue; } if (sdr->sensor_owner_number > MAX_SENSORS) { continue; } sens = s->sensors + sdr->sensor_owner_number; IPMI_SENSOR_SET_PRESENT(sens, 1); IPMI_SENSOR_SET_SCAN_ON(sens, (sdr->sensor_init >> 6) & 1); IPMI_SENSOR_SET_EVENTS_ON(sens, (sdr->sensor_init >> 5) & 1); sens->assert_suppt = sdr->assert_mask[0] | (sdr->assert_mask[1] << 8); sens->deassert_suppt = sdr->deassert_mask[0] | (sdr->deassert_mask[1] << 8); sens->states_suppt = sdr->discrete_mask[0] | (sdr->discrete_mask[1] << 8); sens->sensor_type = sdr->sensor_type; sens->evt_reading_type_code = sdr->reading_type & 0x7f; sens->assert_enable = sens->assert_suppt; sens->deassert_enable = sens->deassert_suppt; } }
1threat
Codename one Tabs : Guys i stuck with this [Codename one][1] UI component from two days and still i didn't get proper solution for that...i will add tabs in my application but when i run the application, The tabs i have added looking not good as i expected so someone help me to get out of this mess? ... thanks in advance. i am sending screenshot of my application[![enter image description here][2]][1] [1]: http://www.codenameone.com [2]: https://i.stack.imgur.com/Uf3nd.png
0debug
Print formatted key and [key, value] from Dictionary : I would like to know how to print key and value from Dictionary. My grouped dictionary: var Grouped: [String? : [(key: String, value: String?)]] How it prints right now. ("9:00 - 22:00", [(key: "II", value: Optional("9:00 - 22:00")), (key: "III", value: Optional("9:00 - 22:00")), (key: "IV", value: Optional("9:00 - 22:00"))]) ("7:00 - 22:00", [(key: "I", value: Optional("7:00 - 22:00"))]) ("Closed", [(key: "VII", value: Optional("Closed"))]) ("9:00 - 21:00", [(key: "V", value: Optional("9:00 - 21:00"))]) ("10:00 - 20:00", [(key: "VI", value: Optional("10:00 - 20:00"))]) Is it possible to print values like that: "9:00 - 22:00" - "II", "III", "IV" "7:00 - 22:00" - "I", "VII" "9:00 - 21:00" - "V" "10:00 - 20:00" - "VI" What is the best way to achieve this in Swift?
0debug
FTP download - not saving : <p>I have a script to download CSV files from a FTP server. I have tested the script now several time. And from PyCharm there are coming no Error. It is going trough as "processed". But the problem is that it is not saving/downloading the files. I can find them in my directory. </p> <p>So I have no feedback in what I am doing wrong. Can anybody help me/ tell me where I am going wrong?</p> <pre><code>from ftplib import FTP import os #domain name or server ip: ftp = FTP('..') ftp.login(user='..', passwd = '..') savedir = '/Users/bjorn/documents/test' os.chdir(savedir) def grabFile(): filename = '2018-11-16-inquiries.csv' localfile = open(filename, 'wb') ftp.retrbinary('RETR ' + filename, localfile.write, 1024) print filename, "done" ftp.quit() localfile.close() </code></pre>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Does matlab simulate "0" for infinitely-many solutions? : Matlab simulates solve(a==a)=0. The solution should have been infinitely many (the solution should have looked like a=a) but it simulates the solution equal to zero which is incorrect. How to fix this?
0debug
static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket *pkt, int len) { ByteIOContext *pb = &s->pb; int hdr, seq, pic_num, len2, pos; int type; int ssize; hdr = get_byte(pb); len--; type = hdr >> 6; switch(type){ case 0: case 2: seq = get_byte(pb); len--; len2 = get_num(pb, &len); pos = get_num(pb, &len); pic_num = get_byte(pb); len--; rm->remaining_len = len; break; case 1: seq = get_byte(pb); len--; if(av_new_packet(pkt, len + 9) < 0) return AVERROR(EIO); pkt->data[0] = 0; AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 5, 0); get_buffer(pb, pkt->data + 9, len); rm->remaining_len = 0; return 0; case 3: len2 = get_num(pb, &len); pos = get_num(pb, &len); pic_num = get_byte(pb); len--; rm->remaining_len = len - len2; if(av_new_packet(pkt, len2 + 9) < 0) return AVERROR(EIO); pkt->data[0] = 0; AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 5, 0); get_buffer(pb, pkt->data + 9, len2); return 0; } if((seq & 0x7F) == 1 || rm->curpic_num != pic_num){ rm->slices = ((hdr & 0x3F) << 1) + 1; ssize = len2 + 8*rm->slices + 1; rm->videobuf = av_realloc(rm->videobuf, ssize); rm->videobufsize = ssize; rm->videobufpos = 8*rm->slices + 1; rm->cur_slice = 0; rm->curpic_num = pic_num; rm->pktpos = url_ftell(pb); } if(type == 2){ len = FFMIN(len, pos); pos = len2 - pos; } if(++rm->cur_slice > rm->slices) return 1; AV_WL32(rm->videobuf - 7 + 8*rm->cur_slice, 1); AV_WL32(rm->videobuf - 3 + 8*rm->cur_slice, rm->videobufpos - 8*rm->slices - 1); if(rm->videobufpos + len > rm->videobufsize) return 1; if (get_buffer(pb, rm->videobuf + rm->videobufpos, len) != len) return AVERROR(EIO); rm->videobufpos += len, rm->remaining_len-= len; if(type == 2 || (rm->videobufpos) == rm->videobufsize){ rm->videobuf[0] = rm->cur_slice-1; if(av_new_packet(pkt, rm->videobufpos - 8*(rm->slices - rm->cur_slice)) < 0) return AVERROR(ENOMEM); memcpy(pkt->data, rm->videobuf, 1 + 8*rm->cur_slice); memcpy(pkt->data + 1 + 8*rm->cur_slice, rm->videobuf + 1 + 8*rm->slices, rm->videobufpos - 1 - 8*rm->slices); pkt->pts = AV_NOPTS_VALUE; pkt->pos = rm->pktpos; return 0; } return 1; }
1threat
static int ipvideo_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IpvideoContext *s = avctx->priv_data; AVFrame *frame = data; int ret; int send_buffer; int frame_format; int video_data_size; if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) { av_frame_unref(s->last_frame); av_frame_unref(s->second_last_frame); } if (buf_size < 6) return AVERROR_INVALIDDATA; frame_format = AV_RL8(buf); send_buffer = AV_RL8(buf + 1); video_data_size = AV_RL16(buf + 2); s->decoding_map_size = AV_RL16(buf + 4); if (frame_format != 0x11) av_log(avctx, AV_LOG_ERROR, "Frame type 0x%02X unsupported\n", frame_format); if (! s->decoding_map_size) { av_log(avctx, AV_LOG_ERROR, "Empty decoding map\n"); return AVERROR_INVALIDDATA; } bytestream2_init(&s->stream_ptr, buf + 6, video_data_size); s->decoding_map = buf + 6 + video_data_size; if (buf_size < 6 + s->decoding_map_size + video_data_size) { av_log(avctx, AV_LOG_ERROR, "Invalid IP packet size\n"); return AVERROR_INVALIDDATA; } if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; if (!s->is_16bpp) { int size; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); if (pal && size == AVPALETTE_SIZE) { frame->palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } else if (pal) { av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); } } ipvideo_decode_opcodes(s, frame); *got_frame = send_buffer; av_frame_unref(s->second_last_frame); FFSWAP(AVFrame*, s->second_last_frame, s->last_frame); if ((ret = av_frame_ref(s->last_frame, frame)) < 0) return ret; return buf_size; }
1threat
Cannot create file using Cocoa (Apple) with objective-C : I'm using xCode to create MacOS application with Cocoa(Objective-C). I happen to create a text file when running my app with the button Run inside xCode, but the problem is that the file is not created when I run my application from the directory Products/Release/ has it something to do with permissions (?)
0debug
How to sum only one textbox value and show result in label in c# : <p>The question could be duplicate but my problem is totally different.</p> <p>I have a one textbox and one label.</p> <p>Example: label text is already exist with number like 450 Now I want to add number in textbox and the textbox value should be sum in 450 + 30 = 480 where 30 is textbox value.</p> <p>what I have tried:</p> <pre><code>lbl_TotalAmount.Text = lbl_TotalAmount.Text + txt_DeliveryCharges.Text; </code></pre> <p>The above Result is: <code>45030</code></p> <p>Another Code I Have tried:</p> <pre><code>double total = Convert.ToDouble(lbl_TotalAmount.Text); double charges = Convert.ToDouble(txt_DeliveryCharges.Text); double sum = total + charges; lbl_TotalAmount.Text = String.Format(sum.ToString("0.00")); </code></pre> <p>The above code is going to sum every value that I put in the textbox and also when I remove one word the number is sum every time.</p> <p>Please give me best solution I tried many solution to solve this but unable to do this.</p> <p>Sorry for bad English.</p>
0debug
automaticaly delete old Data : I have a table that I like the old Data will be deleted automatically. namely, if the zeit old than 5 days The table looks like this. http://de.share-your-photo.com/e6508ee7a6 can someone help me? these do not work <?php require_once __DIR__ . '/connection.php'; $variants_remove='DELETE FROM drucker AS drucker WHERE datediff(now(), drucker.zeit) > 5'; $req = $dbConnect->query($variants_remove); ?> Thank
0debug
Ignoring files from checkin with certain pattern of change : <p>Since having started using <a href="https://www.nuget.org/packages/JetBrains.Annotations">JetBrains Annotations</a>, for my own benefit I've decorated all methods with <code>[CanBeNull]</code> or <code>[NotNull]</code></p> <p>For example, the following line:</p> <pre><code>public AccountController(IAccountService accountService) </code></pre> <p>Would be changed to:</p> <pre><code> public AccountController([CanBeNull] IAccountService accountService) </code></pre> <p>Another example would be:</p> <pre><code>public Account CreateAccountEntity(Account accountEnttity) </code></pre> <p>would be changed to:</p> <pre><code> [CanBeNull] public Account CreateAccountEntity([NotNull] Account accountEnttity) </code></pre> <p><strong>How can I bypass pending changes for annotations, specifically "[CanBeNull]", and have TFS completely ignore this change?</strong></p>
0debug
How do I send alerts every minute? : <p>I'm new to html and javascript but I was wondering how I could go about sending alerts like this <a href="https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_alert" rel="nofollow noreferrer">https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_alert</a> every minute or so.</p>
0debug
accessing 500 text file in 1 folder and spleting them according to certain delimeters using C# : So, I've got 500 .txt files contain **a lot** of words and I want to access those 500 files and store each word in it into a dictionary (the word is separated by space, "/" , "," , ".", etc...) any ideas how can I work this out in C#? Thanks in advance!
0debug
Why is Chrome coloring my cookie red when I set it from the inspector? : <p>If I open the inspector for a page, go to the Application tab, scroll down to Cookies in the left-hand list, expand it, and click my domain, I get a list of cookies set on the domain. I can add new entries to the list and edit existing ones, setting and updating cookies stored for that domain.</p> <p>After upgrading to Chrome 73 if I try and set a cookie the browser colors the text red and does not set or save the cookie. How do I continue setting cookies in Chrome 73?</p>
0debug
static int parse_hex32(DeviceState *dev, Property *prop, const char *str) { uint32_t *ptr = qdev_get_prop_ptr(dev, prop); if (sscanf(str, "%" PRIx32, ptr) != 1) return -EINVAL; return 0; }
1threat
I have to set a heading to the font-family "Cooper Black" but it never actually goes to it. : <p>I'm submitting the gist I have of it with the questions as well. It is specifically question 8 on the full blown assignment. <a href="https://gist.github.com/JStrong0037/67c1a09ccd1943be84f4" rel="nofollow">This</a> is the gist with all my code, but I used the line, font-family: 'Cooper Black', serif; which isn't working. </p> <p>I feel pretty dumb that no matter what I've tried it never works for me. I've tried Chrome, Firefox, and Edge all three when opening this. I'm actually getting desperate to find the cause of the problem or what I'm doing wrong.</p> <p>Thanks for any help you guys can give me!</p>
0debug
static int gif_image_write_image(ByteIOContext *pb, int x1, int y1, int width, int height, const uint8_t *buf, int linesize, int pix_fmt) { PutBitContext p; uint8_t buffer[200]; int i, left, w, v; const uint8_t *ptr; put_byte(pb, 0x2c); put_le16(pb, x1); put_le16(pb, y1); put_le16(pb, width); put_le16(pb, height); put_byte(pb, 0x00); put_byte(pb, 0x08); left= width * height; init_put_bits(&p, buffer, 130); ptr = buf; w = width; while(left>0) { gif_put_bits_rev(&p, 9, 0x0100); for(i=0;i<GIF_CHUNKS;i++) { if (pix_fmt == PIX_FMT_RGB24) { v = gif_clut_index(ptr[0], ptr[1], ptr[2]); ptr+=3; } else { v = *ptr++; } gif_put_bits_rev(&p, 9, v); if (--w == 0) { w = width; buf += linesize; ptr = buf; } } if(left<=GIF_CHUNKS) { gif_put_bits_rev(&p, 9, 0x101); gif_flush_put_bits_rev(&p); } if(pbBufPtr(&p) - p.buf > 0) { put_byte(pb, pbBufPtr(&p) - p.buf); put_buffer(pb, p.buf, pbBufPtr(&p) - p.buf); p.buf_ptr = p.buf; } if(left<=GIF_CHUNKS) { put_byte(pb, 0x00); } left-=GIF_CHUNKS; } return 0; }
1threat
Amazon S3 - different lifecycle rule for "subdirectory" than for parent "directory" : <p>Let's say I have the following data structure:</p> <ul> <li>/</li> <li>/foo</li> <li>/foo/bar</li> <li>/foo/baz</li> </ul> <p>Is it possible to assign to it the following life-cycle rules:</p> <ul> <li>/ (1 month)</li> <li>/foo (2 months)</li> <li>/foo/bar (3 months)</li> <li>/foo/baz (6 months)</li> </ul> <p>The official documentation is unfortunately self-contradictionary in this regard. It doesn't seem to work with AWS console, which makes me somewhat doubtful that SDKs/REST would be any different ;)</p> <p>Failing at that my root problem is: I have 4 types of projects. The most rudimentary type has a few thousand projects, the other ones have a few dozen. Each type I am obligated to store for a different period of time. Each project contains hundreds of thousands of objects. It looks more or less as:</p> <ul> <li>type A, 90% of projects, x storage required</li> <li>type B, 6% of projects, 2x storage required</li> <li>type C, 3% of projects, 4x storage required</li> <li>type D, 1% of projects, 8x storage required</li> </ul> <p>So far so simple. However. Projects may be upgraded or downgraded from one type to another. And as I said - I have a few thousand instances of the first type so I can't write specific rules for every one of them (remember 1000 rule limit per bucket). And since they may upgrade from one type to another I can't simply insert them in a their own folders as well (ex. only projects from a particular type) or bucket. Or so I think? Are there any other options open to me other than iterating over every object, every time I want to purge expired files - which I would seriously rather not do because of the sheer number of objects?</p> <p>Maybe some kind of file "move/transfer" between buckets that doesn't modify the creation time metadata, and isn't costly for our server to process?</p> <p>Would be much obliged :)</p>
0debug
static void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc) { int16_t *filterPos = c->hChrFilterPos; int16_t *filter = c->hChrFilter; void *mmx2FilterCode= c->chrMmx2FilterCode; int i; #if defined(PIC) DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif #if ARCH_X86_64 DECLARE_ALIGNED(8, uint64_t, retsave); #endif __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %7 \n\t" #if ARCH_X86_64 "mov -8(%%rsp), %%"REG_a" \n\t" "mov %%"REG_a", %8 \n\t" #endif #else #if ARCH_X86_64 "mov -8(%%rsp), %%"REG_a" \n\t" "mov %%"REG_a", %7 \n\t" #endif #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE "xor %%"REG_a", %%"REG_a" \n\t" "mov %5, %%"REG_c" \n\t" "mov %6, %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %7, %%"REG_b" \n\t" #if ARCH_X86_64 "mov %8, %%"REG_a" \n\t" "mov %%"REG_a", -8(%%rsp) \n\t" #endif #else #if ARCH_X86_64 "mov %7, %%"REG_a" \n\t" "mov %%"REG_a", -8(%%rsp) \n\t" #endif #endif :: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos), "m" (mmx2FilterCode), "m" (src2), "m"(dst2) #if defined(PIC) ,"m" (ebxsave) #endif #if ARCH_X86_64 ,"m"(retsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { dst1[i] = src1[srcW-1]*128; dst2[i] = src2[srcW-1]*128; } }
1threat
Problem for execute examples in language of programming c++ : <p>I'm newbie and very confused. </p> <p>My compiler is g++ (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4. The program are executed in visual studio. </p> <p>I don't know what's my problem. </p> <p>My command is: </p> <blockquote> <p>g++ -Wall -std=c++11 Book.h Book.cpp Customer.h Customer.cpp Library.h Library.cpp Main.cpp -o Main</p> </blockquote> <pre><code>Main.cpp:1:15: fatal error: Set: No existe el archivo o el directorio #include &lt;Set&gt; ^ compilation terminated. </code></pre>
0debug
unable to pass the context to the another class in android : [enter image description here][1]ServiceCalls serviceCalls = new ServiceCalls(this, "ks"); serviceCalls.execute(requestParams); [1]: http://i.stack.imgur.com/DTjw1.png Note:pls check the image.I am not good at english.thanks in advance
0debug
adb -s 192.168.1.6:5555 ..... error: more than one device/emulator : <p>I am working with react native, and would like to switch adb to wifi for easier debugging.</p> <p>I connect my device using usb, then type these commands.</p> <pre><code>adb tcpip 5555 </code></pre> <p>Then I disconnect my usb cable and enter this command</p> <pre><code>adb connect 192.168.1.6 connected to 192.168.1.6:5555 </code></pre> <p>adb devices result in the following</p> <pre><code>adb devices List of devices attached 192.168.1.6:5555 device </code></pre> <p>So it only shows one device connected. However trying this command</p> <pre><code>adb reverse tcp:8081 tcp:8081 </code></pre> <p>gives me the following error even though only one device is shown with adb devices command as shown above</p> <pre><code>error: more than one device/emulator </code></pre> <p>So I tried this command but I also get the same error</p> <pre><code>adb -s 192.168.1.6:5555 reverse tcp:8081 tcp:8081 error: more than one device/emulator </code></pre> <p>Trying the following gives me the same error</p> <pre><code>adb -s "192.168.1.6:5555" reverse tcp:8081 tcp:8081 adb -s "192.168.1.6" reverse tcp:8081 tcp:8081 adb -s 192.168.1.6 reverse tcp:8081 tcp:8081 </code></pre> <p>even trying to use the device id which I copied when it was connected to usb resulted in the same error</p> <pre><code>adb -s deviceid reverse tcp:8081 tcp:8081 </code></pre> <p>Is there a way to make adb reverse work when adb is connected wireless?</p> <p>Thanks for advance.</p>
0debug
Couldn't get the reason for the fault in th code : This is a program to print the smallest value and its position in an array (defined by user). #include <stdio.h> int position_smallest(int a[],int n) { int smallest = a[0]; int i,k; for(i=0; i<=n-1; i=i+1) { if(a[i]<a[0]) { smallest = a[i]; k = i; } } printf("The smallest value is %d\n", smallest); printf("It's position is %d\n", k); return 0; } int main() { int n,j; int a[n]; printf("Enter the size of the array: "); scanf("%d", &n); for(j=0; j<=n; j=j+1) { printf("a[%d] = ", j); scanf("%d", &a[j]); } position_smallest(a,n); } But upon running it, it shows following error: Segmentation fault (core dumped) What can be the possible reason(s) for it?
0debug
static void gen_rsr(DisasContext *dc, TCGv_i32 d, uint32_t sr) { static void (* const rsr_handler[256])(DisasContext *dc, TCGv_i32 d, uint32_t sr) = { [CCOUNT] = gen_rsr_ccount, [PTEVADDR] = gen_rsr_ptevaddr, }; if (sregnames[sr]) { if (rsr_handler[sr]) { rsr_handler[sr](dc, d, sr); } else { tcg_gen_mov_i32(d, cpu_SR[sr]); } } else { qemu_log("RSR %d not implemented, ", sr); } }
1threat
split MYSQL field into array and search : <p>I have field in MySQL table. The field is called 'vehicles' When I add vehicles I add them by ID not name, so the field is populated like '2:3:4:6:7:9' 2 will be a car, 7 will be a bike, etc. </p> <p>What I want to do quickly and simply is when I query the table I want to see if the field vehicle contains '2' is in that field within the 2:3:4:7:9. </p> <p>I have tried a lot but coming up blank?</p> <p>Thanks</p>
0debug
static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash, const struct ppc_one_seg_page_size *sps, target_ulong ptem, ppc_hash_pte64_t *pte, unsigned *pshift) { CPUPPCState *env = &cpu->env; int i; const ppc_hash_pte64_t *pteg; target_ulong pte0, pte1; target_ulong ptex; ptex = (hash & env->htab_mask) * HPTES_PER_GROUP; pteg = ppc_hash64_map_hptes(cpu, ptex, HPTES_PER_GROUP); if (!pteg) { return -1; } for (i = 0; i < HPTES_PER_GROUP; i++) { pte0 = ppc_hash64_hpte0(cpu, pteg, i); pte1 = ppc_hash64_hpte1(cpu, pteg, i); if (HPTE64_V_COMPARE(pte0, ptem)) { *pshift = hpte_page_shift(sps, pte0, pte1); if (*pshift == 0) { continue; } pte->pte0 = pte0; pte->pte1 = pte1; ppc_hash64_unmap_hptes(cpu, pteg, ptex, HPTES_PER_GROUP); return ptex + i; } } ppc_hash64_unmap_hptes(cpu, pteg, ptex, HPTES_PER_GROUP); return -1; }
1threat
static inline void RENAME(rgb15to24)(const uint8_t *src, uint8_t *dst, unsigned src_size) { const uint16_t *end; #ifdef HAVE_MMX const uint16_t *mm_end; #endif uint8_t *d = (uint8_t *)dst; const uint16_t *s = (uint16_t *)src; end = s + src_size/2; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 7; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq %1, %%mm1\n\t" "movq %1, %%mm2\n\t" "pand %2, %%mm0\n\t" "pand %3, %%mm1\n\t" "pand %4, %%mm2\n\t" "psllq $3, %%mm0\n\t" "psrlq $2, %%mm1\n\t" "psrlq $7, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "movq %%mm1, %%mm4\n\t" "movq %%mm2, %%mm5\n\t" "punpcklwd %5, %%mm0\n\t" "punpcklwd %5, %%mm1\n\t" "punpcklwd %5, %%mm2\n\t" "punpckhwd %5, %%mm3\n\t" "punpckhwd %5, %%mm4\n\t" "punpckhwd %5, %%mm5\n\t" "psllq $8, %%mm1\n\t" "psllq $16, %%mm2\n\t" "por %%mm1, %%mm0\n\t" "por %%mm2, %%mm0\n\t" "psllq $8, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm4, %%mm3\n\t" "por %%mm5, %%mm3\n\t" "movq %%mm0, %%mm6\n\t" "movq %%mm3, %%mm7\n\t" "movq 8%1, %%mm0\n\t" "movq 8%1, %%mm1\n\t" "movq 8%1, %%mm2\n\t" "pand %2, %%mm0\n\t" "pand %3, %%mm1\n\t" "pand %4, %%mm2\n\t" "psllq $3, %%mm0\n\t" "psrlq $2, %%mm1\n\t" "psrlq $7, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "movq %%mm1, %%mm4\n\t" "movq %%mm2, %%mm5\n\t" "punpcklwd %5, %%mm0\n\t" "punpcklwd %5, %%mm1\n\t" "punpcklwd %5, %%mm2\n\t" "punpckhwd %5, %%mm3\n\t" "punpckhwd %5, %%mm4\n\t" "punpckhwd %5, %%mm5\n\t" "psllq $8, %%mm1\n\t" "psllq $16, %%mm2\n\t" "por %%mm1, %%mm0\n\t" "por %%mm2, %%mm0\n\t" "psllq $8, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm4, %%mm3\n\t" "por %%mm5, %%mm3\n\t" :"=m"(*d) :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null) :"memory"); __asm __volatile( "movq %%mm0, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "movq %%mm6, %%mm0\n\t" "movq %%mm7, %%mm1\n\t" "movq %%mm4, %%mm6\n\t" "movq %%mm5, %%mm7\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm1, %%mm3\n\t" "psrlq $8, %%mm2\n\t" "psrlq $8, %%mm3\n\t" "psrlq $8, %%mm6\n\t" "psrlq $8, %%mm7\n\t" "pand %2, %%mm0\n\t" "pand %2, %%mm1\n\t" "pand %2, %%mm4\n\t" "pand %2, %%mm5\n\t" "pand %3, %%mm2\n\t" "pand %3, %%mm3\n\t" "pand %3, %%mm6\n\t" "pand %3, %%mm7\n\t" "por %%mm2, %%mm0\n\t" "por %%mm3, %%mm1\n\t" "por %%mm6, %%mm4\n\t" "por %%mm7, %%mm5\n\t" "movq %%mm1, %%mm2\n\t" "movq %%mm4, %%mm3\n\t" "psllq $48, %%mm2\n\t" "psllq $32, %%mm3\n\t" "pand %4, %%mm2\n\t" "pand %5, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "psrlq $16, %%mm1\n\t" "psrlq $32, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm3, %%mm1\n\t" "pand %6, %%mm5\n\t" "por %%mm5, %%mm4\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm1, 8%0\n\t" MOVNTQ" %%mm4, 16%0" :"=m"(*d) :"m"(*s),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh) :"memory"); d += 24; s += 8; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { register uint16_t bgr; bgr = *s++; *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x7C00)>>7; } }
1threat
Change the label content while processing : <p>I have a function which makes process. At the beginning of the function I want to change the text of a label which indicates the state, and once the process ends, change it again.</p> <p>The fact is that only is shown the final change.</p> <p>I know I can make a thread for the process but not needed in this case and I merely want to know if there's some tip or trick to accomplish it whitout the use of a thread.</p>
0debug
Regex match and count : Using Regex how would you count triplicates in a string? example 122244445577777 1 222 444 4 55 777 77 answer 3
0debug
Regex doesnt contain : I'm looking for the regex expression for a string matching a string starting with a ";" and ending with a ":", that contain neither ";" nor ":" For example ";zreazer:" should match but ";raz:er:" or ";er;:" should not Any idea? :) Thanks in advance, I tried some with ^ and ?! symbols but it didn't work out very well
0debug
static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *machine) { int i; HotpluggableCPUList *head = NULL; sPAPRMachineState *spapr = SPAPR_MACHINE(machine); sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine); int spapr_max_cores = max_cpus / smp_threads; g_assert(smc->dr_cpu_enabled); for (i = 0; i < spapr_max_cores; i++) { HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1); HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1); CpuInstanceProperties *cpu_props = g_new0(typeof(*cpu_props), 1); cpu_item->type = spapr_get_cpu_core_type(machine->cpu_model); cpu_item->vcpus_count = smp_threads; cpu_props->has_core_id = true; cpu_props->core_id = i * smp_threads; cpu_item->props = cpu_props; if (spapr->cores[i]) { cpu_item->has_qom_path = true; cpu_item->qom_path = object_get_canonical_path(spapr->cores[i]); } list_item->value = cpu_item; list_item->next = head; head = list_item; } return head; }
1threat
Regex for phone number that starts with + : <p>For example +4456689854333 is a correct match</p>
0debug
replace CR LF in SED : I have a 1.5 GB Windows text file with some lines ending with LF and most of lines ending with CR+LF Can you please help with SED script which - a. will replace all CR+LF with $|$ - replace all LF with CR+LF - replace back all $|$ with CR+LF
0debug
React Hook : Send data from child to parent component : <p>I'm looking for the easiest solution to pass data from a child component to his parent.</p> <p>I've heard about using Context, pass trough properties or update props, but I don't know which one is the best solution.</p> <p>I'm building an admin interface, with a PageComponent that contains a ChildComponent with a table where I can select multiple line. I want to send to my parent PageComponent the number of line I've selected in my ChildComponent.</p> <p>Something like that :</p> <p>PageComponent :</p> <pre><code>&lt;div className="App"&gt; &lt;EnhancedTable /&gt; &lt;h2&gt;count 0&lt;/h2&gt; (count should be updated from child) &lt;/div&gt; </code></pre> <p>ChildComponent : </p> <pre><code> const EnhancedTable = () =&gt; { const [count, setCount] = useState(0); return ( &lt;button onClick={() =&gt; setCount(count + 1)}&gt; Click me {count} &lt;/button&gt; ) }; </code></pre> <p>I'm sure it's a pretty simple thing to do, I don't want to use redux for that.</p>
0debug
static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, struct vfio_irq_info info) { int ret; VFIOPlatformDevice *vdev = container_of(vbasedev, VFIOPlatformDevice, vbasedev); SysBusDevice *sbdev = SYS_BUS_DEVICE(vdev); VFIOINTp *intp; intp = g_malloc0(sizeof(*intp)); intp->vdev = vdev; intp->pin = info.index; intp->flags = info.flags; intp->state = VFIO_IRQ_INACTIVE; intp->kvm_accel = false; sysbus_init_irq(sbdev, &intp->qemuirq); intp->interrupt = g_malloc0(sizeof(EventNotifier)); ret = event_notifier_init(intp->interrupt, 0); if (ret) { g_free(intp->interrupt); g_free(intp); error_report("vfio: Error: trigger event_notifier_init failed "); return NULL; } intp->unmask = g_malloc0(sizeof(EventNotifier)); ret = event_notifier_init(intp->unmask, 0); if (ret) { g_free(intp->interrupt); g_free(intp->unmask); g_free(intp); error_report("vfio: Error: resamplefd event_notifier_init failed"); return NULL; } QLIST_INSERT_HEAD(&vdev->intp_list, intp, next); return intp; }
1threat
static uint64_t ahci_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { AHCIState *s = opaque; uint32_t val = 0; if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) { switch (addr) { case HOST_CAP: val = s->control_regs.cap; break; case HOST_CTL: val = s->control_regs.ghc; break; case HOST_IRQ_STAT: val = s->control_regs.irqstatus; break; case HOST_PORTS_IMPL: val = s->control_regs.impl; break; case HOST_VERSION: val = s->control_regs.version; break; } DPRINTF(-1, "(addr 0x%08X), val 0x%08X\n", (unsigned) addr, val); } else if ((addr >= AHCI_PORT_REGS_START_ADDR) && (addr < (AHCI_PORT_REGS_START_ADDR + (s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) { val = ahci_port_read(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7, addr & AHCI_PORT_ADDR_OFFSET_MASK); } return val; }
1threat
multiple underscores randomly in a string : /*I want random multiple underscores everytime I refresh the page in a string...*/ enter code here <html> <body> <p id="demo"></p> <p id="temo"></p> <p id="jemo"></p> <p id="remo"></p> <script> var i; var x="Sachin Tendulkar";//String in which i want underscores var res=x.split(""); for(i=1;i<=7;i++)//here in this for loop i generated random numbers and accessing the elements at that indexes and try to put underscores there. { var j=document.getElementById("demo").innerHTML=Math.floor(Math.random()* ((x.length-1)/2)); var t=res[j]; var f=document.getElementById("jemo").innerHTML=x.replace(res[j],"_"); var l=document.getElementById("jemo").innerHTML=f.replace(res[j],"_"); } </script> </body> </html>
0debug
Set Default/Null Value with Select TagHelper : <p>In asp.net mvc you can use:</p> <pre><code>@Html.DropDownListFor(model =&gt; model.Category, ViewBag.Category as IEnumerable&lt;SelectListItem&gt;, "-- SELECT --", new { @class = "form-control" }) </code></pre> <p>Using asp.net 5, how do I include the default or null value <strong>(-- SELECT --)</strong> in a taghelper:</p> <pre><code>&lt;select asp-for="Category" asp-items="@ViewBag.Category" class="form-control"&gt;&lt;/select&gt; </code></pre>
0debug
Angular2 rxjs missing observable.interval method : <p>I'm trying to use the interval method of an observable but I keep getting the error </p> <pre><code> Property 'interval' does not exist on type 'Observable&lt;any&gt;'. </code></pre> <p>I added these imports:</p> <pre><code>import "rxjs/Rx"; import "rxjs/add/observable/interval"; import "rxjs/observable/IntervalObservable"; </code></pre>
0debug
How to use arguments in c# console application? : <p>how can i use arguments in c# console application? hello everyone what is arguments?and how to use it in C# Console? i want,when the user input was empty. it shows help also,when the user input was wrong,it shows help too. help me thanks a lot</p>
0debug
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp) { AVFrame *src = srcp->f; int ret; if (src->format == AV_PIX_FMT_VIDEOTOOLBOX && src->buf[0]->size == 1) return AVERROR_EXTERNAL; ret = av_frame_ref(dst, src); if (ret < 0) return ret; av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(&h->sei.frame_packing), 0); if (srcp->sei_recovery_frame_cnt == 0) dst->key_frame = 1; return 0; }
1threat
static unsigned long iv_decode_frame(Indeo3DecodeContext *s, const uint8_t *buf, int buf_size) { unsigned int image_width, image_height, chroma_width, chroma_height; unsigned long flags, cb_offset, data_size, y_offset, v_offset, u_offset, mc_vector_count; const uint8_t *hdr_pos, *buf_pos; buf_pos = buf; buf_pos += 18; flags = bytestream_get_le16(&buf_pos); data_size = bytestream_get_le32(&buf_pos); cb_offset = *buf_pos++; buf_pos += 3; image_height = bytestream_get_le16(&buf_pos); image_width = bytestream_get_le16(&buf_pos); if(avcodec_check_dimensions(NULL, image_width, image_height)) return -1; chroma_height = ((image_height >> 2) + 3) & 0x7ffc; chroma_width = ((image_width >> 2) + 3) & 0x7ffc; y_offset = bytestream_get_le32(&buf_pos); v_offset = bytestream_get_le32(&buf_pos); u_offset = bytestream_get_le32(&buf_pos); buf_pos += 4; hdr_pos = buf_pos; if(data_size == 0x80) return 4; if(flags & 0x200) { s->cur_frame = s->iv_frame + 1; s->ref_frame = s->iv_frame; } else { s->cur_frame = s->iv_frame; s->ref_frame = s->iv_frame + 1; } buf_pos = buf + 16 + y_offset; mc_vector_count = bytestream_get_le32(&buf_pos); iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, image_width, image_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos, FFMIN(image_width, 160)); if (!(s->avctx->flags & CODEC_FLAG_GRAY)) { buf_pos = buf + 16 + v_offset; mc_vector_count = bytestream_get_le32(&buf_pos); iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos, FFMIN(chroma_width, 40)); buf_pos = buf + 16 + u_offset; mc_vector_count = bytestream_get_le32(&buf_pos); iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos, FFMIN(chroma_width, 40)); } return 8; }
1threat
int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp) { struct ifreq ifr; int fd, ret; int len = sizeof(struct virtio_net_hdr); unsigned int features; TFR(fd = open(PATH_NET_TUN, O_RDWR)); if (fd < 0) { error_setg_errno(errp, errno, "could not open %s", PATH_NET_TUN); return -1; } memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(fd, TUNGETFEATURES, &features) == -1) { error_report("warning: TUNGETFEATURES failed: %s", strerror(errno)); features = 0; } if (features & IFF_ONE_QUEUE) { ifr.ifr_flags |= IFF_ONE_QUEUE; } if (*vnet_hdr) { if (features & IFF_VNET_HDR) { *vnet_hdr = 1; ifr.ifr_flags |= IFF_VNET_HDR; } else { *vnet_hdr = 0; } if (vnet_hdr_required && !*vnet_hdr) { error_setg(errp, "vnet_hdr=1 requested, but no kernel " "support for IFF_VNET_HDR available"); close(fd); return -1; } ioctl(fd, TUNSETVNETHDRSZ, &len); } if (mq_required) { if (!(features & IFF_MULTI_QUEUE)) { error_setg(errp, "multiqueue required, but no kernel " "support for IFF_MULTI_QUEUE available"); close(fd); return -1; } else { ifr.ifr_flags |= IFF_MULTI_QUEUE; } } if (ifname[0] != '\0') pstrcpy(ifr.ifr_name, IFNAMSIZ, ifname); else pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d"); ret = ioctl(fd, TUNSETIFF, (void *) &ifr); if (ret != 0) { if (ifname[0] != '\0') { error_setg_errno(errp, errno, "could not configure %s (%s)", PATH_NET_TUN, ifr.ifr_name); } else { error_setg_errno(errp, errno, "could not configure %s", PATH_NET_TUN); } close(fd); return -1; } pstrcpy(ifname, ifname_size, ifr.ifr_name); fcntl(fd, F_SETFL, O_NONBLOCK); return fd; }
1threat
static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) { BDRVRawState *s = bs->opaque; char *buf; size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); if (bdrv_is_sg(bs) || !s->needs_alignment) { bs->request_alignment = 1; s->buf_align = 1; return; } bs->request_alignment = 0; s->buf_align = 0; if (probe_logical_blocksize(fd, &bs->request_alignment) < 0) { bs->request_alignment = 0; } #ifdef CONFIG_XFS if (s->is_xfs) { struct dioattr da; if (xfsctl(NULL, fd, XFS_IOC_DIOINFO, &da) >= 0) { bs->request_alignment = da.d_miniosz; } } #endif if (!s->buf_align) { size_t align; buf = qemu_memalign(max_align, 2 * max_align); for (align = 512; align <= max_align; align <<= 1) { if (raw_is_io_aligned(fd, buf + align, max_align)) { s->buf_align = align; break; } } qemu_vfree(buf); } if (!bs->request_alignment) { size_t align; buf = qemu_memalign(s->buf_align, max_align); for (align = 512; align <= max_align; align <<= 1) { if (raw_is_io_aligned(fd, buf, align)) { bs->request_alignment = align; break; } } qemu_vfree(buf); } if (!s->buf_align || !bs->request_alignment) { error_setg(errp, "Could not find working O_DIRECT alignment. " "Try cache.direct=off."); } }
1threat
How exactly c++ vtable works? (with example in the q.) : <p>lets take an c++ example:</p> <pre><code>class A { public: A() { cout &lt;&lt; "hey" &lt;&lt; endl; } ~A() { cout &lt;&lt; "by" &lt;&lt; endl; } }; class B : public A { public: B() {} virtual ~B() { cout &lt;&lt; "from b" &lt;&lt; endl; } }; int main() { A * a = new B[5]; delete[] a; return 0; } </code></pre> <p>the results of this code is an infinite loop of "by" , why is this? B vtable supposed to be upcast to A that don't have vtable , so i would expected it to throw an exception when he try to reach the virtual constructor.</p> <p>p.s. where i can read on all kind of examples of wired constructor destructor behave? (with examples ) </p>
0debug
int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size) { const uint8_t *p = buf_in; const uint8_t *end = p + size; const uint8_t *nal_start, *nal_end; size = 0; nal_start = ff_avc_find_startcode(p, end); while (nal_start < end) { while(!*(nal_start++)); nal_end = ff_avc_find_startcode(nal_start, end); avio_wb32(pb, nal_end - nal_start); avio_write(pb, nal_start, nal_end - nal_start); size += 4 + nal_end - nal_start; nal_start = nal_end; } return size; }
1threat
Why this regex is not working? : Test URL: www-test1.examples.com The regex should match -test1 part and only if it is before the first dot and after the start of the expression. www can be any string. Following is m regex: ^(?= \w+)(-\w+)(?! \.) This is not matching the -test1 part. What am I missing in regex? Thanks in advance for the help.
0debug
Drop down button in flutter not switching values to the selected value : <p>I've recently started programming using dart and flutter and everything has been going smoothly for my app, although recently i wanted to add drop down menu to provide the user with multiple options to pick from. everything worked as planned however when i pick a value from the list it doesn't change the value in the box, it goes back to the hint or an empty box. any help would be appreciated!</p> <p>here is my code for the dropdownbutton:</p> <pre><code>Widget buildDropdownButton() { String newValue; return new Padding( padding: const EdgeInsets.all(24.0), child: new Column( mainAxisAlignment: MainAxisAlignment.start, children: &lt;Widget&gt;[ new ListTile( title: const Text('Frosting'), trailing: new DropdownButton&lt;String&gt;( hint: Text('Choose'), onChanged: (String changedValue) { newValue=changedValue; setState(() { newValue; print(newValue); }); }, value: newValue, items: &lt;String&gt;['None', 'Chocolate', 'Vanilla', 'ButterCream'] .map((String value) { return new DropdownMenuItem&lt;String&gt;( value: value, child: new Text(value), ); }).toList()), ), ], ), ); } </code></pre>
0debug
C++ Classname Function() : <p>I was recently giving an online quiz on c++ and a question came that had similar syntax as</p> <pre><code>class className { public: constructor() { print("ABC"); } } int main() { className ABC(); return 0; } </code></pre> <p>I thought it would not compile but rather it compiled and ran without having any effect, I am interested as to what feature this is and in which case do we use this?</p>
0debug
single object of socket io : I am trying to create an application based on socket. Looking at the console it can be said that the client to trying to socket server twice. which should not be allowed. 1. Is there any way to stop that ? 2. If have modular javascript file where multiple script want to access same socket connection how is that possible ? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html> <head> <title>socket</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://cdn.socket.io/socket.io-1.4.5.js"></script> </head> <body> <script type="text/javascript"> $(function(){ var socket = io(); console.log(typeof socket); // object var socket1 = io(); console.log(socket === socket1); // false }) </script> </body> </html> <!-- end snippet -->
0debug
Setup development architecture (best pratices) : <p>I’m searching for a method to build a development architecture. Only i dont know the best pratices. </p> <p><strong>Note</strong>: i'm working with the symfony framework</p> <p>Imagine you have multiple website, must all of these websites have their own database and cms. But when you need to change a column in the DB, you’ve to change it to all DBS. Or is it beter to have one central DB, where you could save data based on company_id.</p> <p>And what to do with code reusability. For example i’ve created a new feature for website 1, how could i make this feature reachable for all my other sites without updating all websites separately.</p> <p>I hoop you co-developers could help me out with above questions.</p>
0debug