problem
stringlengths
26
131k
labels
class label
2 classes
How to know whether I need @ in Razor Pages? : I want to know the rule when I have to use `@` in Razor pages. For example, <div asp-validation-summary="ModelOnly"> <input asp-for="Movie.ID" /> <label asp-for="Movie.Title" ></label> <span asp-validation-for="Movie.Title" > we don't need `@` but <a asp-page="Edit" asp-route-id="@Model.Movie.ID">Edit</a> we do need `@`. What is the rule?
0debug
I am not a programer, so I need your expertise on a macro with multiple "if" scenarios : Using Excel 2007, I am trying to do everything with one macro. Which is a combination of multiple if's. If E147="ESM7" and C147="Bot", then the value shown in O150, if not, then the value shown in Q150. But If E147="ESU7", then the value shown in O151, if not, then the value shown in Q151. So, there are 4 if scenarios, beginning with the main cell is ESM7 or ESU7 ,then depending if the next cell value is either a Bot or SLD. Thanks for your help.
0debug
Understanding "public" / "private" in typescript class : <p>In the below type script code , irrespective of whether name is "public" or "private" , java script code that is generated is same.</p> <p>So my question is, how to decide when the constructor parameter should be public or private ? </p> <pre><code>// typescript code class Animal { constructor( public name: string) { } } // generated JS code var Animal = (function () { function Animal(name) { this.name = name; } return Animal; }()); </code></pre>
0debug
Ajax forgot password error syntax : <p>I am having a syntax error for a form I have changed from PHP to using Jquery/Ajax. I am trying to test if form will work and submit to reset the password.</p> <p>I keep getting the below error</p> <p>syntax error, unexpected $end in <b>/home/a4358077/public_html/mod/forgotajax.php </b> on line <b>38</b><br /></p> <p>My code is -</p> <pre><code>&lt;?php require_once('../inc/autoload.php'); $objForm = new Form(); $objValid = new Validation($objForm); $objUser = new User(); // forgot password form if ($objForm-&gt;isPost('email')) { $objValid-&gt;_expected = array('email'); $objValid-&gt;_required = array('email'); $email = $objForm-&gt;getPost('email'); if (empty($email) || !$objValid-&gt;isEmail($email)) { $objValid-&gt;add2Errors('email'); } else { $user = $objUser-&gt;getByEmail($email); if (!empty($user)) { if ($objValid-&gt;isValid()) { if ($objUser-&gt;forgotUser($user)) { $url = !empty($url) ? $url : '/?page=forgotsuccess'; echo json_encode(array('error' =&gt; false, 'url' =&gt; $url)); } else { $url = !empty($url) ? $url : '/?page=forgot-failed'; //$message = 'Error in registration, Please contact administrator'; // failure $objValid-&gt;add2Errors('login'); echo json_encode(array('error' =&gt; true, 'validation' =&gt; $objValid-&gt;_error_messages)); } } else { echo json_encode(array('error' =&gt; true)); } </code></pre> <p>I have tried fixing the code but cannot figure out where to either put a curly brace.</p> <p>Any help is much appreciated. </p> <p>Thanks</p>
0debug
int nbd_client(int fd) { int ret; int serrno; TRACE("Doing NBD loop"); ret = ioctl(fd, NBD_DO_IT); if (ret == -1 && errno == EPIPE) { ret = 0; } serrno = errno; TRACE("NBD loop returned %d: %s", ret, strerror(serrno)); TRACE("Clearing NBD queue"); ioctl(fd, NBD_CLEAR_QUE); TRACE("Clearing NBD socket"); ioctl(fd, NBD_CLEAR_SOCK); errno = serrno; return ret; }
1threat
Typescript: Ignore imlicitly any type when importing js module : <p>In Typescript project I need to import some old js files that do module.exports inside of themselves.</p> <p>As i import:</p> <pre><code>import * as httpConnection from '...path...'; </code></pre> <p>I got errors from compiler:</p> <pre><code>Could not find a declaration file for module '...path...'. '...path...' implicitly has an 'any' type. </code></pre> <p>After that it works OK, but i need to avoid this error in console.</p> <p>How can I make compiler understand that import has any type without creating declaration file?</p> <p>Thanks for ideas in advance.</p>
0debug
void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, int64_t speed, uint32_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, BlockCompletionFunc *cb, void *opaque, Error **errp) { bool is_none_mode; BlockDriverState *base; if (mode == MIRROR_SYNC_MODE_INCREMENTAL) { error_setg(errp, "Sync mode 'incremental' not supported"); return; } is_none_mode = mode == MIRROR_SYNC_MODE_NONE; base = mode == MIRROR_SYNC_MODE_TOP ? backing_bs(bs) : NULL; mirror_start_job(job_id, bs, target, replaces, speed, granularity, buf_size, backing_mode, on_source_error, on_target_error, unmap, cb, opaque, errp, &mirror_job_driver, is_none_mode, base); }
1threat
Deploy path doesn't work for Git Deploy Method in middleman-deploy : <p>I am using <a href="https://github.com/middleman/middleman-blog" rel="noreferrer">middleman-blog</a> and <a href="https://github.com/middleman-contrib/middleman-deploy" rel="noreferrer">middleman-deploy</a>.</p> <p>What I would like to do, is within the branch I am deploying to, I want the static files to be deployed to a subfolder within the repo (i.e. not the root folder).</p> <p>I tried doing this in my <code>config.rb</code>:</p> <pre><code>activate :deploy do |deploy| deploy.build_before = true deploy.deploy_method = :git deploy.branch = 'gh-pages-2' deploy.remote = 'github' deploy.path = 'blog' end </code></pre> <p>But that doesn't work, it still deploys to the root directory. In fact, it doesn't even create the <code>/blog</code> folder I am looking for.</p> <p>When I visit the config settings locally, these are the settings I see under <code>:deploy</code>:</p> <pre><code>:deploy :branch = "gh-pages" :build_before = true :clean = false :commit_message = nil :deploy_method = :git :flags = nil :host = nil :password = nil :path = "blog" :port = 22 :remote = "github" :strategy = :force_push :user = nil </code></pre> <p>This indicates to me that the path attribute is being set correctly.</p> <p>I also tried doing <code>deploy.path = '/blog'</code> and that still doesn't work.</p> <p>So how can I get this to deploy to <code>\blog\</code> subfolder within my repo rather than the root directory?</p> <p>The versions of the different gems are as follows:</p> <pre><code>middleman (4.1.10) middleman-blog (4.0.1) middleman-cli (4.1.10) middleman-deploy (2.0.0.pre.alpha) </code></pre> <p><strong>Note:</strong> I am purposely using <code>gh-pages-2</code> because I don't want to overwrite my current <code>gh-pages</code> without being certain that it will deploy to the correct subfolder.</p>
0debug
static void nbd_teardown_connection(NbdClientSession *client) { shutdown(client->sock, 2); nbd_recv_coroutines_enter_all(client); nbd_client_session_detach_aio_context(client); closesocket(client->sock); client->sock = -1; }
1threat
Elasticsearch 2.1: Result window is too large (index.max_result_window) : <p>We retrieve information from Elasticsearch 2.1 and allow the user to page thru the results. When the user requests a high page number we get the following error message:</p> <blockquote> <p>Result window is too large, from + size must be less than or equal to: [10000] but was [10020]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level parameter</p> </blockquote> <p>The elastic docu says that this is because of high memory consumption and to use the scrolling api:</p> <blockquote> <p>Values higher than can consume significant chunks of heap memory per search and per shard executing the search. It’s safest to leave this value as it is an use the scroll api for any deep scrolling <a href="https://www.elastic.co/guide/en/elasticsearch/reference/2.x/breaking_21_search_changes.html#_from_size_limits">https://www.elastic.co/guide/en/elasticsearch/reference/2.x/breaking_21_search_changes.html#_from_size_limits</a></p> </blockquote> <p>The thing is that I do not want to retrieve large data sets. I only want to retrieve a slice from the data set which is very high up in the result set. Also the scrolling docu says:</p> <blockquote> <p>Scrolling is not intended for real time user requests <a href="https://www.elastic.co/guide/en/elasticsearch/reference/2.2/search-request-scroll.html">https://www.elastic.co/guide/en/elasticsearch/reference/2.2/search-request-scroll.html</a></p> </blockquote> <p>This leaves me with some questions: </p> <p>1) Would the memory consumption really be lower (any if so why) if I use the scrolling api to scroll up to result 10020 (and disregard everything below 10000) instead of doing a "normal" search request for result 10000-10020?</p> <p>2) It does not seem that the scrolling API is an option for me but that I have to increase "index.max_result_window". Does anyone have any experience with this?</p> <p>3) Are there any other options to solve my problem?</p>
0debug
static av_cold int libwebp_anim_encode_init(AVCodecContext *avctx) { int ret = ff_libwebp_encode_init_common(avctx); if (!ret) { LibWebPAnimContext *s = avctx->priv_data; WebPAnimEncoderOptions enc_options; WebPAnimEncoderOptionsInit(&enc_options); s->enc = WebPAnimEncoderNew(avctx->width, avctx->height, &enc_options); if (!s->enc) return AVERROR(EINVAL); s->prev_frame_pts = -1; s->done = 0; } return ret; }
1threat
I need help counting letters in each index of an array in Ruby : I am new to programming and to Ruby. I am having a problem with an Array. I have an Array of large words, I would like to get the letter count to print next to each word. Right now I get the words to print with a total of all letters to print at the end. Any guidance would be great. Thank you [enter image description here][1] [1]: https://i.stack.imgur.com/9y3Oi.png
0debug
javascript's object: Get only the first key of an object : <p>I'm trying currently to get only the first key of an object for my process. It would allow me to make some comparisons with the root of different objects. </p> <p>currently I use a loop and break at the first instance. Maybe there is more relevant way to achieve this goal? </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var objectKey var p = { "p1": "value1", "p2": "value2", "p3": "value3" }; for (var key in p) { if (p.hasOwnProperty(key)) { var objectKey=key; break } } console.log("the first key is: " + objectKey)</code></pre> </div> </div> </p> <p>any hint would be great, thanks </p>
0debug
Importing Quandl library into Android : <p>I am currently 3 months+ into programming and am trying to build an android app that takes data from Quandl. </p> <p>How do I import the Quandl library into my Android project? I have tried to search for answers - they typically tell me to add the .jar file, but there is no .jar file in the Quandl library here (taken from the link below).</p> <p><a href="https://github.com/jimmoores/quandl4j" rel="nofollow noreferrer">https://github.com/jimmoores/quandl4j</a></p> <p>Will really appreciate it if someone posts a step by step guide for a noob beginner like me. </p>
0debug
php vs MySQLi, Which one is faster : <p>I want to execute a query to fetch data from 1000 rows in my database. I have found two methods to do that.</p> <p>Method 1:</p> <pre><code>SELECT * FROM user WHERE id=879 </code></pre> <p>and second one which I used to protect myself from SQL Injection was:</p> <p>Method 2:</p> <pre><code>&lt;?php $q="SELECT * FROM user"; $get_res=$dbconn-&gt;query($q); while($set=$get_res-&gt;fetch_assoc()) { if($set['id']==879) { //Some task here } } </code></pre> <p>So Which one is faster. I know about SQL prepared Statement.. But I just want to compare these two method.. And if there will be any security flaw in Method2 then Please explain that one also..</p>
0debug
HOW TO CONVERT OBJECT INTO STRING : i am getting an output as object object but i want the record to be display in text[ i have upload an image where i have written a code ][1] field please help me. [1]: https://i.stack.imgur.com/9Pbco.png
0debug
static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) { unsupported_encoding(s, insn); }
1threat
static int au_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret; ret= av_get_packet(s->pb, pkt, BLOCK_SIZE * s->streams[0]->codec->channels * av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3); if (ret < 0) return ret; pkt->stream_index = 0; pkt->size = ret; return 0; }
1threat
case insensitive matching search in string array swift 3 : <p>In Swift 3, I want to create an array of matching string (case insensitive) from string array:-</p> <p>I am using this code, but it is case sensitive, </p> <pre><code>let filteredArray = self.arrCountry.filter { $0.contains("india") } </code></pre> <p>how can I do this.. suppose I have a master string array called arrCountry, I want to create other array of all the string who has "india"(case insensitive) in it. </p> <p>Can anyone help me out.</p>
0debug
static int v9fs_receive_status(V9fsProxy *proxy, struct iovec *reply, int *status) { int retval; ProxyHeader header; *status = 0; reply->iov_len = 0; retval = socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ); if (retval < 0) { return retval; } reply->iov_len = PROXY_HDR_SZ; proxy_unmarshal(reply, 0, "dd", &header.type, &header.size); if (header.size != sizeof(int)) { *status = -ENOBUFS; return 0; } retval = socket_read(proxy->sockfd, reply->iov_base + PROXY_HDR_SZ, header.size); if (retval < 0) { return retval; } reply->iov_len += header.size; proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status); return 0; }
1threat
Why is implicit conversion not ambiguous for non-primitive types? : <p>Given a simple class template with multiple implicit conversion functions (non-explicit constructor and conversion operator), as in the following example:</p> <pre><code>template&lt;class T&gt; class Foo { private: T m_value; public: Foo(); Foo(const T&amp; value): m_value(value) { } operator T() const { return m_value; } bool operator==(const Foo&lt;T&gt;&amp; other) const { return m_value == other.m_value; } }; struct Bar { bool m; bool operator==(const Bar&amp; other) const { return false; } }; int main(int argc, char *argv[]) { Foo&lt;bool&gt; a (true); bool b = false; if(a == b) { // This is ambiguous } Foo&lt;int&gt; c (1); int d = 2; if(c == d) { // This is ambiguous } Foo&lt;Bar&gt; e (Bar{true}); Bar f = {false}; if(e == f) { // This is not ambiguous. Why? } } </code></pre> <p>The comparison operators involving primitive types (<code>bool</code>, <code>int</code>) are ambiguous, as expected - the compiler does not know whether it should use the conversion operator to convert the left-hand template class instance to a primitive type or use the conversion constructor to convert the right-hand primitive type to the expected class template instance.</p> <p>However, the last comparison, involving a simple <code>struct</code>, is not ambiguous. Why? Which conversion function will be used?</p> <p>Tested with compiler msvc 15.9.7.</p>
0debug
php5 OOP INCLUDE HTML TEMPLATE : Am having issues with this and was informed PHP5 OOP doesn't allow include statement in classes? Just verifying if this is right or wrong advice, and if right is this resolved in PHP7.
0debug
static av_cold int ffat_close_encoder(AVCodecContext *avctx) { ATDecodeContext *at = avctx->priv_data; AudioConverterDispose(at->converter); av_frame_unref(&at->new_in_frame); av_frame_unref(&at->in_frame); ff_af_queue_close(&at->afq); return 0; }
1threat
iPhone X hide home indicator on view controller : <p>I have a view controller that takes up the whole screen from top to bottom. I would like to hide the home bar indicator on the bottom of the screen on iPhone X devices. </p> <p>How can I do this in iOS 11?</p>
0debug
Where is Illuminate? : <p>Every time when I try to do some modifications in certain area, <em>Authentication for example</em>, I end up finding everything is declared in <code>Illuminate\Foundation\...</code>.</p> <p>Okay, now all I need to do is get to that location and look into some codes.</p> <p>But hey, where is this <code>Illuminate</code> and all stuff???</p> <p>I don't see any folders named Illuminate anywhere in my Laravel package.</p> <p>Tried to search for the solution but I guess I'm the only silly person who lacks ability in understanding some basics.</p>
0debug
Using operators (like <<) on shared_ptr : <p>I have an FStream that because of other project constraints exists as a <code>std::shared_ptr&lt;std::fstream&gt;</code>.</p> <p>I would like to write to this stream using the <code>&lt;&lt;</code> operator, but I cannot find the correct syntax for writing to the member of a shared pointer.</p>
0debug
static int qcrypto_cipher_setiv_aes(QCryptoCipher *cipher, const uint8_t *iv, size_t niv, Error **errp) { QCryptoCipherBuiltin *ctxt = cipher->opaque; if (niv != 16) { error_setg(errp, "IV must be 16 bytes not %zu", niv); return -1; } g_free(ctxt->state.aes.iv); ctxt->state.aes.iv = g_new0(uint8_t, niv); memcpy(ctxt->state.aes.iv, iv, niv); ctxt->state.aes.niv = niv; return 0; }
1threat
C++ Program Bug? : <pre><code>#include &lt;iostream&gt; #include &lt;cmath&gt; #include &lt;string&gt; using namespace std; string fullName, honorsRank, className; int year; int testScore1, testScore2, testScore3, testScore4, testScore5; int avgScore; int main() { // Retrieve students name cout &lt;&lt; "Please enter your full name: " &lt;&lt; endl; cin &gt;&gt; fullName; // Retrieve students year of high school cout &lt;&lt; "Please indicate which year of High School you are currently in: " &lt;&lt; endl;; cin &gt;&gt; year; // As for all five test scores cout &lt;&lt; "Please enter your score for your first exam: " &lt;&lt; endl; cin &gt;&gt; testScore1; cout &lt;&lt; "Please enter your score for your second exam: " &lt;&lt; endl; cin &gt;&gt; testScore2; cout &lt;&lt; "Please enter your score for your third exam: " &lt;&lt; endl; cin &gt;&gt; testScore3; cout &lt;&lt; "Please enter your score for your fourth exam: " &lt;&lt; endl; cin &gt;&gt; testScore4; cout &lt;&lt; "Please enter your score for your fifth exam: " &lt;&lt; endl; cin &gt;&gt; testScore5; //Compute the average score of the five tests avgScore = (testScore1 + testScore2 + testScore3 + testScore4 + testScore5)/5; // Assign either freshman, sophomore, junior, or senior to the numbered year of high school if (year == 1) className = "Freshman"; else if (year == 2) className = "Sophomore"; else if (year == 3) className = "Junior"; else if (year == 4) className = "Senior"; cout &lt;&lt; "Name........ " &lt;&lt; fullName &lt;&lt; endl; cout &lt;&lt; "Year........ " &lt;&lt; className &lt;&lt; endl; cout &lt;&lt; "Scores...... " &lt;&lt; testScore1 &lt;&lt; " " &lt;&lt; testScore2 &lt;&lt; " " &lt;&lt; testScore3 &lt;&lt; " " &lt;&lt;testScore4 &lt;&lt; " " &lt;&lt; testScore5 &lt;&lt; endl; cout &lt;&lt; "Average..... " &lt;&lt; avgScore &lt;&lt; endl; // Determine students academic standing if (avgScore &gt;= 97.0 &amp;&amp; year == 4) { honorsRank = "**High Honors**", cout &lt;&lt; honorsRank &lt;&lt; " Note: This student IS ELIGIBLE for graduation" &lt;&lt; endl; } else if (avgScore &gt;= 95.0 &amp;&amp; year == 4) { honorsRank = "**Honors**", cout &lt;&lt; honorsRank &lt;&lt; " Note: This student IS ELIGIBLE for graduation" &lt;&lt; endl; } else if (avgScore &gt;= 90.0 &amp;&amp; year == 4) { honorsRank = "**Honorable Mention**", cout &lt;&lt; honorsRank &lt;&lt; " Note: This student IS ELIGIBLE for graduation" &lt;&lt; endl; } else if (avgScore &gt; 65 &amp;&amp; year == 4) { cout &lt;&lt; "Note: This student IS ELIGIBLE for graduation" &lt;&lt; endl; } else if (avgScore &lt; 65.0 &amp;&amp; year == 4) { cout &lt;&lt; "Note: This student is NOT ELIGIBLE for graduation" &lt;&lt; endl; } else if (avgScore &gt;= 97.0 &amp;&amp; year &lt; 4) { honorsRank = "**High Honors**", cout &lt;&lt; honorsRank &lt;&lt; " Great work!! Keep it up!!" &lt;&lt; endl; } else if (avgScore &gt;= 95.0 &amp;&amp; year &lt; 4) { honorsRank = "**Honors**", cout &lt;&lt; honorsRank &lt;&lt; " Great effort!!" &lt;&lt; endl; } else if (avgScore &gt;= 90.0 &amp;&amp; year &lt; 4) { honorsRank = "**Honorable Mention**", cout &lt;&lt; honorsRank &lt;&lt; " Nice job!" &lt;&lt; endl; } else if (avgScore &lt; 65.0 &amp;&amp; year &lt; 4) { cout &lt;&lt; "Note: This student has been placed on academic probation" &lt;&lt; endl; } return 0; } </code></pre> <p>So I know that the program runs as I intended it to (<a href="https://imgur.com/a/YIqa0" rel="nofollow noreferrer">https://imgur.com/a/YIqa0</a>) but when I type in a full name for someone with 2 words, it completely messes up the program (<a href="https://imgur.com/a/fy62N" rel="nofollow noreferrer">https://imgur.com/a/fy62N</a>).</p> <p>For some reason entering a first and last name messes up the program and causes all of the cout statements to display and it won't let you enter anything in the text fields.</p> <p>Any advice/tips?</p> <p>Also I'm more of a beginner C++ programmer if you couldn't tell, so please don't get too annoyed by any idiotic mistakes if you see any :))</p>
0debug
iOS: Is it possible to Programatically disconnect a call? : Is it possible to disconnect a call programmatically? I know call kit can be used to make VOIP calls/ block users but is it possible to install an app and lets say user is busy and just by enabling a flag in the app just send them all to voicemail or disconnect without user interaction?
0debug
Convert Number in Java : <p>I need help How to round number in java I have value 0.655308 then I wan to show to 65.53% I have value 1.0583104 then I wan to show 105.83 in power builder compute expression I use </p> <pre><code> act_qty *work_hour / if (on_hour &lt; work_hour ) / sec_setm_gole_qty ,4) </code></pre> <p>and How to run in java Thanks for advanced</p>
0debug
Coroutine *qemu_coroutine_create(CoroutineEntry *entry) { Coroutine *co = NULL; if (CONFIG_COROUTINE_POOL) { co = QSLIST_FIRST(&alloc_pool); if (!co) { if (release_pool_size > POOL_BATCH_SIZE) { if (!coroutine_pool_cleanup_notifier.notify) { coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup; qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier); } alloc_pool_size = atomic_xchg(&release_pool_size, 0); QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool); co = QSLIST_FIRST(&alloc_pool); } } if (co) { QSLIST_REMOVE_HEAD(&alloc_pool, pool_next); alloc_pool_size--; } } if (!co) { co = qemu_coroutine_new(); } co->entry = entry; QSIMPLEQ_INIT(&co->co_queue_wakeup); return co; }
1threat
static void invalidate_and_set_dirty(target_phys_addr_t addr, target_phys_addr_t length) { if (!cpu_physical_memory_is_dirty(addr)) { tb_invalidate_phys_page_range(addr, addr + length, 0); cpu_physical_memory_set_dirty_flags(addr, (0xff & ~CODE_DIRTY_FLAG)); } xen_modified_memory(addr, length); }
1threat
void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, int is_asi, int size) { CPUState *saved_env; int fault_type; saved_env = env; env = cpu_single_env; #ifdef DEBUG_UNASSIGNED if (is_asi) printf("Unassigned mem %s access of %d byte%s to " TARGET_FMT_plx " asi 0x%02x from " TARGET_FMT_lx "\n", is_exec ? "exec" : is_write ? "write" : "read", size, size == 1 ? "" : "s", addr, is_asi, env->pc); else printf("Unassigned mem %s access of %d byte%s to " TARGET_FMT_plx " from " TARGET_FMT_lx "\n", is_exec ? "exec" : is_write ? "write" : "read", size, size == 1 ? "" : "s", addr, env->pc); #endif fault_type = (env->mmuregs[3] & 0x1c) >> 2; if ((fault_type > 4) || (fault_type == 0)) { env->mmuregs[3] = 0; if (is_asi) env->mmuregs[3] |= 1 << 16; if (env->psrs) env->mmuregs[3] |= 1 << 5; if (is_exec) env->mmuregs[3] |= 1 << 6; if (is_write) env->mmuregs[3] |= 1 << 7; env->mmuregs[3] |= (5 << 2) | 2; if (!is_exec) { env->mmuregs[4] = addr; } } if (fault_type == ((env->mmuregs[3] & 0x1c)) >> 2) { env->mmuregs[3] |= 1; } if ((env->mmuregs[0] & MMU_E) && !(env->mmuregs[0] & MMU_NF)) { if (is_exec) raise_exception(TT_CODE_ACCESS); else raise_exception(TT_DATA_ACCESS); } if (env->mmuregs[0] & MMU_NF) { tlb_flush(env, 1); } env = saved_env; }
1threat
Regex help not to match email id : {code} By Mel An, abf@abc.com By Dem, abc.com / Abc By Sam, John, Todd, and John By Jer {code} Please help in the regex, which matches only till email id and not the email id. It should all the text other than first one. i.e By Mel An, By Dem, abc.com / Abc By Sam, John, Todd, and John By Jer
0debug
Can anuone explain the below code How it works? : I have a custom class that has overridden hashcode() and equals() method class Employee1{ private int id; public int getId() { return id; } public void setId(int id) { this.id = id; } public Employee1(int id) { super(); this.id = id; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + id; return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Employee1 other = (Employee1) obj; if (id != other.id) return false; return true; } } and in main class I am using a Map having Object as Key Map<Integer,Employee1> g = new HashMap<>(); Employee1 e = new Employee1(1); Employee1 e1 = new Employee1(2); g.put(1, e); g.put(2, e1); Employee1 e4 = g.get(1); e4.setId(3); for(Map.Entry<Integer,Employee1> e3:g.entrySet()) { System.out.println(e3.getKey()+" "+e3.getValue().getId()); } my question is how come the key of the map is changed even though I have overridden hashcode and equals methods,key should be same but I am able to get and set the id and its reflecting in the map The o/p for above code is 1 3 2 2
0debug
void HELPER(entry)(CPUXtensaState *env, uint32_t pc, uint32_t s, uint32_t imm) { int callinc = (env->sregs[PS] & PS_CALLINC) >> PS_CALLINC_SHIFT; if (s > 3 || ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) != 0) { qemu_log("Illegal entry instruction(pc = %08x), PS = %08x\n", pc, env->sregs[PS]); HELPER(exception_cause)(env, pc, ILLEGAL_INSTRUCTION_CAUSE); } else { env->regs[(callinc << 2) | (s & 3)] = env->regs[s] - (imm << 3); rotate_window(env, callinc); env->sregs[WINDOW_START] |= windowstart_bit(env->sregs[WINDOW_BASE], env);
1threat
static void vfio_enable_intx_kvm(VFIODevice *vdev) { #ifdef CONFIG_KVM struct kvm_irqfd irqfd = { .fd = event_notifier_get_fd(&vdev->intx.interrupt), .gsi = vdev->intx.route.irq, .flags = KVM_IRQFD_FLAG_RESAMPLE, }; struct vfio_irq_set *irq_set; int ret, argsz; int32_t *pfd; if (!kvm_irqfds_enabled() || vdev->intx.route.mode != PCI_INTX_ENABLED || !kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) { return; } qemu_set_fd_handler(irqfd.fd, NULL, NULL, vdev); vfio_mask_intx(vdev); vdev->intx.pending = false; qemu_set_irq(vdev->pdev.irq[vdev->intx.pin], 0); if (event_notifier_init(&vdev->intx.unmask, 0)) { error_report("vfio: Error: event_notifier_init failed eoi"); goto fail; } irqfd.resamplefd = event_notifier_get_fd(&vdev->intx.unmask); if (kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd)) { error_report("vfio: Error: Failed to setup resample irqfd: %m"); goto fail_irqfd; } argsz = sizeof(*irq_set) + sizeof(*pfd); irq_set = g_malloc0(argsz); irq_set->argsz = argsz; irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK; irq_set->index = VFIO_PCI_INTX_IRQ_INDEX; irq_set->start = 0; irq_set->count = 1; pfd = (int32_t *)&irq_set->data; *pfd = irqfd.resamplefd; ret = ioctl(vdev->fd, VFIO_DEVICE_SET_IRQS, irq_set); g_free(irq_set); if (ret) { error_report("vfio: Error: Failed to setup INTx unmask fd: %m"); goto fail_vfio; } vfio_unmask_intx(vdev); vdev->intx.kvm_accel = true; DPRINTF("%s(%04x:%02x:%02x.%x) KVM INTx accel enabled\n", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); return; fail_vfio: irqfd.flags = KVM_IRQFD_FLAG_DEASSIGN; kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd); fail_irqfd: event_notifier_cleanup(&vdev->intx.unmask); fail: qemu_set_fd_handler(irqfd.fd, vfio_intx_interrupt, NULL, vdev); vfio_unmask_intx(vdev); #endif }
1threat
How to find the length of a path between two nodes in a tree? : <p>I want to calculate the path between two arbitrary nodes in a tree (implemented in Java). Are there in literature any solutions?</p>
0debug
ObjectsSystem.InvalidCastException: Object must implement IConvertible - Xamarin : I came across this error 4 days ago and decided to skip and continue my app but well i am back it with no solution yet. I get this error `System.InvalidCastException: Object must implement IConvertible` in my adapter extended to a baseAdapter specifically in my `GetView function`. If any has come across this issue could be please help me out. I have been at this for a while now. What can i do to solve this? How must i implement IConvertible?
0debug
Creating a list from a range of numbers in Python : <p>I am trying to create a list of size 9 (but that can change) which is populated with numbers from the range of [-pi/2,pi/2] where basically the range is split into 9 numbers and those 9 numbers are what the list is populated with.</p>
0debug
static int default_qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, IOHandler *fd_read, IOHandler *fd_write, void *opaque) { abort(); }
1threat
static void nvdimm_build_fit(Aml *dev) { Aml *method, *pkg, *buf, *buf_size, *offset, *call_result; Aml *whilectx, *ifcond, *ifctx, *elsectx, *fit; buf = aml_local(0); buf_size = aml_local(1); fit = aml_local(2); aml_append(dev, aml_create_dword_field(aml_buffer(4, NULL), aml_int(0), NVDIMM_DSM_RFIT_STATUS)); method = aml_method("RFIT", 1, AML_SERIALIZED); aml_append(method, aml_create_dword_field(aml_buffer(4, NULL), aml_int(0), "OFST")); pkg = aml_package(1); aml_append(method, aml_store(aml_arg(0), aml_name("OFST"))); aml_append(pkg, aml_name("OFST")); call_result = aml_call5(NVDIMM_COMMON_DSM, aml_touuid(NVDIMM_QEMU_RSVD_UUID), aml_int(1) , aml_int(0x1) , pkg, aml_int(NVDIMM_QEMU_RSVD_HANDLE_ROOT)); aml_append(method, aml_store(call_result, buf)); aml_append(method, aml_create_dword_field(buf, aml_int(0) , "STAU")); aml_append(method, aml_store(aml_name("STAU"), aml_name(NVDIMM_DSM_RFIT_STATUS))); ifcond = aml_equal(aml_int(NVDIMM_DSM_RET_STATUS_SUCCESS), aml_name("STAU")); ifctx = aml_if(aml_lnot(ifcond)); aml_append(ifctx, aml_return(aml_buffer(0, NULL))); aml_append(method, ifctx); aml_append(method, aml_store(aml_sizeof(buf), buf_size)); aml_append(method, aml_subtract(buf_size, aml_int(4) , buf_size)); ifctx = aml_if(aml_equal(buf_size, aml_int(0))); aml_append(ifctx, aml_return(aml_buffer(0, NULL))); aml_append(method, ifctx); aml_append(method, aml_create_field(buf, aml_int(4 * BITS_PER_BYTE), aml_shiftleft(buf_size, aml_int(3)), "BUFF")); aml_append(method, aml_return(aml_name("BUFF"))); aml_append(dev, method); method = aml_method("_FIT", 0, AML_SERIALIZED); offset = aml_local(3); aml_append(method, aml_store(aml_buffer(0, NULL), fit)); aml_append(method, aml_store(aml_int(0), offset)); whilectx = aml_while(aml_int(1)); aml_append(whilectx, aml_store(aml_call1("RFIT", offset), buf)); aml_append(whilectx, aml_store(aml_sizeof(buf), buf_size)); ifctx = aml_if(aml_equal(aml_name(NVDIMM_DSM_RFIT_STATUS), aml_int(NVDIMM_DSM_RET_STATUS_FIT_CHANGED))); aml_append(ifctx, aml_store(aml_buffer(0, NULL), fit)); aml_append(ifctx, aml_store(aml_int(0), offset)); aml_append(whilectx, ifctx); elsectx = aml_else(); ifctx = aml_if(aml_equal(buf_size, aml_int(0))); aml_append(ifctx, aml_return(fit)); aml_append(elsectx, ifctx); aml_append(elsectx, aml_add(offset, buf_size, offset)); aml_append(elsectx, aml_concatenate(fit, buf, fit)); aml_append(whilectx, elsectx); aml_append(method, whilectx); aml_append(dev, method); }
1threat
static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIConfigReadFunc *config_read = pc->config_read; PCIConfigWriteFunc *config_write = pc->config_write; AddressSpace *dma_as; if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn += PCI_FUNC_MAX) { if (!bus->devices[devfn]) goto found; } error_report("PCI: no slot/function available for %s, all in use", name); return NULL; found: ; } else if (bus->devices[devfn]) { error_report("PCI: slot %d function %d not available for %s, in use by %s", PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name); return NULL; } pci_dev->bus = bus; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, OBJECT(pci_dev), "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev); pci_config_set_vendor_id(pci_dev->config, pc->vendor_id); pci_config_set_device_id(pci_dev->config, pc->device_id); pci_config_set_revision(pci_dev->config, pc->revision); pci_config_set_class(pci_dev->config, pc->class_id); if (!pc->is_bridge) { if (pc->subsystem_vendor_id || pc->subsystem_id) { pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, pc->subsystem_vendor_id); pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, pc->subsystem_id); } else { pci_set_default_subsystem_id(pci_dev); } } else { assert(!pc->subsystem_vendor_id); assert(!pc->subsystem_id); } pci_init_cmask(pci_dev); pci_init_wmask(pci_dev); pci_init_w1cmask(pci_dev); if (pc->is_bridge) { pci_init_mask_bridge(pci_dev); } if (pci_init_multifunction(bus, pci_dev)) { pci_config_free(pci_dev); return NULL; } if (!config_read) config_read = pci_default_read_config; if (!config_write) config_write = pci_default_write_config; pci_dev->config_read = config_read; pci_dev->config_write = config_write; bus->devices[devfn] = pci_dev; pci_dev->version_id = 2; return pci_dev; }
1threat
int show_formats(void *optctx, const char *opt, const char *arg) { AVInputFormat *ifmt = NULL; AVOutputFormat *ofmt = NULL; const char *last_name; printf("File formats:\n" " D. = Demuxing supported\n" " .E = Muxing supported\n" " --\n"); last_name = "000"; for (;;) { int decode = 0; int encode = 0; const char *name = NULL; const char *long_name = NULL; while ((ofmt = av_oformat_next(ofmt))) { if ((name == NULL || strcmp(ofmt->name, name) < 0) && strcmp(ofmt->name, last_name) > 0) { name = ofmt->name; long_name = ofmt->long_name; encode = 1; } } while ((ifmt = av_iformat_next(ifmt))) { if ((name == NULL || strcmp(ifmt->name, name) < 0) && strcmp(ifmt->name, last_name) > 0) { name = ifmt->name; long_name = ifmt->long_name; encode = 0; } if (name && strcmp(ifmt->name, name) == 0) decode = 1; } if (name == NULL) break; last_name = name; printf(" %s%s %-15s %s\n", decode ? "D" : " ", encode ? "E" : " ", name, long_name ? long_name:" "); } return 0; }
1threat
Migration of Small Parse IDs to normal MongoDB's ObjectIDs : <p>I am using Parse Dashboard for User Management of my iOS Application.Also, I am using external APIs which are using MongoDB database.</p> <p>The issue currently I am facing is the User created from Parse Dashboard is having small id instead of MongoDB's ObjectID, and other resources which are not over parse are generated by normal ObjectID.</p> <p>eg. <strong>User Object:</strong></p> <pre><code>{ _id:"qVnyrGynJE", user_name:"Aditya Raval" } </code></pre> <p><strong>Document Object:</strong></p> <pre><code>{ _id:"507f191e810c19729de860ea", doc_name:"Marksheet", user:"qVnyrGynJE" } </code></pre> <p><strong>Task Object:</strong></p> <pre><code>{ _id:"507f191e810c19729de860ea", task_name:"Marksheet", user:"qVnyrGynJE" } </code></pre> <p>I am also using Keystone.js as a Backend Admin Dashboard.So basically due to this mix kind of IDs relationships inside KeyStone.js is broken and Keystone.js gets crashed.</p> <p>So I want to migrate all my existing small IDs to normal MongoDB ObjectIDs without breaking into relationships or any other walkthrough by fixing Keystone.js</p>
0debug
Getting "TypeError: float() argument must be a string or a number" with pandas plot() : <p>I am going thru simple pandas tutorial. And I am trying to plot DataFrame indexed by dtype='datetime64[ns]', however, when I try to plot, I assume the matplotlib attempts to convert the date to float, which raises an exception.</p> <pre><code>&gt;&gt;&gt; df.index DatetimeIndex(['2012-01-01', '2012-01-02', '2012-01-03', '2012-01-04', '2012-01-05', '2012-01-06', '2012-01-07', '2012-01-08', '2012-01-09', '2012-01-10', ... '2012-12-22', '2012-12-23', '2012-12-24', '2012-12-25', '2012-12-26', '2012-12-27', '2012-12-28', '2012-12-29', '2012-12-30', '2012-12-31'], dtype='datetime64[ns]', name=u'Date', length=366, freq=None) &gt;&gt;&gt; df.plot() Traceback (most recent call last): ... File "/usr/local/lib/python2.7/dist-packages/matplotlib/lines.py", line 676, in recache x = np.asarray(xconv, np.float_) File "/usr/local/lib/python2.7/dist-packages/numpy/core/numeric.py", line 531, in asarray return array(a, dtype, copy=False, order=order) TypeError: float() argument must be a string or a number </code></pre> <p>What am I doing wrong?</p> <p>note: I am following very simple tutorial here: <a href="http://nbviewer.jupyter.org/github/jvns/pandas-cookbook/blob/v0.1/cookbook/Chapter%201%20-%20Reading%20from%20a%20CSV.ipynb" rel="nofollow noreferrer">http://nbviewer.jupyter.org/github/jvns/pandas-cookbook/blob/v0.1/cookbook/Chapter%201%20-%20Reading%20from%20a%20CSV.ipynb</a></p>
0debug
Cannot access $_GET variable from MVC : I have been following a course on Udemy.com and I have been stuck for a few days with no help from the instructor. My controller works as follows: htaccess: `RewriteRule ^([a-zA-Z]*)/?([a-zA-Z]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&id=$3 [NC,L]` As you can see, the url is broken up into controller/action/id. This all works great, but the problem here is that when I try to pass a get variable into the URL it won't recognize it. The image below shows what I mean: [Image][1] Any help would really be appreciated, I have been picking at my brain for a few days [1]: https://i.stack.imgur.com/bodKz.png
0debug
av_cold int ff_nvenc_encode_init(AVCodecContext *avctx) { int ret; if ((ret = nvenc_load_libraries(avctx)) < 0) return ret; if ((ret = nvenc_setup_device(avctx)) < 0) return ret; if ((ret = nvenc_setup_encoder(avctx)) < 0) return ret; if ((ret = nvenc_setup_surfaces(avctx)) < 0) return ret; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { if ((ret = nvenc_setup_extradata(avctx)) < 0) return ret; } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); return 0; }
1threat
i want that more files like ppt,docx,txt using directory.getfiles() method : it does work but not complete my need. i want that more files like ppt,docx,txt using directory.getfiles() method. private void button2_Click(object sender, EventArgs e) { listView1.Items.Clear(); if (textBox1.Text != "") { List<string> files = new List<string>(); files = Directory.GetFiles(textBox1.Text, "*.txt,*.ppt").ToList(); progressBar1.Maximum = files.Count; progressBar1.Value = 0; ListViewItem it; foreach (var file in files) { it = new ListViewItem(file.ToString()); it.SubItems.Add(System.IO.Path.GetFileName(file.ToString())); it.SubItems.Add(System.IO.Path.GetExtension(file.ToString())); listView1.Items.Add(it); progressBar1.Increment(1); } } else MessageBox.Show("Select diroctery first"); }
0debug
static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){ int y_size = s->b8_stride * (2 * s->mb_height + 1); int c_size = s->mb_stride * (s->mb_height + 1); int yc_size = y_size + 2 * c_size; int i; FF_ALLOCZ_OR_GOTO(s->avctx, s->allocated_edge_emu_buffer, (s->width+64)*2*21*2, fail); s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21; FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, (s->width+64)*4*16*2*sizeof(uint8_t), fail) s->me.temp= s->me.scratchpad; s->rd_scratchpad= s->me.scratchpad; s->b_scratchpad= s->me.scratchpad; s->obmc_scratchpad= s->me.scratchpad + 16; if (s->encoding) { FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map , ME_MAP_SIZE*sizeof(uint32_t), fail) FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, ME_MAP_SIZE*sizeof(uint32_t), fail) if(s->avctx->noise_reduction){ FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, 2 * 64 * sizeof(int), fail) } } FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64*12*2 * sizeof(DCTELEM), fail) s->block= s->blocks[0]; for(i=0;i<12;i++){ s->pblocks[i] = &s->block[i]; } if (s->out_format == FMT_H263) { FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail); s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; s->ac_val[2] = s->ac_val[1] + c_size; } return 0; fail: return -1; }
1threat
static void sm501_draw_crt(SM501State *s) { DisplaySurface *surface = qemu_console_surface(s->con); int y, c_x = 0, c_y = 0; uint8_t *hwc_src = NULL, *src = s->local_mem; int width = get_width(s, 1); int height = get_height(s, 1); int src_bpp = get_bpp(s, 1); int dst_bpp = surface_bytes_per_pixel(surface); uint32_t *palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE - SM501_DC_PANEL_PALETTE]; uint8_t hwc_palette[3 * 3]; int ds_depth_index = get_depth_index(surface); draw_line_func *draw_line = NULL; draw_hwc_line_func *draw_hwc_line = NULL; int full_update = 0; int y_start = -1; ram_addr_t page_min = ~0l; ram_addr_t page_max = 0l; ram_addr_t offset = 0; switch (src_bpp) { case 1: draw_line = draw_line8_funcs[ds_depth_index]; break; case 2: draw_line = draw_line16_funcs[ds_depth_index]; break; case 4: draw_line = draw_line32_funcs[ds_depth_index]; break; default: printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n", s->dc_crt_control); abort(); break; } if (is_hwc_enabled(s, 1)) { draw_hwc_line = draw_hwc_line_funcs[ds_depth_index]; hwc_src = get_hwc_address(s, 1); c_x = get_hwc_x(s, 1); c_y = get_hwc_y(s, 1); get_hwc_palette(s, 1, hwc_palette); } if (s->last_width != width || s->last_height != height) { qemu_console_resize(s->con, width, height); surface = qemu_console_surface(s->con); s->last_width = width; s->last_height = height; full_update = 1; } memory_region_sync_dirty_bitmap(&s->local_mem_region); for (y = 0; y < height; y++) { int update, update_hwc; ram_addr_t page0 = offset; ram_addr_t page1 = offset + width * src_bpp - 1; update_hwc = draw_hwc_line && c_y <= y && y < c_y + SM501_HWC_HEIGHT; update = full_update || update_hwc; update |= memory_region_get_dirty(&s->local_mem_region, page0, page1 - page0, DIRTY_MEMORY_VGA); if (update) { uint8_t *d = surface_data(surface); d += y * width * dst_bpp; draw_line(d, src, width, palette); if (update_hwc) { draw_hwc_line(d, hwc_src, width, hwc_palette, c_x, y - c_y); } if (y_start < 0) { y_start = y; } if (page0 < page_min) { page_min = page0; } if (page1 > page_max) { page_max = page1; } } else { if (y_start >= 0) { dpy_gfx_update(s->con, 0, y_start, width, y - y_start); y_start = -1; } } src += width * src_bpp; offset += width * src_bpp; } if (y_start >= 0) { dpy_gfx_update(s->con, 0, y_start, width, y - y_start); } if (page_min != ~0l) { memory_region_reset_dirty(&s->local_mem_region, page_min, page_max + TARGET_PAGE_SIZE, DIRTY_MEMORY_VGA); } }
1threat
How to detect first launch in react-native : <p>What is a good way to detect the first and initial launch of an react-native app, in order to show an on-boarding/introductory screen ?</p>
0debug
facebook graph api not work from 2.2 to 2.3 : <p>Because it's due date for graph api 2.2, I'm trying fix my graph api using v2.3 But I discover most api request response nothing when I use 2.3, but I can not found any update for this in the upgrade document. For example:</p> <pre><code>https://graph.facebook.com/v2.3/{$user_id}?date_format=U&amp;fields=albums.order(reverse_chronological).limit(100).offset(0){id,count,name,created_time} </code></pre> <p>will return nothing if I use 2.3. And I can't get user's birthday when I call:</p> <pre><code>https://graph.facebook.com/v2.3/{$user_id} </code></pre> <p>It's only return name and live location. But in v2.2, it include birthday profile.</p> <p>I use facebook SDK 3.2.2 because my php version is 5.3. Is there any update that I don't know? Thanks.</p>
0debug
int block_signals(void) { TaskState *ts = (TaskState *)thread_cpu->opaque; sigset_t set; int pending; sigfillset(&set); sigprocmask(SIG_SETMASK, &set, 0); pending = atomic_xchg(&ts->signal_pending, 1); return pending; }
1threat
static void render_memory_region(FlatView *view, MemoryRegion *mr, Int128 base, AddrRange clip, bool readonly) { MemoryRegion *subregion; unsigned i; hwaddr offset_in_region; Int128 remain; Int128 now; FlatRange fr; AddrRange tmp; if (!mr->enabled) { return; } int128_addto(&base, int128_make64(mr->addr)); readonly |= mr->readonly; tmp = addrrange_make(base, mr->size); if (!addrrange_intersects(tmp, clip)) { return; } clip = addrrange_intersection(tmp, clip); if (mr->alias) { int128_subfrom(&base, int128_make64(mr->alias->addr)); int128_subfrom(&base, int128_make64(mr->alias_offset)); render_memory_region(view, mr->alias, base, clip, readonly); return; } QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) { render_memory_region(view, subregion, base, clip, readonly); } if (!mr->terminates) { return; } offset_in_region = int128_get64(int128_sub(clip.start, base)); base = clip.start; remain = clip.size; for (i = 0; i < view->nr && int128_nz(remain); ++i) { if (int128_ge(base, addrrange_end(view->ranges[i].addr))) { continue; } if (int128_lt(base, view->ranges[i].addr.start)) { now = int128_min(remain, int128_sub(view->ranges[i].addr.start, base)); fr.mr = mr; fr.offset_in_region = offset_in_region; fr.addr = addrrange_make(base, now); fr.dirty_log_mask = mr->dirty_log_mask; fr.romd_mode = mr->romd_mode; fr.readonly = readonly; flatview_insert(view, i, &fr); ++i; int128_addto(&base, now); offset_in_region += int128_get64(now); int128_subfrom(&remain, now); } now = int128_sub(int128_min(int128_add(base, remain), addrrange_end(view->ranges[i].addr)), base); int128_addto(&base, now); offset_in_region += int128_get64(now); int128_subfrom(&remain, now); } if (int128_nz(remain)) { fr.mr = mr; fr.offset_in_region = offset_in_region; fr.addr = addrrange_make(base, remain); fr.dirty_log_mask = mr->dirty_log_mask; fr.romd_mode = mr->romd_mode; fr.readonly = readonly; flatview_insert(view, i, &fr); } }
1threat
Is there a way to keep fragment alive when using BottomNavigationView with new NavController? : <p>I'm trying to use the new navigation component. I use a BottomNavigationView with the navController : NavigationUI.setupWithNavController(bottomNavigation, navController)</p> <p>But when I'm switching fragments, they are each time destroy/create even if they were previously used.</p> <p>Is there a way to keep alive our main fragments link to our BottomNavigationView?</p>
0debug
static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb) { BDRVQcowState *s = bs->opaque; int old_version = s->qcow_version, new_version = old_version; uint64_t new_size = 0; const char *backing_file = NULL, *backing_format = NULL; bool lazy_refcounts = s->use_lazy_refcounts; const char *compat = NULL; uint64_t cluster_size = s->cluster_size; bool encrypt; int ret; QemuOptDesc *desc = opts->list->desc; while (desc && desc->name) { if (!qemu_opt_find(opts, desc->name)) { desc++; continue; } if (!strcmp(desc->name, BLOCK_OPT_COMPAT_LEVEL)) { compat = qemu_opt_get(opts, BLOCK_OPT_COMPAT_LEVEL); if (!compat) { } else if (!strcmp(compat, "0.10")) { new_version = 2; } else if (!strcmp(compat, "1.1")) { new_version = 3; } else { fprintf(stderr, "Unknown compatibility level %s.\n", compat); return -EINVAL; } } else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) { fprintf(stderr, "Cannot change preallocation mode.\n"); return -ENOTSUP; } else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) { new_size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) { backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { backing_format = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { encrypt = qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, s->crypt_method); if (encrypt != !!s->crypt_method) { fprintf(stderr, "Changing the encryption flag is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) { cluster_size = qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE, cluster_size); if (cluster_size != s->cluster_size) { fprintf(stderr, "Changing the cluster size is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { lazy_refcounts = qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFCOUNTS, lazy_refcounts); } else if (!strcmp(desc->name, BLOCK_OPT_REFCOUNT_BITS)) { error_report("Cannot change refcount entry width"); return -ENOTSUP; } else { assert(false); } desc++; } if (new_version != old_version) { if (new_version > old_version) { s->qcow_version = new_version; ret = qcow2_update_header(bs); if (ret < 0) { s->qcow_version = old_version; return ret; } } else { ret = qcow2_downgrade(bs, new_version, status_cb); if (ret < 0) { return ret; } } } if (backing_file || backing_format) { ret = qcow2_change_backing_file(bs, backing_file ?: bs->backing_file, backing_format ?: bs->backing_format); if (ret < 0) { return ret; } } if (s->use_lazy_refcounts != lazy_refcounts) { if (lazy_refcounts) { if (s->qcow_version < 3) { fprintf(stderr, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)\n"); return -EINVAL; } s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = true; } else { ret = qcow2_mark_clean(bs); if (ret < 0) { return ret; } s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = false; } } if (new_size) { ret = bdrv_truncate(bs, new_size); if (ret < 0) { return ret; } } return 0; }
1threat
How to ensure kubernetes cronjob does not restart on failure : <p>I have a cronjob that sends out emails to customers. It occasionally fails for various reasons. I <em>do not want</em> it to restart, but it still does.</p> <p>I am running Kubernetes on GKE. To get it to stop, I have to delete the CronJob and then kill all the pods it creates manually. </p> <p>This is bad, for obvious reasons. </p> <pre><code>apiVersion: batch/v1beta1 kind: CronJob metadata: creationTimestamp: 2018-06-21T14:48:46Z name: dailytasks namespace: default resourceVersion: "20390223" selfLink: [redacted] uid: [redacted] spec: concurrencyPolicy: Forbid failedJobsHistoryLimit: 1 jobTemplate: metadata: creationTimestamp: null spec: template: metadata: creationTimestamp: null spec: containers: - command: - kubernetes/daily_tasks.sh env: - name: DB_HOST valueFrom: fieldRef: apiVersion: v1 fieldPath: status.hostIP envFrom: - secretRef: name: my-secrets image: [redacted] imagePullPolicy: IfNotPresent name: dailytasks resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Never schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 schedule: 0 14 * * * successfulJobsHistoryLimit: 3 suspend: true status: active: - apiVersion: batch kind: Job name: dailytasks-1533218400 namespace: default resourceVersion: "20383182" uid: [redacted] lastScheduleTime: 2018-08-02T14:00:00Z </code></pre>
0debug
static int kvm_init(MachineState *ms) { MachineClass *mc = MACHINE_GET_CLASS(ms); static const char upgrade_note[] = "Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n" "(see http: struct { const char *name; int num; } num_cpus[] = { { "SMP", smp_cpus }, { "hotpluggable", max_cpus }, { NULL, } }, *nc = num_cpus; int soft_vcpus_limit, hard_vcpus_limit; KVMState *s; const KVMCapabilityInfo *missing_cap; int ret; int type = 0; const char *kvm_type; s = KVM_STATE(ms->accelerator); assert(TARGET_PAGE_SIZE <= getpagesize()); page_size_init(); s->sigmask_len = 8; #ifdef KVM_CAP_SET_GUEST_DEBUG QTAILQ_INIT(&s->kvm_sw_breakpoints); #endif s->vmfd = -1; s->fd = qemu_open("/dev/kvm", O_RDWR); if (s->fd == -1) { fprintf(stderr, "Could not access KVM kernel module: %m\n"); ret = -errno; goto err; } ret = kvm_ioctl(s, KVM_GET_API_VERSION, 0); if (ret < KVM_API_VERSION) { if (ret >= 0) { ret = -EINVAL; } fprintf(stderr, "kvm version too old\n"); goto err; } if (ret > KVM_API_VERSION) { ret = -EINVAL; fprintf(stderr, "kvm version not supported\n"); goto err; } s->nr_slots = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS); if (!s->nr_slots) { s->nr_slots = 32; } soft_vcpus_limit = kvm_recommended_vcpus(s); hard_vcpus_limit = kvm_max_vcpus(s); while (nc->name) { if (nc->num > soft_vcpus_limit) { fprintf(stderr, "Warning: Number of %s cpus requested (%d) exceeds " "the recommended cpus supported by KVM (%d)\n", nc->name, nc->num, soft_vcpus_limit); if (nc->num > hard_vcpus_limit) { fprintf(stderr, "Number of %s cpus requested (%d) exceeds " "the maximum cpus supported by KVM (%d)\n", nc->name, nc->num, hard_vcpus_limit); exit(1); } } nc++; } kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); if (mc->kvm_type) { type = mc->kvm_type(kvm_type); } else if (kvm_type) { ret = -EINVAL; fprintf(stderr, "Invalid argument kvm-type=%s\n", kvm_type); goto err; } do { ret = kvm_ioctl(s, KVM_CREATE_VM, type); } while (ret == -EINTR); if (ret < 0) { fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret, strerror(-ret)); #ifdef TARGET_S390X if (ret == -EINVAL) { fprintf(stderr, "Host kernel setup problem detected. Please verify:\n"); fprintf(stderr, "- for kernels supporting the switch_amode or" " user_mode parameters, whether\n"); fprintf(stderr, " user space is running in primary address space\n"); fprintf(stderr, "- for kernels supporting the vm.allocate_pgste sysctl, " "whether it is enabled\n"); } #endif goto err; } s->vmfd = ret; missing_cap = kvm_check_extension_list(s, kvm_required_capabilites); if (!missing_cap) { missing_cap = kvm_check_extension_list(s, kvm_arch_required_capabilities); } if (missing_cap) { ret = -EINVAL; fprintf(stderr, "kvm does not support %s\n%s", missing_cap->name, upgrade_note); goto err; } s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO); s->broken_set_mem_region = 1; ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS); if (ret > 0) { s->broken_set_mem_region = 0; } #ifdef KVM_CAP_VCPU_EVENTS s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS); #endif s->robust_singlestep = kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP); #ifdef KVM_CAP_DEBUGREGS s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS); #endif #ifdef KVM_CAP_XSAVE s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE); #endif #ifdef KVM_CAP_XCRS s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS); #endif #ifdef KVM_CAP_PIT_STATE2 s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2); #endif #ifdef KVM_CAP_IRQ_ROUTING kvm_direct_msi_allowed = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0); #endif s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3); s->irq_set_ioctl = KVM_IRQ_LINE; if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) { s->irq_set_ioctl = KVM_IRQ_LINE_STATUS; } #ifdef KVM_CAP_READONLY_MEM kvm_readonly_mem_allowed = (kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0); #endif kvm_eventfds_allowed = (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0); kvm_irqfds_allowed = (kvm_check_extension(s, KVM_CAP_IRQFD) > 0); kvm_resamplefds_allowed = (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0); kvm_vm_attributes_allowed = (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0); ret = kvm_arch_init(ms, s); if (ret < 0) { goto err; } if (machine_kernel_irqchip_allowed(ms)) { kvm_irqchip_create(ms, s); } kvm_state = s; s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add; s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del; s->memory_listener.listener.coalesced_mmio_add = kvm_coalesce_mmio_region; s->memory_listener.listener.coalesced_mmio_del = kvm_uncoalesce_mmio_region; kvm_memory_listener_register(s, &s->memory_listener, &address_space_memory, 0); memory_listener_register(&kvm_io_listener, &address_space_io); s->many_ioeventfds = kvm_check_many_ioeventfds(); cpu_interrupt_handler = kvm_handle_interrupt; return 0; err: assert(ret < 0); if (s->vmfd >= 0) { close(s->vmfd); } if (s->fd != -1) { close(s->fd); } g_free(s->memory_listener.slots); return ret; }
1threat
static int qcow_open(BlockDriverState *bs, const char *filename, int flags) { BDRVQcowState *s = bs->opaque; int len, i, shift, ret; QCowHeader header; ret = bdrv_file_open(&s->hd, filename, flags | BDRV_O_AUTOGROW); if (ret < 0) return ret; if (bdrv_pread(s->hd, 0, &header, sizeof(header)) != sizeof(header)) goto fail; be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be64_to_cpus(&header.size); be32_to_cpus(&header.cluster_bits); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); be32_to_cpus(&header.l1_size); be64_to_cpus(&header.refcount_table_offset); be32_to_cpus(&header.refcount_table_clusters); be64_to_cpus(&header.snapshots_offset); be32_to_cpus(&header.nb_snapshots); if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION) goto fail; if (header.size <= 1 || header.cluster_bits < 9 || header.cluster_bits > 16) goto fail; if (header.crypt_method > QCOW_CRYPT_AES) goto fail; s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) bs->encrypted = 1; s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = s->cluster_bits - 3; s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->csize_shift = (62 - (s->cluster_bits - 8)); s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; s->cluster_offset_mask = (1LL << s->csize_shift) - 1; s->refcount_table_offset = header.refcount_table_offset; s->refcount_table_size = header.refcount_table_clusters << (s->cluster_bits - 3); s->snapshots_offset = header.snapshots_offset; s->nb_snapshots = header.nb_snapshots; s->l1_size = header.l1_size; shift = s->cluster_bits + s->l2_bits; s->l1_vm_state_index = (header.size + (1LL << shift) - 1) >> shift; if (s->l1_size < s->l1_vm_state_index) goto fail; s->l1_table_offset = header.l1_table_offset; s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t)); if (!s->l1_table) goto fail; if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) != s->l1_size * sizeof(uint64_t)) goto fail; for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); if (!s->l2_cache) goto fail; s->cluster_cache = qemu_malloc(s->cluster_size); if (!s->cluster_cache) goto fail; s->cluster_data = qemu_malloc(s->cluster_size + 512); if (!s->cluster_data) goto fail; s->cluster_cache_offset = -1; if (refcount_init(bs) < 0) goto fail; if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) len = 1023; if (bdrv_pread(s->hd, header.backing_file_offset, bs->backing_file, len) != len) goto fail; bs->backing_file[len] = '\0'; } if (qcow_read_snapshots(bs) < 0) goto fail; #ifdef DEBUG_ALLOC check_refcounts(bs); #endif return 0; fail: qcow_free_snapshots(bs); refcount_close(bs); qemu_free(s->l1_table); qemu_free(s->l2_cache); qemu_free(s->cluster_cache); qemu_free(s->cluster_data); bdrv_delete(s->hd); return -1; }
1threat
What is difference between REPLICA and DAEMON service type in Amazon EC2 Container Service? : <p>When I created service in Amazon EC2 Container Service, there were 2 options for service type: REPLICA and DAEMON.</p> <p>What is the exact difference between them?</p> <blockquote> <p>Replica services place and maintain a desired number of tasks across your cluster. Daemon services place and maintain one copy of your task for each container instance</p> </blockquote> <p><a href="https://i.stack.imgur.com/mrxga.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mrxga.png" alt="enter image description here"></a></p>
0debug
PHP MYSQLI Call to a member function bind_param() : <p>my code is </p> <pre><code>$query1 = "SELECT `user_id` FROM `it_user` WHERE (user_email_address = ? AND user_mobile_number_verified = NULL)"; $stmt1 = $mysqli-&gt;prepare($query1); $stmt1-&gt;bind_param("s",$email); $stmt1-&gt;execute(); if ($stmt1-&gt;affected_rows == 1) { //set registration flag to 1 stating that the users mobile number is already verified echo '&lt;meta http-equiv="refresh" content="0; URL=\'../signin/\'"/&gt;'; } else { $registration_flag = 2; //redirect user to error page //echo '&lt;meta http-equiv="refresh" content="0; URL=\'../error/\'"/&gt;'; } </code></pre> <p>i am getting this error :: </p> <p>Call to a member function bind_param() on a non-object in ***** on line 62</p> <p>where as my email variable is working corrrect and also the query.</p>
0debug
How would I split this string separate by commas if the first item has two words in Javascript? : <p>If I had a string that was <code>first second, third</code>, how would I separate the first two words from the third if there is a comma separating them?</p>
0debug
Set environment variable for build in Netlify : <p>I'm trying to set an environment variable for an API key that I don't want in my code. My source javascript looks something like this :</p> <pre><code>.get(`http://api-url-and-parameters&amp;api-key=${process.env.API_KEY}`) </code></pre> <p>I'm using webpack and the package dotenv-webpack <a href="https://www.npmjs.com/package/dotenv-webpack" rel="noreferrer">https://www.npmjs.com/package/dotenv-webpack</a> to set API_KEY in a gitignored .env file and it's all running fine on my local. I'd like to also be able to set that variable when deploying through Netlify, I've tried adding it through to GUI to the 'build environment variables', and also to set it directly in the build command, but without success.</p> <p>Any idea what might be the issue ?</p>
0debug
static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { TWOLAMEContext *s = avctx->priv_data; int ret; if ((ret = ff_alloc_packet(avpkt, MPA_MAX_CODED_FRAME_SIZE)) < 0) return ret; if (frame) { switch (avctx->sample_fmt) { case AV_SAMPLE_FMT_FLT: ret = twolame_encode_buffer_float32_interleaved(s->glopts, (const float *)frame->data[0], frame->nb_samples, avpkt->data, avpkt->size); break; case AV_SAMPLE_FMT_FLTP: ret = twolame_encode_buffer_float32(s->glopts, (const float *)frame->data[0], (const float *)frame->data[1], frame->nb_samples, avpkt->data, avpkt->size); break; case AV_SAMPLE_FMT_S16: ret = twolame_encode_buffer_interleaved(s->glopts, (const short int *)frame->data[0], frame->nb_samples, avpkt->data, avpkt->size); break; case AV_SAMPLE_FMT_S16P: ret = twolame_encode_buffer(s->glopts, (const short int *)frame->data[0], (const short int *)frame->data[1], frame->nb_samples, avpkt->data, avpkt->size); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported sample format %d.\n", avctx->sample_fmt); return AVERROR_BUG; } } else { ret = twolame_encode_flush(s->glopts, avpkt->data, avpkt->size); } if (!ret) return 0; if (ret < 0) return AVERROR_UNKNOWN; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); if (frame) { if (frame->pts != AV_NOPTS_VALUE) avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay); } else { avpkt->pts = s->next_pts; } if (avpkt->pts != AV_NOPTS_VALUE) s->next_pts = avpkt->pts + avpkt->duration; av_shrink_packet(avpkt, ret); *got_packet_ptr = 1; return 0; }
1threat
static struct omap_watchdog_timer_s *omap_wd_timer_init(MemoryRegion *memory, hwaddr base, qemu_irq irq, omap_clk clk) { struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) g_malloc0(sizeof(struct omap_watchdog_timer_s)); s->timer.irq = irq; s->timer.clk = clk; s->timer.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_timer_tick, &s->timer); omap_wd_timer_reset(s); omap_timer_clk_setup(&s->timer); memory_region_init_io(&s->iomem, NULL, &omap_wd_timer_ops, s, "omap-wd-timer", 0x100); memory_region_add_subregion(memory, base, &s->iomem); return s; }
1threat
PHP: Mark as link values inside a string (a textarea string) : <p>I'm developing a wikipedia-like Web application. I want to show articles with the possibllity to link to other articles.</p> <p>The way to do it that I can think of, is to mark manually values as a sign for link, like this: " Hello |world| " ("world" would be the link for an article). later, i'll have to find inside the textarea string all the words marked with | on start and | on it's end. bottom line, some string functions are needed. </p> <p>How should I do that? can you, please, give me an example?</p> <p>Thank you in advance.</p>
0debug
dagger android support proguard rules : <p>I'm using <strong>Dagger2 android-support</strong> library with <strong>Proguard</strong> but i can't compile my project because of this error :</p> <pre><code>Warning:dagger.android.AndroidInjector: can't find referenced class com.google.errorprone.annotations.DoNotMock Warning:dagger.android.AndroidInjector$Builder: can't find referenced class com.google.errorprone.annotations.DoNotMock Warning:dagger.android.AndroidInjector$Factory: can't find referenced class com.google.errorprone.annotations.DoNotMock Warning:dagger.android.DaggerApplication: can't find referenced class com.google.errorprone.annotations.ForOverride Warning:dagger.android.DispatchingAndroidInjector: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue Warning:there were 5 unresolved references to classes or interfaces. </code></pre> <p>The version of Dagger that I'm using is <a href="http://search.maven.org/#artifactdetails%7Ccom.google.dagger%7Cdagger%7C2.11%7C" rel="noreferrer">2.11</a>.</p> <p>The question is what Proguard rules should i use for Dagger2 android-support library ?</p>
0debug
static void register_types(void) { register_char_driver_qapi("null", CHARDEV_BACKEND_KIND_NULL, NULL); register_char_driver("socket", qemu_chr_open_socket); register_char_driver("udp", qemu_chr_open_udp); register_char_driver("memory", qemu_chr_open_ringbuf); register_char_driver_qapi("file", CHARDEV_BACKEND_KIND_FILE, qemu_chr_parse_file_out); register_char_driver_qapi("stdio", CHARDEV_BACKEND_KIND_STDIO, qemu_chr_parse_stdio); register_char_driver_qapi("serial", CHARDEV_BACKEND_KIND_SERIAL, qemu_chr_parse_serial); register_char_driver_qapi("tty", CHARDEV_BACKEND_KIND_SERIAL, qemu_chr_parse_serial); register_char_driver_qapi("parallel", CHARDEV_BACKEND_KIND_PARALLEL, qemu_chr_parse_parallel); register_char_driver_qapi("parport", CHARDEV_BACKEND_KIND_PARALLEL, qemu_chr_parse_parallel); #ifdef _WIN32 register_char_driver("pipe", qemu_chr_open_win_pipe); register_char_driver("console", qemu_chr_open_win_con); #else register_char_driver("pipe", qemu_chr_open_pipe); #endif #ifdef HAVE_CHARDEV_TTY register_char_driver("pty", qemu_chr_open_pty); #endif }
1threat
Clean Architecture: Use different model classes for different data sources? : <p>I am currently developing a news feed android app. I try to design my app according to the principles of clean architecture. </p> <p>In the data layer I am using the repository pattern as a facade for the diferent data sources: remote data from an API (<a href="https://newsapi.org/" rel="noreferrer">https://newsapi.org/</a>) , local data from an DB (Realm or SQLite) as well as some in-memory cache.<br> In my domain layer I have defined some immutable model classes (Article, NewsSource, etc.) which are being used by the domain layer as well as the presentation layer (no need for extra model classes in the presentation layer in my opinion). </p> <p><strong>Does it make sense to use different model classes for the remote data source as well as for the local data source?</strong> </p> <p>E.g. The remote data source uses Retrofit to make API calls and the models need to be annotated in order to be parsed by GSON.</p> <pre><code>data class RemoteArticleModel( @SerializedName("title") val title: String, @SerializedName("urlToImage") val urlToImage: String, @SerializedName("url") val url: String) </code></pre> <p>The models for the local data source also may have to fulfill some certain contract like models in a Realm DB need to extend RealmObject.</p> <pre><code>open class Dog : RealmObject() { var name: String? = null @LinkingObjects("dog") val owners: RealmResults&lt;Person&gt;? = null } </code></pre> <p>Obviously, I don´t want my domain models to be 'polluted' by any data source specific contract (annotations, RealmObject inheritance, etc.). So I thought it would make sense to use different models for different data sources and the repository handles the mapping between them. </p> <p><strong>E.g. We want to fetch all articles from the remote API, store them in the local DB and return them to the domain layer.</strong> </p> <p><strong>Flow would be like:</strong> Remote data source makes http request to news api and retrieves a list of <code>RemoteArticleModel</code>´s. The repository would map these models to a Domain specific article model (<code>Article</code>). Then these would be mapped to DB models (e.g. <code>RealmArticleModel</code>) and inserted into the DB. Finally the list of <code>Article</code>´s would be returned to the caller.</p> <p><strong>Two questions arise:</strong> The above example shows how <em>many allocations</em> there would be using this approach. For every article that is going to be downloaded and inserted into the DB, three models would be created in that process. Would that be overkill?</p> <p>Also, I know that the data layer should use different model classes than the domain layer (inner layer should no nothing about outer layer). But how would that make sense in the above example. I would already have two different model classes for the two different data sources. Adding a third one that´s being used as a 'mediator' model by the data-layer/repository to handle mapping to other models (remote, local, domain) would add even more allocations. </p> <p><strong>So should the data layer know nothing about domain models and let the domain do the mapping from a data layer model to a domain layer model?</strong> </p> <p><strong>Should there be a generic model used only by the repository/data-layer?</strong></p> <p>Thank, I really appreciate any help from more experienced developers :)</p>
0debug
SQL Duplicated resault messages : I have SQL Query: SELECT m.message_subject, m.message_message, m.message_smileys, m.message_datestamp, u.user_id, u.user_name, u.user_avatar FROM ".DB_MESSAGES." m LEFT JOIN ( SELECT user_id, user_name, user_avatar FROM ".DB_USERS." GROUP BY user_id ) u ON m.message_from=u.user_id WHERE (message_to='".$userdata['user_id']."' AND message_from='108') OR (message_to='108' AND message_from='".$userdata['user_id']."') ORDER BY message_datestamp Resault: [Resault Image][1] What I need: [Needed Resault Image][2] Any advice? Well thank you [1]: http://i.stack.imgur.com/g2Ev5.png [2]: http://i.stack.imgur.com/D7hNb.png
0debug
Building numpy with ATLAS/LAPACK support : <p>I am trying to compile <code>numpy</code> v1.12 in order to get support for ATLAS/LAPACK routines. </p> <p><strong>The problem</strong></p> <p>The settings I am using for compilation do not appear to work in bringing ATLAS/LAPACK libraries into <code>numpy</code>.</p> <p><strong>The setup</strong></p> <p>I do not have admin privileges on the host(s) I am working on (a computational cluster). </p> <p>However, the nodes offer access to <code>gcc</code> 4.7.2 and 5.3.0, <code>glibc</code> 2.17 and 2.22, and ATLAS/LAPACK libraries and headers v3.10.2 via GNU modules.</p> <p>For compatibility reasons, I am working with a virtual environment that contains Python 2.7.16. Likewise, I am installing an older version of <code>numpy</code> for the same reason. If things work, I may explore newer versions of <code>numpy</code> but at this time, that is what I am working with. </p> <p>My source directory for <code>numpy</code> has a configuration file called <code>site.cfg</code>, which includes these directives:</p> <pre><code>[ALL] library_dirs = /usr/local/lib:/net/module/sw/glibc/2.22/lib64:/net/module/sw/atlas-lapack/3.10.2/lib include_dirs = /usr/local/include:/net/module/sw/glibc/2.22/include:/net/module/sw/atlas-lapack/3.10.2/include [atlas] libraries = lapack,f77blas,cblas,atlas library_dirs = /net/module/sw/atlas-lapack/3.10.2/lib include_dirs = /net/module/sw/atlas-lapack/3.10.2/include </code></pre> <p>I am compiling <code>numpy</code> via the following command:</p> <pre><code>$ CFLAGS="${CFLAGS} -std=c99 -fPIC" LDFLAGS="-L/home/areynolds/.conda/envs/genotyping_environment/lib -Wl,-rpath=/home/areynolds/.conda/envs/genotyping_environment/lib -Wl,--no-as-needed -Wl,--sysroot=/,-L/net/module/sw/glibc/2.22/lib64" python setup.py build --fcompiler=gnu95 </code></pre> <p>I am using <code>--fcompiler=gnu95</code> as the ATLAS/LAPACK libraries were compiled with GNU Fortran. I am overriding <code>CFLAGS</code> and <code>LDFLAGS</code> variables in order for the GCC toolkit to be able to compile and link properly.</p> <p><strong>The question</strong></p> <p>After compilation, I test the <code>numpy</code> library to see what is installed via one method:</p> <pre><code>$ python ... &gt;&gt;&gt; import numpy.distutils.system_info as sysinfo &gt;&gt;&gt; sysinfo.get_info('atlas') ATLAS version 3.10.2 built by root on Wed Jun 1 15:39:08 PDT 2016: UNAME : Linux module0.altiusinstitute.org 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux INSTFLG : -1 0 -a 1 -l 1 ARCHDEFS : -DATL_OS_Linux -DATL_ARCH_UNKNOWNx86 -DATL_CPUMHZ=2876 -DATL_AVXMAC -DATL_AVX -DATL_SSE3 -DATL_SSE2 -DATL_SSE1 -DATL_USE64BITS -DATL_GAS_x8664 F2CDEFS : -DAdd_ -DF77_INTEGER=int -DStringSunStyle CACHEEDGE: 229376 F77 : /net/module/sw/gcc/5.3.0/bin/gfortran, version GNU Fortran (GCC) 5.3.0 F77FLAGS : -O -mavx2 -mfma -m64 -fPIC SMC : /usr/bin/x86_64-redhat-linux-gcc, version x86_64-redhat-linux-gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4) SMCFLAGS : -O -fomit-frame-pointer -mavx2 -mfma -m64 -fPIC SKC : /usr/bin/x86_64-redhat-linux-gcc, version x86_64-redhat-linux-gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4) SKCFLAGS : -O -fomit-frame-pointer -mavx2 -mfma -m64 -fPIC {'libraries': ['lapack', 'f77blas', 'cblas', 'atlas', 'f77blas', 'cblas'], 'library_dirs': ['/net/module/sw/atlas-lapack/3.10.2/lib'], 'define_macros': [('ATLAS_INFO', '"\\"3.10.2\\""')], 'language': 'f77', 'include_dirs': ['/net/module/sw/atlas-lapack/3.10.2/include']} </code></pre> <p>This looks okay, maybe?</p> <p>But when I check via another method, I get a different answer:</p> <pre><code>&gt;&gt;&gt; np.show_config() lapack_opt_info: libraries = ['openblas', 'openblas'] library_dirs = ['/usr/local/lib'] define_macros = [('HAVE_CBLAS', None)] language = c blas_opt_info: libraries = ['openblas', 'openblas'] library_dirs = ['/usr/local/lib'] define_macros = [('HAVE_CBLAS', None)] language = c openblas_info: libraries = ['openblas', 'openblas'] library_dirs = ['/usr/local/lib'] define_macros = [('HAVE_CBLAS', None)] language = c blis_info: NOT AVAILABLE openblas_lapack_info: libraries = ['openblas', 'openblas'] library_dirs = ['/usr/local/lib'] define_macros = [('HAVE_CBLAS', None)] language = c lapack_mkl_info: NOT AVAILABLE blas_mkl_info: NOT AVAILABLE </code></pre> <p>Despite the manual setup described in <code>site.cfg</code>, there are no mentions of ATLAS, nor is LAPACK apparently pointed to the correct module directory (<code>/net/module/sw/atlas-lapack/3.10.2</code>).</p> <p>How do I correctly compile support for ATLAS/LAPACK into <code>numpy</code>, or truly test that I have a working ATLAS/LAPACK setup integrated into <code>numpy</code>, which gives me a consistent (and reliable) answer?</p>
0debug
Merging multiple TypeSafe Config files and resolving only after they are all merged : <p>I am writing test code to validate a RESTful service. I want to be able to point it at any of our different environments by simply changing an environment variable before executing the tests.</p> <p>I want to be able to merge three different config files:</p> <ul> <li><code>conf/env/default.conf</code> - the default configuration values for all environments</li> <li><code>conf/env/&lt;env&gt;.conf</code> - the environment-specific values </li> <li><code>application.conf</code> - the user's overrides of any of the above</li> </ul> <p>The idea is that I don't want everything in a single config file, and run the risk of a bad edit causing configuration items to get lost. So instead, keep them separate and give the user the ability to override them.</p> <p>Here's where it gets tricky: <code>default.conf</code> will include ${references} to things that are meant to be overridden in <code>&lt;env&gt;.conf</code>, and may be further overridden in <code>application.conf</code>. </p> <p>I need to postpone resolving until all three are merged. How do I do that?</p>
0debug
static int h261_decode_gob_header(H261Context *h) { unsigned int val; MpegEncContext *const s = &h->s; if (!h->gob_start_code_skipped) { val = show_bits(&s->gb, 15); if (val) return -1; skip_bits(&s->gb, 16); } h->gob_start_code_skipped = 0; h->gob_number = get_bits(&s->gb, 4); s->qscale = get_bits(&s->gb, 5); if (s->mb_height == 18) { if ((h->gob_number <= 0) || (h->gob_number > 12)) return -1; } else { if ((h->gob_number != 1) && (h->gob_number != 3) && (h->gob_number != 5)) return -1; } while (get_bits1(&s->gb) != 0) skip_bits(&s->gb, 8); if (s->qscale == 0) { av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n"); if (s->avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT)) return -1; } h->current_mba = 0; h->mba_diff = 0; return 0; }
1threat
void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len) { const uint8_t *end; int j; j = ctx->len & 63; ctx->len += len; if (j) { int cnt = FFMIN(len, 64 - j); memcpy(ctx->block + j, src, cnt); src += cnt; len -= cnt; if (j + cnt < 64) return; body(ctx->ABCD, (uint32_t *)ctx->block); } end = src + (len & ~63); if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)src & 3))) { while (src < end) { memcpy(ctx->block, src, 64); body(ctx->ABCD, (uint32_t *) ctx->block); src += 64; } } else { while (src < end) { body(ctx->ABCD, (uint32_t *)src); src += 64; } } len &= 63; if (len > 0) memcpy(ctx->block, src, len); }
1threat
static void grlib_apbuart_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { UART *uart = opaque; unsigned char c = 0; addr &= 0xff; switch (addr) { case DATA_OFFSET: case DATA_OFFSET + 3: if ((uart->chr) && (uart->control & UART_TRANSMIT_ENABLE)) { c = value & 0xFF; qemu_chr_fe_write(uart->chr, &c, 1); if (uart->control & UART_TRANSMIT_INTERRUPT) { qemu_irq_pulse(uart->irq); } } return; case STATUS_OFFSET: return; case CONTROL_OFFSET: uart->control = value; return; case SCALER_OFFSET: return; default: break; } trace_grlib_apbuart_writel_unknown(addr, value); }
1threat
Formatting Razor Files in Visual Studio Code : <p>Anyone have a good solution for formatting Razor files inside of VSCode? I've tried making it work with prettify-vscode and beautify. But in both cases it can't tell that cshtml files. I don't want to change my razor to html as I'll lose a lot of the razor-ness.</p>
0debug
tight_detect_smooth_image24(VncState *vs, int w, int h) { int off; int x, y, d, dx; uint c; uint stats[256]; int pixels = 0; int pix, left[3]; uint errors; unsigned char *buf = vs->tight.buffer; off = !!(vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG); memset(stats, 0, sizeof (stats)); for (y = 0, x = 0; y < h && x < w;) { for (d = 0; d < h - y && d < w - x - VNC_TIGHT_DETECT_SUBROW_WIDTH; d++) { for (c = 0; c < 3; c++) { left[c] = buf[((y+d)*w+x+d)*4+off+c] & 0xFF; } for (dx = 1; dx <= VNC_TIGHT_DETECT_SUBROW_WIDTH; dx++) { for (c = 0; c < 3; c++) { pix = buf[((y+d)*w+x+d+dx)*4+off+c] & 0xFF; stats[abs(pix - left[c])]++; left[c] = pix; } pixels++; } } if (w > h) { x += h; y = 0; } else { x = 0; y += w; } } if (stats[0] * 33 / pixels >= 95) { return 0; } errors = 0; for (c = 1; c < 8; c++) { errors += stats[c] * (c * c); if (stats[c] == 0 || stats[c] > stats[c-1] * 2) { return 0; } } for (; c < 256; c++) { errors += stats[c] * (c * c); } errors /= (pixels * 3 - stats[0]); return errors; }
1threat
Andoird get Index 1 out of range on parse json format : i'm trying to parse this below json format such as: [ [ { "mobileNumber":"(937) 107-6569","contactUserId":"17", "userEwallets": [ {"accountNumber":"EPIRR9371076569"}, {"accountNumber":"EPUSD9371076569"}, {"accountNumber":"EPCHF9371076569"} ] } ] , [ { "mobileNumber":"+981077331743","contactUserId":"1", "userEwallets": [ {"accountNumber":"EPIRR1077331743"} ] } ] ] for parsing second json array of that as [ { "mobileNumber":"+981077331743","contactUserId":"1", "userEwallets": [ {"accountNumber":"EPIRR1077331743"} ] } ] i get this error: Index 1 out of range [0..1) from below code my code can only parse the first array of that, for second array i get exception when i try to get `mobileNumber` of second json array object for (int i = 0; i < response.length(); i++) { try { JSONArray jsonArray = response.getJSONArray(i); final String mobileNumber = jsonArray.getJSONObject(i).getString("mobileNumber"); final String contactUserId = jsonArray.getJSONObject(i).getString("contactUserId"); final String userEwallets = jsonArray.getJSONObject(i).getString("userEwallets"); Log.e("MobileNumber ", mobileNumber); JSONArray ewallets = new JSONArray(userEwallets); for (int j = 0; j < ewallets.length(); j++) { JSONObject ewalletObject = ewallets.getJSONObject(j); final String accountNumber = ewalletObject.getString("accountNumber"); Log.e("accountNumber ", accountNumber); } } catch (JSONException e) { e.printStackTrace(); } }
0debug
Problems with palindrome in c : <p><a href="https://i.stack.imgur.com/4UoFb.png" rel="nofollow noreferrer">A C program to find if the input number is palindrome or not</a></p> <p><a href="https://i.stack.imgur.com/08sYL.png" rel="nofollow noreferrer">The problem as I see it is that the even numbered powers come out strange. Can anyone please tell me what the problem could be?</a></p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
how to fix KeyValuePair<char, int[]> in foreach statement? : how can i use KeyValuePair<char, int[]> in foreach statement? the error is Cannot convert type 'char' to 'System.Collections.Generic.KeyValuePair<char, int[]>' foreach(KeyValuePair<char, int[]> characterEntry in occ_counts_before.Keys) { characterEntry.Value[i] = characterEntry.Value[i - 1] + (characterEntry.Key == current ? 1 : 0); }
0debug
Symfony 2 : Best practice : <p>I have two questions and I hope somebody can answer them clearly.</p> <p>Q1 : Is it recommended to use the same symfony envelop for different projects (each project would be a bundle). In any case, can you explain why it has to be done or not.</p> <p>Q2 : is it recommended (and possible) to move the vendor folder outside the project envelop to be used by different projects. So just one vendor for different projects.</p> <p>Thank you for answering those questions.</p>
0debug
How to check if ANY php parameter exists in url : <p>I am making a forum that accesses threads based off the category in the URL using the GET method. I want to redirect to an error page if no parameters exist in the url, but I want this to be a generic piece of code that can be used around my whole site.</p> <p>For example:</p> <p>The url would normally contain the category id:</p> <pre><code>localhost/myforum/threads.php?categoryid=1 </code></pre> <p>I want it so that when the url is:</p> <pre><code>localhost/myforum/threads.php </code></pre> <p>it is to redirect to an error page, and that this piece of code is usable all around the website</p>
0debug
static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; struct iscsi_data data; IscsiAIOCB *acb; acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->ioh = buf; if (req != SG_IO) { iscsi_ioctl_handle_emulated(acb, req, buf); return &acb->common; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(iscsi)); memset(acb->task, 0, sizeof(struct scsi_task)); switch (acb->ioh->dxfer_direction) { case SG_DXFER_TO_DEV: acb->task->xfer_dir = SCSI_XFER_WRITE; break; case SG_DXFER_FROM_DEV: acb->task->xfer_dir = SCSI_XFER_READ; break; default: acb->task->xfer_dir = SCSI_XFER_NONE; break; acb->task->cdb_size = acb->ioh->cmd_len; memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len); acb->task->expxferlen = acb->ioh->dxfer_len; data.size = 0; if (acb->task->xfer_dir == SCSI_XFER_WRITE) { if (acb->ioh->iovec_count == 0) { data.data = acb->ioh->dxferp; data.size = acb->ioh->dxfer_len; } else { scsi_task_set_iov_out(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_ioctl_cb, (data.size > 0) ? &data : NULL, acb) != 0) { scsi_free_scsi_task(acb->task); if (acb->task->xfer_dir == SCSI_XFER_READ) { if (acb->ioh->iovec_count == 0) { scsi_task_add_data_in_buffer(acb->task, acb->ioh->dxfer_len, acb->ioh->dxferp); } else { scsi_task_set_iov_in(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); iscsi_set_events(iscsilun); return &acb->common;
1threat
How does `ggplotGrob` work? : <p><a href="http://docs.ggplot2.org/0.9.3/ggplotGrob.html">docs.ggplot2.org</a> currently offers very little documentation for the function <code>ggplotGrob</code>. The <a href="http://svitsrv25.epfl.ch/R-doc/library/ggplot2/html/ggplotGrob-1l.html">EPFL website</a> is a little bit more informative but it is still not very helpful.</p> <p>Can you please provide a short tutorial on what one can do with the function <code>ggplotGrob</code>?</p>
0debug
How do I calculate Percentages of Variables in HTML : I pretty much just started learning to code so I know only the most basic info so I might not understand too many coding terms if their put out there. I was trying to make a variable go up by a certain percent every time you click a button. I understand how I could do most of that, I just need to know how to multiply variables with percentages. Could anyone explain to me how to multiply variables with percentages in html.
0debug
How do i reload data in my tableview : Ive seen some answers on Stack about this question but a lot of them are from 5 years ago and using an older version of swift. I would like to reload the data in the table every time the user hits save so that the appended event will now be added to the table. But no matter what i seem to do nothing is showing up! class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var txtTitle: UITextField! @IBOutlet weak var txtLocation: UITextField! @IBOutlet weak var txtDate: UITextField! @IBOutlet weak var txtTime: UITextField! var eventsArray = [Event]() override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } //var events = Event(tits: "W", locs: "UVA-Wise") @IBAction func btnSave() { let event = Event(tits: txtTitle.text!, locs: txtLocation.text!) eventsArray.append(event) print(eventsArray) //reload data } @IBOutlet weak var table: UITableView! func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return eventsArray.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! CustomeCell cell.title.text = eventsArray[indexPath.row].title cell.location.text = eventsArray[indexPath.row].location return cell } }
0debug
static int64_t nfs_client_open(NFSClient *client, QDict *options, int flags, Error **errp, int open_flags) { int ret = -EINVAL; QemuOpts *opts = NULL; Error *local_err = NULL; struct stat st; char *file = NULL, *strp = NULL; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } client->path = g_strdup(qemu_opt_get(opts, "path")); if (!client->path) { ret = -EINVAL; error_setg(errp, "No path was specified"); goto fail; } strp = strrchr(client->path, '/'); if (strp == NULL) { error_setg(errp, "Invalid URL specified"); goto fail; } file = g_strdup(strp); *strp = 0; client->server = nfs_config(options, errp); if (!client->server) { ret = -EINVAL; goto fail; } client->context = nfs_init_context(); if (client->context == NULL) { error_setg(errp, "Failed to init NFS context"); goto fail; } if (qemu_opt_get(opts, "uid")) { client->uid = qemu_opt_get_number(opts, "uid", 0); nfs_set_uid(client->context, client->uid); } if (qemu_opt_get(opts, "gid")) { client->gid = qemu_opt_get_number(opts, "gid", 0); nfs_set_gid(client->context, client->gid); } if (qemu_opt_get(opts, "tcp-syncnt")) { client->tcp_syncnt = qemu_opt_get_number(opts, "tcp-syncnt", 0); nfs_set_tcp_syncnt(client->context, client->tcp_syncnt); } #ifdef LIBNFS_FEATURE_READAHEAD if (qemu_opt_get(opts, "readahead")) { if (open_flags & BDRV_O_NOCACHE) { error_setg(errp, "Cannot enable NFS readahead " "if cache.direct = on"); goto fail; } client->readahead = qemu_opt_get_number(opts, "readahead", 0); if (client->readahead > QEMU_NFS_MAX_READAHEAD_SIZE) { error_report("NFS Warning: Truncating NFS readahead " "size to %d", QEMU_NFS_MAX_READAHEAD_SIZE); client->readahead = QEMU_NFS_MAX_READAHEAD_SIZE; } nfs_set_readahead(client->context, client->readahead); #ifdef LIBNFS_FEATURE_PAGECACHE nfs_set_pagecache_ttl(client->context, 0); #endif client->cache_used = true; } #endif #ifdef LIBNFS_FEATURE_PAGECACHE if (qemu_opt_get(opts, "pagecache")) { if (open_flags & BDRV_O_NOCACHE) { error_setg(errp, "Cannot enable NFS pagecache " "if cache.direct = on"); goto fail; } client->pagecache = qemu_opt_get_number(opts, "pagecache", 0); if (client->pagecache > QEMU_NFS_MAX_PAGECACHE_SIZE) { error_report("NFS Warning: Truncating NFS pagecache " "size to %d pages", QEMU_NFS_MAX_PAGECACHE_SIZE); client->pagecache = QEMU_NFS_MAX_PAGECACHE_SIZE; } nfs_set_pagecache(client->context, client->pagecache); nfs_set_pagecache_ttl(client->context, 0); client->cache_used = true; } #endif #ifdef LIBNFS_FEATURE_DEBUG if (qemu_opt_get(opts, "debug")) { client->debug = qemu_opt_get_number(opts, "debug", 0); if (client->debug > QEMU_NFS_MAX_DEBUG_LEVEL) { error_report("NFS Warning: Limiting NFS debug level " "to %d", QEMU_NFS_MAX_DEBUG_LEVEL); client->debug = QEMU_NFS_MAX_DEBUG_LEVEL; } nfs_set_debug(client->context, client->debug); } #endif ret = nfs_mount(client->context, client->server->host, client->path); if (ret < 0) { error_setg(errp, "Failed to mount nfs share: %s", nfs_get_error(client->context)); goto fail; } if (flags & O_CREAT) { ret = nfs_creat(client->context, file, 0600, &client->fh); if (ret < 0) { error_setg(errp, "Failed to create file: %s", nfs_get_error(client->context)); goto fail; } } else { ret = nfs_open(client->context, file, flags, &client->fh); if (ret < 0) { error_setg(errp, "Failed to open file : %s", nfs_get_error(client->context)); goto fail; } } ret = nfs_fstat(client->context, client->fh, &st); if (ret < 0) { error_setg(errp, "Failed to fstat file: %s", nfs_get_error(client->context)); goto fail; } ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE); client->st_blocks = st.st_blocks; client->has_zero_init = S_ISREG(st.st_mode); *strp = '/'; goto out; fail: nfs_client_close(client); out: qemu_opts_del(opts); g_free(file); return ret; }
1threat
static int piix4_initfn(PCIDevice *d) { uint8_t *pci_conf; isa_bus_new(&d->qdev); register_savevm("PIIX4", 0, 2, piix_save, piix_load, d); pci_conf = d->config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_0); pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; piix4_dev = d; piix4_reset(d); qemu_register_reset(piix4_reset, d); return 0; }
1threat
How to get time and date after certain milliseconds in moment.js? : <p><strong>Problem Statement:</strong> I am trying to get the time and date after certain milliseconds using moment.js <strong>Example:</strong> </p> <pre><code>const expiresIn = 30000 // milliseconds const issuedAt = moment().toString(); const expiresAt = // I need to get the time and date after "expiresIn"(milliseconds) so i can set the "expiresAt" as time and date </code></pre>
0debug
React Native init specific version : <p>I upgraded my latest project to React Native 0.19 and instantly the video no longer works. How can I create a new project with a specific version? I want to init a new project at version 0.18.1. I did some google searches but couldn't find anything about this.</p> <pre><code>$ react-native init newproject --verbose </code></pre> <p>I'm guessing I need to add the word @18.1 in there somewhere but can't get that to work.</p>
0debug
why does google appengine deployment take several minutes to update service : <p>I'm using nodejs flexible environment documented <a href="https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml" rel="noreferrer">here</a></p> <p>Nothing fancy in the config</p> <pre><code>runtime: nodejs vm: true service: SimpleExpressService health_check: enable_health_check: False automatic_scaling: min_num_instances: 1 max_num_instances: 4 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.5 </code></pre> <p>Here is my deployment command</p> <pre><code>gcloud app deploy -q --promote --version $VER </code></pre> <p>Whenever I deploy a new version, almost everything goes really fast. However, the step 'Updating service [SimpleExpressServer]' takes several minutes. </p> <p>Is there anyway to optimize this step?</p> <p><a href="https://i.stack.imgur.com/7oUVt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7oUVt.png" alt="enter image description here"></a></p>
0debug
How to use Schedulers.trampoline() inRxJava : <p>Since <code>Schedulers.trampoline()</code> makes the job work on the current thread, I cannot find the difference between the case with <code>Schedulers.trampoline()</code> and the case without Schedulers settings.</p> <p>Using <code>Schedulers.trampoline()</code>:</p> <pre><code>Observable.from(1, 2, 3) .observeOn(Schedulers.trampoline()) .subscribe(System.out::println) </code></pre> <p>Not Using Schedulers: </p> <pre><code>Observable.from(1, 2, 3) .subscribe(System.out::println) </code></pre> <p>I think that above codes act the same. I really wonder why <code>Schedulers.trampoline()</code> exists in RxJava's API.</p> <p>In what situation, should I use <code>Schedulers.trampoline()</code>?</p>
0debug
Should I keep gitconfig's "signingKey" private? : <p>I have recently set up GPG to sign my Git commits so now I have a <strong>signingKey</strong> field in my gitconfig. I'm not very familiar with details of GPG – is this signingKey a sensitive piece of information that I should keep private or does it fall into the public part of gpg? I have my gitconfig in a public repo where I keep my dotfiles and I was wondering if it's ok to have that field visible. </p>
0debug
Bootstrap 4: Align logo/brand to the right : Total noob here... I'm trying to align the brand/logo on the right side of my navbar but when I manage to do that, the logo stays inside the collapse menu when I get to mobile view. This is the correct position in desktop view: [![Logo right aligned in desktop view][1]][1] This is what happens when I go into mobile view. I want the logo to stay on the top while the menu opens down: [![Logo inside the collapse menu][2]][2] Here's my code: <nav class="navbar navbar-expand-lg navbar-dark fixed-top bg-sika"> <div class="container"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarsExampleDefault"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"> <a class="nav-link" href="#">Início <span class="sr-only">(current)</span></a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Zonas da Casa</a> <div class="dropdown-menu" aria-labelledby="dropdown01"> <a class="dropdown-item" href="#">Garagens e Estacionamentos</a> <a class="dropdown-item" href="#">Cozinhas e WC's</a> <a class="dropdown-item" href="#">Quartos e Salas</a> <a class="dropdown-item" href="#">Varandas e Terraços</a> <a class="dropdown-item" href="#">Piscinas e Reservatórios de Água</a> <a class="dropdown-item" href="#">Fachadas</a> <a class="dropdown-item" href="#">Coberturas Inclinadas</a> <a class="dropdown-item" href="#">Coberturas Planas</a> <a class="dropdown-item" href="#">Caves e Paredes Enterradas</a> <a class="dropdown-item" href="#">Isolamento Térmico pelo Exterior</a> </div> </li> <li class="nav-item"> <a class="nav-link" href="#">100 Soluções</a> </li> <li class="nav-item"> <a class="nav-link page-scroll" href="#pos">Pontos de Venda</a> </li> <li class="nav-item"> <a class="nav-link page-scroll" href="#registo">Registo</a> </li> <li class="nav-item"> <a class="nav-link page-scroll" href="#contacto">Contacto</a> </li> </ul> </div> <a class="navbar-brand" href="#"> <img src="img/logo_sika_pt_02.png" width="225" height="45" class="d-inline-block align-top" alt=""> </a> </div> </nav> This code was copied from a template and I'm trying to edit it. [1]: https://i.stack.imgur.com/ZNxm9.png [2]: https://i.stack.imgur.com/aChtk.png
0debug
arduino python if else condition : i want to make if else condition about status of arduino.How could i make if else condition about status about arduino?If status of arduino is connected,i want to have "Connected" Message.Else,Message is "Disconnected". def connectToArduino(): arduino = serial.Serial(arduinoPort, serialTransferRate) if(arduino.timeout = None): print 'connected' else: print 'disconnected' arduino = connectToArduino()
0debug
int bdrv_flush_all(void) { BlockDriverState *bs = NULL; int result = 0; while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); int ret; aio_context_acquire(aio_context); ret = bdrv_flush(bs); if (ret < 0 && !result) { result = ret; } aio_context_release(aio_context); } return result; }
1threat
static int virtio_blk_init_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); VirtIODevice *vdev; if (proxy->class_code != PCI_CLASS_STORAGE_SCSI && proxy->class_code != PCI_CLASS_STORAGE_OTHER) proxy->class_code = PCI_CLASS_STORAGE_SCSI; if (!proxy->block.dinfo) { error_report("virtio-blk-pci: drive property not set"); return -1; } vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block); vdev->nvectors = proxy->nvectors; virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BLOCK, proxy->class_code, 0x00); proxy->nvectors = vdev->nvectors; return 0; }
1threat
Can not get email address by Facebook login (javascript) : <p>I use Facebook javascript to handle function login by Facebook. Before, i can use it, and Facebook send for my server user's info:</p> <p>localhost</p> <pre><code>v2.2 id: first_name: last_name: email: token: </code></pre> <p>v2.5 - But, now i only get: </p> <pre><code>id: first_name: last_name: token: </code></pre> <p>Don't have email? what's problem at here? and how i can fix it.</p> <p>Thank you so much!</p>
0debug