Skip to content

Instantly share code, notes, and snippets.

View SharzyL's full-sized avatar

Sharzy SharzyL

  • Hua University
  • Beijing, China
  • 03:35 (UTC +08:00)
View GitHub Profile
@SharzyL
SharzyL / mew.asm
Created September 22, 2019 06:30
A self-copying program using a simple machine language
| LOAD: ;load some consts
0x00 | load (const1), 1
0x02 | load (span), 0x70
0x04 | load (code-start), 0 #
0x06 | load (data-offset), 0x3C
0x08 | load (code-len), 0x46
0x0A | load (data-len), 0x0A
|
| COPY_LOOP: ;copy current code to 0x70
0x0C | mov (code-start), (crnt-addr)
@SharzyL
SharzyL / permute.py
Last active April 14, 2020 09:40
A calculator for permutation
from functools import total_ordering
from typing import *
_PermutationRingTermSubType = Union['Permutation', 'PermutationRingTerm']
_PermutationRingSubType = Union['Permutation', 'PermutationRingTerm', 'PermutationRing']
_CoType = Union[int, float] # type of coefficient in group ring
_MultiplierType = Union[_PermutationRingSubType, _CoType]
def _check_co_type(_o: Any) -> bool:

Keybase proof

I hereby claim:

  • I am sharzyl on github.
  • I am sharzy (https://keybase.io/sharzy) on keybase.
  • I have a public key whose fingerprint is FCC0 1E57 6D77 32FF 264B DE53 C929 DD40 7793 44DF

To claim this, I am signing this object:

@SharzyL
SharzyL / gate.nb
Last active September 5, 2020 08:59
A Mathematica script to calculate the matrix representation of quantum gate.
depth = 3;
gate[func_] := Table[Flatten[func @@ IntegerDigits[l, 2, depth]], {l, 0, 2^depth - 1}];
v[i_] := If[EvenQ[i], {1, 0}, {0, 1}];
h[i_] := 1/Sqrt[2] (v[0] + (1 - 2 i) v[1]);
t[i_] := If[EvenQ[i], v[0], E^(I \[Pi]/4) v[1]];
tc[i_] := If[EvenQ[i], v[0], E^(-I \[Pi]/4) v[1]];
s[i_] := If[EvenQ[i], v[0], I v[1]];
gates = {
gate[TensorProduct[v[#1], v[#2], h[#3]] &],
@SharzyL
SharzyL / trigesimal.py
Last active August 9, 2021 07:56
30-hour clock is good, so display it on your i3bar
# A simple py3status module to display datetime on your i3bar as if there are 30 hours every day
# Usage: store this file as ~/.config/py3status/modules/trigesimal.py (or in directory storing
# py3status modules), then append `order += 'trigesimal'` to your py3status config file
# Timezone and locale setting is left to the user as a beneficial exercise.
import datetime
class Py3status:
@SharzyL
SharzyL / crawl.py
Last active June 6, 2021 03:47
Telegram Relation Graph
# requirements: telethon, networkx, python-pysocks[asyncio], pygraphviz, tqdm
from telethon.client import TelegramClient
from telethon.tl.types import User as TgUser, Channel as TgChannel, Chat as TgChat
import telethon
import asyncio
import networkx as nx
from tqdm import tqdm
import pickle