These are a list of usages of shell commands I can't live without on UNIX-based systems.
Using Homebrew (yes, I am opinionated) you can install the following tools with the following packages:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" |
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
urlencode() { | |
# urlencode <string> | |
old_lc_collate=$LC_COLLATE | |
LC_COLLATE=C | |
local length="${#1}" | |
for (( i = 0; i < length; i++ )); do | |
local c="${1:$i:1}" | |
case $c in |
import os | |
from os import path | |
from werkzeug import secure_filename | |
from tobikko.core import * | |
from tobikko.patch import * | |
patch_all() | |
import urllib2 | |
from pyquery import PyQuery as pq | |
import urllib | |
from urlparse import urlparse |
# from https://libbits.wordpress.com/2011/04/09/get-total-rsync-progress-using-python/ | |
import subprocess | |
import re | |
import sys | |
print('Dry run:') | |
cmd = 'rsync -az --stats --dry-run ' + sys.argv[1] + ' ' + sys.argv[2] | |
proc = subprocess.Popen(cmd, | |
shell=True, |
#! /bin/bash | |
# | |
# # keepalive # | |
# | |
# Keeps your processes running - handy quick-restart for services. | |
# | |
# USAGE: | |
# | |
# Run a server with: | |
# |
# A two-line colored Bash prompt (PS1) with Git branch and a line decoration | |
# which adjusts automatically to the width of the terminal. | |
# Recognizes and shows Git, SVN and Fossil branch/revision. | |
# Screenshot: http://img194.imageshack.us/img194/2154/twolineprompt.png | |
# Michal Kottman, 2012 | |
RESET="\[\033[0m\]" | |
RED="\[\033[0;31m\]" | |
GREEN="\[\033[01;32m\]" | |
BLUE="\[\033[01;34m\]" |
# Ruby Thread Pool | |
# ================ | |
# A thread pool is useful when you wish to do some work in a thread, but do | |
# not know how much work you will be doing in advance. Spawning one thread | |
# for each task is potentially expensive, as threads are not free. | |
# | |
# In this case, it might be more beneficial to start a predefined set of | |
# threads and then hand off work to them as it becomes available. This is | |
# the pure essence of what a thread pool is: an array of threads, all just | |
# waiting to do some work for you! |
#! /usr/bin/env ruby | |
require "fileutils" | |
search_term = ARGV[0] | |
if search_term | |
time = Time.now | |
directory_path = File.dirname(__FILE__) + "/tweets/" + search_term + "_" + time.to_i.to_s | |
FileUtils.mkdir_p(directory_path) | |
directory = Dir.new(directory_path) | |
(1..15).each do |i| | |
`curl "http://search.twitter.com/search.json?q=#{search_term}&rpp=100&page=#{i}&include_entities=true&result_type=mixed" > #{directory.path}/#{i}.json` |