Skip to content

Instantly share code, notes, and snippets.

View hitsumabushi's full-sized avatar

hitsumabushi hitsumabushi

  • Tokyo, Japan
View GitHub Profile
@hitsumabushi
hitsumabushi / euler10.py
Created August 1, 2012 15:34
Dayly programing (Project Euler:#10)
#/usr/bin/python
import math
def is_prime(x):
if x < 0:
x = -x
if x < 2:
return False
# check the case: x=2,3
if x % 2 == 0:
@hitsumabushi
hitsumabushi / euler13.py
Created August 4, 2012 06:50
Dayly programing (Project Euler:#13)
ans = 0
arr = """37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
89261670696623633820136378418383684178734361726757
28112879812849979408065481931592621691275889832738
44274228917432520321923589422876796487670272189318
47451445736001306439091167216856844588711603153276
@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
@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 / 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 / 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 / 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 / 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
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 / 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 ---