Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am Sidnicious on github.
  • I am sidney (https://keybase.io/sidney) on keybase.
  • I have the public key with fingerprint 5E68 5E60 EB87 3365 4DCB  0057 0DAA 1A4A B1D8 8291

To claim this, I am signing this object:

@s4y
s4y / covered.html
Created February 7, 2015 22:53
Covered button
<!DOCTYPE html>
<style>
html {
font: 18px "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.covered {
position: relative;
overflow: hidden;
@s4y
s4y / Generator.swift
Created March 12, 2015 00:38
GCD-based generator for Swift
import Foundation
class Generator<T>: GeneratorType, SequenceType {
var val: T? = nil
let yieldSemaphore = dispatch_semaphore_create(0)
let valueSemaphore = dispatch_semaphore_create(0)
init(f: ((T) -> ()) -> ()) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
@s4y
s4y / invitation.md
Created March 13, 2015 15:02
Amazon Echo: Developer Program Invitation

Dear Developer,

Thank you for your interest in developing for Amazon Echo. We would like to invite you to participate in our Amazon Echo Developer Program. As an early adopter developer, we would value your feedback on the Amazon Echo developer experience.

If you are interested in participating in the Amazon Echo Developer Program, please complete the following steps by Wednesday, March 18, 2015 as space is limited:

  1. Register for the Amazon Appstore (if you’ve not already done so);
  2. Review the Nondisclosure Agreement (NDA) included below;
  3. Reply to this e-mail (alexa-echo-developers@amazon.com) and make sure the original message is included below your response. It’s important the text of the NDA be included in your reply.
  • Write the following in the text of your e-mail: “I hereby agree to the nondisclosure agreement included below. [Your full name here], [City, State, Country]”
@s4y
s4y / CLLocationManager+getLocation.swift
Last active August 29, 2015 14:17
A class method on CLLocationManager that fetches the current location and returns it in a Promise
import CoreLocation
extension CLLocationManager {
class func getLocation(accuracy: CLLocationAccuracy) -> Promise<CLLocation> {
class GetLocationDelegate: NSObject, CLLocationManagerDelegate {
var holdSelf: GetLocationDelegate?
let locationManager = CLLocationManager()
let promise: Promise<CLLocation>
let resolve: CLLocation -> ()
http://www.holeintheceiling.com/blog/2012/08/14/mountain-lion-and-ssh/
func delay(interval: NSTimeInterval) -> Promise<()> {
return Promise<()> { resolve, reject in
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(interval * NSTimeInterval(NSEC_PER_SEC))), dispatch_get_main_queue(), resolve)
}
}
@s4y
s4y / example.iced
Created July 5, 2015 17:08
A (very preliminary) USB driver for some signs manufactured by BrightLEDSigns.com
miniled = require 'miniled'
sign = miniled.signs()[0]
await sign.open defer()
sign.set 'Hello, world!'
@s4y
s4y / ratelimiter.coffee
Created July 31, 2015 02:00
A super tiny rate limiter
class RateLimiter
constructor : (@max, @interval) ->
@table = {}
hit : (key) ->
now = +new Date
if (hits = @table[key])?
if hits.length is @max
return false
@s4y
s4y / curried.js
Created February 7, 2015 21:02
Tiny curry
function curried(fn) {
function curry() {
if (arguments.length >= fn.length) {
return fn.apply(this, arguments);
}
var args = arguments;
return function() {
return curry.apply(
null, Array.prototype.concat.apply(
Array.prototype.slice.call(args), arguments)