Skip to content

Instantly share code, notes, and snippets.

import Foundation
//
// XcodeKitDefines.h
// Xcode
//
// Copyright © 2016 Apple Inc. All rights reserved.
//
/** The build version of XcodeKit itself.
@erica
erica / kinds.md
Last active April 29, 2016 21:50

Kinds of things

  • Random Access Collection: retrieve member in O(1) time
  • Bidirectional Collection
  • Default Collection, default, with forward traversal

Things that can be strided through:

  • Can stride through a number line, regardless of whether that numberline is discrete or continuous
  • Can stride over a collection so long as a collection returns a list of indices. The indices may or may not be ordered and the stride may not return the same values over each traversal.
@alyssaq
alyssaq / main.go
Last active February 13, 2024 08:01
GET and POST golang API
/*
* Sample API with GET and POST endpoint.
* POST data is converted to string and saved in internal memory.
* GET endpoint returns all strings in an array.
*/
package main
import (
"encoding/json"
"flag"
@Avaq
Avaq / combinators.js
Last active May 19, 2024 00:21
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
// Created by Chris Eidhof on 04-01-16.
// Copyright © 2016 Chris Eidhof. All rights reserved.
//
// Large parts copy/pasted from https://github.com/Eonil/TCPIPSocket.Swift
import Foundation
struct TCPIPSocketAddress {
init(_ a:UInt8, _ b:UInt8, _ c:UInt8, _ d:UInt8) {
let a1 = UInt32(a) << 24
@briancroom
briancroom / xctest_finder.py
Last active April 17, 2016 11:05
Script to assist with conforming to XCTestCaseProvider
#!/usr/bin/python
# Invoke this script with a Swift file containing an XCTestCase and it will
# generate an implementation for the `allTests` variable required for
# XCTestCaseProvider conformance on Linux
import sys
import re
inFile = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin
@chriseidhof
chriseidhof / Shoes.swift
Last active April 21, 2022 17:02
shoes in swift
import Cocoa
class MyAppDelegate: NSObject, NSApplicationDelegate {
let window = NSWindow()
var didFinishLaunching: NSWindow -> () = { _ in () }
func applicationDidFinishLaunching(aNotification: NSNotification) {
didFinishLaunching(window)
}
}
@oisdk
oisdk / free.swift
Last active December 10, 2015 14:41
func free<A,B>(f: A -> () -> B) -> A -> B {
return { f($0)() }
}
[[1, 2, 3], [4, 5, 6]].map(free(Array.reverse)) // [[3, 2, 1], [6, 5, 4]]
//: Playground - noun: a place where people can play
import Cocoa
var aSet = Set<Int>()
aSet.insert(1)
aSet.insert(2)
aSet.insert(3)
// The rest of this code doesn't even remotely work.
@patik
patik / how-to-squash-commits-in-git.md
Last active October 17, 2023 02:19
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date: