problem
stringlengths
26
131k
labels
class label
2 classes
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined issue : <p>I am very unsure at why I am getting such an error with my code </p> <pre><code>try { $stmt = $connection-&gt;prepare("INSERT INTO table (path, title, era, information) VALUES (:path, :title, :era, :information)"); $stmt-&gt;bindParam(':path', $fname); $stmt-&gt;bindParam(':title', $Name); $stmt-&gt;bindParam(':era', $Era); $stmt-&gt;bindParam(':descrip', $Description); // insert row $stmt-&gt;execute(); } catch(PDOException $e) { echo $e-&gt;getMessage(); } echo "Upload Successful"; } </code></pre> <p>I have tried so many different options and I just cant fix the error</p> <pre><code>$fname=$_FILES["userfile"]["name"]; $Name =$_POST["name"]; $Era =$_POST["era"]; $Description =$_POST["info"]; </code></pre> <p>these are the variables I used if that helps in solving my issue</p>
0debug
what is the best way to save json in app in iOS? : <p>I am using a json that is very big. it takes lot of time to fetch it as api response. I want to fetch it once and save it locally, so that I can use it in my app. I want to save it in a file but the question is where should I store this file. </p>
0debug
Paint a circular image with border : <p>I want to do something like </p> <pre><code>new BoxDecoration( color: const Color(0xff7c94b6), image: new DecorationImage( image: new ExactAssetImage('assets/images/restaurant.jpg'), fit: BoxFit.cover, ), borderRadius: new BorderRadius.all(new Radius.circular(50.0)), border: new Border.all( color: Colors.red, width: 4.0, ), </code></pre> <p>The visual I am looking for is like the way gmail shows the user's image. This code - which is from the docs - works fine, but my image should be loaded from a url, and is not in the assets.</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
def area_trapezium(base1,base2,height): area = 0.5 * (base1 + base2) * height return area
0debug
static int decode_band(IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx) { int result, i, t, idx1, idx2, pos; IVITile *tile; band->buf = band->bufs[ctx->dst_buf]; if (!band->buf) { av_log(avctx, AV_LOG_ERROR, "Band buffer points to no data!\n"); return AVERROR_INVALIDDATA; } band->ref_buf = band->bufs[ctx->ref_buf]; band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3); result = ctx->decode_band_hdr(ctx, band, avctx); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n", result); return result; } if (band->is_empty) { av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n"); return AVERROR_INVALIDDATA; } band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel]; for (i = 0; i < band->num_corr; i++) { idx1 = band->corr[i * 2]; idx2 = band->corr[i * 2 + 1]; FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); } pos = get_bits_count(&ctx->gb); for (t = 0; t < band->num_tiles; t++) { tile = &band->tiles[t]; if (tile->mb_size != band->mb_size) { av_log(avctx, AV_LOG_ERROR, "MB sizes mismatch: %d vs. %d\n", band->mb_size, tile->mb_size); return AVERROR_INVALIDDATA; } tile->is_empty = get_bits1(&ctx->gb); if (tile->is_empty) { result = ivi_process_empty_tile(avctx, band, tile, (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3)); if (result < 0) break; av_dlog(avctx, "Empty tile encountered!\n"); } else { tile->data_size = ivi_dec_tile_data_size(&ctx->gb); if (!tile->data_size) { av_log(avctx, AV_LOG_ERROR, "Tile data size is zero!\n"); return AVERROR_INVALIDDATA; } result = ctx->decode_mb_info(ctx, band, tile, avctx); if (result < 0) break; result = ivi_decode_blocks(&ctx->gb, band, tile, avctx); if (result < 0 || ((get_bits_count(&ctx->gb) - pos) >> 3) != tile->data_size) { av_log(avctx, AV_LOG_ERROR, "Corrupted tile data encountered!\n"); break; } pos += tile->data_size << 3; } } for (i = band->num_corr-1; i >= 0; i--) { idx1 = band->corr[i*2]; idx2 = band->corr[i*2+1]; FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); } #ifdef DEBUG if (band->checksum_present) { uint16_t chksum = ivi_calc_band_checksum(band); if (chksum != band->checksum) { av_log(avctx, AV_LOG_ERROR, "Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n", band->plane, band->band_num, band->checksum, chksum); } } #endif align_get_bits(&ctx->gb); return result; }
1threat
static void i440fx_pcihost_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass); hc->root_bus_path = i440fx_pcihost_root_bus_path; dc->realize = i440fx_pcihost_realize; dc->fw_name = "pci"; dc->props = i440fx_props; }
1threat
In chrome dev tools, what is the speed of each preset option for network throttling? : <p>Since a recent update to chrome, the presets are no longer labelled with bandwidth. <a href="https://i.stack.imgur.com/qzL2r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qzL2r.png" alt="bandwidth presets"></a></p> <p>Chrome used to list the actual speed of each one so you could simply tell.</p> <p>What bandwidth or latency do the options here represent?</p>
0debug
Sum of sale of each partnumber .and partnumber have its substitute partnumber in another table : I have two table first have part number and sale of each month. And another table have substitute part of part number. Table 1 Partnumber jun19sale jul19sale A 1 1 B 2 1 C 3 4 E 5 3 D 1 2 Table2 Partnumber subpart A B A C A D How can i get somthing like this. Partnumber jun19sale jul19sale A 7 8 B 7 8 C 7 8 E 5 3 D 7 8 I try with subqueries with or,in which give me accurate result .but its take to much time. Because table have large amount of data. Please suggest best way. Thanks in advanced
0debug
Renaming multiple files in a directory using Python : <p>I'm trying to rename multiple files in a directory using this Python script:</p> <pre><code>import os path = '/Users/myName/Desktop/directory' files = os.listdir(path) i = 1 for file in files: os.rename(file, str(i)+'.jpg') i = i+1 </code></pre> <p>When I run this script, I get the following error:</p> <pre><code>Traceback (most recent call last): File "rename.py", line 7, in &lt;module&gt; os.rename(file, str(i)+'.jpg') OSError: [Errno 2] No such file or directory </code></pre> <p>Why is that? How can I solve this issue?</p> <p>Thanks.</p>
0debug
How to redirect stderr to a file in a cron job : <p>I've got a cron job that is set up like this in my crontab:</p> <pre><code>*/1 * * * * sudo /home/pi/coup/sensor.py &gt;&gt; /home/pi/sensorLog.txt </code></pre> <p>It puts stdout into sensorLog.txt, and any stderr it generates gets put into an email. </p> <p>I want both stdout and stderr to go into sensorLog.txt, so I added <code>1&gt;&amp;2</code> to the crontab, which is supposed to make stderr go into the same place as stdout. It now looks like this:</p> <pre><code>*/1 * * * * sudo /home/pi/coup/sensor.py &gt;&gt; /home/pi/sensorLog.txt 1&gt;&amp;2 </code></pre> <p>Now, both stdout and stderr both get put into an email, and nothing gets added to the file. This is the opposite of what I am trying to accomplish.</p> <p>How do I get both stdout and stderr to get redirected to the file?</p>
0debug
How to escape the symbol of percentage '%' in r? : <p>In an url, I am dealing with the special character '<strong>%</strong>' that I should pass as a string. The url contain some argumnents so I use <code>sprintf.</code> How to escape the symbol '<strong>%</strong>' in r ?</p> <pre><code>start &lt;- 1 #%s is my variable url&lt;-(sprintf('https://www.amazon.com/s/ref=sr_pg_%s?rh=n%3A172282%2Cn%3A%21493964%2Cn%3A502394%2Cn%3A281052%2Cn%3A12556502011%2Cn%3A3017941&amp;page=%s&amp;ie=UTF8', start, start)) </code></pre> <blockquote> <p>invalid format '%2Cn%3A'; use format %s for character objects</p> </blockquote>
0debug
def max_Product(arr): arr_len = len(arr) if (arr_len < 2): return ("No pairs exists") x = arr[0]; y = arr[1] for i in range(0,arr_len): for j in range(i + 1,arr_len): if (arr[i] * arr[j] > x * y): x = arr[i]; y = arr[j] return x,y
0debug
How to find the sum of n element in a given array should be x : We have an array arr[10,-5,-115,6,70,25,345,-35] We need to check the addition of  any 4,number should be 100.
0debug
Is there any way we can restrict the android application at the time of installation : Its like we specify in android manifest file about minimum amd maximun sdk version so can we restrict the installation of an android application depending on the processor it has like qualcom,mediatek etc.
0debug
Conncetivity between two oracle Server : <p>I have two PC A and B.In both the machine Oracle 10g Express Edition.In this 2 machine both have internet connection with different service provider with different network.Now i like to connect 2 oracle server by command line sqlplus.please help me.</p>
0debug
Error Message: "An interface can only extend an object type or intersection of object types with statically known members" : <p>The following code:</p> <pre class="lang-js prettyprint-override"><code>export type Partial2DPoint = { x: number } | { y: number } export interface Partial3DPoint extends Partial2DPoint { z: number } </code></pre> <p>Fails with the following error:</p> <blockquote> <p>An interface can only extend an object type or intersection of object types with statically known members.</p> </blockquote> <p>Why is this happening?</p>
0debug
Difference in the 'lib' property in tsconfig.json between es6 and es2017? : <p>I've been researching what the possible values of the <code>lib</code> property mean in the <code>compilerOptions</code> found within the <code>tsconfig.json</code> file. I found on the <a href="https://github.com/Microsoft/TypeScript/tree/master/lib" rel="noreferrer">Typescript GitHub</a> page the relevant <code>d.ts</code> files corresponding to those values and apparently by using <code>ES2017</code> the following ES features are included:</p> <pre><code>/// &lt;reference path="lib.es2016.d.ts" /&gt; /// &lt;reference path="lib.es2017.object.d.ts" /&gt; /// &lt;reference path="lib.es2017.sharedmemory.d.ts" /&gt; /// &lt;reference path="lib.es2017.string.d.ts" /&gt; /// &lt;reference path="lib.es2015.d.ts" /&gt; /// &lt;reference path="lib.es2016.array.include.d.ts" /&gt; /// &lt;reference path="lib.es2015.core.d.ts" /&gt; /// &lt;reference path="lib.es2015.collection.d.ts" /&gt; /// &lt;reference path="lib.es2015.generator.d.ts" /&gt; /// &lt;reference path="lib.es2015.iterable.d.ts" /&gt; /// &lt;reference path="lib.es2015.promise.d.ts" /&gt; /// &lt;reference path="lib.es2015.proxy.d.ts" /&gt; /// &lt;reference path="lib.es2015.reflect.d.ts" /&gt; /// &lt;reference path="lib.es2015.symbol.d.ts" /&gt; /// &lt;reference path="lib.es2015.symbol.wellknown.d.ts" /&gt; /// &lt;reference path="lib.es5.d.ts" /&gt; </code></pre> <p>But apparently ES6 is not included and has it's own <a href="https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts" rel="noreferrer">file</a> that doesn't reference anything. My question is, if anybody knows, is it safe to assume that by using <code>es2017</code> I cover all the <code>es6</code> functionality (from a typings perspective) or should that be included separately in the <code>lib</code> option?</p> <p>For example, like this:</p> <pre><code>{ ... "compilerOptions": { ... "lib": ["es2017", "dom"] }, ... } } </code></pre> <p>OR this:</p> <pre><code>{ ... "compilerOptions": { ... "lib": ["es2017", "es6", "dom"] }, ... } } </code></pre>
0debug
static int cook_decode_init(AVCodecContext *avctx) { COOKextradata *e = avctx->extradata; COOKContext *q = avctx->priv_data; if (avctx->extradata_size <= 0) { av_log(NULL,AV_LOG_ERROR,"Necessary extradata missing!\n"); } else { av_log(NULL,AV_LOG_DEBUG,"codecdata_length=%d\n",avctx->extradata_size); if (avctx->extradata_size >= 8){ e->cookversion = be2me_32(e->cookversion); e->samples_per_frame = be2me_16(e->samples_per_frame); e->subbands = be2me_16(e->subbands); } if (avctx->extradata_size >= 16){ e->js_subband_start = be2me_16(e->js_subband_start); e->js_vlc_bits = be2me_16(e->js_vlc_bits); } } q->sample_rate = avctx->sample_rate; q->nb_channels = avctx->channels; q->bit_rate = avctx->bit_rate; q->random_state = 1; q->samples_per_channel = e->samples_per_frame / q->nb_channels; q->samples_per_frame = e->samples_per_frame; q->subbands = e->subbands; q->bits_per_subpacket = avctx->block_align * 8; q->js_subband_start = 0; q->log2_numvector_size = 5; q->total_subbands = q->subbands; av_log(NULL,AV_LOG_DEBUG,"e->cookversion=%x\n",e->cookversion); switch (e->cookversion) { case MONO_COOK1: if (q->nb_channels != 1) { av_log(NULL,AV_LOG_ERROR,"Container channels != 1, report sample!\n"); } av_log(NULL,AV_LOG_DEBUG,"MONO_COOK1\n"); break; case MONO_COOK2: if (q->nb_channels != 1) { q->joint_stereo = 0; q->bits_per_subpacket = q->bits_per_subpacket/2; } av_log(NULL,AV_LOG_DEBUG,"MONO_COOK2\n"); break; case JOINT_STEREO: if (q->nb_channels != 2) { av_log(NULL,AV_LOG_ERROR,"Container channels != 2, report sample!\n"); } av_log(NULL,AV_LOG_DEBUG,"JOINT_STEREO\n"); if (avctx->extradata_size >= 16){ q->total_subbands = q->subbands + e->js_subband_start; q->js_subband_start = e->js_subband_start; q->joint_stereo = 1; q->js_vlc_bits = e->js_vlc_bits; } if (q->samples_per_channel > 256) { q->log2_numvector_size = 6; } if (q->samples_per_channel > 512) { q->log2_numvector_size = 7; } break; case MC_COOK: av_log(NULL,AV_LOG_ERROR,"MC_COOK not supported!\n"); break; default: av_log(NULL,AV_LOG_ERROR,"Unknown Cook version, report sample!\n"); break; } q->mlt_size = q->samples_per_channel; q->numvector_size = (1 << q->log2_numvector_size); init_rootpow2table(q); init_pow2table(q); init_gain_table(q); if (init_cook_vlc_tables(q) != 0) if ((q->decoded_bytes_buffer = av_mallocz((avctx->block_align+(4-avctx->block_align%4) + FF_INPUT_BUFFER_PADDING_SIZE)*sizeof(uint8_t))) == NULL) q->decode_buf_ptr[0] = q->decode_buffer_1; q->decode_buf_ptr[1] = q->decode_buffer_2; q->decode_buf_ptr[2] = q->decode_buffer_3; q->decode_buf_ptr[3] = q->decode_buffer_4; q->decode_buf_ptr2[0] = q->decode_buffer_3; q->decode_buf_ptr2[1] = q->decode_buffer_4; q->previous_buffer_ptr[0] = q->mono_previous_buffer1; q->previous_buffer_ptr[1] = q->mono_previous_buffer2; if ( init_cook_mlt(q) == 0 ) if (q->total_subbands > 53) { av_log(NULL,AV_LOG_ERROR,"total_subbands > 53, report sample!\n"); } if (q->subbands > 50) { av_log(NULL,AV_LOG_ERROR,"subbands > 50, report sample!\n"); } if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) { } else { av_log(NULL,AV_LOG_ERROR,"unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel); } #ifdef COOKDEBUG dump_cook_context(q,e); #endif return 0; }
1threat
static void qmp_deserialize(void **native_out, void *datap, VisitorFunc visit, Error **errp) { QmpSerializeData *d = datap; QString *output_json = qobject_to_json(qmp_output_get_qobject(d->qov)); QObject *obj = qobject_from_json(qstring_get_str(output_json)); QDECREF(output_json); d->qiv = qmp_input_visitor_new(obj); qobject_decref(obj); visit(qmp_input_get_visitor(d->qiv), native_out, errp); }
1threat
static void SET_TYPE(resample_nearest)(void *dst0, int dst_index, const void *src0, int index) { FELEM *dst = dst0; const FELEM *src = src0; dst[dst_index] = src[index]; }
1threat
How to pause loop after x loops for x seconds : <p>How can I pause my loop after x loops for x seconds?</p> <p>My loop reads a list of IP addresses line by line. After 50 loops it should pause x seconds till the loop continues.</p>
0debug
Cant run PHPUnit with Composer on Travis-CI : I need some help with a problem. I'm trying to execute a simple build with tests on Travis-CI, but its error, saying that it could not found Class: > Fatal error: Class 'com\bitshammer\collection\utils\CollectionUtils' not found in /home/travis/build/BitsHammer/CollectionUtils/test/CollectionUtilsTest.php on line 20 Just for your knowledge, its my first project using composer! What I am doing wrong? Do you guys have any ideia? Thanks! [Travis-CI Page](https://travis-ci.org/BitsHammer/CollectionUtils/jobs/171248224) [Project Page](https://github.com/BitsHammer/CollectionUtils)
0debug
Extending custom router to default router across apps in Django Rest Framework : <p>I have come across a problem regarding having the API apps seperate, while still being able to use the browsable API for navigation.</p> <p>I have previously used a seperate <code>routers.py</code> file in my main application containing the following extension of the <code>DefaultRouter</code>.</p> <pre><code>class DefaultRouter(routers.DefaultRouter): def extend(self, router): self.registry.extend(router.registry) </code></pre> <p>Followed by adding the other application routers like this:</p> <pre><code>from . routers import DefaultRouter from app1.urls import router as app1_router # Default Router mainAppRouter = DefaultRouter() mainAppRouter.extend(app1_router) </code></pre> <p>where the <code>app1_router</code> is a new <code>SimpleRouter</code> object.</p> <p>Now the problem occurs when I want to modify the <code>SimpleRouter</code> and create my own <code>App1Router</code>, such as this</p> <pre><code>class App1Router(SimpleRouter): routes = [ Route( url = r'^{prefix}{trailing_slash}$', mapping = { 'get': 'retrieve', 'post': 'create', 'patch': 'partial_update', }, name = '{basename}-user', initkwargs = {} ), ] </code></pre> <p>This will not handle my extension correctly. As an example, <code>GET</code> and <code>PATCH</code> are not recognized as allowed methods whenever I extend the router, but when I dont extend, but only use the custom router, everything works fine.</p> <p>My question is therefor, <em>how can I handle extending custom routers across seperate applications, but still maintain a good browsable API</em>? </p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Build NuGet package on Linux that targets .NET Framework : <p>I want to create a NuGet package that can simultaneously and explicitly target <em>both</em> .NET Framework 4.6.2 and .Net Standard 1.5. Here's an abbreviated .csproj file from VS 2017:</p> <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt; &lt;PropertyGroup&gt; &lt;TargetFrameworks&gt;net462;netstandard1.5&lt;/TargetFrameworks&gt; ... &lt;/PropertyGroup&gt; &lt;/Project&gt; </code></pre> <p>When I execute the dotnet build and pack commands from my local Windows machine, the NuGet package is created perfectly well as expected.</p> <p><strong>However</strong>, when I attempt to execute the same dotnet commands on Linux, I receive the following error:</p> <blockquote> <p>/opt/dotnet/sdk/1.0.4/Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.</p> </blockquote> <p>It then dawned on me that there aren't any regular .NET Framework assemblies on the Linux box (let alone . Thus, it appears that I won't be able to use Linux to build my NuGet package. I searched around for a "Targeting Pack", but it's only available for Windows.</p> <p>At the risk of sounding naïve, is anyone successfully building NuGet packages on Linux that can target .NET Framework?</p>
0debug
Apache HTTP Client/Commons with User authentication : Need to do HTTP GET with UserId/password Authentication using Apache HTTP Client/Commons lib: val targetHost = new HttpHost("url", 8080, "http"); val credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("user", "password")); val authCache = new BasicAuthCache(); authCache.put(targetHost, new BasicScheme()); val context = HttpClientContext.create(); context.setCredentialsProvider(credsProvider); context.setAuthCache(authCache); val client = HttpClientBuilder.create().build(); var response = client.execute( new HttpGet("url"), context); var statusCode = response.getStatusLine().getStatusCode(); But not able to fetch the data from the URL as it is failing to connect to the URL.Please can someone assist
0debug
I need to import some custom javascript files and use those functions in my JMeter test : I need to import some custom javascript files (which are currently being used by the Web application's UI layer) and use those functions in my JMeter test. Can you please suggest the best way and the details for the same ?
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
static uint64_t imx_timerp_read(void *opaque, target_phys_addr_t offset, unsigned size) { IMXTimerPState *s = (IMXTimerPState *)opaque; DPRINTF("p-read(offset=%x)", offset >> 2); switch (offset >> 2) { case 0: DPRINTF("cr %x\n", s->cr); return s->cr; case 1: DPRINTF("int_level %x\n", s->int_level); return s->int_level; case 2: DPRINTF("lr %x\n", s->lr); return s->lr; case 3: DPRINTF("cmp %x\n", s->cmp); return s->cmp; case 4: return ptimer_get_count(s->timer); } IPRINTF("imx_timerp_read: Bad offset %x\n", (int)offset >> 2); return 0; }
1threat
static int normalize_samples(AC3EncodeContext *s) { int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE); lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v); return v - 9; }
1threat
Force <a download /> to download image instead of opening url link to image : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;a download='file' href="https://tinyjpg.com/images/social/website.jpg"&gt; Download &lt;/a&gt;</code></pre> </div> </div> </p> <p>Is there a way to force the download of a file instead of opening the file in a new window? Right now if the file is a URL, like the example below it won't be downloaded and will open in a new window.</p> <p>Thank you 🙌</p>
0debug
def count_duplic(lists): element = [] frequency = [] if not lists: return element running_count = 1 for i in range(len(lists)-1): if lists[i] == lists[i+1]: running_count += 1 else: frequency.append(running_count) element.append(lists[i]) running_count = 1 frequency.append(running_count) element.append(lists[i+1]) return element,frequency
0debug
Python: Build a 2D list of attributes from user input : Very new to python. I am interested in learning how to build a 2D list, where each row contains an object number in column one and its attributes in the following columns. This will be done for as many objects as the user defines. It would look like this: Object1 big heavy square Object2 small heavy round Object3 small light round So if the user says there are eight objects, a loop would ask for the object number, size, weight, and shape of each object and populate the list. Any help would be greatly appreciated. Thanks
0debug
OOP PHP in practice : I have problem with OOP, I use external xml, this works, but I have another problem. In my __construct I have $elem which is responsible for filtering the xml data. But it not working. Please help. I dont how to bite it. class Property { public $xmlClass; public $array = []; public $elem = ''; public function __construct($xml,$elem) { $this->xmlClass=$xml; foreach($xml->list->film->$elem as $result) { $array = array_push($result); } } } $result_scenario = new Property($xml,'scenario'); print_r($result_scenario);
0debug
Permission access to microphone of iOS device ios : <p>I want <strong>permission access to Microphone of iOS device.</strong> Project is in Angular JS 1 and android team had written native code to access microphone which works perfectly fine. Below is native code for Android </p> <p><a href="https://i.stack.imgur.com/qycgu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qycgu.png" alt="Screenshot 1"></a></p> <p><a href="https://i.stack.imgur.com/iUDP6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iUDP6.png" alt="Screenshot 2"></a></p> <p>What will be equivalent code for iOS? Any help will be much appreciated!</p>
0debug
what is the button called in android phone(go back to previous page) : <p>for android phone when we go back to previous activity. we press some button at the bottom of the phone<br/></p> <p>what is the name of this button and override method?<br/></p> <p>I can not override or search because I do not know the name of this. <br/></p>
0debug
Wordpress $ is undefined : <p>I include some custom javascript into my wordpress theme. So I added this lines to my <code>functions.php</code></p> <pre><code>function add_theme_scripts() { wp_enqueue_script('equalheight', get_template_directory_uri().'/js/equalheight.js', array ( 'jquery' ), true); wp_enqueue_script('script', get_template_directory_uri().'/js/script.js', array ( 'jquery' ), true); } add_action('wp_enqueue_scripts', 'add_theme_scripts'); </code></pre> <p>But the scripts having problems with jquery. I will get this in my browser console: </p> <pre><code>TypeError: $ is undefined </code></pre> <p>Why? The dependence to jquery is set.</p> <p>Does anyone have an idea?</p>
0debug
Where are the classes for vector,lists etc. are defined,in std namespace or in their respective header files? : <p>Currently,I am learning C++ and I observed that objects like vectors,lists can be used if we include their respective header file and std::object_name.Where these classes are actually defined,in their respective header files or in std namespace? </p>
0debug
EF Core tools version update 2.1.1 : <p>If I run <code>dotnet ef add testmigration</code></p> <p>I get this warning: <code>The EF Core tools version '2.1.0-rtm-30799' is older than that of the runtime '2.1.1-rtm-30846'. Update the tools for the latest features and bug fixes.</code></p> <p>So I checked my csproj file:</p> <pre><code>&lt;ItemGroup&gt; &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.1" /&gt; &lt;PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" /&gt; &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" /&gt; &lt;PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" /&gt; &lt;/ItemGroup&gt; </code></pre> <p>Which looks correct to me, version 2.1.1. So I checked the docs, <a href="https://docs.microsoft.com/en-us/ef/core/get-started/install/" rel="noreferrer">here</a></p> <p>And they suggest the tools entry in the csproj needs to have this package:</p> <pre><code>&lt;ItemGroup&gt; &lt;DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.1" /&gt; &lt;/ItemGroup&gt; </code></pre> <p>Now a <code>dotnet restore</code> complains that:</p> <p><code>warning : The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box).</code></p> <p>And <code>dotnet ef --version</code> still lists the old one.</p> <p>So the next thing I do is remove the entry in the <code>csproj</code> altogether, now <code>dotnet ef</code> still works, but still gives me the old version.</p> <p>So I figured I somehow must update the dotnet global tools for EF. But a 'dotnet tools list -g' gives me no results.</p> <p>All very confusing.</p> <p>Where does the old version come from, how do I get rid of it/update it?</p>
0debug
Cocoapods 1.0: "xcodeproj was renamed to `project`. Please use that from now on." : <p>I do get the warning <code>xcodeproj was renamed to</code>project<code>. Please use that from now on.</code> when running <code>pod install</code> with Cocoapods 1.0.</p> <p>Also, <code>[NSBundle bundleWithIdentifier:@"org.cocoapods.xyz"]</code> returns <code>nil</code>.</p> <p>With version 0.39.0 I don't get the warning and <code>[NSBundle bundleWithIdentifier:@"org.cocoapods.xyz"]</code> returns a valid bundle.</p> <p>Does anyone know a solution for this?</p>
0debug
Runtime Error Of Scanf(); : <p>In following c code scanf is not working. When program is run, it execute upto the second printf line and after it skips the scanf("%c",&amp;sex); and directly execute next printf(). Why this so happen? I run this code on different c compilers, but the output is same.</p> <pre><code>#include&lt;stdio.h&gt; void main() { char mar,sex; int age,flag=0; printf("Married [Y/N]:"); scanf("%c",&amp;mar); printf("Sex [M/F] :"); scanf("%c",&amp;sex); //**This not working** printf("Age :"); //**execution directly jumped here** scanf("%d",&amp;age); if(mar=='y') flag=1; else if(sex=='m'&amp;&amp; age&gt;=30) flag=1; else if(sex=='f'&amp;&amp; age&gt;=25) flag=1; else { } if(flag) { printf("Congratulations!!!! You are Egligible.."); else printf("Sorry... You are not egligible.."); getch(); } </code></pre> <p>//Output</p> <pre><code>Married [Y/N]:y Sex [M/F] :Age :23 Congratulations!!!! You are Egligible.. </code></pre>
0debug
How do I format a multi-line TODO comment in PyCharm? : <p>I want to add a multi-line TODO comment to my PyCharm project.</p> <pre><code># TODO: Multiple errors can be wrapped inside an exception. # WfcApiException should do recursive error checking to locate # and store an arbitrary number of nested errors. </code></pre> <p>Unfortunately, PyCharm only recognizes the first line as a TODO comment. Any following lines are viewed as standard Python comments.</p> <p><a href="https://i.stack.imgur.com/99qAn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/99qAn.png" alt="Failed attempt at a multi-line TODO statement in PyCharm"></a></p> <p>What is the correct way to format a multi-line TODO comment in PyCharm?</p>
0debug
Rewrite HTML using jQuery : <p>I have table that looks like this:</p> <pre><code>&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Link&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Link&lt;/th&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;&lt;a href='#' onClick=('remove(0)')&gt;Remove&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;&lt;a href='#' onClick=('remove(1')&gt;Remove&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;&lt;a href='#' onClick=('remove(2)')&gt;Remove&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;&lt;a href='#' onClick=('remove(3)')&gt;Remove&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;&lt;a href='#' onClick=('remove(4)')&gt;Remove&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;6&lt;/td&gt; &lt;td&gt;&lt;a href='#' onClick=('remove(5)')&gt;Remove&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Where the inparameter to remove() is the rownumber. In the remove function I'm removing the row, which means I need to rewrite the rownumbers if want to delete more than once before reloading the page. How can I achieve this using jQuery? </p>
0debug
I writed Random Password Generator in C. But my code erroring. What is the problem? Please send me the solutions. Thanks : I writed Random Password Generator in C. But my code erroring. What is the problem? Please send me the solutions. Thanks... #include <stdio.h> #include <stdlib.h> #include <time.h> int main(){enter code here srand((unsigned int)(time(NULL))); int k_sayi,i; srand((unsigned int)(time(NULL))); char kucuk_harf[26]="abcdefghijklmnoprstuvwxyz"; char buyuk_harf[26]="ABCDEFGHIJKLMNOPRSTUVWXYZ"; char sayilar[11]="1234567890"; char ozel_karakter[13]="!'^+%&/=?_*"; char *pass; printf("Parola kac karakterli olsun?: "); scanf("%d",&k_sayi); pass=(char *)malloc(k_sayi*sizeof(char)); for(i=0;i<k_sayi;i++){ pass[i]=rand()%(sizeof kucuk_harf); } pass[i]='\0'; printf("%s",pass); return 0; }
0debug
static int mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s) { AVStream *video_st = s->streams[0]; AVCodecParameters *video_par = s->streams[0]->codecpar; AVCodecParameters *audio_par = s->streams[1]->codecpar; int audio_rate = audio_par->sample_rate; int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den; int audio_kbitrate = audio_par->bit_rate / 1000; int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate); if (frame_rate < 0 || frame_rate > INT32_MAX) { av_log(s, AV_LOG_ERROR, "Frame rate %f outside supported range\n", frame_rate / (double)0x10000); return AVERROR(EINVAL); } avio_wb32(pb, 0x94); ffio_wfourcc(pb, "uuid"); ffio_wfourcc(pb, "PROF"); avio_wb32(pb, 0x21d24fce); avio_wb32(pb, 0xbb88695c); avio_wb32(pb, 0xfac9c740); avio_wb32(pb, 0x0); avio_wb32(pb, 0x3); avio_wb32(pb, 0x14); ffio_wfourcc(pb, "FPRF"); avio_wb32(pb, 0x0); avio_wb32(pb, 0x0); avio_wb32(pb, 0x0); avio_wb32(pb, 0x2c); ffio_wfourcc(pb, "APRF"); avio_wb32(pb, 0x0); avio_wb32(pb, 0x2); ffio_wfourcc(pb, "mp4a"); avio_wb32(pb, 0x20f); avio_wb32(pb, 0x0); avio_wb32(pb, audio_kbitrate); avio_wb32(pb, audio_kbitrate); avio_wb32(pb, audio_rate); avio_wb32(pb, audio_par->channels); avio_wb32(pb, 0x34); ffio_wfourcc(pb, "VPRF"); avio_wb32(pb, 0x0); avio_wb32(pb, 0x1); if (video_par->codec_id == AV_CODEC_ID_H264) { ffio_wfourcc(pb, "avc1"); avio_wb16(pb, 0x014D); avio_wb16(pb, 0x0015); } else { ffio_wfourcc(pb, "mp4v"); avio_wb16(pb, 0x0000); avio_wb16(pb, 0x0103); } avio_wb32(pb, 0x0); avio_wb32(pb, video_kbitrate); avio_wb32(pb, video_kbitrate); avio_wb32(pb, frame_rate); avio_wb32(pb, frame_rate); avio_wb16(pb, video_par->width); avio_wb16(pb, video_par->height); avio_wb32(pb, 0x010001); return 0; }
1threat
Reverse engineering - Is this a cheap 3D distance function? : <p>I am reverse engineering a game from 1999 and I came across a function which looks to be checking if the player is within range of a 3d point for the triggering of audio sources. The decompiler mangles the code pretty bad but I think I understand it.</p> <pre><code>// Position Y delta v1 = * (float * )(this + 16) - LocalPlayerZoneEntry - &gt; y; // Position X delta v2 = * (float * )(this + 20) - LocalPlayerZoneEntry - &gt; x; // Absolute value if (v1 &lt; 0.0) v1 = -v1; // Absolute value if (v2 &lt; 0.0) v2 = -v2; // What is going on here? if (v1 &lt;= v2) v1 = v1 * 0.5; else v2 = v2 * 0.5; // Z position delta v3 = * (float * )(this + 24) - LocalPlayerZoneEntry - &gt; z; // Absolute value if (v3 &lt; 0.0) v3 = -v3; result = v3 + v2 + v1; // Radius if (result &gt; * (float * )(this + 28)) return 0.0; return result; </code></pre> <p>Interestingly enough, when in game, it seemed like the triggering was pretty inconsistent and would sometimes be quite a bit off depending on from which side I approached the trigger.</p> <p>Does anyone have any idea if this was a common algorithm used back in the day?</p> <p>Note: The types were all added by me so they may be incorrect. I assume that this is a function of type bool.</p>
0debug
Schema Builder : Create Table if not exists : <p>I am using below code in Schema Builder to create table.</p> <pre><code>Schema::create('tblCategory', function (Blueprint $table) { $table-&gt;increments('CategoryID'); $table-&gt;string('Category', 40); $table-&gt;unique('Category', 'tblCategory_UK_Category'); $table-&gt;timestamps(); }); </code></pre> <p>Here is the problem is, if I have to create the new table, all old scripts runs and show error that table already exists. </p> <p>is there any way to create table if not exists using Schema builder ?</p>
0debug
Pros and Cons of running all Docker Swarm nodes as Managers? : <p>I am considering building out a Docker Swarm cluster. For the purpose of keeping things both simple and relatively fault-tolerant, I thought about simply running 3 nodes as managers.</p> <p>What are the trade-offs when not using any dedicated worker nodes? Is there anything I should be aware of that might not be obvious?</p> <p>I found this <a href="https://github.com/moby/moby/issues/26919" rel="noreferrer">Github issue</a> which asks a similar question, but the answer is a bit ambiguous to me. It mentions the performance may be worse. It also mentions that it will take longer to reach consensus. In practice, what functionality would be slower? And what does "take longer to reach consensus" actually affect?</p>
0debug
SQL convert date to string in custom format : I need to SELECT a date field but export it as STRING. Not date formatted in a specific way but pure STRING. for example if I have a date 06-May-2016 I need it to be exported as "06.2016". I tried something like: SELECT convert ( "Application_Date", 'MM.YYYY') but that's just rubbish. It seems like a simple issue but I've been searching for an answer for sometime now and nothing.
0debug
Vue.js scroll to top of new page route after setTimeout : <p>I have a page transition that doesn't work nicely when the scroll to the top of a new route is instant. I'd like to wait 100ms before it automatically scrolls to the top. The following code doesn't end up scrolling at all. Is there a way to do this?</p> <pre><code>export default new Router({ mode: 'history', routes: [ { path: '/', name: 'Home', component: Home } ], scrollBehavior (to, from, savedPosition) { setTimeout(() =&gt; { return { x: 0, y: 0 } }, 100); } }) </code></pre>
0debug
void portio_list_add(PortioList *piolist, MemoryRegion *address_space, uint32_t start) { const MemoryRegionPortio *pio, *pio_start = piolist->ports; unsigned int off_low, off_high, off_last, count; piolist->address_space = address_space; off_last = off_low = pio_start->offset; off_high = off_low + pio_start->len; count = 1; for (pio = pio_start + 1; pio->size != 0; pio++, count++) { assert(pio->offset >= off_last); off_last = pio->offset; if (off_last > off_high) { portio_list_add_1(piolist, pio_start, count, start, off_low, off_high); pio_start = pio; off_low = off_last; off_high = off_low + pio->len; count = 0; } else if (off_last + pio->len > off_high) { off_high = off_last + pio->len; } } portio_list_add_1(piolist, pio_start, count, start, off_low, off_high); }
1threat
static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segments, MXFIndexTableSegment ***sorted_segments) { int i, j, nb_segments = 0; MXFIndexTableSegment **unsorted_segments; int last_body_sid = -1, last_index_sid = -1, last_index_start = -1; for (i = 0; i < mxf->metadata_sets_count; i++) if (mxf->metadata_sets[i]->type == IndexTableSegment) nb_segments++; if (!nb_segments) return AVERROR_INVALIDDATA; *sorted_segments = av_mallocz(nb_segments * sizeof(**sorted_segments)); unsorted_segments = av_mallocz(nb_segments * sizeof(*unsorted_segments)); if (!sorted_segments || !unsorted_segments) { av_freep(sorted_segments); av_free(unsorted_segments); return AVERROR(ENOMEM); } for (i = j = 0; i < mxf->metadata_sets_count; i++) if (mxf->metadata_sets[i]->type == IndexTableSegment) unsorted_segments[j++] = (MXFIndexTableSegment*)mxf->metadata_sets[i]; *nb_sorted_segments = 0; for (i = 0; i < nb_segments; i++) { int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1; for (j = 0; j < nb_segments; j++) { MXFIndexTableSegment *s = unsorted_segments[j]; if ((i == 0 || s->body_sid > last_body_sid || s->index_sid > last_index_sid || s->index_start_position > last_index_start) && (best == -1 || s->body_sid < best_body_sid || s->index_sid < best_index_sid || s->index_start_position < best_index_start)) { best = j; best_body_sid = s->body_sid; best_index_sid = s->index_sid; best_index_start = s->index_start_position; } } if (best == -1) break; (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best]; last_body_sid = best_body_sid; last_index_sid = best_index_sid; last_index_start = best_index_start; } av_free(unsorted_segments); return 0; }
1threat
def series_sum(number): total = 0 total = (number * (number + 1) * (2 * number + 1)) / 6 return total
0debug
static inline int64_t bs_get_v(const uint8_t **bs) { int64_t v = 0; int br = 0; int c; do { c = **bs; (*bs)++; v <<= 7; v |= c & 0x7F; br++; if (br > 10) return -1; } while (c & 0x80); return v - br; }
1threat
Interactive Jupyter/IPython notebooks in slideshow mode? : <p>Is it possible to run Jupyter Notebooks in an interactive slideshow mode? That is, Python kernel would be running in the background and I can modify and execute cells.</p> <p>The following command generates HTML slideshow and I can't modify nor execute the cells:</p> <pre><code>jupyter nbconvert mynotebook.ipynb --to slides --post serve </code></pre>
0debug
How to return a string from pandas.DataFrame.info() : <p>I would like to display the output from <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.info.html" rel="noreferrer"><code>pandas.DataFrame.info()</code></a> on a <code>tkinter</code> text widget so I need a string. However <code>pandas.DataFrame.info()</code> returns <code>NoneType</code> is there anyway I can change this?</p> <pre><code>import pandas as pd import numpy as np data = np.random.rand(10).reshape(5,2) cols = 'a', 'b' df = pd.DataFrame(data, columns=cols) df_info = df.info() print(df_info) type(df_info) </code></pre> <p>I'd like to do something like:</p> <pre><code>info_str = "" df_info = df.info(buf=info_str) </code></pre> <p>Is it possible to get <code>pandas</code> to return a string object from <code>DataFrame.info()</code>?</p>
0debug
PDFSharp: Copy and resize document and fit it into box : I'm using PDFSharp to create PDF. I am trying to copy other document/image (PDF format with A3 size) and paste it in the image box, in the new document (A4 size). In the new document, there will be have image details box and image box. So, how do I copy the image from other PDF into the image box in the new document? I also attach the sample I need to create using PDFSharp. [![enter image description here][1]][1] Thanks. [1]: https://i.stack.imgur.com/vdUX6.png
0debug
how convert the usd to other currency using php : <p>i need php coding for convert the USD TO ALL LOCAL CURRENCY.i find the lot of link stock overflow but they not working .especially this(<a href="https://www.google.com/finance/converter?a=" rel="nofollow noreferrer">https://www.google.com/finance/converter?a=</a>$amount&amp;from=$from&amp;to=$to) link not working kindly give the solution of my problem</p>
0debug
Why http.HandleFunc execute two times for one request? : <p>I build a very simple web sever with golang to understand the http package, but I find the HandleFunc function executed two times for one request, and there's a favicon.ico I have not expected.</p> <p>Here's the web server code:</p> <pre class="lang-golang prettyprint-override"><code>package main import ( "fmt" "log" "net/http" "strings" ) // sayHelloName a basic web function func sayHelloName(w http.ResponseWriter, r *http.Request) { r.ParseForm() // Parse parameters fmt.Println(r.Form) fmt.Println("path", r.URL.Path) fmt.Println("scheme", r.URL.Scheme) fmt.Println(r.Form["url_long"]) for k, v := range r.Form { fmt.Println("key", k) fmt.Println("val", strings.Join(v, "")) } fmt.Fprintf(w, "hello Go-web") } func main() { http.HandleFunc("/", sayHelloName) // log.Println("Serve listen at http://localhost:8900/") err := http.ListenAndServe(":8900", nil) if err != nil { log.Fatal("Listen &amp; Serve Error", err) } } </code></pre> <h2>visit <code>http://localhost:9090/?url_long=111&amp;url_long=222</code></h2> <p><strong>Real Output</strong><br/> map[url_long:[111 222]]<br/> path /<br/> scheme <br/> [111 222]<br/> key url_long<br/> val 111222<br/> map[]<br/> path /favicon.ico<br/> scheme <br/> []<br/> <strong>I don't understand why there's a favicon.ico here.</strong><br/> Any help will be appreciated.</p>
0debug
int qcow2_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_id, const char *name, Error **errp) { int i, snapshot_index; BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; uint64_t *new_l1_table; int new_l1_bytes; int ret; assert(bs->read_only); snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name); if (snapshot_index < 0) { error_setg(errp, "Can't find snapshot"); return -ENOENT; } sn = &s->snapshots[snapshot_index]; if (sn->l1_size > QCOW_MAX_L1_SIZE) { error_setg(errp, "Snapshot L1 table too large"); return -EFBIG; } new_l1_bytes = sn->l1_size * sizeof(uint64_t); new_l1_table = g_malloc0(align_offset(new_l1_bytes, 512)); ret = bdrv_pread(bs->file, sn->l1_table_offset, new_l1_table, new_l1_bytes); if (ret < 0) { error_setg(errp, "Failed to read l1 table for snapshot"); g_free(new_l1_table); return ret; } g_free(s->l1_table); s->l1_size = sn->l1_size; s->l1_table_offset = sn->l1_table_offset; s->l1_table = new_l1_table; for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } return 0; }
1threat
Database services on new vps : <p>There are services like ServerPilot and many others that install on a vps that handle the lamp stack env. I'm wondering if there is a service that does this for databases. I install the service on a fresh vps and that the service would do all the heavy lifting like security, replication, separate read writes, back-ups and monitoring a long with easily setting up private network access for a set fee to use that service on my server.</p> <p>Looking for a simple service to install on my own fresh vps, not RDS or Google Cloud.</p> <p>Thank you!</p>
0debug
static int hdev_create(const char *filename, QEMUOptionParameter *options) { int fd; int ret = 0; struct stat stat_buf; int64_t total_size = 0; while (options && options->name) { if (!strcmp(options->name, "size")) { total_size = options->value.n / 512; } options++; } fd = open(filename, O_WRONLY | O_BINARY); if (fd < 0) return -EIO; if (fstat(fd, &stat_buf) < 0) ret = -EIO; else if (!S_ISBLK(stat_buf.st_mode)) ret = -EIO; else if (lseek(fd, 0, SEEK_END) < total_size * 512) ret = -ENOSPC; close(fd); return ret; }
1threat
(HELP ME PLEASE ) >>> my program desing for claculating the ( average ) i can input in the program but i can't stop the loop and see the ( average ) : .MODEL SMALL .DATA VAL1 DB ? DISPLAY1 DB 0AH,0DH,'HOW MANY NUMBER OF STUDENT SCORES DO YOU WANT TO INPUT? :','$' DISPLAY2 DB 0AH,0DH,'ENTER NO:','$' DISPLAY3 DB 0AH,0DH,'AVEARGE:','$' BUFFER DB 3,4 DUP(?) .CODE MAIN PROC .STARTUP LEA DX,DISPLAY1 ; loads the message in the variable display 1 MOV AH,09H ; interrupt function to display the message INT 21H MOV AH,0AH ; Read into buffer INT 21H SUB AL,30H MOV CL,AL MOV BL,AL ; moves the content of al to bl register MOV AL,00 ; sets the value of al to zero, the value of al is now in bl register MOV VAL1,AL ; stores al in val1 NB: al is still zero. LBL1: LEA DX,DISPLAY2 ; displays message in display 2 MOV AH,09H INT 21H MOV AH,0AH ;Read into buffer LEA DX,BUFFER INT 21H SUB AL,30H ADD AL,VAL1 ; add val1 to al i.e, it now adds the previous value to the new one. MOV VAL1,AL ; saves the added value to val 1. LOOP LBL1 ; continues too add. LBL2: LEA DX,DISPLAY3 ; displays character in display 3 MOV AH,09H INT 21H MOV AX,00 ; sets ax value back to 00 MOV AL,VAL1 ; moves the total value back to al DIV BL ; divides the total value with the inputed number of values tht was stored in bl ADD AX,3030H ; convert to ASCII MOV DX,AX ; now moves the content of ax register to data register MOV AH,09H ; this displays the result INT 21H .EXIT MAIN ENDP END MAIN
0debug
How do I determine which dictionary has the most entries? : <p>I have a dictionary in which the key is a country code, and the value is a dictionary. For each country, the key is one of seven airport types, and the value is a list of airport names. </p> <p>I'm trying to determine what country has the most airports of a certain type. In other words, which country has the most entries in it's subdictionary for seaplane bases. </p> <p>How can I accomplish this? </p>
0debug
How do I turn an image (200x200 Black and White photos) into a single list of 40,000 values using numpy? : <p>As the title says I have an image (well a bunch of images) and I want to turn it from a 200x200 image into a 1-D list of 40,000.</p>
0debug
int bdrv_is_encrypted(BlockDriverState *bs) { if (bs->backing_hd && bs->backing_hd->encrypted) return 1; return bs->encrypted; }
1threat
number to be printed in a format using java : I am using java script to print a 10 digit number. example 1234567891. But i want that number to be printed in a particular format link 123.456.789-1. Can somebody please help me to sort this.
0debug
apksigner not accepting password : <p>Up until now I had been signing my apks with the following method:</p> <p><code>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore {keystore-file} {apk-file} {keystore-alias}</code></p> <p>However I am trying to use the new apksigner tool and I cannot get it to work since it always tells me the password is invalid. Which is impossible because I have done it multiple times, with the jarsigner works and with the apksigner doesn't. The commands I have tried are the following:</p> <p><code>apksigner sign --ks {keystore-file} {apk-file}</code></p> <p><code>apksigner sign --ks {keystore-file} --ks-key-alias {keystore-alias} {apk-file}</code></p> <p>Now the weirdest part comes when I created a new keystore to test this, and with this new keystore it's working. So I don't understand what is the difference. Here's the information obtained from calling "keytool -v -list -keystore {keystore-file}" on both.</p> <p>Production keystore (I have removed some text in case this is dangerous):</p> <pre><code>Keystore type: JKS Keystore provider: SUN Your keystore contains 1 entry Alias name: {keystore-alias} Creation date: Apr 4, 2016 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate[1]: Owner: CN={removed-text}, OU={removed-text}, O={removed-text}, L=Unknown, ST=Unknown, C=Unknown Issuer: CN={removed-text}, OU={removed-text}, O={removed-text}, L=Unknown, ST=Unknown, C=Unknown Serial number: {removed-text} Valid from: Mon Apr 04 12:39:50 CEST 2016 until: Fri Aug 21 12:39:50 CEST 2043 Certificate fingerprints: MD5: {removed-text} SHA1: {removed-text} SHA256: {removed-text} Signature algorithm name: SHA256withRSA Version: 3 Extensions: #1: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: {removed-text} 0010: {removed-text} {removed-text} .... ] ] ******************************************* ******************************************* </code></pre> <p>New test keystore:</p> <pre><code>Keystore type: JKS Keystore provider: SUN Your keystore contains 1 entry Alias name: app Creation date: Nov 17, 2016 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate[1]: Owner: CN=Foobar, OU=Foobar, O=foobar, L=Unknown, ST=Unknown, C=Unknown Issuer: CN=Foobar, OU=Foobar, O=foobar, L=Unknown, ST=Unknown, C=Unknown Serial number: 448c7afc Valid from: Thu Nov 17 11:40:26 CET 2016 until: Mon Apr 04 12:40:26 CEST 2044 Certificate fingerprints: MD5: 3E:29:C0:3C:30:B4:DC:E0:A5:94:1D:2E:E9:86:58:CA SHA1: 3D:09:B4:42:A2:7C:14:C7:3E:54:33:0E:AB:75:2E:F1:19:23:00:FA SHA256: 7F:E0:51:F1:6A:53:45:56:42:B9:F9:38:92:69:81:7A:DA:71:FF:44:51:15:7F:F9:B4:1C:AA:2B:53:4A:89:72 Signature algorithm name: SHA256withRSA Version: 3 Extensions: #1: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: BC 1B E6 C4 6D 25 01 70 CA AC 81 34 81 4B AE 41 ....m%.p...4.K.A 0010: 10 DF D8 13 .... ] ] ******************************************* ******************************************* </code></pre>
0debug
Flutter Android PreferenceScreen settings page : <p>Android has <code>PreferenceScreen</code> which provides you the consistent <a href="https://developer.android.com/guide/topics/ui/settings" rel="noreferrer">Settings</a> interface and handles a lot of <code>SharedPreferences</code> functionality on its own. </p> <p>Is there anything similar in Flutter or do I have to create it by my own using custom <code>ListView</code>?</p>
0debug
Daily notification on xamarin c# : <p>What is the best way to give the user an option to select time in the day in app and then they will receive a repeated notification on their phone at that time every day. I know there is a way to push notifications with app center and firebase but I just wanted to see if there is an easy way to set up repeated daily notifications with xamarin whether thats with forms or separate for ios and android and let the user choose when. Please let me know if there is a guide, tutorial, or anything I can use for this. I have experience with c# but I am fairly new to xamarin, so I appreciate any help.</p> <p>Thank you!</p>
0debug
int tcp_start_incoming_migration(const char *host_port) { struct sockaddr_in addr; int val; int s; if (parse_host_port(&addr, host_port) < 0) { fprintf(stderr, "invalid host/port combination: %s\n", host_port); return -EINVAL; } s = socket(PF_INET, SOCK_STREAM, 0); if (s == -1) return -socket_error(); val = 1; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val)); if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) == -1) goto err; if (listen(s, 1) == -1) goto err; qemu_set_fd_handler2(s, NULL, tcp_accept_incoming_migration, NULL, (void *)(unsigned long)s); return 0; err: close(s); return -socket_error(); }
1threat
static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt) { uint8_t buffer[4096]; size_t offset; offset = iov_to_buf(iov, iovcnt, 0, buffer, sizeof(buffer)); return nc->info->receive(nc, buffer, offset); }
1threat
PHP > Returning allowed paths : <p><em>I already asked this question but it was published a little confusing and therefore proberbly not answered. So I try again with an extra example, if it's fine.</em></p> <p>There are original array's with url's like the one in example 1 and 2. Every <strong>last</strong> folder of each element of the original array is the folder where some user has the right to view.</p> <p><strong>Example 1</strong></p> <pre><code>Array( 'a' 'a/b/c' 'a/b/c/d/e' 'a/y' 'b/z' 'b/z/q ) </code></pre> <p>I would like to get a two array's like:</p> <pre><code>Array['short']( 'a/c/e' 'a/y' 'z/q' ) Array['full']( 'a/b/c/d/e' 'a/y' 'b/z/q' ) </code></pre> <p><strong>Example 2</strong> </p> <pre><code>Array( 'projects/projectA/books' 'projects/projectA/books/cooking/book1' 'projects/projectA/walls/wall' 'projects/projectX/walls/wall' 'projects/projectZ/' 'projects/projectZ/Wood/Cheese/Bacon' ) </code></pre> <p>I would like to get a two array's like:</p> <pre><code>Array['short']( 'books/book1' 'wall' 'wall' 'projectZ/Bacon' ) Array['full']( 'projects/projectA/books/cooking/book1' 'projects/projectA/walls/wall' 'projects/projectX/walls/wall' 'projects/projectZ/Wood/Cheese/Bacon' ) </code></pre>
0debug
AspNet5 - Windows Authentication Get Group Name From Claims : <p>I have a asp.net5 project setup to use windows authentication. When I set a break point and look at the User, I see that there is a Claims array that contains Group SID's. How do I get the actual group name from the claims?</p> <p>I am trying to limit the windows logged in user using the active directory groups that they belong to, and am struggling setting it up.</p> <p>Questions: How can I see the active directory groups that the logged in user belongs to? How do I convert the GroupSID's to a group name? Do I need to include anything in the startup.cs to limit certain groups to REST service calls?</p> <p>I see examples of setting up claims manually based upon the logged in user. I am interested in using the Windows authenticated user and their groups to limit access.</p> <p>Thanks</p>
0debug
HTML5/Bootstrap - How do i add tooltip for bootstrap glyphicon icons? : <p>How do i add the tooltip for the below HTML5 statement?</p> <pre><code>&lt;tr&gt;&lt;td&gt;&lt;a ng-href="#"&gt;Call us&lt;/a&gt; &lt;span class="glyphicon glyphicon-phone" &gt; &lt;/span&gt; &lt;/td&gt; </code></pre>
0debug
installing packages in R - warning messages : <p>I tried to install packages in R. But, R software gives warning messages in the below picture. How to install packages in ?</p> <p><a href="https://i.stack.imgur.com/naDtw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/naDtw.png" alt="enter image description here"></a></p>
0debug
Conditional Validation in Yup : <p>I have an email field that only gets shown if a checkbox is selected (boolean value is <code>true</code>). When the form get submitted, I only what this field to be required if the checkbox is checked (boolean is true). </p> <p>This is what I've tried so far:</p> <pre><code> const validationSchema = yup.object().shape({ email: yup .string() .email() .label('Email') .when('showEmail', { is: true, then: yup.string().required('Must enter email address'), }), }) </code></pre> <p>I've tried several other variations, but I get errors from Formik and Yup:</p> <p><code>Uncaught (in promise) TypeError: Cannot read property 'length' of undefined at yupToFormErrors (formik.es6.js:6198) at formik.es6.js:5933 at &lt;anonymous&gt; yupToFormErrors @ formik.es6.js:6198 </code></p> <p>And I get validation errors from Yup as well. What am I doing wrong? </p>
0debug
Spark DataFrame - Select n random rows : <p>I have a dataframe with multiple thousands of records, and I'd like to randomly select 1000 rows into another dataframe for demoing. How can I do this in Java? </p> <p>Thank you!</p>
0debug
Java - How can I run the javascript in all my html rows : I am creating invoice form, I have written a Java Script to calculate Tax and Discount price as the user the value, But it is just working in one row how can I enable it to work on all the rows Javascript[Javascript to calculate discount and tax][1] [Html form][2] [1]: http://i.stack.imgur.com/ZkuWK.jpg [2]: http://i.stack.imgur.com/i2IPs.jpg
0debug
static void akita_init(int ram_size, int vga_ram_size, int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { spitz_common_init(ram_size, vga_ram_size, ds, kernel_filename, kernel_cmdline, initrd_filename, akita, 0x2e8); }
1threat
Child node "2" exited prematurely : <p>I recently retargeted my Windows 8.1 app to Windows 10. I'm getting this error when building the UI projects, </p> <pre><code>"MSBUILD : error MSB4166: Child node "2" exited prematurely. Shutting down. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt." </code></pre> <p>That's not particularly useful, so I went to %temp% looking for said failure log, and it doesn't exist. Am I looking in the wrong "temp" directory?</p> <p>What causes this error? I can build my supporting library project without this error.</p>
0debug
Xamarin Forms image not showing : <p>I have a Xamarin Forms (2.0) Android app where I'm trying to show an image. I've got an icon called <code>icon-pages-r1.png</code> which I'm trying to show using the following code:</p> <pre><code>&lt;Image Source="icon-pages-r1.png" /&gt; </code></pre> <p>The image isn't showing though. When I change the source to <code>Icon.png</code> (the default Xamarin icon) it does work.</p> <p>The image is a semi-transparent PNG (thus a colored icon in the middle and transparent around it), it's 46x46 and in Windows it shows fine as item type PNG File. I tried opening the image in Paint and re-saving it (which kills the transparency) but that doesn't work either. The <code>Build Action</code> for the images are <code>AndroidResource</code> with <code>Copy to Output Directory</code> set to <code>Do not copy</code>.</p> <p>Does anyone know why I can't get this image to show in my app?</p>
0debug
why am i getting null pointer exception when trying to set a value to "rating" in my rating bar? : <p>I can see that the exception occurs at "rtb.setRating(8.0f);" Also, i am able to set the rating manually in the xml file and that produces the intended outcome, e.g. android:rating="3.7"</p> <pre><code>static String ingredients[] = {"Ingredient1","Ingredient2","Ingredient3","Ingredient4","Ingredient5","Ingredient6","Ingredient7","Ingredient8","Ingredient9","Ingredient10","Ingredient11","Ingredient12","Ingredient13","Ingredient14","Ingredient15","Ingredient16","Ingredient17","Ingredient18","Ingredient19","Ingredient20"}; static String steps[] = {"Step1","Step2","Step3","Step4","Step5","Step6","Step7","Step8","Step9","Step10"}; String url = "http://192.168.1.2/cricketjson.txt"; private ListView mDrawerList; private ArrayAdapter&lt;String&gt; mAdapter; static int[] ids = {1,2,3,4,5}; /** * Fragment managing the behaviors, interactions and presentation of the navigation drawer. */ private NavigationDrawerFragment mNavigationDrawerFragment; /** * Used to store the last screen title. For use in {@link #restoreActionBar()}. */ private CharSequence mTitle; private CharSequence mStep; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); RatingBar rtb = (RatingBar) findViewById(R.id.rb); rtb.setRating(8.0f); setContentView(R.layout.activity_recipe); mDrawerList = (ListView)findViewById(R.id.navList); //set visual features //set string values TextView[] txtStep = {(TextView) findViewById(R.id.txtStep1), (TextView) findViewById(R.id.txtStep2)}; //txtStep1.setText("ftUr"); //set font Title TextView mRecipeTitle = (TextView) findViewById(R.id.Title); Typeface face = Typeface.createFromAsset(getAssets(), "Italianno-Regular.ttf"); mRecipeTitle.setTypeface(face); mRecipeTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 77); // set scrollview as transparent findViewById(R.id.recipScrollView).setBackgroundColor(getResources().getColor(android.R.color.transparent)); // PD = new ProgressDialog(this); // PD.setMessage("Loading....."); mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp( R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Toast.makeText(RecipeActivity.this, "Time for an upgrade!", Toast.LENGTH_SHORT).show(); } }); //here*#8*#* put in the steps to the func.jsonrq // Funcs.makejsonobjreq(ingredients, url, this,steps,id); Funcs.makejsonobjreq(ingredients, url, this); Funcs.makejsonobjreqrecipe(ingredients, url, this, steps, ids[0], txtStep); } @Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.container, PlaceholderFragment.newInstance(position + 1)) .commit(); } public void onSectionAttached(int number) { switch (number) { case 1: mTitle = getString(R.string.title_Recipe); break; case 2: mTitle = ingredients[0]; break; case 3: mTitle = ingredients[1]; break; case 4: mTitle = ingredients[2]; break; case 5: mTitle = ingredients[3]; break; case 6: mTitle = ingredients[4]; break; case 7: mTitle = ingredients[5]; break; case 8: mTitle = ingredients[6]; break; case 9: mTitle = ingredients[7]; break; case 10: mTitle = ingredients[8]; break; case 11: mTitle = ingredients[9]; break; case 12: mTitle = ingredients[10]; break; case 13: mTitle = ingredients[11]; break; case 14: mTitle = ingredients[12]; break; case 15: mTitle = ingredients[13]; break; case 16: mTitle = ingredients[14]; break; case 17: mTitle = ingredients[15]; break; case 18: mTitle = ingredients[16]; break; case 19: mTitle = ingredients[17]; break; case 20: mTitle = ingredients[18]; break; case 21: mTitle = ingredients[19]; break; } } public void restoreActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(mTitle); } @Override public boolean onCreateOptionsMenu(Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) { // Only show items in the action bar relevant to this screen // if the drawer is not showing. Otherwise, let the drawer // decide what to show in the action bar. getMenuInflater().inflate(R.menu.recipe, menu); restoreActionBar(); return true; } return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment argument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; } public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_recipe, container, false); return rootView; } @Override public void onAttach(Activity activity) { super.onAttach(activity); ((RecipeActivity) activity).onSectionAttached( getArguments().getInt(ARG_SECTION_NUMBER)); } } } </code></pre> <p>And the coressponding XML:</p> <p> </p> <pre><code>&lt;!-- As the main content view, the view below consumes the entire space available using match_parent in both dimensions. --&gt; &lt;FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;LinearLayout android:background="@drawable/background8" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingTop="20dip" android:layout_gravity="right|center_vertical" android:weightSum="1"&gt; &lt;TextView android:layout_marginTop="0dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Text" android:id="@+id/Creator" android:layout_alignLeft="@id/title" android:textSize="20dp" android:layout_gravity="center_horizontal" /&gt; &lt;TextView android:layout_marginTop="30dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Large Text" android:id="@+id/Title" android:layout_below="@id/Creator" android:layout_gravity="center_horizontal" /&gt; &lt;ScrollView android:layout_width="match_parent" android:layout_marginTop="0dp" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" android:layout_height="198dp" android:background="#ffffff" android:id="@+id/recipScrollView"&gt; &lt;LinearLayout android:layout_marginLeft="30dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="20dip" android:weightSum="1"&gt; &lt;TextView android:layout_marginTop="0dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Txt" android:id="@+id/txtStep1" /&gt; &lt;TextView android:layout_marginTop="30dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Txt" android:id="@+id/txtStep2" android:layout_below="@id/txtStep1"/&gt;/&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;RatingBar android:layout_marginTop="30dp" android:layout_marginLeft="30dp" android:id="@+id/rb" style="?android:attr/ratingBarStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:max="10" android:numStars="10" android:rating="3.7" android:stepSize="0.0" /&gt; &lt;/LinearLayout&gt; &lt;/FrameLayout&gt; &lt;!-- android:layout_gravity="start" tells DrawerLayout to treat this as a sliding drawer on the left side for left-to-right languages and on the right side for right-to-left languages. If you're not building against API 17 or higher, use android:layout_gravity="left" instead. --&gt; &lt;!-- The drawer is given a fixed width in dp and extends the full height of the container. --&gt; &lt;fragment android:id="@+id/navigation_drawer" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:layout_gravity="start" android:name="com.example.finnb.rcp.NavigationDrawerFragment" tools:layout="@layout/fragment_navigation_drawer" /&gt; &lt;ListView android:id="@+id/navList" android:layout_width="200dp" android:layout_height="match_parent" android:layout_gravity="left|start" android:background="#ffeeeeee"/&gt; </code></pre> <p></p> <p>And the LogCat error:</p> <pre><code>03-08 04:52:30.350 1946-1946/com.example.finnb.rcp D/dalvikvm﹕ Not late-enabling CheckJNI (already on) 03-08 04:52:30.460 1946-1946/com.example.finnb.rcp D/AndroidRuntime﹕ Shutting down VM 03-08 04:52:30.460 1946-1946/com.example.finnb.rcp W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb0ca2b20) 03-08 04:52:30.460 1946-1946/com.example.finnb.rcp E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.finnb.rcp, PID: 1946 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.finnb.rcp/com.example.finnb.rcp.RecipeActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.example.finnb.rcp.RecipeActivity.onCreate(RecipeActivity.java:62) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)             at android.app.ActivityThread.access$800(ActivityThread.java:135)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:136)             at android.app.ActivityThread.main(ActivityThread.java:5017)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)             at dalvik.system.NativeStart.main(Native Method) </code></pre>
0debug
static void gen_casx_asi(DisasContext *dc, TCGv addr, TCGv val2, int insn, int rd) { TCGv val1 = gen_load_gpr(dc, rd); TCGv dst = gen_dest_gpr(dc, rd); TCGv_i32 r_asi = gen_get_asi(dc, insn); gen_helper_casx_asi(dst, cpu_env, addr, val1, val2, r_asi); tcg_temp_free_i32(r_asi); gen_store_gpr(dc, rd, dst); }
1threat
static int ppc_hash64_translate(CPUPPCState *env, struct mmu_ctx_hash64 *ctx, target_ulong eaddr, int rwx) { int ret; ppc_slb_t *slb; hwaddr pte_offset; ppc_hash_pte64_t pte; int target_page_bits; assert((rwx == 0) || (rwx == 1) || (rwx == 2)); if (((rwx == 2) && (msr_ir == 0)) || ((rwx != 2) && (msr_dr == 0))) { ctx->raddr = eaddr & 0x0FFFFFFFFFFFFFFFULL; ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE; return 0; } slb = slb_lookup(env, eaddr); if (!slb) { return -5; } if ((rwx == 2) && (slb->vsid & SLB_VSID_N)) { return -3; } pte_offset = ppc_hash64_htab_lookup(env, slb, eaddr, &pte); if (pte_offset == -1) { return -1; } LOG_MMU("found PTE at offset %08" HWADDR_PRIx "\n", pte_offset); ctx->key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP) : (slb->vsid & SLB_VSID_KS)); int access, pp; bool nx; pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61); nx = (pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G); access = ppc_hash64_pp_check(ctx->key, pp, nx); ctx->raddr = pte.pte1; ctx->prot = access; ret = ppc_hash64_check_prot(ctx->prot, rwx); if (ret) { LOG_MMU("PTE access rejected\n"); return ret; } LOG_MMU("PTE access granted !\n"); if (ppc_hash64_pte_update_flags(ctx, &pte.pte1, ret, rwx) == 1) { ppc_hash64_store_hpte1(env, pte_offset, pte.pte1); } target_page_bits = (slb->vsid & SLB_VSID_L) ? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS; if (target_page_bits != TARGET_PAGE_BITS) { ctx->raddr |= (eaddr & ((1 << target_page_bits) - 1)) & TARGET_PAGE_MASK; } return ret; }
1threat
How do x86 sub-register specific assembly instructions interact with the whole? : <p>Mostly asking about arithmetic operations.</p> <p>Example: </p> <p>Assume 32-bit hardware eax stores 0xff000000</p> <p>If "sub al, 0x10" is called, do the higher bytes/bits change? Does it affect the whole register, or does it confine the operation to that subdivision?</p> <p>Do other operations (add, sal, sar, etc.) have consistent whole/sub register interactions?</p>
0debug
import math def min_Operations(A,B): if (A > B): swap(A,B) B = B // math.gcd(A,B); return B - 1
0debug
static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) { BDRVSheepdogState *s = bs->opaque; BDRVSheepdogState *old_s; char tag[SD_MAX_VDI_TAG_LEN]; uint32_t snapid = 0; int ret = 0; old_s = g_malloc(sizeof(BDRVSheepdogState)); memcpy(old_s, s, sizeof(BDRVSheepdogState)); snapid = strtoul(snapshot_id, NULL, 10); if (snapid) { tag[0] = 0; } else { pstrcpy(tag, sizeof(tag), snapshot_id); } ret = reload_inode(s, snapid, tag); if (ret) { goto out; } ret = sd_create_branch(s); if (ret) { goto out; } g_free(old_s); return 0; out: memcpy(s, old_s, sizeof(BDRVSheepdogState)); g_free(old_s); error_report("failed to open. recover old bdrv_sd_state."); return ret; }
1threat
static void async_complete(void *opaque) { USBHostDevice *s = opaque; AsyncURB *aurb; int urbs = 0; while (1) { USBPacket *p; int r = ioctl(s->fd, USBDEVFS_REAPURBNDELAY, &aurb); if (r < 0) { if (errno == EAGAIN) { if (urbs > 2) { fprintf(stderr, "husb: %d iso urbs finished at once\n", urbs); } return; } if (errno == ENODEV) { if (!s->closing) { trace_usb_host_disconnect(s->bus_num, s->addr); do_disconnect(s); } return; } perror("USBDEVFS_REAPURBNDELAY"); return; } DPRINTF("husb: async completed. aurb %p status %d alen %d\n", aurb, aurb->urb.status, aurb->urb.actual_length); if (aurb->iso_frame_idx == -1) { int inflight; int pid = (aurb->urb.endpoint & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT; int ep = aurb->urb.endpoint & 0xf; if (aurb->urb.status == -EPIPE) { set_halt(s, pid, ep); } aurb->iso_frame_idx = 0; urbs++; inflight = change_iso_inflight(s, pid, ep, -1); if (inflight == 0 && is_iso_started(s, pid, ep)) { fprintf(stderr, "husb: out of buffers for iso stream\n"); } continue; } p = aurb->packet; trace_usb_host_urb_complete(s->bus_num, s->addr, aurb, aurb->urb.status, aurb->urb.actual_length, aurb->more); if (p) { switch (aurb->urb.status) { case 0: p->result += aurb->urb.actual_length; break; case -EPIPE: set_halt(s, p->pid, p->devep); p->result = USB_RET_STALL; break; default: p->result = USB_RET_NAK; break; } if (aurb->urb.type == USBDEVFS_URB_TYPE_CONTROL) { trace_usb_host_req_complete(s->bus_num, s->addr, p->result); usb_generic_async_ctrl_complete(&s->dev, p); } else if (!aurb->more) { trace_usb_host_req_complete(s->bus_num, s->addr, p->result); usb_packet_complete(&s->dev, p); } } async_free(aurb); } }
1threat
UIControlState.Normal is Unavailable : <p>Previously for <code>UIButton</code> instances, you were able to pass in <code>UIControlState.Normal</code> for <code>setTitle</code> or <code>setImage</code>. <code>.Normal</code> is no longer available, what should I use instead?</p> <pre><code>let btn = UIButton(frame: CGRect(x: 0, y: 0, width: 20, height: 20)) btn.setTitle("title", for: .Normal) // does not compile </code></pre> <p><sup>(This is a canonical Q&amp;A pair to prevent the flood of duplicate questions related to this <code>UIButton</code> and <code>UIControl</code> changes with iOS 10 and Swift 3)</sup></p>
0debug
Prevent dplyr from joining on NA's : <p>I'd like to do a full-join of 2 df's. To my surprise, dplyr's default behavior is to join on NA's if they exist in both df's. Is there a functionality to prevent dplyr from doing this?</p> <p>Here's an example with inner join:</p> <pre><code>x &lt;- data.frame(a = c(5, NA, 9), b = 1:3) y &lt;- data.frame(a = c(5, NA, 9), c = 4:6) z &lt;- dplyr::inner_join(x, y, by = 'a') </code></pre> <p>I would like z to contain only 2 records, not 3. Ideally, I want to do this without having to manually filter out the records with NA's beforehand and then append them to the result (since that seems clumsy).</p>
0debug
Replace while loop with for each : <p>How can I replace while loop below with for each loop in Java? </p> <pre><code>JSONObject postParameters = new JSONObject(); Map parameterMap = httpRequest.getParameterMap(); Iterator&lt;Map.Entry&lt;String, String[]&gt;&gt; it = parameterMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry&lt;String, String[]&gt; entry = it.next(); if(entry.getValue().length == 1){ postParameters.put(entry.getKey(), entry.getValue()[0].toString()); } else{ JSONArray valueList = new JSONArray(); for(String value : entry.getValue()){ valueList.add(value.toString()); } postParameters.put(entry.getKey(), valueList); } } </code></pre> <p>Basically I want to make it bit more readable.</p>
0debug
Java while loop not breaking after break; statment : import java.util.Scanner; public class LoopsEndingRemembering { public static void main(String[] args) { // program in this project exercises 36.1-36.5 // actually this is just one program that is split in many parts Scanner reader = new Scanner(System.in); System.out.println("Type numbers: "); int input = Integer.parseInt(reader.nextLine()); while(true){ if(input == -1){ break; } } System.out.println("Thank you and see you later!"); } } //The user should be able to put in multiple numbers until -1 is reached. Once its reached it should break the loop and print the last line.
0debug
Expose port in minikube : <p>In minikube, how to expose a service using nodeport ?</p> <p>For example, I start a kubernetes cluster using the following command and create and expose a port like this:</p> <pre><code>$ minikube start $ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080 $ kubectl expose deployment hello-minikube --type=NodePort $ curl $(minikube service hello-minikube --url) CLIENT VALUES: client_address=192.168.99.1 command=GET real path=/ .... </code></pre> <p>Now how to access the exposed service from the host? I guess the minikube node needs to be configured to expose this port as well. </p>
0debug
build_dsdt(GArray *table_data, GArray *linker, AcpiPmInfo *pm, AcpiMiscInfo *misc, PcPciInfo *pci, MachineState *machine) { CrsRangeEntry *entry; Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs; GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free); GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free); PCMachineState *pcms = PC_MACHINE(machine); uint32_t nr_mem = machine->ram_slots; int root_bus_limit = 0xFF; PCIBus *bus = NULL; int i; dsdt = init_aml_allocator(); acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); build_dbg_aml(dsdt); if (misc->is_piix4) { sb_scope = aml_scope("_SB"); dev = aml_device("PCI0"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03"))); aml_append(dev, aml_name_decl("_ADR", aml_int(0))); aml_append(dev, aml_name_decl("_UID", aml_int(1))); aml_append(sb_scope, dev); aml_append(dsdt, sb_scope); build_hpet_aml(dsdt); build_piix4_pm(dsdt); build_piix4_isa_bridge(dsdt); build_isa_devices_aml(dsdt); build_piix4_pci_hotplug(dsdt); build_piix4_pci0_int(dsdt); } else { sb_scope = aml_scope("_SB"); aml_append(sb_scope, aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(0xae00), 0x0c)); aml_append(sb_scope, aml_operation_region("PCSB", AML_SYSTEM_IO, aml_int(0xae0c), 0x01)); field = aml_field("PCSB", AML_ANY_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS); aml_append(field, aml_named_field("PCIB", 8)); aml_append(sb_scope, field); aml_append(dsdt, sb_scope); sb_scope = aml_scope("_SB"); dev = aml_device("PCI0"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08"))); aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03"))); aml_append(dev, aml_name_decl("_ADR", aml_int(0))); aml_append(dev, aml_name_decl("_UID", aml_int(1))); aml_append(dev, aml_name_decl("SUPP", aml_int(0))); aml_append(dev, aml_name_decl("CTRL", aml_int(0))); aml_append(dev, build_q35_osc_method()); aml_append(sb_scope, dev); aml_append(dsdt, sb_scope); build_hpet_aml(dsdt); build_q35_isa_bridge(dsdt); build_isa_devices_aml(dsdt); build_q35_pci0_int(dsdt); build_cpu_hotplug_aml(dsdt); build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); scope = aml_scope("_GPE"); { aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006"))); aml_append(scope, aml_method("_L00", 0, AML_NOTSERIALIZED)); if (misc->is_piix4) { method = aml_method("_E01", 0, AML_NOTSERIALIZED); aml_append(method, aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF)); aml_append(method, aml_call0("\\_SB.PCI0.PCNT")); aml_append(method, aml_release(aml_name("\\_SB.PCI0.BLCK"))); aml_append(scope, method); } else { aml_append(scope, aml_method("_L01", 0, AML_NOTSERIALIZED)); method = aml_method("_E02", 0, AML_NOTSERIALIZED); aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD)); aml_append(scope, method); method = aml_method("_E03", 0, AML_NOTSERIALIZED); aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH)); aml_append(scope, method); aml_append(scope, aml_method("_L04", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L05", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L06", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L07", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L08", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L09", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L0A", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L0B", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L0C", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L0D", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L0E", 0, AML_NOTSERIALIZED)); aml_append(scope, aml_method("_L0F", 0, AML_NOTSERIALIZED)); aml_append(dsdt, scope); bus = PC_MACHINE(machine)->bus; if (bus) { QLIST_FOREACH(bus, &bus->child, sibling) { uint8_t bus_num = pci_bus_num(bus); uint8_t numa_node = pci_bus_numa_node(bus); if (!pci_bus_is_root(bus)) { continue; if (bus_num < root_bus_limit) { root_bus_limit = bus_num - 1; scope = aml_scope("\\_SB"); dev = aml_device("PC%.02X", bus_num); aml_append(dev, aml_name_decl("_UID", aml_int(bus_num))); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03"))); aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num))); if (numa_node != NUMA_NODE_UNASSIGNED) { aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node))); aml_append(dev, build_prt(false)); crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent), io_ranges, mem_ranges); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(scope, dev); aml_append(dsdt, scope); scope = aml_scope("\\_SB.PCI0"); crs = aml_resource_template(); aml_append(crs, aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE, 0x0000, 0x0, root_bus_limit, 0x0000, root_bus_limit + 1)); aml_append(crs, aml_io(AML_DECODE16, 0x0CF8, 0x0CF8, 0x01, 0x08)); aml_append(crs, aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE, AML_ENTIRE_RANGE, 0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8)); crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF); for (i = 0; i < io_ranges->len; i++) { entry = g_ptr_array_index(io_ranges, i); aml_append(crs, aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE, AML_ENTIRE_RANGE, 0x0000, entry->base, entry->limit, 0x0000, entry->limit - entry->base + 1)); aml_append(crs, aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, AML_CACHEABLE, AML_READ_WRITE, 0, 0x000A0000, 0x000BFFFF, 0, 0x00020000)); crs_replace_with_free_ranges(mem_ranges, pci->w32.begin, pci->w32.end - 1); for (i = 0; i < mem_ranges->len; i++) { entry = g_ptr_array_index(mem_ranges, i); aml_append(crs, aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, AML_NON_CACHEABLE, AML_READ_WRITE, 0, entry->base, entry->limit, 0, entry->limit - entry->base + 1)); if (pci->w64.begin) { aml_append(crs, aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, AML_CACHEABLE, AML_READ_WRITE, 0, pci->w64.begin, pci->w64.end - 1, 0, pci->w64.end - pci->w64.begin)); aml_append(scope, aml_name_decl("_CRS", crs)); dev = aml_device("GPE0"); aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06"))); aml_append(dev, aml_name_decl("_UID", aml_string("GPE0 resources"))); aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, pm->gpe0_blk, pm->gpe0_blk, 1, pm->gpe0_blk_len) ); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(scope, dev); g_ptr_array_free(io_ranges, true); g_ptr_array_free(mem_ranges, true); if (pm->pcihp_io_len) { dev = aml_device("PHPR"); aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06"))); aml_append(dev, aml_name_decl("_UID", aml_string("PCI Hotplug resources"))); aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, pm->pcihp_io_base, pm->pcihp_io_base, 1, pm->pcihp_io_len) ); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(scope, dev); aml_append(dsdt, scope); scope = aml_scope("\\"); if (!pm->s3_disabled) { pkg = aml_package(4); aml_append(pkg, aml_int(1)); aml_append(pkg, aml_int(1)); aml_append(pkg, aml_int(0)); aml_append(pkg, aml_int(0)); aml_append(scope, aml_name_decl("_S3", pkg)); if (!pm->s4_disabled) { pkg = aml_package(4); aml_append(pkg, aml_int(pm->s4_val)); aml_append(pkg, aml_int(pm->s4_val)); aml_append(pkg, aml_int(0)); aml_append(pkg, aml_int(0)); aml_append(scope, aml_name_decl("_S4", pkg)); pkg = aml_package(4); aml_append(pkg, aml_int(0)); aml_append(pkg, aml_int(0)); aml_append(pkg, aml_int(0)); aml_append(pkg, aml_int(0)); aml_append(scope, aml_name_decl("_S5", pkg)); aml_append(dsdt, scope); { uint8_t io_size = object_property_get_bool(OBJECT(pcms->fw_cfg), "dma_enabled", NULL) ? ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : FW_CFG_CTL_SIZE; scope = aml_scope("\\_SB.PCI0"); dev = aml_device("FWCF"); aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size) ); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(scope, dev); aml_append(dsdt, scope); if (misc->applesmc_io_base) { scope = aml_scope("\\_SB.PCI0.ISA"); dev = aml_device("SMC"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001"))); aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, misc->applesmc_io_base, misc->applesmc_io_base, 0x01, APPLESMC_MAX_DATA_LENGTH) ); aml_append(crs, aml_irq_no_flags(6)); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(scope, dev); aml_append(dsdt, scope); if (misc->pvpanic_port) { scope = aml_scope("\\_SB.PCI0.ISA"); dev = aml_device("PEVT"); aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001"))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1) ); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO, aml_int(misc->pvpanic_port), 1)); field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); aml_append(field, aml_named_field("PEPT", 8)); aml_append(dev, field); aml_append(dev, aml_name_decl("_STA", aml_int(0xF))); method = aml_method("RDPT", 0, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_name("PEPT"), aml_local(0))); aml_append(method, aml_return(aml_local(0))); aml_append(dev, method); method = aml_method("WRPT", 1, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_arg(0), aml_name("PEPT"))); aml_append(dev, method); aml_append(scope, dev); aml_append(dsdt, scope); sb_scope = aml_scope("\\_SB"); { build_processor_devices(sb_scope, machine, pm); build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); { Object *pci_host; PCIBus *bus = NULL; pci_host = acpi_get_i386_pci_host(); if (pci_host) { bus = PCI_HOST_BRIDGE(pci_host)->bus; if (bus) { Aml *scope = aml_scope("PCI0"); build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en); dev = aml_device("ISA.TPM"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31"))); aml_append(dev, aml_name_decl("_STA", aml_int(0xF))); crs = aml_resource_template(); aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(scope, dev); aml_append(sb_scope, scope); aml_append(dsdt, sb_scope); g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); build_header(linker, table_data, (void *)(table_data->data + table_data->len - dsdt->buf->len), "DSDT", dsdt->buf->len, 1, NULL, NULL); free_aml_allocator();
1threat
int tlb_set_page_exec(CPUState *env, target_ulong vaddr, target_phys_addr_t paddr, int prot, int mmu_idx, int is_softmmu) { PhysPageDesc *p; unsigned long pd; unsigned int index; target_ulong address; target_ulong code_address; target_phys_addr_t addend; int ret; CPUTLBEntry *te; CPUWatchpoint *wp; target_phys_addr_t iotlb; p = phys_page_find(paddr >> TARGET_PAGE_BITS); if (!p) { pd = IO_MEM_UNASSIGNED; } else { pd = p->phys_offset; } #if defined(DEBUG_TLB) printf("tlb_set_page: vaddr=" TARGET_FMT_lx " paddr=0x%08x prot=%x idx=%d smmu=%d pd=0x%08lx\n", vaddr, (int)paddr, prot, mmu_idx, is_softmmu, pd); #endif ret = 0; address = vaddr; if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) { address |= TLB_MMIO; } addend = (unsigned long)qemu_get_ram_ptr(pd & TARGET_PAGE_MASK); if ((pd & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) { iotlb = pd & TARGET_PAGE_MASK; if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM) iotlb |= IO_MEM_NOTDIRTY; else iotlb |= IO_MEM_ROM; } else { iotlb = (pd & ~TARGET_PAGE_MASK); if (p) { iotlb += p->region_offset; } else { iotlb += paddr; } } code_address = address; TAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { iotlb = io_mem_watch + paddr; address |= TLB_MMIO; } } index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); env->iotlb[mmu_idx][index] = iotlb - vaddr; te = &env->tlb_table[mmu_idx][index]; te->addend = addend - vaddr; if (prot & PAGE_READ) { te->addr_read = address; } else { te->addr_read = -1; } if (prot & PAGE_EXEC) { te->addr_code = code_address; } else { te->addr_code = -1; } if (prot & PAGE_WRITE) { if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_ROM || (pd & IO_MEM_ROMD)) { te->addr_write = address | TLB_MMIO; } else if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM && !cpu_physical_memory_is_dirty(pd)) { te->addr_write = address | TLB_NOTDIRTY; } else { te->addr_write = address; } } else { te->addr_write = -1; } return ret; }
1threat
C division in fraction : In c programming when I divide 2 numbers like 2/4 it gives output 0.5 but I want 1/2. So I want know how to perform division to get answer in fractions like numerator/denominator.
0debug
VBA Code to pick from range : I am trying to write a simple VBA code to pick up a complete row from one sheet and copy to another sheet based o cetain If condition For Ex: If the first value in the row is Cricket, system will create a worksheet in the name of cricket and whatever row has the first value as cricket, it will copy and paste the row in to that sheet i have written below, however its not working as expected Sub officetest() Worksheets("Sheet1").Activate If Range("A1,A10000") = "Cricket" Then Sheets.Add Sheets(2).Name = "Cricket" Worksheets("Sheet1").Range("A1, A10000").Copy Worksheets("Sheet2").Range("A1") End If End Sub
0debug
static void coroutine_fn v9fs_xattrcreate(void *opaque) { int flags; int32_t fid; int64_t size; ssize_t err = 0; V9fsString name; size_t offset = 7; V9fsFidState *file_fidp; V9fsFidState *xattr_fidp; V9fsPDU *pdu = opaque; v9fs_string_init(&name); err = pdu_unmarshal(pdu, offset, "dsqd", &fid, &name, &size, &flags); if (err < 0) { goto out_nofid; } trace_v9fs_xattrcreate(pdu->tag, pdu->id, fid, name.data, size, flags); file_fidp = get_fid(pdu, fid); if (file_fidp == NULL) { err = -EINVAL; goto out_nofid; } xattr_fidp = file_fidp; xattr_fidp->fid_type = P9_FID_XATTR; xattr_fidp->fs.xattr.copied_len = 0; xattr_fidp->fs.xattr.len = size; xattr_fidp->fs.xattr.flags = flags; v9fs_string_init(&xattr_fidp->fs.xattr.name); v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name); xattr_fidp->fs.xattr.value = g_malloc(size); err = offset; put_fid(pdu, file_fidp); out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name); }
1threat