Skip to content

Instantly share code, notes, and snippets.

View lepture's full-sized avatar
💭
I'm working on Typlog.com now

Hsiaoming Yang lepture

💭
I'm working on Typlog.com now
View GitHub Profile
@lepture
lepture / cordova-bridge.js
Created November 24, 2014 06:28
Use xhr mode.
var exec = cordova.require('cordova/exec');
exec.setJsToNativeBridgeMode(exec.jsToNativeModes.XHR_OPTIONAL_PAYLOAD);
@lepture
lepture / weibo.m
Last active August 29, 2015 14:10
test weibo
@import Social;
@import Accounts;
- (void)testWeibo {
BOOL isWeiboAvailable = [SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo];
NSLog(@"isWeiboAvailable:%d", isWeiboAvailable);
if (isWeiboAvailable) {
var protocol = document.location.protocol === 'https:' ? 'https:' : 'http:';
var ds = document.createElement('script');
ds.type = 'text/javascript';
ds.async = true;
ds.src = protocol + '//static.duoshuo.com/embed.js';
document.getElementsByTagName('head')[0].appendChild(ds);
module.exports = function(cb) {
import time
j = range(100000)
def test_plus():
out = ''
for i in j:
out += 'a'
return out
# coding: utf-8
import mistune
text = '''hello world
* list item 1
* list item 2
here is a [link](http://lepture.com/)
@lepture
lepture / iconify
Created October 23, 2014 06:52
replace icon for mac application and folder
#!/bin/bash
BIN=/Applications/Xcode.app/Contents/Developer/Tools/
DeRez=$BIN/DeRez
Rez=$BIN/Rez
iconify() {
ICON="$1"; FOLDER="$2"
if [[ -f $ICON && -d $FOLDER ]]; then
TMP_DIR=$(mktemp -d -t iconify)
@lepture
lepture / subpath_wsgi.py
Last active August 29, 2015 14:04
subpath for wsgi
# coding: utf-8
from flask import Flask
from werkzeug.wsgi import pop_path_info, peek_path_info
from werkzeug.serving import run_simple
app = Flask(__name__)
class PathDispatcher(object):
@lepture
lepture / random.js
Created February 12, 2014 10:36
Random a choice.
function random(obj) {
var keys = Object.keys(obj)
var choice = keys[Math.floor(Math.random() * (keys.length + 1))];
return obj[choice]
}
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
import time
import hmac
import hashlib
import json
from base64 import urlsafe_b64encode
def create_token(access_key, secret_key, scope):
deadline = int(time.time()) + 50000