Skip to content

Instantly share code, notes, and snippets.

@twittoru
twittoru / Makefile
Created April 14, 2013 11:12
rijndael
SOURCE=http://www.efgh.com/software/rijndael.txt
DEFAULT: encrypt decrypt
clean:
rm -f encrypt decrypt rijndael.c rijndael.h rijndael.txt encrypt.c decrypt.c
encrypt: encrypt.c rijndael.c rijndael.h
decrypt: decrypt.c rijndael.c rijndael.h
@twittoru
twittoru / sha1.R
Last active December 14, 2015 00:59
SHA-1 in pure R / attendant unsigned int32 and bitwise operation
library(methods)
# bitwise operation
Bit32 <- setRefClass("bit32",
methods = list(
rotate = function(a,s) {
ior(shift(a,s),shift(a,-(32-s)))
},
shift = function(a,shift) {
if(class(a) != "uint32") a <- UInt32$new(a)
curl -d"q=select * from html where url='http://d.hatena.ne.jp/mamoruk/archive?word=$(($RANDOM % 1550))' and xpath='//li[contains(concat(\" \",@class,\" \"),\" archive-section \")]/a' limit 1 offset $(($RANDOM % 50))" http://query.yahooapis.com/v1/public/yql
@twittoru
twittoru / build
Created September 25, 2012 09:37
まつもとゆきひろ『プログラミング言語Ruby』を大いに語る を mobi に
cat job | xargs -L1 kindlenap.pl -o ./
# kindlenap get from motemen/Kindlenap
for i in *.html
do
sed -i"" -e "s/<body>/<body><h1>${i%.*}<\/h1>/" $i
sed -i"" -e "s/<\/body>/<mbp:pagebreake \/><\/body>/" $i
done
kindlegen matz-talks-the-ruby-book.opf
@twittoru
twittoru / plots.R
Created November 12, 2011 07:15
Tsukuba.R#9 appendix2
library(ggplot2)
# inline でのプロット 省略の波は Keynote のテキストをはっつけた
inline <- data.frame(x=c("C", "RCpp", "Pure R"), y=c(0.219, 0.242, 27.969))
ggplot(inline, aes(x=x, y=y))
+ geom_bar(aes(fill=x)) # x ごとに色づけ
+ coord_cartesian(ylim=c(0, 0.5)) # y 軸を制限 (はみでる barplot は scale_y_continuous で制限はできない)
+ scale_y_continuous(name="elapsed",
breaks=c(0, 0.1, 0.2, 0.3, 0.4, 0.5), # 適当に軸を分割する
labels=c(0, 0.1, 0.2, 26, 27, 28)) # フリーダムにラベルを張る
@twittoru
twittoru / BlasOSX.sh
Created November 12, 2011 06:47
Tsukuba.R#9 appendix1
#!/bin/zsh
# OSX 2.13 公式バイナリ
# GotoBLAS 1.13
wget http://r.research.att.com/benchmarks/R-benchmark-25.R
Rscript R-benchmark-25.R > netlib.log
#curl http://cms.tacc.utexas.edu/fileadmin/images/GotoBLAS2-1.13_bsd.tar.gz | tar zxf - && cd GotoBLAS2 && make
# install yourself
@twittoru
twittoru / cmigemo.rb
Created January 18, 2011 14:30 — forked from lapis25/gist:583235
C/Migemo のconfigureがprefixをうまく受けいれてくれず、/usr/local 直下に作ろうとするので改変。これでsudoしないでもinstallできる。 prefixを変更したらMakefileの解釈がおかしいのかディレクトリつくるまえにinstallしようとするので先にディレクトリつくるように。
require 'formula'
class Cmigemo <Formula
url 'http://www.kaoriya.net/dist/var/cmigemo-1.3c.tar.bz2'
homepage 'http://www.kaoriya.net/#CMIGEMO'
md5 '0b9d2feff4cfdc673cc1947fe54191ed'
version '1.3c'
depends_on 'nkf'
# {{{
OAuth.R.License <-
'Copyright (c) 2010 OZAKI Toru (twittoru)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: