Skip to content

Instantly share code, notes, and snippets.

Neil Cowburn neilco

Block or report user

Report or block neilco

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
@neilco
neilco / log.go
Last active Feb 5, 2016 — forked from cespare/log.go
Golang apache logging
View log.go
package main
import (
"fmt"
"io"
"net/http"
"strings"
"time"
)
@neilco
neilco / UIColor+Brightness.swift
Created Oct 29, 2015
Adjust brightness of a UIColor instance
View UIColor+Brightness.swift
import UIKit
public extension UIColor {
public func colorWithBrightness(brightness: CGFloat) -> UIColor {
var H: CGFloat = 0, S: CGFloat = 0, B: CGFloat = 0, A: CGFloat = 0
if getHue(&H, saturation: &S, brightness: &B, alpha: &A) {
B += (brightness - 1.0)
B = max(min(B, 1.0), 0.0)
@neilco
neilco / RSASHA1.swift
Created Apr 27, 2015
RSA-SHA1 signing with a PKCS#12 private key
View RSASHA1.swift
//
// RSASHA1.swift
//
// Copyright (c) 2015 Neil Cowburn. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
View 1 - GrandCentralSwift.swift
import Foundation
public let GCD_MAIN_QUEUE = dispatch_get_main_queue()
public let GCD_BACKGROUND_QUEUE = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
public let GCD_LOW_PRIORITY_QUEUE = dispatch_get_global_queue(QOS_CLASS_UTILITY, 0)
public let GCD_DEFAULT_QUEUE = dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)
public let GCD_HIGH_PRIORITY_QUEUE = dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)
public func after(delay: NSTimeInterval, block: () -> ())
{
@neilco
neilco / Example Output.png
Last active Mar 17, 2017
json_curl: Pretty-print colourised JSON output from cURL
@neilco
neilco / 1.Promise.swift
Last active May 18, 2018
Coffee Break Hack - Ultra-simple Promises
View 1.Promise.swift
public final class Promise<T> {
private var resolveClosure: (T -> Void)?
private var rejectClosure: (AnyObject? -> Void)?
public init() { }
public func then(resolve: (T -> Void), _ reject: (AnyObject? -> Void)? = nil) -> Promise<T> {
self.rejectClosure = reject
self.resolveClosure = resolve
@neilco
neilco / NCAdHocUtils.h
Created Jun 13, 2014
HOW-TO: Detect ad-hoc release builds at runtime
View NCAdHocUtils.h
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT BOOL NCIsAdHocReleaseBuild();
@neilco
neilco / address.go
Created Nov 21, 2013
Go function to return the first IPv4 address of the named interface
View address.go
package net
import (
"net"
"os"
)
func InterfaceIPv4Address(name string) net.IP {
intf, err := net.InterfaceByName(name)
if err != nil {
@neilco
neilco / gist:7579740
Created Nov 21, 2013
Universal library build script
View gist:7579740
LIB_TARGET_NAME="${PRODUCT_NAME}"
if [ "${ACTION}" = "clean" ]
then
echo "Cleaning Libraries..."
cd "${PROJECT_DIR}"
xcodebuild -target "$LIB_TARGET_NAME" -configuration ${CONFIGURATION} -sdk iphoneos clean
xcodebuild -target "$LIB_TARGET_NAME" -configuration ${CONFIGURATION} -sdk iphonesimulator clean
fi
You can’t perform that action at this time.