Skip to content

Instantly share code, notes, and snippets.

View k2nr's full-sized avatar

Kazunori Kajihiro k2nr

  • KOMOJU by Degica
  • Tokyo
  • 02:06 (UTC +09:00)
View GitHub Profile
@k2nr
k2nr / wa
Created April 8, 2019 13:34
window arrangement
#!/usr/bin/env python3
import subprocess
import os
import argparse
wdir = os.environ["HOME"]+"/.wa"
def get(command):
return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8")
---
- hosts: localhost
connection: local
become: true
vars:
- google_file: /etc/apt/sources.list.d/google-chrome.list
tasks:
- name: base deps
apt: name={{ item }} update_cache=yes
with_items:
@k2nr
k2nr / keybase.md
Created November 17, 2017 08:08
keybase

Keybase proof

I hereby claim:

  • I am k2nr on github.
  • I am k2nr (https://keybase.io/k2nr) on keybase.
  • I have a public key ASCYfKJsYFkLAe0Ur2o4xFZ9kfk3uYkwFmt0d2h8wunqKAo

To claim this, I am signing this object:

# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete # this file and re-run i3-config-wizard(1). #
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
@k2nr
k2nr / .Xmodmap
Last active September 27, 2021 03:27
NixOS configuration for MacBookPro retina 15 early 2012
keycode 97 = grave asciitilde
keycode 132 = grave asciitilde
(ns md5.core
(:require [clojure.core.reducers :as r]
[clojure.string :as s])
(:import [java.security MessageDigest]
[javax.xml.bind DatatypeConverter]))
(defn ^String hexdigest [^String s]
(let [digester (MessageDigest/getInstance "MD5")]
(. digester update (.getBytes s))
(DatatypeConverter/printHexBinary (.digest digester))))
@k2nr
k2nr / gist:8052100
Created December 20, 2013 08:47
ramdisk mysql macOS hombrew
#!/bin/bash
RAMDISK_SIZE=1024 # MB
RAMDISK_BLOCKS=$((2048*$RAMDISK_SIZE))
RAMDISK_ROOT=/Volumes/ramdisk
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://$RAMDISK_BLOCKS` &> /dev/null
mkdir $RAMDISK_ROOT/mysql
unset TMPDIR
@k2nr
k2nr / gist:4276794
Created December 13, 2012 14:44
define memoized function. It's useful for memoized recursion.
(defmacro defmemo
[name & fdecl]
`(def ~name
(memoize (fn ~fdecl))))
@k2nr
k2nr / gist:3092157
Created July 11, 2012 18:22
remove duplicates in javascript
function removeDups(array) {
var obj = {},
len = array.length,
res = [],
i;
for(i=0; i < len; i++) {
obj[JSON.stringify(array[i])] = array[i];
}
@k2nr
k2nr / hack.sh
Created April 1, 2012 05:53 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#