Posts

compiler construction - Why Bison gives Conflict: 2 Shift Reduce error -

i'm trying below yacc grammar part gives me, wrong this? , how can solve it? there rules define grammar in bison/ yacc ? c:\users\dilan\documents\lexprogram\miniproject>bison -dy videostore.y conflicts: 1 shift/reduce and yacc code : %start videostore %token title %token type %token name %token days %% videostore : movies customers | customers movies | movies | customers ; movies : movies movie | movie ; movie : title type rentals2 ; rentals2 : rentals2 rental2 | rental2 ; rental2 : customer1 ; customer1 : name days ; customers : customers customer | customer ; customer : name days rentals ; rentals : rentals rental | rental ; rental : movie1 ; movie1 : title type ; %% int trace=0; my problem videostore.y: conflicts: 2 shift/reduce , how...

multithreading - Node.js data processing distribution -

i'm in need of strategy distribute data processing using node.js. i'm trying figure out if using worker pool , isolate groups of tasks in these workers best way, or using pipe/node-based system http://strawjs.com/ way go. the steps have following (for single job): extract zip-file containing gis shapefiles convert files geojson using ogr2ogr denormalize data in geojson file transform data format use in mongodb upsert data mongodb collection the main problem don't know how merge data different geojson files when using pipe/node-based system straw. i understand how work in worker pools. don't know how distribute workers on several machines. i've tried naive way of doing in single thread on single machine using async module. works small sets of data. in production i'm need able support millions of documents on pretty frequent interval. the reasons behind using node.js have solid infrastructure scaling node.js processes , use node.js every as...

c# - Store difference between two dates recursively and calculate time spent on web site -

i have find time spent on site choose maintain 2 datetimes , time in database can save difference between login time , logout time , store in table column timespent . the time stored {00:16:58.413785200} have add amount of time recursively after each logout if spent 10 minutes in first login , 5 minutes in 2nd login have store 15 min timspent on site. but problem not able guess happens if want add 2 minutes after 23:59:59.000000000. know max time value 23:59:59 can stored time datatype in sql. so how achieve this? have tried var _user = db.users.singleordefault(t => t.id == id); _user.endtime = datetime.now; var _starttime = _user.starttime; if (_user.timespent != null) { _user.timespent = _user.timespent + (_user.endtime - _starttime); } else { _user.timespent = (_user.endtime - _starttime); } db.savechanges(); you need switch datatype on timespent column bigint . should have default value of 0 timespent column aswell or handle in code. var...

android - How can i send images available in asset folder using intent -

i'm trying send images available in asset folder using intent providing error says shared failed try again later please provide me suggestion. here i'm doing intent share = new intent(intent.action_send); share.settype("image/*"); share.putextra(intent.extra_stream, uri.parse("file:///android_asset/1.jpg")); startactivity(intent.createchooser(share, "share image!")); i trying using this intent share = new intent(intent.action_send); share.settype("image/*"); share.putextra(intent.extra_stream, uri.parse("android.resource://com.example.whatsappshare/asset/1.jpg")); startactivity(intent.createchooser(share, "share image!")); both ways providing same result. once created bitmap said earlier, use following snippet send attachment. string path = images.media.insertimage(getcontentresolver(), your_bitmap, "title", null); uri screenshoturi = uri.parse(path); final intent emailintent = new...

lua - Parse rest api query with OR condition -

i having difficulties working out how perform or type query using parse rest api. i have 2 classes set below. there 1 - many relationship between , b classa -> objectid -> player1 -> player2 classb -> objectid -> classaid (pointer) -> somedata1 -> somedata2 what trying classb records current user id either in player1 or player2 field if classa. i can query working when looking see if player1 field current user i.e. lua table looks (then encoded json , sent parse). send query classb rest url. local querytable = { ["where"] = { ["classaid"] = { ["$inquery"] = {["where"] = { ["player1"] = settings.userid} , ["classname"] = "classa" } } } } could point how can include player2 field. if sql i'd on sonic parse different beast! ...

Objective-c string not working -

hi im new objective c , have question. here code... ccscene *restartscene = [ccbreader loadasscene:@"levels/level%d",_currentlevel]; basically when level loads want load ever level value of _currentlevel is, getting error saying "too many arguments method call, expected 1,have 2". making noob mistake in advance. loadasscence needs string argument. have construct string: ccscene *restartscene = [ccbreader loadasscene: [nsstring stringwithformat:@"levels/level%d",_currentlevel];

java - canvas bitmap animations without using a sprite sheet -

bitmap[] planeframes = new bitmap[4]; protected void ondraw(canvas canvas) { for(int = 0 ; < planeframes.length;i++) canvas.drawbitmap(planeframes[i], plane.getcenterx(), 0, null); // planeframes array of bitmaps } im trying animate plane swapping images not working don't know if method simple work with you can not animate way. ondraw called per draw iteration meaning whatever draw on canvas @ return what's going drawn on screen. you're doing here drawing bitmaps on canvas @ same spot , plastered on top of each other. what need call invalidate() method of view. make things more efficient, can use rect or define areas around bitmaps. @override protected void ondraw(canvas canvas) { canvas.drawbitmap(planeframes[i], plane.getcenterx(), 0, null); if(++i >= planeframes.length) { = 0; } invalidate(bmprect); } this consistently draw through bitmaps while repeatedly drawing new bitmaps. last forever long v...