Posts

c++ - Is there a way to emplace return value? -

// version 1 struct range { int begin, end; }; inline range getrange() { int newbegin, newend; // calculations return {newbegin, newend}; } struct test { std::vector<range> ranges; inline void intensive() { ranges.push_back(getrange()); // or ranges.emplace_back(getrange()); // (gives same performance results) } }; // version 2 struct range { int begin, end; }; struct test { std::vector<range> ranges; inline void intensive() { int newbegin, newend; // calculations ranges.emplace_back(newbegin, newend); } }; version 2 faster version 1 . fact is, getrange() used multiple classes. if apply version 2 , there lot of code duplication. also, cannot pass ranges non-const reference getrange() , other classes use std::stack instead of std::vector . have create multiple overloads , have more code duplications. is there common way/idiom emplace return value ? followin...

rotation - Rotate grid of plot with R -

Image
for example : plot(1:10, 1:10) grid(col="red") is possible rotate red grid around intersection of x axis , y axis (the origin {0,0}) , arbitrary angle ? doesn't mean example want that. the grid function cannot in base r anyway. it's not object-oriented plotting paradigm. think come close abline : plot(1:10, 1:10,xlim=c(0,10), ylim=c(0,10)) sapply(seq(0,20,by=2), function(a) abline(a=a, b=-1,lty=3,col="red")) sapply(seq(-10,10,by=2), function(a) abline(a,b=1,lty=3,col="red")) it's minor application of coordinate geometry rotate arbitrary angle. angle=pi/8; rot=tan(angle); backrot=tan(angle+pi/2) sapply(seq(-10,10,by=2), function(inter) abline(a=inter, b=rot,lty=3,col="red")) sapply(seq(0,40,by=2), function(inter) abline(a=inter, b=backrot, lty=3,col="red")) this break down when angle = pi/2 might want check ...

c# - SendInput is blocked in fruit ninja for pc -

i writing program uses sendinput function simulate mouse events play fruit ninja pc. when called sendinput , mouse moved nothing happened on game screen. tell me why doesn't work , give me solutions? programmed on c# , used [dllimport] call sendinput function. thanks. i suggest simulating mouse move . should simulate mouse drag . first mouse down -> mouse move -> mouse up here code old project: namespace clicker.enums { public enum mouseevents { move = 0x0001, /* mouse move */ leftdown = 0x0002, /* left button down */ leftup = 0x0004, /* left button */ rightdown = 0x0008, /* right button down */ rightup = 0x0010, /* right button */ middledown = 0x0020, /* middle button down */ middleup = 0x0040, /* middle button */ xdown = 0x0080, /* x button down */ xup = 0x0100, /* x button down */ wheel = 0x0800, /* wheel button rolled */ virtualdesk = 0x4000, /* map entire...

.htaccess - Rule to redirect file based on timestamp? -

i need filter json files based on date , time present on it's name. if file name datetime.json bigger current time want redirect future.json . if file name less current time, don't redirect. for example: current date , time 1377512625 . file name 1345732202 . current date , time greater file name, serve 1345732202.json : http://myserver.com/1345732202.json current date , time 1377512625 . file name 1408804202 . current date , time less file name, serve future.json : http://myserver.com/1408804202.json here .htaccess not work: rewriteengine on rewritecond %{time} <%{request_filename} [nc] rewriterule ^(.*)\.json$ /future.json [r=307,l]

sql - Removing SSRS security for a single person -

we have employee left company, , have bunch of ssrs reports has access to. there way remove of reports @ once, or have go 1 one? you can delete user reportserver database. then, user can no longer verified, , login becomes impossible. ps: backup reportserver database first, in case... delete [reportserver].[dbo].[policyuserrole] userid in ( select userid users username ='blabla' ) delete users username ='blabla'

android - Creating a polygonal geofence -

this question has answer here: android geofencing (polygon) 1 answer does know how create polygonal geofence in android? i know android supports circular (i.e., lat/long + radius) geofences, need more precise control on boundaries. for concerns cpu & power consume , recommend use solution decribed here . create fake circular geo-fence around polygon when geofence alert thrown circular geofence, evaluate if inside polygon using answer provided karl.

r - Set color for segments in ggnet -

Image
i hvar following data set: structure(c(2l, 6l, 2l, 6l, 7l, 7l, 2l, 7l, 6l, 8l, 8l, 4l, 8l, 2l, 9l, 8l, 7l, 6l, 9l, 1l, 9l, 4l, 9l, 3l, 2l, 10l, 9l, 10l, 8l, 10l, 7l, 6l, 10l, 1l, 2l, 12l, 9l, 8l, 12l, 1l, 11l, 10l, 2l, 44l, 79l, 10l, 8l, 47l, 45l, 51l, 9l, 11l, 74l, 75l, 77l, 69l, 75l, 77l, 78l, 2l, 44l, 44l, 46l, 46l, 8l, 6l, 1l, 1l, 6l, 7l, 1l, 4l, 7l, 8l, 8l, 1l, 4l, 8l, 3l, 8l, 8l, 9l, 9l, 9l, 1l, 9l, 5l, 9l, 3l, 9l, 9l, 9l, 10l, 8l, 10l, 7l, 10l, 10l, 1l, 10l, 10l, 9l, 12l, 12l, 1l, 12l, 12l, 12l, 12l, 7l, 7l, 44l, 44l, 44l, 44l, 44l, 44l, 44l, 44l, 44l, 44l, 7l, 7l, 7l, 7l, 44l, 10l, 9l, 42l, 43l, 46l, 46l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, -1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, -1l, 1l, 1l, 1l, -1l, -1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, -1l), .dim = c(66l, 3l), .dimnames = list(null, c("from", "to", "impac...