A quick ruby command line to pretty-print piped json.
Put this somewhere in your path, with chmod +x
, then:
curl http://myapp.com/stuff.json | json
#!/usr/bin/env roundup | |
describe "redis-cli(1)" | |
# Start the redis server on port 9999 | |
port=9999 | |
printf "PORT $port\n" | ./redis-server - & | |
redis_pid=$! | |
# Give redis time to start listening |
require 'net/http' | |
class Item | |
#replaced with dynamic initialization below | |
#attr_reader :id, :user, :state | |
# | |
# | |
# Sample JSON | |
# | |
# [{ "id":1, "user":"john", "state":"active" }, | |
# { "id":2, "user":"jane", "state":"inactive" }, |
class Item | |
def initialize item | |
raise "expected Hash param" unless item.kind_of? Hash | |
item.each do |key,value| | |
instance_variable_set(clean_key(key), value) | |
define_singleton_method(key.to_s) { instance_variable_get( clean_key(key) ) } | |
define_singleton_method("#{key.to_s}=") { |val| instance_variable_set( clean_key(key), val ) } | |
end | |
end |
# From a fresh install of squeeze | |
apt-get install ruby rubygems # Need ruby to use fpm | |
gem1.8 install fpm --no-ri --no-rdoc | |
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
tar -zxvf ruby-1.9.3-p125.tar.gz | |
cd ruby-1.9.3-p125 | |
rm -rf /tmp/ruby193 |
A quick ruby command line to pretty-print piped json.
Put this somewhere in your path, with chmod +x
, then:
curl http://myapp.com/stuff.json | json
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.
Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.
On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation
#! /usr/bin/python | |
######################################################################################### | |
# gistcli - version 1.1 # | |
# written by : pranavk # | |
######################################################################################### | |
import urllib2 | |
import sys |
git push origin previous_name:new_name | |
git branch new_name origin/new_name | |
# http://stackoverflow.com/a/3790682/341929 |
" for use before a colorscheme definition | |
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red | |
" for use when not using a colorscheme | |
" highlight ExtraWhitespace ctermbg=red guibg=red | |
" show unwanted whitespace | |
match ExtraWhitespace /\s\+\%#\@<!$/ | |
" strip unwanted trailing whitespace on save |