Posts

Art of unix programming

from Software Quality Rule of Modularity: Write simple parts connected by clean interfaces. Rule of Clarity: Clarity is better than cleverness. Rule of Composition: Design programs to be connected with other programs. Rule of Separation: Separate policy from mechanism; separate interfaces from engines. Rule of Simplicity: Design for simplicity; add complexity only where you must. Rule of Parsimony: Write a big program only when it is clear by demonstration that nothing else will do. Rule of Transparency: Design for visibility to make inspection and debugging easier. Rule of Robustness: Robustness is the child of transparency and simplicity. Rule of Representation: Fold knowledge into data, so program logic can be stupid and robust. Rule of Least Surprise: In interface design, always do the least surprising thing. Rule of Silence: When a program has nothing surprising to say, it should say nothing. Rule of Repair: Repair what you can — but when you must fail, fail noisily and as soon a...

DaVinci's Best Ideas

Personally I like DaVinci's Idea to build a revolving bridge. Check his ideas out. DaVinci's Top 10 Best Ideas

Lucene Search Engine

This is fantastic, Lucene is a awsome project and now they will have Lucene4c

Path to Relationship Destruction

These are the most dangerous in a relationship that will ultimately destroy it. Contempt, Stonewalling, Defensiveness, Critisism Don't let them ruin your life

The Power of Profitable Thinking

The man onstage tells the folks with their eyes shut to think "bad thoughts" as their arms are pressed down by their partners. The arms go down easily. Then the man tells them to repeat the process, this time thinking positive thoughts. No arms go down, even though some of the people pushing down have gotten on their toes to get more leverage. "Thoughts radiate physically," the man says. "Change your thoughts and you change your actions, your results, your destiny. I'm here to help you think about what you think about and to help you manage your thoughts. I'm Jim Fannin. I coach champions." self-discipline, concentration, optimism, relaxation, and en- joyment http://www.fortune.com/fortune/smallbusiness/managing/articles/0,15114,1110596-1,00.html

BlueBalls everywhere - this is amazing

Image
Check out the original because it's animated and a thousand times cooler. This image is from http://blueballfixed.ytmnd.com/

Vim vi how to reload a file your editing

5.8. How do I reload/re-edit the current file? You can use the ":edit" command, without specifying a file name, to reload the current file. If you have made modifications to the file, you can use ":edit!" to force the reload of the current file (you will lose your modifications). For more information, read :help :edit :help :edit! :help 'confirm' from - http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#5.8

ActionScript casting objects

Here is the example supplied by Macromedia function bark(myAnimal:Animal) { var foo:Dog = Dog(myAnimal); foo.bark(); } var curAnimal:Animal = new Dog(); bark(curAnimal); // will work curAnimal = new Cat(); bark(curAnimal); // won't work import Dog; function bark(myAnimal:Animal) { var foo:Dog = Dog(myAnimal); if (foo) { foo.bark(); } }

ActionScript casting a string

If you do a string comparision that fails when by all indications that it should pass, you should do the following var String tmpvar = someFunction(); if(tmpvar == "equivalentvalue"){ trace("true"); } else { trace("false"); } OUTPUT is:false Instead Cast the return value to a String var String tmpvar = new String(someFunction()); if(tmpvar == "equivalentvalue"){ trace("true"); } else { trace("false"); } OUTPUT is:true var myArray:Array = new Array(); var someString:String = "asdf"; myArray[0] = someString; . . . var testVar:Object = myArray[0]; if (testVar instanceof String || typeof(testVar) == "string") { var typedVar:String = String(testVar); // do something with typedVar }

python shutdown hook method UPDATE

I think using atexit module - http://docs.python.org/lib/module-atexit.html is cleaner -- Lawrence - http://www.oluyede.org/blog "Anyone can freely use whatever he wants but the light at the end of the tunnel for most of his problems is Python" 5. Duncan Booth Nov 16, 3:48 am show options Newsgroups: comp.lang.python From: Duncan Booth - Find messages by this author Date: 16 Nov 2005 08:48:15 GMT Local: Wed, Nov 16 2005 3:48 am Subject: Re: Shutdown hook Lawrence Oluyede wrote: Correct, although this won't catch all cases where a program is exiting. For example, on Windows, if you use Ctrl+C to terminate a program the atexit function *is* called, but if you use Ctrl+Break the atexit function is not called unless you install a suitable signal handler: import signal def sigbreak(signum, frame): sys.exit("***break") signal.signal(signal.SIGBREAK, sigbreak) Even then there are still other ways to terminate a process which will not

Python Shutdown hook comp.lang.python

My comp.lang.python post..... Does any one know if python has the ability to run a shutdown hook. For example you set a method to run when the python process is shutting down, like it recieved a kill signal? Basically looking for an effect like the following java code. Runtime.getRuntime().addShutdownHook(new Thread(this)); Reply 2. Ben Finney Nov 15, 5:55 pm show options Newsgroups: comp.lang.python From: Ben Finney - Find messages by this author Date: Wed, 16 Nov 2005 09:55:17 +1100 (EST) Local: Tues, Nov 15 2005 5:55 pm Subject: Re: Shutdown hook Steve wrote: > Does any one know if python has the ability to run a shutdown hook. When the Python runtime system wants to exit, it raises a SystemExit exception. Catch that exception at the top level of your code, and do whatever you like. (It might be polite to actually exit at some point, of course. sys.exit(exitcode) will do so -- raising another SystemExit exception.) -- \ "I took it easy today. I just pretty muc...

Razr Phone just like a Razor

Image
I love my Razr V3 phone. I only care about 3 features on my phone - Signal, Battery Life and that it has a address book. This phone was rumored to have great Signal Strength and Battery Life and it's all true. I have had the phone for 3 months and wanted to inform the world. http://direct.motorola.com/ENS/web_producthome.asp?Country=USA&language=ENS&productid=29302

Off and Away LA , Las Vegas and beyond

Soon I am off to LA again and then to Las Vegas for Laurie's birthday, I can't wait, maybe we will even have dinner saterday at the stratosphere ;)

python how to add item to a dictionary

python how to add item to a dictionary Here is an example: mydictionary = {} mydictionary["new key"] = "new value" mydictionary[1] = "monday" mydictionary[(3,"wed")] = ["pick up billy","go to market","date with laurie"]

python how to access global variable from method / function

>>> v = 1 >>> global v >>> print v 1 >>> def i(): ... global v ... v = v + 1 ... print v http://www.python.org/doc/2.0.1/ref/global.html

python how to i++

Python doesn't have i++ you can do: i += 1 i++ in c/java returns it's value while i += 1 does not return a value it just increments

python switch case statement

Python doesn't have switch case statements. But I found code that will simulate a switch case statement result = { 'a': lambda x: x * 5, 'b': lambda x: x + 7, 'c': lambda x: x - 2 }[value](x) to catch an error if no key found try: {'option1': function1, 'option2': function2, 'option3': function3, 'option4': function4}[value]() except KeyError: # default action I would probably use switch = {'option1': function1, 'option2': function2, 'option3': function3, 'option4': function4} if value in switch: switch[value]() else: pass #default

How to yank (aka copy) 3 letters in Vi or Vim

How to yank (aka copy to the clipboard) 3 letters in Vi or Vim Example: yank 3 characters. 3yl Which is 3y(the letter L)l

Test if variable exists in python

Here is how to test if a variable exists try: x except NameError: # x doesn't exist, do something else: # x exists, do something else

Most affordable college towns

Most affordable college towns http://money.cnn.com/2005/11/02/real_estate/college_towns/index.htm http://www.ttu.edu/administration/enrmgt/emplan/ch1abc.php