Skip to content

Instantly share code, notes, and snippets.

@shunirr
shunirr / pre-commit
Last active August 29, 2015 13:56
git commit の時に名前が良い感じかどうか判定するやつ
#!/bin/bash
ORIGIN=$(git remote | grep origin | head -1)
NAME=$(git config --get user.name)
EMAIL=$(git config --get user.email)
if [ -n "$(git remote show ${ORIGIN} | grep 'github.com\|bitbucket.org')" ]; then
if [ "${NAME}" = "shunirr" -a "${EMAIL}" = "m@s5r.jp" ]; then
exit 0
fi
#!/usr/bin/env ruby
require 'nokogiri'
def markdown(children)
data = []
children.each do |child|
case child.node_name
when "p", "div" then
data << markdown(child.children)
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
def anchor(children)
data = []
children.each do |child|
case child.node_name
when "p", "div" then
http://ameblo.jp/ogura-yui/image-10302198220-10235474958.html http://stat.ameba.jp/user_images/20090818/11/ogura-yui/3c/9e/j/o0200026710235474958.jpg
http://ameblo.jp/ogura-yui/image-10302198220-10235474964.html http://stat.ameba.jp/user_images/20090818/11/ogura-yui/10/7d/j/o0200026710235474964.jpg
http://ameblo.jp/ogura-yui/image-10302374961-10235474969.html http://stat.ameba.jp/user_images/20090818/11/ogura-yui/cb/fe/j/o0200026710235474969.jpg
http://ameblo.jp/ogura-yui/image-10302374961-10235474972.html http://stat.ameba.jp/user_images/20090818/11/ogura-yui/e8/f8/j/o0240032010235474972.jpg
http://ameblo.jp/ogura-yui/image-10302786438-10235483910.html http://stat.ameba.jp/user_images/20090818/12/ogura-yui/a3/cd/j/o0240032010235483910.jpg
http://ameblo.jp/ogura-yui/image-10302931649-10216155772.html http://stat.ameba.jp/user_images/20090719/16/ogura-yui/c5/ef/j/o0020002010216155772.jpg
http://ameblo.jp/ogura-yui/image-10302931649-10216155773.html http://stat.ameba.jp/user_images/20090719/16/ogura-yui/
o0100016610278596467.jpg 100 166
o0100016610279738540.jpg 100 166
o0100016610279738541.jpg 100 166
o0120016010481949660.jpg 120 160
o0123012311153493237.jpg 123 123
o0124016610224915774.jpg 124 166
o0124016610224919557.jpg 124 166
o0127018010974376068.jpg 127 180
o0127018010974376069.jpg 127 180
o0127018010974376070.jpg 127 180
@shunirr
shunirr / custom_base_num.rb
Created February 13, 2014 10:23
自由に n 進数作る
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
class CustomBaseNum
def self.convert(value, base_str)
base = base_str.size
result = ''
while true
break if value <= 0
remainder = value % base
require 'damerau-levenshtein'
module MethodSuggestion
def method_missing(name, *args)
nearly_methods = methods.sort_by do |m|
DamerauLevenshtein.distance(name.to_s, m.to_s)
end
__send__ nearly_methods[0], *args
end
end
#!/bin/sh
GH_TOKEN=$1
UPLOAD_FILE=$2
GH_USER_NAME=$3
GH_REPO_NAME=$4
VERSION=$5
if [ $# -ne 5 ]; then
echo "Invalid arguments."
@shunirr
shunirr / buid.gradle
Created January 17, 2014 07:31
Android-ViewPagerIndicator と volley を Gradle で使う
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.3'
}
}
project(':modules:volley') {
apply plugin: 'android-library'
#!/usr/bin/env ruby
require 'mysql2-cs-bind'
require 'pit'
def get_channel_id(client, name)
channel_id = nil
client.xquery("SELECT id, name FROM channel WHERE name=?", name).each do |data|
channel_id = data['id']
end