Posts

Showing posts from March, 2011

How do you do conditional "left join" in R? -

i have found myself doing "conditional left join" several times in r. illustrate example; if have 2 data frames such as: > df b 1 1 0 2 2 0 > other.df b 1 2 3 the goal end data frame: > final.df b 1 1 0 2 2 3 the code i've been written far: c <- merge(df, other.df, by=c("a"), all.x = true) c[is.na(c$b.y),]$b.y <- 0 d<-subset(c, select=c("a","b.y")) colnames(d)[2]<-b to arrive result wanted. doing in 4 lines makes code opaque. there better, less cumbersome way this? here 2 ways. in both cases first line left merge returning required columns. in case of merge have set names. final line in both lines replaces na s 0 . merge res1 <- merge(df, other.df, = "a", all.x = true)[-2] names(res1) <- names(df) res1[is.na(res1)] <- 0 sqldf library(sqldf) res2 <- sqldf("select a, o.b df left join 'other.df' o using(a)") res2[is.na(res2)] <- 0

c# - bindingContext.ModelName is empty? -

so i'm trying apply darin dimitrov's answer , in implementation bindingcontext.modelname equal "". here's viewmodel: public class urunviewmodel { public urun urun { get; set; } public type uruntype { get; set; } } here's part of view posts model types: @model urunviewmodel @{ viewbag.title = "tablo ekle"; var types = new list<tuple<string, type>>(); types.add(new tuple<string, type>("tuval baskı", typeof(tuvalbaski))); types.add(new tuple<string, type>("yağlı boya", typeof(yagliboya))); } <h2>tablo ekle</h2> @using (html.beginform("urunekle", "yonetici")) { @html.validationsummary(true) <fieldset> <legend>tablo</legend> @html.dropdownlistfor(m => m.uruntype, new selectlist(types, "item2", "item1" )) and here's custom model binder: public class urunbinder : defaultmodelbinder { protected override object createmodel(control...

c++ - Returning a reference parameter -

say have following code: #include <string> using namespace std; string getpath(const string & astring); int main() { string dave = "hello"; string tom = getpath(dave); } string getpath(const string & astring) { //do stuff //if function fails return original string return astring; //or should return string(astring) } i have situation need pass string function , if function fails task return string passed in. my question i'm unsure on behaviour of returning astring has been passed reference. should sort of code avoided, , if why? suprised return (does make copy perhaps?). to on safe side constructed new object returned return string(astring) again may overkill , not necessary. any clarification appreciated. thanks yes, it's fine return astring because return value , theoretically copy created (rvo can kick in, if does, doesn't affect behavior). to on safe side constructed new object returned return string(astring) again may overkill , n...

sockets - WSAWaitForMultipleEvents returns timeout when send() is succesful -

i working on application involves socket programming. trying implement reset functionality in application in case server closed or crashed reason. reset need reestablish communication between client , server after manual restart of server. able send request client server server process , send reply client. send() function @ server side returning success wsawaitformultipleevents() function @ client side returning wsa_time_out every time. i restart socket @ client side so_reuseaddr true value on reset. new network programming not able understand why happening. please help. thank you here code @ client side. little messed please bear me void socketlistner::run() { // std::cout << "thread id of socketlistener : " << qthread::currentthreadid() << "\n"; if(_isframegrabber) { _listenforframes(); } else { _listenforrequests(); } } void socketlistner::_listenforrequests() { dword eventval; unsigned int eventsock; wsanetworkevents networkevents; std...

sql - alternate use of the CASE on table UPDATE -

this works: update keyboard_learning set a.date_completed = case when a.date_completed = '04-jul-2012' '06-jul-2012' end a.emplid = 18 but won't(below). error datatypes don't match, , of course makes sense because 1 date datatype , other number. update keyboard_learning set a.date_completed = case a.date_completed when '04-jul-2012' '06-jul-2012' end a.emplid = 21 my question: there workaround make second way work place column name 'a.date_completed' in case line of sql instead of how got working first way? off on syntax second sql? convert date_completed string in case statement. try this: update keyboard_learning set a.date_completed = case to_char(a.date_completed, 'dd-mon-rrrr') when '04-jul-2012' to_date('06-jul-2012','dd-mon-rrrr') end a.emplid = 21

http status code 404 - Not Found The requested URL was not found on this server. Additionally, a 404 -

Image
i have website can load homepage other link than homepage brings error. i have index.php file in root sever dont have .htacess file. need this. if need more information please let me know. thank you not found the requested url /tv-torrents/tour-de-france-2012-stage-5-nbc-sports-hd_399285833.html not found on server. additionally, 404 not found error encountered while trying use errordocument handle request. http status code 404 - not found requested url not found on server. additionally, 404 - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick overview of site center detailed answers questions might have meta discuss workings , policies of site learn more stack overflow compa...

android - How do I detect if a user has touched any part of the screen other than the inside of an EditText? -

i guessing means making whole screen touchable. how done? and secondly calculating if x,y within edittext. override ontouchevent in activity want implement this....and x, y co-ordinates using event.getx() , event.gety() @override public boolean ontouchevent(motionevent event) { int x = (int)event.getx(); int y = (int)event.gety(); switch (event.getaction()) { case motionevent.action_down: case motionevent.action_move: case motionevent.action_up: } return false; } but suggest must search thoroughly before posting question.

html - Google+ Button Not Displaying Inline -

my google+ button displays inline other buttons in firefox & internet explorer. however, not display inline other buttons in google chrome. page can seen here: http://www.abijahchristos.com/sample/springspa jsfiddle here: http://jsfiddle.net/abijah/hjpac/ in main.css on line 170 change #social li { display: inline } to #social li { display: inline-block } jsfiddle

java - Realtime Sound Producing Website for Smart Phones -

Image
i looking options available create website accessible via smartphone can produce sound in real time. mean might need library convert osc messages sound using smart phone browser. javascript not seem work reason. could please suggest able render sound on smartphone in realtime? html5/css/javascript/java applet? time! java - realtime sound producing website smart phones - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick overview of site center detailed answers questions might have meta discuss workings , policies of site learn more stack overflow company business learn more hiring developers or posting ads log in sign up learn, share, build each mo...