Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
function State() { | |
this.actions = {}; | |
this.subscriptions = []; | |
this.history = []; | |
} | |
State.prototype.subscribe = function(element, action, callback) { | |
this.subscriptions[action] = this.subscriptions[action] || []; | |
this.subscriptions[action].push(function(data) { | |
callback.apply(element, data); |
# Either use node version specified in package.json | |
use node package.json | |
# Or a specific version | |
use node 5.0.0 | |
# Rest of direnv setup.. | |
export FOO=BAR |
#!/bin/sh | |
echo -n '{' | |
# memory as "mem": { "current": 800, "total": 1024, "load", 82 } where amount is in MB and load in % | |
free -m | awk 'NR==2{printf "\"mem\": { \"current\":%d, \"total\":%d, \"load\": %.2f }", $3,$2,$3*100/$2 }' | |
echo -n ',' | |
# diska as "disk": { "current": 6, "total": 40, "used": 19 } where amount is in GB and used in % | |
df -h | awk '$NF=="/"{printf "\"disk\": { \"current\":%d, \"total\":%d, \"used\": %d }", $3,$2,$5}' |
# Client id from Google Developer console | |
# Client Secret from Google Developer console | |
# Scope this is a space seprated list of the scopes of access you are requesting. | |
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes. | |
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=[Scopes]&response_type=code | |
# Exchange Authorization code for an access token and a refresh token. | |
curl \ |
1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020 | |
2) add to postgresql.conf: | |
shared_preload_libraries = 'pg_stat_statements' # (change requires restart) | |
136 pg_stat_statements.max = 1000 | |
137 pg_stat_statements.track = all | |
3) restart postgres | |
4) check it out in psql |
namespace :db do | |
desc "Migrates the database to the target version, or to the lastest version if no target is given" | |
task :migrate, [:target, :current] => :environment do |t, args| | |
opts = {} | |
opts[:target] = args[:target].to_i if args[:target] | |
opts[:current] = args[:current].to_i if args[:current] | |
Sequel::Migrator.run(DB, "db/migrate", opts) | |
Rake::Task["db:dump"].invoke if Rails.env.development? | |
end |
#!/bin/bash | |
# Based on the "Shell image viewer" by Andreas Schönfelder: | |
# https://bbs.archlinux.org/viewtopic.php?id=106089 | |
# Defaults. | |
doublexres="yes" | |
colors="$(tput colors)" | |
size="$(($(tput cols) - 2))x$(($(tput lines) - 2))" |
app = node[:rails][:app] | |
rails_base app[:name] do | |
ruby_ver app[:ruby_ver] | |
gemset app[:gemset] | |
end | |
%w{config log pids cached-copy bundle system}.each do |dir| | |
directory "#{app[:app_root]}/shared/#{dir}" do | |
owner app[:deploy_user] |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |