Posts

Showing posts from January, 2014

debugging - how to close gdb connection without stopping running program -

is there way exit gdb connnection without stopping / exiting running program ? need running program continues after gdb connection closed. is there way exit gdb connnection without stopping / exiting running program ? (gdb) detach detach process or file attached. if process, no longer traced, , continues execution. if debugging file, file closed , gdb no longer accesses it. list of detach subcommands: detach checkpoint -- detach checkpoint (experimental) detach inferiors -- detach inferior id (or list of ids) type "help detach" followed detach subcommand name full documentation. type "apropos word" search commands related "word". command name abbreviations allowed if unambiguous.

android - Is it possible to show RecyclerView preview in layout editor with horizontal orientation? -

Image
recyclerview shown vertical orientation, , can not set property, because orientation belongs linearlayoutmanager object. way simulate horizontal layout? anyway linearlayoutmanager created in code set horizontal. llm.setorientation(linearlayoutmanager.horizontal); try add these parameters recyclerview inside layout xml: android:orientation="horizontal" android:scrollbars="horizontal" app:layoutmanager="linearlayoutmanager"

How to update(change ) UserIdentity in IBM Mobilefirst -

i trying change useridentity different credentials. gets successful login realm new userid not getting updated in mobilefirst console. console still shows old userid. i using following code. function submitauthentication(username, password){ useridentity = { userid: username, displayname: "sample", attributes: { foo: "bar" } }; wl.server.setactiveuser("authrealm", null); wl.server.setactiveuser("authrealm", useridentity); return { authstatus: "complete" , result: "success" }; // } } i saw below error @ android client side, challengehandler class/handlechallenge method 07-12 07:14:34.265 13001-13078/system.err: java.lang.nullpointerexception: attempt invoke virtual method 'boolean com.worklight.wlclient.wlrequest.shouldfailonchallengecancel()

otp - In Erlang, what's the difference between gen_server:start() and gen_server:start_link()? -

can explain what's difference between gen_server:start() , gen_server:start_link() ? i've been told it's multi threading stuff. edit: if gen_server called multiple threads, execute them @ once ? or create concurrency between these threads? both functions start new gen_server instances children of calling process, differ in gen_server:start_link/3,4 atomically starts gen_server child , links parent process . linking means if child dies, parent default die. supervisors parent processes use links take specific actions when child processes exit abnormally, typically restarting them. other linking involved in gen_server:start_link case, there no multi-process aspects involved in these calls. regardless of whether use gen_server:start or gen_server:start_link start new gen_server , new process has single message queue, , receives , processes messages 1 @ time. there nothing gen_server:start_link causes new gen_server process behave or perform differe

java - Netbeans debug error for JSF application -

i'm trying tutorial https://netbeans.org/kb/docs/web/jsf20-intro.html#template , have problems step 8 - debugging. can deploy application without errors. while deployment, encounter warnings: warning: [options] source value 1.5 obsolete , removed in future release warning: [options] target value 1.5 obsolete , removed in future release warning: [options] suppress warnings obsolete options, use -xlint:-options. 3 warnings but application gets deployed , runs fine. however, i've got problems when comes debugging. right-click project -> debug, , following error: org.netbeans.api.debugger.jpda.debuggerstartexception: connect: address invalid on local machine, or port not valid on remote machine @ org.netbeans.modules.debugger.jpda.jpdadebuggerimpl.waitrunning(jpdadebuggerimpl.java:404) @ org.netbeans.modules.debugger.jpda.jpdadebuggerimpl.waitrunning(jpdadebuggerimpl.java:386) @ org.netbeans.api.debugger.jpda.jpdadebugger.attach(jpdadebugger.java:

Ionic inserts unexpected class -

when writing ionic tabs [ion-tabs] use class "tabs-positive tabs-icon-top" nut when run run , inspect element chrome see there class :"tabs-top tabs-striped" here code <ion-tabs class="tabs-positive tabs-icon-top"> <!-- home tab --> <ion-tab title="home" icon-off="ion-ios-home-outline" icon-on="ion-ios-home" href="#/tab/dash"> <ion-nav-view name="tab-dash"></ion-nav-view> </ion-tab> <!-- man tab --> <ion-tab title="man" icon-off="ion-man" icon-on="ion-man" href="#/tab/man"> <ion-nav-view name="tab-man"></ion-nav-view> </ion-tab> <!-- woman tab --> <ion-tab title="woman" icon-off="ion-woman" icon-on="ion-woman" href="#/tab/woman">

c++ - Memory access comparison -

which 1 of 2 faster (c++)? for(i=0; i<n; i++) { sum_a = sum_a + a[i]; sum_b = sum_b + b[i]; } or for(i=0; i<n; i++) { sum_a = sum_a + a[i]; } for(i=0; i<n; i++) { sum_b = sum_b + b[i]; } i beginner don't know whether makes sense, in first version, array 'a' accessed, 'b', might lead many memory switches, since arrays 'a' , 'b' @ different memory locations. in second version, whole of array 'a' accessed first, , whole of array 'b', means continuous memory locations accessed instead of alternating between 2 arrays. does make difference between execution time of 2 versions (even negligible one)? i don't think there correct answer question. in general, second version has more twice iterations (cpu execution overhead), worse access memory (memory access overhead). imagine run code on pc has slow clock, insanely cache. memory overhead gets reduced, since clock slow running same loop twice

c++ - Can sqrtsd in inline assembler be faster than sqrt()? -

i creating testing utility requires high usage of sqrt() function. after digging in possible optimisations, have decided try inline assembler in c++. code is: #include <iostream> #include <cstdlib> #include <cmath> #include <ctime> using namespace std; volatile double normalsqrt(double a){ double b = 0; for(int = 0; < iterations; i++){ b = sqrt(a); } return b; } volatile double asmsqrt(double a){ double b = 0; for(int = 0; < iterations; i++){ asm volatile( "movq %1, %%xmm0 \n" "sqrtsd %%xmm0, %%xmm1 \n" "movq %%xmm1, %0 \n" : "=r"(b) : "g"(a) : "xmm0", "xmm1", "memory" ); } return b; } int main(int argc, char *argv[]){ double = atoi(argv[1]); double c; std::clock_t start; double duration; start = std::clock(); c = a

c# - How can I make gridview cells be textboxes instead of labels? -

my gridview supposed display data excel datasheet. able display data in grid labels excel values. i'm trying make editable gridview , hence keep in in edit mode why need cells textboxes. how can that? visual explanation <asp:gridview id="gridview4" runat="server" cellpadding="4" forecolor="#333333" gridlines="none" onrowcommand="gridview4_rowcommand" onselectedindexchanged="gridview4_selectedindexchanged"> <alternatingrowstyle backcolor="white" /> <columns> <asp:templatefield showheader="false"> <itemtemplate> <asp:linkbutton onclick="updaterow_click" id="linkbutton1" runat="server" causesvalidation="false"

redirect_uri_mismatch error while creating a classroom through google classroom API -

i trying use google classroom api's integrate product. have created project in developer console , created oauth credentials. downloaded client secret json file. i trying create class in google classroom through api. code have used access follows: using (var stream = new filestream(system.web.httpcontext.current.server.mappath("client_secret.json"), filemode.open, fileaccess.read)) { string credpath = system.environment.getfolderpath(system.environment.specialfolder.personal); credpath = path.combine(@"c:\googlekeys\.credentials\classroom-dotnet-quickstart.json"); credential = googlewebauthorizationbroker.authorizeasync(googleclientsecrets.load(stream).secrets, scopes, "user", cancellationtoken.none, new filedatastore(credpath, true)).result; } when executing last step giving error error: redirect_uri_mismatch i have cross checked between developer console , json file

java - Brasilia Summer Time transition at 2037-10-18 -

timezone.setdefault(timezone.gettimezone("bet")); locale.setdefault(locale.english); simpledateformat sdf1 = new simpledateformat("yyyy-mm-dd hh:mm:ss.sss"); simpledateformat sdf2 = new simpledateformat("yyyy-mm-dd hh:mm:ss.sss zzzz"); date d0 = sdf1.parse("2037-10-17 23:00:00.000"); date d1 = sdf1.parse("2037-10-17 23:00:00.001"); date d2 = sdf1.parse("2037-10-17 23:59:59.999"); date d3 = sdf1.parse("2037-10-18 00:00:00.000"); date d4 = sdf1.parse("2037-10-18 00:00:00.001"); date d5 = sdf1.parse("2037-10-18 00:59:59.999"); date d6 = sdf1.parse("2037-10-18 01:00:00.000"); date d7 = sdf1.parse("2037-10-18 01:00:00.001"); date d8 = sdf1.parse("2037-10-18 01:59:59.999"); date d9 = sdf1.parse("2037-10-18 02:00:00.000"); system.out.println(sdf2.format(d0) + "(" + d0.gettime() + "), dst: " + timezone.getdefault().indaylighttime(d0) + &qu

split - Resplit long strings in TSQL -

i have table long strings splitted 200char per row. need re-split them max 80char per row, possibile tsql function or have write , external program? this example (text field lenght reduced have more rows per id) +----+----------------------------+ | id | textlong | +----+----------------------------+ | 1 | long text chunked part 1/3 | +----+----------------------------+ | 1 | long text chunked part 2/3 | +----+----------------------------+ | 1 | long text chunked part 3/3 | +----+----------------------------+ | 2 | long text chunked part 1/2 | +----+----------------------------+ | 2 | long text chunked part 2/2 | +----+----------------------------+ to +----+------------------------+ | id | textsmall | +----+------------------------+ | 1 | long text chunked | +----+------------------------+ | 1 | part 1/3long text | +----+------------------------+ | 1 | chunked part 2/3 long | +----+------------------------+ | 1 | text chun

c++ isn't Inserting values into registry -

my test program insert values registry not work. have not found solution on google or website. after running program administrator, instantly closes , register not modified. hkey hkey; const char path[] = "c:\\program files\\windows nt\\accessories\\wordpad.exe"; regopenkeyex(hkey_local_machine, "software\\microsoft\\windows\\currentversion\\run", 0, key_write, &hkey); regsetvalueex(hkey, "testwordpad", 0, reg_sz, (byte*)path, strlen(path)); regclosekey(hkey); return 0; after start debugging in output: 'consoleapplication1.exe' (win32): loaded 'c:\users\jakub\desktop\consoleapplication1\debug\consoleapplication1.exe'. symbols loaded. 'consoleapplication1.exe' (win32): loaded 'c:\windows\syswow64\ntdll.dll'. cannot find or open pdb file. 'consoleapplication1.exe' (win32): loaded 'c:\windows\syswow64\kernel32.dll'. cannot find or open pdb file.

Mysql remove a special charecter which occurs after a specific special character -

the data in cell " 0^0^@1@^0^0^1^0 " , want 0^0^@1@0^0^1^0 . looking , want remove special character "^" occurs after "@". note remaining "^" should remain is. i think want replace() : select replace(col, '@^', '@')

c# - EF6 - code-first - how to properly handle deleting a parent entry from an m:n relationship -

i have situation have 2 entities - itemgroup , item - linked in m:n fashion: create table itemgroup ( itemgroupid int identity(1,1) primary key clustered, itemgroupname varchar(50) ) create table item ( itemid int identity(1,1) primary key clustered, itemname varchar(50) ) create table itemgroup_item ( itemgroupid int not null constraint fk_itemgroupitem_itemgroup foreign key references dbo.itemgroup(itemgroupid), itemid int not null constraint fk_itemgroupitem_item foreign key references dbo.item(itemid), constraint pk_itemgroup_item primary key clustered(itemgroupid, itemid) ) therefore, in sql server database, have "link" table connects 2 entities including respective primary keys. when re-engineer ef 6 model, these 2 classes: [table("item")] public partial class item { public item() { itemgroup = new hashset<itemgroup>(); } public int itemid { get;

javascript - targetting just one image under a div jQuery -

i trying show different image based on random number. if number not 2 want change image box-lose on box user clicked on. unfortunately, not able target image. want change image user clicked on lose image. see jsfiddle here may make question clearer. have tried use closest , find cannot seem target element. js $('.box').click(function(){ var randomnumber = 1; var thisbox = $(this); if(randomnumber === 2){ alert('number 2'); } else { thisbox.closest('img').find('.box-img').css('display', 'none'); thisbox.closest('img').find('.box-lose').css('display', 'block'); } }); html <div class="box"> <img class="box-img" src="http://assets.nydailynews.com/polopoly_fs/1.986006.1336765559!/img/httpimage/image.jpg_gen/derivatives/gallery_1200/hulk-hogan-pastamania.jpg"> <img class="box-win&quo

c++ - why should we use pointer for this code? -

i found following code tutorial of c++. in: cout << "value of v = " << *v << endl; you can see *v used. can tell me why should not use v instead of *v ? #include "stdafx.h" #include <iostream> #include <vector> using namespace std; int main() { // create vector store int vector<int> vec; int i; // access 5 values vector for(i = 0; < 5; i++){ cout << "value of vec [" << << "] = " << vec[i] << endl; } // use iterator access values vector<int>::iterator v = vec.begin(); while( v != vec.end()) { cout << "value of v = " << *v << endl; v++; } cin.get(); cin.get(); return 0; } the type of v vector<int>::iterator v therefore if tried do << v << endl; you'd trying write iterator output stream, whereas want int . therefore, dereference itera

excel - Macro loop to pull data from sheet to sheet stopping when no data resent and not entering 0 -

i trying data rows g,h, , row 15 down (stopping when there no data present)from "order sheet", pasted in sheet called “data” in columns m,q , r row 8 down. i have tried recording macro, data changes day day, recorded macro stays same , don’t have know how place if formula in macro stop when there no data in origin cell. 1 day data row 15 50 in order sheet , next 15 71 (always starts @ 15). when macro 200 rows cover rows no matter how many rows may be, itll places 0 in data sheet when nothing present in order sheet cell. leave blank if there no number in order sheet cell. e.g. “order sheet” column paste “data sheet” (starting row 15 down on order sheet , row 8 down on data sheet) g m / h q / r e.g. g15 m8 / h16 q9 / i17 r10 see basic recorder macro idea. thanks in advance activewindow.smallscroll down:=-15 range("m8").select activecell.formular1c1 = "='order sheet'!r[7]c[-6]" range("m8").select selection.au

Azure App Services DNS Configuration -

hy we have 2 azure app services (webapps). 1 web application (single page), other rest service backend. we own our own domain (say www.blabla.com) , map our app services following way: - xxx.blabla.com should point our web application - xxx.blabla.com/api should point our rest service is possible on azure? how can achieve such scenario? thanks help. kind regards, peter what asking typically achieved in on-premise using feature called reverse proxy via url rewrite module. this module available on azure web apps . ruslan has great article demonstrating feature: http://ruslany.net/2014/05/using-azure-web-site-as-a-reverse-proxy/ you don't require code this.

java - Selenium FirefoxDriver stopped working after switch to ChromeDriver and back -

i wanted try selenium chrome did changes code according page https://sites.google.com/a/chromium.org/chromedriver/getting-started from : webdriver driver = new firefoxdriver(); to : system.setproperty("webdriver.chrome.driver", "/path/to/chromedriver"); webdriver driver = new chromedriver(); it worked fine , after few successful tests moved firefox driver. since moment when run test there problem. firefox window opened, there message firefox stopped working , in log see error. error : org.openqa.selenium.remote.unreachablebrowserexception: not start new session. possible causes invalid address of remote server or browser start-up failure. i can see in firefox url text about:blank&utm_content=firstrun before crashes. when use chromedriver again works fine it. i'm using windows 10, firefox 47.0.1.

Where exactly are the variables stored in a C program? -

i new computer programming. studying variables , came across definition on internet: variables names give computer memory locations used store values in computer program. what these memory locations? these locations refer actual computer memory or dump in program calls variables later when need them? there other terms encountered here on stack overflow heap , stack. not head around these. please help. the way you've asked question suggests expect single answer. not case. in rough sense, variables exist in memory while program being executed. memory variables exist in depends both on several things. modern computer hardware has quite complex physical memory architecture - multiple levels of cache (in both cpu, , various peripheral devices), number of cpu registers, shared memory, different types of ram, storage devices, eeproms, etc. different systems have these types of memory - , more types - in different proportions. operating systems may make mem

android - calling a mapFragment in an activity -

i want use mapfragment in activity created map's xml file , java file , call in main activit y getting error java.lang.stackoverflowerror on line view view = inflater.inflate(r.layout.fragment_map, container, false); 06-29 11:14:26.264 23599-23599/com.sifast.appsocle e/androidruntime: fatal exception: main java.lang.stackoverflowerror @ android.content.res.assetmanager.getresourcevalue(assetmanager.java:201) @ android.content.res.resources.getvalue(resources.java:1022) @ android.content.res.resources.loadxmlresourceparser(resources.java:2131) @ android.content.res.resources.getlayout(resour

dom - Delete XML child node -

hi having trouble in deleting xml node. <instance> <internal> <attribute> <name>length</name> </attribute> <name>internal</name> </internal> <name>instanec</name> </instance> i want delete name node output below. <instance> <internal> <attribute> </attribute> </internal> </instance> i tried following code : nodelist baseelmntlst2 = doc.getelementsbytagname("name"); (int k = 0; k < baseelmntlst2.getlength(); k++) { element node = (element) baseelmntlst2.item(k); element node2 = (element) baseelmntlst2.item(k).getparentnode(); node2.removechild(node); } but not delete name elements dont understand. thankyou dom nodelist s live collections if want delete items in nodelist 1 way start @ end e.g. for (int k = ba

javascript - Component state in ReactJS -

first of all, new in reactjs. display markers in mapcomponent. made work, honest think there should better way it... props parent component, loaded json. pass coordinates each item(from json) markers in state in mapcomponent. used react-google-maps solution google maps. maybe give me advice best approach in case? lot tips! export class mapcomponent extends react.component { constructor(props) { super(props) this.state = { markers: [] } } getmarkers() { if (this.props.data.rows) { var markers = this.props.data.rows.map(function(item, i) { return { position: { lat: item.coordinate[0], lng: item.coordinate[1] }, item: item } }); this.setstate({ markers: markers }); } } shouldcomponentupdate(nextprops, nextstate) { return true; } componentdidupdate() { this.getmarkers(); } render() { return ( <div classname={styl

swift - my slide menu button and Tabbar items not working/populating in reveal viewcontroller . why? -

Image
i have used revealviewcontroller in take view controller , set sw_front tabbar controller , sw_rear tableview controller. when running , working fine . in tabbar controller have added 5 different view controllers , same items in tableview cells dynamically in sw_rear part. in table view each cell have connected dynamic cells related view controller based on indexpath.row . when click on tabbar items not coming . navigation items coming because before every view controller have embed navigation controller. why tabbar items not coming??? for better understanding sending few codes , screens codes i have set tableview each dynamic cell switch(indexpath.row) { case 0 : print("1st row") //self.performseguewithidentifier("segueidentifier", sender: self) let mainstoryboard = uistoryboard(name: "main", bundle: nsbundle.mainbundle()) let vc : uinavigationcontroller = mainstoryboard.instantiateviewcontrollerwith

multithreading - C# Parallel Foreach + Async -

i'm processing list of items (200k - 300k), each item processing time between 2 8 seconds. gain time, can process list in parallel. i'm in async context, use : public async task<list<keyword>> doword(list<string> keyword) { concurrentbag<keyword> keywordresults = new concurrentbag<keyword>(); if (keyword.count > 0) { try { var tasks = keyword.select(async kw => { return await work(kw).configureawait(false); }); keywordresults = new concurrentbag<keyword>(await task.whenall(tasks).configureawait(false)); } catch (aggregateexception ae) { foreach (exception innerex in ae.innerexceptions) { log.errorformat("core threads exception: {0}", innerex); } } } return keywordresults.tolist(); } the keyword list contains 8 elements (comming above) pr

sql server - Concatenate 2 x fields to make a Date -

i have 2 x fields t1.period , t1.year both have data type smallint using sql management studio 2014 how may concatenate them , return result date type? also, t1.period has values 1 12 how may pad out 01 12 ... or changing date type sort out? much appreciated! sample data ... period yr 1 2015 2 2009 12 2009 11 2010 10 2011 result ... date 01/01/2015 01/02/2009 01/12/2009 01/11/2010 01/10/2011 thanks! looks terrible struggling lists - sorry :( converting values old fashioned way assuming t1.period value represents month, consider converting values strings , converting concatenated result date via cast() function : select cast(cast(t1.year varchar) + '-' + cast(t1.period varchar) + '-1' date) this build string looks {year}-{month}-1 , parsed date , should give first date of given month/year. using datefromparts() function sql server 2012 , above support datefromparts() function allow pass in various parts (year, month, day)

php - Calculate price form excel javascript -

Image
on website customer fills in height , width . round number echo round(657, -2, php_round_half_up); example. so have width & height in hundreds. price scheme: *breedte = width, hoogte = height in millimeters. result price. the calculation have been simple if there formula. width * height = x. x * y = price. don't know y. client says y irregular , cannot found. think otherwise. math guys, if can find formula have eternal thanks. now real question. let's turn massive function php or fill in database calculate price. painful. best way it? php function? javascript function? fill database , retrieve price there? if can find pattern in data , able calculate x , y coordinates, can make function. preferably in business logic of application (that php, not javascript). otherwise you'll looking @ lookup table. it's best not hard-code these, , maintainability you're going want put these values either in file or database separate code, can adjust them

ruby on rails - PG::ConnectionBad: FATAL: database "db_name" does not exist on EC2 amazon -

i using capistrano rails application deployment. i'm facing pg::connectionbad: fatal: database "db_name" not exist error. kindly guide me. this error indicates there no database exist name "db_name". you need create database on ec2 server , use name , password of database config/database.yml file in production block. alternatively, can run bundle exec rake db:create rails_env=production on ec2 server, create database specified configuration of database.yml file. once database gets created no longer error.

logging - How to display azure app service's web server log on Azure log Analytics? -

Image
i have api application hosted on azure app services. web server log (iis logs) i've turned on web server logging azure portal. @ screenshot below. for storing web server logging server logs allowed stored on azure blob containers only. per configuration logs stored on blob container expected. want use these logs displayed on azure log analytics. i've following storage configurations on log analytics in azure web portal. on log analytics explorer can view logs other sources except web server (iis logs). i'm missing here?

Inner List in Android -

Image
i have problem lists. i want implement scrollable big list, each element of contains text on left side , non-scrollable inner list on right side. (for example: name of flat , list of inhabitants names) both lists should filled cursors , contain informatio them: want have oppurtunitz cursos fields when click element of inner list. as far understood i's not possible solve 2 listviews. expandablelistview not pass me because not want expand first list, want have inner list visible. do have ideas how can realize it? try using listview big list, , empty linearlayout in each item. fill linearlayout of each item programmatically in big list adapters getview(..) method, int position item number. see also: android nested listview edit: or use expandablelistview, items expand programmatically without animation expandgroup(int position, boolean animate). prevent collapsing setting expandablelistview.ongroupcollapselistener, in expand group again. (seems bit hacky) do

python - list_price and price_and_currency are empty but product page shows price -

i'm trying price info amazon product asin: b00bvrv8h0 using python-amazon-simple-product-api wrapper ( https://github.com/yoavaviram/python-amazon-simple-product-api ) from amazon.api import amazonapi amazon_access_key = 'a...q' amazon_secret_key = 'l...j' amazon = amazonapi(amazon_access_key, amazon_secret_key, aws_associate_tag = 'test') product = amazon.lookup(itemid='b00bvrv8h0') print(product.list_price) print(product.price_and_currency) gives: (none, none) (none, none) for asin both list_price , price_and_currency equal (none, none) , when visit product page ( https://www.amazon.com/smoke-pickles-recipes-stories-southern-ebook/dp/b00bvrv8h0 ) see price. how can using api wrapper? other products works fine.

reactive programming - Handle Async Operations in Node.js -

i have been using async package npm inside node.js service run different operations in sequence. example: when run functiona , functionb , functionc in sequence. use promise in node.js, means using callbacks not efficient when have lot of functions need run in sequence. i have familiarized myself reactive programming using observable s , being used in frontend frameworks such angularjs , react. wondering if node.js has similar , if there better ways handle async operations in sequence.

How do I find the Tenant ID of my SharePoint Online Account -

Image
i newbie in sharepoint. trying access token via oauth , came know tenant id or site realm of sharepoint account. find or how can retrieve ? from ui: navigate site collection app permissions page ( http:// <sharepointwebsite> /_layouts/15/appprincipals.aspx ) identify row registered application , locate @ app identifier column . site realm corresponds part of app identifier followed after last @ delimiter

javascript - I cant add class to nth-child -

html: <div id="brojac-poteza" style="clear:both;padding-top:40px;padding-left:60px;padding-right:40px"> <div class="round-end darker-back card-choice">1</div> <div class="darker-back card-choice">2</div> <div class="darker-back card-choice">3</div> <div class="darker-back card-choice">4</div> <div class="darker-back card-choice">6</div> <div class="darker-back card-choice">5</div> <div class="darker-back card-choice">7</div> <div class="darker-back card-choice">8</div> <div class="darker-back card-choice">9</div> <div class="darker-back card-choice">10</div> </div> script.js (above code set var g

bash - Why does printf (Unix) use round half down? -

why printf behave in such uncommon way? > printf %.0f 2.5 > 2 > printf %.0f 2.51 > 3 is there advantage of behaviour compensates probable misunderstandings (like this one )? it's not strictly round-down: > printf '%.0f\n' 2.5 2 > printf '%.0f\n' 3.5 4 this form of rounding used combat bias if rounding large number of values; half of them rounded down, other half rounded up. rule is, round down if integer portion even, if integer portion odd. this is, however, explanation of particular rounding scheme, not guaranteed used implementations of printf .

swift - How to get back to viewcontroller in alertview -

Image
i tried viewcontroller when user press go home in alertview , show me error ( libc++abi.dylib: terminating uncaught exception of type nsexception ) @ibaction func roundbutton(sender: anyobject) { //add alert alertcontroller = uialertcontroller(title: "return home", message: "are sure???", preferredstyle: .alert) let alertaction1 = uialertaction(title: "cancel", style: .default) { (action) in } let alertaction2 = uialertaction(title: "go home", style: .destructive) { (action) in let nv = self.storyboard!.instantiateviewcontrollerwithidentifier("storyboardidentifier") as! viewcontroller self.presentviewcontroller(nv, animated:true, completion:nil) } alertcontroller?.addaction(alertaction2) alertcontroller?.addaction(alertaction1) self.presentviewcontroller(alertcontroller!, animated: true, completion: nil) //end alert } since didn't provide information, th

codenameone - Codename One - How to Store an Array of JSON data in Persistent Memory and Read it Back -

i have json data receive response after sending json request. store data in persistent storage memory or file , read later , display in on screen dropdown list. appreciate if knows how in codename one. { result_code=0.0, data= [ { id=1, title=afghanistan }, { id=2, title=albania }, { id=3, title=algeria }, { id=4, title=andorra }, { id=5, title=angola }, { id=6, title=antigua , barbuda }, ], message=ok } i did small test (y) string x = "{result_code=0.0,data= [{id=1, title=afghanistan }, { id=2, title=albania }, { id=3, title=algeria }, { id=4, title=andorra }, { id=5, title=angola }, { id=6, title=antigua , barbuda },

c# - RabbitMQ Pub/Sub - Subscriber is not able to receive message -

i using sample code implement publish/subscribe using "fanout" exchange type. in below code subscriber not displaying 'hello word' message published. publisher.cs var factory = new connectionfactory() { hostname = "localhost" }; using (var connection = factory.createconnection()) using (var channel = connection.createmodel()) { channel.exchangedeclare(exchange: "logs", type: "fanout"); var message = getmessage(args); var body = encoding.utf8.getbytes(message); channel.basicpublish(exchange: "logs", routingkey: "", basicproperties: null, body: body); console.writeline(" [x] sent {0}", message); } console.writeline(" press [enter] exit."); console.readline(); } private static st

spray - Request entity expected but not supplied inside postman -

the http post method request not working in postman localhost:9090/user/approve?userid=1467279168878 in headers added 1 field access_token . i have got message when tried post on record existing in db. try removing item or using put.

javascript - Save image on server error -

i have ajax fuction take div , make picture , post on php saving . <script> $("#capture").click(function() { html2canvas([document.getelementbyid('printablearea')], { onrendered: function (canvas) { var imagedata = canvas.todataurl('image/png'); var imgdata = imagedata.replace(/^data:image\/(png|jpg);base64,/, ""); //ajax call save image inside folder $.ajax({ url: 'save_image.php', data: { imgdata:imgdata }, type: 'post', success: function (response) { console.log(response); $('#image_id img').attr('src', response); } }); } }) }); </script> then have save image php save on server <?php $imagedata = base64_decode($_post['imgdata']); $filename = md5(uniqid(rand(), true)); //path want upload image $file = 

android create and read xml from sdcard -

i use 2 button, 1st button create xml file in sdcard , 2nd button read xml. code : string xml_root; listview lv_emp; static final string key_name = "name"; static final string key_age = "age"; list<hashmap<string, string>> emphashmap; list<classemp> emplist = null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_empacc); xml_root = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "\n" + "<employees>" + "\n" + "\t" + "<emp>" + "\n" + "\t" + "\t" + "<name>" + "jame" + "</name>" + "\n" + "\t" + "\t" + "<age>" + "17" + "</age>" + "\n" + "