Skip to content

Instantly share code, notes, and snippets.

View hitsumabushi's full-sized avatar

hitsumabushi hitsumabushi

  • Tokyo, Japan
View GitHub Profile
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 ---
package main
import (
"time"
"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
)
func main() {
@hitsumabushi
hitsumabushi / setup.sh
Last active August 29, 2015 14:22
Initial Setup Shell
# Install basic packages
sudo apt-get update
sudo apt-get install zsh vim git curl wget
# pyenv installer
sudo apt-get install libreadline-dev libbz2-dev libsqlite3-dev
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
#!/usr/bin/python
# -*- coding: utf-8 -*-.
import exceptions
import requests
import tempfile
from bs4 import BeautifulSoup
def main():
module = AnsibleModule(
@hitsumabushi
hitsumabushi / gist:8496cee5decf22f39585
Created June 24, 2015 11:52
doctestでprint文を無視する場合の例
x = 0
def f():
""" 適当にTrueが返る
>>> sys.stdout.write("magic comment:"); f() # doctest:+ELLIPSIS
magic comment:...
True
"""
for s in range(0, 2):
@hitsumabushi
hitsumabushi / example.py
Created August 10, 2015 17:32
example of parsimonious
from parsimonious.grammar import Grammar
conf = """diag read interface-id 1
enable
!
interfae vlan 1
!
interface ip hoo
interface id
interface route
@hitsumabushi
hitsumabushi / basic.ps1
Last active September 4, 2015 12:25
Windows update
Param([string]$interfaceName, [string]$ip, [int]$prefixLength, [string]$gateway, [string[]]$dnsServers, [string]$serverName, [string]$ntpServer)
# Utility functions
function SetIPAddress ([string]$interfaceName, [string]$ip, [int]$prefixLength, [string]$gateway){
Get-NetAdapter $interface | New-NetIPAddress -IPAddress $ip -PrefixLength $prefixlength -DefaultGateway $gateway
}
function SetDNS ([string]$interface, [string[]]$dnsServers){
Get-NetAdapter $interface | Set-DnsClientServerAddress -ServerAddresses $dnsServers
}
function DisableIPv6 ([string]$interface) {
@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