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 plistlib, pprint, sys, uuid | |
| with open(sys.argv[1], "rb") as plist: | |
| plist = plistlib.load(plist) | |
| assert plist["$archiver"] == "NSKeyedArchiver" | |
| objs = plist["$objects"] | |
| def decode(val): | |
| if isinstance(val, dict): |
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
| from PIL import Image | |
| def trim(im): | |
| data = list(im.getdata()) | |
| cs = set() | |
| w, h = im.size | |
| for x in range(w): | |
| cs.add(data[x]) | |
| cs.add(data[(h - 1) * w + x]) | |
| for y in range(h): |
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 hashlib, sys, zipfile | |
| with zipfile.ZipFile(sys.argv[1]) as zip: | |
| for filename in sorted(zip.namelist()): | |
| if filename.endswith("/"): | |
| continue | |
| with zip.open(filename) as file: | |
| print(hashlib.file_digest(file, sys.argv[2]).hexdigest(), filename) |
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 struct, sys, zlib | |
| PNG_HEADER = b"\x89PNG\r\n\x1a\n" | |
| for path in sys.argv[1:]: | |
| with open(path, "rb") as png: | |
| png = png.read() | |
| print(path + ":") | |
| if not png.startswith(PNG_HEADER): | |
| print("not a png") |
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 dis, sys | |
| def varnames(): | |
| frame = sys._getframe(1) | |
| instrs = dis.get_instructions(frame.f_code) | |
| instr = next(instr for instr in instrs if instr.offset > frame.f_lasti) | |
| match instr.opname: | |
| case "STORE_FAST" | "STORE_GLOBAL" | "STORE_NAME": | |
| return instr.argval | |
| case "STORE_FAST_LOAD_FAST": |
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
| def sig(fn): | |
| code = fn.__code__ | |
| defaults = fn.__defaults__ | |
| kwdefaults = fn.__kwdefaults__ | |
| if defaults is None: | |
| defaults = () | |
| if kwdefaults is None: | |
| kwdefaults = {} | |
| pos, varnames = code.co_varnames[:code.co_argcount], code.co_varnames[code.co_argcount:] |
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 types | |
| class StaticMethod: | |
| def __init__(self, f): | |
| self.f = f | |
| def __get__(self, instance, owner): | |
| return self.f | |
| class ClassMethod: |
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
| ╭───────╮ | |
| │ Hello │ | |
| ╰───────╯ | |
| ┌───────┐ | |
| │ Hello │ | |
| └───────┘ | |
| ┏━━━━━━━┓ | |
| ┃ Hello ┃ |
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 Lean.Elab.Term | |
| deriving instance Lean.ToExpr for String.Pos | |
| deriving instance Lean.ToExpr for Substring | |
| deriving instance Lean.ToExpr for Lean.SourceInfo | |
| deriving instance Lean.ToExpr for Lean.Syntax | |
| syntax "log! " (interpolatedStr(term) <|> term:arg) : term | |
| @[term_elab termLog!__] |
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
| -- https://arxiv.org/abs/1911.08174 | |
| def T : Prop := ∀ p, (p → p) → p → p | |
| def δ (z : T) : T := fun p η h => η (z (T → T) id id z p η h) | |
| def ω : T := fun _ _ h => propext ⟨fun _ => h, fun _ => id⟩ ▸ δ | |
| def Ω : T := δ ω | |
| noncomputable def WellFounded.fix' {α : Sort u} {r : α → α → Prop} (hwf : WellFounded r) {C : α → Sort v} (F : ∀ x, (∀ y, r y x → C y) → C x) x : C x := | |
| @Acc.rec α r (fun x _ => C x) (fun x _ => F x) x (Ω (∀ x, Acc r x) (fun wf x => ⟨x, fun y _ => wf y⟩) hwf.apply x) | |
| theorem WellFounded.fix'_eq : @WellFounded.fix' α r hwf C F x = F x fun y _ => hwf.fix' F y := rfl |
NewerOlder