Skip to content

Instantly share code, notes, and snippets.

tell application "iTunes"
set iname to name of current track
set iartist to artist of current track
if iartist is not equal to "" then
set iartist to iartist & " - "
end if
tell application "Keychain Scripting"
set twitter_key to first Internet key of current keychain whose server is "twitter.com"

djb

みんなそろそろ D.J. Bernstein が世界史上最高のプログラマだというのを思い出すべきだと思うんだ。

まず、客観的な事実だけを見てみよう。 djb は2つの重要なシステムソフトウェアを書いた。 メールサーバと DNS サーバだ。 どちらも何百万というドメインで使われている。 ありとあらゆる複雑な仕事をこなし、とてつもない高負荷でも問題ないし、どんな異常事態にも対応する。 これらは、Bernstein が最初にリリースしたときとまったく同じものが動いてるのだ。

#!/usr/bin/env jruby
# -*- coding: utf-8 -*-
# ディレクトリ内の画像を全てkindleで読みやすいようにリサイズ→2値化→アンチエイリアス処理する
# イラストも2値化されるので、小説などの文字ページ専用。
require 'rubygems'
require 'ArgsParser'
require 'java'
import 'java.lang.System'
import 'javax.imageio.ImageIO'
import 'java.awt.image.BufferedImage'
@utaal
utaal / Makefile
Created September 5, 2011 16:42
webserver using libuv
webserver: webserver.c libuv/uv.a http-parser/http_parser.o
gcc -I libuv/include \
-lrt -lm -lpthread -o \
webserver webserver.c \
libuv/uv.a http-parser/http_parser.o
libuv/uv.a:
$(MAKE) -C libuv
http-parser/http_parser.o:
@nbqx
nbqx / app.rb
Created September 22, 2011 08:14
# -*- coding: utf-8 -*-
require 'sinatra'
module MyCustomRequestMethod
def hey(path,opts={},&blk)
route __method__.to_s.upcase,path,opts,&blk
end
end
module Sinatra
#!/usr/bin/env ruby
require 'optparse'
require 'pathname'
require 'tmpdir'
libraries = %w|/Applications/Processing.app/Contents/Resources/Java/core.jar|
compiler = 'scalac'
OptionParser.new {|opt|
opt.on('-w', '--watch') { compiler = 'fsc' }
# -*- coding: utf-8 -*-
Earthquake.init do
command %r|^:cen\s*(\d+)*\s+(.+)$|, :as => :cen do |m|
_str = "▓"
th = 0.5
censored = ["名詞","動詞","助動詞","形容詞"]
cmd = m[1] ? ":reply #{m[1]}" : ":update"
url = "http://yapi.ta2o.net/apis/mecapi.cgi?sentence=#{URI.escape(m[2])}&response=surface+pos&filter=&format=json"
#!/usr/bin/env ruby
%w|ubygems pathname pit erb|.each {|g| require g }
def read_sections
sections = {}
section = nil
DATA.readlines.each do |line|
if line =~ /^@@\s+(.+)/
section = $1
elsif section
require 'net/http'
require 'uri'
class KindleIt
def initialize(email)
@email = email
@account, @domain = @email.split('@')
end
def post(url)
@tily
tily / aozora_sort.rb
Created March 9, 2012 16:44
青空文庫の長めの小説をソート
# coding:utf-8
# Usage: ruby aozora_sort.rb URL [--morph] > kokoro_sorted.txt
%w(kconv MeCab open-uri rubygems nokogiri).each{|x| require x}
def main(argv)
morph = argv[1] == '--morph'
text = Nokogiri::HTML.parse(open(argv[0]).read).xpath('/html/body').text
text.gsub!(/[\r\n\s ]/u, '')
arr = morph ? split_with_morph(text) : split_with_char(text)
arr.sort.each_with_index do |s, i|