This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
quick incoming rename script | |
""" | |
import os | |
for f in os.listdir('.'): | |
if not os.path.isdir(f) or '_' in f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as n | |
def s(x):return 1.0/(1+n.exp(-x)) | |
def d(x):return x*(1.0-x) | |
class N: | |
def __init__(self,x,y):self.x,self.y=x,y;self.w1,self.w2,self.o=n.random.rand(self.x.shape[1],4),n.random.rand(4,1),n.zeros(self.y.shape) | |
def f(self):self.l1=s(n.dot(self.x,self.w1));self.o=s(n.dot(self.l1,self.w2)) | |
def b(self):r=n.dot(self.l1.T,(2*(self.y-self.o)*d(self.o)));q=n.dot(self.x.T,(n.dot(2*(self.y-self.o)*d(self.o),self.w2.T)*d(self.l1)));self.w1+=q;self.w2+=r | |
X=n.array([[0,0,1],[0,1,1],[1,0,1],[1,1,1]]);y=n.array([[0],[1],[1],[0]]);a=N(X,y) | |
for i in range(1500):a.f();a.b() | |
print(a.o) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A: | |
def __init__(self): | |
self.b = B() | |
@property | |
def f1(self): | |
return self.b | |
class B: | |
def __init__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
quick incoming rename script 2 | |
""" | |
import os | |
for f in os.listdir('.'): | |
is_file = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 | |
for c in range(int(input())): | |
n = int(input()) | |
a = n | |
for i, d in enumerate(reversed(str(n))): | |
if d == '4': | |
a -= 10 ** i | |
b = n - a | |
print('Case #{0}: {1} {2}'.format(c+1, a, b)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def get_new_message(message): | |
message = message.lower() | |
blindvalues = [ | |
'10', '120', '140', '1450', '150', '1240', '12450', | |
'1250', '240', '2450', '130', '1230', '1340', '13450', | |
'1350', '12340', '123450', '12350', '2340', '23450', '1360', | |
'12360', '24560', '13460', '134560', '13560', | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import crayons | |
import requests | |
PYPI_URL = 'https://pypi.org/pypi/{package_name}/json' | |
homoglyphs = { | |
'a': ['ɑ'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
for f in os.listdir('.'): | |
is_file = False | |
if os.path.isfile(f): | |
is_file = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
def get_bytes(file_name): | |
with open(file_name, 'rb') as f: | |
return [byte for byte in f.read()] | |
out_bytes = list() | |
for a, b in zip(get_bytes(sys.argv[1]), get_bytes(sys.argv[2])): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import marshal, types | |
# >>> def x(): | |
# ... return eval | |
# ... | |
# >>> x()('2+2') | |
# 4 | |
# >>> import marshal | |
# >>> marshal.dumps(x.__code__) | |
# ... |