Skip to content

Instantly share code, notes, and snippets.

Grey Lee bcse

Block or report user

Report or block bcse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bcse
bcse / app.yaml
Created Aug 28, 2015
Debian repository on Google App Engine
View app.yaml
application: altcanvas-repo
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: debrepo.py
@bcse
bcse / .clang-format
Created Mar 21, 2014
My ClangFormat configuration
View .clang-format
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignTrailingComments: false
ColumnLimit: 0
NamespaceIndentation: Inner
ObjCSpaceAfterProperty: true
IndentWidth: 4
BreakBeforeBraces: Stroustrup
View ASCIIzation.php
<?php
function asciize($str)
{
static $from = array('Á', 'À', 'Â', 'Ä', 'Ǎ', 'Ă', 'Ā', 'Ã', 'Å', 'Ǻ', 'Ą', 'Ɓ', 'Ć', 'Ċ', 'Ĉ', 'Č', 'Ç', 'Ď', 'Ḍ', 'Ɗ', 'É', 'È', 'Ė', 'Ê', 'Ë', 'Ě', 'Ĕ', 'Ē', 'Ę', 'Ẹ', 'Ǝ', 'Ə', 'Ɛ', 'Ġ', 'Ĝ', 'Ǧ', 'Ğ', 'Ģ', 'Ɣ', 'Ĥ', 'Ḥ', 'Ħ', 'I', 'Í', 'Ì', 'İ', 'Î', 'Ï', 'Ǐ', 'Ĭ', 'Ī', 'Ĩ', 'Į', 'Ị', 'Ĵ', 'Ķ', 'Ƙ', 'Ĺ', 'Ļ', 'Ł', 'Ľ', 'Ŀ', 'Ń', 'Ň', 'Ñ', 'Ņ', 'Ó', 'Ò', 'Ô', 'Ö', 'Ǒ', 'Ŏ', 'Ō', 'Õ', 'Ő', 'Ọ', 'Ø', 'Ǿ', 'Ơ', 'Ŕ', 'Ř', 'Ŗ', 'Ś', 'Ŝ', 'Š', 'Ş', 'Ș', 'Ṣ', 'Ť', 'Ţ', 'Ṭ', 'Ú', 'Ù', 'Û', 'Ü', 'Ǔ', 'Ŭ', 'Ū', 'Ũ', 'Ű', 'Ů', 'Ų', 'Ụ', 'Ư', 'Ẃ', 'Ẁ', 'Ŵ', 'Ẅ', 'Ƿ', 'Ý', 'Ỳ', 'Ŷ', 'Ÿ', 'Ȳ', 'Ỹ', 'Ƴ', 'Ź', 'Ż', 'Ž', 'Ẓ', 'á', 'à', 'â', 'ä', 'ǎ', 'ă', 'ā', 'ã', 'å', 'ǻ', 'ą', 'ɓ', 'ć', 'ċ', 'ĉ', 'č', 'ç', 'ď', 'ḍ', 'ɗ', 'é', 'è', 'ė', 'ê', 'ë', 'ě', 'ĕ', 'ē', 'ę', 'ẹ', 'ǝ', 'ə', 'ɛ', 'ġ', 'ĝ', 'ǧ', 'ğ', 'ģ', 'ɣ', 'ĥ', 'ḥ', 'ħ', 'ı', 'í', 'ì', 'i', 'î', 'ï', 'ǐ', 'ĭ', 'ī', 'ĩ', 'į', 'ị', 'ĵ', 'ķ', 'ƙ', 'ĸ', 'ĺ', 'ļ', 'ł', 'ľ', 'ŀ', 'ʼn', 'ń', 'ň', 'ñ', 'ņ', 'ó', 'ò', 'ô', 'ö', 'ǒ', 'ŏ'
View flickr_backup.py
from __future__ import with_statement
import glob
import os.path
import re
import urllib
import flickrapi
api_key = '________________________________'
api_secret = '________________'
user_id = '____________'
@bcse
bcse / zoinkfic.py
Created Jan 29, 2011
streamlined zoink.it + torrific (Depends on suds and Python 2.5 or higher)
View zoinkfic.py
from os.path import expanduser, join
from base64 import b64encode
from glob import glob
import webbrowser
from suds.client import Client
url = 'https://zoink.it/api/torrage.wsdl'
client = Client(url)
files = glob(join(expanduser('~'), 'Downloads', '*.torrent'))
@bcse
bcse / greyscale2alpha.py
Created Mar 8, 2011
Convert black to opaque and white to transparent. (Depends on pypng)
View greyscale2alpha.py
import png
def convert(fin, fout):
reader = png.Reader(filename=fin)
width, height, pixels, metadata = reader.asDirect()
#print metadata
out = list()
for row in pixels:
row_out = list()
@bcse
bcse / dbbackup.php
Created Sep 8, 2011
Backup all MySQL databases and send to my E-mail
View dbbackup.php
<?php
$DBUSERNAME = 'YOUR_USERNAME';
$DBPASSWORD = 'YOUR_PASSWORD';
$EMAIL = 'YOUR_EMAIL';
$boundary = '==DBBACKUP-'.md5(uniqid(rand(), true));
$date = date('Ymd');
$header = "Content-Type: multipart/mixed; boundary=\"$boundary\"";
$message =
"This is a multi-part message in MIME format.\n".
@bcse
bcse / plurk-smiley-notifier.py
Created Sep 8, 2011
Automatic post latest smiley on your timeline (Plurk API 1.0)
View plurk-smiley-notifier.py
#!/usr/bin/env python
APIKEY = 'YOUR_APIKEY'
USERNAME = 'YOUR_USERNAME'
PASSWORD = 'YOUR_PASSWORD'
#--- Setup ---------------------------------------------------
import sys, os, urllib, urllib2, cookielib
try:
import json
except:
@bcse
bcse / fetch-by-tag.py
Last active Sep 27, 2015
Fetch top 100 popular photos from Flickr
View fetch-by-tag.py
import re
import json
import os
from urllib.request import urlopen, urlretrieve
from glob import glob
config = {
'api_key': 'YOUR_API_KEY',
'sort': 'interestingness-desc',
'per_page': 100
View mm.py
registry = {}
class MultiMethod(object):
def __init__(self, name):
self.name = name
self.typemap = {}
def __call__(self, *args):
types = tuple(arg.__class__ for arg in args) # a generator expression!
function = self.typemap.get(types)
if function is None:
You can’t perform that action at this time.