problem
stringlengths
26
131k
labels
class label
2 classes
Check a value is exactly 0? : <p>I want to check whether a value <code>s</code> is exactly zero,but when <code>s = False</code>, <code>s == 0</code> is also true.Thus how to address such case?<br> Thanks in advance!</p>
0debug
vArray if else macro Excel 2016 : I am trying to create a macro the adds different pages to a pdf based on a check box status. This is what I currently have. Sub ToyotaMO() ' ' ToyotaMO Macro ' Sheets("TC").Visible = True Sheets("BS").Visible = True Sheets("ToyotaMO").Activate If Sheets("ACM").OLEObjects("Toyota").Object.Value = True Then vArray = Array("ToyotaMO", "TC", "BS") Else vArray = Array("Proposal", "TC") End If ThisWorkbook.Sheets(vArray).Select ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ ThisWorkbook.Path & "\" & ActiveSheet.Range("C5").Value & " Toyota Material Only ACM Proposal" & Format(Date, " MMDDYY") & ".pdf" _ , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ :=False, OpenAfterPublish:=True Sheets("ToyotaMO").Activate Range("A1").Select Sheets("TC").Visible = False Sheets("BS").Visible = False Sheets("ACM").Select Range("B1").Select End Sub The macro works on all the other forms the only difference is I need to add worksheet "BS" to the PDF if the checkbox is checked. VBA always stalls at ThisWorkbook.Sheets(vArray).Select. Any help is greatly appreciated
0debug
What are Android Architecture Components,LiveData and ViewModel? : <p>As a beginner it is very hard to understand what are these things Is there any resource which can give a grasp knowledge of things in easy language?</p>
0debug
static void show_programs(WriterContext *w, AVFormatContext *fmt_ctx) { int i; writer_print_section_header(w, SECTION_ID_PROGRAMS); for (i = 0; i < fmt_ctx->nb_programs; i++) { AVProgram *program = fmt_ctx->programs[i]; if (!program) continue; show_program(w, fmt_ctx, program); } writer_print_section_footer(w); }
1threat
Matlab repmat into long single dismension array? : <p>I'm trying to take: </p> <pre><code>a = [1 2 3] </code></pre> <p>and repeat it 5 times to get: </p> <pre><code>b = [1 2 3 1 2 3 1 2 3 1 2 3 1 2 3] </code></pre> <p>but when I try: </p> <pre><code>b = repmat(a, 5, 1) </code></pre> <p>instead I get: </p> <pre><code> b = 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 </code></pre> <p>I could probably do it with a for loop but I'd like to do it correctly if possible. Any suggestions? Thanks in advance</p>
0debug
static void scsi_unmap_complete(void *opaque, int ret) { UnmapCBData *data = opaque; SCSIDiskReq *r = data->r; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint64_t sector_num; uint32_t nb_sectors; r->req.aiocb = NULL; if (r->req.io_canceled) { scsi_req_cancel_complete(&r->req); goto done; } if (ret < 0) { if (scsi_handle_rw_error(r, -ret)) { goto done; } } if (data->count > 0) { sector_num = ldq_be_p(&data->inbuf[0]); nb_sectors = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL; if (!check_lba_range(s, sector_num, nb_sectors)) { scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); goto done; } r->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs, sector_num * (s->qdev.blocksize / 512), nb_sectors * (s->qdev.blocksize / 512), scsi_unmap_complete, data); data->count--; data->inbuf += 16; return; } scsi_req_complete(&r->req, GOOD); done: scsi_req_unref(&r->req); g_free(data); }
1threat
static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) { AVFrame *decoded_frame, *f; AVCodecContext *avctx = ist->dec_ctx; int i, ret, err = 0; if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) return AVERROR(ENOMEM); if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) return AVERROR(ENOMEM); decoded_frame = ist->decoded_frame; ret = decode(avctx, decoded_frame, got_output, pkt); if (!*got_output || ret < 0) return ret; ist->samples_decoded += decoded_frame->nb_samples; ist->frames_decoded++; if (decoded_frame->pts != AV_NOPTS_VALUE) ist->next_dts = decoded_frame->pts; else if (pkt && pkt->pts != AV_NOPTS_VALUE) { decoded_frame->pts = pkt->pts; } if (decoded_frame->pts != AV_NOPTS_VALUE) decoded_frame->pts = av_rescale_q(decoded_frame->pts, ist->st->time_base, (AVRational){1, avctx->sample_rate}); ist->nb_samples = decoded_frame->nb_samples; for (i = 0; i < ist->nb_filters; i++) { if (i < ist->nb_filters - 1) { f = ist->filter_frame; err = av_frame_ref(f, decoded_frame); if (err < 0) break; } else f = decoded_frame; err = ifilter_send_frame(ist->filters[i], f); if (err < 0) break; } av_frame_unref(ist->filter_frame); av_frame_unref(decoded_frame); return err < 0 ? err : ret; }
1threat
count only if field is filled : I have a question about an sql query i want to make. Supose i have an column with the follow values in table: school with column: grades. SUI grades | Score 2 9 2 2 9 5 4 1 5 4 1 5 4 6 1 1 6 1 Now i wan't an output where it groups the SUI that counts grades only if Score is filled. So my output will be: SUI Count 2 1 4 2 6 1
0debug
void do_405_check_sat (void) { if (!likely(((T1 ^ T2) >> 31) || !((T0 ^ T2) >> 31))) { if (T2 >> 31) { T0 = INT32_MIN; } else { T0 = INT32_MAX; } } }
1threat
Automatically answer to input prompt in windows batch : <p>In a windows batch, I want to start a program that prompts the user for an input:</p> <pre><code>&gt;someProgram.exe &gt; "Please enter "s" to start the program: &gt; </code></pre> <p>How can I automatically pass the "y" input to the prompt, such that I can start the program by just clicking the batch? </p>
0debug
Can some explain the java code given here? : <p>code - job.setOutputKeyClass(Text.class); </p> <p>what does it mean by passing param as Text.class? whey .class is required.</p>
0debug
Read from a file search for a word and copy the entire line to another file : <p>I have a file 1.txt with lines of words</p> <ol> <li>A cat went bankrupt</li> <li>List item</li> <li>Something is there</li> </ol> <p>I search for a word List and copy the entire line to new file 2.txt List item.</p> <p>How do i do that? thank you.</p>
0debug
When i update an android app i am getting error code:-26.How to solve it? : <p>When i update an android app i am getting error code:-26.How to solve it?<a href="https://i.stack.imgur.com/yl5Za.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yl5Za.png" alt="enter image description here"></a></p>
0debug
uint32_t avpriv_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id) { int i; for (i = 0; avpriv_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) { if ((codec_id == AV_CODEC_ID_NONE || avpriv_fmt_conversion_table[i].codec_id == codec_id) && (pix_fmt == AV_PIX_FMT_NONE || avpriv_fmt_conversion_table[i].ff_fmt == pix_fmt)) { return avpriv_fmt_conversion_table[i].v4l2_fmt; } } return 0; }
1threat
How to get top and bottom number of a number in iOS Swift? : <p>I have a number like 73<br> how get max and min like 70 and 80.<br> or 173 I want to get 170 and 180 etc.</p>
0debug
vbDatabaseCompare in StrComp function : <p>When we use StrComp in VBA we have 3 compare options. <br><br> vbTextCompare<br> vbBinaryCompare<br> vbDatabaseCompare<br></p> <p>How vbDatabaseCompare differs from other 2?</p>
0debug
Is the default lodash memoize function a danger for memory leaks? : <p>I want to use <code>memoize</code> but I have a concern that the cache will grow indefinitely until sad times occur.</p> <p>I couldn't find anything via google/stackoverflow searches.</p> <p>P.S. I am using lodash v4.</p>
0debug
Construct regular expression that matches numeric expressions like 5+65 : <p>I'm looking for a way to construct regular expressions to match two integers with mathematical operation, like 6+36 85*52 </p>
0debug
display mysql-table - wrong order displayed : <p>php snippet:</p> <pre><code>mysqli_select_db($con,"dbtest"); $sql="SELECT * FROM w3school"; $result = mysqli_query($con,$sql); echo "&lt;ul id='myUL'&gt;"; while($w3school = mysqli_fetch_array($result)) { echo "&lt;li id='".$w3school['id']."'&gt;" . $w3school['LastName'] . "&lt;/li&gt;"; } echo "&lt;ul&gt;"; </code></pre> <p>SCREEN OUTPUT looks like this:</p> <pre><code>id = 5; id = 4; id = 3; id = 1; id = 2; </code></pre> <p>I don't see why its not 1,2,3,4 ...</p> <p>Any suggestions? (any spec info just let me know)</p>
0debug
who is the owner of the contracts deployed using truffle? : <p>I am using testrpc and truffle to test my contract.</p> <p>When I type <code>truffle migrate</code> , this will deploy my contract to the testrpc network.</p> <p>My question is , which account (from testrpc accounts) has been used to deploy the contract.</p> <p>In other word, whose the contract owner?</p> <p>Thank you in advance</p>
0debug
Missing "Web Inspector" Settings in simulator : <p>After doing a "Reset All Content And Settings.." on the simulator the setting to enable using the web inspector in safari has disappeared, and I have no idea how to get it back:</p> <p><a href="https://i.stack.imgur.com/njxSz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/njxSz.png" alt="Advanced Settings Menu"></a></p> <p>Does anyone have an idea how to get this back, and "remote" debug a webpage in the simulator again?</p>
0debug
Rotate all html element (whole page) 90 degree with CSS? : <p>I want to display every thing in the page rotated consistently and dependently 90 degree, I tried to do it but the result was inaccurate and each element rotated independently.</p>
0debug
How to write a `ByteData` instance to a File in Dart? : <p>I am using Flutter to load an "asset" into a <code>File</code> so that a native application can access it.</p> <p>This is how I load the asset:</p> <pre><code>final dbBytes = await rootBundle.load('assets/file'); </code></pre> <p>This returns an instance of <code>ByteData</code>.</p> <p>How can I write this to a <code>dart.io.File</code> instance?</p>
0debug
index was outside the bounds of the array meaning WPF C# : <p>I try this code to display names from database in loop but this shows an error index was outside the bounds of the array meaning on this line name[j++] = Convert.ToString(reader["CategoryName"]);</p> <p>code</p> <pre><code> con.Open(); int count =0; int j =0; //cmd = new SqlCommand("select * from Category"); string[] name = new string[count]; cmd = new SqlCommand("select CategoryName from Category",con); reader = cmd.ExecuteReader(); while (reader.Read()) { name[j++] = Convert.ToString(reader["CategoryName"]); } int loc = 37; CheckBox[] obj = new CheckBox[count]; for (int i = 0; i &lt; count; i++) { obj[i] = new CheckBox(); obj[i].Location = new System.Drawing.Point(loc, 50); obj[i].Size = new System.Drawing.Size(80, 17); obj[i].Text = name[i]; this.Controls.Add(obj[i]); loc += 80; } con.Close(); </code></pre> <p>any help?</p>
0debug
How to use this inside a collection class : <p>How can I use THIS keyword to refer to the collection in a class which inherits from an ArrayList like this. I got an error at design time and IDE doesn't allow me to compile my code. </p> <pre><code>public class Company{ private EmployeeCollection employees; public Company(){ this.employees = new EmployeeCollection(); this.employees.add(new Employee()); this.employees.add(new Employee()); this.employees.add(new Employee()); this.employees.add(new Employee()); this.employees.add(new Employee()); } public void MyMethod(){ Employee fourthEmployee = employees.getFourth(); } } public class EmployeeCollection extends ArrayList&lt;Employee&gt;{ public Employee getFourth(){ return this[3]; //&lt;-- Error } public Employe getEmployee(int id){ for(int i = 0; i&lt; this.size(); i++){ //&lt;-- Error if(id == this[i].id){ //&lt;-- Error return this[i]; //&lt;-- Error } } } } </code></pre> <p>Normally in C# I can do something like this</p> <pre><code> public object test(int id) { for (int i = 0; i &lt; this.Count; i++) { if (this[i].ID == id) { return this[i]; } } return null; } </code></pre>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
void r4k_helper_tlbp(CPUMIPSState *env) { r4k_tlb_t *tlb; target_ulong mask; target_ulong tag; target_ulong VPN; uint8_t ASID; int i; ASID = env->CP0_EntryHi & 0xFF; for (i = 0; i < env->tlb->nb_tlb; i++) { tlb = &env->tlb->mmu.r4k.tlb[i]; mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1); tag = env->CP0_EntryHi & ~mask; VPN = tlb->VPN & ~mask; #if defined(TARGET_MIPS64) tag &= env->SEGMask; #endif if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) { env->CP0_Index = i; break; } } if (i == env->tlb->nb_tlb) { for (i = env->tlb->nb_tlb; i < env->tlb->tlb_in_use; i++) { tlb = &env->tlb->mmu.r4k.tlb[i]; mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1); tag = env->CP0_EntryHi & ~mask; VPN = tlb->VPN & ~mask; #if defined(TARGET_MIPS64) tag &= env->SEGMask; #endif if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) { r4k_mips_tlb_flush_extra (env, i); break; } } env->CP0_Index |= 0x80000000; } }
1threat
How get time on timecurrent on node of firebase using angular? : I want to show only the time on the view, when use $firebaseArray i get the list of items and i want to get only the time. firebase tree { "eventmodel" : { "-KX6kDkufxLg-fLocsN7" : { "info" : "ok", "limit" : 2, "timeCurrentStart" : "29/11/2016 17:38", }, "-KXBB-R7xAPl65xhlTpg" : { "info" : "ok", "limit" : 2, "timeCurrentStart" : "29/11/2016 17:38", } } }
0debug
def extract_rear(test_tuple): res = list(sub[len(sub) - 1] for sub in test_tuple) return (res)
0debug
window.back() is not working in javascript : <p>window.back() is not working in javascript.</p> <p>Trying to write a test case where need to access the url from history.</p> <p>but not getting any result</p>
0debug
How can I make a trailing slash optional on a Django Rest Framework SimpleRouter : <p>The <a href="http://www.django-rest-framework.org/api-guide/routers/#simplerouter" rel="noreferrer">docs</a> say you can set <code>trailing_slash=False</code> but how can you allow both endpoints to work, with or without a trailing slash?</p>
0debug
I insert struct to vector,but address of all the elements of vector are same : <p>I declared a struct treenode</p> <pre><code>struct treenode { int val; treenode *l; treenode *r; }; </code></pre> <p>and a vector</p> <pre><code>vector&lt;int&gt; v = { 1,2,3,4,5,6,7,8,9 }; </code></pre> <p>now I want to create a vector tv to store the value of v</p> <pre><code>vector&lt;treenode* &gt; tv; for (int i = 0; i &lt; v.size(); i++) { treenode mid; mid.val = v[i]; mid.l = NULL; mid.r = NULL; tv.push_back(&amp;mid); } </code></pre> <p>but when I print the value of tv, I found all the element of tv are same(same address), there are 9. I`m confused, I have create a new treenode every iteration, why all the element use same address <a href="http://i.stack.imgur.com/DmrC7.png" rel="nofollow">enter image description here</a></p>
0debug
Where shall I put an existing DB in a android project : <p>Im making an app, and want to port it to android which im new to. Where should i place the db? and is the code below enough to successfully connect and query the db or do i need more to just test if it works?</p> <pre><code> String path = "WHERE_SHOULD_I_PLACE_MY_DB_?"; SQLiteDatabase sqLiteDatabase = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY); Cursor cursor = sqLiteDatabase.rawQuery("select * from table", null); String something = cursor.getString(1); System.out.println(something); </code></pre>
0debug
SQL queries - For Customer and Sale representative using pgAdmin4 : Q: List the numbers and names of all customers who are represented by Ann Hull but who do not currently have orders on file. This is what i have so far... but it isn't the right output... Can someone HELP!
0debug
Extracting highest value in some unequal periods/time-series in R : I have two data frame: period_example (consists of ‘ Beg’, and ‘End’) and price_example (consists of ‘Date’ and ‘High’). I want the highest value of High for each Beg-End period. How to do it? Thank you. Here is the data: > period_example <- data.frame(Beg = as.Date(c("2000-01-01","2000-01-04","2000-01-09")),End = as.Date(c("2000-01-03","2000-01-08","2000-01-12"))) > price_example <- data.frame(Date = seq(as.Date("2000-01-01"), as.Date("2000-01-12"),by="days"), High = c(100,105,104,103,102,106,107,108,109,110,115,114)) The result should be like this: > result <- data.frame(Beg = as.Date(c("2000-01-01","2000-01-04","2000-01-09")),End = as.Date(c("2000-01-03","2000-01-08","2000-01-12")), High = c(105,108,115))
0debug
Bad initialisation of std::vector ? : <p>This is how I declare my vector : </p> <pre><code> std::vector &lt;Link *&gt; _components; </code></pre> <p>Link is this structure : </p> <pre><code> struct Link { size_t targetPin; nts::IComponent *component; }; </code></pre> <p>First to initialise it I do </p> <pre><code> this-&gt;_components.reserve(2); </code></pre> <p>Then, when this instruction happen, it segfault </p> <pre><code> this-&gt;_components[0]-&gt;component = this; </code></pre> <p>Got an idea ? </p>
0debug
@mention via incoming webhook in MS Teams : <p>I'm trying to mention a user from an incoming webhook.</p> <p>I tried a few iterations via Postman of </p> <pre><code>{ "text": "test @user" } </code></pre> <p>or </p> <pre><code>{ "text": "test @user@email.com" } </code></pre> <p>but none of these seem to work. Is this simple but very important thing just not possible?</p> <p>Thanks.</p>
0debug
How do I fix error of the main python file? : Please help. It gave me an error when running the main.py file.. Error: No module named 'kivymd.app'
0debug
How can this be done in perl : <Root> <Top Name=" "> <Tag name="ALU"> <in name="PC"/> <iodirection name="AB"/> </Tag> <Tag name=" "> <in name="CCB"/> <ou name="PC"/> <bi name="AB"/> </Tag> <Tag name=" "> <in name="DB"/> <ou name="DI"/> <bi name="CCB"/> </Tag> <Tag name=" "> <in name="DI"/> <ou name="DB"/> <bi name="CCB"/> </Tag> </Top> </Root> I'm not a perl expert, but some simple things are hard for me to figure out and one such task is this. The above XML as you can see the attributes/elements, they're repeated couple of times but for different `<in> <io> <ou>` tags . Now I'm looking to return only the repeated attributes/elements and Just print them once. Example : DI DB CCB AB My code snippet goes something like this use strict; use XML::Simple; use Data::Dumper; $xml_1 = XMLin('./tmp.xml'); my $root_top = $xml_1->{Top}; my $mod_top= $root_top1->{Tag}; my @mod = keys %$mod_top; foreach my $mods (values %$mod_top) { my $temp=shift(@mod); print XST_FILE "$temp u_$temp(\n"; my $in_mo = $modules->{in}; my @in_1 = keys %$in_mo; foreach my $name_1 (values %$in_mo) { my $inn = shift(@in_1); if($inn=~/\bname\b/){ print" \.$name_1\($name_1\)\,\n"; } else { print " \.$in\($in\)\,\n"; } } P.S: I'd appreciate if this can be modified only in XML::Simple. Though [XML::Simple is discouraged][1], he's not righteous, but he is the one I'm currently using just to finish this task Any help is appreciated! [1]: http://stackoverflow.com/questions/33267765/why-is-xmlsimple-discouraged
0debug
static struct omap_pwl_s *omap_pwl_init(MemoryRegion *system_memory, target_phys_addr_t base, omap_clk clk) { struct omap_pwl_s *s = g_malloc0(sizeof(*s)); omap_pwl_reset(s); memory_region_init_io(&s->iomem, &omap_pwl_ops, s, "omap-pwl", 0x800); memory_region_add_subregion(system_memory, base, &s->iomem); omap_clk_adduser(clk, qemu_allocate_irqs(omap_pwl_clk_update, s, 1)[0]); return s; }
1threat
Android gradle 3.0.0 buildConfigField warning after updating : <p>I recently installed the latest Canary build of Android Studio which is currently using the Android Gradle plugin <code>3.0.0-alpha4</code> (previous was <code>2.3.3</code>).</p> <p>I now get a warning for all of my buildConfigFields:</p> <pre><code>buildTypes { def BOOLEAN = "boolean" def STRING = "String" def INT = "int" def TRUE = "true" def FALSE = "false" def SOME_PER_BUILD_TYPE_FIELD = "SOME_PER_BUILD_TYPE_FIELD" debug { buildConfigField BOOLEAN, SOME_PER_BUILD_TYPE_FIELD, FALSE } release { buildConfigField BOOLEAN, SOME_PER_BUILD_TYPE_FIELD, TRUE } </code></pre> <p>The warnings read like:</p> <pre><code>Warning:BuildType(debug): buildConfigField 'SOME_PER_BUILD_TYPE_FIELD' value is being replaced: false -&gt; false Warning:BuildType(debug): buildConfigField 'SOME_STRING_FIELD' value is being replaced: "999" -&gt; "999" </code></pre> <p>And there is like 100 of them for my various fields and build types. How do I fix them and what is the warning actually telling me?</p>
0debug
name 'A' is not defined : <p>I am trying to learn opencv using python, when I try to define a variable, I got the same error. </p> <p>this is my code </p> <pre><code>import numpy as np import cv2 img = cv2. imread('love.jpg', 1) cv2. imshow('image', img) A == cv2.waitkey(0) &amp; 0xFF if A == 27: cv2.destroyAllWindows() elif A == ord('s'): cv2.imwrite('love.png', img) cv2.destroyAllWindows() </code></pre> <p>and this is the result </p> <pre><code>NameError: name 'A' is not defined </code></pre> <p>I thing the problem in installing python in my device ( windows 10, 64 bit) </p>
0debug
Making REST calls from a react component : <p>I am trying to make REST call from a react component and render the returned JSON data into the DOM</p> <p>Here is my component</p> <pre><code>import React from 'react'; export default class ItemLister extends React.Component { constructor() { super(); this.state = { items: [] }; } componentDidMount() { fetch(`http://api/call`) .then(result=&gt; { this.setState({items:result.json()}); }); } render() { return( WHAT SHOULD THIS RETURN? ); } </code></pre> <p>In order to bind the returned json in a DOM?</p>
0debug
Random letter generator game : <p>Warning: I am brand new to programing! I am trying to create a random letter generator game for a class project. I feel like I have a decent start to it but I am having difficulty with a few points. </p> <p>The program is supposed to ask the player how many games they would like to play(1-5). The maximum number of guesses they get per game is 5 and then it is supposed to print out what the correct answer was if it was not guessed. As it is, I have it so that it will run the correct number of guesses but not games and it dosent cout&lt;&lt; the correct answer when all guesses are done. Any help is appreciated, thanks.</p> <pre><code>#include&lt;iostream&gt;; #include&lt;cstdlib&gt;; #include&lt;ctime&gt;; using namespace std; int main() { char alphabet [27]; int number_of_games; char guess; int x = 1; srand(time(0)); int n = rand() % 26 + 1; cout&lt;&lt;"Weclome to the Letter Guessing game!\n"; cout&lt;&lt;"You have 5 chances to guess each letter.\n \n"; cout&lt;&lt;"How many games do you want to play?\n"; cin &gt;&gt; number_of_games; cout&lt;&lt;"**************************************************\n\n"; while (x &lt;= number_of_games) //Need to get it for how many rounds, not how many guesses { if (number_of_games &lt; 1) { cout&lt;&lt; "Lets play game " &lt;&lt; number_of_games &lt;&lt; '\n'; } //cout &lt;&lt; (char)(n+97); //cheat to make sure working cout&lt;&lt;"Enter your guess: "; cin &gt;&gt; guess; int guessValue = int(guess); if (guessValue &gt; (n+97)) { cout&lt;&lt;"The letter you are trying to guess is before " &lt;&lt;guess &lt;&lt;"\n"; } else if (guessValue &lt; (n+97)) { cout&lt;&lt;"The letter you are trying to guess is after " &lt;&lt;guess &lt;&lt; "\n"; } else if( (char)(n+97)) { cout &lt;&lt; "The answer you were looking for was " &lt;&lt; (char)(n+97) &lt;&lt; "\n"; } else { cout&lt;&lt;"Your guess is correct! \n"; break; } //if answer is not right after x tries, cout the correct answer x++; } system("pause"); return 0; } </code></pre>
0debug
How can I avoid <br> tags inside of other tags using php : <p>For some reasons, I do not want to have <code>&lt;br&gt;</code> tags inside of my others tags. For example, if I have </p> <pre><code>&lt;b&gt;This is a line&lt;br&gt;another line?&lt;/b&gt; &lt;i&gt;testing 1&lt;br&gt;testing 2&lt;/i&gt; </code></pre> <p>I want it to be converted to</p> <pre><code>&lt;b&gt;This is a line&lt;/b&gt;&lt;br&gt;&lt;b&gt;another line?&lt;/b&gt; &lt;i&gt;testing 1&lt;/i&gt;&lt;br&gt;&lt;i&gt;testing 2&lt;/i&gt; </code></pre> <p>I know that they display the same in browsers. But I need to have the codes in this format for some other reasons. I am using php. Thanks for your help. </p>
0debug
items in flex container overlap : When I try this code, the two dots overlap each other as well as the text. Why? How can I get them to be side by side? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> .container { display: flex; flex-direction: row; } .dot { width: 8px; height: 8px; border-radius: 4px; background: black; } <!-- language: lang-html --> <div class="container"> <span class="dot" /> <span class="dot" /> some text </div> <!-- end snippet -->
0debug
static void patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { assert(type == R_ARM_PC24); assert(addend == 0); reloc_pc24(code_ptr, (tcg_insn_unit *)value); }
1threat
def No_of_cubes(N,K): No = 0 No = (N - K + 1) No = pow(No, 3) return No
0debug
void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq) { stellaris_enet_state *s; int iomemtype; qemu_check_nic_model(nd, "stellaris"); s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state)); iomemtype = cpu_register_io_memory(0, stellaris_enet_readfn, stellaris_enet_writefn, s); cpu_register_physical_memory(base, 0x00001000, iomemtype); s->irq = irq; memcpy(s->macaddr, nd->macaddr, 6); if (nd->vlan) { s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, stellaris_enet_receive, stellaris_enet_can_receive, s); qemu_format_nic_info_str(s->vc, s->macaddr); } stellaris_enet_reset(s); register_savevm("stellaris_enet", -1, 1, stellaris_enet_save, stellaris_enet_load, s); }
1threat
static void pmac_ide_transfer(DBDMA_io *io) { MACIOIDEState *m = io->opaque; IDEState *s = idebus_active_if(&m->bus); MACIO_DPRINTF("\n"); s->io_buffer_size = 0; if (s->drive_kind == IDE_CD) { if (s->lba == -1) { s->io_buffer_size = MIN(io->len, s->packet_transfer_size); block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size, BLOCK_ACCT_READ); MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n", s->io_buffer_size); cpu_physical_memory_write(io->addr, s->io_buffer, s->io_buffer_size); ide_atapi_cmd_ok(s); m->dma_active = false; MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n"); block_acct_done(bdrv_get_stats(s->bs), &s->acct); io->dma_end(io); return; } block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len, BLOCK_ACCT_READ); pmac_ide_atapi_transfer_cb(io, 0); return; } switch (s->dma_cmd) { case IDE_DMA_READ: block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len, BLOCK_ACCT_READ); break; case IDE_DMA_WRITE: block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len, BLOCK_ACCT_WRITE); break; default: break; } io->requests++; pmac_ide_transfer_cb(io, 0); }
1threat
static void omap_pwl_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_pwl_s *s = (struct omap_pwl_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; if (size != 1) { return omap_badwidth_write8(opaque, addr, value); } switch (offset) { case 0x00: s->level = value; omap_pwl_update(s); break; case 0x04: s->enable = value & 1; omap_pwl_update(s); break; default: OMAP_BAD_REG(addr); return; } }
1threat
How to use tf.keras with bfloat16 : <p>I'm trying to get a tf.keras model to run on a TPU using mixed precision. I was wondering how to build the keras model using bfloat16 mixed precision. Is it something like this?</p> <pre><code>with tf.contrib.tpu.bfloat16_scope(): inputs = tf.keras.layers.Input(shape=(2,), dtype=tf.bfloat16) logits = tf.keras.layers.Dense(2)(inputs) logits = tf.cast(logits, tf.float32) model = tf.keras.models.Model(inputs=inputs, outputs=logits) model.compile(optimizer=tf.keras.optimizers.Adam(.001), loss='mean_absolute_error', metrics=[]) tpu_model = tf.contrib.tpu.keras_to_tpu_model( model, strategy=tf.contrib.tpu.TPUDistributionStrategy( tf.contrib.cluster_resolver.TPUClusterResolver(tpu='my_tpu_name') ) ) </code></pre>
0debug
Recursively list directories in powershell : <p>How do you recursively list directories in Powershell?</p> <p>I tried <code>dir /S</code> but no luck:</p> <pre><code>PS C:\Users\snowcrash&gt; dir /S dir : Cannot find path 'C:\S' because it does not exist. At line:1 char:1 + dir /S + ~~~~~~ + CategoryInfo : ObjectNotFound: (C:\S:String) [Get-ChildItem], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand </code></pre>
0debug
How to pass an std::array with unknown size? in C++ : <p>I'd like to pass an C++ std::array defined as </p> <pre><code>array&lt;int,100&gt; arrayName </code></pre> <p>to another function, but I don't want to specify there the size, so I can easily change the size only at creation of the array.</p> <p>How do I write this? I can't write</p> <pre><code>function(array&lt;&gt; arrayName) </code></pre> <p>as I would do with an char array...</p> <p>Kind regards, iova.</p>
0debug
Is there a way to make an array of arrays? Java : <p>OK so I created a method and I actually need it to return two different values. Two different arrays. Now the only way I think I could do this is by putting the values into an array. That didn't work. This was because I was initializing improperly. Now I have no clue if what I'm trying to do is possible. Or if it is I don't know how to do it and I would like some assistance. Below is what I tried doing:</p> <pre><code>double[] average = {averagevalues, averagepi}; and double[] average = new double[2]; average[0] = averagevalues; average[1] = averagepi; </code></pre>
0debug
CPUPPCState *cpu_ppc_init(void) { CPUPPCState *env; cpu_exec_init(); env = qemu_mallocz(sizeof(CPUPPCState)); if (!env) return NULL; #if !defined(CONFIG_USER_ONLY) && defined (USE_OPEN_FIRMWARE) setup_machine(env, 0); #else env->spr[PVR] = 0x00080100; #endif tlb_flush(env, 1); #if defined (DO_SINGLE_STEP) msr_se = 1; #endif msr_fp = 1; msr_me = 1; #if defined(CONFIG_USER_ONLY) msr_pr = 1; cpu_ppc_register(env, 0x00080000); #else env->nip = 0xFFFFFFFC; #endif env->access_type = ACCESS_INT; cpu_single_env = env; return env; }
1threat
HOW TO DRAW EDGES WITH JUNG LIBRARY? : I have an implementation of a Graph and I want to visualize it using JUNG. My problem is that when I add an edge, I visualize 2 edges, for example 1 to 2 and 2 to 1 with the same weight, but I just want to see 1 edge. My code: public void createGraph(HashMap<Integer, Vertice<Integer, Integer>> vertices, long[][] matriz) { if (vertices != null) { Graph<Vertice<Integer, Integer>, Arista<Integer, Integer>> ig = new SparseMultigraph<Vertice<Integer, Integer>, Arista<Integer, Integer>>(); for (int i = 0; i < vertices.size(); i++) { ig.addVertex(vertices.get(i)); } for (int i = 0; i < matriz.length; i++) { for (int j = 0; j < i; j++) { if(matriz[i][j] > 0){ Arista<Integer, Integer> a= new Arista(vertices.get(i), vertices.get(j), (int)matriz[i][j]); ig.addEdge(a, vertices.get(i), vertices.get(j)); } } } VisualizationImageServer<Vertice<Integer, Integer>, Arista<Integer, Integer>> vs = new VisualizationImageServer<Vertice<Integer, Integer>, Arista<Integer, Integer>>( new KKLayout<Vertice<Integer, Integer>, Arista<Integer, Integer>>(ig), new Dimension(680, 340)); vs.setBackground(Color.GRAY); Transformer<Vertice<Integer, Integer>, Paint> vertexColor = new Transformer<Vertice<Integer, Integer>, Paint>() { @Override public Paint transform(Vertice<Integer, Integer> i) { return Color.GREEN; } }; vs.getRenderContext().setVertexFillPaintTransformer(vertexColor); vs.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Vertice<Integer, Integer>>()); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vs.getRenderContext().setEdgeLabelTransformer(new Transformer<Arista<Integer, Integer>, String>() { public String transform(Arista<Integer, Integer> e) { return (e.toString()); } }); this.add(vs, BorderLayout.CENTER); } } }
0debug
static bool cmd_read_multiple(IDEState *s, uint8_t cmd) { bool lba48 = (cmd == WIN_MULTREAD_EXT); if (!s->bs || !s->mult_sectors) { ide_abort_command(s); return true; } ide_cmd_lba48_transform(s, lba48); s->req_nb_sectors = s->mult_sectors; ide_sector_read(s); return false; }
1threat
trouble merging two pandas dataframes by the transposed headers : <p>I'm having trouble merging two of my pandas dataframes together. I have two dictionaries that I turn into dataframes and transpose, and I want to merge the two dataframes based on the first row headers.</p> <p>I have two dictionaries </p> <pre><code>dict1 = defaultdict(list, {'a': [1.9,2.0,2.0], 'b': [3.9,3.6,2.4]} dict2 = defaultdict(list, {'a': '3.3', 'a': '3.6'}) </code></pre> <pre><code>df2 = pd.DataFrame(dict2).transpose() </code></pre> <p>gives</p> <pre><code> 0 a 3.3 b 3.6 </code></pre> <p>Then the second datframe I made like:</p> <pre><code>df = pd.DataFrame(dict2) #add in some other data df.loc['mean'] = df.mean() df.loc['SEM'] = df.sem() df = df.transpose() df.columns = ['t1', 't2', 't3', 'mean', 'sem'] </code></pre> <p>And that gives something like:</p> <pre><code> t1 t2 t3 mean sem a 1.9 2.0 2.0 2.0 0.02 b 3.9 3.6 2.4 3.3 0.34 </code></pre> <p>I want to add the things in the other dictionar/dataframe so that I get something like:</p> <pre><code> t1 t2 t3 mean sem NEW_COLUMN a 1.9 2.0 2.0 2.0 0.02 3.3 b 3.9 3.6 2.4 3.3 0.34 3.6 </code></pre>
0debug
Angular 6 Downloading file from rest api : <p>I have my REST API where I put my pdf file, now I want my angular app to download it on click via my web browser but I got HttpErrorResponse </p> <p>"Unexpected token % in JSON at position 0"</p> <p>"SyntaxError: Unexpected token % in JSON at position 0↵ at JSON.parse (</p> <p>this is my endpoint</p> <pre><code> @GetMapping("/help/pdf2") public ResponseEntity&lt;InputStreamResource&gt; getPdf2(){ Resource resource = new ClassPathResource("/pdf-sample.pdf"); long r = 0; InputStream is=null; try { is = resource.getInputStream(); r = resource.contentLength(); } catch (IOException e) { e.printStackTrace(); } return ResponseEntity.ok().contentLength(r) .contentType(MediaType.parseMediaType("application/pdf")) .body(new InputStreamResource(is)); } </code></pre> <p>this is my service </p> <pre><code> getPdf() { this.authKey = localStorage.getItem('jwt_token'); const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/pdf', 'Authorization' : this.authKey, responseType : 'blob', Accept : 'application/pdf', observe : 'response' }) }; return this.http .get("http://localhost:9989/api/download/help/pdf2", httpOptions); </code></pre> <p>}</p> <p>and invocation </p> <pre><code>this.downloadService.getPdf() .subscribe((resultBlob: Blob) =&gt; { var downloadURL = URL.createObjectURL(resultBlob); window.open(downloadURL);}); </code></pre>
0debug
Is Java Random return negative numbers? : I'd like to know that if I try to get a random integer using the following method, should it return negative value? int value = new Random().nextInt(bound);
0debug
def find_longest_conseq_subseq(arr, n): ans = 0 count = 0 arr.sort() v = [] v.append(arr[0]) for i in range(1, n): if (arr[i] != arr[i - 1]): v.append(arr[i]) for i in range(len(v)): if (i > 0 and v[i] == v[i - 1] + 1): count += 1 else: count = 1 ans = max(ans, count) return ans
0debug
int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; trace_blk_co_preadv(blk, blk_bs(blk), offset, bytes, flags); ret = blk_check_byte_request(blk, offset, bytes); if (ret < 0) { return ret; } if (blk->public.throttle_state) { throttle_group_co_io_limits_intercept(blk, bytes, false); } return bdrv_co_preadv(blk_bs(blk), offset, bytes, qiov, flags); }
1threat
How to validate javascript and html code? : <p>In our application end users are provided with a textbox where they can paste their html or javascript code to create advertisement much like Google advertisement , so I need to validate these html and js source code against malicious code and also proper syntax . So are there any API's available in java to do the same ?</p> <p>Thanks in advance Ali.</p>
0debug
Errors occuring on running : I am new to C programming in Linux. I wrote a program, in compiling, no errors are occurred. But on running it is giving too many errors. My program is, #include <stdio.h> typedef struct a{ char *name; int id; char *department; int num; } ab; int main() { ab array[2]={{"Saud",137,"Electronics",500},{"Ebad",111,"Telecom",570}}; printf("First student data:\n%s\t%d\t%s\t%d",array[0].name,array[0].id, array[0].department,array[0].num); //ab swap(&array[]); } Errors are, ./newproject: In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here ./newproject: In function `data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here ./newproject: In function `data_start': (.data+0x8): multiple definition of `__dso_handle' /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o:(.data+0x0): first defined here ./newproject:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here ./newproject: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here ./newproject: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__' ./newproject:(.data+0x10): first defined here /usr/bin/ld: error in ./newproject(.eh_frame); no .eh_frame_hdr table will be created. collect2: error: ld returned 1 exit status
0debug
How to find every version of android support libraries source code : <p>I meets some problems so I want to find the source code of the Android support libraries . For example , I want to read the ActionBarActivity.java source code in version 19.0.1 and 20.0.0 in support.appcompat-v7 , and find out the difference between the two versions.</p> <p>I found the <a href="https://github.com/android/platform_frameworks_base" rel="noreferrer">https://github.com/android/platform_frameworks_base</a> , but the release have named as android-x.x.x_rxx but not like 19.0.1 .</p>
0debug
Read incoming sms at every time in Oreo : <p>I want to read all sms messages from specific number at any time not relating when app is runned or not runned. How can I read all messages when app is not runned, in newer versions of android?</p>
0debug
AttributeError: 'dict' object has no attribute 'cpe_mac' : I'm trying to print out all the cpe_mac fields of my API via python. I have # Last updated : BH | 8/31/2016 import requests import json ssc_ip = raw_input("What is your SSC Host (Ex. http://172.19.242.32:1234/ ) ? : ") if not ssc_ip: ssc_ip = 'http://172.19.242.32:1234/' cpe_num = raw_input("How many CPE(s) you want to delete ? : ") print '\n' url = ssc_ip+'vse/vcpes' json_data = requests.get(url).json() # print json_data for x in json_data: print json_data.cpe_mac ___ I kept getting >AttributeError: 'dict' object has no attribute 'cpe_mac'
0debug
React Native 0.47.1: Hot reload is not reflecting code changes on MacOS : <p>I'm trying to get hot reload working with my React Native project. The packager shows the message <code>Bundling index.ios.js ... [hmr enabled]</code> and when I make a change, i see the <code>Hot reloading...</code> message flash on the device so I'm confident that the change is being detected. However, the actual screen is not reflecting the code changes. Live reload works fine.</p> <p>I've reinstalled the node modules and reset/uninstalled/reinstalled watchman. Nothing seems to have any effect.</p> <p>What else should I be trying? How do I figure out why the screen isn't being updated? </p>
0debug
unexpacted output from C-program : thanks for your help earlier.. here i am with a new problem facing the same output. scanf() not working. i am using MACROs in it and this time format is correct LOL.. please have a look and tell me what am i doing wrong here. i am trying to take two characters as input and test whether they are "uppercase or not" or "lowercase or not". my program scans for ch1 but doesn't scan for ch2; i tried flushing the input using "fflush(stdin);" but still the same. when i printed the value of ch2 to see what it is taking in account it shows "10" that's where i tried to flush the input but still the same output. so please have a look and please tell me my mistake. i'll be very thankful. #include <stdio.h> #define UPPERCASE(x) {\ if(x>=65 && x<=90)\ printf("Uppercase letter\n");\ else printf("not Uppercase\n");} #define LOWERCASE(x) {\ if(x>=97 && x<=122)\ printf("LOWERCASE LETTER\n");\ else printf("not lowercase\n");} #define BIGGER(x,y) { \ if(x>y)\ printf("%d is biger\n",x);\ else printf("%d is bigger\n",y);} int main() { char ch1,ch2; int x,y; printf("enter a UPPERCASE LETTER\n"); scanf("%c",&ch1); UPPERCASE(ch1); printf("enter a LOWERCASE LETTER \n"); fflush(stdin); scanf("%c",&ch2); LOWERCASE(ch2); printf("enter two numbers\n"); scanf("%d%d",&x,&y); BIGGER(x,y); return 0; } Please click here to see my output [1]: https://i.stack.imgur.com/zrsWT.png
0debug
Using classes vs constructor functions in TypeScript : I am starting to write my first little app in TypeScript. Before, I did a lot of reading on the JavaScript classes and how *bad* and *fake* they are in JavaScript. That's why I decided to use good old constructor functions in my TS application, but after I wrote my first interface, a problem arose - how do I implement it in my constructor function? Let's say I have an interface: ``` interface WebScraper { url: string, getRawContent(): string, } ``` when I used classes I would simply code ``` class Scraper implements WebScraper { //... } ``` but how do I do it for a constructor function? I will be using it with the `new` keyword so it will return an object with specific properties. Would that be correct then, if I specify the interface as the return type? ``` function Scraper(): WebScraper { //... } ``` I actually tried that and got an error ``` error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ``` How do I solve this then?
0debug
CREATE PROCEDURE for INSERTING THE RECORDS, IF EXCEPTION, PROCEDURE NEEDS START FROM EXCEPTION LINE : I need to write the procedure for inserting the records in to multiple tables, for example I am HAVING here 3 table, CREATE TABLE SOURCE ( SORT_CODE NUMBER, FLAG CHAR(1) ); INSERT INTO SOURCE VALUES(605096,5); INSERT INTO SOURCE VALUES(605097,5); INSERT INTO SOURCE VALUES(605098,5); INSERT INTO SOURCE VALUES(605099,5); INSERT INTO SOURCE VALUES(605100,5); INSERT INTO SOURCE VALUES(605101,6); INSERT INTO SOURCE VALUES(605102,6); INSERT INTO SOURCE VALUES(605103,6); INSERT INTO SOURCE VALUES(605104,6); INSERT INTO SOURCE VALUES(605105,6); SQL> SELECT * FROM SOURCE; SORT_CODE F ---------- - 605096 5 605097 5 605098 5 605099 5 605100 5 605101 6 605102 6 605103 6 605104 6 605105 6 10 rows selected. CREATE TABLE TARGET ( SORT_CODE NUMBER, TARGET_SORT_CODE NUMBER ); Table created. --INSERT 5 VALUES INSERT INTO TARGET VALUES(605101,189873); INSERT INTO TARGET VALUES(605102,189874); INSERT INTO TARGET VALUES(605103,189875); INSERT INTO TARGET VALUES(605104,189876); INSERT INTO TARGET VALUES(605105,''); SELECT * FROM TARGET; SORT_CODE TARGET_SORT_CODE ---------- ---------------- 605101 189873 605102 189874 605103 189875 605104 189876 605105 CREATE TABLE NEWID ( SORT_CODE NUMBER, ID_SCODE NUMBER ); Table created. --INSERT 2 VALUES INSERT INTO TARGET VALUES(605103,189875); INSERT INTO TARGET VALUES(605104,189876); SELECT * FROM NEWID; SORT_CODE ID_SCODE ---------- ---------------- 605103 189875 605104 189876 --Creating intermediate tables with existing table's structure. CREATE TABLE SOURCE_TEMP AS (SELECT * FROM SOURCE WHERE 1=2); CREATE TABLE TARGET_TEMP AS (SELECT * FROM TARGET WHERE 1=2); CREATE TABLE NEWID_TEMP AS (SELECT * FROM NEWID WHERE 1=2); --MY Procedure for inserting the records CREATE OR REPLACE PROCEDURE insert_sql is BEGIN DELETE FROM SOURCE_TEMP; INSERT INTO SOURCE_TEMP SELECT * FROM SOURCE; --insert query 1 DELETE FROM TARGET_TEMP; INSERT INTO TARGET_TEMP SELECT * FROM TARGET; --insert query 2 --due to some network issue or table error this procedure GOT EXEPCTION here and above insert query 2(TARGET_TEMP) and below --insert query 3(NEWID_TEMP) is not inserted the values or not executed procedure is came out from this line. DELETE FROM NEWID_TEMP; INSERT INTO NEWID_TEMP SELECT * FROM NEWID; --insert query 3 EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('ERROR'); END; Point 1: The above procedure is executed only one insert query 1 SOURCE_TEMP is got the values. Point 1: TARGET_TEMP and NEWID_TEMP is not inserted the values or not execute. MyQues: can I able to re-execute this procedure with starting point of '--insert query 2' line? becoz I am inserting the 100 tables records in new tables, if 50 tables are inserted the values during this time if i am getting any error in the proc execution, remaining 50 tables needs to insert the values, for I dont wish to delete the previous 50 tables inserted the values it will be the time consuming activity. any save point or boolean concepts is there for this type of issue in ORACLE (which is available in java and unix) if yes how to use this function? Thanks Sanjay
0debug
Clicked legend should show remaining all legend should hide automattically in highchart.js : I am having 10 legends in highchart,if i click first legend only clicked legend should show remaining all legend should hide automatically...
0debug
DropDownList - ASP.NET Problems : <p>Having trouble with a drop down list in my ASP site</p> <p>Ok, what am i trying to do? </p> <p>i want to select a item from my drop list and then fire some code, an example when i click Hek, it loads the correct information i'm after, when i click Dodixie after the page refreshes but not loading the new values, also when i click on a name the drop down text keeps defaulting to Jita again. </p> <p>here is some code:</p> <p>Front End: </p> <pre><code>&lt;asp:DropDownList ID="stationSelect" runat="server" CssClass="OverviewText" AutoPostBack="true" OnSelectedIndexChanged="stationSelect_SelectedIndexChanged" &gt; &lt;asp:ListItem value="0"&gt;Jita&lt;/asp:ListItem&gt; &lt;asp:ListItem value="1"&gt;Hek&lt;/asp:ListItem&gt; &lt;asp:ListItem value="2"&gt;Dodxie&lt;/asp:ListItem&gt; &lt;asp:ListItem value="3"&gt; Armar&lt;/asp:ListItem&gt; &lt;asp:ListItem value="4"&gt;Rens&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; </code></pre> <p>Back End: </p> <pre><code>protected void stationSelect_SelectedIndexChanged(object sender, EventArgs e) { stationSelect.ClearSelection(); stationSelect.SelectedIndex = stationSelect.Items.IndexOf(stationSelect.Items.FindByValue("0")); { string OrePriceA = "http://api.eve-central.com/api/marketstat?typeid=34&amp;minQ=1&amp;typeid=35&amp;minQ=1&amp;typeid=36&amp;minQ=1&amp;typeid=37&amp;minQ=1&amp;typeid=38&amp;minQ=1&amp;typeid=39&amp;minQ=1&amp;typeid=40&amp;minQ=1&amp;typeid=11399&amp;minQ=1&amp;usesystem=30002187"; XmlDocument xdoc = new XmlDocument(); xdoc.Load(OrePriceA); TriPrAmarB.Text = GetStat(xdoc, 34, TranType.Buy, StatType.Max); TriPrAmarS.Text = GetStat(xdoc, 34, TranType.Sell, StatType.Max); PyrPrAmarB.Text = GetStat(xdoc, 35, TranType.Buy, StatType.Max); PyrPrAmarS.Text = GetStat(xdoc, 35, TranType.Sell, StatType.Max); MexPrAmarB.Text = GetStat(xdoc, 36, TranType.Buy, StatType.Max); MexPrAmarS.Text = GetStat(xdoc, 36, TranType.Sell, StatType.Max); IsoPrAmarB.Text = GetStat(xdoc, 37, TranType.Buy, StatType.Max); IsoPrAmarS.Text = GetStat(xdoc, 37, TranType.Sell, StatType.Max); NocPrAmarB.Text = GetStat(xdoc, 38, TranType.Buy, StatType.Max); NocPrAmarS.Text = GetStat(xdoc, 38, TranType.Sell, StatType.Max); ZydPrAmarB.Text = GetStat(xdoc, 39, TranType.Buy, StatType.Max); ZydPrAmarS.Text = GetStat(xdoc, 39, TranType.Sell, StatType.Max); MegPrAmarB.Text = GetStat(xdoc, 40, TranType.Buy, StatType.Max); MegPrAmarS.Text = GetStat(xdoc, 40, TranType.Sell, StatType.Max); MorPrAmarB.Text = GetStat(xdoc, 11399, TranType.Buy, StatType.Max); MorPrAmarS.Text = GetStat(xdoc, 11399, TranType.Sell, StatType.Max); }; stationSelect.ClearSelection(); stationSelect.SelectedIndex = stationSelect.Items.IndexOf(stationSelect.Items.FindByValue("1")); { string OrePriceH = "http://api.eve-central.com/api/marketstat?typeid=34&amp;minQ=1&amp;typeid=35&amp;minQ=1&amp;typeid=36&amp;minQ=1&amp;typeid=37&amp;minQ=1&amp;typeid=38&amp;minQ=1&amp;typeid=39&amp;minQ=1&amp;typeid=40&amp;minQ=1&amp;typeid=11399&amp;minQ=1&amp;usesystem=30003394"; XmlDocument xdocH = new XmlDocument(); xdocH.Load(OrePriceH); TriPrAmarB.Text = GetStat(xdocH, 34, TranTypeH.Buy, StatTypeH.Max); TriPrAmarS.Text = GetStat(xdocH, 34, TranTypeH.Sell, StatTypeH.Max); PyrPrAmarB.Text = GetStat(xdocH, 35, TranTypeH.Buy, StatTypeH.Max); PyrPrAmarS.Text = GetStat(xdocH, 35, TranTypeH.Sell, StatTypeH.Max); MexPrAmarB.Text = GetStat(xdocH, 36, TranTypeH.Buy, StatTypeH.Max); MexPrAmarS.Text = GetStat(xdocH, 36, TranTypeH.Sell, StatTypeH.Max); IsoPrAmarB.Text = GetStat(xdocH, 37, TranTypeH.Buy, StatTypeH.Max); IsoPrAmarS.Text = GetStat(xdocH, 37, TranTypeH.Sell, StatTypeH.Max); NocPrAmarB.Text = GetStat(xdocH, 38, TranTypeH.Buy, StatTypeH.Max); NocPrAmarS.Text = GetStat(xdocH, 38, TranTypeH.Sell, StatTypeH.Max); ZydPrAmarB.Text = GetStat(xdocH, 39, TranTypeH.Buy, StatTypeH.Max); ZydPrAmarS.Text = GetStat(xdocH, 39, TranTypeH.Sell, StatTypeH.Max); MegPrAmarB.Text = GetStat(xdocH, 40, TranTypeH.Buy, StatTypeH.Max); MegPrAmarS.Text = GetStat(xdocH, 40, TranTypeH.Sell, StatTypeH.Max); MorPrAmarB.Text = GetStat(xdocH, 11399, TranTypeH.Buy, StatTypeH.Max); MorPrAmarS.Text = GetStat(xdocH, 11399, TranTypeH.Sell, StatTypeH.Max); }; stationSelect.ClearSelection(); // ENTER TEXT HERE { string OrePriceD = "http://api.eve-central.com/api/marketstat?typeid=34&amp;minQ=1&amp;typeid=35&amp;minQ=1&amp;typeid=36&amp;minQ=1&amp;typeid=37&amp;minQ=1&amp;typeid=38&amp;minQ=1&amp;typeid=39&amp;minQ=1&amp;typeid=40&amp;minQ=1&amp;typeid=11399&amp;minQ=1&amp;usesystem=30002659"; XmlDocument xdocD = new XmlDocument(); xdocD.Load(OrePriceD); TriPrAmarB.Text = GetStat(xdocD, 34, TranTypeD.Buy, StatTypeD.Max); TriPrAmarS.Text = GetStat(xdocD, 34, TranTypeD.Sell, StatTypeD.Max); PyrPrAmarB.Text = GetStat(xdocD, 35, TranTypeD.Buy, StatTypeD.Max); PyrPrAmarS.Text = GetStat(xdocD, 35, TranTypeD.Sell, StatTypeD.Max); MexPrAmarB.Text = GetStat(xdocD, 36, TranTypeD.Buy, StatTypeD.Max); MexPrAmarS.Text = GetStat(xdocD, 36, TranTypeD.Sell, StatTypeD.Max); IsoPrAmarB.Text = GetStat(xdocD, 37, TranTypeD.Buy, StatTypeD.Max); IsoPrAmarS.Text = GetStat(xdocD, 37, TranTypeD.Sell, StatTypeD.Max); NocPrAmarB.Text = GetStat(xdocD, 38, TranTypeD.Buy, StatTypeD.Max); NocPrAmarS.Text = GetStat(xdocD, 38, TranTypeD.Sell, StatTypeD.Max); ZydPrAmarB.Text = GetStat(xdocD, 39, TranTypeD.Buy, StatTypeD.Max); ZydPrAmarS.Text = GetStat(xdocD, 39, TranTypeD.Sell, StatTypeD.Max); MegPrAmarB.Text = GetStat(xdocD, 40, TranTypeD.Buy, StatTypeD.Max); MegPrAmarS.Text = GetStat(xdocD, 40, TranTypeD.Sell, StatTypeD.Max); MorPrAmarB.Text = GetStat(xdocD, 11399, TranTypeD.Buy, StatTypeD.Max); MorPrAmarS.Text = GetStat(xdocD, 11399, TranTypeD.Sell, StatTypeD.Max); }; stationSelect.ClearSelection(); } // Dodixie enum TranTypeD { Buy, Sell, All }; enum StatTypeD { Volume, Avg, Max, Min, StdDev, Median, Percentile }; private static string GetStat(XmlDocument xdocD, int id, TranTypeD tranType, StatTypeD statType) { string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}", id, tranType.ToString().ToLower(), statType.ToString().ToLower()); return GetFirstElementText(xdocD, xpath); } // Hek enum TranTypeH { Buy, Sell, All }; enum StatTypeH { Volume, Avg, Max, Min, StdDev, Median, Percentile }; private static string GetStat(XmlDocument xdocH, int id, TranTypeH tranType, StatTypeH statType) { string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}", id, tranType.ToString().ToLower(), statType.ToString().ToLower()); return GetFirstElementText(xdocH, xpath); } // Jita enum TranType { Buy, Sell, All }; enum StatType { Volume, Avg, Max, Min, StdDev, Median, Percentile }; private static string GetStat(XmlDocument xdoc, int id, TranType tranType, StatType statType) { string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}", id, tranType.ToString().ToLower(), statType.ToString().ToLower()); return GetFirstElementText(xdoc, xpath); } </code></pre> <p>A picture to give you a better idea: </p> <p><a href="https://i.stack.imgur.com/eVqWO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eVqWO.jpg" alt="enter image description here"></a></p>
0debug
Lock symbol in Android xml : I've been trying to put a [Lock Symbol][1] in the textview of an activity. However what I have used from this website did not seem to work. <TextView android:id="@+id/lockTextView" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="\uD83D\uDD12"/> [1]: http://www.fileformat.info/info/unicode/char/1f512/index.htm
0debug
getting this error Binary operator '==' cannot be applied to operands of type 'Any' and 'Int' : for i in class_User.day{ if i == 1{ print(i) strdays += "1" } else if (i == "2"){ print(i) strdays += "- 2" } } I m using this for array which comes from api but i am getting this error can you please tell me solution
0debug
docker-compose: difference between network and link : <p>I'm learning docker. I see those two terms make me confuse. For example here is a docker-compose that defined two services <code>redis</code> and <code>web-app</code>.</p> <pre><code>services: redis: container_name: redis image: redis:latest ports: - "6379:6379" networks: - lognet app: container_name: web-app build: context: . dockerfile: Dockerfile ports: - "3000:3000" volumes: - ".:/webapp" links: - redis networks: - lognet networks: lognet: driver: bridge </code></pre> <p>This <code>docker-compose</code> file defines a bridge network named lognet and all services will connect to this network. As I understand, this action makes those services can see others. So why app service still need to link to redis service in above case.</p> <p>Thanks</p>
0debug
What is better to certain values in a certain manner in C : <p>I want to know which is the suitable way to store some generated values values? the values will be computed like so:</p> <pre><code>0 0 N/4 2N/4 3N/4 0 N/4² .. .. .. .. (4²-1)N/4² . . . 0 N/4^p .. .. .. .. (4^p-1)N/4^p </code></pre> <p>Is a table a suitable way? (I don't think so). A hashtable (how it will be accessed) or a structure??</p>
0debug
How do I get Windows 10 Terminal to launch WSL? : <p>I'm using the new Windows Terminal, and trying to get it to launch my WSL terminal. This is the setting that I'm trying to use:</p> <pre><code> { "acrylicOpacity" : 0.75, "closeOnExit" : true, "colorScheme" : "Campbell", "commandline" : "%LOCALAPPDATA%/wsltty/bin/mintty.exe --WSL= --configdir='%APPDATA%/wsltty' -~ ", "cursorColor" : "#FFFFFF", "cursorShape" : "bar", "fontFace" : "Consolas", "fontSize" : 10, "guid" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "historySize" : 9001, "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png", "name" : "wsl", "padding" : "0, 0, 0, 0", "snapOnInput" : true, "startingDirectory" : "%USERPROFILE%", "useAcrylic" : true } </code></pre> <p>But all it's doing is opening some sort of CMD.</p> <p>What's the correct command to run the WSL terminal</p> <p><strong>Edit:</strong></p> <p>I did notice that the GUID was the same thing as the regular CMD, so I changed that. Then it did launch an <em>external</em> shell.</p>
0debug
how ı write a matrix ? it print random numbers : I'm trying write a code that matrix 3*3 but it doesn't work corretly.ıt print random numbers.what ı did wrong? int matrix[3][3]; int i,j; for(i=0;i<3;i++){ for(j=0;j<3;j++){ scanf("%d",&matrix[i][j]); } } for(i=0;i<3;i++){ for(j=0;j<3;j++){ printf("%d ",&matrix[i][j]); } } return 0; }
0debug
void cpu_reset(CPUSPARCState *env) { if (qemu_loglevel_mask(CPU_LOG_RESET)) { qemu_log("CPU Reset (CPU %d)\n", env->cpu_index); log_cpu_state(env, 0); } tlb_flush(env, 1); env->cwp = 0; #ifndef TARGET_SPARC64 env->wim = 1; #endif env->regwptr = env->regbase + (env->cwp * 16); #if defined(CONFIG_USER_ONLY) #ifdef TARGET_SPARC64 env->cleanwin = env->nwindows - 2; env->cansave = env->nwindows - 2; env->pstate = PS_RMO | PS_PEF | PS_IE; env->asi = 0x82; #endif #else #if !defined(TARGET_SPARC64) env->psret = 0; #endif env->psrs = 1; env->psrps = 1; CC_OP = CC_OP_FLAGS; #ifdef TARGET_SPARC64 env->pstate = PS_PRIV; env->hpstate = HS_PRIV; env->tsptr = &env->ts[env->tl & MAXTL_MASK]; env->lsu = 0; #else env->mmuregs[0] &= ~(MMU_E | MMU_NF); env->mmuregs[0] |= env->def->mmu_bm; #endif env->pc = 0; env->npc = env->pc + 4; #endif }
1threat
static void musb_async_cancel_device(MUSBState *s, USBDevice *dev) { int ep, dir; for (ep = 0; ep < 16; ep++) { for (dir = 0; dir < 2; dir++) { if (s->ep[ep].packey[dir].p.owner == NULL || s->ep[ep].packey[dir].p.owner->dev != dev) { continue; } usb_cancel_packet(&s->ep[ep].packey[dir].p); } } }
1threat
DateTime.Parse changing date? : <p>This is my code snippet: </p> <pre><code> public bool getEffDate() { testfunction(DateTime.Today.ToString("u")); return true; } private bool testfunction(string modDate) { modDate = DateTime.Parse(modDate).ToString("yyyy-MM-dd"); return true; } </code></pre> <p>DateTime.Today.ToString("u") - Returns current date Whereas, modDate returns current_date - 1.. </p> <p>Can someone help me with the UTC date function? Why is the Parse function bringing the previous day? </p>
0debug
How do I create or add a user to rabbitmq? : <p>This seems like a question that should be easily be googleable. It is not though. Can anybody help?</p> <p>How do I create a new user for rabbitmq?</p>
0debug
static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "movq "MANGLE(bm01010101)", %%mm4 \n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",4), %%mm0 \n\t" "movq 8(%1, %%"REG_a",4), %%mm1 \n\t" "pand %%mm4, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, %%mm1 \n\t" "psrlw $8, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "packuswb %%mm0, %%mm0 \n\t" "packuswb %%mm1, %%mm1 \n\t" "movd %%mm0, (%3, %%"REG_a") \n\t" "movd %%mm1, (%2, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width) : "%"REG_a ); #else int i; for (i=0; i<width; i++) { dstU[i]= src1[4*i + 0]; dstV[i]= src1[4*i + 2]; } #endif assert(src1 == src2); }
1threat
Hi i am trying to solve this task of a javascript challenge : The task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number. Examples: Input: 21445 Output: 54421 Input: 145263 Output: 654321 Input: 1254859723 Output: 9875543221 My thinking is to break the number into individual strings and push into array then sort them descending way then make it a number again . But is there a better way to handle this?
0debug
Unique Login and SQLiteConstraintException in Android : I have the following code for inserting login information into a SQL Lite database. public boolean addLogin(Login login) { SQLiteDatabase Db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(TABLE1_COL1, login.getUser_Name()); values.put(TABLE1_COL2, login.getPassword()); try { Db.insert(TABLE1_NAME, null, values); } catch (SQLiteConstraintException ex) { System.out.println("here"); return false; } return true; } When I try to test my code with this method executed in my main activity: //Testing Adding Logins Login login1 = new Login("having1", "fun1"); Login login2 = new Login("having1", "fun1"); db.addLogin(login1); db.addLogin(login2); I get the error: E/SQLiteDatabase: Error inserting User_Names=having1 Password=fun1 android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: Login_Table.User_Names (code 1555) But isn't this what the try and catch statement is supposed to prevent? I also do not see the `System.out.println("here")` statement. Any insights as to why this is happening much appreciated.
0debug
Why WebAssembly is so slow? : <p>I'm implementing a Mandelbrot Set visualization using Rust with WebAssmbly, where my goal is to make it using multi-threading.</p> <p>I've implemented the Mandelbrot Set both in Javascript (using Typescript) and in Rust single-threaded so far. I've made some benchmarks and the Rust implementation is about x17 time slower, and I'm completely lost here, I don't know why I'm getting this bad performance.</p> <p>Here is the repo, at <code>master</code> the implementation that uses Rust, and in <code>js-implementation</code> the one with Rust.</p> <p><a href="https://github.com/DanielRamosAcosta/mandlerbot-set-webassembly" rel="nofollow noreferrer">https://github.com/DanielRamosAcosta/mandlerbot-set-webassembly</a></p> <p>Thanks in advance.</p>
0debug
how to fill array content using for loop in JavaScript : <p>I want to create and array and fill it's content using for loop. It's like </p> <h1>include </h1> <pre><code>Int main (){ Int array [6]; Int i; For(i=0;i &lt;6;i++){ Array [i]=i*3; Printf ("%d",array [i]); } Return 0; } </code></pre> <p>In c. How to do it in javascript?</p>
0debug
How to query a relationship on multiple polymorphic-inheritance tables? : <p>Let's say you have the following simplified example schema, which uses SQLAlchemy joined table polymorphic inheritance. <code>Engineer</code> and <code>Analyst</code> models have a <code>Role</code> relationship. The <code>Intern</code> model does not.</p> <pre><code>class Role(db.Model): __tablename__ = 'role' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(16), index=True) class EmployeeBase(db.Model): __tablename__ = 'employee_base' id = db.Column(db.Integer, primary_key=True) some_attr = db.Column(db.String(16)) another_attr = db.Column(db.String(16)) type = db.Column(db.String(50), index=True) __mapper_args__ = { 'polymorphic_identity': 'employee', 'polymorphic_on': type } class Engineer(EmployeeBase): __tablename__ = 'engineer' id = db.Column(db.Integer, db.ForeignKey('employee_base.id'), primary_key=True) role_id = db.Column(db.Integer, db.ForeignKey('role.id'), index=True) role = db.relationship('Role', backref='engineers') __mapper_args__ = { 'polymorphic_identity': 'engineer', } class Analyst(EmployeeBase): __tablename__ = 'analyst' id = db.Column(db.Integer, db.ForeignKey('employee_base.id'), primary_key=True) role_id = db.Column(db.Integer, db.ForeignKey('role.id'), index=True) role = db.relationship('Role', backref='analysts') __mapper_args__ = { 'polymorphic_identity': 'analyst', } class Intern(EmployeeBase): __tablename__ = 'intern' id = db.Column(db.Integer, db.ForeignKey('employee_base.id'), primary_key=True) term_ends = db.Column(db.DateTime, index=True, nullable=False) __mapper_args__ = { 'polymorphic_identity': 'intern', } </code></pre> <p><strong>If I want to find <code>Employees</code> with a <code>Role</code> <code>name</code> having "petroleum" somewhere in the name, how would I do that?</strong></p> <p>I've tried many, many approaches. The closest I've come is this, which only returns <code>Analyst</code> matches:</p> <pre><code>employee_role_join = with_polymorphic(EmployeeBase, [Engineer, Analyst]) results = db.session.query(employee_role_join).join(Role).filter(Role.name.ilike('%petroleum%')) </code></pre> <p>If I try to do something like this, I get an <code>AttributeError</code>, because I'm searching on an attribute of the joined <code>Role</code> table:</p> <pre><code>employee_role_join = with_polymorphic(EmployeeBase, [Engineer, Analyst]) results = db.session.query(employee_role_join).filter(or_( Engineer.role.name.ilike('%petroleum%'), Analyst.role.name.ilike('%petroleum%'))) </code></pre>
0debug
static int virtio_blk_device_init(VirtIODevice *vdev) { DeviceState *qdev = DEVICE(vdev); VirtIOBlock *s = VIRTIO_BLK(vdev); VirtIOBlkConf *blk = &(s->blk); static int virtio_blk_id; if (!blk->conf.bs) { error_report("drive property not set"); return -1; } if (!bdrv_is_inserted(blk->conf.bs)) { error_report("Device needs media, but drive is empty"); return -1; } blkconf_serial(&blk->conf, &blk->serial); if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) { return -1; } virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); vdev->get_config = virtio_blk_update_config; vdev->set_config = virtio_blk_set_config; vdev->get_features = virtio_blk_get_features; vdev->set_status = virtio_blk_set_status; vdev->reset = virtio_blk_reset; s->bs = blk->conf.bs; s->conf = &blk->conf; memcpy(&(s->blk), blk, sizeof(struct VirtIOBlkConf)); s->rq = NULL; s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1; s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output); #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE if (!virtio_blk_data_plane_create(vdev, blk, &s->dataplane)) { virtio_cleanup(vdev); return -1; } #endif s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm(qdev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_dev_ops(s->bs, &virtio_block_ops, s); bdrv_set_buffer_alignment(s->bs, s->conf->logical_block_size); bdrv_iostatus_enable(s->bs); add_boot_device_path(s->conf->bootindex, qdev, "/disk@0,0"); return 0; }
1threat
static BusState *qbus_find_recursive(BusState *bus, const char *name, const BusInfo *info) { DeviceState *dev; BusState *child, *ret; int match = 1; if (name && (strcmp(bus->name, name) != 0)) { match = 0; } if (info && (bus->info != info)) { match = 0; } if (match) { return bus; } LIST_FOREACH(dev, &bus->children, sibling) { LIST_FOREACH(child, &dev->child_bus, sibling) { ret = qbus_find_recursive(child, name, info); if (ret) { return ret; } } } return NULL; }
1threat
How to compare a string with a struct (which include strings too)? : <p>so im working on my project and i have problem.</p> <p>This is my struct:</p> <pre><code>struct adminst { string usernameadmin; int passwordadmin; </code></pre> <p>and its another function:</p> <pre><code>void adminlogin() { string username, password; adminst Username[100]; cout &lt;&lt; "Please enter your username"; cin &gt;&gt; username; ifstream admin("adminha.txt"); for (int i = 1; i &lt; 100; i++) { admin &gt;&gt; Username[i].usernameadmin; if ((Username[i].compare(username)) &lt; 0) } </code></pre> <p>and i also used:</p> <pre><code>strcmp( Username[i],usernameadmin) == 0 </code></pre> <p>but didnt get any answers. I would be happy if you fix my code.</p>
0debug
C# Coding structure wrong, input (45 degrees) not outputting correct answer? : <p>I have some c# code (as below **) but I cannot seem to output the correct answer? The input is 45 (degrees) and the output should read 255.102 (meters), my answer is wrong as the output reads 413.2653. </p> <p>I must confess that I think my code (structure) is actually wrong and not the arithmetic?</p> <p>The whole code is as followed:</p> <p>**</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace sums { class Program { static void Main(string[] args) { //prompt the user for angle in degrees Console.Write("Enter initial angle in degrees: "); float theta = float.Parse(Console.ReadLine()); //convert the angle from degrees to radians float DtoR = theta * ((float)Math.PI / 180); //Math.Cos DtoR = theta * (float)Math.Cos(theta); //Math.Sin DtoR = theta * (float)Math.Sin(theta); //t = Math.Sin / 9.8 DtoR = theta / (float)9.8; //h = Math.Sin * Math.Sin / (2 * 9.8) DtoR = theta * theta / (2 * (float)9.8); //dx = Math.Cos* 2 * Math.Sin / 9.8 DtoR = theta * 2 * theta / (float)9.8; //result Console.Write("Horizontal distance {0} Meters. \r\n ", DtoR, theta); } } } </code></pre>
0debug
static int64_t archipelago_volume_info(BDRVArchipelagoState *s) { uint64_t size; int ret, targetlen; struct xseg_request *req; struct xseg_reply_info *xinfo; AIORequestData *reqdata = g_malloc(sizeof(AIORequestData)); const char *volname = s->volname; targetlen = strlen(volname); req = xseg_get_request(s->xseg, s->srcport, s->mportno, X_ALLOC); if (!req) { archipelagolog("Cannot get XSEG request\n"); goto err_exit2; } ret = xseg_prep_request(s->xseg, req, targetlen, sizeof(struct xseg_reply_info)); if (ret < 0) { archipelagolog("Cannot prepare XSEG request\n"); goto err_exit; } char *target = xseg_get_target(s->xseg, req); if (!target) { archipelagolog("Cannot get XSEG target\n"); goto err_exit; } memcpy(target, volname, targetlen); req->size = req->datalen; req->offset = 0; req->op = X_INFO; reqdata->op = ARCHIP_OP_VOLINFO; reqdata->volname = volname; xseg_set_req_data(s->xseg, req, reqdata); xport p = xseg_submit(s->xseg, req, s->srcport, X_ALLOC); if (p == NoPort) { archipelagolog("Cannot submit XSEG request\n"); goto err_exit; } xseg_signal(s->xseg, p); qemu_mutex_lock(&s->archip_mutex); while (!s->is_signaled) { qemu_cond_wait(&s->archip_cond, &s->archip_mutex); } s->is_signaled = false; qemu_mutex_unlock(&s->archip_mutex); xinfo = (struct xseg_reply_info *) xseg_get_data(s->xseg, req); size = xinfo->size; xseg_put_request(s->xseg, req, s->srcport); g_free(reqdata); s->size = size; return size; err_exit: xseg_put_request(s->xseg, req, s->srcport); err_exit2: g_free(reqdata); return -EIO; }
1threat
static void test_visitor_out_native_list_number(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); }
1threat
static void mmio_ide_cmd_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { MMIOState *s = opaque; ide_cmd_write(&s->bus, 0, val); }
1threat
How to get specific key values from an multi dimensional array in PHP : I currently have the following array: <pre> Array ( [2] => Array ( [id] => 2 [type] => 2 [name] => R-1 Agency [parent] => 1 [children] => Array ( [3] => Array ( [id] => 3 [type] => 3 [name] => R-1-W-1 [parent] => 2 [children] => Array ( [11] => Array ( [id] => 11 [type] => 4 [name] => mdf,lk [parent] => 3 [children] => Array ( ) ) ) ) ) ) [38] => Array ( [id] => 38 [type] => 2 [name] => sndflk [parent] => 1 [children] => Array ( [40] => Array ( [id] => 40 [type] => 3 [name] => new one [parent] => 38 [children] => Array ( ) ) ) ) ) </pre>
0debug
Copy one struct to another with some uncommon fileds? : I have two structs. type UserStruct struct{ UserID string `bson:"user_id" json:"user_id"` Address string `bson:"address" json:"address"` Email string `bson:"email" json:"email"` CreatedAt time.Time `bson:"created_at" json:"created_at"` PhoneNumber string `bson:"phone_number" json:"phone_number"` PanCard string `bson:"pancard" json:"pancard"` Details map[string]string `json:"details"` } type SecretsStruct struct { UserID string `r:"user_id" json:"user_id"` Secrets []string `r:"secrets" json:secrets` Address string `r:"address" json:"address"` Email string `r:"email"json:"email"` CreatedAt time.Time `r:"created_at"json:"created_at"` PhoneNumber string `r:"phone_number" json:"phone_number"` PanCard string `r:"pancard" json:"pancard"` } I already have all the values in UserStruct, Now I want to copy fields common in both structs, from UserStruct to SecretsStruct without using reflect. Things to note: 1) I dont want to use reflections.
0debug
static inline void gen_op_eval_fbue(TCGv dst, TCGv src, unsigned int fcc_offset) { gen_mov_reg_FCC0(dst, src, fcc_offset); gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); tcg_gen_xor_tl(dst, dst, cpu_tmp0); tcg_gen_xori_tl(dst, dst, 0x1); }
1threat