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 / MyMenu.swift
Last active May 25, 2018
Generics class with delegate
View MyMenu.swift
import Foundation
import UIKit
public protocol MenuItem {}
public protocol MenuDelegate: AnyObject {
associatedtype Item: MenuItem
func menu(_ menu: Menu<Item, Self>, didSelect item: Item)
bcse / main.m
Created Sep 27, 2017
[GCD] Use semaphore as lock
View main.m
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
dispatch_semaphore_t lock = dispatch_semaphore_create(0);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{
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
- url: .*
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
bcse /
Last active Dec 25, 2015
Python OrderedSet

OrderedSet is a set-like class that also keeps inserting order like list.

Here are some test results compared with ABC-based OrderedSet:

  My OrderedSet ABC-based Boost::MultiIndex-based
bcse /
Last active Dec 24, 2015
iTunes Festival London 2014 Download Link Generator


  1. Execute
  2. Insert artist name, e.g. 5 Seconds of Summer
  3. 5 Seconds of Summer.txt and 5 Seconds of Summer.ac3.txt will be generated
  4. Download video from 5 Seconds of Summer.txt and combine them with cat *.ts > combined.ts
  5. (Optional) If you want to download 5.1 channel AC-3 audio as well. Download them from 5 Seconds of Summer.ac3.txt and combine them with cat *.ac3 > combined.ac3
bcse /
Last active Dec 23, 2015
Python port of WebKit bezier solver
# Copyright (C) 2008 Apple Inc. All Rights Reserved.
# Copyright (C) 2013 Grey Lee. All Rights Reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
bcse /
Last active Dec 21, 2015
Generate plexconnect.pot
#!/usr/bin/env python
import datetime
import glob
import os
import re
import sys
def main(base_path):
msgid = set()
bcse /
Created Jun 19, 2013
Remove all UTF-16 characters by regular expression
txt = u'\U0001f600'
r = re.compile(u'[\uD800-\uDBFF][\uDC00-\uDFFF]')
r.sub('', txt)
bcse /
Created Mar 18, 2013
Extending urllib2.Request, so we can assign HTTP verb manually.
from urllib2 import Request as RequestBase
class Request(RequestBase):
def __init__(self, url, data=None, headers=None, origin_req_host=None,
unverifiable=False, method=None):
if headers is None:
headers = {}
super(Request, self).__init__(url, data, headers, origin_req_host, unverifiable)
self.method = method
You can’t perform that action at this time.