problem
stringlengths
26
131k
labels
class label
2 classes
Trying to understand a Bash script given to me, specifically the while loop : <p>I am using a script made by one of my former colleagues, he told me I'll need some working with it. I am wondering what this while loop does:</p> <pre><code># This is the loop that does the simulation lastsim=0 nextsim=`/usr/bin/expr $lastsim + 1` while [ $nextsim -le $upperlimit ] do cp -i Dynamics_${lastsim}_500ps/*.prmtop ./$paramInput.prmtop </code></pre> <p>specifically I'm confused by thie -le syntax This is only part of the script I can upload the rest if necessary.</p>
0debug
Android: Error while installing APKs : <p>I'm slowly trying to do some simple tasks in <code>Android Studio</code>. The following app is installed on emulator without any errors. But when I tried to install it on a real device Redmi 3S this error occured:</p> <pre><code>Unknown failure (Failure - not installed for 0) Error while Installing APKs </code></pre> <p>I went through similar questions around here but in these cases the error was caused by not enabled debugging, or not accepitng the app instalation. However, I allowed debugging and I also tried to install <strong>some other app</strong> in Studio and it <strong>worked fine</strong>.</p> <p>So the question probably is, what's wrong with the code.</p> <blockquote> <p>MainActivity.java</p> </blockquote> <pre><code>package tlacitko.button; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void sendMessage(View view) { new Thread(new Runnable() { public void run() { runOnUiThread(new Runnable() { @Override public void run() { try{ URL url = new URL("http://147.32.186.51:8080"); // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String s = ""; }catch(MalformedURLException ex){ }catch(IOException e){ } } }); } }).start(); } } </code></pre> <p>And the xml code:</p> <blockquote> <p>activity_main.xml </p> </blockquote> <pre><code> &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Try to connect the server." app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /&gt; &lt;Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="7dp" android:layout_marginTop="16dp" android:onClick="sendMessage" android:text="Conncect" app:layout_constraintLeft_toRightOf="@+id/editText" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /&gt; &lt;/android.support.constraint.ConstraintLayout&gt; </code></pre>
0debug
static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file->bs, offset, count, flags); }
1threat
Core data complicated array : <p>I have this kind of array:</p> <pre><code>var vakken: [(String,[Int],[Int])] </code></pre> <p>but I don't know how i could put this in core data and pull it back?</p> <p>Has anyone advice how to make this or even some code?</p> <p>Thanks in advance</p>
0debug
Redirect after log in to index using php : <p>I want to make the system login. After user insert username and password, he/she is redirect to index.php But, i got a problem for the process script.</p> <pre><code>Notice: Undefined variable: conn in C:\xampp\htdocs\file\login.php on line 15 Fatal error: Call to a member function query() on null in C:\xampp\htdocs\file\login.php on line 15 </code></pre> <p>And here is the script:</p> <pre><code>&lt;?php include('connection.php'); session_start(); if ( ! empty($_SESSION['username'] ) ) { header('Location:index.html?'); exit; } if(isset($_POST["login"])) //FUNGSI LOGIN { $username = $_POST["username"]; $password = $_POST["password"]; $sql_login = "SELECT * FROM tbl_user WHERE username='$username' AND password='$password'"; $result_login = $conn-&gt;query($sql_login); $row_login = $result_login-&gt;fetch_assoc(); $numrow_login = $result_login-&gt;num_rows; if($numrow_login==1) { $_SESSION['username'] = $username; header('Location:index.html?'); exit; } } ?&gt; </code></pre>
0debug
Convert incoming bytestream into integers and export to excel Arduino/C : I am very new to programming and am working on an Arduino project to measure wavelengths of light. I am using the Spectruino 3 (http://myspectral.com/spectruino-installation.html) and am trying to read in the bytes that it records into an array, convert the array into an integer array and then export that data to excel. Currently I have this: const int numBytes = 501; int bytestream[numBytes]; void setup(){ Serial.begin(115200); } void loop() { for(int i=0; i<numBytes; i++){ bytestream[i]=Serial.read(); } } My spectrometer currently doesn't work, but this seems to compile. I was just wondering how to convert this bytestream array into an integer array and then export it into excel. Thanks!
0debug
CouchDb Which is the Best Performing approach to find data using Views or N1sql : i am building an php application using couchdb (mostly), but still not completely clear on the best approach for fetching contents, there are 2 different ways to get data (if i am correct) 1. Using View functions 2. Querying Data with N1QL That mean i can get same content using these 2 options.. For my developments purpose (n1sql) second option is more suitable. But still i am willing to rewrite my models to use more view function , if that approach works well (in terms good performance, less RAM and CPU usage, less maintenance costs, etc. ) Please share your thoughts about this Thanks in advance
0debug
pgAdmin 4 always open in browser not as a standalone desktop application : <p>installed PSQL10 but when pgAdmin is run from start then always open in browser.There is no option to run as a Desktop Application</p>
0debug
Python how to use the __str__ code for the __repr__? : <p>I've stated programming in Phyton just few days ago, so I'm sorry if the question is quite easy.</p> <p>I've written this code:</p> <pre><code>&gt;&gt;&gt; class Polynomial: def __init__(self, coeff): self.coeff=coeff def __repr_(self): return str(self) def __str__(self): s='' flag=0; for i in reversed(range(len(self.coeff))): if(i==0): s+= '+ %g ' % (self.coeff[i]) elif (flag==0): flag=1 s+= '%g z**%d' % (self.coeff[i],i) else: s+= '+ %g z**%d ' % (self.coeff[i],i) return s </code></pre> <p>but <code>__repr__</code> is not working:</p> <pre><code>&gt;&gt;&gt; p= Polynomial([1,2,3]) &gt;&gt;&gt; p &lt;__main__.Polynomial instance at 0x7fd3580ad518&gt; &gt;&gt;&gt; print p 3 z**2+ 2 z**1 + 1 </code></pre> <p>How can i use the code wrritten in <code>def __str__(self):</code> without re-writining it? I couldn't find the answer anywhere else. thanks.</p>
0debug
static int tta_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TTAContext *s = avctx->priv_data; int i; init_get_bits(&s->gb, buf, buf_size*8); { int cur_chan = 0, framelen = s->frame_length; int32_t *p; if (*data_size < (framelen * s->channels * 2)) { av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n"); return -1; } s->total_frames--; if (!s->total_frames && s->last_frame_length) framelen = s->last_frame_length; for (i = 0; i < s->channels; i++) { s->ch_ctx[i].predictor = 0; ttafilter_init(&s->ch_ctx[i].filter, ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]); rice_init(&s->ch_ctx[i].rice, 10, 10); } for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { int32_t *predictor = &s->ch_ctx[cur_chan].predictor; TTAFilter *filter = &s->ch_ctx[cur_chan].filter; TTARice *rice = &s->ch_ctx[cur_chan].rice; uint32_t unary, depth, k; int32_t value; unary = tta_get_unary(&s->gb); if (unary == 0) { depth = 0; k = rice->k0; } else { depth = 1; k = rice->k1; unary--; } if (get_bits_left(&s->gb) < k) return -1; if (k) { if (k > MIN_CACHE_BITS) return -1; value = (unary << k) + get_bits(&s->gb, k); } else value = unary; switch (depth) { case 1: rice->sum1 += value - (rice->sum1 >> 4); if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) rice->k1--; else if(rice->sum1 > shift_16[rice->k1 + 1]) rice->k1++; value += shift_1[rice->k0]; default: rice->sum0 += value - (rice->sum0 >> 4); if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) rice->k0--; else if(rice->sum0 > shift_16[rice->k0 + 1]) rice->k0++; } #define UNFOLD(x) (((x)&1) ? (++(x)>>1) : (-(x)>>1)) *p = UNFOLD(value); ttafilter_process(filter, p, 0); #define PRED(x, k) (int32_t)((((uint64_t)x << k) - x) >> k) switch (s->bps) { case 1: *p += PRED(*predictor, 4); break; case 2: case 3: *p += PRED(*predictor, 5); break; case 4: *p += *predictor; break; } *predictor = *p; if (cur_chan < (s->channels-1)) cur_chan++; else { if (s->channels > 1) { int32_t *r = p - 1; for (*p += *r / 2; r > p - s->channels; r--) *r = *(r + 1) - *r; } cur_chan = 0; } } if (get_bits_left(&s->gb) < 32) return -1; skip_bits(&s->gb, 32); switch(s->bps) { case 2: { uint16_t *samples = data; for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { *samples++ = *p; } *data_size = (uint8_t *)samples - (uint8_t *)data; break; } default: av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n"); } } return buf_size; }
1threat
How can I update a dataclass in place? : <p>Given two instances of the same dataclass, how can I update the first one in-place with values from the second one?</p> <p>i.e.</p> <pre class="lang-py prettyprint-override"><code>@dataclass class Foo: a: str b: int f1 = Foo("foo", 1) f2 = Foo("bar", 2) # Update in place, so that f1.a == f2.a, f1.b == f2.b and so on </code></pre> <p>Note: I do not want to simply set <code>f1 = f2</code>; I want to update <code>f1</code> in place.</p>
0debug
How to do an ElasticSearch Select Distinct : <p>I just want to do the following request with elasticsearch.</p> <p>In SQL :</p> <pre><code>Select distinct(id) from my_table where userid = '20' or activity = '9'; </code></pre> <p>I just have :</p> <pre><code>{ "query" : { "bool" : { "should" : [ { "term" : { "userid" : "20" } }, { "term" : { "activity" : "9" } } ] } } } </code></pre> <p>Thanks in advance :)</p>
0debug
NameError: name 'user_id' is not defined. For no apparent reason : <p><strong>Error description</strong></p> <p>I would fire up the server program, and fire a request (GET) at the path <code>/test_connection</code> which is the path used by the client to test the server IP address btw. The server would then respond by printing out the traceback below in the console, the one line in particular that I can't get my head around is <code>NameError: name 'user_id' is not defined</code> as the variable is not even included in the response function for the path <code>/test_connection</code> (<code>connection_test()</code>). I know the error is on the server side as it will print out 'INTERNAL SERVER ERROR: 500' on the client code, so I didn't feel the necessity to include the client code.</p> <p><strong>Additional info:</strong></p> <ul> <li>Python version: 3.7</li> <li>OS: Windows 10</li> <li>Server Library: Flask</li> </ul> <p><strong>Traceback from error:</strong></p> <pre><code> Traceback (most recent call last): File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 2309, in __call__ return self.wsgi_app(environ, start_response) File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\_compat.py", line 35, in reraise raise value File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\_compat.py", line 35, in reraise raise value File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\sccre\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "E:\USB Stick Files\Programming\Python\Chat Room Thingy\server.py", line 19, in connection_test message_dict[user_id] NameError: name 'user_id' is not defined </code></pre> <p><strong>Server code</strong></p> <pre><code>from flask import Flask, request from threading import Thread import json app = Flask(__name__) message_dict = {} ids = -1 @app.route('/test_connection') def connection_test(): global ids print('Connection tested from: {}'.format(request.remote_addr)) ids += 1 id_sent = str(ids) return '{}'.format(id_sent) @app.route('/new_message', methods=['POST']) def new_message(): global message_dict message_text = request.form['message'] user_id = request.form['id'] try: message_dict[user_id]['message'] = message_text except: message_dict[user_id] = None message_dict[user_id]['message'] = message_text return '0' @app.route('/chat') def chat(): return json.dumps(message_dict) if __name__ == '__main__': app.run(debug=True, host='0.0.0.0') </code></pre> <p>Any help with this would be greatly appreciated.</p> <p>Oscar.</p>
0debug
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unexpected start state' : <p>I've strange and rare to reproduce crash that happening on iOS 9. The question are <strong>How to fix this</strong> or <strong>What leads to this exception</strong> </p> <p>As you can see traces not contains my code and crash happens on app start. </p> <pre><code>Last Exception Backtrace: 0 CoreFoundation 0x0000000180a49900 __exceptionPreprocess + 124 1 libobjc.A.dylib 0x00000001800b7f80 objc_exception_throw + 52 2 CoreFoundation 0x0000000180a497d0 +[NSException raise:format:arguments:] + 104 3 Foundation 0x00000001813bca08 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 84 4 UIKit 0x00000001859f9f34 _prepareForCAFlush + 252 5 UIKit 0x00000001859ff4f0 _beforeCACommitHandler + 12 6 CoreFoundation 0x0000000180a00588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28 7 CoreFoundation 0x00000001809fe32c __CFRunLoopDoObservers + 368 8 CoreFoundation 0x00000001809fe75c __CFRunLoopRun + 924 9 CoreFoundation 0x000000018092d680 CFRunLoopRunSpecific + 380 10 GraphicsServices 0x0000000181e3c088 GSEventRunModal + 176 11 UIKit 0x00000001857a4d90 UIApplicationMain + 200 12 MyAppName 0x000000010009d200 main (main.m:14) 13 ??? 0x00000001804ce8b8 0x0 + 0 Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001805ec140 __pthread_kill + 8 1 libsystem_pthread.dylib 0x00000001806b4ef8 pthread_kill + 108 2 libsystem_c.dylib 0x000000018055ddac abort + 136 3 MyAppName 0x0000000100805bcc uncaught_exception_handler + 28 4 CoreFoundation 0x0000000180a49c88 __handleUncaughtException + 648 5 libobjc.A.dylib 0x00000001800b823c _objc_terminate() + 108 6 libc++abi.dylib 0x00000001800aaf44 std::__terminate(void (*)()) + 12 7 libc++abi.dylib 0x00000001800aab10 __cxa_rethrow + 140 8 libobjc.A.dylib 0x00000001800b8120 objc_exception_rethrow + 40 9 CoreFoundation 0x000000018092d728 CFRunLoopRunSpecific + 548 10 GraphicsServices 0x0000000181e3c088 GSEventRunModal + 176 11 UIKit 0x00000001857a4d90 UIApplicationMain + 200 12 MyAppName 0x000000010009d200 main (main.m:14) 13 ??? 0x00000001804ce8b8 0x0 + 0 </code></pre>
0debug
Does Gensim library support GPU acceleration? : <p>Using Word2vec and Doc2vec methods provided by Gensim, they have a distributed version which uses BLAS, ATLAS, etc to speedup (details <a href="http://rare-technologies.com/word2vec-in-python-part-two-optimizing/" rel="noreferrer">here</a>). However, is it supporting GPU mode? Is it possible to get GPU working if using Gensim?</p>
0debug
What is the difference between NumPy array and simple python array? : <p>Why do we use numpy arrays in place of simple arrays in python? What is the main difference between them?</p>
0debug
static av_cold int decode_init(AVCodecContext * avctx) { KmvcContext *const c = avctx->priv_data; int i; c->avctx = avctx; if (avctx->width > 320 || avctx->height > 200) { av_log(avctx, AV_LOG_ERROR, "KMVC supports frames <= 320x200\n"); return -1; } c->frm0 = av_mallocz(320 * 200); c->frm1 = av_mallocz(320 * 200); c->cur = c->frm0; c->prev = c->frm1; for (i = 0; i < 256; i++) { c->pal[i] = 0xFF << 24 | i * 0x10101; } if (avctx->extradata_size < 12) { av_log(avctx, AV_LOG_WARNING, "Extradata missing, decoding may not work properly...\n"); c->palsize = 127; } else { c->palsize = AV_RL16(avctx->extradata + 10); if (c->palsize >= (unsigned)MAX_PALSIZE) { c->palsize = 127; av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n"); return AVERROR_INVALIDDATA; } } if (avctx->extradata_size == 1036) { uint8_t *src = avctx->extradata + 12; for (i = 0; i < 256; i++) { c->pal[i] = AV_RL32(src); src += 4; } c->setpal = 1; } avcodec_get_frame_defaults(&c->pic); avctx->pix_fmt = AV_PIX_FMT_PAL8; return 0; }
1threat
Use route parameters with `app.use` on Express : <p>I cannot use route parameters with <code>app.use</code> on Express 4.16.2.</p> <p>I have a statement like this:</p> <pre><code>app.use('/course-sessions/:courseSessionId/chapter-sessions', chapterSessionsRouter) </code></pre> <p>And, in chapter sessions router:</p> <pre><code>// Index. router.get('/', ...resource.indexMethods) </code></pre> <p>When I got <code>'/course-sessions/0/chapter-sessions/'</code>, I have 404.</p> <p>Then I am trying a statement like this:</p> <pre><code>app.get('/course-sessions/:courseSessionId/chapter-sessions', ...chapterSessionResource.indexMethods) </code></pre> <p>Now I have the result I want. So route parameters don't work with <code>app.use</code>.</p> <p>While I am researching, I got <a href="https://github.com/expressjs/express/issues/696" rel="noreferrer">this GitHub issue</a> and <a href="https://github.com/expressjs/express/pull/1935" rel="noreferrer">this pull request</a> which closes the issue. But it seems that the issue is still around here. Or do I make something wrong?</p>
0debug
what are store, dispatch, payloads, types, actions, connect, thunk, reducers in react redux? : <p><strong>what are store, dispatch, payloads, types, actions, connect, thunk, reducers in react redux??</strong></p> <pre><code>import { createStore, applyMiddleware } from 'redux' import thunk from 'redux-thunk' const createStoreWithMiddleware = applyMiddleware(thunk)(createStore) const store = createStoreWithMiddleware(reducer) ReactDOM.render( &lt;MuiThemeProvider muiTheme={muiTheme}&gt; &lt;Provider store={store}&gt; &lt;Router history={ browserHistory }&gt; &lt;Route path="/" component={ Content }/&gt; &lt;Route path="/filter" component={ Filter }/&gt; &lt;Route path="/details" component={ Details }/&gt; &lt;/Router&gt; &lt;/Provider&gt; &lt;/MuiThemeProvider&gt;, document.getElementById('root') ) </code></pre>
0debug
PASSING DATA to PHP query using Ajax : how can I pass the input text data in HTML to a PHP function, without clicking the submit button? I already had the idea to use Ajax to fetch the data from the database, but I only wanted to query a specific row. [php function to fetch specific row][1] [html page that automatically fills the input text for contact and address whenever after input the name of the customer, instantaneously fetch the information of that name from the database][2] [1]: https://i.stack.imgur.com/WrFiM.png [2]: https://i.stack.imgur.com/x4h6w.png
0debug
how can i fill null value with S.T in postgersSQL? : Does anyone know how to fill null value in postgerSQL? For example, Null values are replaced with X column A B Null C D Null column A B x C D x
0debug
how can i read list of object of array : how can i read with ngfor unter lebens = [ { lebenslage: "Arbeit & Ruhestand", kata: [ { unter: "altervorsorge", unterunter: [ "Erbschein", "Zusätzliche Altersvorsorgeförderung", "Urkundenverwahrung und -registrierung" ] }, { unter: "Arbeitsplatzwechsel", unterunter: [ "Gesundheitszeugnis", "Zulassung für reglementierte Berufe", "Anerkennung akademischer Abschlüsse" ] } ] }, { lebenslage: "Bauen & Wohnen", kata: [ { unter: "Wohnen & Umzug", unterunter: [ "Abfallentsorgung", "Baumfällgenehmigung", "Rundfunkbeitrag" ] }, { unter: "Bauen & Immobilien", unterunter: [ "Abbruchgenehmigung", "Baulastenverzeichnis", "Denkmalförderung" ] } ] } ]
0debug
sqlalchemy postgresql enum does not create type on db migrate : <p>I develop a web-app using Flask under Python3. I have a problem with postgresql enum type on db migrate/upgrade.</p> <p>I added a column "status" to model:</p> <pre><code>class Banner(db.Model): ... status = db.Column(db.Enum('active', 'inactive', 'archive', name='banner_status')) ... </code></pre> <p>Generated migration by <code>python manage.py db migrate</code> is:</p> <pre><code>from alembic import op import sqlalchemy as sa def upgrade(): op.add_column('banner', sa.Column('status', sa.Enum('active', 'inactive', 'archive', name='banner_status'), nullable=True)) def downgrade(): op.drop_column('banner', 'status') </code></pre> <p>And when I do <code>python manage.py db upgrade</code> I get an error:</p> <pre><code>... sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type "banner_status" does not exist LINE 1: ALTER TABLE banner ADD COLUMN status banner_status [SQL: 'ALTER TABLE banner ADD COLUMN status banner_status'] </code></pre> <p><strong>Why migration does not create a type "banner_status"?</strong></p> <p><strong>What am I doing wrong?</strong></p> <pre><code>$ pip freeze alembic==0.8.6 Flask==0.10.1 Flask-Fixtures==0.3.3 Flask-Login==0.3.2 Flask-Migrate==1.8.0 Flask-Script==2.0.5 Flask-SQLAlchemy==2.1 itsdangerous==0.24 Jinja2==2.8 Mako==1.0.4 MarkupSafe==0.23 psycopg2==2.6.1 python-editor==1.0 requests==2.10.0 SQLAlchemy==1.0.13 Werkzeug==0.11.9 </code></pre>
0debug
how to show time performance for merge sort? : <p>show the time performance analysis for merge sort algorithm in c programming how to print merge sort algorithm the time performance (in ms) in c programming. Merge sort time complexity is (n log n) whether the condition in the worst case or best case. Someone can help me solve the problem. thanks, someone for solving my problem. </p> <pre><code>#include&lt;stdio.h&gt; #define MAX 50 void mergeSort(int arr[],int low,int mid,int high); void partition(int arr[],int low,int high); int main(){ int merge[MAX],i,n; printf("Enter the total number of elements: "); scanf("%d",&amp;n); printf("Enter the elements which to be sort: "); for(i=0;i&lt;n;i++){ scanf("%d",&amp;merge[i]); } partition(merge,0,n-1); printf("After merge sorting elements are: "); for(i=0;i&lt;n;i++){ printf("%d ",merge[i]); } return 0; } void partition(int arr[],int low,int high){ int mid; if(low&lt;high){ mid=(low+high)/2; partition(arr,low,mid); partition(arr,mid+1,high); mergeSort(arr,low,mid,high); } } void mergeSort(int arr[],int low,int mid,int high){ int i,m,k,l,temp[MAX]; l=low; i=low; m=mid+1; while((l&lt;=mid)&amp;&amp;(m&lt;=high)){ if(arr[l]&lt;=arr[m]){ temp[i]=arr[l]; l++; } else{ temp[i]=arr[m]; m++; } i++; } if(l&gt;mid){ for(k=m;k&lt;=high;k++){ temp[i]=arr[k]; i++; } } else{ for(k=l;k&lt;=mid;k++){ temp[i]=arr[k]; i++; } } for(k=low;k&lt;=high;k++){ arr[k]=temp[k]; } } </code></pre>
0debug
How do I write the data from Scapy into a CSV file : <p>Using Scapy I have extracted the ethernet frame length, IP payload size, and the header length I would like to write this information to a csv file for further examination </p> <pre><code>from scapy.all import * pcap = rdpcap('example.pcap') out = open("out.csv", "wb") for pkts in pcap: ethernet_header = (len(pkts)) # IP payload size ip_pload = (len(pkts.payload) - 20) # Ethernet frame length ip_header = (len(pkts.payload)) # Total length IP header print(ip_pload, len(pkts), ip_header) out.write(ethernet_header, ip_pload, ip_header) </code></pre>
0debug
uint64_t helper_mulqv(CPUAlphaState *env, uint64_t op1, uint64_t op2) { uint64_t tl, th; muls64(&tl, &th, op1, op2); if (unlikely((th + 1) > 1)) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return tl; }
1threat
File extension naming: .p vs .pkl vs .pickle : <p>When reading and writing pickle files, I've noticed that some snippets use <code>.p</code> others <code>.pkl</code> and some the full <code>.pickle</code>. Is there one most pythonic way of doing this?</p> <p>My current view is that there is no one right answer, and that any of these will suffice. In fact, writing a filename of <code>awesome.pkl</code> or <code>awesome.sauce</code> won't make a difference when running <code>pickle.load(open(filename, "rb"))</code>. This is to say, the file extension is just a convention which doesn't actually affect the underlying data. Is that right?</p> <p>Bonus: What if I saved a PNG image as <code>myimage.jpg</code>? What havoc would that create?</p>
0debug
static int lzw_get_code(struct LZWState * s) { int c; if(s->mode == FF_LZW_GIF) { while (s->bbits < s->cursize) { if (!s->bs) { s->bs = *s->pbuf++; if(!s->bs) { s->eob_reached = 1; break; } } s->bbuf |= (*s->pbuf++) << s->bbits; s->bbits += 8; s->bs--; } c = s->bbuf & s->curmask; s->bbuf >>= s->cursize; } else { while (s->bbits < s->cursize) { if (s->pbuf >= s->ebuf) { s->eob_reached = 1; } s->bbuf = (s->bbuf << 8) | (*s->pbuf++); s->bbits += 8; } c = (s->bbuf >> (s->bbits - s->cursize)) & s->curmask; } s->bbits -= s->cursize; return c; }
1threat
How to run a sql query in C# and asp.net and show the result in csv file locally : <p>I don't have permission to create files on the server so, I cannot write to file and then show it to user. I am trying to redirect the query result to a file which user can open/save locally in their computers.</p>
0debug
av_cold void ff_dct_init_mmx(DCTContext *s) { #if HAVE_YASM int has_vectors = av_get_cpu_flags(); if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) s->dct32 = ff_dct32_float_sse; if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE) s->dct32 = ff_dct32_float_sse2; if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX) s->dct32 = ff_dct32_float_avx; #endif }
1threat
static void test_ide_drive_user(const char *dev, bool trans) { char *argv[256], *opts; int argc; int secs = img_secs[backend_small]; const CHST expected_chst = { secs / (4 * 32) , 4, 32, trans }; argc = setup_common(argv, ARRAY_SIZE(argv)); opts = g_strdup_printf("%s,%s%scyls=%d,heads=%d,secs=%d", dev ?: "", trans && dev ? "bios-chs-" : "", trans ? "trans=lba," : "", expected_chst.cyls, expected_chst.heads, expected_chst.secs); cur_ide[0] = &expected_chst; argc = setup_ide(argc, argv, ARRAY_SIZE(argv), 0, dev ? opts : NULL, backend_small, mbr_chs, dev ? "" : opts); g_free(opts); qtest_start(g_strjoinv(" ", argv)); test_cmos(); qtest_end(); }
1threat
No suitable driver found for jdbc:oracle:thin:@localhost:1522:xe : <p>I am trying to create a connection to my database(oracle), when I put test my code using the main method, it works seamlessly. However, when trying to access it through Tomcat 8, it fails with error: No suitable driver found for "jdbc:oracle:thin:@localhost:1522:xe" I have added ojdbc6 jar file to lib and also configured the built path. The url,use, password is correct still it give the above error. when i paste the same code in main it runs but in tomcat it doesn't.</p>
0debug
Why is parameter not a constant expression? : <p>Could you please explain why this code doesn't compile?</p> <pre><code>// source.cpp constexpr const char* func(const char* s) { return s;} constexpr bool find(const char *param) { constexpr const char* result = func(param); return (param == 0); } int main() { constexpr bool result = find("abcde"); } </code></pre> <p>The compile command:</p> <pre><code>$ g++ -std=c++14 source.cpp </code></pre> <p>I've tried gcc5.4 and gcc6.4. The error:</p> <pre><code>source.cpp: In function ‘constexpr bool find(const char*)’: source.cpp:5:46: error: ‘param’ is not a constant expression constexpr const char* result = func(param); ^ </code></pre>
0debug
Checking GPS Status in android permanently : <p>I have an android application ,I want to show GPS status permanently in my application , I used timer before to check GPS status every 3 seconds , it works correct,But I don't want to use timer now. I just want when GPS turned on , my application notify and when GPS terned off that notifiy.</p>
0debug
def count_Unset_Bits(n) : cnt = 0; for i in range(1,n + 1) : temp = i; while (temp) : if (temp % 2 == 0) : cnt += 1; temp = temp // 2; return cnt;
0debug
can i get a solution for this error please? : File "<ipython-input-15-155e515d797c>", line 3 DOWNLOAD_BASE = 'file:H:\New_folder\models\research\object_detection' ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 7-8: malformed \N character escape
0debug
static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; int tag, len; get_be32(pb); len = mp4_read_descr(c, pb, &tag); if (tag == MP4ESDescrTag) { get_be16(pb); get_byte(pb); } else get_be16(pb); len = mp4_read_descr(c, pb, &tag); if (tag == MP4DecConfigDescrTag) { int object_type_id = get_byte(pb); get_byte(pb); get_be24(pb); get_be32(pb); get_be32(pb); st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); dprintf(c->fc, "esds object type id %d\n", object_type_id); len = mp4_read_descr(c, pb, &tag); if (tag == MP4DecSpecificDescrTag) { dprintf(c->fc, "Specific MPEG4 header len=%d\n", len); if((uint64_t)len > (1<<30)) return -1; st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); get_buffer(pb, st->codec->extradata, len); st->codec->extradata_size = len; if (st->codec->codec_id == CODEC_ID_AAC) { MPEG4AudioConfig cfg; ff_mpeg4audio_get_config(&cfg, st->codec->extradata, st->codec->extradata_size); if (cfg.chan_config > 7) return -1; st->codec->channels = ff_mpeg4audio_channels[cfg.chan_config]; if (cfg.object_type == 29 && cfg.sampling_index < 3) st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index]; else st->codec->sample_rate = cfg.sample_rate; dprintf(c->fc, "mp4a config channels %d obj %d ext obj %d " "sample rate %d ext sample rate %d\n", st->codec->channels, cfg.object_type, cfg.ext_object_type, cfg.sample_rate, cfg.ext_sample_rate); if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types, cfg.object_type))) st->codec->codec_id = CODEC_ID_AAC; } } } return 0; }
1threat
Programming Homework: Robot Genetic Algorithm : <p>This program is built to run 10000 generations of 200 robots, allowing evolution to shape the digits in the robot's "DNA". The problem I'm having is that, even though there is nothing but numbers going into the 'robotGenes' array, the resulting DNA that prints is a random collection of letters, numbers and symbols. I have absolutly no idea why. I have tried switching up where I declare and assign my variables, unfortunatly its all been in vane. Plz halp. </p> <p>P.s. I'm posting the entire program code here, as I am unsure what is causing the problem, though I am positive that I am simply being daft. Any help is greatly appreciated.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;stdlib.h&gt; #include &lt;cmath&gt; using namespace std; int randBattery = 0, randRobot = 0, randDirect = 0, board[144] = { }, testDirect = 0, randTurn = 0, randTurnDirect = 0, genAdd = 0, masterFit = 0, abc = 0; double fitness[10000] = { }, winners[5] = { }; std::string startCond; unsigned char robotGenes[200][12] = { }, test[12] = { }; class Display { public: int results() { cout &lt;&lt; "\n\n\n-Evolution Winning Avg. Fitness Ratings-\n\n"; cout &lt;&lt; "1. " &lt;&lt; winners[1]; cout &lt;&lt; "\n DNA: "; for (int G = 1; G &lt;= 12; G++) { cout &lt;&lt; robotGenes[1][G]; } cout &lt;&lt; "\n\n2. " &lt;&lt; winners[2]; cout &lt;&lt; "\n DNA: "; for (int G = 1; G &lt;= 12; G++) { cout &lt;&lt; robotGenes[41][G]; } cout &lt;&lt; "\n\n3. " &lt;&lt; winners[3]; cout &lt;&lt; "\n DNA: "; for (int G = 1; G &lt;= 12; G++) { cout &lt;&lt; robotGenes[81][G]; } cout &lt;&lt; "\n\n4. " &lt;&lt; winners[4]; cout &lt;&lt; "\n DNA: "; for (int G = 1; G &lt;= 12; G++) { cout &lt;&lt; robotGenes[121][G]; } cout &lt;&lt; "\n\n5. " &lt;&lt; winners[5]; cout &lt;&lt; "\n DNA: "; for (int G = 1; G &lt;= 12; G++) { cout &lt;&lt; robotGenes[161][G]; } return 0; }; }; class RobotSex { public: int bang() { int newGen, newGen2, B; newGen = 101; newGen2 = 102; B = 2; for (int C = 1; C &lt;= 100; C += 2) { robotGenes[newGen][6] = robotGenes[C][6]; robotGenes[newGen][7] = robotGenes[C][7]; robotGenes[newGen][8] = robotGenes[C][8]; robotGenes[newGen][9] = robotGenes[C][9]; robotGenes[newGen][10] = robotGenes[B][10]; robotGenes[newGen][11] = robotGenes[B][11]; robotGenes[newGen2][6] = robotGenes[B][6]; robotGenes[newGen2][7] = robotGenes[B][7]; robotGenes[newGen2][8] = robotGenes[B][8]; robotGenes[newGen2][9] = robotGenes[B][9]; robotGenes[newGen2][10] = robotGenes[C][10]; robotGenes[newGen2][11] = robotGenes[C][11]; newGen += 2; newGen2 += 2; B += 2; } }; }; class Genocide { public: int ethnicCleansing() { for (int x = 101; x &lt;= 200; x++) { for (int y = 6; y &lt;= 12; y++) { robotGenes[x][y] = 0; } } }; }; class Sorting { public: int sortPower() { for (int P = 0; P &lt;= 200; P++) { for (int x = 1; x &lt;= 200; x++) { int y; y = x + 1; if (robotGenes[x][12] &lt; robotGenes[y][12]) for (int Q = 1; Q &lt;= 12; Q++) swap (robotGenes[x][Q], robotGenes[y][Q]); } } }; int addGenFit() { for (int o = 1; o &lt;= 200; o++) { genAdd += robotGenes[o][12]; } fitness[masterFit] = genAdd / 200; ::masterFit += 1; }; int sortGenFit() { for (int P = 0; P &lt;= 10000; P++) { for (int x = 1; x &lt;= 9999; x++) { int y; y = x + 1; if (fitness[x] &lt; fitness[y]) swap (fitness[x], fitness[y]); } } for (int o = 1; o &lt;= 2000; o++) { genAdd += fitness[o]; } winners[1] = genAdd / 2000; for (int o = 2001; o &lt;= 4000; o++) { genAdd += fitness[o]; } winners[2] = genAdd / 2000; for (int o = 4001; o &lt;= 6000; o++) { genAdd += fitness[o]; } winners[3] = genAdd / 2000; for (int o = 6001; o &lt;= 8000; o++) { genAdd += fitness[o]; } winners[4] = genAdd / 2000; for (int o = 8001; o &lt;= 10000; o++) { genAdd += fitness[o]; } winners[5] = genAdd / 2000; }; }; class Establishing { public: int clearBoard() { for (int c = 0; c &lt;= 144; c++) //Clearing board { board[c] = 0; } for (int x = 0; x &lt;= 12; x++) //Establishing walls { board[x] = 9; } for (int x = 132; x &lt;= 144; x++) { board[x] = 9; } for (int x = 13; x &lt;= 121; x += 12) { board[x] = 9; } for (int x = 24; x &lt;= 132; x += 12) { board[x] = 9; } }; }; class Randomizer { public: int randBattery() { for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R1 ::randBattery = (rand() % 14+23); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R2 ::randBattery = (rand() % 26+35); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R3 ::randBattery = (rand() % 38+47); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R4 ::randBattery = (rand() % 50+59); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R5 ::randBattery = (rand() % 62+71); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R6 ::randBattery = (rand() % 74+82); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R7 ::randBattery = (rand() % 85+95); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R8 ::randBattery = (rand() % 98+107); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R9 ::randBattery = (rand() % 110+119); board[::randBattery] = 1; } for (int t = 1; t &lt;= 4; t++) { srand(time(NULL)); //Random battery placement R10 ::randBattery = (rand() % 122+131); board[::randBattery] = 1; } }; int randPlacement() { for (int t = 1; t &lt;= 200; t++) { srand(time(NULL)); //Random robot placement &amp; resets power level randRobot = (rand() % 62+71); robotGenes[t][1] = randRobot; robotGenes[t][12] = 5; } }; char randDirect() { for (int d = 1; d &lt;= 200; d++) { srand(time(NULL)); //Random robot direction ::randDirect = (rand() % 62+71); robotGenes[d][5] = ::randDirect; } }; }; class Reader { public: int readDNA() { do { if (board[test[1]] == 1) //Pickup battery test[12] += 5; if (test[9] == 1) //Check for wall { if (board[test[2]] == 9) { if (test[5] == 1) test[5] = 4; if (test[5] == 2) test[5] = 1; if (test[5] == 3) test[5] = 2; if (test[5] == 4) test[5] = 3; } if (board[test[2]] == 9 &amp;&amp; board[test[3]] == 9) { if (test[5] == 1) test[5] = 2; if (test[5] == 2) test[5] = 3; if (test[5] == 3) test[5] = 4; if (test[5] == 4) test[5] = 1; } } if (test[7] == test[6]) //Changing direction after # of moves if (test[6] % 2 == 0) //Turning left { if (test[5] == 1) test[5] = 4; if (test[5] == 2) test[5] = 1; if (test[5] == 3) test[5] = 2; if (test[5] == 4) test[5] = 3; } else //Turning right { if (test[5] == 1) test[5] = 2; if (test[5] == 2) test[5] = 3; if (test[5] == 3) test[5] = 4; if (test[5] == 4) test[5] = 1; } if (test[10] == 1) //Left sensor checking for battery, TURN LEFT if (test[5] == 1) test[5] = 4; if (test[5] == 2) test[5] = 1; if (test[5] == 3) test[5] = 2; if (test[5] == 4) test[5] = 3; if (test[11] == 1) //Right sensor checking for battery, TURN RIGHT if (test[5] == 1) test[5] = 2; if (test[5] == 2) test[5] = 3; if (test[5] == 3) test[5] = 4; if (test[5] == 4) test[5] = 1; if (test[5] == 1) //Face north { test[2] = test[1] + 12; ::test[3] = test[1] - 1; test[4] = test[1] + 1; test[1] += 12; //Move north test[2] += 12; ::test[3] += 12; test[4] += 12; } if (test[5] == 2) //Face east { test[2] = test[1] + 1; ::test[3] = test[1] + 12; test[4] = test[1] - 12; test[1] += 1; //Move east test[2] += 1; ::test[3] += 1; test[4] += 1; } if (test[5] == 3) //Face south { test[2] = test[1] - 12; ::test[3] = test[1] + 1; test[4] = test[1] - 1; test[1] -= 12; //Move south test[2] -= 12; ::test[3] -= 12; test[4] -= 12; } if (test[5] == 4) //Face west { test[2] = test[1] - 1; ::test[3] = test[1] - 12; test[4] = test[1] + 12; test[1] -= 1; //Move west test[2] -= 1; ::test[3] -= 1; test[4] -= 1; } test[7] += 1; test[12] -= 1; } while (test[12] &gt; 1 &amp;&amp; test[7] &lt; 24); }; }; class Running { public: void runRobot() { for (int q = 1; q &lt;= 200; q++) { for (int z = 1; z &lt;= 12; z++) { ::test[z] = robotGenes[q][z]; } Reader objectDNA; objectDNA.readDNA(); for (int z = 1; z &lt;= 12; z++) { ::robotGenes[q][z] = test[z]; } } }; }; int main() { //System Greeting cout &lt;&lt; "Enter anything to start simulation.\n\n"; cin &gt;&gt; startCond; masterFit = 1; //Setting starting genes for (int t = 1; t &lt;= 200; t++) { srand(time(NULL)); randTurn = (rand() % 10+1); robotGenes[t][6] = randTurn; } for (int o = 1; o &lt;= 40; o++) { robotGenes[o][8] = 1; robotGenes[o][9] = 0; robotGenes[o][10] = 0; robotGenes[o][11] = 0; } for (int o = 41; o &lt;= 80; o++) { robotGenes[o][8] = 0; robotGenes[o][9] = 1; robotGenes[o][10] = 1; robotGenes[o][11] = 1; } for (int o = 81; o &lt;= 120; o++) { robotGenes[o][8] = 1; robotGenes[o][9] = 1; robotGenes[o][10] = 0; robotGenes[o][11] = 0; } for (int o = 121; o &lt;= 160; o++) { robotGenes[o][8] = 0; robotGenes[o][9] = 0; robotGenes[o][10] = 0; robotGenes[o][11] = 0; } for (int o = 161; o &lt;= 200; o++) { robotGenes[o][8] = 1; robotGenes[o][9] = 0; robotGenes[o][10] = 1; robotGenes[o][11] = 1; } //Running sims (not the game) Randomizer objectRaDirect; objectRaDirect.randDirect(); Randomizer objectRaPlace; objectRaPlace.randPlacement(); for (int sims = 1; sims &lt;= 10000; sims++) { Establishing objectClear; objectClear.clearBoard(); Randomizer objectRaBattery; objectRaBattery.randBattery(); Running objectRun; objectRun.runRobot(); abc += 1; cout &lt;&lt; "\n\nGeneration " &lt;&lt; abc &lt;&lt; " is complete.\n"; Sorting objectPower; objectPower.sortPower(); Sorting objectGenFit; objectGenFit.addGenFit(); Genocide objectHitler; objectHitler.ethnicCleansing(); RobotSex objectSex; objectSex.bang(); } Sorting objectWin; objectWin.sortGenFit(); for (int B = 1; B &lt;= 5; B++) { winners[B] = abs (winners[B]); } Display objectEnd; objectEnd.results(); }; </code></pre>
0debug
VBA code to count columns : how do i select the last column from second row and move the cursor one cell above. For eg. if I am at cell A2, how do I make macro to count the number of columns starting from Row 2 and select the cell above it.
0debug
static void aio_epoll_disable(AioContext *ctx) { ctx->epoll_available = false; if (!ctx->epoll_enabled) { return; } ctx->epoll_enabled = false; close(ctx->epollfd); }
1threat
1067: Implicit coercion of a value of type congrate to an unrelated type flash.display:DisplayObject : in one input text field has two possible answer which is luah or hal. why it is not working at all.someone please help me the right way to write a code?? stop(); //var jawapan1=Array; txt_zuhal.addEventListener(KeyboardEvent.KEY_DOWN,handler); function handler(event:KeyboardEvent) { //jawapan1=("luah", "hal"); // if the key is ENTER if(event.charCode == 13) { if(txt_zuhal.text=='luah'||'hal') { trace("1.correct"); } else { trace("1.Sorry, Wrong answer"); } } }
0debug
static void user_monitor_complete(void *opaque, QObject *ret_data) { MonitorCompletionData *data = (MonitorCompletionData *)opaque; if (ret_data) { data->user_print(data->mon, ret_data); } monitor_resume(data->mon); g_free(data); }
1threat
how to use phpexcel in yii2 : <p>I have a excel file with the extension .xlsx. I need to read this file and save into database. how to do this. I have no idea about this. plese guide me how to do step by step. Im using yii2 basic version.</p>
0debug
void qmp_blockdev_mirror(const char *device, const char *target, bool has_replaces, const char *replaces, MirrorSyncMode sync, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, Error **errp) { BlockDriverState *bs; BlockBackend *blk; BlockDriverState *target_bs; AioContext *aio_context; BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN; Error *local_err = NULL; blk = blk_by_name(device); if (!blk) { error_setg(errp, "Device '%s' not found", device); return; } bs = blk_bs(blk); if (!bs) { error_setg(errp, "Device '%s' has no media", device); return; } target_bs = bdrv_lookup_bs(target, target, errp); if (!target_bs) { return; } aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); bdrv_set_aio_context(target_bs, aio_context); blockdev_mirror_common(bs, target_bs, has_replaces, replaces, sync, backing_mode, has_speed, speed, has_granularity, granularity, has_buf_size, buf_size, has_on_source_error, on_source_error, has_on_target_error, on_target_error, true, true, &local_err); if (local_err) { error_propagate(errp, local_err); } aio_context_release(aio_context); }
1threat
static void network_to_compress(RDMACompress *comp) { comp->value = ntohl(comp->value); comp->block_idx = ntohl(comp->block_idx); comp->offset = ntohll(comp->offset); comp->length = ntohll(comp->length); }
1threat
int tcp_socket_incoming(const char *address, uint16_t port) { char address_and_port[128]; Error *local_err = NULL; combine_addr(address_and_port, 128, address, port); int fd = inet_listen(address_and_port, NULL, 0, SOCK_STREAM, 0, &local_err); if (local_err != NULL) { qerror_report_err(local_err); error_free(local_err); } return fd; }
1threat
static int aasc_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AascContext *s = avctx->priv_data; int compr, i, stride, psize; s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; compr = AV_RL32(buf); buf += 4; buf_size -= 4; psize = avctx->bits_per_coded_sample / 8; switch (avctx->codec_tag) { case MKTAG('A', 'A', 'S', '4'): bytestream2_init(&s->gb, buf - 4, buf_size + 4); ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb); break; case MKTAG('A', 'A', 'S', 'C'): switch(compr){ case 0: stride = (avctx->width * psize + psize) & ~psize; for(i = avctx->height - 1; i >= 0; i--){ if(avctx->width * psize > buf_size){ av_log(avctx, AV_LOG_ERROR, "Next line is beyond buffer bounds\n"); break; memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width * psize); buf += stride; buf_size -= stride; break; case 1: bytestream2_init(&s->gb, buf, buf_size); ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr); return -1; break; default: av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag); return -1; if (avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(s->frame.data[1], s->palette, s->palette_size); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size;
1threat
static void decode_opc (CPUState *env, DisasContext *ctx) { int32_t offset; int rs, rt, rd, sa; uint32_t op, op1, op2; int16_t imm; if (ctx->pc & 0x3) { env->CP0_BadVAddr = ctx->pc; generate_exception(ctx, EXCP_AdEL); return; } if ((ctx->hflags & MIPS_HFLAG_BMASK) == MIPS_HFLAG_BL) { int l1; MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4); l1 = gen_new_label(); gen_op_jnz_T2(l1); gen_op_save_state(ctx->hflags & ~MIPS_HFLAG_BMASK); gen_goto_tb(ctx, 1, ctx->pc + 4); gen_set_label(l1); } op = MASK_OP_MAJOR(ctx->opcode); rs = (ctx->opcode >> 21) & 0x1f; rt = (ctx->opcode >> 16) & 0x1f; rd = (ctx->opcode >> 11) & 0x1f; sa = (ctx->opcode >> 6) & 0x1f; imm = (int16_t)ctx->opcode; switch (op) { case OPC_SPECIAL: op1 = MASK_SPECIAL(ctx->opcode); switch (op1) { case OPC_SLL: case OPC_SRL ... OPC_SRA: gen_arith_imm(env, ctx, op1, rd, rt, sa); break; case OPC_MOVZ ... OPC_MOVN: check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); case OPC_SLLV: case OPC_SRLV ... OPC_SRAV: case OPC_ADD ... OPC_NOR: case OPC_SLT ... OPC_SLTU: gen_arith(env, ctx, op1, rd, rs, rt); break; case OPC_MULT ... OPC_DIVU: gen_muldiv(ctx, op1, rs, rt); break; case OPC_JR ... OPC_JALR: gen_compute_branch(ctx, op1, rs, rd, sa); return; case OPC_TGE ... OPC_TEQ: case OPC_TNE: gen_trap(ctx, op1, rs, rt, -1); break; case OPC_MFHI: case OPC_MFLO: gen_HILO(ctx, op1, rd); break; case OPC_MTHI: case OPC_MTLO: gen_HILO(ctx, op1, rs); break; case OPC_PMON: #ifdef MIPS_STRICT_STANDARD MIPS_INVAL("PMON / selsl"); generate_exception(ctx, EXCP_RI); #else gen_op_pmon(sa); #endif break; case OPC_SYSCALL: generate_exception(ctx, EXCP_SYSCALL); break; case OPC_BREAK: generate_exception(ctx, EXCP_BREAK); break; case OPC_SPIM: #ifdef MIPS_STRICT_STANDARD MIPS_INVAL("SPIM"); generate_exception(ctx, EXCP_RI); #else MIPS_INVAL("spim (unofficial)"); generate_exception(ctx, EXCP_RI); #endif break; case OPC_SYNC: break; case OPC_MOVCI: check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); if (env->CP0_Config1 & (1 << CP0C1_FP)) { save_cpu_state(ctx, 1); check_cp1_enabled(ctx); gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7, (ctx->opcode >> 16) & 1); } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) case OPC_DSLL: case OPC_DSRL ... OPC_DSRA: case OPC_DSLL32: case OPC_DSRL32 ... OPC_DSRA32: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_arith_imm(env, ctx, op1, rd, rt, sa); break; case OPC_DSLLV: case OPC_DSRLV ... OPC_DSRAV: case OPC_DADD ... OPC_DSUBU: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_arith(env, ctx, op1, rd, rs, rt); break; case OPC_DMULT ... OPC_DDIVU: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_muldiv(ctx, op1, rs, rt); break; #endif default: MIPS_INVAL("special"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SPECIAL2: op1 = MASK_SPECIAL2(ctx->opcode); switch (op1) { case OPC_MADD ... OPC_MADDU: case OPC_MSUB ... OPC_MSUBU: check_insn(env, ctx, ISA_MIPS32); gen_muldiv(ctx, op1, rs, rt); break; case OPC_MUL: gen_arith(env, ctx, op1, rd, rs, rt); break; case OPC_CLZ ... OPC_CLO: check_insn(env, ctx, ISA_MIPS32); gen_cl(ctx, op1, rd, rs); break; case OPC_SDBBP: check_insn(env, ctx, ISA_MIPS32); if (!(ctx->hflags & MIPS_HFLAG_DM)) { generate_exception(ctx, EXCP_DBp); } else { generate_exception(ctx, EXCP_DBp); } break; #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) case OPC_DCLZ ... OPC_DCLO: check_insn(env, ctx, ISA_MIPS64); check_mips_64(ctx); gen_cl(ctx, op1, rd, rs); break; #endif default: MIPS_INVAL("special2"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SPECIAL3: op1 = MASK_SPECIAL3(ctx->opcode); switch (op1) { case OPC_EXT: case OPC_INS: check_insn(env, ctx, ISA_MIPS32R2); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_BSHFL: check_insn(env, ctx, ISA_MIPS32R2); op2 = MASK_BSHFL(ctx->opcode); switch (op2) { case OPC_WSBH: GEN_LOAD_REG_TN(T1, rt); gen_op_wsbh(); break; case OPC_SEB: GEN_LOAD_REG_TN(T1, rt); gen_op_seb(); break; case OPC_SEH: GEN_LOAD_REG_TN(T1, rt); gen_op_seh(); break; default: MIPS_INVAL("bshfl"); generate_exception(ctx, EXCP_RI); break; } GEN_STORE_TN_REG(rd, T0); break; case OPC_RDHWR: check_insn(env, ctx, ISA_MIPS32R2); switch (rd) { case 0: save_cpu_state(ctx, 1); gen_op_rdhwr_cpunum(); break; case 1: save_cpu_state(ctx, 1); gen_op_rdhwr_synci_step(); break; case 2: save_cpu_state(ctx, 1); gen_op_rdhwr_cc(); break; case 3: save_cpu_state(ctx, 1); gen_op_rdhwr_ccres(); break; case 29: #if defined (CONFIG_USER_ONLY) gen_op_tls_value(); break; #endif default: MIPS_INVAL("rdhwr"); generate_exception(ctx, EXCP_RI); break; } GEN_STORE_TN_REG(rt, T0); break; case OPC_FORK: check_mips_mt(env, ctx); GEN_LOAD_REG_TN(T0, rt); GEN_LOAD_REG_TN(T1, rs); gen_op_fork(); break; case OPC_YIELD: check_mips_mt(env, ctx); GEN_LOAD_REG_TN(T0, rs); gen_op_yield(); GEN_STORE_TN_REG(rd, T0); break; #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS: check_insn(env, ctx, ISA_MIPS64R2); check_mips_64(ctx); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_DBSHFL: check_insn(env, ctx, ISA_MIPS64R2); check_mips_64(ctx); op2 = MASK_DBSHFL(ctx->opcode); switch (op2) { case OPC_DSBH: GEN_LOAD_REG_TN(T1, rt); gen_op_dsbh(); break; case OPC_DSHD: GEN_LOAD_REG_TN(T1, rt); gen_op_dshd(); break; default: MIPS_INVAL("dbshfl"); generate_exception(ctx, EXCP_RI); break; } GEN_STORE_TN_REG(rd, T0); #endif default: MIPS_INVAL("special3"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_REGIMM: op1 = MASK_REGIMM(ctx->opcode); switch (op1) { case OPC_BLTZ ... OPC_BGEZL: case OPC_BLTZAL ... OPC_BGEZALL: gen_compute_branch(ctx, op1, rs, -1, imm << 2); return; case OPC_TGEI ... OPC_TEQI: case OPC_TNEI: gen_trap(ctx, op1, rs, -1, imm); break; case OPC_SYNCI: check_insn(env, ctx, ISA_MIPS32R2); break; default: MIPS_INVAL("regimm"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_CP0: check_cp0_enabled(ctx); op1 = MASK_CP0(ctx->opcode); switch (op1) { case OPC_MFC0: case OPC_MTC0: case OPC_MFTR: case OPC_MTTR: #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) case OPC_DMFC0: case OPC_DMTC0: #endif gen_cp0(env, ctx, op1, rt, rd); break; case OPC_C0_FIRST ... OPC_C0_LAST: gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd); break; case OPC_MFMC0: op2 = MASK_MFMC0(ctx->opcode); switch (op2) { case OPC_DMT: check_mips_mt(env, ctx); gen_op_dmt(); break; case OPC_EMT: check_mips_mt(env, ctx); gen_op_emt(); break; case OPC_DVPE: check_mips_mt(env, ctx); gen_op_dvpe(); break; case OPC_EVPE: check_mips_mt(env, ctx); gen_op_evpe(); break; case OPC_DI: check_insn(env, ctx, ISA_MIPS32R2); save_cpu_state(ctx, 1); gen_op_di(); ctx->bstate = BS_STOP; break; case OPC_EI: check_insn(env, ctx, ISA_MIPS32R2); save_cpu_state(ctx, 1); gen_op_ei(); ctx->bstate = BS_STOP; break; default: MIPS_INVAL("mfmc0"); generate_exception(ctx, EXCP_RI); break; } GEN_STORE_TN_REG(rt, T0); break; case OPC_RDPGPR: check_insn(env, ctx, ISA_MIPS32R2); GEN_LOAD_SRSREG_TN(T0, rt); GEN_STORE_TN_REG(rd, T0); break; case OPC_WRPGPR: check_insn(env, ctx, ISA_MIPS32R2); GEN_LOAD_REG_TN(T0, rt); GEN_STORE_TN_SRSREG(rd, T0); break; default: MIPS_INVAL("cp0"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_ADDI ... OPC_LUI: gen_arith_imm(env, ctx, op, rt, rs, imm); break; case OPC_J ... OPC_JAL: offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; gen_compute_branch(ctx, op, rs, rt, offset); return; case OPC_BEQ ... OPC_BGTZ: case OPC_BEQL ... OPC_BGTZL: gen_compute_branch(ctx, op, rs, rt, imm << 2); return; case OPC_LB ... OPC_LWR: case OPC_SB ... OPC_SW: case OPC_SWR: case OPC_LL: case OPC_SC: gen_ldst(ctx, op, rt, rs, imm); break; case OPC_CACHE: check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); break; case OPC_PREF: check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); break; case OPC_LWC1: case OPC_LDC1: case OPC_SWC1: case OPC_SDC1: if (env->CP0_Config1 & (1 << CP0C1_FP)) { save_cpu_state(ctx, 1); check_cp1_enabled(ctx); gen_flt_ldst(ctx, op, rt, rs, imm); } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; case OPC_CP1: if (env->CP0_Config1 & (1 << CP0C1_FP)) { save_cpu_state(ctx, 1); check_cp1_enabled(ctx); op1 = MASK_CP1(ctx->opcode); switch (op1) { case OPC_MFHC1: case OPC_MTHC1: check_insn(env, ctx, ISA_MIPS32R2); case OPC_MFC1: case OPC_CFC1: case OPC_MTC1: case OPC_CTC1: gen_cp1(ctx, op1, rt, rd); break; #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) case OPC_DMFC1: case OPC_DMTC1: check_insn(env, ctx, ISA_MIPS3); gen_cp1(ctx, op1, rt, rd); break; #endif case OPC_BC1ANY2: case OPC_BC1ANY4: check_cp1_3d(env, ctx); case OPC_BC1: gen_compute_branch1(env, ctx, MASK_BC1(ctx->opcode), (rt >> 2) & 0x7, imm << 2); return; case OPC_S_FMT: case OPC_D_FMT: case OPC_W_FMT: case OPC_L_FMT: case OPC_PS_FMT: gen_farith(ctx, MASK_CP1_FUNC(ctx->opcode), rt, rd, sa, (imm >> 8) & 0x7); break; default: MIPS_INVAL("cp1"); generate_exception (ctx, EXCP_RI); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; case OPC_LWC2: case OPC_LDC2: case OPC_SWC2: case OPC_SDC2: case OPC_CP2: generate_exception_err(ctx, EXCP_CpU, 2); break; case OPC_CP3: if (env->CP0_Config1 & (1 << CP0C1_FP)) { save_cpu_state(ctx, 1); check_cp1_enabled(ctx); op1 = MASK_CP3(ctx->opcode); switch (op1) { case OPC_LWXC1: case OPC_LDXC1: case OPC_LUXC1: case OPC_SWXC1: case OPC_SDXC1: case OPC_SUXC1: gen_flt3_ldst(ctx, op1, sa, rd, rs, rt); break; case OPC_PREFX: break; case OPC_ALNV_PS: case OPC_MADD_S: case OPC_MADD_D: case OPC_MADD_PS: case OPC_MSUB_S: case OPC_MSUB_D: case OPC_MSUB_PS: case OPC_NMADD_S: case OPC_NMADD_D: case OPC_NMADD_PS: case OPC_NMSUB_S: case OPC_NMSUB_D: case OPC_NMSUB_PS: gen_flt3_arith(ctx, op1, sa, rs, rd, rt); break; default: MIPS_INVAL("cp3"); generate_exception (ctx, EXCP_RI); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) case OPC_LWU: case OPC_LDL ... OPC_LDR: case OPC_SDL ... OPC_SDR: case OPC_LLD: case OPC_LD: case OPC_SCD: case OPC_SD: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_ldst(ctx, op, rt, rs, imm); break; case OPC_DADDI ... OPC_DADDIU: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_arith_imm(env, ctx, op, rt, rs, imm); break; #endif case OPC_JALX: check_insn(env, ctx, ASE_MIPS16); case OPC_MDMX: check_insn(env, ctx, ASE_MDMX); default: MIPS_INVAL("major opcode"); generate_exception(ctx, EXCP_RI); break; } if (ctx->hflags & MIPS_HFLAG_BMASK) { int hflags = ctx->hflags & MIPS_HFLAG_BMASK; ctx->hflags &= ~MIPS_HFLAG_BMASK; ctx->bstate = BS_BRANCH; save_cpu_state(ctx, 0); switch (hflags) { case MIPS_HFLAG_B: MIPS_DEBUG("unconditional branch"); gen_goto_tb(ctx, 0, ctx->btarget); break; case MIPS_HFLAG_BL: MIPS_DEBUG("blikely branch taken"); gen_goto_tb(ctx, 0, ctx->btarget); break; case MIPS_HFLAG_BC: MIPS_DEBUG("conditional branch"); { int l1; l1 = gen_new_label(); gen_op_jnz_T2(l1); gen_goto_tb(ctx, 1, ctx->pc + 4); gen_set_label(l1); gen_goto_tb(ctx, 0, ctx->btarget); } break; case MIPS_HFLAG_BR: MIPS_DEBUG("branch to register"); gen_op_breg(); gen_op_reset_T0(); gen_op_exit_tb(); break; default: MIPS_DEBUG("unknown branch"); break; } } }
1threat
static int rm_read_header(AVFormatContext *s) { RMDemuxContext *rm = s->priv_data; AVStream *st; AVIOContext *pb = s->pb; unsigned int tag; int tag_size; unsigned int start_time, duration; unsigned int data_off = 0, indx_off = 0; char buf[128], mime[128]; int flags = 0; tag = avio_rl32(pb); if (tag == MKTAG('.', 'r', 'a', 0xfd)) { return rm_read_header_old(s); } else if (tag != MKTAG('.', 'R', 'M', 'F')) { return AVERROR(EIO); } tag_size = avio_rb32(pb); avio_skip(pb, tag_size - 8); for(;;) { if (url_feof(pb)) return -1; tag = avio_rl32(pb); tag_size = avio_rb32(pb); avio_rb16(pb); av_dlog(s, "tag=%c%c%c%c (%08x) size=%d\n", (tag ) & 0xff, (tag >> 8) & 0xff, (tag >> 16) & 0xff, (tag >> 24) & 0xff, tag, tag_size); if (tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A')) return -1; switch(tag) { case MKTAG('P', 'R', 'O', 'P'): avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); duration = avio_rb32(pb); s->duration = av_rescale(duration, AV_TIME_BASE, 1000); avio_rb32(pb); indx_off = avio_rb32(pb); data_off = avio_rb32(pb); avio_rb16(pb); flags = avio_rb16(pb); break; case MKTAG('C', 'O', 'N', 'T'): rm_read_metadata(s, 1); break; case MKTAG('M', 'D', 'P', 'R'): st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->id = avio_rb16(pb); avio_rb32(pb); st->codec->bit_rate = avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); start_time = avio_rb32(pb); avio_rb32(pb); duration = avio_rb32(pb); st->start_time = start_time; st->duration = duration; if(duration>0) s->duration = AV_NOPTS_VALUE; get_str8(pb, buf, sizeof(buf)); get_str8(pb, mime, sizeof(mime)); st->codec->codec_type = AVMEDIA_TYPE_DATA; st->priv_data = ff_rm_alloc_rmstream(); if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data, avio_rb32(pb), mime) < 0) return -1; break; case MKTAG('D', 'A', 'T', 'A'): goto header_end; default: avio_skip(pb, tag_size - 10); break; } } header_end: rm->nb_packets = avio_rb32(pb); if (!rm->nb_packets && (flags & 4)) rm->nb_packets = 3600 * 25; avio_rb32(pb); if (!data_off) data_off = avio_tell(pb) - 18; if (indx_off && pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) && avio_seek(pb, indx_off, SEEK_SET) >= 0) { rm_read_index(s); avio_seek(pb, data_off + 18, SEEK_SET); } return 0; }
1threat
int qemu_devtree_add_subnode(void *fdt, const char *name) { int offset; char *dupname = g_strdup(name); char *basename = strrchr(dupname, '/'); int retval; if (!basename) { return -1; } basename[0] = '\0'; basename++; offset = fdt_path_offset(fdt, dupname); if (offset < 0) { return offset; } retval = fdt_add_subnode(fdt, offset, basename); g_free(dupname); return retval; }
1threat
strange missing value message from geom_point : I have a really strange missing values message which is not reproducible and I also can't find the problem. Any suggestion? Once I get the warning, once not, and by counting NAs, I don't find it. > ggplot(jnk, aes(x=Experiment, y=Log2Intensity)) + + geom_boxplot(outlier.shape = NA) + + geom_point(aes(color=imputed), + position=position_jitter(width=.4), + alpha=.5) + #scatter dots, fill if imputed + scale_color_manual('Imputed', values = c(`TRUE`='blue', `FALSE`='orange')) + + scale_y_continuous(limits=range_intensities) + + facet_wrap(~ my_label, ncol = 10, nrow=5) > ggplot(jnk, aes(x=Experiment, y=Log2Intensity)) + + geom_boxplot(outlier.shape = NA) + + geom_point(aes(color=imputed), + position=position_jitter(width=.4), + alpha=.5) + #scatter dots, fill if imputed + scale_color_manual('Imputed', values = c(`TRUE`='blue', `FALSE`='orange')) + + scale_y_continuous(limits=range_intensities) + + facet_wrap(~ my_label, ncol = 10, nrow=5) Warning message: Removed 1 rows containing missing values (geom_point). > apply(jnk, 2, function(x) sum(is.na(x))) my_label Protein.IDs Experiment replicate imputed Log2Intensity page 0 0 0 0 0 0 0
0debug
unable to run 'aws' from cygwin : <p>I'm using <code>cygwin</code> installed on <code>Windows 10</code> and trying to access <code>awscli</code> from it.</p> <p>I used <code>pip install awscli</code> to install <code>awscli</code>. This installed <code>awscli</code>. I then tried to run only <code>aws</code> to see if it is installed and I get the following error:</p> <pre><code>-bash: /cygdrive/c/Program Files/Anaconda2/Scripts/aws: C:\Program: bad interpreter: No such file or directory </code></pre> <p>I'm not sure why this is happening. Any help in this regard would be highly apreciated.</p>
0debug
How can ı convert png to base64 and than use it in asp.net mvc project? : I have an ımage list an ı want it to be in html export .So the way that ı need to achive is base64.But ı didnt find valuable information how to transform to base64 and in html use it.Can you help me on this?
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Safely assign value to nested hash using Hash#dig or Lonely operator(&.) : <pre><code>h = { data: { user: { value: "John Doe" } } } </code></pre> <p>To assign value to the nested hash, we can use</p> <pre><code>h[:data][:user][:value] = "Bob" </code></pre> <p>However if any part in the middle is missing, it will cause error.</p> <p>Something like </p> <pre><code>h.dig(:data, :user, :value) = "Bob" </code></pre> <p>won't work, since there's no <code>Hash#dig=</code> available yet.</p> <p>To safely assign value, we can do</p> <pre><code>h.dig(:data, :user)&amp;.[]=(:value, "Bob") # or equivalently h.dig(:data, :user)&amp;.store(:value, "Bob") </code></pre> <p>But is there better way to do that? </p>
0debug
static av_cold int dnxhd_decode_init(AVCodecContext *avctx) { DNXHDContext *ctx = avctx->priv_data; ctx->avctx = avctx; ctx->cid = -1; avctx->colorspace = AVCOL_SPC_BT709; avctx->coded_width = FFALIGN(avctx->width, 16); avctx->coded_height = FFALIGN(avctx->height, 16); ctx->rows = av_mallocz_array(avctx->thread_count, sizeof(RowContext)); if (!ctx->rows) return AVERROR(ENOMEM); return 0; }
1threat
Getting text between 2 strings in JS Regex : <p>I have this JavaScript code:</p> <pre><code>var str = "#foo#"; var regex = /(?&lt;=#)(.*)(?=#)/ig; var result = str.replace(regex,"&lt;a href='https://www.google.com/search?q=$1'&gt;$1&lt;/a&gt;"); alert(result); </code></pre> <p>I want the text between surrounded by # to turn into a link to a google search. I would like get the text between #, not change it. Is there a way to do this?</p>
0debug
Can't set visibility on constraint group : <p>When i try to set the visibility of the group on button click,it doesn't affect the view's visibility.Using com.android.support.constraint:constraint-layout:1.1.0-beta4. I've tried setting it element-wise without problems,but no success with the group. </p> <p><strong>My MainActivity.kt</strong></p> <pre><code>private fun toggleLoginUI(show: Boolean) { if (show) { group.visibility = VISIBLE } else { group.visibility = INVISIBLE } } fun onClick(view: View) { when (view.id) { R.id.button -&gt; toggleLoginUI(true) R.id.button4 -&gt; toggleLoginUI(false) } } </code></pre> <p><strong>My activity_main.xml</strong></p> <pre><code> &lt;android.support.constraint.ConstraintLayout.. &lt;TextView android:id="@+id/textView" ... /&gt; &lt;TextView android:id="@+id/textView2" ... /&gt; &lt;Button android:id="@+id/button" .../&gt; &lt;Button android:id="@+id/button4" ... /&gt; &lt;android.support.constraint.Group android:id="@+id/group" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="visible" app:constraint_referenced_ids="textView,textView2" /&gt; &lt;/android.support.constraint.ConstraintLayout&gt; </code></pre>
0debug
How to use time.Parse with string Go? : <p>I have func use to get hour . </p> <pre><code>func GetHourFromAPI(lastUpdate string) int { t, err := time.Parse(time.RFC3339, lastUpdate) var hourTime = t.Hour() if err != nil { fmt.Println(err) } return hourTime } </code></pre> <p>lastUpdate is type string like this : "20190925141100" I tried parse lastUpdate with type RFC3339 and get hour . But , system return t= 0001-01-01 00:00:00 +0000 . My issue at time.Parse ? what i am missing ?</p>
0debug
chart js 2 how to set bar width : <p>I'm using Chart js version: 2.1.4 and I'm not able to limit the bar width. I found two options on stackoverflow</p> <pre><code>barPercentage: 0.5 </code></pre> <p>or</p> <pre><code>categorySpacing: 0 </code></pre> <p>but neither of one works with the mentioned version. Is there a way to solve this issue without manually modifying the chart.js core library?</p> <p>thanks</p>
0debug
static void vqa_decode_chunk(VqaContext *s) { unsigned int chunk_type; unsigned int chunk_size; int byte_skip; unsigned int index = 0; int i; unsigned char r, g, b; int index_shift; int cbf0_chunk = -1; int cbfz_chunk = -1; int cbp0_chunk = -1; int cbpz_chunk = -1; int cpl0_chunk = -1; int cplz_chunk = -1; int vptz_chunk = -1; int x, y; int lines = 0; int pixel_ptr; int vector_index = 0; int lobyte = 0; int hibyte = 0; int lobytes = 0; int hibytes = s->decode_buffer_size / 2; while (index < s->size) { chunk_type = AV_RB32(&s->buf[index]); chunk_size = AV_RB32(&s->buf[index + 4]); switch (chunk_type) { case CBF0_TAG: cbf0_chunk = index; break; case CBFZ_TAG: cbfz_chunk = index; break; case CBP0_TAG: cbp0_chunk = index; break; case CBPZ_TAG: cbpz_chunk = index; break; case CPL0_TAG: cpl0_chunk = index; break; case CPLZ_TAG: cplz_chunk = index; break; case VPTZ_TAG: vptz_chunk = index; break; default: av_log(s->avctx, AV_LOG_ERROR, " VQA video: Found unknown chunk type: %c%c%c%c (%08X)\n", (chunk_type >> 24) & 0xFF, (chunk_type >> 16) & 0xFF, (chunk_type >> 8) & 0xFF, (chunk_type >> 0) & 0xFF, chunk_type); break; } byte_skip = chunk_size & 0x01; index += (CHUNK_PREAMBLE_SIZE + chunk_size + byte_skip); } if ((cpl0_chunk != -1) && (cplz_chunk != -1)) { av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: found both CPL0 and CPLZ chunks\n"); return; } if (cplz_chunk != -1) { } if (cpl0_chunk != -1) { chunk_size = AV_RB32(&s->buf[cpl0_chunk + 4]); if (chunk_size / 3 > 256) { av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: found a palette chunk with %d colors\n", chunk_size / 3); return; } cpl0_chunk += CHUNK_PREAMBLE_SIZE; for (i = 0; i < chunk_size / 3; i++) { r = s->buf[cpl0_chunk++] * 4; g = s->buf[cpl0_chunk++] * 4; b = s->buf[cpl0_chunk++] * 4; s->palette[i] = (r << 16) | (g << 8) | (b); } } if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) { av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: found both CBF0 and CBFZ chunks\n"); return; } if (cbfz_chunk != -1) { chunk_size = AV_RB32(&s->buf[cbfz_chunk + 4]); cbfz_chunk += CHUNK_PREAMBLE_SIZE; decode_format80(&s->buf[cbfz_chunk], chunk_size, s->codebook, s->codebook_size, 0); } if (cbf0_chunk != -1) { chunk_size = AV_RB32(&s->buf[cbf0_chunk + 4]); if (chunk_size > MAX_CODEBOOK_SIZE) { av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: CBF0 chunk too large (0x%X bytes)\n", chunk_size); return; } cbf0_chunk += CHUNK_PREAMBLE_SIZE; memcpy(s->codebook, &s->buf[cbf0_chunk], chunk_size); } if (vptz_chunk == -1) { av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: no VPTZ chunk found\n"); return; } chunk_size = AV_RB32(&s->buf[vptz_chunk + 4]); vptz_chunk += CHUNK_PREAMBLE_SIZE; decode_format80(&s->buf[vptz_chunk], chunk_size, s->decode_buffer, s->decode_buffer_size, 1); if (s->vector_height == 4) index_shift = 4; else index_shift = 3; for (y = 0; y < s->frame.linesize[0] * s->height; y += s->frame.linesize[0] * s->vector_height) { for (x = y; x < y + s->width; x += 4, lobytes++, hibytes++) { pixel_ptr = x; switch (s->vqa_version) { case 1: lobyte = s->decode_buffer[lobytes * 2]; hibyte = s->decode_buffer[(lobytes * 2) + 1]; vector_index = ((hibyte << 8) | lobyte) >> 3; vector_index <<= index_shift; lines = s->vector_height; if (hibyte == 0xFF) { while (lines--) { s->frame.data[0][pixel_ptr + 0] = 255 - lobyte; s->frame.data[0][pixel_ptr + 1] = 255 - lobyte; s->frame.data[0][pixel_ptr + 2] = 255 - lobyte; s->frame.data[0][pixel_ptr + 3] = 255 - lobyte; pixel_ptr += s->frame.linesize[0]; } lines=0; } break; case 2: lobyte = s->decode_buffer[lobytes]; hibyte = s->decode_buffer[hibytes]; vector_index = (hibyte << 8) | lobyte; vector_index <<= index_shift; lines = s->vector_height; break; case 3: lines = 0; break; } while (lines--) { s->frame.data[0][pixel_ptr + 0] = s->codebook[vector_index++]; s->frame.data[0][pixel_ptr + 1] = s->codebook[vector_index++]; s->frame.data[0][pixel_ptr + 2] = s->codebook[vector_index++]; s->frame.data[0][pixel_ptr + 3] = s->codebook[vector_index++]; pixel_ptr += s->frame.linesize[0]; } } } if ((cbp0_chunk != -1) && (cbpz_chunk != -1)) { av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: found both CBP0 and CBPZ chunks\n"); return; } if (cbp0_chunk != -1) { chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]); cbp0_chunk += CHUNK_PREAMBLE_SIZE; memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index], &s->buf[cbp0_chunk], chunk_size); s->next_codebook_buffer_index += chunk_size; s->partial_countdown--; if (s->partial_countdown == 0) { memcpy(s->codebook, s->next_codebook_buffer, s->next_codebook_buffer_index); s->next_codebook_buffer_index = 0; s->partial_countdown = s->partial_count; } } if (cbpz_chunk != -1) { chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]); cbpz_chunk += CHUNK_PREAMBLE_SIZE; memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index], &s->buf[cbpz_chunk], chunk_size); s->next_codebook_buffer_index += chunk_size; s->partial_countdown--; if (s->partial_countdown == 0) { decode_format80(s->next_codebook_buffer, s->next_codebook_buffer_index, s->codebook, s->codebook_size, 0); s->next_codebook_buffer_index = 0; s->partial_countdown = s->partial_count; } } }
1threat
static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv) { static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b}; MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; int64_t end = avio_tell(pb) + klv->length; uint64_t size; uint64_t orig_size; uint64_t plaintext_size; uint8_t ivec[16]; uint8_t tmpbuf[16]; int index; if (!mxf->aesc && s->key && s->keylen == 16) { mxf->aesc = av_malloc(av_aes_size); if (!mxf->aesc) return -1; av_aes_init(mxf->aesc, s->key, 128, 1); } avio_skip(pb, klv_decode_ber_length(pb)); klv_decode_ber_length(pb); plaintext_size = avio_rb64(pb); klv_decode_ber_length(pb); avio_read(pb, klv->key, 16); if (!IS_KLV_KEY(klv, mxf_essence_element_key)) return -1; index = mxf_get_stream_index(s, klv); if (index < 0) return -1; klv_decode_ber_length(pb); orig_size = avio_rb64(pb); if (orig_size < plaintext_size) return -1; size = klv_decode_ber_length(pb); if (size < 32 || size - 32 < orig_size) return -1; avio_read(pb, ivec, 16); avio_read(pb, tmpbuf, 16); if (mxf->aesc) av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1); if (memcmp(tmpbuf, checkv, 16)) av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n"); size -= 32; size = av_get_packet(pb, pkt, size); if (size < 0) return size; else if (size < plaintext_size) return AVERROR_INVALIDDATA; size -= plaintext_size; if (mxf->aesc) av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size], &pkt->data[plaintext_size], size >> 4, ivec, 1); av_shrink_packet(pkt, orig_size); pkt->stream_index = index; avio_skip(pb, end - avio_tell(pb)); return 0; }
1threat
Converting Date Format to numeric Date : <p>I have a Date in this format:</p> <pre><code>Tue Mar 10 00:00:00 UTC 1987 </code></pre> <p>It is stored in a Object Date.</p> <pre><code>Object tmp = solrDoc.getFieldValue("date_from") </code></pre> <p>I would like to convert it to a strictly numeric format, without the hours, timezone etc., like</p> <pre><code>10.03.1987 </code></pre> <p>This is what I tried so far:</p> <pre><code>DateFormat date = new SimpleDateFormat("dd.MM.yyyy"); date.format(tmp); </code></pre> <p>It returns:</p> <pre><code> "java.text.SimpleDateFormat@7147a660" </code></pre>
0debug
def dict_depth(d): if isinstance(d, dict): return 1 + (max(map(dict_depth, d.values())) if d else 0) return 0
0debug
static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, int *data_size, const uint8_t *buf, int buf_size) { static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; unsigned int refl_rms[4]; uint16_t block_coefs[4][30]; unsigned int lpc_refl[10]; int i, c; int16_t *data = vdata; unsigned int energy; RA144Context *ractx = avctx->priv_data; GetBitContext gb; if(buf_size < 20) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); *data_size = 0; return buf_size; } init_get_bits(&gb, buf, 20 * 8); for (i=0; i<10; i++) lpc_refl[i] = lpc_refl_cb[i][get_bits(&gb, sizes[i])]; eval_coefs(ractx->lpc_coef[0], lpc_refl); ractx->lpc_refl_rms[0] = rms(lpc_refl); energy = energy_tab[get_bits(&gb, 5)]; refl_rms[0] = interp(ractx, block_coefs[0], 0, 1, ractx->old_energy); refl_rms[1] = interp(ractx, block_coefs[1], 1, energy <= ractx->old_energy, t_sqrt(energy*ractx->old_energy) >> 12); refl_rms[2] = interp(ractx, block_coefs[2], 2, 0, energy); refl_rms[3] = rescale_rms(ractx->lpc_refl_rms[0], energy); int_to_int16(block_coefs[3], ractx->lpc_coef[0]); for (c=0; c<4; c++) { do_output_subblock(ractx, block_coefs[c], refl_rms[c], &gb); for (i=0; i<BLOCKSIZE; i++) *data++ = av_clip_int16(ractx->curr_sblock[i + 10] << 2); } ractx->old_energy = energy; ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0]; FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); *data_size = 2*160; return 20; }
1threat
static int get_cluster_table(BlockDriverState *bs, uint64_t offset, uint64_t **new_l2_table, uint64_t *new_l2_offset, int *new_l2_index) { BDRVQcowState *s = bs->opaque; unsigned int l1_index, l2_index; uint64_t l2_offset; uint64_t *l2_table = NULL; int ret; l1_index = offset >> (s->l2_bits + s->cluster_bits); if (l1_index >= s->l1_size) { ret = qcow2_grow_l1_table(bs, l1_index + 1, false); if (ret < 0) { return ret; } } l2_offset = s->l1_table[l1_index]; if (l2_offset & QCOW_OFLAG_COPIED) { l2_offset &= ~QCOW_OFLAG_COPIED; ret = l2_load(bs, l2_offset, &l2_table); if (ret < 0) { return ret; } } else { if (l2_offset) qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t)); ret = l2_allocate(bs, l1_index, &l2_table); if (ret < 0) { return ret; } l2_offset = s->l1_table[l1_index] & ~QCOW_OFLAG_COPIED; } l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *new_l2_table = l2_table; *new_l2_offset = l2_offset; *new_l2_index = l2_index; return 0; }
1threat
NullPointerException when pressing JOptionPane Cancel button : <p>I am writing a program to choose between different shape and then input the values (e.g. radius) to calculate the volume of the shape using JOptionPane, I did some input validation, but the problem is whenever I press the cancel button of the JOptionPane.showInputDialog, the program crash with the following error, where is the problem comes from? And how can I solve it? Thanks!</p> <pre><code>while(choice.equalsIgnoreCase("y")) { ....... if (n== JOptionPane.YES_OPTION) { while (notDone) { try { radiusStr = JOptionPane.showInputDialog("Please enter the radius of the sphere"); radius = Double.parseDouble(radiusStr); notDone = false; } catch (NumberFormatException e ){ JOptionPane.showMessageDialog(null, "Input error! Please enter a number."); continue; } volume = new CircularVolume(radius); </code></pre>
0debug
<identifier> expected Error in java Compilation : <p>As i am new in java. I have searched about static mean in java and i got solution on stack overflow <strong><a href="https://stackoverflow.com/questions/413898/what-does-the-static-keyword-do-in-a-class">here</a></strong> but when i compiled it it is showing error. Can anybody suggest Where i am mistaking ?</p> <pre><code>public class Hello { // value / method public static String staticValue; public String nonStaticValue; } class A { Hello hello = new Hello(); hello.staticValue = "abc"; hello.nonStaticValue = "xyz"; } class B { Hello hello2 = new Hello(); // here staticValue = "abc" hello2.staticValue; // will have value of "abc" hello2.nonStaticValue; // will have value of null } </code></pre> <p><a href="https://i.stack.imgur.com/cBHGd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cBHGd.jpg" alt="enter image description here"></a></p>
0debug
Python create all possible combinations from a integer : <p>I have integer for example "123", using this i want to create all possible combinations listed below. 123 12,3 1,23 and so on irrespective of the digits i have entered. Is there any way possible using python for the same? I am not able to get any idea.</p>
0debug
Error! : 'function' object has no attribute '_getexif' : [enter image description here][1] [1]: https://i.stack.imgur.com/BcCrr.jpg Where am I wrong? help.. I'm extracting information from my image.
0debug
static void do_commit(void) { int i; for (i = 0; i < MAX_DISKS; i++) { if (bs_table[i]) bdrv_commit(bs_table[i]); } }
1threat
Leaflet: Map container not found : <p>I have the below react class which fetches the geolocation through the browser.</p> <p>I am mapping a leaflet map. I want to geolocation to be an input to the setView, for such that the map "zooms" into the region of the client browser location. </p> <p>Here's the react class: </p> <pre><code> import React from 'react'; import L from 'leaflet'; import countries from './countries.js'; var Worldmap = React.createClass({ render: function() { let geolocation = []; navigator.geolocation.getCurrentPosition(function(position) { let lat = position.coords.latitude; let lon = position.coords.longitude; geolocation.push(lat, lon); locationCode() }); function locationCode() { if(geolocation.length &lt;= 0) geolocation.push(0, 0); } let map = L.map('leafletmap').setView(geolocation, 3); L.geoJSON(countries, { style: function(feature) { return { fillColor: "#FFBB78", fillOpacity: 0.6, stroke: true, color: "black", weight: 2 }; } }).bindPopup(function(layer) { return layer.feature.properties.name; }).addTo(map); return ( &lt;div id="leafletmap" style={{width: "100%", height: "800px" }}/&gt; ) } }); export default Worldmap </code></pre> <p>It's called in a main file where the HTML is rendered as <code>&lt;WorldMap /&gt;</code>.</p> <p>I get the error <code>Uncaught Error: Map container not found.</code> when loading the page. Looking around, usually it would be because the map is trying to be displayed in a div before being provided values((gelocation, 3) in this case). However, it shouldn't display it before being returned from the render function below. </p> <p>What could the issue be?</p> <p>Printing out the <code>geolocation</code> in the console correctly fetches the coordinates, so that doesn't seem to be the issue. </p>
0debug
static void vfio_put_device(VFIOPCIDevice *vdev) { g_free(vdev->vbasedev.name); if (vdev->msix) { g_free(vdev->msix); vdev->msix = NULL; } vfio_put_base_device(&vdev->vbasedev); }
1threat
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
Populating Dropdown in ASP.net Core : <p>Does anyone know how to deal with Dropdowns in Asp.net core. I think I made myself very complicated to understand the new Asp.net core concept. (I am new to Asp.net Core).</p> <p>I have models called <code>Driver</code>, <code>Vehicle</code>. Basically one can create bunch of vehicles in the master then attach it to the Driver. So that the driver will be associated with a vehicle.</p> <p>My problem is that I am also using viewmodel in some area to combine two different models.(understood little from default template)</p> <p>My problem is I have no idea what is the next step since ASP.net Core is very latest, there are not a lot of tutorials and Q/As available.</p> <p>Driver Model</p> <pre><code>public class Driver { [Required] public int Id { get; set; } [Required] public string ApplicationUserId { get; set; } [Required] public int VehicleId { get; set; } [Required] public string Status { get; set; } public virtual ApplicationUser ApplicationUser { get; set; } public virtual Vehicle Vehicle { get; set; } } </code></pre> <p>Vehicle Model</p> <pre><code>public class Vehicle { [Required] public int Id { get; set; } [Required] public string Make { get; set; } public string Model { get; set; } [Required] public string PlateNo { get; set; } public string InsuranceNo { get; set; } } </code></pre> <p>ViewModel of Driver</p> <pre><code> public class DriverViewModel { [Required] [Display(Name = "ID")] public int ID { get; set; } [Required] [Display(Name = "User ID")] public string ApplicationUserId { get; set; } [Required] [Display(Name = "Vehicle ID")] public IEnumerable&lt;Vehicle&gt; VehicleId { get; set; } //public string VehicleId { get; set; } [Required] [Display(Name = "Status")] public string Status { get; set; } } </code></pre> <p>Here is my View</p> <pre><code>&lt;div class="col-md-10"&gt; @*&lt;input asp-for="VehicleId" class="form-control" /&gt;*@ @Html.DropDownList("VehicleId", null, htmlAttributes: new { @class = "form-control"}) &lt;span asp-validation-for="VehicleId" class="text-danger" /&gt; &lt;/div&gt; </code></pre>
0debug
static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel) { int i[2] = { 0 }; int index = 0; while (i[0] < len || i[1] < len) { while (i[0] < len && !(in[i[0]] && (in[i[0]]->reference & sel))) i[0]++; while (i[1] < len && !(in[i[1]] && (in[i[1]]->reference & (sel ^ 3)))) i[1]++; if (i[0] < len) { in[i[0]]->pic_id = is_long ? i[0] : in[i[0]]->frame_num; split_field_copy(&def[index++], in[i[0]++], sel, 1); } if (i[1] < len) { in[i[1]]->pic_id = is_long ? i[1] : in[i[1]]->frame_num; split_field_copy(&def[index++], in[i[1]++], sel ^ 3, 0); } } return index; }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
Removing sandbox accounts from tvOS 13 : <p>I have been developing a tvOS app that uses in-app purchasing. As part of the development process, the app must be tested using iTunes sandbox user accounts. When beginning the in-app purchase using a local build, the user is prompted for the account credentials to one of these sandbox accounts.</p> <p>The problem arises with tvOS 13, which does not appear to let you log out from or remove a sandbox account from the device once entered. While this might be okay for purchasing a single time, going through the purchase process again requires a new sandbox account, since otherwise, the purchase would be treated as a renewal rather than a new purchase.</p> <p>Has anyone figured out a way to log out of a sandbox account with an Apple TV running tvOS 13? The only workaround I have found is to perform a reset on the device and go through the setup process again costing a great deal of time.</p>
0debug
Vuejs doesn't render components inside HTML table elements : <p>I want to render a custom component that displays a row inside a table.</p> <p>I have the following code:</p> <pre><code>// js file Vue.component('message-row', { data: function () { return { msg: 'Hello' } }, template: '&lt;tr&gt;&lt;td&gt;{{ msg }}&lt;/td&gt;&lt;/tr&gt;' }); new Vue({ el: '#app' }); // html file &lt;div id="app"&gt; &lt;table&gt;&lt;message-row&gt;&lt;/message-row&gt;&lt;/table&gt; &lt;/div&gt; </code></pre> <p>The problem is that the row ends up rendered outside the table! Like this:</p> <pre><code>&lt;div id="app"&gt; &lt;tr&gt;&lt;td&gt;Hello&lt;/td&gt;&lt;/tr&gt; &lt;table&gt;&lt;/table&gt; &lt;/div&gt; </code></pre> <p>You can check it out in this JSFiddle <a href="https://jsfiddle.net/eciii/7v6yrf3x/" rel="noreferrer">https://jsfiddle.net/eciii/7v6yrf3x/</a></p> <p>I'm not sure if this is a bug or I'm just missing something really obvious here...</p>
0debug
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err) { FILE *fh; int fd; int64_t ret = -1, handle; if (!has_mode) { mode = "r"; } slog("guest-file-open called, filepath: %s, mode: %s", path, mode); fh = fopen(path, mode); if (!fh) { error_setg_errno(err, errno, "failed to open file '%s' (mode: '%s')", path, mode); return -1; } fd = fileno(fh); ret = fcntl(fd, F_GETFL); ret = fcntl(fd, F_SETFL, ret | O_NONBLOCK); if (ret == -1) { error_setg_errno(err, errno, "failed to make file '%s' non-blocking", path); fclose(fh); return -1; } handle = guest_file_handle_add(fh, err); if (error_is_set(err)) { fclose(fh); return -1; } slog("guest-file-open, handle: %d", handle); return handle; }
1threat
How to add an HTTP header to all Django responses : <p>I'd like to add a few headers to all responses that my Django website returns. Is there a way to do this (besides adding a wrapper to the <code>render</code> function)?</p>
0debug
static int v9fs_do_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf) { return s->ops->lstat(&s->ctx, path->data, stbuf); }
1threat
jQuery code to JavaScript : <pre><code>$(function () { $(document).on('click', 'td', function () { $(this).toggleClass('active'); }); }); </code></pre> <p>Can someone please show what this code would be in vanilla javascript?</p> <p><a href="https://stackoverflow.com/questions/22105868/difficulty-changing-dynamically-generated-table-cell-background-onclick/50448074#50448074">Difficulty changing dynamically generated table cell background onclick</a></p>
0debug
static int tiff_decode_tag(TiffContext *s, AVFrame *frame) { unsigned tag, type, count, off, value = 0, value2 = 0; int i, start; int pos; int ret; double *dp; ret = ff_tread_tag(&s->gb, s->le, &tag, &type, &count, &start); if (ret < 0) { goto end; } off = bytestream2_tell(&s->gb); if (count == 1) { switch (type) { case TIFF_BYTE: case TIFF_SHORT: case TIFF_LONG: value = ff_tget(&s->gb, type, s->le); break; case TIFF_RATIONAL: value = ff_tget(&s->gb, TIFF_LONG, s->le); value2 = ff_tget(&s->gb, TIFF_LONG, s->le); break; case TIFF_STRING: if (count <= 4) { break; } default: value = UINT_MAX; } } switch (tag) { case TIFF_WIDTH: s->width = value; break; case TIFF_HEIGHT: s->height = value; break; case TIFF_BPP: s->bppcount = count; if (count > 4) { av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); return AVERROR_INVALIDDATA; } if (count == 1) s->bpp = value; else { switch (type) { case TIFF_BYTE: case TIFF_SHORT: case TIFF_LONG: s->bpp = 0; if (bytestream2_get_bytes_left(&s->gb) < type_sizes[type] * count) return AVERROR_INVALIDDATA; for (i = 0; i < count; i++) s->bpp += ff_tget(&s->gb, type, s->le); break; default: s->bpp = -1; } } break; case TIFF_SAMPLES_PER_PIXEL: if (count != 1) { av_log(s->avctx, AV_LOG_ERROR, "Samples per pixel requires a single value, many provided\n"); return AVERROR_INVALIDDATA; } if (value > 4U) { av_log(s->avctx, AV_LOG_ERROR, "Samples per pixel %d is too large\n", value); return AVERROR_INVALIDDATA; } if (s->bppcount == 1) s->bpp *= value; s->bppcount = value; break; case TIFF_COMPR: s->compr = value; s->predictor = 0; switch (s->compr) { case TIFF_RAW: case TIFF_PACKBITS: case TIFF_LZW: case TIFF_CCITT_RLE: break; case TIFF_G3: case TIFF_G4: s->fax_opts = 0; break; case TIFF_DEFLATE: case TIFF_ADOBE_DEFLATE: #if CONFIG_ZLIB break; #else av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n"); return AVERROR(ENOSYS); #endif case TIFF_JPEG: case TIFF_NEWJPEG: avpriv_report_missing_feature(s->avctx, "JPEG compression"); return AVERROR_PATCHWELCOME; case TIFF_LZMA: #if CONFIG_LZMA break; #else av_log(s->avctx, AV_LOG_ERROR, "LZMA not compiled in\n"); return AVERROR(ENOSYS); #endif default: av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", s->compr); return AVERROR_INVALIDDATA; } break; case TIFF_ROWSPERSTRIP: if (!value || (type == TIFF_LONG && value == UINT_MAX)) value = s->height; s->rps = FFMIN(value, s->height); break; case TIFF_STRIP_OFFS: if (count == 1) { s->strippos = 0; s->stripoff = value; } else s->strippos = off; s->strips = count; if (s->strips == 1) s->rps = s->height; s->sot = type; break; case TIFF_STRIP_SIZE: if (count == 1) { s->stripsizesoff = 0; s->stripsize = value; s->strips = 1; } else { s->stripsizesoff = off; } s->strips = count; s->sstype = type; break; case TIFF_XRES: case TIFF_YRES: set_sar(s, tag, value, value2); break; case TIFF_TILE_BYTE_COUNTS: case TIFF_TILE_LENGTH: case TIFF_TILE_OFFSETS: case TIFF_TILE_WIDTH: av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n"); return AVERROR_PATCHWELCOME; break; case TIFF_PREDICTOR: s->predictor = value; break; case TIFF_PHOTOMETRIC: switch (value) { case TIFF_PHOTOMETRIC_WHITE_IS_ZERO: case TIFF_PHOTOMETRIC_BLACK_IS_ZERO: case TIFF_PHOTOMETRIC_RGB: case TIFF_PHOTOMETRIC_PALETTE: case TIFF_PHOTOMETRIC_YCBCR: s->photometric = value; break; case TIFF_PHOTOMETRIC_ALPHA_MASK: case TIFF_PHOTOMETRIC_SEPARATED: case TIFF_PHOTOMETRIC_CIE_LAB: case TIFF_PHOTOMETRIC_ICC_LAB: case TIFF_PHOTOMETRIC_ITU_LAB: case TIFF_PHOTOMETRIC_CFA: case TIFF_PHOTOMETRIC_LOG_L: case TIFF_PHOTOMETRIC_LOG_LUV: case TIFF_PHOTOMETRIC_LINEAR_RAW: avpriv_report_missing_feature(s->avctx, "PhotometricInterpretation 0x%04X", value); return AVERROR_PATCHWELCOME; default: av_log(s->avctx, AV_LOG_ERROR, "PhotometricInterpretation %u is " "unknown\n", value); return AVERROR_INVALIDDATA; } break; case TIFF_FILL_ORDER: if (value < 1 || value > 2) { av_log(s->avctx, AV_LOG_ERROR, "Unknown FillOrder value %d, trying default one\n", value); value = 1; } s->fill_order = value - 1; break; case TIFF_PAL: { GetByteContext pal_gb[3]; off = type_sizes[type]; if (count / 3 > 256 || bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3) return AVERROR_INVALIDDATA; pal_gb[0] = pal_gb[1] = pal_gb[2] = s->gb; bytestream2_skip(&pal_gb[1], count / 3 * off); bytestream2_skip(&pal_gb[2], count / 3 * off * 2); off = (type_sizes[type] - 1) << 3; for (i = 0; i < count / 3; i++) { uint32_t p = 0xFF000000; p |= (ff_tget(&pal_gb[0], type, s->le) >> off) << 16; p |= (ff_tget(&pal_gb[1], type, s->le) >> off) << 8; p |= ff_tget(&pal_gb[2], type, s->le) >> off; s->palette[i] = p; } s->palette_is_set = 1; break; } case TIFF_PLANAR: s->planar = value == 2; break; case TIFF_YCBCR_SUBSAMPLING: if (count != 2) { av_log(s->avctx, AV_LOG_ERROR, "subsample count invalid\n"); return AVERROR_INVALIDDATA; } for (i = 0; i < count; i++) s->subsampling[i] = ff_tget(&s->gb, type, s->le); break; case TIFF_T4OPTIONS: if (s->compr == TIFF_G3) s->fax_opts = value; break; case TIFF_T6OPTIONS: if (s->compr == TIFF_G4) s->fax_opts = value; break; #define ADD_METADATA(count, name, sep)\ if ((ret = add_metadata(count, type, name, sep, s, frame)) < 0) {\ av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\ goto end;\ } case TIFF_MODEL_PIXEL_SCALE: ADD_METADATA(count, "ModelPixelScaleTag", NULL); break; case TIFF_MODEL_TRANSFORMATION: ADD_METADATA(count, "ModelTransformationTag", NULL); break; case TIFF_MODEL_TIEPOINT: ADD_METADATA(count, "ModelTiepointTag", NULL); break; case TIFF_GEO_KEY_DIRECTORY: ADD_METADATA(1, "GeoTIFF_Version", NULL); ADD_METADATA(2, "GeoTIFF_Key_Revision", "."); s->geotag_count = ff_tget_short(&s->gb, s->le); if (s->geotag_count > count / 4 - 1) { s->geotag_count = count / 4 - 1; av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n"); } if (bytestream2_get_bytes_left(&s->gb) < s->geotag_count * sizeof(int16_t) * 4) { s->geotag_count = 0; return -1; } s->geotags = av_mallocz_array(s->geotag_count, sizeof(TiffGeoTag)); if (!s->geotags) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); s->geotag_count = 0; goto end; } for (i = 0; i < s->geotag_count; i++) { s->geotags[i].key = ff_tget_short(&s->gb, s->le); s->geotags[i].type = ff_tget_short(&s->gb, s->le); s->geotags[i].count = ff_tget_short(&s->gb, s->le); if (!s->geotags[i].type) s->geotags[i].val = get_geokey_val(s->geotags[i].key, ff_tget_short(&s->gb, s->le)); else s->geotags[i].offset = ff_tget_short(&s->gb, s->le); } break; case TIFF_GEO_DOUBLE_PARAMS: if (count >= INT_MAX / sizeof(int64_t)) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int64_t)) return AVERROR_INVALIDDATA; dp = av_malloc_array(count, sizeof(double)); if (!dp) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); goto end; } for (i = 0; i < count; i++) dp[i] = ff_tget_double(&s->gb, s->le); for (i = 0; i < s->geotag_count; i++) { if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) { if (s->geotags[i].count == 0 || s->geotags[i].offset + s->geotags[i].count > count) { av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key); } else { char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", "); if (!ap) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); av_freep(&dp); return AVERROR(ENOMEM); } s->geotags[i].val = ap; } } } av_freep(&dp); break; case TIFF_GEO_ASCII_PARAMS: pos = bytestream2_tell(&s->gb); for (i = 0; i < s->geotag_count; i++) { if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) { if (s->geotags[i].count == 0 || s->geotags[i].offset + s->geotags[i].count > count) { av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key); } else { char *ap; bytestream2_seek(&s->gb, pos + s->geotags[i].offset, SEEK_SET); if (bytestream2_get_bytes_left(&s->gb) < s->geotags[i].count) return AVERROR_INVALIDDATA; ap = av_malloc(s->geotags[i].count); if (!ap) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } bytestream2_get_bufferu(&s->gb, ap, s->geotags[i].count); ap[s->geotags[i].count - 1] = '\0'; s->geotags[i].val = ap; } } } break; case TIFF_ARTIST: ADD_METADATA(count, "artist", NULL); break; case TIFF_COPYRIGHT: ADD_METADATA(count, "copyright", NULL); break; case TIFF_DATE: ADD_METADATA(count, "date", NULL); break; case TIFF_DOCUMENT_NAME: ADD_METADATA(count, "document_name", NULL); break; case TIFF_HOST_COMPUTER: ADD_METADATA(count, "computer", NULL); break; case TIFF_IMAGE_DESCRIPTION: ADD_METADATA(count, "description", NULL); break; case TIFF_MAKE: ADD_METADATA(count, "make", NULL); break; case TIFF_MODEL: ADD_METADATA(count, "model", NULL); break; case TIFF_PAGE_NAME: ADD_METADATA(count, "page_name", NULL); break; case TIFF_PAGE_NUMBER: ADD_METADATA(count, "page_number", " / "); break; case TIFF_SOFTWARE_NAME: ADD_METADATA(count, "software", NULL); break; default: if (s->avctx->err_recognition & AV_EF_EXPLODE) { av_log(s->avctx, AV_LOG_ERROR, "Unknown or unsupported tag %d/0X%0X\n", tag, tag); return AVERROR_INVALIDDATA; } } end: bytestream2_seek(&s->gb, start, SEEK_SET); return 0; }
1threat
How to find which Yocto Project recipe populates a particular file on an image root filesystem : <p>I work with the Yocto Project quite a bit and a common challenge is determining why (or from what recipe) a file has been included on the rootfs. This is something that can hopefully be derived from the build system's environment, log &amp; meta data. Ideally, a set of commands would allow linking a file back to a source (ie. recipe).</p> <p>My usual strategy is to perform searches on the meta data (e.g. <code>grep -R filename ../layers/*</code>) and searches on the internet of said filenames to find clues of possible responsible recipes. However, this is not always very effective. In many cases, filenames are not explicitly stated within a recipe. Additionally, there are many cases where a filename is provided by multiple recipes which leads to additional work to find which recipe ultimately supplied it. There are of course many other clues available to find the answer. Regardless, this investigation is often quite laborious when it seems the build system should have enough information to make resolving the answer simple.</p>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
C++ dereferencing for std::priority_queue::top : <p>Documentation states <code>std::priority_queue::top</code> returns a constant reference to the top element in the priority_queue, but when printing the top element, the unary dereference operator is not used. </p> <pre><code>// priority_queue::top #include &lt;iostream&gt; // std::cout #include &lt;queue&gt; // std::priority_queue int main () { std::priority_queue&lt;int&gt; mypq; mypq.push(10); mypq.push(20); mypq.push(15); std::cout &lt;&lt; "mypq.top() is now " &lt;&lt; mypq.top() &lt;&lt; '\n'; return 0; } </code></pre> <p>Is <code>top()</code> being implicitly dereferenced or is the returned value a copy?</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc) { assert(pkt); if (!pkt->has_virt_hdr && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { net_tx_pkt_do_sw_csum(pkt); } if (VIRTIO_NET_HDR_GSO_NONE != pkt->virt_hdr.gso_type) { if (pkt->payload_len > ETH_MAX_IP_DGRAM_LEN - pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len) { return false; } } if (pkt->has_virt_hdr || pkt->virt_hdr.gso_type == VIRTIO_NET_HDR_GSO_NONE) { qemu_sendv_packet(nc, pkt->vec, pkt->payload_frags + NET_TX_PKT_PL_START_FRAG); return true; } return net_tx_pkt_do_sw_fragmentation(pkt, nc); }
1threat
python generators garbage collection : <p>I think my question is related to <a href="https://stackoverflow.com/questions/15490127/will-a-python-generator-be-garbage-collected-if-it-will-not-be-used-any-more-but">this</a>, but not exactly similar. Consider this code:</p> <pre><code>def countdown(n): try: while n &gt; 0: yield n n -= 1 finally: print('In the finally block') def main(): for n in countdown(10): if n == 5: break print('Counting... ', n) print('Finished counting') main() </code></pre> <p>The output of this code is:</p> <pre><code>Counting... 10 Counting... 9 Counting... 8 Counting... 7 Counting... 6 In the finally block Finished counting </code></pre> <p>Is it guaranteed that the line "In the finally block" is going to be printed before "Finished counting"? Or is this because of cPython implementation detail that an object will be garbage collected when the reference count reaches 0.</p> <p>Also I am curious on how <code>finally</code> block of the <code>countdown</code> generator is executed? e.g. if I change the code of <code>main</code> to</p> <pre><code>def main(): c = countdown(10) for n in c: if n == 5: break print('Counting... ', n) print('Finished counting') </code></pre> <p>then I do see <code>Finished counting</code> printed before <code>In the finally block</code>. How does the garbage collector directly go to the <code>finally</code> block? I think I have always taken <code>try/except/finally</code> on its face value, but thinking in the context of generators is making me think twice about it. </p>
0debug
Why is this Java code returning a memory address? : <p>This code is returning a memory address of an array being returned by the rgb2hsv function. I am not sure as to why this is, or if it is even a memory address that it is returning as I am familiar with memory addresses looking something along the lines of "0x038987086" but the code is returning something that looks more like this : "[F@12bb4df8", I am not sure as to why this is, if you could answer why and what it exactly what it is returning that would be extremely beneficial. Here is the code:</p> <pre><code> public class HelloWorld{ public static float max(float[] nums) { if (nums[0] &gt; nums [1] &amp;&amp; nums[0] &gt; nums[2]) { return nums[0]; } if (nums[1] &gt; nums [0] &amp;&amp; nums[1] &gt; nums[2]) { return nums[1]; } if (nums[2] &gt; nums[0] &amp;&amp; nums[2] &gt; nums[1]) { return nums[2]; } return 0; } public static float min(float[] nums) { if (nums[0] &lt; nums [1] &amp;&amp; nums[0] &lt; nums[2]) { return nums[0]; } if (nums[1] &lt; nums [0] &amp;&amp; nums[1] &lt; nums[2]) { return nums[1]; } if (nums[2] &lt; nums[0] &amp;&amp; nums[2] &lt; nums[1]) { return nums[2]; } return 0; } public static float[] rgb2hsv(float r,float g, float b) { float h; //Initializes h h=0; float s; float v; // Floats added to avoid operator precedence float x; float a; float hue; //Divides by 255 r=r/255; g=g/255; b=b/255; float[] rgbArray = {r,g,b}; float mx= max(rgbArray); float mn= min(rgbArray); float df= mx-mn; if (mx == mn) { h=0; } if (mx==r) { x=g-b; a=x/df+360; hue=a % 360; h=hue; } if (mx==g) { x=b-r; a=x/df+120; hue=a % 360; h=hue; } if (mx==b) { x=r-g; a=x/df+240; hue=a % 360; h=hue; } if(mx==0) { s=0; } else { s=df/mx; } v=mx; float[] hsvArray = {h,s,v}; return hsvArray; } public static void main(String []args){ float[] x=rgb2hsv(255, 255, 0); System.out.println(x); } </code></pre> <p>}</p> <p>This should of outputted something along the lines of 3 distinct numbers telling me hue, value, and saturation. Instead it returns something similar to "[F@12bb4df8"</p>
0debug
How to get kNN in python (visual studio)? I thought it was part of sklearn? : <p>I tried to import it</p> <pre><code>from numpy import * import kNN from matplotlib import * from matplotlib.pyplot import * from os import * </code></pre> <p>but kNN is highlighted with an error: ImportError: No module named kNN</p>
0debug
static int write_elf32_load(DumpState *s, MemoryMapping *memory_mapping, int phdr_index, hwaddr offset) { Elf32_Phdr phdr; int ret; int endian = s->dump_info.d_endian; memset(&phdr, 0, sizeof(Elf32_Phdr)); phdr.p_type = cpu_convert_to_target32(PT_LOAD, endian); phdr.p_offset = cpu_convert_to_target32(offset, endian); phdr.p_paddr = cpu_convert_to_target32(memory_mapping->phys_addr, endian); if (offset == -1) { phdr.p_filesz = 0; } else { phdr.p_filesz = cpu_convert_to_target32(memory_mapping->length, endian); } phdr.p_memsz = cpu_convert_to_target32(memory_mapping->length, endian); phdr.p_vaddr = cpu_convert_to_target32(memory_mapping->virt_addr, endian); ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s); if (ret < 0) { dump_error(s, "dump: failed to write program header table.\n"); return -1; } return 0; }
1threat
HTML & CSS formatting bug when printing web page : I am attempting to print a web page via Ctrl-P or right-click print so I can save it as a PDF. Up until several minutes ago, this was working flawlessly. I have made some minor sizing edits to the grid I am working with on the page and now when I attempt to print, the web page is displaying some formatting glitches on the preview screen. The problem is shown below. There are various borders missing from the grid and this is carrying over to the PDF when fully saved. [![Glitched web page][1]][1] [1]: https://i.stack.imgur.com/oEhby.png
0debug
char *g_strdup_printf(const char *format, ...) { char ch, *s; size_t len; __coverity_string_null_sink__(format); __coverity_string_size_sink__(format); ch = *format; s = __coverity_alloc_nosize__(); __coverity_writeall__(s); __coverity_mark_as_afm_allocated__(s, AFM_free); return s; }
1threat
Airflow - how to make EmailOperator html_content dynamic? : <p>I'm looking for a method that will allow the content of the emails sent by a given EmailOperator task to be set dynamically. Ideally I would like to make the email contents dependent on the results of an xcom call, preferably through the html_content argument.</p> <pre><code>alert = EmailOperator( task_id=alertTaskID, to='please@dontreply.com', subject='Airflow processing report', html_content='raw content #2', dag=dag ) </code></pre> <p>I notice that the Airflow docs say that xcom calls can be embedded in templates. Perhaps there is a way to formulate an xcom pull using a template on a specified task ID then pass the result in as html_content? Thanks</p>
0debug
How to fill in [x]% of a 2d array with the values of another array : <p>I have 2 two-dimensional arrays, one is filled and one is to be filled, both of the same size (n x m). I need to fill in [some random]% of my second array with the exact same values as my first array. So let's say</p> <pre><code>int[][] arr1 = new int[][] {{0, 1, 0, 1}, {1, 0, 1, 0}, {0, 0, 1, 1}, {1, 1, 0, 0}}; </code></pre> <p>I want arr2 to be filled with 25% of arr1's values in the same spot with the other spots just remaining null..</p> <pre><code>int[][] arr2 = new int[4][4]; // where arr2 = something like {{0,1,0,1}, // { , , , }, // { , , , }, // { , , , }} </code></pre> <p>Eventually, the program will call on the user to fill in the missing values, which I can do, just for some reason this part seems to not want to work for me. This is for a school assignment and the teacher isn't being very helpful with answering questions.</p> <p>Here's my code: noting that (variable names are in French..)</p> <ol> <li>nbCases = total number of elements in the 2d array</li> <li>nbARemplir = number of elements in the 2nd array to have values assigned to them (based on nbCases * nbPourc where nbPourc is the percentage of the 2nd array to be assigned values)</li> <li>grille[][] = original array</li> <li><p>gui = second "array" (it's actually a 2d array of JButtons that the teacher wrote..syntax to add a value : gui.setValeur(i, j, value) )</p> <pre><code>int nbCases = grille.length * grille[0].length; int nbARemplir = (int)(nbCases * nbPourc); do{ for(int i = 0; i &lt; grille.length; i++) { for(int j = 0; j &lt; grille[i].length; j++) { if(rand.nextInt(2) == 1 &amp;&amp; nbARemplir &gt; 0) { gui.setValeur(i, j, "" + grille[i][j]); nbARemplir--; } } } } while(nbARemplir &gt; 0); </code></pre></li> </ol> <p>Thanks for your help! :)</p>
0debug
void virtio_init(VirtIODevice *vdev, const char *name, uint16_t device_id, size_t config_size) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); int i; int nvectors = k->query_nvectors ? k->query_nvectors(qbus->parent) : 0; if (nvectors) { vdev->vector_queues = g_malloc0(sizeof(*vdev->vector_queues) * nvectors); } vdev->device_id = device_id; vdev->status = 0; vdev->isr = 0; vdev->queue_sel = 0; vdev->config_vector = VIRTIO_NO_VECTOR; vdev->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_QUEUE_MAX); vdev->vm_running = runstate_is_running(); for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { vdev->vq[i].vector = VIRTIO_NO_VECTOR; vdev->vq[i].vdev = vdev; vdev->vq[i].queue_index = i; } vdev->name = name; vdev->config_len = config_size; if (vdev->config_len) { vdev->config = g_malloc0(config_size); } else { vdev->config = NULL; } vdev->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change, vdev); vdev->device_endian = virtio_default_endian(); vdev->use_guest_notifier_mask = true; }
1threat
static void pxa2xx_rtc_swupdate(PXA2xxRTCState *s) { int64_t rt = qemu_get_clock(rt_clock); if (s->rtsr & (1 << 12)) s->last_swcr += (rt - s->last_sw) / 10; s->last_sw = rt; }
1threat
Post files from ASP.NET Core web api to another ASP.NET Core web api : <p>We are building a web application that consist of an Angular2 frontend, a ASP.NET Core web api public backend, and a ASP.NET Core web api private backend.</p> <p>Uploading files from Angular2 to the public backend works. But we would prefer to post them forward to the private backend.</p> <p>Current working code</p> <pre><code>[HttpPost] public StatusCodeResult Post(IFormFile file) { ... } </code></pre> <p>From there I can save the file to disk using file.CopyTo(fileStream);</p> <p>However, I want to re-send that file, or those files, or, ideally, the whole request to my second web api core.</p> <p>I am not sure how to achieve this with the HttpClient class of asp.net core.</p> <p>I've tried all kinds of things such as</p> <pre><code>StreamContent ss = new StreamContent(HttpContext.Request.Body); var result = client.PostAsync("api/Values", ss).Result; </code></pre> <p>But my second backend gets an empty IFormFile.</p> <p>I have a feeling it is possible to send the file(s) as a stream and reconstruct them on the other side, but can't get it to work.</p> <p>The solution must use two web api core.</p>
0debug