Skip to content

Instantly share code, notes, and snippets.

@hara-y-u
hara-y-u / xmltext.rb
Created July 11, 2011 04:58
ruby command which extract text from xmlfile
#!/usr/bin/env ruby
# extract text node from xml file
# USAGE:
# xmltext.rb file_path xpath
require "rexml/document"
file = ARGV.shift.dup
xpath = ARGV.shift.dup
// access nested hash data using string
// Usage:
// var hash = {"foo": {"bar": true, "baz": false }};
// getVal(hash, "foo.bar".split(".")); //=> true
// getVal(hash, "foo.baz".split(".")); //=> false
// setVal(hash, "foo.baz".split("."), "hoge"); //=> "hoge"
// you can also create new keys step by step (same as accessing with array-style)
function getVal(hash, keys) {
var frst=keys.splice(0,1);
if(keys.length) {
#!/bin/sh
#hoard.sh: Private twitter on the shell
#usage:
# hoard "some string here": for store your hoard into file
# hoard -s: hoard: for See your recent hoard
# hoard -e: for Edit your recent hoard
#Change these lines for your System.
hoarddir="/Users/$USER/Documents/Hoard/"
hoardfile="`date +%Y%m`.txt"