Topics
- bash (4)
- css (3)
- data arch. (14)
- html (6)
- javascript (8)
- mysql (17)
- oracle (10)
- php (7)
- python (13)
- shell tips (17)
- software arch. (10)
- ssh (3)
-
Recent Posts
- scripting Photoshop for stop motion
- locking and concurrency in python, part 2
- locking and concurrency in python, part 1
- zip archive in python
- chaining ssh tunnels
- timeout command in python
- python slice and sql every Nth row
- sqlplus, utility scripts
- screen and screenrc
- nvl, ifnull, nullif, isnull, coalesce
Archives
Monthly Archives: June 2011
tail -F
I would like to follow an error log as errors are written. The GNU tail command support a --follow option that outputs data as a file grows. There's also a --retry option that will keep trying to access a file … Continue reading
Posted in shell tips
Leave a comment
nohup &
I would like to run a script in the background and to keep running even after I log out. To run a command or script in the background use an ampersand, e.g., # ./long-running-script.sh & This is equivalent to suspending … Continue reading
Posted in bash, shell tips
Leave a comment
php echo and print
Is echo really, even negligibly, faster than print in php? Conventional wisdom of the Internet says "yes", because print performs one extra op (it returns a value). I've seen performance charts with 20% or more difference in performance. I tested … Continue reading
Posted in php
Leave a comment
get_magic_quotes_gpc(), or not
I would like to sanitize user-supplied HTTP request variables before sending them to a database. There is a deprecated PHP setting called magic_quotes_gpc that automatically escapes GET, POST, and COOKIE (GPC) operators. Please understand that magic_quotes_gpc is highly discouraged. <?php … Continue reading
Posted in php
Leave a comment
last_insert_id()
I would like to retrieve the id of a row I just inserted. In Oracle this problem is handled with the use of sequences, SQL> SELECT uid_seq.NEXTVAL INTO user_id FROM DUAL; SQL> INSERT INTO users (id, username) VALUES (user_id, 'joebob'); … Continue reading
Posted in data arch., mysql, php
Leave a comment
php DB adapter, with magic
I would like to encapsulate the handling of database connections, and maintain a loose coupling between database connections and application and data-access code. I'll not focus on connection pooling since that can be handled at the driver level independent of … Continue reading
Posted in mysql, php
Leave a comment
mysql \c
The mysql command line interface provides several very useful shortcuts. For example, the 'tee' command will append everything to a specified outfile: mysql> \T logfile.txt Logging to file 'logfile.txt' The 'clear' command saves from accidentally hitting Ctrl-C and disconnecting from … Continue reading
Posted in mysql
Leave a comment
php Namespaces and Class loading
I want to autoload php classes and functions. Ideally, I want a lazy loader (include class files only when they are needed, never including more files than necessary). I'd also like namespace protection (if running PHP 5.3 or later). And … Continue reading
Posted in php
Leave a comment