Skip to content

Instantly share code, notes, and snippets.

View amake's full-sized avatar
🌵

Aaron Madlon-Kay amake

🌵
View GitHub Profile
@amake
amake / ParseCLI.java
Last active December 16, 2015 16:49
A function for correctly parsing CLI commands with quotes and escape characters, on Windows, Linux, and OS X.
/**************************************************************************
Public Domain
To the extent possible under law, Aaron Madlon-Kay has waived all
copyright and related or neighboring rights to this work.
This work is published from: Japan
**************************************************************************/
package org.amk;
import java.util.ArrayList;
@amake
amake / phraseextractor.py
Last active March 26, 2016 13:11
A simple Python phrase extractor
'''
A simple phrase extractor
Usage: cat file.txt | python phraseextractor.py [max_ngram] [min_count]
Options:
max_ngram: Maximum phrase length in words (default: 5)
min_count: Minimum number of phrase occurrences (default: 3)
'''
@amake
amake / kanji_and.py
Last active May 11, 2016 04:56
Kanji Bitwise-and Generator
# -*- coding: utf-8 -*-
'''Like Miyagawa's cute "生 & 死 = 愛" trick?
https://gist.github.com/miyagawa/2212589
This script generates every (jōyō) kanji & kanji = ? combination (no
args) or the result for supplied strings.
Note: A "wide" build of Python is required to handle surrogate chars
correctly.
@amake
amake / jesoftcorp2tmx.py
Last active May 24, 2016 07:15
Japanese–English Software Corpus to TMX
#!/usr/bin/env python
# Convert the parallel corpora available at
# http://www2.nict.go.jp/univ-com/multi_trans/member/mutiyama/manual/index.html
# to TMX format
import os
import re
import tarfile
import urllib
@amake
amake / kanjiring.py
Last active May 31, 2016 06:59
Kanji Ring Generator
# -*- coding: utf-8 -*-
'''
Generate randomize rings of kanji with a shared component a la the classic
吾、唯、足るを知る:
 五
矢口隹
 止
@amake
amake / doservice-main.swift
Created June 2, 2016 09:11
A Swift CLI tool for calling arbitrary OS X Services
//
// main.swift
// doservice
//
// Created by Aaron Madlon-Kay on 6/2/16.
// Copyright © 2016 Aaron Madlon-Kay. All rights reserved.
//
import Foundation
import AppKit
@amake
amake / io.jenkins.slave.plist
Last active June 7, 2016 07:44
Jenkins slave connection managed by launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.jenkins.slave</string>
<key>ProgramArguments</key>
<array>
<!-- If authentication is not required, you can launch via Java Web Start directly in the plist.
Otherwise you need a script like below.
@amake
amake / japanese-khk-words.py
Last active June 16, 2016 11:56
Generate a list of Japanese words that include at least one Kanji, Hiragana, and Katakana character
import urllib2
import re
dict_url = 'http://openlab.jp/skk/skk/dic/SKK-JISYO.L'
data = urllib2.urlopen(dict_url).read().decode('euc-jp')
words = set([l.split('/')[1].split(';')[0]
for l in data.split('\n')
if '/' in l and not l.startswith(';;')])
@amake
amake / surrogates.swift
Last active July 11, 2016 16:00
Naked Unicode surrogates in Swift
// Making strings of "normal" Unicode is pretty easy:
// Unicode Scalar literal
"\u{2603}" // "☃"
// From int
String(UnicodeScalar(0x2603)) // "☃"
// Maybe you want to test how your app handles weird Unicode input, like naked surrogates.
// But Swift makes it pretty hard to create such strings.
@amake
amake / unicode-portfolio.py
Created September 16, 2015 04:37
Generate a list of Unicode codepoints that are also stock tickers
import urllib2
# Data from Quandl: https://www.quandl.com/resources/useful-lists
data = ['https://s3.amazonaws.com/quandl-static-content/Ticker+CSV%27s/Indicies/SP500.csv',
'https://s3.amazonaws.com/quandl-static-content/Ticker+CSV%27s/Indicies/dowjonesIA.csv',
'https://s3.amazonaws.com/quandl-static-content/Ticker+CSV%27s/Indicies/NASDAQComposite.csv',
'https://s3.amazonaws.com/quandl-static-content/Ticker+CSV%27s/Indicies/nasdaq100.csv',
'https://s3.amazonaws.com/quandl-static-content/Ticker+CSV%27s/Indicies/NYSEComposite.csv',
'https://s3.amazonaws.com/quandl-static-content/Ticker+CSV%27s/Indicies/nyse100.csv',
'https://s3.amazonaws.com/quandl-static-content/Ticker+CSV%27s/Indicies/FTSE100.csv']