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
print test
@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
@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 / 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 / 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 / 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 / detectNoneType.py
Created February 6, 2014 07:18
NoneTypeの判別
isinstance(None, type(None)) # True
@ami-GS
ami-GS / fastPrime.py
Last active August 29, 2015 13:56
Nまでの素数のリストを出力
import sys
import time
s = time.time()
N = int(sys.argv[1])
prime = [1]*N
prime[0] = 0
prime[1] = 0
@ami-GS
ami-GS / varAccess.py
Created February 14, 2014 09:04
study for variable access
class Var():
x = "x"
_x = "_x"
__x = "__x"
def __init__(self):
self.y = "y"
self._y = "_y"
self.__y = "__y"
@ami-GS
ami-GS / getArgments.py
Last active August 29, 2015 13:56
get arguments of function or method
import inspect
print inspect.getargspec(function)
print inspect.getargspec(Class.method)