Skip to content

Instantly share code, notes, and snippets.

View Kimtaro's full-sized avatar

Kim Ahlström Kimtaro

View GitHub Profile
const HIRAGANA = "ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんゔゕゖ";
const KATAKANA = "ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶ";
function transliterateHiraganaToKatakana(text) {
var newText = "";
for(let character of text) {
const codepoint = character.codePointAt(0);
if(codepoint >= 12353 && codepoint <= 12438) {
#!/usr/bin/perl
## Depending on which Perl version you're running you'll get different Unicode semantics
# Perl 5.18 (OSX default) - Unicode 6.2
# Perl 5.24 (Latest, available through homebrew) - Unicode 8.0
# Perl 5.25 (Bleeding edge, available through perlbrew) - Unicode 9.0
## perlbrew allows you to easily install bleeding edge Perl:
# sudo /usr/bin/cpan App::perlbrew
# perlbrew install 5.25.9; perlbrew use 5.25.9
@Kimtaro
Kimtaro / [TextMate] Split Windows.scpt
Created March 9, 2016 09:25
Split windows in TextMate
set dock_position to do shell script "defaults read com.apple.dock orientation"
tell application "System Events" to tell process "Dock"
set dock_dimensions to size in list 1
set dock_width to item 1 of dock_dimensions
set dock_height to item 2 of dock_dimensions
end tell
tell application "Finder"
set the_bounds to bounds of window of desktop
#!/usr/bin/env ruby
# https://gist.github.com/jvatic/2711625
flag = false
files = `git diff --cached --name-only --diff-filter=ACM | grep "_spec\.rb$"`.split("\n")
files.each do |file|
results = `git diff --cached #{file} | grep "^\+[^+]" | grep ":focus"`.split("\n").map { |r| r.sub(/^\+[\s\t]*/, '') }
if $? == 0
1: 日
2: 一
3: 国
4: 会
5: 人
6: 年
7: 大
8: 十
9: 二
10: 本
@Kimtaro
Kimtaro / gist:ab137870ad4a385b2d79
Created December 26, 2014 12:06
Add to mecab dictionary
# Put new words in a CSV with this format
# 表層形,左文脈ID,右文脈ID,コスト,品詞,品詞細分類1,品詞細分類2,品詞細分類3,活用形,活用型,原形,読み,発音
# surface_form,left_context_id,right_context_id,cost,part_of_speech,pos_division_1,pos_division_2,pos_division_3,inflection_type,inflection_style,lemma,reading,pronunciation
$ echo "fasihsignal,-1,-1,100,名詞,一般,*,*,*,*,fasihsignal,ファシシグナル,ファシシグナル" > a.csv
# Then use mecab-dict-index to compile the csv into a .dic file, based on an existing mecab dictionary file
$ /usr/local/Cellar/mecab/0.996/libexec/mecab/mecab-dict-index -d/usr/local/Cellar/mecab/0.996/lib/mecab/dic/ipadic/ -u a.dic -f utf8 -t utf8 a.csv
# The use it
$ mecab -ua.dic
@Kimtaro
Kimtaro / gist:bde33d2ae6f71a5d74d7
Created November 10, 2014 15:29
SPARQL for DBpedia, stations in Tokyo
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?station, ?label, ?lat, ?long, ?location WHERE {
?station rdf:type <http://dbpedia.org/ontology/RailwayStation> .
?station <http://dbpedia.org/ontology/location> :Tokyo .
?station <http://dbpedia.org/ontology/location> ?location .
?station rdfs:label ?label .
?station <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat .
?station <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?long .
FILTER (LANG(?label) = 'ja')
@Kimtaro
Kimtaro / .ruby-version
Last active August 29, 2015 14:04
Wlass
2.1.0
@Kimtaro
Kimtaro / keybase.md
Created February 25, 2014 01:13
keybase.md

Keybase proof

I hereby claim:

  • I am kimtaro on github.
  • I am kimtaro (https://keybase.io/kimtaro) on keybase.
  • I have a public key whose fingerprint is 6A97 1676 C83A 5C3C 0DEB 2C1A 73FF AC4F D496 2F38

To claim this, I am signing this object:

@Kimtaro
Kimtaro / webmock.rb
Created August 22, 2013 01:19
Moneky patch to force Webmock to always puts when it disallows a request. This works around overly eager rescue statements hiding the Webmock NetConnectNotAllowedError.
# Encoding: UTF-8
module WebMock
class NetConnectNotAllowedError
def initialize_with_puts(request_signature)
begin
raise initialize_without_puts(request_signature)
rescue => e
puts "< ===== WEBMOCK WEBMOCK WEBMOCK WEBMOCK WEBMOCK ===== >", e.inspect
e