Skip to content

Instantly share code, notes, and snippets.

View chiastolite's full-sized avatar

Hiroyuki Morita chiastolite

View GitHub Profile
@chiastolite
chiastolite / gist:9246215
Created February 27, 2014 08:08
focuslight log
17:07:47 web.1 | started with pid 62564
17:07:47 worker1.1 | started with pid 62565
17:07:47 worker2.1 | started with pid 62566
17:07:47 web.1 | I, [2014-02-27T17:07:47.201378 #62564] INFO -- : listening on addr=0.0.0.0:5125 fd=9
17:07:47 web.1 | I, [2014-02-27T17:07:47.201553 #62564] INFO -- : worker=0 spawning...
17:07:47 web.1 | I, [2014-02-27T17:07:47.203146 #62564] INFO -- : master process ready
17:07:47 web.1 | I, [2014-02-27T17:07:47.206611 #62567] INFO -- : worker=0 spawned pid=62567
17:07:47 web.1 | I, [2014-02-27T17:07:47.207565 #62567] INFO -- : Refreshing Gem list
17:07:47 worker1.1 | "/Users/chiastolite/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/focuslight-0.1.2/focuslight/.env" is not found. Run `focuslight new` first
17:07:47 worker2.1 | "/Users/chiastolite/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/focuslight-0.1.2/focuslight/.env" is not found. Run `focuslight new` first
function peco-git-log () {
if [ -d ".git" ]; then
local git_hash=$(git log --oneline | peco --query "$LBUFFER"|cut -d' ' -f1)
if [ -n "$git_hash" ]; then
BUFFER="git ${git_hash}"
fi
zle clear-screen
fi
}
@chiastolite
chiastolite / gist:a47225d3e0b3359bfed3
Last active August 29, 2015 14:04
Middleman調べてた

Markdownでの画像ファイルの表示について

middleman/middleman-core/lib/middleman-core/renderers/kramdown.rbのconvert_imgでパスの書き換えが行われてる
redcarpetの場合もこれやらないとダメぽい middleman/middleman-core/lib/middleman-core/renderers/redcarpet.rbがあった

逆に↓この説明通りにやるとしくじるのでは…

http://middlemanapp.com/jp/basics/pretty-urls/

@chiastolite
chiastolite / git-wip
Created August 26, 2014 03:23
git-wip
#!/bin/sh
if ! hash hub 2>/dev/null; then
echo 'command not found: hub'
echo ''
echo 'hub is needed for create pull-request.'
echo ''
echo 'see: https://github.com/github/hub'
exit 1
fi
require 'bundler/setup'
Bundler.require
require 'google/api_client'
require 'google/api_client/client_secrets'
require 'google/api_client/auth/installed_app'
client = Google::APIClient.new(
:application_name => 'Example Ruby application',
:application_version => '1.0.0'
)
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "ruboty-fluent-logger"
spec.version = "1.0.0"
spec.authors = ["chiastolite"]
spec.email = ["[email protected]"]
spec.summary = "foward all messages to fluentd"
spec.license = "MIT"
                                       
                                       
                                       
             
@chiastolite
chiastolite / gist:4b95d88811b6355ae540
Last active August 29, 2015 14:24
こういうhas_oneの使い方ってありなんだろうか?
class Entry < ActiveRecord:Base
has_many :messages
has_one :latest_message, -> { merge(Message.latest) }, class_name: 'Message'
end
class Message < ActiveRecord:Base
scope :latest, -> { order(id: :desc) }
end
@chiastolite
chiastolite / grouping.rb
Last active August 18, 2020 16:25
こんなのどうやるんだけ
FooModel.pluck(:hoge_id, :id)
# => [[1, 1], [1, 2], [2, 3], [3, 4], [3, 5]]
# ↑これを↓こんな風にhoge_id毎にまとめたい
# => {1 => [1, 2], 2 => [3], 3 => [4, 5]}
#!/bin/bash
# Gitリポジトリ内ではなければ処理をしない
git status > /dev/null 2>&1
if [ $? != 0 ] ; then
echo "Not a git repository"
exit 1
fi
# stagingされているファイルがある場合は処理をしない
if [ -n "`git diff --name-only --cached`" ]; then