Posts

PyDev's inteactive shell with Django problem -

i'm going through django tutorial , using pydev eclipse plugin development. for interactive testing use "interactive shell django" accessed right click on pydev project -> django -> shell django environment. and here problem encountered ("lemonanas" project name, "polls" app name): >>from lemonanas.polls.models import poll, choice >>poll.objects.filter(id=1) traceback (most recent call last): file "<console>", line 1, in <module> file "f:\python27\lib\site-packages\django\db\models\manager.py", line 141, in filter return self.get_query_set().filter(*args, **kwargs) file "f:\python27\lib\site-packages\django\db\models\query.py", line 561, in filter return self._filter_or_exclude(false, *args, **kwargs) file "f:\python27\lib\site-packages\django\db\models\query.py", line 579, in _filter_or_exclude clone.query.add_q(q(*args, **kwargs)) file "f:\pytho...

c# - Why does casting the same two numbers to Object make them not equal? -

i have following code snippet getting wrong output. class program { static void main(string[] args) { var = 10000; var j = 10000; console.writeline((object) == (object) j); } } i expecting true getting false you boxing numbers (via object cast) creates new instance each variable. == operator objects based on object identity (also known reference equality) , seeing false (since instances not same) to correctly compare these objects use object.equals(i, j) or i.equals(j) . work because actual runtime instance of object int32 equals() method has correct equality semantics integers.

Rails 3 Devise problem -

i've got strange problem project. have rails 3 , devise , running, i've added custom route: match '/users', :to => 'users#index', :as => "all_users", :via => "get" my rake routes returns this: marat@rails:~/projects/test$ rake routes | grep users new_user_session /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"} user_session post /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"} destroy_user_session /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"} user_password post /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"} new_user_password /users/password/new(.:format) ...

internals - Where does Git store the SHA1 of the commit for a submodule? -

i know when add submodule git repository tracks particular commit of submodule referenced sha1. i'm trying find sha1 value stored. the .gitmodules , .git/config files show paths submodule, not sha1 of commit. the git-submodule(1) reference speaks of gitlink entry , gitmodules(5) reference doesn't either. it stored in git's object database directly. tree object directory submodule lives have entry submodule's commit (this so-called "gitlink"). try doing git ls-tree master <path-to-directory-containing-submodule> (or git ls-tree master if submodule lives in top-level directory).

java - Another question, this time regarding breaking a string down for validity -

thanks bunch tip on static of folks answered! feeling little less frustrated now. i not going ask questions step step through whole assignment, want make sure way go 1 of next tasks. have written following, compiles fine (the purpose check string make sure numeric, , user may have entered isbn number or without dashes): private string validateisbn(string booknum) { string[] book; int j=0; ( int i=0;i<booknum.length();i++) if (character.isdigit(booknum.charat[i])) booknum.charat[i]=book[j];j++; i haven't written next part, has allow x last digit in string (which apparently how isbn numbers work). assume if above correct (or close), need check ninth character digit or x, writing like: if book[9] isdigit() || if book[9] == "x" || if book[9] == "x"; is right (isbn numbers 10 numbers or 9 numbers , x @ end)? the last digit of isbn-10 check digit. since method supposed check if entered isbn c...

c# - Add multiple controls to panel in webforms -

i able add multiple label controls panel , display them on onlick event. code have want first time, label simple replaced new label on second onlick event , on. here have far: private void createtasklabel(guid goalid, string goal) { label tasklabel = new label(); tasklabel.id = goalid.tostring(); tasklabel.text = goal.tostring(); taskpanel.controls.add(tasklabel); } so, instance, creates new label uniqueid (handled elsewhere) , places within panel , displays it. when onlick fires again, same label replaced instead of new 1 appearing below it. dynamically created controls not persisted after postback. need keep track of how many controls have generated , regenerate of them each time work how want. basic implementation: list<string> labeidlist = new list<string>(); override saveviewstate(..) { if (labelidlist.count>0) { viewstate["labeldilist"]=labelidlist; } base.saveviewstate(..) } override loadvie...

java - Is there a simple way to match a field using Hamcrest? -

i want test whether specific field of object matches value specify. in case, it's bucket name inside s3bucket object. far can tell, need write custom matcher this: mockery.checking(new expectations() {{ one(query.s3).getobject(with( new basematcher<s3bucket>() { @override public boolean matches(object item) { if (item instanceof s3bucket) { return ((s3bucket)item).getname().equals("bucket"); } else { return false; } } @override public void describeto(description description) { description.appendtext("bucket name isn't \"bucket\""); } }), with(equal("key"))); ... }}); it nice if there simpler way this, like: mockery.checking(new expectations() {{ one(query.s3).getobject( with(equal(methodof(s3bucket.class).getname(), "bucket")), with(equal("key"))); ... }}); ...