Skip to content

Instantly share code, notes, and snippets.

View stulevine's full-sized avatar

Stu Levine stulevine

  • @wildcatproductions.com
  • Auburn Hills, MI
  • 08:24 (UTC -04:00)
View GitHub Profile
@chriseidhof
chriseidhof / TypedExpr.swift
Last active February 3, 2018 23:01
Typed Expressions in Swift
// Variables just contain an integer. We can have a maximum of `Int.max` variables in our program. ¯\_(ツ)_/¯
private struct Var {
static var freshVarIx = 0
let ix: Int
init() {
Var.freshVarIx+=1
ix = Var.freshVarIx
}
}
@alskipp
alskipp / filter_colors.hs
Last active January 6, 2024 07:23
Filtering arrays of enums (Haskell / Swift 1.2 / Swift 2.0 comparison)
-- data structure for RGBA, RGB & CMYK colors
data Color = RGBA Float Float Float Float
| RGB Float Float Float
| CMYK Float Float Float Float
deriving (Eq, Ord, Show)
-- list of colors
colors = [ RGBA 0.1 0.1 0.5 0.2
, RGBA 1 1 0 0.9
, RGB 0.5 0.5 0
@kristopherjohnson
kristopherjohnson / dispatch_once.swift
Created August 12, 2014 16:25
Example of using dispatch_once() in Swift
import Foundation
var token: dispatch_once_t = 0
func test() {
dispatch_once(&token) {
println("This is printed only on the first call to test()")
}
println("This is printed for each call to test()")
}
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtX6cMHZCIcqW5Pt+3HGn7iR/KHMPrPxdzV96nrRwCUnFfQ3m8Axxnd4hTTgyKdBN74zYEaZCpoVUwthyRwzqzXLb87iLkUtzGBUOqMg6q2TpciHcUMhpmgqTR/Xwtpu9bvshJ1+FYUHW9oMfeN1UMhraeXSMG6aoaQPgPWTfigN/CG0f77szKqOXTimBpwbCU7/4jixkZdIosvy8r2oKVQxR2kPy2/qUetQB19eS28eu02WBWeGQuLc1l04gmezGcYGcc1Tac6IiyWqDrJwZGh0Yrbv2U3Zvuv2idcyIFPpTK/l9n90UyA+iPs/ct9mJr6/g1xYGVZLxOyLje1FO4un0w1JhcXcquS2nNU/9zIF7efCdNe2XJQgex/xfcv5CkAnZComRCIQpokQd1byVCOUfLn5OpfYtgfClJQOZI5zlH0prx9DV85FDIAYIaJ2tFnw4u8PZoyF0zGElM4fxd3S8sSh2qUw4goAHGBKtDOI5Fi18qkt/4xmtHGsJo+rdR+OjWlZMLrPp/A9vWQvKkldFSFWxANNFx3No7HIWlauZrgZqKmt2/deHHCxFZxCJLPbiV5LKueNXQFxRVwQ44BK8/r9HJ24QfYwG5t82ydJB4+m1YhfM0nWgrI4063jzRZ0rqTJJTMWdH0wgViTniA/rCKQd5raY0YDC32dZ1qQ== slevine@Stuart-MBA.local
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active April 11, 2024 22:09
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@mattt
mattt / alfred-wwdc.url
Last active September 25, 2018 10:01
Alfred ASCIIwwdc Web Search
alfred://customsearch/Search%20WWDC%20Sessions/wwdc/utf8/noplus/http://asciiwwdc.com/search?q={query}
@phildow
phildow / CLLocation+EXIFGPS.h
Last active December 2, 2019 02:37
Category to create GPS metadata dictionary from CLLocation and CLHeading for writing to EXIF data in images.
#import <CoreLocation/CoreLocation.h>
#import <ImageIO/ImageIO.h>
@interface CLLocation (EXIFGPS)
- (NSDictionary*) EXIFMetadataWithHeading:(CLHeading*)heading;
@end
@interface NSDate (EXIFGPS)
@prebenlm
prebenlm / .A how to display Irssi-hilights in OS X Notification Center.md
Last active August 12, 2019 08:54
Guide: how to make irc messages in a screen on a remote server appear in your Mac OS X Lion Notification Center with the help of terminal-notifier

Irssi in Mac OS X Notification Center

Mou icon

Overview

This guide will explain how you can make irc messages in a screen on a remote server appear in your Mac OS X Lion Notification Center with the help of terminal-notifier.

We will also explain how the process can be automatically started each time you log in to your Mac and ensure the connection to the server is kept alive.

@onevcat
onevcat / NSData+Base64.h
Created February 24, 2012 15:11 — forked from 0xced/NSData+Base64.h
NSData Base64 category
//
// Created by Cédric Luthi on 2012-02-24.
// Copyright (c) 2012 Cédric Luthi. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSData (Base64)
+ (id) dataWithBase64Encoding_xcd:(NSString *)base64String;