Skip to content

Instantly share code, notes, and snippets.

@mutsune
mutsune / reading_list_on_chrome.scpt
Created April 6, 2018 05:25
Chrome で開いているタブを Safari の Reading List へ追加する AppleScript
tell application "Google Chrome"
set myURL to get URL of active tab of first window
set myTitle to get title of active tab of first window
end tell
tell application "Safari" to add reading list item myURL with title myTitle
class Katakana2Hiragana {
public static void main(String args[]) {
System.out.println((char)("ガ".charAt(0) - 'ァ' + 'ぁ') == 'が');
}
}
@mutsune
mutsune / Pipfile
Last active November 4, 2017 14:26
ブロックチェーンを作ることで学ぶ 〜ブロックチェーンがどのように動いているのか学ぶ最速の方法は作ってみることだ〜 https://qiita.com/hidehiro98/items/841ece65d896aeaa8a2a のコード。タイポ修正やコメントを微妙に書き加えた
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
[requires]
python_version = "3.6"
#!/usr/bin/env python
import urllib.request
import os
import html
def save(path, content):
with open(path, "w") as file:
file.write(content)
@mutsune
mutsune / custom.css
Created February 22, 2017 14:45
Fira Code with Ligature for Jupyter Notebook
@font-face {
font-family: 'Fira Code';
src: url("https://cdn.rawgit.com/dunovank/jupyter-themes/1e851888/jupyterthemes/fonts/monospace/firacode/firacode.otf") format("opentype");
}
.CodeMirror {
font-family: 'Fira Code';
font-variant-ligatures: initial;
}
@mutsune
mutsune / viterbi.py
Last active February 21, 2016 17:15
A trial program of the viterbi algorithm with HMM for POS tagging.
import numpy as np
# data
x = ["Brown", "promises", "free"]
y = ["Noun", "Verb", "Adj"]
# suppose the probabilities
p_x_y = [[0.3, 0.2, 0.5], [0.3, 0.4, 0.1], [0.4, 0.4, 0.4]] # p(x_t, y_t)
p_y_y = [[0.4, 0.7, 0.5], [0.5, 0.1, 0.2], [0.1, 0.2, 0.3]] # p(y_t, y_t-1)
@mutsune
mutsune / csvToJson.py
Last active August 29, 2015 14:02
CSV から JSON への変換スクリプト (単純な Array か Object への変換)
#!/usr/bin/env python
# encoding: utf-8
import sys
indent = [" ", " "]
def t(n):
return "".join(indent[:n])
l = "\""
@mutsune
mutsune / controlFlowStatement.py
Created June 6, 2014 06:42
Python で制御構造っぽいものを定義
def repeat(n):
def _repeat(f, *args):
[ f(*args) for i in xrange(n)]
return _repeat
def _print(text):
print text
repeat(10)(_print, "hoge")
@mutsune
mutsune / get emoji
Created April 11, 2014 10:57
まったくつまらないものを作ってしまいましたが、絵文字を表す Unicode の正規表現を出力するワンライナーです
eval $(curl -s http://www.unicode.org/Public/6.0.0/ucd/EmojiSources.txt | awk -F";" ' BEGIN { printf "perl -MRegexp::Assemble::Compressed -le \047$r=Regexp::Assemble::Compressed->new; " } { if ($1 !~ /^#/ && $1 ~ /^[0-9A-Fa-f]+$/) printf "$r->add( \"" $1 "\" ); " } END { printf "print $r->re\047\n" } ')
perl -MRegexp::Assemble::Compressed -le '$r=Regexp::Assemble::Compressed->new; $r->add( "hoge" ); $r->add( "moge" ); print $r->re'