Posts

returning a multidimensional array with explicit return type in c++ -

i have class has member defined as: float u[2][2]; now have accessor function , return reference array. so, have like: const float & [2][2] mat() const { return u; } is there way return using kind o syntax rather pointer syntax (i think makes things more explicit). it's awkward, but: const float (&mat() const)[2][2] { return u; } using typedef or decltype might better, eg: const decltype(u) &mat() const { return u; } or: using mat22 = float[2][2]; const mat22 &mat() const { return u; } (this latter 1 suggested daniel h. in comments). or, in c++14, just: const auto &mat() const { return u; }

How to plot mixed-effects model estimates in ggplot2 in R? -

Image
i have 2x2x2 factorial design 1 random effect. data (dat) follows: colour size level marbles set blue large low 80 1 blue large high 9 2 blue small low 91 1 blue small high 2 1 white large low 80 2 white large high 9 1 white small low 91 2 white small high 2 1 i want plot 2 models: mod1 <- lmer(marbles ~ colour + size + level + colour:size + colour:level + size:level + (1|set), data = dat) mod2 <- lmer(marbles ~ colour + size + level +(1|set), data = dat) i use following code plots: pd <- position_dodge(0.82) ggplot(dat, aes(x=colour, y=marbles, fill = level)) + theme_bw() + stat_summary(geom="bar", fun.y=mean, position = "dodge") + stat_summary(geom="errorbar", fun.data=mean_cl_boot, position = pd)+ + facet_grid(~size) i'm unsure on how replace terms coefficients model estimates. ideas on how can plot ...

(Android)changing the game window size and re-positioning it -

i'm making top-down shooter android platform , i'm trying screen portrayed in added image( orange rectangles virtual buttons). following code being run before game starts change game window size fit device's screen: ///display properties display_width=display_get_width(); display_height=display_get_height(); ideal_width=0; ideal_height=display_height; aspect_ratio=display_width/display_height; ideal_width=round(ideal_height*aspect_ratio); //ideal_height=round(ideal_width / aspect_ratio); //perfect pixel scaling if(display_width mod ideal_width != 0) { var d = round(display_width/ideal_width); ideal_width=display_width/d; } if(display_height mod ideal_height != 0) { var d = round(display_height/ideal_height); ideal_height=display_height/d; } //check odd numbers if(ideal_width & 1) ideal_width++; if(ideal_height & 1) ideal_height++; for(var i=1; i<=room_last; i++) { if(room_exists(i)) { room_set_view(i,0,true,0,0,720,1280,60,60,720,1280,0,0,0,0,-...

react native - How to test a Saga with an API call? -

i have saga export function* mysaga(api, action) { const response = yield call(api.service, action); yield put(navactions.goto('page', { success: response.ok })); } that calls api , return value navigate screen passing api call result ( response.ok ). it('test', () => { // ... const gen = mysaga(api, action); const step = () => gen.next().value; // doesn't run api const response = call(api.service, {}); expect(step()).tomatchobject(response); // ok // error, cannot read property 'ok' of undefined expect(step()).tomatchobject( put(navactions.goto('page', { success: response.ok })) ); }); since it's not running api call response doesn't defined. i don't know should test scenario. how test second step of saga? by default, yield expression resolves whatever yielded. however, can pass value gen.next method , yield expression resolved passed there. so should trick (untested): con...

html - setting the focus on the nav bar -

does know css , html code can use set focus on nav bar. in other words want page tab such home page highlighted when user on home page. if user go's contact page contact page nav bar tab should highlighted. you can in html/ccs providing pages have classes or id's. using home example: html <body class="home">... <li class="home>...</li><li class="other>...</li> css .home li.home { ... } .other li.other { ... } this won't set :focus give visual effect desire.

android - Copy file with hook -

i'm working ionic application , need replace mainactivity generated, new 1 create. since use ibm mfp analytics plugin , other tests. the hook creates: #!/bin/bash gulp build in hook folder have: hooks ---- before_build ---- mainactivity.java all_before_build.sh lo que necesito es agregar este hook la linea cp mainactivity.java platforms/android/src/cl/my_app/android/ however, when execute hook error: cp: cannot stat 'mainactivity.java': no such file or directory i know error not find file mainactivity.java , if is, explained above directory. edit the previous problem solved, leaving full path of mainactivity.java, when run application, works fine opens notepad code.

javascript - How to make keydown or keypress to be handled only by the current focused element -

i have sort of single web page app in have 2 different views (divs) displayed both in same time on page. the first view has ui grid on navigation feature have eventlisteners keydown , keypress detect tab or arrow keys being pressed , navigate cell cell on grid. in second view have form many fields , 1 of them textarea multiline input (see biography field in the md-input demo page ). textarea needs navigation on lines while editing. when arrow keys pressed both grid , textarea react , navigation occurs in both when textarea focused. i have tried apply $event.stoppropagation(); , event.stopimmediatepropagation() on grid root element when textarea focused didn't work. possible prevent keydown , keypress handlers being executed in whole first view , let happen in second view ? how prevent happen in element , children ?