Skip to content

Instantly share code, notes, and snippets.

View hitsumabushi's full-sized avatar

hitsumabushi hitsumabushi

  • Tokyo, Japan
View GitHub Profile
package main
import (
"time"
"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
)
func main() {
@hitsumabushi
hitsumabushi / gist:96af3e99bb5efe2676f9
Created April 5, 2015 06:21
pyenv&virtualenv for zsh
# For zshrc setting
echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.zshrc
echo 'if [ -d "${PYENV_ROOT}" ]; then' >> ~/.zshrc
echo ' export PATH=${PYENV_ROOT}/bin:$PATH' >> ~/.zshrc
echo ' eval "$(pyenv init -)"' >> ~/.zshrc
echo 'fi' >> ~/.zshrc
exec $SHELL -l
# Install pyenv & virtualenv
@hitsumabushi
hitsumabushi / boot.cfg
Created January 7, 2015 00:10
esxi kickstart
bootstate=0
title=Loading ESXi installer
prefix=/esxi50/
kernel=tboot.b00
#kernelopt=runweasel
modules=b.b00 --- useropts.gz --- k.b00 --- a.b00 --- ata-pata.v00 --- ata-pata.v01 --- ata-pata.v02 --- ata-pata.v03 --- ata-pata.v04 --- ata-pata.v05 --- ata-pata.v06 --- ata-pata.v07 --- block-cc.v00 --- ehci-ehc.v00 --- s.v00 --- weaselin.i00 --- ima-qla4.v00 --- ipmi-ipm.v00 --- ipmi-ipm.v01 --- ipmi-ipm.v02 --- misc-cni.v00 --- misc-dri.v00 --- net-be2n.v00 --- net-bnx2.v00 --- net-bnx2.v01 --- net-cnic.v00 --- net-e100.v00 --- net-e100.v01 --- net-enic.v00 --- net-forc.v00 --- net-igb.v00 --- net-ixgb.v00 --- net-nx-n.v00 --- net-r816.v00 --- net-r816.v01 --- net-s2io.v00 --- net-sky2.v00 --- net-tg3.v00 --- ohci-usb.v00 --- sata-ahc.v00 --- sata-ata.v00 --- sata-sat.v00 --- sata-sat.v01 --- sata-sat.v02 --- sata-sat.v03 --- scsi-aac.v00 --- scsi-adp.v00 --- scsi-aic.v00 --- scsi-bnx.v00 --- scsi-fni.v00 --- scsi-hps.v00 --- scsi-ips.v00 --- scsi-lpf.v00 --- scsi-meg.v00 --- scsi-meg.v01 --- scsi-meg.v02 ---
import fcntl, struct, socket
def getHwAddr(ifname):
'Return MAC address of given NIC'
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
info = fcntl.ioctl(s.fileno(), 0x8927,
struct.pack('256s', bytes(ifname[:15], 'ascii')))
return ''.join(['%02x:' % char for char in info[18:24]])[:-1]
except OSError:
@hitsumabushi
hitsumabushi / default
Last active September 21, 2020 09:12
Preseed Files : working with Wheezy & Ubuntu 14.04
# D-I config version 2.0
default debian/7.4/amd64/boot-screens/vesamenu.c32
prompt 1
timeout 300
menu title - Boop Menu -
label Debian-7.4
menu label ^0 Debian 7.4
#include debian/7.4/amd64/boot-screens/menu.cfg
kernel debian/7.4/amd64/linux
@hitsumabushi
hitsumabushi / default
Last active September 8, 2020 13:32
PXE install
# pxelinux.cfg/default file
default debian/7.4/amd64/boot-screens/vesamenu.c32
prompt 1
timeout 300
menu title - Boop Options Menu -
label Debian-7.4
menu label ^0 Debian 7.4
#include debian/7.4/amd64/boot-screens/menu.cfg
kernel debian/7.4/amd64/linux
@hitsumabushi
hitsumabushi / sugoih_Osaka_1.hs
Created November 11, 2012 07:43
すごいH本読書会 in 大阪 #1 問題
-- ガードを使わないことにしてみる。
-- map, filter,fold も使わない.
-- いくつかの関数の実装
-- null, sum, product, elem
null' :: [a] -> Bool
null' [] = True
null' _ = False
-- sum と product 書くのめんどくさいので。
@hitsumabushi
hitsumabushi / euler21.py
Created August 12, 2012 02:21
Dayly programing (Project Euler:#21)
#/usr/bin/python3
from math import sqrt
def d(n):
sum = 1
sq = int(sqrt(n))
for s in range(2, sq + 1):
if n % s == 0:
sum += s + int(n/s)
@hitsumabushi
hitsumabushi / euler20.py
Created August 10, 2012 22:25
Dayly programing (Project Euler:#20)
#!/usr/bin/python
from math import factorial
def digit_sum(num,sum=0):
if num > 0:
num,sum = int(num / 10), sum + (num % 10)
return digit_sum(num,sum)
else:
return sum
@hitsumabushi
hitsumabushi / euler18.py
Created August 9, 2012 20:00
Dayly programing (Project Euler:#18)
#/usr/bin/python
triangle = []
a = """75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34