This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// N x repeated characters | |
const LEN = process.argv.length > 2 ? parseInt(process.argv[2]) : 4 | |
console.log('LEN: ' + LEN) | |
function check(s) { | |
let i = s.length - LEN | |
const p = s.charAt(i) | |
for (i++; i<s.length; i++) { | |
if (p != s.charAt(i)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
var view, viewModel, valueTemplate; | |
valueTemplate = { | |
configurable: false, | |
enumerable: true, | |
get: function () { | |
return this._value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# observable | |
# observer | |
# reaction | |
# derivation | |
import time | |
from typing import Callable | |
from collections import defaultdict | |
from attr import attrib, attrs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
导出数据 | |
~~~~~~~~~~~~~ | |
反序列化数据列,支持字符,数组,字典等复杂结构, | |
TODO: | |
- 数据类型标注: string,bool,int,float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mapper = function() { | |
const value = { | |
country: this.country, | |
province: this.province, | |
city: this.city, | |
region: this.region, | |
wifi: this.wifi, | |
app_version: this.app_version, | |
os_version: this.os_version, | |
os: this.os, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import random | |
def id_generator(size=64, chars=string.ascii_uppercase + string.digits): | |
return ''.join(random.choice(chars) for _ in range(size)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import User | |
from django.db.models.signals import post_save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
NewerOlder