Skip to content

Instantly share code, notes, and snippets.


laike9m laike9m

View GitHub Profile
laike9m /
Created May 31, 2020
Checks whether the current Python interpreter has computed gotos enabled
# This file is for detecting whether the current interpreter has enabled computed gotos.
# See for details.
import sys
def global_tracer(frame, event_type, arg):
assert event_type == "call"
print(f"computed gotos enabled: {frame.f_back.f_lasti == 40}") # Win: 38, Mac, Linux: 40
laike9m /
Last active May 24, 2020
Mili - sustain++; (ending ver.) / Ghost In The Shell: SAC_2045 Ending
* The goal of this program is to obtain a HEALTHY
* and SUSTAINABLE relationship, darling.
* @author Cassie Wei from Mili
public class sustainPlusPlus {
public static void main(String[] args) {
World world = new World();
Life me = new Ghost();
laike9m /
Created Nov 18, 2019
Basic Calculator III
class Solution:
@param s: the expression string
@return: the answer
def calculate(self, s):
i = 0
left_brac_indexes = []
while i < len(s):
View raw string
Raw string 是个通用概念。即 escape 不生效的 string,既然不生效,也无法 escape 掉 ending sequence。
所有语言的 raw string 都面临一个问题,即如何处理 ending sequence
staring sequence: “ or '
ending sequence: “ or '
Python 的做法是允许 ‘, “ 出现,但需要用 \ escape 掉它们(相当于在 Python raw string里有唯一生效的escape就是\”和\’),并且 \ 依然会出现
View dot
digraph "Cyberbrain Output" {
graph [forcelabels=true];
node [label="\N"];
subgraph "cluster_(0, 0, 0)" {
graph [color=lightgrey,
label="(0, 0, 0)",
node [color=white,
# Tests how EXTENDED_ARG works
import bytecode
import dis
import sys
from bytecode import ConcreteInstr, ConcreteBytecode
CONST_ARG = 0x1234567 # The real argument we want to set.
cbc = bytecode.ConcreteBytecode()
cbc.consts = [None] * (CONST_ARG + 1) # Make sure co_consts is big enough.
laike9m /
Created May 28, 2019
Record call arguments by manually recording VM stack.
import dis
import sys
def g(x, y):
# Code that analyzes outer frame to get passed in arguments.
outer_frame = sys._getframe(1)
instructions = list(dis.get_instructions(outer_frame.f_code))
call_start_offset = None
def xxxx(ph, sin_id):
with OracleConnect(xxxx) as db_oracle:
sql = u"xxxxx"
has_data, sql_data = db_oracle.get_one(sql)
if has_data:
return sql_data.get("task_id", ""), "rollback"
return sin_id, "calculate"
with freeze_time(datetime.datetime(2016, 2, 10, tzinfo=pytz.timezone('US/Pacific'))):
from mymodule import date_manager
class _DateManager(object):
def __init__(self):
self._today ='US/Pacific'))
View 百度网盘加速(北京)
You can’t perform that action at this time.