Friday, 15 February 2013

XCode force touch -



XCode force touch -

how can forcefulness xcode (4.5.x) forcefulness "touch" on file (foo.m) every time nail build button.

i file compiled every time though nil has changed (it contains date & time macro in case curious).

that's poor solution. improve run build script generate source file containing current date , time. can compile , link generated source file final binary.

this create easier manage git, foo.m won't seen alter though no functional changes have occurred.

xcode touch

Using session object in Django unit test -



Using session object in Django unit test -

i writing login view , add together unit test view. view looks this:

def login(request): if request.post: usrname = request.post.get('username') password = request.post.get('password') user = authenticate(username=usrname, password=password) if user not none: auth_login(request, user) homecoming redirect('/core/home/') else: context = {'error_message': "invalid username or password"} homecoming render(request, 'core/login.html', context) else: c = {} c.update(csrf(request)) homecoming render_to_response('core/login.html',c) def home(request): if request.user.is_authenticated(): context = {'user' : request.user} homecoming render(request, 'core/home.html', context) else: homecoming render(request, 'core/login.html')

and unit test looks this:

class coreviewtests(testcase): def setup(self): self.factory = requestfactory() def test_login_view_with_valid_user(self): uf = userfactory() user = uf.make_user("validuser1", "12345", "user@abc.com") self.assertequal(user.username, "validuser1") request = self.factory.post('/core/login', {"username": "validuser1", "password": "12345"}) response = login(request) self.assertequal(response.status_code, 200)

the unit test crash because cannot find session object. follow couple tutorial on websites defining dummy session dictionary doesn't help.

can shed lite me how write unit test view need deal session object?

thanks.

from documentation requestfactory object:

it not back upwards middleware. session , authentication attributes must supplied test if required view function properly.

you seek manually setting request.session dictionary appropriate stuff in it, say. might turn out easier utilize old-fashioned django test client though.

django session

java - Trouble with my algorithm to solve a boggle board -



java - Trouble with my algorithm to solve a boggle board -

so i'm relatively new java (i'm taking ap java @ school currently) , trying develop recursive algorithm solve n*n board , sense close not quite there yet. have written out traverse dictionary find if letters sending words or not etc. algorithm have starting letter (n,p) in array, send cordinates method go in every direction find possible combinations. 1 time combinations starting (n,p) have been found, increment p until got end of row increment n , start p 0 again. (i go through half letters because combinations same backwards , forwards)

the part have problem recursive sequence because 1 time go on position on board want mark create sure never go on 1 time again rest of sequence. doesn't work , wondering if tell me why/help me write improve algorithm. in advance

public void allletters(int n, int p, int x, int y,string word, string myletteres[][]){ int temp=0; int startletter =(int)(math.pow(myletteres.length,2)); while(temp<startletter)//runs through every letter { if(temp==0) getpaths(p, n,x,y,word, myletteres); else if(temp%(myletteres.length-1)==temp){ getpaths(p, n+1,x,y,word, myletteres); } else { getpaths(p+1, 0,x,y,word, myletteres); } if(temp==(startletter/2-1)){ temp=startletter; } temp++; } } public void getpaths(int p, int n, int x, int y,string word, string myletteres[][]){ if( x ==p-1 && y == n-1){//reach (n,p) point system.out.print(""); }else if( x >= myletteres.length || y >= myletteres.length||x < 0 || y < 0){//out of bounds return; }else { if(x+1<myletteres.length&&!myletteres[x+1][y].equals("0")){//up{ word=word+""+myletteres[x+1][y]; check(word);//function checks if word reverse(word);//checks word backwards (for efficenicy) myletteres[x+1][y]="0";//marking i've used position system.out.print("1");//debugging purposes getpaths(n,p, x +1, y,word , myletteres); } if(x-1>0&&!myletteres[x-1][y].equals("0")){//down word=word+""+myletteres[x-1][y]; check(word); reverse(word); myletteres[x-1][y]="0"; system.out.print("2"); getpaths(n,p, x -1, y ,word, myletteres); } if(y+1<myletteres.length&&!myletteres[x][y+1].equals("0")){//right word=word+""+myletteres[x][y+1]; check(word); reverse(word); myletteres[x][y+1]="0"; system.out.print("3"); getpaths(n, p,x , y +1,word, myletteres); } if(y-1>0&&!myletteres[x][y-1].equals("0")){//left word=word+""+myletteres[x][y-1]; check(word); reverse(word); myletteres[x][y-1]="0"; system.out.print("4"); getpaths(n,p, x , y -1,word, myletteres); } if(x+1<myletteres.length&&y+1<myletteres.length&&!myletteres[x+1][y+1].equals("0")){//right, word=word+""+myletteres[x+1][y+1]; check(word); reverse(word); myletteres[x+1][y+1]="0"; system.out.print("5"); getpaths(n,p, x +1, y +1,word, myletteres); } if(x-1>0&&y-1>0&&!myletteres[x-1][y-1].equals("0")){//down, left word=word+""+myletteres[x-1][y-1]; check(word); reverse(word); myletteres[x-1][y-1]="0"; system.out.print("6"); getpaths(n,p, x-1 , y -1,word, myletteres); } if(x-1>0&&y+1<myletteres.length&&!myletteres[x-1][y+1].equals("0")){//down, right word=word+""+myletteres[x-1][y+1]; check(word); reverse(word); myletteres[x-1][y+1]="0"; system.out.print("7"); getpaths(n,p, x+1, y-1, word,myletteres); } if(x+1<myletteres.length&&y-1>0&&!myletteres[x+1][y-1].equals("0")){//up, left word=word+""+myletteres[x+1][y-1]; check(word); reverse(word); myletteres[x+1][y-1]="0"; system.out.print("8"); getpaths(n, p,x-1 , y +1, word,myletteres); } } }

you write 0's myletteres maintain recursion looping on itself. 1 time recursive phone call has returned, need restore original letter in position. otherwise search can @ each position once, on branches tries.

(also, simplify code lot looping through list of (x, y) offsets rather having separate if statement each one)

edit:

int[][] offsets = { {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1} }; for(int[] off : offsets) { nx = x + off[0]; ny = y + off[1]; if(nx < 0 || ny < 0 || nx >= myletteres.length || ny >= myletteres[nx].length) { continue; } string letter = myletteres[nx][ny]; if(letter.equals("0")) { continue; } myletteres[nx][ny] = "0"; check(word + letter); reverse(word + letter); getpaths(n,p, nx, ny, word + letter, myletteres); myletteres[nx][ny] = letter; }

java array-algorithms

asp.net - Integrate SVN with Visual Studio 2003 -



asp.net - Integrate SVN with Visual Studio 2003 -

i trying find free tool not visualsvn(i know visualsvn integrates visual studio 2003/2005/2008/2010....) integrate sub version/tortoisesvn visual studio 2003. there tool integrates visual studio 2005/2008/2010 svn, given in hyperlink here -> http://garrys-brain.blogspot.ca/2007/07/tortoisesvn-and-visual-studio.html not integrate visual studio 2003.

agent svn ms-scci subversion plug-in should work vs 2003.

asp.net visual-studio svn visualsvn

Local variables, "dead code" and 2D arrays problems in Java -



Local variables, "dead code" and 2D arrays problems in Java -

i'm having few problems while developing next code in java:

setpos(x, y); (int = 0; x < size; i++) { (int j = 0; y < size; j++) { if (board[x][y] == 'k') { system.out.println("you've found key! congrats!"); homecoming true; }

eclipse notice me i , j, local variables, they're not used : the value of local variable not used . if alter i , write x instead, tells me i'm repeating variable.

j++ tagged dead code ?

also, have search concrete type of element on diagonal of bidimensional array, i've been trying 2 loops, above, no result yet.

hope can help me, in advance!

eclipse notice me i , j, local variables, they're not used

that's because you're not using them. you've assigned them values, , you've later incremented (added to) values, you've never used them anything.

j++ tagged "dead code" (?)

for same reason, code increments value of j, j never used, code nothing. "dead code" refers code has no purpose or never run.

your loops don't create lot of sense. instance:

for (int = 0; x < size; i++) {

normally for loop, command variable (i in case) should appear in all three of parts of for statement (the initializer, test, , increment), this:

for (int = 0; < size; i++) { // alter here -^

but you're not doing that, you're using i in initializer , increment, never in test (x < size). same true of loop j.

similarly, unless there's changing value of x, y, and/or size, loops either never run (because x or y >= size), run once (because happens board[x][u] == 'k'), or they'll run forever (because x or y < size , since nil changes that, maintain looping...).

java arrays local

mono - Portable Class Library in Monodevelop:incompatible target framework -



mono - Portable Class Library in Monodevelop:incompatible target framework -

i error when trying compile portable class library mono project.

c:\program files (x86)\mono-2.10.9\lib\mono\xbuild\microsoft\portable\v4.0\microsoft.portable.csharp.targets: project file not imported, beingness imported portabletest.csproj: imported project: "c:\program files (x86)\mono-2.10.9\lib\mono\xbuild\microsoft\portable\v4.0\microsoft.portable.csharp.targets" not exist. (portabletest)

i utilize modified 3.1.1 version of monodevelop supporting portable class library , think working before reinstall mono. suppose folder has been deleted.

is there easy way able compile portable library in monodevelop again?

thanks in advance help.

try targeting scheme (microsoft) .net framework instead of mono .net framework.

mono monodevelop

c# - Deserialization with options -



c# - Deserialization with options -

i achieving serialization of collection file. results how expect

<persons> <person> <identity>1234</identity> <name>asd</name> </person> <person> <identity>12345</identity> <name>asdd</name> </person> </persons>

now, don't want deserialize whole collection want deserialize object file specific options. example,

object getpersonwithidentity(int identity ) { // here } object asd = getpersonwithidentity(1234); // expected person identity "1234" , name "asd"

is reasonable deserialize whole collection , find specific object , homecoming it, or there other solution this?

xml not seekable @ to the lowest degree have read forwards till find first match. framework not back upwards automatically have manually using xmlreader laborious.

if file little and/or performance not issue, deserialize , done it.

if dataset big i'd consider moving more scalable format embedded sql database. sql databases have capability inherently.

c# deserialization