Skip to content

Instantly share code, notes, and snippets.

@atton
atton / gist:3337950
Created August 13, 2012 07:46
install vim
hg clone http://vim.googlecode.com/hg vim
cd vim
./configure --enable-multibyte
make
make test
sudo make install
cd ..
rm -rf vim
@atton
atton / ref_install.sh
Created August 12, 2012 08:07
ref.vim install script
#!/bin/sh
# iedevのVim勉強会(http://atnd.org/events/30822)用のスクリプト。
# vunldeとref.vimをインストール + webdict周りの設定をします。
# git と w3m は用意しておいてください
# git のチェック
which git > /dev/null
if [ $? -ne 0 ]; then
echo git not found. please install git.
exit
file = File.open("filename","r")
2.times { file.gets.chomp }
data = ""
while data = file.gets
puts data
end
@atton
atton / gist:3069690
Created July 8, 2012 06:44
increment-test(gcc4.2.1)
#include <stdio.h>
int test(void){
int n = 2;
n = ++n;
printf("%d\n",n); // 3
return 0;
}
int hoge(void){
@atton
atton / bot.rb
Created June 7, 2012 10:23
ruby bot
# -*- coding: utf-8 -*-
require 'twitter'
Twitter.configure do |config|
config.consumer_key = gets.chomp
config.consumer_secret = gets.chomp
config.oauth_token = gets.chomp
config.oauth_token_secret = gets.chomp
end
@atton
atton / 1_10.scm
Created May 12, 2012 05:31
sicp 1.10
(define (A x y)
(cond ((= y 0) 0)
((= x 0) (* 2 y))
((= y 1) 2)
(else (A (- x 1)
(A x (- y 1))))))
(A 1 10)
(A 2 4)
(A 3 3)
(define (hoge a b c)
(define (square x) (* x x))
(define (minimum x y) (if (< x y) x y))
(-
(+ (square a) (square b) (square c))
(square (minimum a (minimum b c)))))
@atton
atton / gist:2576895
Created May 2, 2012 14:27
prime check
def prime? num
return 0 if num == 1
(num-1).downto(2) do |n|
return 0 if num.modulo(n) == 0
end
return 1
end
@atton
atton / gist:2365464
Created April 12, 2012 07:38
shell script option test
#!/bin/sh
# shell script option test
a=0
b=0
while getopts ab opt
do
case ${opt} in
a)
@atton
atton / gist:2300896
Created April 4, 2012 12:57
double regexp "foobar" v2
# -*- coding: utf-8 -*-
# fooが頭に無いbarをファイルに出力する 2.2
array = ["foo","bar","baz","hoge"]
file_name = "./hoge.txt"
f = File.open file_name,"a+"
array.each do |head|