duangsuse::Echo
770 subscribers
4.42K photos
135 videos
583 files
6.72K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): a19a0b
Download Telegram
Forwarded from dnaugsuz
ςετυθιοπασδφγηξκλζχψωννμ
ΣΕΡΤΥΘΙΟΠΑΣΔΦΓΗΞΚΛΖΧΨΩΒΝΜ
你们更喜欢哪个希腊字母(
Forwarded from dnaugsuz
Λrrow is a functional companion to Κotlin standard library
Forwarded from dnaugsuz
greekToSimilar = {
"οθσ": 'o',
"υμ": 'u',
"ι": 'l',
"γ": 'y',
"η": 'n',
"κ": 'k',
"χ": 'x',
"ω": 'w',
"ν": 'v'
}
🤔看来需要特殊处理

def singleCharDict(pairs: str):
assert len(pairs) % 2 == 0, "unpaired"
ks, vs = map(lambda i0: [pairs[i] for i in range(i0, len(pairs), 2)], [0, 1])
return dict(zip(ks, vs))

greekSimilar = singleCharDict("lιyγnηkκxχwω")
greekSimilar.update({'o': "οθσ", 'u': "υμ"})


然后再来个火星文生成器……

from random import choice

def huoxin(text): ''.join([ choice(greekSimilar[c]) for c in text if c in greekSimilar ])

好像不行,再来一个……

def let(op, x): return op(x) if x != None else None
def huoxin(text):
chars = [ let(choice, greekSimilar.get(c)) or c for c in text ]
return "".join(chars)


huoxin("Kotlin") #'Kοtιiη'
Forwarded from dnaugsuz
huoxin("Arrow is a functional companion to Κotlin standard library")
#Arrσω is a fμηctiσηaι cοmpaηiθη tσ Κοtιiη staηdard ιibrarγ
def singleCharDict(pairs: str):
assert len(pairs) % 2 == 0, "unpaired"
ks, vs = map(lambda i0: [pairs[i] for i in range(i0, len(pairs), 2)], [0, 1])
return dict(zip(ks, vs))

greekSimilar = singleCharDict("lιyγnηkκxχwω"+"PΡTΤYΥIΙHΗTΓZΖXΧBΒNΝMΜ")
greekSimilar.update({'o': "οθσ", 'u': "υμ", 'E': "ΕΣΞ", 'O': "ΘΟΩ", 'A': "ΑΔΛ"})


from random import choice
def let(op, x): return op(x) if x != None else None

def huoxin(text):
chars = [ let(choice, greekSimilar.get(c)) or c for c in text ]
return "".join(chars)
def mapInputBy(transform, prompt = "> "):
while True:
try: print(transform(input(prompt)))
except KeyboardInterrupt or EOFError: break

def mapLongInputBy(transform, prompt = "» "):
buffer = ""
while True:
try: buffer += input(prompt)+'\n'
except KeyboardInterrupt: break
except EOFError:
print(transform(buffer))
buffer = ""
def reversedMap(map, keys = lambda it: list(iter(it))):
reverseMap = {}
for (k, v) in map.items():
for key in keys(v):
reverseMap[key] = k
return reverseMap

def intoTranslateMap(map): return {ord(k): v for (k, v) in map.items()}

_huoxinBackDict = intoTranslateMap(reversedMap(greekSimilar))
def huoxinBack(text): return text.translate(_huoxinBackDict)
_huoxinDict = intoTranslateMap({choice(k):v for (k, v) in greekSimilar.items()})
def huoxin1(text): return text.translate(_huoxinDict)
In [35]: %timeit huoxinBack("Arrσω is a fμηctiσηaι cοmpaηiθη tσ Κοtιiη staηdard ιibrarγ")
3.77 µs ± 14.8 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [37]: %timeit huoxin("Arrow is a functional companion to Κotlin standard library")
23.1 µs ± 33.1 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

In [39]: huoxin1("Arrow is a functional companion to Κotlin standard library")
Out[39]: 'ΑΔΛrrοθσω is a fυμηctiοθσηaι cοθσmpaηiοθση tοθσ Κοθσtιiη staηdard ιibrarγ'

In [40]: %timeit huoxin1("Arrow is a functional companion to Κotlin standard library")
4 µs ± 8.11 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

In [42]: %timeit huoxin1("Arrow is a functional companion to Κotlin standard library")
4 µs ± 8.54 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
duangsuse::Echo
def singleCharDict(pairs: str): assert len(pairs) % 2 == 0, "unpaired" ks, vs = map(lambda i0: [pairs[i] for i in range(i0, len(pairs), 2)], [0, 1]) return dict(zip(ks, vs)) greekSimilar = singleCharDict("lιyγnηkκxχwω"+"PΡTΤYΥIΙHΗTΓZΖXΧBΒNΝMΜ") gre…
>>> mapLongInputBy(huoxin)
def siηgιeCharDict(pairs: str):
assert ιeη(pairs) % 2 == 0, "μηpaired"
κs, vs = map(ιambda i0: [pairs[i] fσr i iη raηge(i0, ιeη(pairs), 2)], [0, 1])
retυrη dict(zip(κs, vs))

greeκSimiιar = siηgιeCharDict("ιιγγηηκκχχωω"+"ΡΡΓΤΥΥΙΙΗΗΓΓΖΖΧΧΒΒΝΝΜΜ")
greeκSimiιar.μpdate({'σ': "οθσ", 'μ': "υμ", 'Σ': "ΕΣΞ", 'Ω': "ΘΟΩ", 'Δ': "ΑΔΛ"})

frοm raηdοm impοrt chοice
def ιet(σp, χ): retυrη οp(χ) if χ != Νοηe eιse Νθηe

def hυσχiη(teχt):
chars = [ ιet(chθice, greeκSimiιar.get(c)) σr c fοr c iη teχt ]
retυrη "".jθiη(chars)
>>> mapLongInputBy(huoxinBack)
def singleCharDict(pairs: str):
assert len(pairs) % 2 == 0, "unpaired"
ks, vs = map(lambda i0: [pairs[i] for i in range(i0, len(pairs), 2)], [0, 1])
return dict(zip(ks, vs))

greekSimilar = singleCharDict("llyynnkkxxww"+"PPTΤYYIIHHTTZZXXBBNNMM")
greekSimilar.update({'o': "ooo", 'u': "uu", 'E': "EEE", 'O': "OOO", 'A': "AAA"})

from random import choice
def let(op, x): return op(x) if x != None else None

def huoxin(text):
chars = [ let(choice, greekSimilar.get(c)) or c for c in text ]
return "".join(chars)
"自举"了(开个玩笑,定义不正确) 😂 #Python #Haha #tools
Forwarded from Teg
Forwarded from dnaugsuz
🤔 就内容 start_bom() 来看,会不会是什么不好的代码啊
Forwarded from dnaugsuz
哦,弱密码穷举爬虫? ……
而且编写质量还贼烂, "".join(range(0, 9)) 没被定为变量、本来直接 sys.exit() 的非得 global is_exit,infinity loop 里 while 不用 True 还用 1
Forwarded from dnaugsuz
放到 web 安全界,绝对会被当成脚本小子
建议不要使用,去找合适的工具(而且这种爆破成功机会有多少……都拦着弱密码了)
Forwarded from dnaugsuz
顺便提一句,千万别 for c0 in xs: for c1 in xs:
要写就写一个更 general 的 generator 出来:

def flatten2(*iters):
for iter in iters:
for item in iter:
yield item

def combinations(xs, n):
if n == 1: return xs
return map(lambda x: flatten2(iter([x]), combinations(xs[1:], n -1)), xs)


啊好蠢我写不出来(那就写一个非 lazy 版的

def combinations(xs):
if len(xs) == 1: return xs
return [[x] + combinations(xs[1:]) for x in xs]


草好像写不出来了 🤪
太艹了,居然这都不会写…… 🤪
def combinations(items: set):
return [[item] + combinations(items - set([item])) for item in items]

[[1, [2, [3]], [3, [2]]], [2, [1, [3]], [3, [1]]], [3, [1, [2]], [2, [1]]]] 也不对…… a*b 吗……
def combinations(xs):
return [ [x]+combinations(xs[1:]) for x in xs ] if len(xs) != 0 else []

还是不对…… 其实这个是要 flatMap

from itertools import chain

def flatMap(f, xs):
return f(xs[0]) if len(xs) == 1 else chain(f(xs[0]), flatMap(f, xs[1:]))


list(flatMap(lambda c: [c, c.upper()], "abc")) == ['a', 'A', 'b', 'B', 'c', 'C']
好了,我终于记起来最开始是咋组织的程序了……
啊……不对,我想起来了,之前处理的数据结构是 [a, [b1, b2], [c1, c2]] …… 这次的有点区别,不过实际上可以一样处理

def combinations(xs);
return flatMap(lambda x0: [x0+], xs)


def subtractSet(set, item):
newSet = set.copy(); newSet.remove(item)
return newSet

def flatMap(f, xs: iter):
try: return chain(f(next(xs)), flatMap(f, xs))

except StopIteration: return []
list(flatMap(lambda a: [a,a+1], iter([1,2,3])))
== [1, 2, 2, 3, 3, 4]

def combinations(items: set):
return flatMap(lambda item: [item, combinations( subtractSet(items, item) )], items)


……我真是服了,list set 都不是 iter、iter 又没有 copy,算了就此为止吧
This media is not supported in your browser
VIEW IN TELEGRAM