ps -ef | grep httpd | wc -lnetstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'| #!/bin/bash | |
| bundle check || bundle install --jobs 4 --retry 5 | |
| pids=( server.pid realtime_updater.pid ) | |
| for file in "${pids[@]}" | |
| do | |
| path="tmp/pids/$file" | |
| if [ -f $path ]; then | |
| rm $path | |
| fi |
| # lib/tasks/db.rake | |
| namespace :db do | |
| desc "Dumps the database to db/APP_NAME.dump" | |
| task :dump => :environment do | |
| cmd = nil | |
| with_config do |app, host, db, user| | |
| cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
| end | |
| puts cmd |
| # 20131214 | |
| # switch to the relevant keg directory | |
| cd /usr/local/Library/Taps/homebrew-science | |
| brew versions opencv | |
| # look for the version you want, eg: | |
| # 2.4.5 git checkout ae74fe9 opencv.rb | |
| # checkout the version you want | |
| git checkout ae74fe9 opencv.rb |
| from urllib2 import urlopen | |
| code = urlopen("http://example.com/").code | |
| if (code / 100 >= 4): | |
| print "Nothing there." | |
| # via http://stackoverflow.com/questions/1966086/how-can-i-determine-if-anything-at-the-given-url-does-exist |
| #!/bin/bash | |
| # | |
| # steps taken verbatim from: | |
| # http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html#install_docker | |
| # | |
| sudo yum update -y | |
| sudo yum install -y docker | |
| sudo service docker start | |
| sudo usermod -a -G docker ec2-user | |
| # log out and log in to pickup the added group |
Created from the plain text reference card on orgmode.org Download this file, and open it in Emacs org-mode!
| The basic idea here is to substantiate the claims made by this square post: | |
| http://corner.squareup.com/2011/06/postgresql-data-is-important.html | |
| In PostgreSQL, and MySQL (MyISAM and InnoDB) I create millions of rows and then add | |
| and remove columns and add and remove indexes. For columns without defaults this is | |
| basically free in PostgreSQL and O(n) in MySQL. For adding indexes its at best O(n) | |
| everywhere, but with PostgreSQL it claims not to do any locking that would otherwise | |
| prevent table interaction. | |
| Also, PostgreSQL has _awsome_ documentation (it has real examples!). I always get |