This file contains 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 'rubygems' | |
require 'ruby-cldr' | |
require 'cldr' | |
require 'cldr/data' | |
require 'cldr/download' | |
require 'yaml' | |
# NOTE: nb = no (norwegian) | |
locales = ["he", "en", "fr", "it", "de", "es", "ja", "ko", "ru", "tr", "pt", "fil", "hi", "ms", "id", "nl", "da", "sv", "pl", "hu", "fi", "nb", "zh", "zh-Hant", "ar", "fa", "ur", "th", "uk", "ca", "el", "af", "cs", "eu"] | |
components = ["calendars", "currencies", "delimiters", "languages", "numbers", "Plurals", "territories", "timezones", "units"] |
This file contains 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
#!/bin/env ruby | |
# lazy hack from Robert Klemme | |
module Memory | |
# sizes are guessed, I was too lazy to look | |
# them up and then they are also platform | |
# dependent | |
REF_SIZE = 4 # ? | |
OBJ_OVERHEAD = 4 # ? |
This file contains 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 'rubygems' | |
require 'json' | |
require 'ya2yaml' | |
require 'twitter_cldr' | |
require 'fileutils' | |
ENDPOINT = "http://translate.twttr.com/api/2/twitter/phrase/{{phrase_id}}/translations.json" | |
merged = { :day => 19636, :hour => 19638, :second => 19639, :minute => 19634 }.inject({}) do |final_ret, (label, phrase_id)| | |
cur_data = JSON.parse(`curl #{ENDPOINT.gsub("{{phrase_id}}", phrase_id.to_s)} --silent`).inject({}) do |ret, (locale, trans)| |
This file contains 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 'open-uri' | |
require 'fileutils' | |
require 'yaml' | |
PROPS_URL = "http://www.unicode.org/Public/6.1.0/ucd/DerivedNormalizationProps.txt" | |
OUTPUT_FILE = "/tmp/cldr/composition_exclusions.yml" | |
EXPECTED_TOTAL_POINTS = 1120 | |
data = open(PROPS_URL).read | |
start_pos = data.index("# Derived Property: Full_Composition_Exclusion") |
This file contains 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 'twitter_cldr' | |
require 'fileutils' | |
require 'yaml' | |
OUTPUT_FILE = "/tmp/cldr/decomposition_map.yml" | |
CODE_POINT_MAX = 1114111 | |
decomps = {} | |
CODE_POINT_MAX.times do |i| | |
code_point = TwitterCldr::Shared::CodePoint.for_hex(i.to_s(16)) |
This file contains 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
# protip: use Ruby 1.9 for block support with Enumerable#count | |
def count_ones(num) | |
return 0 if num == 0 | |
digits = Math.log2(num).floor + 1 | |
0.upto(digits).count do |i| | |
num & (2 ** i) == (2 ** i) | |
end | |
end |
This file contains 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
/ | |
/ | | |
/ | | |
116,435 / | | |
/ | 8,000 | |
/ x | | |
___________ | |
116,160 | |
soh cah toa |
This file contains 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
class Project < ActiveRecord::Base | |
has_and_belongs_to_many :phrases | |
end | |
class Phrase < ActiveRecord::Base | |
has_and_belongs_to_many :projects | |
end | |
join_dependency = ActiveRecord::Associations::JoinDependency.new(Project, [:phrases], []) |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>CSKit HTML Example</title> | |
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet"> | |
<style> | |
.cskit-strongs-word { |
This file contains 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
module BeforeMethodHook | |
def before(*names) | |
names.each do |name| | |
m = instance_method(name) | |
define_method(name) do |*args, &block| | |
yield self | |
m.bind(self).call(*args, &block) | |
end | |
end | |
end |
OlderNewer