Skip to content

Instantly share code, notes, and snippets.

View shotasenga's full-sized avatar

Shota Senga shotasenga

  • Canada
View GitHub Profile
@shotasenga
shotasenga / pre-commit
Created September 14, 2013 02:43
Git pre-commit hook. user.name, user.email がローカルにセットされていなければコミットさせない。
#!/bin/sh
## fork from http://qiita.com/uasi/items/a340bb487ec07caac799
if [ -z "`git config --local user.name`" ]; then
echo "fatal: user.name is not set locally"
exit 1
fi
if [ -z "`git config --local user.email`" ]; then
echo "fatal: user.email is not set locally"
exit 1
@shotasenga
shotasenga / wp_remove_accesskeys.user.js
Created October 2, 2013 19:08
WordPressの投稿画面のショートカットを全部無効にするuser script http://senta.me/blog/wordpress/wp-post-is-bad/
// ==UserScript==
// @name WP Remove Accesskeys
// @namespace senta.me
// @description WordPressのアクセスキーを削除する。
// @include http://*/wp-admin/post.php*
// @include http://*/wp-admin/post-new.php*
// ==/UserScript==
(function(){
window.addEventListener("load",function(){
var els = document.getElementsByTagName("input");
@shotasenga
shotasenga / step-frames.scss
Created March 7, 2015 18:07
SCSS mixin instead of `steps()` timing function. some old Android browsers not supported steps() timing function.
@mixin step-frames($steps, $fromX, $fromY, $toX, $toY){
$i: 0;
$frame: 0;
@while $frame < 100 {
@if $frame > 0{
#{$frame - 0.00001}% {
background-position: #{($toX - $fromX) / $steps * ($i - 1)}px #{($toY - $fromY) / $steps * ($i - 1)}px;
}
}
@shotasenga
shotasenga / mogrify-cheat-sheet.md
Last active August 29, 2015 14:16
imagemagick command line tool cheat sheet the I frequently use.

official document

resize image

mogrify -resize 50% copy.png
mogrify -resize 256x256 *.jpg

transparent background

mogrify -transparent white image.png

@shotasenga
shotasenga / cli.sh
Created April 7, 2015 03:27
Make type-hint for PHPStorm
mysql -u root the_db -e 'desc the_table'|awk '{if (match($2, "int")){type = "int"}else{type = "string"}}{print "* @property", type, $1}'
@shotasenga
shotasenga / 01-task.rb
Last active September 24, 2015 16:11
Octopress Rake Task for list categories that used on the blog.
desc "List categories from existing posts (#{source_dir}/#{posts_dir}/*#{new_post_ext})"
task :categories do
categories = []
tags = []
Dir.glob("./#{source_dir}/#{posts_dir}/*.markdown") do |path|
content = File.read(path)
next unless content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
data = YAML.load($1)
categories.push data["categories"] if data["categories"]
@shotasenga
shotasenga / index.sh
Created March 9, 2016 11:55
create new project directory.
cd ~/Dev
mkdir project/{apps,scripts,docs} && touch $(dirname $_)/note.org
#!/bin/sh
brew deps --installed | \
awk -F'[: ]+' \
'{
packages[$1]++
for (i = 2; i <= NF; i++)
dependencies[$i]++
}
END {
@shotasenga
shotasenga / git-export-diff.sh
Created September 2, 2016 05:03
Git subcommand to export diff
#!/bin/bash
# Git subcommand to export diff
#
# `git export-diff <base> <target>`
# ...or
# `git export-diff <target>` base=HEAD
BASE=$1
TARGET=$2
@shotasenga
shotasenga / git-export-diff.sh
Created September 2, 2016 05:03
Git subcommand to export diff
#!/bin/bash
# Git subcommand to export diff
#
# `git export-diff <base> <target>`
# ...or
# `git export-diff <target>` base=HEAD
BASE=$1
TARGET=$2