Skip to content

Instantly share code, notes, and snippets.

@bcse
bcse / app.yaml
Created August 28, 2015 06:59
Debian repository on Google App Engine
application: altcanvas-repo
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: debrepo.py
@bcse
bcse / main.m
Created September 27, 2017 03:56
[GCD] Use semaphore as lock
#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 / MyMenu.swift
Last active May 25, 2018 07:01
Generics class with delegate
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 / gist:3fd23b5d3daaf12c7e99b7b260dd250f
Last active December 3, 2020 15:58
jq - VoTT JSON to CreateML JSON
jq '[.assets[] | { image: .asset.name, annotations: [.regions[] | { label: .tags[0], coordinates: .boundingBox | { x: .left | round, y: .top | round, width: .width | round, height: .height | round } }] }]'