Skip to content

Instantly share code, notes, and snippets.

View jamesp's full-sized avatar

James Penn jamesp

  • Met Office
  • Devon, UK
View GitHub Profile
module ColourfulPuts
def cprint(text, colour)
colours = {
:red => "\033[1;31m",
:yellow => "\033[1;31m",
:green => "\033[1;32m",
:blue => "\033[1;34m",
:magenta => "\033[1;35m",
:default => "\033[0m"
}
@jamesp
jamesp / bibberish.rb
Created November 20, 2008 11:39
Uses the google translate api to translate a string between languages, via any intermediate
#!/usr/bin/env ruby
# translate text on the command line
require 'rubygems'
require 'open-uri'
require 'json'
# Usage: $0 from:to phrase...
#
# the first argument defines the languages to convert from and to. If only one
# config/app_config.yml
---
defaults: &defaults
:name: Super Awesome Blog
:tagline: My super awesome blog and stuff.
:email: you@example.org
development:
<<: *defaults
# Override the defaults.
# Learning Cantonese using bastardised pinyin
# Cantonese pronunciation : English phrase
#
ng goi: please/thank you (in shops etc)
dor dze: thank you (someone has just done something nice for you)
ngaw seung...: I would like...
ngaw seung leung go bear-tzhao: I would like 2 beers.
1) Guilin - famous for landscape
2) X'ian
3) Zhang Jia Jie - Where Owen went
1) Guilin - famous for landscape
2) X'ian
3) Zhang Jia Jie - Where Owen went
Your origina
a a1 a2 a3 a4 a5 e e1 e2 e3 e4 e5 i i1 i2 i3 i4 i5 o o1 o2 o3 o4 o5 u u1 u2 u3 u4 u5 ü v1 v2 v3 v4 ü
Tonal pinyin:
a ā á ǎ à a e ē é ě è e i ī í ǐ ì i o ō ó ǒ ò o u ū ú ǔ ù u ü ǖ ǘ ǚ ǜ ü
a a&#772; a&#769; a&#780; a&#768; a e e&#772; &eacute; e&#780; &egrave; e i &#299; &iacute; &#464; &igrave; i o o&#772; o&#769; o&#780; o&#768; o u u&#772; u&#769; u&#780; u&#768; u ü &#470; &#472; &#474; &#476; Ã
Tones = {
1 => :flat,
2 => :up,
3 => :downup,
4 => :down,
5 => :notone,
}
# where v = umlaut
Vowels = [
# Built in library imports
import mimetypes
import re
import os
import sys
# Server imports
import urlparse
import cgi
class Juno(object):
@jamesp
jamesp / gist:106362
Created May 4, 2009 07:36
RStakeout
#!/usr/bin/env ruby
# Originally by Mike Clark.
#
# From http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/StakingOutFileChanges.rdoc
#
# Runs a user-defined command when files are modified.
#
# Can use Ruby's Dir[] to get file glob. Quote your args to take advantage of this.
#