Skip to content

Instantly share code, notes, and snippets.


BBB yxy

  • gggg
View GitHub Profile
yxy /
Created Oct 11, 2018
- 数据类型标注: string,bool,int,float
yxy / mapper.js
Created Apr 21, 2018
mongodb map reduce advantage usage.
View mapper.js
const mapper = function() {
const value = {
province: this.province,
region: this.region,
wifi: this.wifi,
app_version: this.app_version,
os_version: this.os_version,
os: this.os,
yxy /
Created Feb 12, 2018
random string
import string
import random
def id_generator(size=64, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
yxy /
Created Feb 7, 2018
django 事件信号
from django.dispatch import Signal
# 注册
user_created = Signal(providing_args=['user', 'app_id'])
# 更新
user_updated = Signal(providing_args=['user', 'app_id'])
# 登录
user_logged = Signal(providing_args=['user', 'ip', 'app_id'])
# 登出
user_logout = Signal(providing_args=['user', 'ip', 'app_id'])
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
yxy /
Created Sep 9, 2017 — forked from mgerring/
"Export to CSV" action for django admin
import unicodecsv
from django.http import HttpResponse
def export_as_csv_action(description="Export selected objects as CSV file",
fields=None, exclude=None, header=True):
This function returns an export csv action
'fields' and 'exclude' work like in django ModelForm
'header' is whether or not to output the column names as the first row
yxy / gist:b1fd18f84a925c6afc94577dcce9c70d
Created Jul 19, 2017 — forked from ymotongpoo/gist:1342656
extract AAC audio from flv, and convert aac to mp3 using ffmpeg
View gist:b1fd18f84a925c6afc94577dcce9c70d
# using libfaac on Mac OS X 10.6.8
# -vn : not copying video
# -acodec : specify codec used in flv file
# -ac : channels. 1 is for mono, 2 is for stereo
# -ab : specify bitrate for output file (note that rate is not kbps but bps)
# -ar : sampling frequency (Hz)
# -threads: number of threads for encoding
# "-strict experimental" is necessary to use libfaac
ffmpeg -y -i xxxxxxxxxxx.flv -vn -acodec aac -ac 2 -ab 128000 -ar 44100 -threads 4 -strict experimental xxxxx.m4a
yxy /
Last active Apr 9, 2021
Railway Oriented Programming in python. inspired by
class Success(object):
def __init__(self, value):
self.value = value
class Error(object):
def __init__(self, value):
self.value = value
class wrapper(object):
def __init__(self, result):
yxy /
Created Sep 21, 2016
Generic Maximum or Minimum Heap implemenation
class Heap(object):
def __init__(self, test_func):
self._data = []
self._pos = 0
self.test_func = test_func
def size(self):
return self._pos
def add(self, val):
yxy /
Last active Aug 11, 2016
White Falcon And Tree Problem
# TODO: this program too slow, got be some nice solution. :(
# some graph related knownledge
def f(node, x):
return node[0] * x + node[1]
paths = {}
def cache(fn):
def _(u, v, *args, **kwargs):