Skip to content

Instantly share code, notes, and snippets.

View qiuyuzhou's full-sized avatar

Qiu Yuzhou qiuyuzhou

  • ShenZhen, China
View GitHub Profile
@qiuyuzhou
qiuyuzhou / update_potatso_rules.py
Last active December 30, 2018 15:22
Download latest gfwlist.txt then convert it to potatso rules config file. Python3
# -*- coding: utf-8
__author__ = 'Charlie Qiu <qbowater@gmail.com>'
import logging
import urllib.parse
import base64
import os
import requests
import yaml
from django.conf import settings
@qiuyuzhou
qiuyuzhou / netutil.go
Last active September 5, 2015 07:10
Write/Read string to io.Writer/Reader with length header
package core
import "io"
import "encoding/binary"
import "bufio"
func WriteString(writer io.Writer, s string) (err error) {
l := len(s)
if l < 128 {
err = binary.Write(writer, binary.BigEndian, byte(l))
@qiuyuzhou
qiuyuzhou / gist:f04b30f12dc0e3b11f32
Created July 28, 2014 02:30
Timeout Cache decorator
# -*- coding: utf-8
__author__ = 'Charlie Qiu <qbowater@gmail.com>'
import time
class TTLCache(object):
_caches = {}
_timeouts = {}
# -*- coding: utf-8
__author__ = 'Charlie Qiu <qbowater@gmail.com>'
"""
A implementation of singleton from stackoverflow.
http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern
Example:
@Singleton
@qiuyuzhou
qiuyuzhou / gist:0bcfe16586f174c73a96
Last active August 29, 2015 14:02
Get identifier For Vendor on iOS
NSString *idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
@qiuyuzhou
qiuyuzhou / signals.lua
Created January 17, 2014 05:36
signal/slot
module('signals',package.seeall)
local oo = require "loop.base"
Signal = oo.class{
name = '',
slots = {}
}
@qiuyuzhou
qiuyuzhou / gist:84fab254b82dff9416f0
Created January 13, 2014 09:17
Helper functions for using cocos2dx actions in lua coroutine.
-- 使用CCSequence将多个action串起来
function sequenceActions(...)
local actions = { ... }
if #actions == 1 then
return actions[1]
end
local pre_action = actions[1]
for i = 2, #actions do
pre_action = CCSequence:createWithTwoActions(pre_action, actions[i])
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LevelEditor
{
public sealed class Singleton<T> where T: new()
{
@qiuyuzhou
qiuyuzhou / greenlet.lua
Last active December 21, 2015 21:09
Wrap and patch lua coroutine module in order to add coroutine.kill which is similar to g.throw in python greenlet.
module('greenlet',package.seeall)
local _resume = coroutine.resume
local _yield = coroutine.yield
local _create = coroutine.create
local _wrap = coroutine.wrap
function create(func)
function f(is_kill,...)