Archive for the ‘Programming’ Category
Tuesday, May 20th, 2008
Posted in Programming, Python | 8 Comments »
This article shows how to put a few lines of python code into your python script so you can tell how long the script has been running, or how long a certain part of the task took to run.
The Quick Answer: For the most accurrate time elapsed, use the time module and make 2 time.time() objects. The difference between these objects is the time elapsed. Do not use time.clock().
Read the rest of this article »
Thursday, May 1st, 2008
Posted in Fixes/Hacks, Programming, Python, Web, WordPress | 1 Comment »
Problem: Recently I was writing an article where I posted some python code. Using WordPress, I was switching between HTML/Code view and “Visual” view. Every time that I switched, the WordPress editor would change some of my code, namely the quotes. I ended up with something that looked like this:

Solution: Not exactly sure, but it seems to have stopped.
Read the rest of this article »
Thursday, May 1st, 2008
Posted in HTML/XHTML, Web, WordPress | 13 Comments »
Problem: In WordPress 2.5.1, I was trying to make a multiple-page article using the <!–nextpage–> quicktag, but it wasn’t working.
Quick Answer: When you want a page break, switch to HTML/Code view and then type <!–nextpage–>.
Read the rest of this article »
Thursday, May 1st, 2008
Posted in Programming, Python | No Comments »
This articles covers how I was able to get the managed attributes from an object, and then get the public and managed attributes from an object. There used to be an __members__ method, but that has been depreciated according to http://docs.python.org/lib/specialattrs.html. Really, I hope there is a better way to do this, but I can’t seem to find it (let me know).
Quick Answer (for managed attributes only):
class dumb:
def dummy():
pass
def attributes(o):
print "object:", o
print "Initialized attribute values:"
step=0
for var in dir(o):
vartype=-1
exec("vartype = type(o."+str(var)+")")
if not(var in o.__dict__) and not(vartype == type( dumb.dummy)) and not("__" == var[:2]):
value = -30
exec("value = o."+str(dir(o)[step]))
print '%40s' % var +": "+ str(value)
step += 1
Read the rest of this article »
Wednesday, March 5th, 2008
Posted in Apache | 3 Comments »
When changing websites, I was trying to use Apache’s RedirectMatch to send all documents from one domain to another domain. I used code that I found on other websites, but I found that it didn’t do what I wanted.
What I wanted was for a user to put in http://www.olddomain.com/a_file.html and be redirected to http://newdomain.com/a_file.html. I wanted it to do that for each file, and I didn’t want to specify a redirect for each file. I didn’t want to use mod_rewrite because I wanted to give the 301 redirect for Search Engine Optimization (SEO) reasons.
Quick Answer: use RedirectMatch permanent ^(.*)$ http://www.newdomain.com$1 in a .htaccess file in your old domain.
Read the rest of this article »
Monday, February 18th, 2008
Posted in Apple/Mac, WordPress | 22 Comments »
I recently upgraded to a 1 Terabyte external hard drive and wanted to move my Time Machine backups to that drive (and start using this new drive for Time Machine). This is how I did it.
Quick Solution: Use Disk Utility to Restore your old drive to your new drive, then tell Time Machine that you want to use a different disk
Read the rest of this article »
Saturday, February 9th, 2008
Posted in Fixes/Hacks, WordPress | 1 Comment »
I recently made a WordPress blog for one of our clients. Everything was setup fine in a directory similar to www.thewebsite.com/blog/. Then I decided that I wanted the blog to have its own subdirectory, www.blog.thewebsite.com.
The quick answer: export your data and reinstall WordPress.
Read the rest of this article »