ZN Code Saves
20 subscribers
2 photos
2 links
Code snippets and programming notes.

For testing bots and scripts, please join: @botspamdebug

More from ZN: @z_network
Download Telegram
from itertools import permutations
import string
import re
dig = string.digits
pattern = r"^[a-z]((?!__)[\w\d]){3,30}[a-z\d]"
charset = [*string.ascii_lowercase, *dig, '_']
count = 0
for R in range(5,33):
print(R)
for perm in permutations(charset, r=R):
if re.match(pattern, ''.join(perm)):
count += 1
print(count)
Forwarded from drunktimelord
Language:
py3


Source:
print(bin(1)+' Kenobi')


Result:
0b1 Kenobi
Forwarded from Deleted Account
Language:
py3


Source:
class www:
class docs:
class pyrogram:
class org:
pass

print(www.docs.pyrogram.org.__qualname__)


Result:
www.docs.pyrogram.org
Forwarded from Monster Alien
s/^(?:.(?=.+((?(1).\1|.))$))*.\K/|
from datetime import datetime
# https://stackoverflow.com/a/15537393
def remap(x, oMin, oMax, nMin, nMax):
if oMin == oMax:
print("Warning: Zero input range")
return None
if nMin == nMax:
print("Warning: Zero output range")
return None
reverseInput = False
oldMin = min(oMin, oMax)
oldMax = max(oMin, oMax)
if not oldMin == oMin:
reverseInput = True
reverseOutput = False
newMin = min(nMin, nMax)
newMax = max(nMin, nMax)
if not newMin == nMin :
reverseOutput = True
portion = (x-oldMin)*(newMax-newMin)/(oldMax-oldMin)
if reverseInput:
portion = (oldMax-x)*(newMax-newMin)/(oldMax-oldMin)
result = portion + newMin
if reverseOutput:
result = newMax - portion
return result


def main():
min_x = 1
# get max message count
max_x = 85175
min_y = 1.0
# get telegram account creation date
tg_creation = datetime(2017, 8, 1)
# get group creation date
grp_creation = datetime(2019, 6, 3)
max_y = (datetime.now() - (tg_creation if tg_creation>=grp_creation else grp_creation)).total_seconds()
# get current message count in group
x = 11151
# get group join date
y = (datetime.now() - datetime(2019, 6, 3)).total_seconds()
min_sc = -500
max_sc = 500
# x_norm = (x-min_x/max_x-min_x)*(max_sc-min_sc)+min_sc
# y_norm = (y-min_y/max_y-min_y)*(max_sc-min_sc)+min_sc
x_norm = remap(x, min_x, max_x, min_sc, max_sc)
y_norm = remap(y, min_y, max_y, min_sc, max_sc)
credit_score = round(x_norm + y_norm, 3)
print("Your group credit score (between -1000 to 1000) is currently:", credit_score)


main()
Forwarded from Zac
Language:
py3


Source:
import random as r
i=r.randint
c=list('bdfghjklmnprstvwyz')
v=list('aie')
n=len(c)-1
def f():
return ''.join([c[i(0,n)].upper(),v[i(0,2)],c[i(0,n)],v[i(0,2)],c[i(0,n)],v[i(0,2)]])
print(f(),f())


Result:
Nesefi Yepape
Forwarded from Zac
Language:
py3


Source:
mc,ctemp,cmax,current,c=[],[],5,0,0
members=[*'abcdefghijklmn']
while current < len(members):
c=0
for m in members[current:]:
if c==cmax:break
ctemp.append(m)
c+=1
current+=1
mc.append(ctemp)
ctemp=[]
print(mc)


Result:
[['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['k', 'l', 'm', 'n']]
Language:
py3


Source:
def turn_down():return
turn_down_for = \
[turn_down() for wat in range(5)]

print(*turn_down_for, " Batman!", sep='')


Result:
NoneNoneNoneNoneNone Batman!
๐Ÿคก1
Forwarded from Zac
Language:
py3


Source:
from datetime import datetime,timedelta
import math
p,m="โ–“","โ–‘"
n=datetime.now()
st,en=datetime(n.year,1,1), datetime(n.year+1,1,1)-timedelta(days=1)
tot,el=en-st,n-st
pe=(el/tot)*100
elp=int(math.ceil(pe)*0.17)
print(p*elp,m*(17-elp)," ",int(pe),"%",sep="")


Result:
โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 69%
Forwarded from Zac
from datetime import datetime,timedelta
import math
# https://stackoverflow.com/a/15537393
def remap(x, oMin, oMax, nMin, nMax):
if oMin == oMax:
print("Warning: Zero input range")
return None
if nMin == nMax:
print("Warning: Zero output range")
return None
reverseInput = False
oldMin = min(oMin, oMax)
oldMax = max(oMin, oMax)
if not oldMin == oMin:
reverseInput = True
reverseOutput = False
newMin = min(nMin, nMax)
newMax = max(nMin, nMax)
if not newMin == nMin :
reverseOutput = True
portion = (x-oldMin)*(newMax-newMin)/(oldMax-oldMin)
if reverseInput:
portion = (oldMax-x)*(newMax-newMin)/(oldMax-oldMin)
result = portion + newMin
if reverseOutput:
result = newMax - portion
return result


p,m="โ–“","โ–‘"
n=datetime.now()
st,en=datetime(n.year,1,1), datetime(n.year+1,1,1)-timedelta(days=1)
tot,el=en-st,n-st
pe=(el/tot)*100
elp=int(math.ceil(pe)*0.16)
sc_pe= math.ceil(remap(pe, 1, 100, 1, 14000/23))
print("{}{} {}% ({}%)".format(p*elp,m*(16-elp),int(sc_pe),int(pe)))
Forwarded from Deleted Account
Result:
โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘โ–‘โ–‘ 420% (69%)
Forwarded from Jonatan [active currently]
Language:
py3


Source:
def x():
yield (yield (yield))


x = x()
next(x)
print(x.send('a'))


Result:
a
Language:
py3


Source:
input_text = 'hello bobin'
mapped = dict(list(zip(range(65,90), range(0x1F1E6,0x1F1FF)))+[(32,32)])
gen = [chr(mapped[ord(x.upper())]) for x in input_text]
print(*gen,sep='\u200b')


Result:
๐Ÿ‡ญโ€‹๐Ÿ‡ชโ€‹๐Ÿ‡ฑโ€‹๐Ÿ‡ฑโ€‹๐Ÿ‡ดโ€‹ โ€‹๐Ÿ‡งโ€‹๐Ÿ‡ดโ€‹๐Ÿ‡งโ€‹๐Ÿ‡ฎโ€‹๐Ÿ‡ณ
Language:
py3


Source:
input_text = '#hello 123\n bobin!!!   \n:D'
r=range(65,90)
mapped = dict(list(zip(r, range(0x1F1E6,0x1F1FF)))+[(32,32)])
gen = [chr(mapped[ord(x)]) if ord(x) in r else x for x in input_text.upper()]
print(*gen,sep='\u200b')


Result:
#โ€‹๐Ÿ‡ญโ€‹๐Ÿ‡ชโ€‹๐Ÿ‡ฑโ€‹๐Ÿ‡ฑโ€‹๐Ÿ‡ดโ€‹ โ€‹1โ€‹2โ€‹3โ€‹
โ€‹ โ€‹๐Ÿ‡งโ€‹๐Ÿ‡ดโ€‹๐Ÿ‡งโ€‹๐Ÿ‡ฎโ€‹๐Ÿ‡ณโ€‹!โ€‹!โ€‹!โ€‹ โ€‹ โ€‹ โ€‹
โ€‹:โ€‹๐Ÿ‡ฉ
Language:
py3


Source:
male = "โ™‚๏ธ"
female = "โ™€๏ธ"
man = "๐Ÿ’โ€โ™‚๏ธ"
trans = man.translate(man.maketrans(male, female))
neutral = trans[:-3]
print(man, trans, neutral, sep="\n")


Result:
๐Ÿ’โ€โ™‚๏ธ
๐Ÿ’โ€โ™€๏ธ
๐Ÿ’
Language:
py3


Source:
man = '๐Ÿ’โ€โ™‚๏ธ'

_=man.translate

trans = _(\
man.maketrans('โ™‚๏ธ','โ™€๏ธ'))

neutral = trans[:-3]

print(man, trans, neutral)


Result:
๐Ÿ’โ€โ™‚๏ธ ๐Ÿ’โ€โ™€๏ธ ๐Ÿ’
import re
from string import printable as pr

p=pr[10:]+'0123456789'
extra = len(p) % 16
if extra > 0:
p = p + ("\x00" * (16 - extra))
spl = re.findall("(.{1,16})", p, flags=re.DOTALL)[0]

inp = "helloo"

jnd=''.join([str(hex(spl.find(x))).split('x')[1] for x in inp])
spl2= re.findall("(.{2})", jnd, flags=re.DOTALL)
jnd2=''.join([chr(int(x, 16)) for x in spl2])
print('Input text: ', inp, '\nCompressed: ', jnd2, '\nSavings: ', int((len(inp)/len(jnd2))*100), '%', sep='')

djnd=[str(hex(ord(x))).split('x')[1] for x in jnd2]
dcd=[spl[int(x[0],16)]+spl[int(x[1],16)] for x in djnd]
print('Decompressed: ', *dcd, sep='')
Language:
py3


Source:
class Boat():
def __init__(s):pass
@staticmethod
def build():
return " ๐Ÿšฉ\n\___/"

boat = Boat()
print(boat.build())


Result:
  ๐Ÿšฉ
\___/
Language:
py3


Source:
a,x,y,z,j,k,b,m=1,5.5,0,2,3,5,4,0
while y<((a*a)/z+(a*z))*(x*z)*j+k:y+=a;
while m<(b*((a+a)*j*j-a)):m+=b;
print(''.join(map(chr,[int(m*((int(str(k+a)+str(j)+"0")+a)*j+(a/b)))])))


Result:
๐Ÿ›ฅ
๐Ÿ˜ข1
Forwarded from Zac
Language:
py3


Source:
from string import printable
fancy_code = """๐“…๐“‡๐’พ๐“ƒ๐“‰("๐ป๐‘’๐“๐“๐‘œ, ๐“Œ๐‘œ๐“‡๐“๐’น!")"""

d = dict(zip("""๐Ÿข๐Ÿฃ๐Ÿค๐Ÿฅ๐Ÿฆ๐Ÿง๐Ÿจ๐Ÿฉ๐Ÿช๐Ÿซ๐’ถ๐’ท๐’ธ๐’น๐‘’๐’ป๐‘”๐’ฝ๐’พ๐’ฟ๐“€๐“๐“‚๐“ƒ๐‘œ๐“…๐“†๐“‡๐“ˆ๐“‰๐“Š๐“‹๐“Œ๐“๐“Ž๐“๐’œ๐ต๐’ž๐’Ÿ๐ธ๐น๐’ข๐ป๐ผ๐’ฅ๐’ฆ๐ฟ๐‘€๐’ฉ๐’ช๐’ซ๐’ฌ๐‘…๐’ฎ๐’ฏ๐’ฐ๐’ฑ๐’ฒ๐’ณ๐’ด๐’ต""", printable))

exec(''.join([d[x] if x in d else x for x in fancy_code]))


Result:
Hello, world!