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
Category Archives: shell tips
scripting Photoshop for stop motion
I would like a simple and quick way to save a copy of an image in Photoshop, with an auto-incrementing filename. Ideally, a single button to capture a frame in a stop motion animation. In other words, I would like … Continue reading
Posted in html, javascript, shell tips
Comments Off
locking and concurrency in python, part 2
Previously, I created a "MultiLock" class for managing locks and lockgroups across a shared file system. Now I want to create a simple command-line utility that uses this functionality. To start, we can create a simple runone() function that leverages … Continue reading
Posted in python, shell tips, software arch.
Comments Off
zip archive in python
I would like to create zip archives within a python batch script. I would like to compress individual files or entire directories of files. You can use the built-in zipfile module, and create a ZipFile as you would a normal … Continue reading
Posted in python, shell tips
Comments Off
chaining ssh tunnels
Imagine you're working within a private home network and need to connect to an Oracle database within a corporate network accessible only through a bastion host hidden within the corporate network. Odd as that sounds, it's a typical network configuration, … Continue reading
Posted in bash, shell tips, ssh
Comments Off
timeout command in python
I would like to add a timeout to any shell command such that if it does not complete within a specified number of seconds the command will exit. This would be useful for a any long-running command where I'd like … Continue reading
Posted in python, shell tips
Comments Off
sqlplus, utility scripts
I would like to use sqlplus in development projects, and I would like it to be easy to use. First off, I want command-history and tab-completion. The easiest approach is to use rlwrap which uses the GNU readline library as … Continue reading
Posted in oracle, shell tips
Comments Off
screen and screenrc
I would like to use GNU screen as a window manager. By default screen seems like little more than a persistent shell (that you can resume even after logging out). By itself, this is incredibly useful if you wish to … Continue reading
Posted in bash, shell tips
Leave a comment
sqlplus pagesize and linesize
I would like sqlplus output to be more readable. Fortunately, you can adjust the pagesize and linesize variables on the fly, e.g., foo_owner@FOO> set pagesize 50000 foo_owner@FOO> set linesize 120 You can set pagesize to 0, which is very useful … Continue reading
Posted in oracle, shell tips
Leave a comment
sqlplus command prompt (sqlprompt)
I would like to change the sqlplus command-prompt to something more useful than SQL> You can modify the sqlprompt variable as follows, SQL> SQL> set sqlprompt "_USER'@'_CONNECT_IDENTIFIER> " FOO_OWNER@FOO> You can also use variables such as _PRIVILEGE and _DATE, although … Continue reading
Posted in oracle, shell tips
Leave a comment
reverse ssh tunnel
I would like ssh access to a protected host that is not directly accessible on the Internet but does have outbound access. This is a common scenario in corporate networks that often require a vpn for remote access; but in … Continue reading
Posted in shell tips, ssh
Leave a comment
ssh agent across multiple hosts
I would like secure single-sign-in across multiple hosts. An easy way to do this is with ssh-agent, however, ssh-agent is a bit limited. For example, the normal use of ssh-agent looks like this, $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-stSwW11394/agent.11394; export SSH_AUTH_SOCK; SSH_AGENT_PID=11395; export … Continue reading
Posted in shell tips, ssh
Leave a comment
python, unique files by content
I would like to retrieve a list of unique files by content rather than by filename. That is, if spam.txt and eggs.txt both contained the same contents I want only one of them to return. A very simple approach is … Continue reading
Posted in python, shell tips
Leave a comment
mysqldump, tips and tricks
I want to backup a mysql database. The easiest approach is using mysqldump with its default options, i.e., # mysqldump -u user -h host -ppass db > backup.sql This will dump the full DDL and DML needed to re-create the … Continue reading
Posted in mysql, shell tips
Leave a comment
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