Posts

Showing posts from August, 2011

objective c - Getting screwy results from NSDateComponentsFormatter -

i learned new-to-ios8 class nsdatecomponentsformatter. lets generate time strings time-spans rather dates. pretty cool. decided tinker it, , wrote test code creates various time-spans , logs output. here's code (english , french output) nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nscalendaridentifiergregorian]; nsdatecomponentsformatter* formatter = [[nsdatecomponentsformatter alloc] init]; formatter.unitsstyle = nsdatecomponentsformatterunitsstylefull; formatter.calendar = gregorian; formatter.allowedunits = nscalendarunityear + nscalendarunitmonth + nscalendarunitday; nsdatecomponents *components = [[nsdatecomponents alloc] init]; (int years = 1; years <= 10; years++) { int days = arc4random_uniform(10); components.year = years; components.month = 3; components.day = days; nsstring* outputstring = [formatter stringfromdatecomponents: components]; nslog(@"for %02d years %02d days, date components ...

three.js - Rotation after a Rotation not acting how I Expect -

Image
i have rubiks-cube-like puzzle trying model in webgl using three.js: each of two-color centers can rotate. when rotate, bring of pieces around them along on rotation. example, if rotate orange-blue center, happens: when complete rotation, lines up: however, when try rotate orange-white center, strange behavior 2 pieces inherited orange-blue center after first rotation: i expect them rotate other pieces, instead rotate differently. i using three.js's object3d.rotateonaxis() function rotations: function rotate ( center, distance ) { var axis = center.axis; center.model.rotateonaxis ( axis, distance ); ( var in center.stickers ) { center.stickers[i].rotateonaxis ( axis, distance ); } ( var in center.children ) { center.children[i].model.rotateonaxis ( axis, distance ); //note: stickers colored faces ( var s in center.children[i].stickers ) { center.children[i].stickers[s].rotateonaxis ( axis, di...

android - I keep getting error on fetch_assoc() in PHP -

i trying create login/register feature on android app. 1 of files contains 2 functions being used register , login. keep getting error, same error when try both. getting error error_log file , have tried google while , can't seem find solution particular issue. error is: call member function fetch_assoc() on non-object in db_functions.php and parts error here: login: public function getuserbyemailandpassword($email, $password) { $stmt = $this->conn->prepare("select * users email = ?"); $stmt->bind_param("s", $email); if ($stmt->execute()) { $user = $stmt->get_result()->fetch_assoc(); <----this line $stmt->close(); return $user; } else { return null; } } register: if ($result) { $stmt = $this->conn->prepare("select * users email = ?"); $stmt->bind_param("s", $email); $stmt->execute(); $user = $stmt->get_result()-...

android - iBeacon Ranging Service Not Returning any Beacons -

i working ibeacon technology, , trying create rangingservice search nearby ibeacons every 5 seconds , run in background of application. code below not working. i'm sure i'm making dumb mistake somewhere, can see in log files checkpoint 3 , 4 being reached every 5 seconds, while checkpoints 1 , 2 never being reached. thus, nearby beacons not being detected. don't have experience services or beacons, appreciate help, @davidgyoung. please forgive me if code below isn't indented :) can me. import android.app.service; import android.content.intent; import android.os.handler; import android.os.ibinder; import android.os.message; import android.os.remoteexception; import android.util.log; import android.widget.edittext; import android.widget.toast; import org.altbeacon.beacon.beacon; import org.altbeacon.beacon.beaconconsumer; import org.altbeacon.beacon.beaconmanager; import org.altbeacon.beacon.rangenotifier; import org.altbeacon.beacon.region; import java.util.col...

ios - Animate a UIView on a sine wave path -

Image
how make uiview move along sine wave path? ideally, i'd able stop animation when uiview goes off screen , release it. see uiview->animatewithduration can animate on 1 property @ time, seems 2 exclusive things happening simultaneously: it's moving right , it's moving up/down. you can simple cakeyframeanimation . override func viewdidload() { super.viewdidload() let myview = uiview(frame: cgrect(x: 10, y: 100, width: 50, height: 50)) myview.backgroundcolor = uicolor.cyan view.addsubview(myview) let animation = cakeyframeanimation() animation.keypath = "position" animation.duration = 60 // 60 seconds animation.isadditive = true // make animation position values later generate relative values. // x = 0 x = 299, generate y values using sine. animation.values = (0..<300).map({ (x: int) -> nsvalue in let xpos = cgfloat(x) let ypos = sin(xpos) let point = cgpoint(x: xpos, y: ypo...

swing - How to move Polygon Object with KeyListener in Java -

i working on 2d game learning project , have hit bump. cannot figure out how move polygon object using keylistener within jpanel (which added jframe). i've tried frog.translate(int x, int y) method, not update location. i've tried changing array coordinates manually. sample of code below: import javax.swing.*; import java.awt.*; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyevent; import java.awt.event.keylistener; public class board extends jpanel implements keylistener { private frog frog; public board() { setbackground(color.green); addkeylistener(this); setfocusable(true); setfocustraversalkeysenabled(false); } @override public void paintcomponent(graphics g) { super.paintcomponent(g); graphics2d g2 = (graphics2d)g; frog = new frog(); // frog graphics g2.setcolor(color.black); g2.drawpolygon(frog); ...

babeljs - react native init: ReferenceError: [BABEL] Unknown option: Unknown option: base.optional -

i'm getting following error upon running react-native init testnative referenceerror: [babel] /users/m/git/testnative/node_modules/react-native/local-cli/bundle/bundle.js: unknown option: base.optional @ logger.error (/users/m/git/testnative/node_modules/babel-core/lib/transformation/file/logger.js:41:11) @ optionmanager.mergeoptions (/users/m/git/testnative/node_modules/babel-core/lib/transformation/file/options/option-manager.js:289:18) @ optionmanager.init (/users/m/git/testnative/node_modules/babel-core/lib/transformation/file/options/option-manager.js:486:10) @ file.initoptions (/users/m/git/testnative/node_modules/babel-core/lib/transformation/file/index.js:211:75) @ new file (/users/m/git/testnative/node_modules/babel-core/lib/transformation/file/index.js:129:22) @ pipeline.transform (/users/m/git/testnative/node_modules/babel-core/lib/transformation/pipeline.js:48:16) @ object.transformfilesync (/users/m/git/testnative/node_modules/babel-co...

core data - CoreData-- how many NSFetchedResultsControllers do I need? -

i have data query in several ways. enough use 1 nsfetchedresultscontroller multiple types of queries, or need 1 per query type? if need data queried in various ways @ same time. suggest use multiple nsfetchedresultscontroller. can react on changes of data each query.

ruby - Take in string, return true if after "a", a "z" appears within three places -

# write method takes string in , returns true if letter # "z" appears within 3 letters **after** "a". may assume # string contains lowercase letters. i came this, seems logical, reason if "z" comes directly after "a", returns false. can explain why? def nearby_az(string) = 0 if string[i] == "a" && string[i+1] == "z" return true elsif string[i] == "a" && string[i+2] == "z" return true elsif string[i] == "a" && string[i+3] == "z" return true else return false end += 1 end @shivram has given reason problem. here couple of ways it. problem tailor-made regular expression r = / # match "a" .{,2} # match n characters 0 <= n <= 2 z # match "z" /x # extended/free-spacing regex definition mode !!...

angular - Angular2 and UI library -

in angular1, have lots of 3rd ui directives library build application with, angular-ui. in angular2, how these basic ui components, progress bar, date picker, etc. shall use jquery-ui, or polymer web components? cheers, ron checkout primeng. http://www.primefaces.org/primeng/ open source ui suite angular2.

knockout.js - custom bindinghandler in knockoutjs -

i have div in html below.. <div data-helper="my helper text1">help</div> also have array in javascript self.helpers = [ { name: ' abc ', helper: ' helper text1 ' }, { name: ' def ', helper: ' helper text2 ' }, { name: ' xyz ', helper: ' helper text3 ' } ]; using knockoutjs, bind helper data-helper text. basically need convert code below necessary html code .. <div databind="helper:helpers.helper">help</div> i tried create custom bindinghandler not.. any sincerely appreciated. thanks update: accepted answer without looking @ code , have reopen question. need lines below.. <div data-helper="my helper text1">help</div> so, div data-bind:text not work i tried below did not succeed.. <!-- ko foreach: helpers --> <div data-bind="attr: {data-helper:helper}">help </div...

c - no reference to pthread_mutex_lock with -lpthread compiled -

i compiling program contains mutex semaphores pthread library when compile using -lpthread flag getting undefined reference error. gcc -lpthread prodcon.c /tmp/ccesolon.o: in function `producer': prodcon.c:(.text+0x2e): undefined reference `pthead_mutex_lock' prodcon.c:(.text+0xd6): undefined reference `pthead_mutex_unlock' collect2: ld returned 1 exit status the syntax mutex lock so: pthread_mutex_t mutex1; is global declaration can used multiple threads. within functions calling mutex so: pthead_mutex_lock(&mutex1); pthead_mutex_unlock(&mutex1); but getting compiler error, tried compiling -pthread flag gcc -pthread prodcon.c /tmp/cc6wiqpr.o: in function `producer': prodcon.c:(.text+0x2e): undefined reference `pthead_mutex_lock' prodcon.c:(.text+0xd6): undefined reference `pthead_mutex_unlock' collect2: ld returned 1 exit status i have searched answers @ loss , appreciate figuring out why has undefined reference when linking in libra...

java app, thread hangs after killing MySQL connection -

i have worker threads running, mysql , mysql-connector-java-5.1.20. when kill sql statement ( using kill "connection id" mysql client), java thread hangs, should throw exception. jstack prints: "quartzbase$child#45e3dd3c_worker-3" prio=10 tid=0x00007f960004c800 nid=0x713d runnable [0x00007f943b3a0000] java.lang.thread.state: runnable @ java.net.plainsocketimpl.socketavailable(native method) @ java.net.plainsocketimpl.available(plainsocketimpl.java:472) - locked <0x00007f9e11fe13a8> (a java.net.sockssocketimpl) @ java.net.socketinputstream.available(socketinputstream.java:217) @ com.mysql.jdbc.util.readaheadinputstream.available(readaheadinputstream.java:232) @ com.mysql.jdbc.mysqlio.clearinputstream(mysqlio.java:981) @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:2426) @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:2651) @ com.mysql.jdbc.connectionimpl.execsql(conne...

c - Handling Functions and Pointers -

i'm not c programmer need simple poc 1 of our applications can extended c. i've got code compiling passing data straight through module , idea pass out reverse of character string passed in prove code has done data. i have code pass each input straight output: infa_ctsetdata(outputgroupports[i], infa_ctgetdatastringm(inputgroupports[i])); the infa_ctgetdatastringm function defined as: char* infa_ctgetdatastringm(infa_ct_inputport_handle datahandle); i have found function reverse string here char *mystrrev(char *s) { char *start = s, *t = strchr(s, '\0'); /* point end of string */ /* * swap values @ beginning (pointed 's') , end * (pointed 't'); 's' , 't' meet in middle. */ ( --t/* skip terminating null character */; s < t; ++s, --t ) { /* run-of-the-mill swap here. */ char temp = *s; *s = *t; *t = temp; } return start; } what i'm failing pass result of cal...

position - Reposition jQuery alert -

wondering how reposition jquery alert in form below. pops @ top of browser, under address bar. nice have closer center of screen if @ possible. inexperienced jquery appreciated. thank in advance! susan {% if template contains 'product' , product.available %} <script> jquery('form[action^="/cart/add"]').submit(function() { var product = {{ product | json }}, cannotaddthisquantity = false, message = 'so sorry! must have gotten last one! not have more %t in stock.', selectedvariantid = jquery(this).find('[name="id"]').val(), quantitytoadd = parseint(jquery(this).find('[name="quantity"]').val(), 10) || 1, quantityincart = 0, title = ''; inventorylimited = false, inventory = 0; (var i=0; i<product.variants.length; i++) { if (product.variants[i].id == selectedvariantid) { var variant = product.variants[i];; title = product.title; if (produ...

postgresql - Revoking privileges from role that inherits from object's owner -

i have done set of instructions: create role master superuser createdb createrole valid until 'infinity'; set role = master; create table test ( name text ) ( oids=false ); alter table test owner master; create role inherited login nosuperuser inherit nocreatedb nocreaterole noreplication; grant master inherited; set role=master; revoke select on test inherited cascade; anybody can tell me why can still select on table test? 1 still works: set role=inherited; select * test; role inherited inherits after owner of object - that's problem. there way revoke select anyway? you can because owner assumed have full permissions table. you have revoke access owning role.

java - Operand stack underrun -

i have program generate bytecode java file. , simple test() method public void test() { boolean = false; if (a || true) { boolean b = false; } } , generate follow piece of bytecode public void test() code: 7: iconst_0 8: istore_1 9: iload_1 10: ifne 13 13: iconst_0 14: istore_2 15: return when execute class, keep getting operand stack underrun in test() , couldn't figure out why because generated bytecode looks (to me) could me debug this? (here's did trace stack public void test() code: 7: iconst_0 (1 on stack) 8: istore_1 (0 on stack) 9: iload_1 (1 on stack) 10: ifne 13 (0 on stack) 13: iconst_0 (1 on stack) 14: istore_2 (0 on stack) 15: return so yeah, stack looks fine me!) edit: here's generated bytecode javac public void test(); code: 0: iconst_0 1: istore_1 2: iload_1 3: ifne 6 6: iconst_0 7: istore_2 8: ...

Random access on a huge file in haskell -

what best way read huge file (around 1 tb) in haskell. file contains matrix of integer data. , may need (efficiently ) calculate correlation between different rows or between columns. i have used pytables thinking of trying same in haskell. know haskell has hdf5 bindings there other options not aware of ? you give mmap try. example, can map whole file bytestring : import data.bytestring b import system.io.mmap main = bs <- mmapfilebytestring "mylargefile" nothing let l = b.length bs print l -- print last 1024 bytes: let bs2 = b.drop (l - 1024) bs print (b.unpack bs2) cutting piece out of fast - no data copied. can use whatever tool parse bytestring s.

Download ZIP from Amazon S3 does not preserve timestamp when extracting in Java -

when download zip file amazon s3 , extract using java, not preserve original timestamp of file inside zip. why? here's uncompress java code: public void unzipfile(string zipfile, string newfile) { try { fileinputstream fis = new fileinputstream(zipfile); bufferedinputstream bis = new bufferedinputstream(fis); zipinputstream zis = new zipinputstream(bis); fileoutputstream fos = new fileoutputstream(newfile); final byte[] buffer = new byte[1024]; int len = 0; while ((len = zis.read(buffer)) != -1) { fos.write(buffer, 0, len); } //close resources fos.close(); zis.close(); } catch (ioexception e) { e.printstacktrace(); } } basically, want timestamp of file inside of zip file, file x has jan-01-2010 preserved. file x's overwridden timestamp of zip file, has sep-20-2013. it's because putting contents of zip file new file. you try like: publi...

sql server - trimming empty spaces in large table sql serever -

how trim large table more 300 columns dynamically. when tried code getting error because variable @sql of nvarchar(max) , have 300 columns column names not coming when run query can of guys me in ? declare @sql nvarchar(max) declare @tablename nvarchar(128) set @tablename = 'mytablename' select @sql = coalesce(@sql + ',[', '[') + column_name + ']=ltrim(rtrim([' + column_name + ']))' information_schema.columns table_name = @tablename set @sql = 'update [' + @tablename + '] set ' + @sql print @sql execute @sql while have defined @sql nvarchar(max), boils down how query sent sql server engine. quote msdn maximum capacity specifications. "network packet size size of tabular data stream (tds) packets used communicate between applications , relational database engine. default packet size 4 kb, , controlled network packet size configuration option." the max...

jquery - CSS3 shapes and animation - Arrow -

Image
as shown in image below, have create image , animate it. planning not use image rather using css3 border-radius . so, below html , css i'm at. the animation want arrow should start appearing bottom , moving along flow keeps on showing, take right flow till end arrow pointer. not sure how can this. have support browser ie8+, chrome, ff. html: <div class="years"> <article> <figure> <div class="vrt-bar"></div> <div class="hrzt-bar"></div> <div class="arrow"></div> </figure> </article> </div> css: .years article figure { height:auto; position:relative; } .years article figure .vrt-bar { width:34px; height:192px; behavior: url(css/pie.htc); border-radius:25px 0 25px 25px; -webkit-border-radius: 25px 0 25px 25px; -moz-border-radius: 25px 0 25px 25px; float:left; ...

ServiceStack MAX and MIN query -

being relatively new servicestack, not sure how this... i have object called nexthint provides hint user. [autoincrement] public int id { get; set; } public string body { get; set; } public string title { get; set; } public int votecount { get; set; } public int timesshown { get; set; } i trying find hint has highest number of votes (max(votecount)) , has been least seen (min(timesshown)). rationale of logic not point here rather sql mechanics. my method looks like... public object get(nexthint request) { hint hint; using (var db = dbconnectionfactory.opendbconnection()) { //don't know here!!! db.single<hint>("min(timesshown) , max(votecount) group id"); //update count of timesshown hint.timesshown++; db.update(hint); } return new nexthintresponse { title = hint.title, body = hint.body }; } could point me in right d...

javascript - JS syntax issue or using three.js THREE.ImageLoader in a cycle -

think more javascript syntax issue three.js still.. have object "o = {}", textures stored this o = { ... textures: { one: { low: { t: new three.texture(), url: 'http://i.imgur.com/tj0ujpt.jpg' }, normal: { t: new three.texture(), url: 'http://i.imgur.com/wbb1nzn.jpg' } }, two: { low: { t: new three.texture(), url: 'http://i.imgur.com/9jaozna.jpg' }, normal: { t: new three.texture(), url: 'http://i.imgur.com/p9wo18t.jpg' } hd: ... etc.. } etc.. } ... } what need function can load texture using three.imageloader. also, when textures loaded want run o.texturesonload(); function. thats have http://jsfiddle.net/nexny/5/ last texture of o.textures working.. think i'm passing variables loader.load( ... ) in wrong way; hope can me, thanks. i found solution wrapping loader.load(...) in self execut...

Getting subform control value in Access -

i have subform placed inside form called "updatestudentlisting" in application. subform called "family_t subform". subform loops through multiple records , shows multiple sets of fields related each record. i need grab value 1 of fields, "dl_pic_location", in active form when control in same looped form clicked. how specify far down? i'm able retrieve value of first printed form in list of repeated sets of data in subform. thanks. edit:: to clarify, subform has "cycle" setting in property sheet set "all records", , need value of control inside same form control clicked contained inside.

Ruby class with array attribute -

i have non-database-backed class in ruby: class user attr_accessor :countries end i want countries array of iso country codes (us, gb, ca, au, etc) , don't want build separate model hold each. there magic way make ruby understand :countries array , treat accordingly, or need write countries , countries= methods? i tried setting countries array user.countries = ['us'], , i'm getting nomethoderror. the type of variable doesn't matter in ruby. attr_accessor creates getter , setter methods set , return instance variables; @countries in case. can set instance variable array, or use setter: class user attr_accessor :countries def initialize @countries = %w[foo bar baz] # or... self.countries = %w[foo bar baz] end end > puts user.new.countries => ["foo", "bar", "baz"] personally prefer using instance variable instead of self.xxx ; it's easy forget self. bit , end setting local va...

selenium webdriver - Troubleshooting Firefox 22 w/ FireBug 1.73 and hopefully FirePath 0.9.7 -

this supposedly proper version configuration. need stay w/ firefox 22 in order compatible selenium webdriver 2.35. see complete firebug ui "inspect element" feature doesn't work. when enable firepath (which after) firepath tab becomes accessible tab nothing appears work. presume in sort of configuration hell far can tell using correct versions of aforementioned. fwiw - running win7 32bit. suggestions? you've got firebug 1.7 because of issue addons.mozilla.org , firebug ( https://bugzilla.mozilla.org/show_bug.cgi?id=823840 ). you should firebug 1.11.4, last version supporting firefox 22: https://addons.mozilla.org/fr/firefox/addon/firebug/versions/?page=1#version-1.11.4 florent

asp.net - Dynamically dropping grid columns - effect on postbacks -

i have read number of threads here on subject of posting data dynamically added datagrid columns. i've read says since columns added after init phase, not available in control collection upon postback , therefore data posted these dynamically added columns not available , cannot restored viewstate unless re-created in page_init. have read long controls re-added identical ids ( i.e ids should match match posted control ids), restored viewstate. what if i'm not dynamically adding grid columns rather dropping grid columns in code behind. id's of columns remmin should match in control collection begin data posted should resotored right not i'm seeing. suppos following list of columns in aspx page. if in code behind drop "test" column check checkbox in first column. upon postback, checkbox selection not maintained. have expected based on i've read. can correct understanding on this? <columns> <asp:templatecolumn headertext=...

python - No module named Alchemy API -

i trying run alchemy api on computer python 2.7. file: alchemyapi.py-2.5 i have kept in same file code: # load alchemyapi module code. import alchemyapi # create alchemyapi object. alchemyobj = alchemyapi.alchemyapi() # load api key disk. alchemyobj.loadapikey("api_key.txt") # extract ranked list of named entities web url. result = alchemyobj.urlgetrankednamedentities("http://www.techcrunch.com/"); print (result) # extract ranked list of named entities text string. result = alchemyobj.textgetrankednamedentities("hello name bob. speaking @ moment. listening me, bob?"); print (result) # load html document analyze. htmlfilehandle = open("data/example.html", 'r') htmlfile = htmlfilehandle.read() htmlfilehandle.close() # extract ranked list of named entities html document. result = alchemyobj.htmlgetrankednamedentities(htmlfile, "http://www.test.com/"); print (result) this standard code , gives error have me...

batch programming ignore date and find new -

how can if variable %paaa% not equal %%u ( %%u showed in code) ignore nearest date, , find next? for /f "tokens=1,2,3 delims=-" %%a in ("%current-date%") ( set comparable_date=%%a!%%b!%%c ) rem echo %comparable_date% set /a nearest_date=99999999 /f "tokens=1,2,3 delims=. " %%a in (%file_path%) ( set /a possible_nearest_date=%%c%%b%%a set /a old_result=!nearest_date!-comparable_date set /a new_result=!possible_nearest_date!-comparable_date if !new_result! lss !old_result! set /a nearest_date=!possible_nearest_date! ) if !nearest_date! equ 99999999 echo wrong file>&2 && endlocal && exit /b 3 set nearest_date=!nearest_date:~-2!.!nearest_date:~4,2!.!nearest_date:~0,4! color 4e echo( echo( rem type %file_path% /f "tokens=1,2* delims=()" %%l in ('type %file_path%^|find "!nearest_date!"') ( /f "tokens=1,2" %%t in ("%%l") ( echo ...

Why scrapy crawler stops? -

i have written crawler using scrapy framework parse products site. crawler stops in between without completing full parsing process. have researched lot on , of answers indicate crawler being blocked website. there mechanism can detect whether spider being stopped website or stop on own? the below info level log entry of spider . 2013-09-23 09:59:07+0000 [scrapy] info: scrapy 0.18.0 started (bot: crawler) 2013-09-23 09:59:08+0000 [spider] info: spider opened 2013-09-23 09:59:08+0000 [spider] info: crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min) 2013-09-23 10:00:08+0000 [spider] info: crawled 10 pages (at 10 pages/min), scraped 7 items (at 7 items/min) 2013-09-23 10:01:08+0000 [spider] info: crawled 22 pages (at 12 pages/min), scraped 19 items (at 12 items/min) 2013-09-23 10:02:08+0000 [spider] info: crawled 31 pages (at 9 pages/min), scraped 28 items (at 9 items/min) 2013-09-23 10:03:08+0000 [spider] info: crawled 40 pages (at 9 pages/min), scrape...

sql server - convert string format yyyy-mm-dd to dd/mm/yyyy -

ive got issue converting string field in ms sql table desired date format. previously have used convert(date,c.inp_date ,103) but gives me error [err] 22007 - [sql server]conversion failed when converting date and/or time character string. two sample records have 2013-09-18 , 2013-09-18 17:17:32.0000000 receive import via mysql. need these converted dd/mm/yyyy time applicable. any gurus out there appreciated :) declare @a varchar(50) = '2013-09-18' , @b varchar(50) = '2013-09-18 17:17:32.0000000' select convert(varchar(10),cast(@a date),103) , convert(varchar(10),cast(@b date),103)

class - I'm having problems understanding how this Java works with the arguments I'm feeding it -

the issue i'm having understanding code when running command: java driver 1000000 returning: sum(1000000) = 1784293664 and no matter how long try @ cant understand why , how code doing im wondering if can provide in understanding code number? class sum { private int sum; public int get() { return sum; } public void set(int sum) { this.sum = sum; } } class summation implements runnable { private int upper; private sum sumvalue; public summation(int upper, sum sumvalue) { this.upper = upper; this.sumvalue = sumvalue; } public void run() { int sum = 0; (int = 0; <= upper; i++) sum += i; sumvalue.set(sum); } } public class driver { public static void main(string[] args) { if (args.length != 1) { system.err.println("usage driver <integer>"); system.exit(0); } if (integer.parseint(args[0]) < 0) { system.err.println(args[0] + " must >= 0"); syst...

linq - How to update a property for a specific element of an IEnumerable List in C# -

i have ienumerable list, ienumerable<sortelement> sorts; i updating property as: sorts.where(a => a.displayname.tolower() == "abc") .tolist() .foreach(sl => sl.displayname = "testing"); but not change property specific element. change "abc" "abc" . condition never met. can change .tolower() .toupper() . i thing this: foreach(var e in sorts.where(a => a.displayname.tolower() == "abc")) e.displayname = "testing"; because code in fact executes 2 loops, that's not necessary.

java - Eclipse incorrect project location on disk -

i had problem eclipse juno due workspace name , project name being same. created new workspace , imported projects new one. when go project's properties (in new workspace), showing path old workspace on disk. how solve this? why not open .classpath , .project files in notepad , take @ values pointing old location , change them new paths relevant.

c# - making a .NET TextBox work FIFO style -

i have win gui application written in c#, in have textbox component write log to. @ point gets loaded , entire app starting falter. i'd make efficient mechanism make fifo, meaning - make fixed size , deleting oldest content automatically. is there .net/c# feature doing that? otherwise, right way this? update : have issue other sort of textual data, , not logs. therefor, listbox not proper solution me. to create circular buffer text, i'd use stringbuilder , capacity set twice amount of data want display. const int displaysize = 10000; stringbuilder fifo = new stringbuilder(2 * displaysize); string appendtofifo( string s ) { if (s.length >= displaysize) { // fact: display include data s // therefore, toss entire buffer, , keep tail of s fifo.clear(); fifo.append(s, s.length - displaysize, displaysize); return fifo.tostring(); } if (fifo.length + s.length > fifo.capacity) { // fact: overflow f...

how to get table list and there structure in sql server -

how can table list , structure sql server.. use following code database list sql server. select * sys.databases sys.databases.database_id > 4 this query return's database "name" , "id" , many other fied... and .net app show bind list dropdown... need table list of selected database in dropdown on basis of it's id... what query table list of selected database. select name sys.tables type = 'u' --u = user defined tables opposed system tables

jquery - Is it possible to specify context in callback of a jsonp Ajax call? -

is possible specify our specific context in callback of jsonp ajax call? the way found specifying callback name not implementing callback go in success method desired context: $.ajax({ type: "get", url: 'someurl', datatype: 'jsonp', jsonpcallback: 'mycallbackname', context: this, success: function (response) { console.log(this); //this must context specified earlier } }); the problem if it's working, receive lot of errors: typeerror: mycallbackname not function any idea of how achieve without causing errors? thanks etienne this should trick: $.ajax({ type: "get", url: 'someurl', datatype: 'jsonp', jsonpcallback: 'mycallbackname', context: this, success: delegate(this, function (response) { console.log(this); //this must context specified earlier }) }); var delegate...

amazon ec2 - Upgrading an EC2 m1.Medium into a EC2 m1.Large instance -

i scale wanted know if can upgrade current 64 bits ec2 m1.medium instance 64 bits m1.large instance. is right way scale (bare in mind i'm running small site)? after upgrade new instance , terminate old one, there difference between 2 instances? thanks in advanced. is right way scale (bare in mind i'm running small site)? it work, minize risk , downtime people prefer create ami existing instance, create new, upgraded instance ami. way can test new instance while old 1 still runing. once you're satisfied new instance, reassign elastic ip of old 1 new one. after upgrade new instance , terminate old one, there difference between 2 instances? other increased memory, cpu , storage, there should little difference. filesystem content should identical.

c - How to use sockets recv(,,,) for an indeterminate response length -

i have requirement send commands , read responses device using irda sockets communication. although packaging commands straight forward, determining expected size of response not possible. example command "get_errors" results in device returning data 0 n , \n delimited lines of 80 bytes each. have read post * here , ***header preceding actual data block* not provided me device. [edit] here typical response get_errors command (shorted readability): date time fault 10/12/2000 02:00:00 3f46 10/12/2000 02:00:00 bcf5 10/12/2000 02:00:00 1312 10/12/2000 02:00:00 a334 10/12/2000 02:00:00 b212 10/12/2000 02:00:00 b212 10/12/2000 02:00:00 c43a % this example, (from post here ) works if know length of data being returned: int recv_all(int sockfd, void *buf, size_t len, int flags) { size_t toread = len; char *bufptr = (char*) buf; while (toread > 0) { ssize_t rsz = recv(sockfd, bufptr, toread, flags); if (rsz <= 0) ...

iphone - Button's background on ios7 is squeezed, ios6 ok -

Image
i updated xcode 5. buttons in app ok in ib , on ios 6 device, on ios 7 device (they should cover whole black space): i have images both non-retina/retina. i have no idea do, because didn't change in code or ib. edit: now found out, if change type of button custom system , set background instead of image, correct size strange shadow on it. edit2: now set button's tint color "clear color" , seems ok (shadow disappeared). still not sure has changed in ios 7 related this. the human interface guidelines outline how system-style uibuttons work default. it explains system button: has no border or background appearance default ... supports custom decoration, such border or background image (to add custom appearance, use button of type uibuttontypecustom , supply custom background image). however uibutton hig page provides little more information, specifically: if not explicitly set tint color, button inherit superview’s tint color. ...

perl - Need to replace a specific column value of a file based on values in other columns of the file -

below content of file , below requirement based value in column no 1 , column no 5, want replace value in column 7 "1". for example: if column 1="change" , column 5="defer", replace value in column 7 "1". if column 1="change" , column 5="defererence" replace value in column 7 "1". otherwise not row, keep is. input file: change|sinmg|1234|ewfew|def|fdfd|james|rewr|robert|3|fe change|sinmg|2345|ewfew|defer|venktraaammamamammama|3|rewr|beaey|3| nochange|sinmg|2323|ewfew|def|venktraaammamamammama|3|rewr|beaey|3|fe change|sinmg|3456|ewfew|defer|venktraaammamamammama|3|rewr|beaey|3| change|sinmg|2345|ewfew|defererence|venktraaammamamammama|3|rewr|beaey|3| above sample make easier explain.however want pass values column 1 , column 5 file match against value in file. if matches, replace column 7 value "1" otherwise dont row, keep is. i tried couple of options , not able achieve required results....

javascript - How to make the gird groupable false/true dynamically in JS? -

at first, grid defined this: click search button , grid reads data , becomes grouped class: @(html.kendo().grid<student>() .name("studentgrid") .scrollable() .columns(columns => { columns.bound(o => o.class).groupable(true).title("class"); columns.bound(o => o.name).groupable(true).title("name"); columns.bound(o => o.point).groupable(true).title("point"); }).autobind(false) .datasource(datasource => datasource .ajax().group(i => i.add(a => a.class)) .read(read => read.action("getstudentpoint", "studentcontrol")) .events(events => events.error("error_handler")) )) now want make gird groupable false , hide class column. means, not want group student data , hide class column: $("#studentgrid").data("kendogrid").groupable( false ); $("#studentgrid").data("kendogrid").hid...

php - How can I implement Ajax Form Validation in Sonata Admin Bundle? -

i newbie in symfony. use sonata admin bundle symfony 2.1. how can implement ajax form validation? there solutions? i'm not sure if works in sonata admin 2.1 can try following if have example *sonata_type_collection*. set option: 'cascade_validation' => true should job. that works quite fine @ current sonata admin (2.3). $formmapper ->with('customer_contacts', array('collapsed' => true)) ->add('customer_has_contacts', 'sonata_type_collection', array('cascade_validation' => true), array( 'edit' => 'inline', 'inline' => 'table', 'sortable' => 'position', 'admin_code' => 'acme_demo_bundle.customer_has_contacts', ) ) ->end();

mongodb - Reference field within same schema -

is possible reference field within same schema? see example below. or going wrong way? var userschema = new mongoose.schema ({ username: string, password: string, email: string, foods: [{ name: string, category: string, ingredients: // how reference values in ingredients array? }], ingredients: [{ name: string, category: string }] }); short answer this core mongodb design decision: mongodb relationships: embed or reference? storing references objects, rather independent copies of them, in relational database possible in mongodb , done, results in more , more complex queries when need them up. long answer if goal keep definitions of ingredient schemas consistent, can define schema , use twice. ingredients stored independent copies, e.g. [{ username: 'bob', ingredients: [ { name: 'carrot', category: 'vegetable' } , ...], foods: [ { name: 'salad', category:...