Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
echo -n !
exec git "$@"
@hitode909
hitode909 / gist:7da7d4dad43c6fb94407
Created April 8, 2015 03:41
トリミングしてアスペクト比を1.3くらいにする
% convert -trim sozai-big.png sozai-trim.png
% identify sozai-trim.png
sozai-trim.png PNG 2385x2885 2834x3000+286+115 8-bit sRGB 3.756MB 0.000u 0:00.000
% convert -resize 2300x3000 -gravity south -background white -extent 2300x3000 sozai-trim.png onigiri.jpg
@hitode909
hitode909 / a.css
Created April 12, 2015 09:05
左端は丸くしない
body {
border-radius: 0px !important;
}
require 'pp'
$KCODE = 'UTF8'
module Ngram
def run(str)
analyze(cut(str,3))
end
def cut(str, n)
list = str.split(//)
# /usr/bin/ruby
# -*- coding: utf-8 -*-
# オセロの石を置くプログラム
# based on http://bkc.g.hatena.ne.jp/coconutsfine/20081010/1223651539
# 新しい盤面のArrayを作って返す
def setup_box
# 盤面オブジェクトを生成(8x8の:empty)
box = Array.new(8){ Array.new(8, :empty) }
#盤面の初期値を設定
#! /usr/bin/ruby
def parse(string)
string.each_line do |line|
list = line.split(" ")
print "#{list.first}: "
list[1..-1].each do |token|
raise "input's size should 2(#{token})" if token.size != 2
token.split("").each do |char|
num = char.chomp.hex.to_s(2)
print "#{'0'*(4-num.size%4) if num.size%4 != 0}#{num}"
* N: NUMBER OF INPUT
N: EQU 80H
* CUR: CURRENT RESULT (AND RESULT)
CUR: EQU 81H
* P1: PREVIOUS RESULT
P1: EQU 82H
* P2: PRE-PREVIOUS RESULT
class Stone
@@STONE_COLORS = [:white, :black]
def initialize(heads_color)
raise "Invalid type" unless @@STONE_COLORS.include?(heads_color)
@heads = heads_color
end
attr_reader :heads # 表の色
LINE = "="*80
Dir.glob("*.cpp\0*.h") do |file|
puts LINE
puts " " + file
puts LINE
system("cat -n #{file}")
end
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
# マルコフ連鎖をしてみるやつ
$KCODE = 'UTF8'
# Array::choiseを追加
class Array
def choise
self[rand(self.size)]