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
#! /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.
@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]
}
@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):
# coding: utf-8
import mistune
text = '''hello world
* list item 1
* list item 2
here is a [link](http://lepture.com/)
import time
j = range(100000)
def test_plus():
out = ''
for i in j:
out += 'a'
return out
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) {
@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) {
@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 / slack-logger.py
Created December 15, 2014 07:24
Send logging to slack by webhook
# coding: utf-8
import json
import logging
import requests
class SlackHandler(logging.Handler):
def __init__(self, url, channel, username='error', emoji='scream'):
super(SlackHandler, self).__init__()
#!/usr/bin/env python
import os
import re
import sys
import json
import requests
def parse_junit(filepath):