Posts

arrays - Combinatorial game in java -

i've got assignment computer science class. i've been thinking answer more 2 weeks without success decided give try in here. game consists of 4 cia agents using 4 adjacent telephone booths. arrive @ set of booths 1 @ time, following rules: 1 - agent chooses booth has 2 neighbouring booths unoccupied (this includes booths @ edges of set); 2 - if condition above isn't met, agent chooses booth has 1 neighbouring booth unoccupied; and 3 - if both conditions fail, agent chooses booth. there 8 different ways of occupying booths given 4 agents , 4 booths, according rules. example: agent #1 occupies first booth (the left edge one), agent #2 occupies third booth (from left right), agent #3 occupies fourth booth , agent #4 occupies second booth. we asked write code counts number of ways 19 agents occupy 19 booths, according these rules. my natural choice problem creating array of boolean, in false represents vacant booth , true represents occupied booth: public...

Test Android PackageManager.getInstaller() -

maybe missing very obvious here: i wanted test packagemanager.getinstallerpackagename() . when test app through eclipse, or standalone apk, above method returns null expected. users install through google play or amazon appstore , returned value not null . my question how test before putting app production? ( eg. possible: upload draft in android developer console, , without moving production, somehow access through google play, maybe using device setup same account developer console account; , install , test on test device?) updated answer: if want able test actual install google play use alpha , beta programs. see here description of program. original answer: if want test handling of case, can use buildconfig.debug flag give dummy value when in debug mode. string installer; if (buildconfig.debug) { installer = "com.android.vending"; } else { installer = pm.getinstallerpackagenamge(mypackage); }

entity framework - ASP.NET MVC domain Models and Identity Models in same context - UserLogin has no key -

Image
i want application models in same dbcontext has identity model. inserted classes identitydbcontext this: public partial class applicationdbcontext : identitydbcontext<applicationuser> { public applicationdbcontext() : base("humantask") { } public virtual dbset<wfinstance> wfinstance { get; set; } public virtual dbset<wfservice> wfservice { get; set; } public virtual dbset<wftask> wftask { get; set; } public virtual dbset<wfworkflow> wfworkflow { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.entity<wftask>() .property(e => e.wftaskid) .isunicode(false); modelbuilder.entity<wfworkflow>() .property(e => e.name) .isunicode(false); } } } now, when try create new controller 1 of classes classes using...

Error with Git SVN clone -

i migrating several projects svn git, , using git's 'svn clone' feature. trying run following: git svn clone --stdlayout --authors-file=authors.txt <path-to-svn-project> <local-git-repo-name> i have been able clone several smaller projects, when try , clone larger project gives following errors: couldn't truncate file @ /usr/lib/perl5/site_perl/git.pm line 1322. error removing .git/git_04wyzv @ /usr/lib/perl5/5.8.8/file/temp.pm line 890. i thought find quick fix in google search, instead looks unusual error. have clue how can past this? my versions pretty recent, , i'm trying run on windows 8.1: git: using version 1.9.4.msysgit.0 subversion: using version 1.8.9 git-svn: using version 1.9.4.msysgit.0 run git --version , ensure on version 2.4+. can't find link right now, in 2.2.x , before, there bug in git svn code cause fail @ various points through large repository migrations. ended working git developers on irc , using pat...

javascript - Why does document.getElementById return an object that has a property called 'value'? -

i'm trying learn javascript , dom. based on examples on internet have created html: <input type="text" id="amount3"> then later in javascript code have line. document.getelementbyid("amount3").value= x; the code works well. i'm able change what's shown inside text input. i'm trying understand underlying code , how works. looked dom reference in https://developer.mozilla.org/en-us/docs/web/api/document.getelementbyid . i can see method should return object element . however, element not contain property called value. notice there sub-object called htmlelement has sub-object htmlinputelement. , object contains property called value. is code above somehow typecast child object? why value property work such? htmlinputelement inherits htmlelement which, in turn, inherits element . if object inherits object, have properties of object. this means expects deal element can given htmlinputelement instead (since ...

java - How can I use Assert in Unit Testing? -

package htmlunit; import org.junit.assert; import com.gargoylesoftware.htmlunit.webclient; import com.gargoylesoftware.htmlunit.html.htmlpage; public class test { public static void main(string[] args) throws exception { final webclient webclient = new webclient(); final htmlpage page = webclient.getpage("http://htmlunit.sourceforge.net"); assert.assertequals("htmlunit - welcome htmlunit", page.gettitletext()); final string pageasxml = page.asxml(); assert.asserttrue(pageasxml.contains("<body class=\"composite\">")); final string pageastext = page.astext(); assert.asserttrue(pageastext.contains("support http , https protocols")); if(assert.asserttrue(pageastext.contains("support http , https protocols"))){ system.out.println("true"); } else { system.out.println("false"); } sy...

python - scrapy how to import the settings to override it -

this code class test(spider): self.settings.overrides['jobdir']= "seen" i got: file "c:\python27\lib\site-packages\scrapy\spider.py", line 46, in settings return self.crawler.settings file "c:\python27\lib\site-packages\scrapy\spider.py", line 41, in crawler assert hasattr(self, '_crawler'), "spider not bounded crawler" assertionerror: spider not bounded crawler i extending spider , not using crawler because don't have links nor rules follow i guessing problem because didn't import settings , need please in order change settings in spider can: class testspider(spider): def set_crawler(self, crawler): super(testspider, self).set_crawler(crawler) crawler.settings.set('jobdir','seen') # rest of spider code