Posts

python - local variable - run time error with local -

x=5 def printx() print x x=10 running gives unboundlocal error but when function print x no error.. simply assigning value x in function making local variable, therefore shadowing global x specified on previous line. , on line you're trying print it, local version of x hasn't been initialized yet. curious how doing on later line influencing lines come before it, that's how works. you don't need special declaration read global variable, therefore works without assignment. however, if you'd rather assign global x instead of making new, local x , you'll have specify global x before assigning it.

MIPS assembly to determine whether hardware I/O interrupt has occurred? -

in mips32 exception handler, want determine whether exception caused i/o interrupt. cause register bits 2-6 inclusive has checked. what's mips assembly code determine this? you have mask out each bit check interrupt came from. exception handler procedure shown here: exchandler http://i47.tinypic.com/5yt47c.png can see manual hardware says interrupt came , theres error codes u can load register , compare epie register see if exception trap or interrupt, remember reset epie (error status register) before return error , enable interrupt bits in processors control register allow hardware make interrupts. this scheme used when coding exception handler nios ii, procedure should similar mips32. mips assembly language , mips: interrupts , exceptions page 22

Implementing conditional fluent mapping according to db -

i'm working 2 different db's in app, big(oracle) 1 online mode , small(sqlce) 1 offline mode. the problem mappings, id generation strategy not same, need custom implementation on sqlce(something sequences negative direction). how can achieve ability, without mapping contain if's instead of manually setting it, can define convention? have 1 if, convention load @ session factory config time. or maybe none if convention can examine way dialect being used (though don't know if fluent nhibernate objects available conventions supports that).

database - REDIS: Numeric keys (1,2,3..) vs compressed keys (A9z3,A9z4..)? -

we having fun redis on nodejs server - great combo btw. question out of curiosity , should treated "in theory". is there performance difference between storing values on numeric keys (1,2,3,4...) on compressed keys (a9z3,a9z4,a9z5...). i'm thinking select speed in database 2 million keys. i hope question not damn stupid, best regards ;) if storing keys list or string, there should no performance difference, integers stored same way strings in memory. so, there no noticeable performance difference when selecting string or integer. memory wise, compressed keys have less overhead in memory "because small keys , values there lot of overhead." talking bytes here. (http://redis.io/topics/faq)

Why were old games programmed in assembly when higher level languages existed? -

i noticed if not nes / atari, etc games coded in assembly, @ time, c, cobol, , fortran existed think make easier code right? why did choose assembly on these available higher level languages? those games had 8-bit cpu chips , microscopic memories, like, 2kb. answer take on half ram. compiled code out of question. on 8-bit cpu's "large" memories, "64k" (whee!) compiled code difficult use; not routinely seen until 16-bit microprocessors appeared. also, potentially useful language c , had not yet taken on world. there few if c compilers 8-bit micros @ time. but c wouldn't have helped much. games had horribly cheap hacks in them pretty required timing-specific instruction loops ... e.g., sprite's y-coordinate might depend on when (in video scan) control register written. (shudder...) now there was nice interpreted-bytecode language around time or perhaps little bit later: ucsd pascal running on ucsd p-system. although i'm not big ...

sql server - Changes to a table-valued function called by a stored procedure are not recognized? -

i have stored procedure sp calls table-valued function tvf. modify tvf when subsequently executing sp, output sp same before modification. seems cached or compiled or something. if make dummy change sp, right output of sp. is there way, can overcome problem? in oracle possible re-compile stored procedures, haven't been able figure out how in sql server? any highly appreciated. you can use sp_recompile recompile stored procedure afaik, describe shouldn't happen. could post udf ? scenario can think of when udf returns same result, regardless of input parameters.

iphone objective-c custom font -

how can load , embed custom font in iphone app? font file types supported? (otf, ttf...) it possible supply fonts app , use them. take @ cgfontcreatewithdataprovider should provide functionality need. at least ttf supported, not sure otf.