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 / scrdec18-VC8.exe
Created Feb 15, 2012
Windows Script Decoder 1.8 (Decoding JScript.Encoded)
@bcse
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
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), ^{
NSLog(@"unlock");
dispatch_semaphore_signal(lock);
});
@bcse
bcse / build-ffmpeg.sh
Created Aug 22, 2011
Compile FFmpeg/Libav for iOS
View build-ffmpeg.sh
# configure for armv7 build
./configure \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='/usr/local/bin/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7' \
--extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk' \
@bcse
bcse / README.md
Last active Dec 25, 2015
Python OrderedSet
View README.md

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
bcse / README.md
Last active Dec 24, 2015
iTunes Festival London 2014 Download Link Generator
View README.md

Usage

  1. Execute iftgen.py
  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
bcse / UnitBezier.py
Last active Dec 23, 2015
Python port of WebKit bezier solver
View UnitBezier.py
# 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
bcse / genpot.py
Last active Dec 21, 2015
Generate plexconnect.pot
View genpot.py
#!/usr/bin/env python
import datetime
import glob
import os
import re
import sys
def main(base_path):
msgid = set()
@bcse
bcse / remove_utf16.py
Created Jun 19, 2013
Remove all UTF-16 characters by regular expression
View remove_utf16.py
txt = u'\U0001f600'
r = re.compile(u'[\uD800-\uDBFF][\uDC00-\uDFFF]')
r.sub('', txt)
@bcse
bcse / request.py
Created Mar 18, 2013
Extending urllib2.Request, so we can assign HTTP verb manually.
View request.py
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.