start new:
tmux
start new with session name:
tmux new -s myname
| require 'net/http' | |
| require 'xmlsimple' | |
| url = "http://www.user-agents.org/allagents.xml" | |
| xml_data = Net::HTTP.get_response(URI.parse(url)).body | |
| data = XmlSimple.xml_in(xml_data) | |
| agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")} | |
| agent_names = agents.collect {|agent| agent["String"].first} |
| t = 236 # seconds | |
| Time.at(t).utc.strftime("%H:%M:%S") | |
| => "00:03:56" | |
| # Reference | |
| # http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| de | |
| a | |
| o | |
| que | |
| e | |
| do | |
| da | |
| em | |
| um | |
| para |
| /* | |
| In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp | |
| server, but for some reason omit a client connecting to it. I added an | |
| example at the bottom. | |
| Save the following server in example.js: | |
| */ | |
| var net = require('net'); |
| Simple Ruby Server: | |
| # ruby -run -e httpd -- -p 5000 . | |
| Simple Python Server: | |
| # python -m SimpleHTTPServer |
| # Setup for use of Android SDK tools from command line | |
| # Set ANDROID_SDK_ROOT to point to the root of the SDK installation | |
| export ANDROID_SDK_ROOT='/Applications/adt-bundle-mac-x86_64-20130729/sdk' | |
| export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/tools/lib/x86_64 |
| #!/bin/bash | |
| # Install Xcode Command Line Tools first (required) | |
| xcode-select --install | |
| # Check PHP version `php --version` | |
| PHP_VER=$(php -v | head -1 | awk '{ print $2 }') | |
| # Extensions directory (default: empty string) | |
| EXT_DIR="" |
| launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist |