Skip to content

Instantly share code, notes, and snippets.

@Anton-2
Anton-2 / micropython clang makefile
Created August 2, 2014 17:40
Clang makefile for micropython/unix on mac os
include ../py/mkenv.mk
-include mpconfigport.mk
# define main target
PROG = micropython
# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h
# OS name, for simple autoconfig
@chrisyip
chrisyip / Date Validation Expression.js
Created October 11, 2012 09:09
A regular expression that validates date.
var re = /^(\d{4})[-\/\.]{0,1}(?:(?:(11|0?[469])[-\/\.]?([12]\d|30|0?[1-9]))|(?:(1[02]|0?[13578])[-\/\.]{0,1}([1-2]\d|3[01]|0?[1-9]))|(?:(0?2)[-\/\.]{0,1}(2[1-9]|1\d|0?[1-9])))$/;
// test
[
// valid dates
'2012-4-21',
'2012-04-21',
'2012-5-1',
'2012-05-31',
'2012-11-21',
@jamiesun
jamiesun / batch2utf8.py
Created July 19, 2012 10:36
批量转换一个目录下的文件到utf8
#!/usr/bin/python
#codeing:utf-8
import os
from optparse import OptionParser
if __name__ == "__main__":
usage = "usage: %prog [options] arg"
parser = OptionParser(usage)
@falcondai
falcondai / mp3_tag.py
Created May 2, 2012 17:36
This module provides MP3 tags conversion from any (python-supported) encoding to UTF-8.
# File: mp3_tag.py
#
# Description: This module provides MP3 tags correction, i.e. from
# any encoding X to UTF-8, the standard across different apps
# and platforms. The default parameters target the common Chinese
# encoding GBK.
#
# Features: 1. it recursively handles MP3 files > 512KB in all subdirectories.
# 2. outputs a log formatted to show the directory structure
# with failures (decoding/encoding error, the field will be
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@rslinckx
rslinckx / principal.py
Created October 14, 2010 20:49
Suggested improvements of Flask-Principal
import logging
log = logging.getLogger(__name__)
from functools import wraps
from flask import session, request, g
from flaskext.principal import Principal as RealPrincipal, identity_loaded, Identity, AnonymousIdentity
__all__ = ['Principal']