Skip to content

Instantly share code, notes, and snippets.

View holysugar's full-sized avatar

HORII Keima holysugar

  • Aiming, Inc
  • Tokyo
View GitHub Profile
@holysugar
holysugar / growthforecast.sh
Last active December 14, 2015 18:58 — forked from oranie/gist:3697669
/etc/init.d/growthforecast
#!/bin/bash
#
# /etc/rc.d/init.d/growthforecast
#
# chkconfig: - 80 20
# description: growthforecast
# processname: growthforecast
# pidfile: /var/run/growthforecast/growthforecast.pid
#
### BEGIN INIT INFO
@holysugar
holysugar / 711uranai.rb
Created March 8, 2013 11:27
今日の1階うらない取得ワンライナーっぽいアレ
# coding: utf-8
require 'net/http'
Net::HTTP.get(URI.parse('http://yonekawa711.blog22.fc2.com/')).force_encoding('UTF-8').scan(/『.+?『.+?。/m)[0].gsub(/\<.+?\>/,'')
@holysugar
holysugar / rubylib.watchr
Created February 6, 2013 10:27
Ruby のライブラリ汎用 watchr 設定ファイル screen 通知用
# vim: ft=ruby fileencoding=utf-8
# --------------------------------------------------
# Notifier to screen
# --------------------------------------------------
def hardstatus
status = open("#{ENV['HOME']}/.screenrc"){|f| f.grep(/^hardstatus/)[-1] } || ""
status.chomp.rstrip
end
@holysugar
holysugar / pre-commit
Last active December 10, 2015 19:48
pre-commit hook: reject commit including p or pry
#!/bin/sh
git diff --cached | grep -E '^\+.*\bp(ry)?\b' && echo 'p or pry may exist.' && exit 1
@holysugar
holysugar / struct_module.rb
Created December 21, 2012 04:59
struct_module.rb
# coding: utf-8
require "struct_module/version"
module StructModule
class << self
def generate_module(attrs)
Module.new{|mod|
@_members = attrs
def self.included(base)
@holysugar
holysugar / itms-redirection-sample.rb
Created December 6, 2012 05:31
ITMS へのリダイレクト例 (sinatra)
# coding: utf-8
require 'sinatra'
itms_url = 'itms-apps://itunes.apple.com/jp/genre/id6014'
get '/' do
return <<-HTML
<html>
<head>
<title>ITMSリダイレクト挙動サンプル</title>
@holysugar
holysugar / close.html
Created December 4, 2012 07:00
開いてすぐ閉じる HTML 例
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = function(){
document.getElementById('d').innerHTML = 'xxxxxxxxxx';
window.open("about:blank","_self").close();
// window.close();
};
</script>
@holysugar
holysugar / gist:4192128
Created December 3, 2012 02:01
後置 while にする?
def generate_name
begin
name = Digit.generate(6)
end while Image.exists?(name: name)
name
end
def generate_name
loop do
name = Digit.generate(6)
@holysugar
holysugar / organization_members.sh
Created November 19, 2012 13:21
Get organization members
curl -u USERNAME https://api.github.com/orgs/ORGNAME/members | ruby -rjson -e 'o = JSON.parse(ARGF.read); puts o.map{|i| i["login"]}'