Skip to content

Instantly share code, notes, and snippets.

View ainame's full-sized avatar

Satoshi Namai ainame

View GitHub Profile
(autoload 'js2-mode "js2" nil t)
(add-hook 'js2-mode-hook
#'(lambda ()
(require 'espresso)
(setq espresso-indent-level 2
espresso-expr-indent-offset 2
indent-tabs-mode nil)
(set (make-local-variable 'indent-line-function) 'espresso-indent-line)))
@ainame
ainame / 15_javascript-config.el
Created December 13, 2011 09:06
JavaScriptのメジャーモードの設定
;;
;; JavaScriptについて
;;
;; js2-modeを使う
;; しかしインデントが糞なのでjs-modeの物を使う
(autoload 'js2-mode "js2" nil t)
(setq-default js2-basic-offset 4)
(when (load "js2" t)
#リポジトリのルートに飛ぶ
function cdr(){
cd ../
if [ -e .git -a -d .git ]; then
return 0
else
cdr
fi
return 0
}
#リポジトリのルートに飛ぶ
function cdr(){
if [ -e .git -a -d .git ]; then
return 0
else
cd ../
cdr
fi
return 0
}
# -*- coding: utf-8 -*-
def parse_max(data)
puts "要素数:" + data.size.to_s
max = 0
max_idx = 0
data.each_with_index do |val, idx|
val = val.to_f unless val.kind_of? String
if max <= val
max = val
max_idx = idx
# -*- coding: utf-8 -*-
# コメントテスト
def parse_max(data)
puts "要素数:" + data.size.to_s
max = 0
max_idx = 0
no_increace = 0
data.each_with_index do |val, idx|
val = val.to_f unless val.kind_of? String
# -*- coding: utf-8 -*-
def parse_max(data)
puts "要素数:" + data.size.to_s
max = 0
max_idx = 0
no_increace = 0
data.each_with_index do |val, idx|
val = val.to_f unless val.kind_of? String
if max <= val
@ainame
ainame / gist:1519491
Created December 25, 2011 16:54
do〜while in ruby
# C言語では こんな感じなのが
#
# int flag = 0
# do{
# flag = hoge ? 1 : 0;
# } while (flag);
#
# Rubyでは
# -*- coding: utf-8 -*-
#実験結果をcsv化するスクリプト
log = Hash.new
Dir.glob("*/log") do |log_path|
key = "N=" + log_path.match(/N_(.*)\/log/).captures[0]
log[key] = Array.new
open(log_path) do |f|
f.read.each_line do |line|
if line =~ /Pred/
# 01_というプリフィックスをつけたファイルを用意
mbp:~ namai$ echo "a" > 01_a
mbp:~ namai$ echo "b" > 01_b
# コピー先のディレクトリを用意
mbp:~ namai$ mkdir desti
# $ cp 01_* desti/ と打とうとしたら...間違って途中エンター押しちゃった
mbp:~ namai$ cp 01_*
# 中を見るとどっちも同じファイルに・・・
mbp:~ namai$ cat 01_a
a