Skip to content

Instantly share code, notes, and snippets.

View ami-GS's full-sized avatar
🎯
Focusing

Daiki AMINAKA ami-GS

🎯
Focusing
View GitHub Profile
@ami-GS
ami-GS / detectNoneType.py
Created February 6, 2014 07:18
NoneTypeの判別
isinstance(None, type(None)) # True
@ami-GS
ami-GS / print.py
Created February 2, 2014 13:40
Difference between python2.x and python3.x
print("abcd", end=" ")#print "abcd" ,#2
print("efgh")#print "efgh"
string = u'ぱいそん'
print(string)#エラー
string = 'ぱいそん'
print(string)#
@ami-GS
ami-GS / compressString.py
Created January 29, 2014 01:21
the way to compress string data
import zlib
s = """
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
@ami-GS
ami-GS / calcE.py
Created January 24, 2014 14:05
高精度の10進数演算と小数点以下の長さ決定
from decimal import *
getcontext().prec = 1000000#表示したい桁 デフォルトは28
N = 100
print (Decimal(1) + Decimal(1) / Decimal(N)) ** Decimal(N)
# or more precisely
@ami-GS
ami-GS / getIP.py
Created January 24, 2014 09:25
ローカルIPアドレスとグローバルIPアドレスが知りたいとき
import urllib
import socket
def getLocalIP():
return socket.gethostbyname(socket.gethostname())
def getGrobalIP():
sock = urllib.urlopen("http://ipcheck.ieserver.net/")
ip = sock.read()
sock.close()
@ami-GS
ami-GS / initEpsBB.sh
Created January 16, 2014 07:37
LaTeXでeps画像を使いPDFにすると画像がズレる原因を修正
#!/bin/sh
for FILE in *eps
do
IN=${FILE%.eps}
ps2pdf -dEPSCrop -dPDFSETTINGS=/prepress $IN.eps $IN.pdf
pdf2ps $IN.pdf $IN.eps
rm $IN.pdf
done
print test