Skip to content

Instantly share code, notes, and snippets.

@s4y
s4y / 1 - get a health store.swift
Created September 2, 2014 03:54
HealthKit examples
let healthStore = HKHealthStore()
@s4y
s4y / showAlert.swift
Last active March 15, 2016 07:40
A function for showing alerts and action sheets, written for iOS 7 and 8
import UIKit
// Notes:
// - You must explicitly weak link to UIKit to support iOS 7
// - Action sheets on iOS 7 only show a title
func showAlert(viewController: UIViewController, style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, sourceView: UIView? = nil, completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) {
if (NSClassFromString("UIAlertController") != nil) {
// iOS 8+

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 / Makefile
Last active December 31, 2015 21:29
A toy hash table
EVERYTHING = $(patsubst %.c,%,$(wildcard *.c))
CC=clang
CCFLAGS +=\
-std=c99\
-DDEBUG\
-g\
-Wall\
-Wpedantic\
-Werror
@s4y
s4y / pushbundler.py
Last active December 28, 2015 19:38
Create a push bundle for Mavericks push notifications
import json, subprocess, hashlib
from zipfile import ZipFile
class PushPackage(object):
def __init__(self, filename):
self.zfile = ZipFile(filename, 'w')
self.manifest = {}
def __enter__(self):
@s4y
s4y / map.cpp
Last active December 26, 2015 05:38
#include <team-functional.hpp>
#include <iostream>
using namespace std;
using namespace team;
int slowSquare(int a) {
usleep(100 * (5 - a));
return a * a;
}
@s4y
s4y / bahn_server.cpp
Created October 15, 2013 15:13
Early work on a Team web framework
#include <team/bahn.h>
const char *ip = "127.0.0.1";
const int port = 8080;
using namespace std;
using namespace team;
int main() {
@s4y
s4y / http.cpp
Last active December 24, 2015 15:38
Experimenting with web servers in Team.
#include <team/net.h>
#include <stdio>
using namespace std;
using namespace async;
const char *ip = "127.0.0.1";
const int port = 8080;
void amain() {
@s4y
s4y / scary.T.cpp
Last active December 22, 2015 22:58
tamed template <typename T1>
typename event<T1>::ptr tvoid_t<T1>::run(event<>::ptr in) {
tvars { T1 t; typename event<T1>::ptr out; }
DEFAULT_RETURN { return out; }
twait { out = mkevent(t); }
if (in) in->trigger();
}
tamed template <typename T1>
typename event<T1>::ptr tvoid_t<T1>::run(event<>::ptr in) {
tvars { T1 t; }
DEFAULT_RETURN { return mkevent(t); }
twait { }
if (in) in->trigger();
}