This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the given block +num+ times and then print out the mean, median, min, | |
# max, and stddev of the run. For example: | |
# | |
# irb> stats(10) { sleep(rand / 100) } | |
# mean: 5.99ms | |
# median: 6.76ms | |
# min: 1.49ms | |
# max: 9.28ms | |
# stddev: 2.54ms | |
def stats(num) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails_root = "/data/github/current" | |
20.times do |num| | |
God.watch do |w| | |
w.name = "dj-#{num}" | |
w.group = 'dj' | |
w.interval = 30.seconds | |
w.start = "rake -f #{rails_root}/Rakefile production jobs:work" | |
w.uid = 'git' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in /etc/munin/munin.conf | |
contacts campfire | |
contact.campfire.command | /web/scripts/alerts /web/scripts/alerts | |
contact.campfire.always_send warning critical |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is the sphinx.yml file I use for webtranslateit.com | |
# It has been tested with latin languages, Chinese, Japanese, Korean and Russian | |
development: | |
enable_star: true | |
min_prefix_len: 1 | |
min_word_len: 1 | |
ngram_len: 1 | |
ngram_chars: "U+00C6->U+00E6, U+01E2->U+00E6, U+01E3->U+00E6, U+01FC->U+00E6, \\\n \ | |
U+01FD->U+00E6, U+1D01->U+00E6, U+1D02->U+00E6, U+1D2D->U+00E6, U+1D46->U+00E6, U+00E6, U+0622->U+0627, U+0623->U+0627, U+0624->U+0648, U+0625->U+0627, U+0626->U+064A, U+06C0->U+06D5, U+06C2->U+06C1, U+06D3->U+06D2, U+FB50->U+0671, U+FB51->U+0671, U+FB52->U+067B, \\\n \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# change postgresql template1 db encoding to utf8 (unicode) by dropping it and recreating from template0 | |
UPDATE pg_database SET datistemplate=false WHERE datname='template1'; | |
drop database template1; | |
create database template1 with template = template0 encoding = 'UTF8'; | |
UPDATE pg_database SET datistemplate=true WHERE datname='template1'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'RMagick' | |
TOP_N = 10 # Number of swatches | |
# Create a 1-row image that has a column for every color in the quantized | |
# image. The columns are sorted decreasing frequency of appearance in the | |
# quantized image. | |
def sort_by_decreasing_frequency(img) | |
hist = img.color_histogram | |
# sort by decreasing frequency |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'web_translate_it' | |
# create a KeepAlive HTTPS connection to WebTranslateIt.com | |
WebTranslateIt::Connection.new('secret_api_key') do | |
# create translations | |
translation_en = WebTranslateIt::Translation.new({ :locale => "en", :text => "Hello" }) | |
translation_fr = WebTranslateIt::Translation.new({ :locale => "fr", :text => "Bonjour" }) | |
# create a new segment | |
string = WebTranslateIt::String.new({ :key => "Greetings", :translations => [translation_en, translation_fr]}) | |
# and save |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This ruby script will pull all your strings from WebTranslateIt.com | |
# and format them under the Apple .strings format | |
# beforehand: `gem install web_translate_it` | |
# make sure you’re using the version 2.0.2 which implements pagination on `String.find_all` | |
require 'web_translate_it' | |
api_key = 'sekret' | |
WebTranslateIt::Connection.new(api_key) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before using: gem install web_translate_it | |
require 'web_translate_it' | |
file = File.new("my_file.csv", "w") | |
locales = %w{en fr de it ru sv} | |
file.puts "key," + locales.join(",") | |
WebTranslateIt::Connection.new('api_key') do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before using: gem install web_translate_it | |
require 'web_translate_it' | |
file = File.new("fr.yml", "w") | |
file.puts "fr:\n" | |
WebTranslateIt::Connection.new('api_key') do | |
puts "Fetching all strings in project..." | |
WebTranslateIt::String.find_all.each do |string| |
OlderNewer