There is a nice bit of Javascript code here: http://alexgorbatchev.com/wiki/SyntaxHighlighter This package allows uses css to display pretty source code on a webpage. It supports a lot of languages, but is missing a lot of common ones too.
If you are using Blogger (or somewhere else where you can't upload files). You can hot link the the scripts and css at http://alexgorbatchev.com/pub/sh/ which is up 99% of the time.
Saturday, March 28, 2009
kdbom.tryDBconnect
I put a factory function for kdbom.db instances in kdbom.kdbom (previously I had it in viroinfo).
It automatically checks localhost,3306 for the database after checking at the specified sites.... good if clients are not on the same private subnet the the server is on.
It automatically checks localhost,3306 for the database after checking at the specified sites.... good if clients are not on the same private subnet the the server is on.
def tryDBconnect(db=None,serversPorts=None,user=None,
reuseDB=None,getTables=True,tryLocalPort=3306,
fatal=False,verboseFailure=False):
"""Try to connect to a database and return the db instance. One or more server/port
combinations can be tried. If no connection is successful a Warning is issued,
unless fatal is true in which case KdbomDatabaseError is raised.
db = databse name (string)
server = servers hostname (string)
port = server's listening port (int)
After all given (server,port) combinations are tried one or more localhost
connections over port tryLocalPort will be attempted unless that is set
to None. tryLocalPort can be an integre type or a sequence of integers.
serversPorts should be a list of (server,port) tuples, or a single 2-tuple.
serversPorts can also be a single string to make replacement of db()
calls more straight forward (defaultPort is then used for the port).
Ir reuseDB is specified, this is just a call to the db class constructor.
"""
connected = False
database = None
if reuseDB != None:
database = kdbom.db(db=db,reuseDBconnection=reuseDB,getTables=getTables)
connected = True
else:
if type (serversPorts) in StringTypes:
serversPorts = [(serversPorts,defaultPort)]
if type(serversPorts) != ListType:
if type(serversPorts) == NoneType:
serversPorts = []
elif (len(serversPorts) == 2
and type(serversPorts[0]) in StringTypes
and type(serversPorts[1]) in (IntType,LongType)):
serversPorts = [serversPorts]
elif type(serversPorts) == TupleType:
serversPorts = [serversPorts]
else:
raise ArgumentError, "serversPorts should be a list of tuples not: %s" % serversPorts
try:
for p in tryLocalPort:
serversPorts.append(('localhost',p))
except TypeError:
serversPorts.append(('localhost',tryLocalPort))
for host,port in serversPorts:
try:
print host,port
database = kdbom.db(db=db,host=host,port=port,user=user,getTables=getTables)
connected = True
except:
pass
if not connected:
if fatal:
if not verboseFailure:
raise KdbomDatabaseError, "%s DB not loaded" % db
else:
warnings.warn("%s DB not loaded" % db)
return database
Thursday, March 26, 2009
Google + Python + LLVM
There has been talk of targeting python to LLVM before (PyPy). Google is jumping in with the Unladen Swallow Project, hoping for performance multiples in the 3-5x range.
Update:
More from PyPy's author.
Update:
More from PyPy's author.
Weather Station Near Dork Haus
I wonder what the weather at my house is like right now?
Weather Station History : KUTSALTL17
Or at work it's like this -
Weather Station History : KUTSALTL17
Or at work it's like this -
Tuesday, March 24, 2009
GPL Harmful (the heresy of ESR)
Open source software and hacker God Eric S. Raymond (ESR) told the Long Island Linux Club (LILUG) that the GPL does more harm than good. Needless to say the GNU herd didn't want to hear it.
dotCOMmie's Blog
dotCOMmie's Blog
Labels:
free as in herpes,
gnu,
gpl,
linux
Monday, March 23, 2009
Old Snooping Methods are New Again
I guess this has been in the works for a while, but now it's out in the open. Remember: just because you are paranoid, that doesn't mean they aren't after you.
Researchers find ways to sniff keystrokes from thin air | ITworld
Researchers find ways to sniff keystrokes from thin air | ITworld
Sunday, March 22, 2009
Thursday, March 19, 2009
What people really think about God
It is interesting to see the hate people have for people who have the audacity to believe something they do not. Sunnite <=> Shi'ite; Christian <=> Pastafarian.
Here is a record of how people feel about Pastafarians: Hate Mail (and concerned criticism) archive - Church of the Flying Spaghetti Monster
Here is a record of how people feel about Pastafarians: Hate Mail (and concerned criticism) archive - Church of the Flying Spaghetti Monster
Censorwatch: $11,000-A-Day Fine For Linking To A Blacklisted Site, Wikileaks Blacklisted - Gizmodo Australia
Censorwatch: $11,000-A-Day Fine For Linking To A Blacklisted Site, Wikileaks Blacklisted - Gizmodo Australia: "Censorwatch: $11,000-A-Day Fine For Linking To A Blacklisted Site, Wikileaks Blacklisted"
wikileaks
wikileaks
White House Declares Copyright Treaty State Secret | WebProNews
Tuesday, March 17, 2009
PEP 289 -- Generator Expressions
Everyone that learned python from me, probably doesn't know these exist. So take note:
kewler than list comprehension: generator expressions (!)
PEP 289 -- Generator Expressions
kewler than list comprehension: generator expressions (!)
PEP 289 -- Generator Expressions
Compare command output on 2 hosts
This works nicely on my 2 compute nodes.
Q: What Software Is Installed On Only One Node?
A:
#!/bin/tcsh
set tmp1 = `mktemp -t computeDiff.csh.c1.XXXXXX`
set tmp2 = `mktemp -t computeDiff.csh.c2.XXXXXX`
onintr exit
foreach cmd ( $argv )
ssh kf-compute1 "$cmd" >! $tmp1
ssh kf-compute2 "$cmd" >! $tmp2
echo "########### $cmd ################"
echo "### diff compute1 compute2"
diff $tmp1 $tmp2
end
exit:
rm $tmp1* >&/dev/null
rm $tmp2* >&/dev/null
# end script
Q: What Software Is Installed On Only One Node?
A:
% computeDiff.csh pkg_info
########### pkg_info ################
### diff compute1 compute2
22a23
> compat6x-amd64-6.4.604000.200810 A convenience package to install the compat6x libraries
24d24
< cvsup-without-gui-16.1h_4 File distribution system optimized for CVS (non-GUI version
34d33
< fastest_cvsup-0.2.9_5 Finds fastest CVSup server
62a62
> iperf-2.0.4 A tool to measure maximum TCP and UDP bandwidth
150d149
< sge-6.2.b Sun Grid Engine, a batch queueing system
Thursday, March 12, 2009
finaly factored out PickleableObject
uses my nonclobbering file opener: safeOFW
I've been meaning to move this from a class that Peter wrote it in to originally at my request. It's quite nice to have it globally available.
class PickleableObject(object):
"""Generic pickleable class
"""
def save(self,filename,clobber=False):
"""given an object, e.g. a taxon dictionary,
pickle it into the specified filename
Set clobber = True to allow overwriting of the
output file"""
import cPickle
f = safeOFW(filename,clobber=clobber,append=False)
cPickle.dump(self,f)
f.close()
@classmethod
def restore(cls,filename):
"""given a filename, return an object containing the
pickled data in that file"""
import cPickle
f = open(filename,'rb')
obj = cPickle.load(f)
return obj
I've been meaning to move this from a class that Peter wrote it in to originally at my request. It's quite nice to have it globally available.
Wednesday, March 11, 2009
Words that nerds use that I hate
distro - "distribution" please
tarball - "tar file" (the fact that it is gzipped, will be obvious to any that care)
architected - the word you are looking for is "designed" n.b. actual architects do not use this word to describe their activities.
sequel - Do you mean "S"-"Q"-"L"? (./ers you know the 'sequel' form is M$ spawn, right?)
tarball - "tar file" (the fact that it is gzipped, will be obvious to any that care)
architected - the word you are looking for is "designed" n.b. actual architects do not use this word to describe their activities.
sequel - Do you mean "S"-"Q"-"L"? (./ers you know the 'sequel' form is M$ spawn, right?)
HealthMap | Global disease alert map
This should go on the lab web page HealthMap | Global disease alert map
Subscribe to:
Posts (Atom)