Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
open -a iTerm "$SRCROOT"
@usami-k
usami-k / enable-pam_tid.sh
Last active September 27, 2023 23:56
Touch ID で sudo の利用を許可する
#!/bin/zsh
test -f /etc/pam.d/sudo_local && exit 0
test -f /usr/lib/pam/pam_tid.so.2 || exit 1
if ! grep -Eq '^auth\s.*\spam_tid\.so$' /etc/pam.d/sudo; then
pam_sudo=$(awk 'fixed||!/^auth /{print} !fixed&&/^auth/{print "auth sufficient pam_tid.so";print;fixed=1}' /etc/pam.d/sudo)
sudo tee /etc/pam.d/sudo <<<"$pam_sudo"
fi
@usami-k
usami-k / numbers_into_words.hs
Created November 2, 2016 12:19
Haskell Programming from first principles : Chapter 8 : Exercise
import Data.List (intersperse)
digitToWord :: Int -> String
digitToWord 0 = "zero"
digitToWord 1 = "one"
digitToWord 2 = "two"
digitToWord 3 = "three"
digitToWord 4 = "four"
digitToWord 5 = "five"
digitToWord 6 = "six"
@usami-k
usami-k / Stream.hs
Created November 4, 2015 12:23
4.2.1 生産者の流量制限
{-# LANGUAGE BangPatterns, CPP #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fwarn-unused-imports #-}
-- -Wall
-- A module for stream processing built on top of Control.Monad.Par
-- (In the future may want to look into the stream interface used by
-- the stream fusion framework.)
module Stream
@usami-k
usami-k / sugoih2-16.5.md
Created May 13, 2015 10:17
すごいHaskell読書会 in 大阪 2週目 #16.5
@usami-k
usami-k / collatz.hs
Created November 19, 2014 12:05
Project Euler 14問目「最長のコラッツ数」
collatz :: Integer -> [Integer]
collatz 1 = [1]
collatz n = n : (collatz $ collatzNext n)
where
collatzNext :: Integer -> Integer
collatzNext n | even n = n `div` 2
collatzNext n | odd n = 3 * n + 1
collatzLength :: Integer -> Int
collatzLength n = length $ collatz n
@usami-k
usami-k / sudden.hs
Last active August 29, 2015 14:06
すごいHaskell読書会 課題回答 https://atnd.org/events/55693
import Data.Char
charLength :: Char -> Int
charLength x
| isAscii x = 1
| otherwise = 2
asciiLength :: String -> Int
asciiLength "" = 0
asciiLength (x:xs) = charLength x + asciiLength xs
@usami-k
usami-k / generate_xcassets.sh
Last active December 30, 2015 05:39
Create xcassets from image files for Xcode 5 : http://qiita.com/usamik26/items/c0c0559b6d66aa8e3bff
#!/bin/sh
create_imagesets() {
for file in * ; do
if [ -f $file ] ; then
file_base=${file%.*}
imageset_base=${file_base%~iphone}
imageset_base=${file_base%~ipad}
imageset_base=${imageset_base%@2x}
dir=$imageset_base".imageset"
@usami-k
usami-k / simplify_shortcut_name.reg
Created August 31, 2012 01:12
MS Windows XP : Simplify shortcut name
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"link"=hex:00,00,00,00
@usami-k
usami-k / CapsLock_as_Ctrl.reg
Created July 19, 2012 07:06
MS Windows XP : Make CapsLock key an additional Ctrl key
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00