Skip to content

Instantly share code, notes, and snippets.

View bcho's full-sized avatar
💍
一起来发财吧!Let's make some money!

hbc bcho

💍
一起来发财吧!Let's make some money!
View GitHub Profile
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()
/**
* Simple userland CPU profiler using v8-profiler
* Usage: require('[path_to]/CpuProfiler').init('datadir')
*
* @module CpuProfiler
* @type {exports}
*/
var fs = require('fs');
var profiler = require('v8-profiler');
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@rodricios
rodricios / summarize.py
Last active November 18, 2020 17:21
Flipboard's summarization algorithm, sort of
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pip install networkx distance pattern
In Flipboard's article[1], they kindly divulge their interpretation
of the summarization technique called LexRank[2].
@lepture
lepture / backup2qiniu.py
Last active August 31, 2015 07:55
Backup Database to Qiniu
#!/usr/bin/env python
import os
import sys
import hmac
import json
import time
import hashlib
import datetime
import requests
@liruqi
liruqi / nginxhttpproxy.conf
Created November 22, 2014 15:29
nginx http proxy config
server {
listen 80;
server_name *.cn *.org *.com *.jp *.hk *.io *.info "";
client_body_timeout 60000;
client_max_body_size 1024m;
send_timeout 60000;
client_header_buffer_size 16k;
large_client_header_buffers 4 64k;
@sleekslush
sleekslush / gist:57f198bdaa6561fe55c3
Created August 27, 2014 20:12
Change jinja cache size in flask
from flask import Flask as DefaultFlask
class Flask(DefaultFlask):
def create_jinja_environment(self):
self.jinja_options = dict(self.jinja_options)
if 'JINJA_CACHE_SIZE' in self.config:
self.jinja_options['cache_size'] = self.config['JINJA_CACHE_SIZE']
return super(Flask, self).create_jinja_environment()
@cryptix
cryptix / vineScrape.go
Created August 27, 2014 12:31
extract a javascript object value from a html page using goquery and otto
package main
import (
"errors"
"log"
"os"
"github.com/PuerkitoBio/goquery"
"github.com/robertkrimen/otto"
)
@bcho
bcho / nfa_re.py
Created August 15, 2014 14:38
A small nfa regex express engine written in Python.
# coding: utf-8
'''
Support operations:
- character match
- seq
- or
- repeatition
@wkjagt
wkjagt / audio-book-reader.md
Last active April 12, 2024 14:18
How I built an audio book reader for my nearly blind grandfather

#How I built an audio book reader for my nearly blind grandfather

Tweet this - Follow me

Last year, when visiting my family back home in Holland, I also stopped by my grand-parents. My grand-father, now 93 years old, had always been a very active man. However, during the presceding couple of months, he'd gone almost completely blind and now spent his days sitting in a chair. Trying to think of something for him to do, I suggested he try out audio books. After finally convincing him -- he said audio books were for sad old people -- that listening to a well performed recording is actually a wonderful experience, I realized the problem of this idea.

####The problem with audio devices and the newly blind. After my first impulse to jump up and go buy him an