Posts

java - What declaration turns the below loop into infinite loop? -

place declaration i @ line 3 loop becomes infinite loop. public class puzzel3 { public static void main(string[] args) { // line 3 while (i == + 1) { system.out.println(i); } system.out.println("done"); } } double i=1/0.0; it turn loop in infinite

algorithm - how to find the longest path of increasing numbers in a grid? -

this question has answer here: longest increasing sequence 2d matrix recursion 4 answers assuming have grid: 1 5 7 3 4 9 6 2 8 the solution be: 1-3-4-5-7-9 how solved? i think problem can solved using recursive dp. memoise lenght of longest path obtained starting @ particular point. int dp[rows][cols]={0}; int dfs(int x , int y , int val) { if(dp[i][j] != 0 ) // visited return dp[i][j]; int lengthoflongestpath = 0; search in 4 directions in grid element greater val; // newx, newy,newval lengthoflongestpath = max(lengthoflongestpath , dfs( newx , newy , newval)); lengthoflongestpath ++; // add particular element path dp[x][y] = lengthoflongestpath; return dp[x][y]; } int ans = 0; for(i=0 rows) for(j=0 cols) if(dp[i][j] == 0) // unvisited { dp[i][j] = dfs(i,j,grid[i][j])...

asp.net mvc - How to Get a custom header value from an HttpAuthenticationContext -

i busy implementing , authentication filter: public task authenticateasync(httpauthenticationcontext context, cancellationtoken cancellationtoken) { var request = context.request; // receive token client. here example when token in header: var token = request.headers.firstordefault(x => x.key == "token").value.tostring(); //["token"]; how header called token ? because above code doesn't work. guessing because not standard header. request.headers.getvalues("token");

Reading node.js documentation on the command line -

i'm relatively new node , other day when hacking on without 'net connection, wanted read documentation of http module command line. in python or perl, use pydoc or perldoc , name of module want read documentation for, life of me, couldn't figure out how node.js , now, reading online doesn't seem shed light on tiny little brain. so how read (install?) node documentation, particularly non-core modules such angular, particularly if i'm in old farmhouse in middle of , no 'net connection? check out wat , project made above. it's in beta, should public release month, , supports node.js documentation on command line.

Creating a class,for a box. (Java) -

hi had assignment class: implement class named box have following attributes , methods: int length, width, height string color constructor method that: will initialize 3 integers 10, 8, 6 will initialize color “black” a setter , getter method each of 4 attributes a method volume of box a method surface area of box (all 6 sides) i have getters , setters length width , color. problem volume not calculate if set values different. it takes initialized values. ideas go it? code below class. example .setlength(7) , instead of printing total 7*8*6, prints out total of 10*8*6. public class box { private int height = 6; public void se(int height){ this.height=height; } public int getheight(){ return height; } private int width = 8; public void setwidth(int width){ this.width=width; } public int getwidth(){ return width; } private int length= 10; public void setlength(int l...

android - Floating EditText on top of Layout -

in xamarin, possible have edittext "floating" on top of layout? i thinking of "bring front" sort of code. currently edittext not showing. here current code: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:padding="5dip"> <edittext android:id="@+id/inputsearch" android:layout_width="fill_parent" android:layout_height="49.1dp" android:hint="find..." android:inputtype="textvisiblepassword" android:layout_marginbottom="15.2dp" /> <framelayout android:id="@+id/mapwithoverlay" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_below=...

c# - ASP MVC4 + NHibernate objects in Session -

i need save hibernate object session , retrieve 1 of it's foreign key properties this: public actionresult login(loginmodel model, string returnurl) { user usr = _userrepository.getbyid(convert.toint32(modelstate["user"].value.attemptedvalue)); session["user"] = usr; } public actionresult index() { customer customeractive = session["user"].customer.active; // line throws error: // initializing[myproj.models.customer#3]-could not initialize proxy - no session. } as user.customer foreign key , nhibernate lazy loads it, call fails. how prevent "no session" failure? if want continue existing approach want make sure customer initialized before put session, e.g. var userid = convert.toint32(modelstate["user"].value.attemptedvalue); user usr = _userrepository.getbyid(userid); nhibernateutil.initialize(usr.customer); session["user"] = usr; but... as commentators have hinted there vari...