Skip to content

Instantly share code, notes, and snippets.

@nysalor
nysalor / kc_voicelist.rb
Last active December 25, 2018 22:40
艦これwikiから台詞リストを取得する
require 'uri'
require 'mechanize'
start_url = ARGV[0] || 'https://wikiwiki.jp/kancolle/%E8%89%A6%E5%A8%98%E3%82%AB%E3%83%BC%E3%83%89%E4%B8%80%E8%A6%A7'
agent = Mechanize.new
index_page = agent.get(start_url)
uri = URI.parse(start_url)
vessels = []
;; highlight-indent
(require 'highlight-indent-guides)
(setq highlight-indent-guides-method 'column)
(setq highlight-indent-guides-auto-enabled t)
(setq highlight-indent-guides-responsive 'top)
(add-hook 'ruby-mode-hook 'highlight-indent-guides-mode)
@nysalor
nysalor / ci-rebuild.zsh
Created October 6, 2017 03:02
CircleCI rebuild function (with peco and jq)
# set CircleCI token to $CIRCLECI_TOKEN
function ci-rebuild () {
BUILDID=$(curl -s "https://circleci.com/api/v1/recent-builds?circle-token=$CIRCLECI_TOKEN" |jq -r '.[] | "\(.username)/\(.reponame)/\(.build_num) \(.subject)"' | peco | cut -f 1 -d ' ')
if test "${BUILDID}" != ""; then
curl -X POST "https://circleci.com/api/v1/project/$BUILDID/retry?circle-token=$CIRCLECI_TOKEN"
fi
}
zle -N ci-rebuild
@nysalor
nysalor / in_multi_columns.rb
Created February 26, 2016 02:53
ActiveRecord "IN" statement for multi columns condition
query_params = [['pochi', 'dog', 'black'], ['tama', 'cat', 'mike'], ['baron', 'horse', 'kurige']]
placeholder = query_params.map { (?, ?, ?) }
args = ["SELECT id FROM animals WHERE (name, race, color) IN (#{placeholder})", *query_params]
ids = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, args)).map {|x| x['id'] }
@nysalor
nysalor / stringify.rb
Created November 5, 2015 09:58
yaml stringifier
require 'yaml'
def stringify(hash, prefix = nil)
hash.map { |k, v|
scope = prefix ? "#{prefix}.#{k}" : k
if v.is_a?(Hash)
stringify v, scope
else
"#{scope}: #{v}"
end
@nysalor
nysalor / search_form
Created June 11, 2015 08:38
ajax search
@searchForm = (trigger) ->
field = $($(trigger).data('field'))
opts = {}
opts[field.attr('name')] = field.val()
$(field).on 'input', () =>
opts[field.attr('name')] = field.val()
$(trigger).on 'click', () =>
$.ajax({
diff -Nrc emacs-24.4.orig/configure.ac emacs-24.4/configure.ac
*** emacs-24.4.orig/configure.ac 2014-10-13 09:14:08.000000000 +0900
--- emacs-24.4/configure.ac 2014-11-03 16:08:44.000000000 +0900
***************
*** 1782,1788 ****
INSTALL_ARCH_INDEP_EXTRA=
fi
! NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o $macfont_file"
fi
@nysalor
nysalor / rebase.txt
Created April 17, 2015 05:24
git rebase help
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#!/bin/sh
date=`date "+%Y%m%d-%H%M%S"`
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
host=`hostname -s`
git checkout -b "wip-${date}"
git add .
git add -u
@nysalor
nysalor / peco-kill.zsh
Created September 24, 2014 02:37
peco-kill
function peco-kill () {
kill $(ps aux | peco --query "$LBUFFER" | awk '{ print $2 }')
}
zle -N peco-kill
alias pk="peco-kill"