Skip to content

Instantly share code, notes, and snippets.

@takesato
takesato / create_schema.rake
Created December 7, 2012 05:01
DB情報からtextileフォーマットのドキュメントを出力する
# -*- coding: utf-8 -*-
namespace :ar do
namespace :schema do
task :export do
output_dir = File.join(Padrino.root, 'documents')
FileUtils.mkdir_p(output_dir)
tables = ActiveRecord::Base.connection.execute("show tables").to_a.map{|t| t[0]}.reject{ |t| t == 'schema_migrations' }
tables.each do |table|
columns = ActiveRecord::Base.connection.execute("show full columns from #{table}").to_a
rows = [
<source>
type exec
command df -k / | sed -E -e 1d -e N -e 's/\n//g' -e 's/%//' -e 's/ +/\t/g'
tag df
keys fs,1024_blocks,used,available,capacity,mounted_on
run_interval 30s
</source>
<match df>
type growthforecast
@takesato
takesato / peco-select-branch.sh
Created July 31, 2014 06:38
branchを最終更新順に並べてpecoで選択してcheckoutする
function peco-switch-branch() {
local branch=$(
(
for i in `git branch | colrm 1 2|grep -v detached`;
do
echo `git log --date=iso8601 -n 1 --pretty="format:[%ai] %h" $i` $i;
done
) | sort -r|peco --query "$LBUFFER" | cut -f 5 -d" ")
if [ -n "$branch" ]; then
BUFFER="git checkout ${branch}"
#!/bin/sh
VOLUME_NAME=ramdisk
BSAE_DIR=/usr/local/Cellar/mysql/5.6.22
NUMSECTORS="$(hdiutil attach -nomount ram://1000000)"
diskutil eraseDisk HFS+ $VOLUME_NAME $NUMSECTORS
mysql_install_db --datadir=/Volumes/$VOLUME_NAME --basedir=$BSAE_DIR
@takesato
takesato / .zshrc
Last active August 29, 2015 14:23
今いるディレクトリに .ssh_config があったらそっちを使って ssh する
ssh() {
if [ -f ".ssh_config" ]; then
/usr/bin/ssh -F .ssh_config "$@"
else
/usr/bin/ssh "$@"
fi
}
@takesato
takesato / zsh_precmd.sh
Created July 8, 2015 09:01
コマンド実行したら terminal-notify で通知.
local COMMAND=""
precmd() {
terminal-notifier -message $COMMAND
COMMAND=""
}
preexec () {
COMMAND="${1}"
}
@takesato
takesato / slack_incoming_webhook.json
Created July 22, 2017 07:48
insomnia で slack incoming webhook を実行する
{
"_type": "export",
"__export_format": 3,
"__export_date": "2017-07-22T07:43:03.577Z",
"__export_source": "insomnia.desktop.app:v5.5.2",
"resources": [
{
"_id": "wrk_1fb26f168cc544f48c461586e05b0284",
"parentId": null,
"modified": 1500708477152,
@takesato
takesato / cd_scriptpath.sh
Created April 11, 2019 03:04
どこから実行してもスクリプトを置いたパス内を起点に動くようにする
#!/bin/sh
cd "${0%/*}"
# cd `dirname $0`
# dirname だとスペースのあるパスで上手く動かない
@takesato
takesato / ios.md
Last active October 1, 2019 11:22
[url schema Links]
@takesato
takesato / .env_file
Last active September 1, 2022 12:22
docker と docker-compose と dotenv と.
SAMPLE1=.env_file
SAMPLE2=.env_file
SAMPLE3=.env_file