Skip to content

Instantly share code, notes, and snippets.

@matsub
matsub / pre-push
Last active June 5, 2016 11:41
tweet automatically if you have new posts.
#!/bin/sh
# you need to write title in Front Matter of each post like:
# ---
# title: SOME TITLE
# ---
# require:
# https://github.com/shokai/tw
tw_ID="{{ your twitter ID registered in tw }}"
cname="{{ your GitHub Pages' CNAME }}"
@matsub
matsub / add_prefixes.scss
Created March 18, 2016 10:06
SCSS mixin to add vendor prefixes.
$PREFIXES: null, -moz-, -webkit-;
@mixin prefix($property, $value){
@each $prefix in $PREFIXES{
#{$prefix}#{$property}: $value;
}
}
@matsub
matsub / rename.sh
Last active June 19, 2016 06:16
rename bulk files to sequential numbers.
ary=(`ls -1 *.*`);for i in $(seq -w `ls -U1 | wc -l`);do;mv $ary[i] $i"."${ary[$i]##*.};done
@matsub
matsub / clicker.py
Created June 21, 2015 10:52
windows、python用クリッカーです。e(keycode=69)押すと実行/停止の切り替え。waiting中にq(keycode=81)押すと終了。
# coding: utf-8
import sys
import time
from ctypes import windll
user32 = windll.user32
def detector(keycode=69):
# famous
def gcd(a, b):
if b:
return gcd(b, a%b)
return a
# non-recursive
def Gcd(a, b):
while b:
a, b = b, a%b
#!/usr/bin/env python3
# codin: utf-8
# memoizing decorator
def memoize(function):
def _memoize(*args, _cache={}):
if args in _cache:
print('return using cached') # just for logging
return _cache[args]