Skip to content

Instantly share code, notes, and snippets.

View kachick's full-sized avatar
😋
😪

Kenichi Kamiya kachick

😋
😪
View GitHub Profile
@kachick
kachick / how_to_delete_exif.md
Created February 9, 2014 16:04
コマンドラインから、exifに詰まった情報を削除する

Perl製なツールのexiftoolがOSSで公開されてて対応フォーマットも多く、一番良いんじゃ無いかなーと感じた。

exiftool -all= image.jpg

とかで消えた。と思う。

import functools
def checkio(els):
return functools.reduce(lambda x,y: x+y, els[:3])
if checkio([1, 2, 3, 4, 5, 6]) == 6:
print('Done!')
@kachick
kachick / mergesort.rb
Created June 24, 2015 17:21
Rubyでアルゴリズムやらデータ構造やらのお勉強(Merge Sort / マージソート)- 2
# coding: us-ascii
# 2015 Kenichi Kamiya
class Array
# [6, 5, 1, 4, 3] => [1, 3, 4, 5, 6]
def mergesort
case size
when 0, 1
self
when 2
@kachick
kachick / all_combinations.rb
Created July 19, 2015 16:44
Ruby 全ての組み合わせ
# coding: us-ascii
# Copyright (c) 2015 Kenichi Kamiya
class Array
def all_combinations(&block)
return to_enum __callee__ unless block_given?
size.downto(1).map { |n| combination(n, &block) }
end
@kachick
kachick / key-change.md
Created August 9, 2015 22:35
壊れたキーボードの凌ぎ方 in Linux

キーボードの調子おかしくなってきて掃除した時、UpAllow↑キーの中のふにゃふにゃとキーカバーが上手くはまらないままどっかいっちゃった ベテランは使わないキーな気もするけど自分にとっては慣れ親しんだキーなので結構困る。 幸い?すぐそばの右シフトは使わなかったんでこれを差し替えて凌いでる。

# まずはxenvで
xenv
# 差し替え対象と差し替え先のキーを叩いてキーコード確認する。それさえ出来ない時も「xmodmap -pke」でなんとなく読める一覧は得られる
# 変更コマンドファイル作ってxmodmapに読み込ませる
@kachick
kachick / hash_maph.rb
Created January 17, 2012 10:02
Hash#maph
# an aproach to http://www.ruby-forum.com/topic/3446541
$VERBOSE = true
class Hash
def maph
return to_enum(__method__) unless block_given?
{}.tap {|hash|
each_pair do |key, value|
$VERBOSE = true
module Enumerable
def count_by
return to_enum(__method__) unless block_given?
Hash.new(0).tap{|h|
each{|v|h[yield v] += 1}
}
end
@kachick
kachick / guess_number.rb
Created January 24, 2012 17:48
Guess number
# an approach to
# * http://vipprog.net/wiki/exercise.html#d082e883
# tested Ruby 1.9.3
$VERBOSE = true
right = rand 100
loop do
@kachick
kachick / ceasar.rb
Created January 24, 2012 17:36
Ceaser
# an approach to
# * http://vipprog.net/wiki/exercise.html#h54a0395
# * http://vipprog.net/wiki/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E8%A8%80%E8%AA%9E/Ruby/%E7%B7%B4%E7%BF%92%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E4%BE%8B.html#h97ae94f
# tested Ruby 1.9.3
$VERBOSE = true
ENCRYPTED = 'qdq-gi.q-a ziatmxxitmdqibtqi-ustbi ri.qmoqrcxi.qbubu zir -ibtqi-qp-qaai ripmymsqkir -ibtqi-qy dmxi ri.cnxuoi rruoumxakir -ibtqiqzmobyqzbkii-q.qmxi -imyqzpyqzbi rixmeaki -puzmzoqai -i-qscxmbu zaimzpir -i btq-iymbbq-a;iz -iatmxximzgi.q-a zinqiuzimzgiemgipuao-uyuzmbqpimsmuzabir -ia. za -uzsiacotiimi.qbubu zj'
chars = [*'abcdefghijklmnopqrstuvwxyz .,'.chars, '\-']
# an approach to
# * http://vipprog.net/wiki/exercise.html#ffeaab60
# tested Ruby 1.9.3
$VERBOSE = true
class Array
def uniq?
dup.uniq!.nil?