Skip to content

Instantly share code, notes, and snippets.

View ausaki's full-sized avatar
🎯
Focusing

jamielu ausaki

🎯
Focusing
View GitHub Profile
@ausaki
ausaki / stun_client.py
Created July 22, 2023 15:53
A STUN clinet
import os
import socket
import struct
from typing import Any
"""
ref: https://gfiber.googlesource.com/vendor/google/platform/+/master/cmds/stun.py
"""
@ausaki
ausaki / chatpdf-zh.ipynb
Created March 27, 2023 14:51 — forked from ninehills/chatpdf-zh.ipynb
ChatPDF-zh.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ausaki
ausaki / per.py
Created March 19, 2019 07:03
这个问题的解法:https://www.v2ex.com/t/546059
import itertools
def solution(items):
print(items)
for i in range(len(items)):
positions = list(range(len(items)))
positions.remove(i)
# print('pos', positions)
for j in range(1, len(items)):
for pers in itertools.combinations(positions, j):
from selectors import DefaultSelector, EVENT_READ, EVENT_WRITE
import socket
class Future:
def __init__(self):
self.result = None
self.callbacks = []
def set_result(self, result=None):
self.result = result
@ausaki
ausaki / metaclass_test.py
Last active August 17, 2018 02:33
metaclass_test.py
class MyMetaClass(type):
def __init__(cls, name, bases, attrs):
"""
initial class after __new__
"""
print '__init__ in the metaclass'
print 'cls:', cls
print 'name:', name
print 'bases:', bases
@ausaki
ausaki / global_context.py
Created August 9, 2018 07:45
global context, thread local
from thread import get_ident
from threading import RLock, Thread
class GlobalContext(object):
def __init__(self):
self._rlock = RLock()
self._store = {}
def _lock(self):
# -*- coding: utf8 -*-
"""
source:https://github.com/donnemartin/system-design-primer/blob/master/solutions/object_oriented_design/lru_cache/lru_cache.ipynb
"""
class Node(object):
def __init__(self, key, val):
self.key = key
@ausaki
ausaki / setup_zsh.centos.sh
Last active May 10, 2018 02:20
setup zsh shell script for CentOS
yum install -y zsh git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# ZSH_THEME="amuse"
# plugins=(
# zsh-autosuggestions
# )
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
@ausaki
ausaki / getResourceLinksOfZimuzu.user.js
Last active July 11, 2016 11:36
获取字幕组资源下载链接(javascript)
// ==UserScript==
// @name Zimuzu
// @namespace zimuzu
// @include http://www.zimuzu.tv/resource/list/*
// @version 1
// @grant none
// allow pasting
// ==/UserScript==
Zimuzu = function(){
@ausaki
ausaki / re_for_zimuzu.tv
Last active February 29, 2016 03:52
字幕组(http://www.zimuzu.tv) 资源下载页面匹配下载链接的正则表达式
(?s)<li [^<]*format="1080P" season="8"[^<]*>.*?<a href="(ed2k.*?)">.*?</li>