Skip to content

Instantly share code, notes, and snippets.

View angerman's full-sized avatar
🇸🇬

Moritz Angermann angerman

🇸🇬
View GitHub Profile

Keybase proof

I hereby claim:

  • I am angerman on github.
  • I am angerman (https://keybase.io/angerman) on keybase.
  • I have a public key whose fingerprint is D911 CD44 6398 8B80 97E1 7856 6A30 3B61 31E5 29AC

To claim this, I am signing this object:

@angerman
angerman / Break.swift
Created October 22, 2015 08:29
EXC_BAD_ACCESS
// Let’s alias a function that takes an int and does nothing with it.
typealias Action = Int -> ()
// If something has an action, it's Actionable, no? I think so. But we’ll leave it optional if there actually *is* an action.
protocol Actionable {
var action: Action? { get }
}
// And obviously we need Things. We always need Things.
protocol Thing {}
// Now Items are Things that are Actionable.
struct Item: Thing, Actionable {
@angerman
angerman / Break.swift
Last active October 8, 2015 10:13
value of type '_ -> _' has no member 'init'
class X : NSCoding {
@objc func encodeWithCoder(aCoder: NSCoder) {fatalError()}
@objc required init?(coder aDecoder: NSCoder) {fatalError()}
}
class B {}
class A<T>:X {}
class C:A<B> {
init(x:Int) {super.init()}
}
@angerman
angerman / powerset.hs
Last active May 3, 2018 20:39
Powersets in Haskell
powerset :: [a] -> [[a]]
powerset [] = [[]]
powerset (x:xs) = map (x:) (powerset xs) ++ powerset xs
#!/usr/bin/env bash
source "${HALCYON_DIR}/src.sh"
post_build_hook () {
expect_vars HALCYON_BASE
local tag source_dir constraints
expect_args tag source_dir build_dir -- "$@"
label=$( get_tag_label "${tag}" )
@angerman
angerman / 0_reuse_code.js
Created January 29, 2014 19:34
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@angerman
angerman / samba.3.6.1.osx-getgrouplist.patch
Created January 4, 2012 11:09
_SC_NGROUPS_MAX cannot be used with getgrouplist on OS X
--- a/source3/lib/system.c 2011-10-18 20:48:48.000000000 +0200
+++ b/source3/lib/system.c 2012-01-04 11:57:25.000000000 +0100
@@ -1159,6 +1159,13 @@
int groups_max(void)
{
+ /* On OS X, sysconf(_SC_NGROUPS_MAX) returns 16
+ * due to OS X's group nesting and getgrouplist
+ * will return a flat list; users can exceed the
+ * maximum of 16 groups. And easily will.
<?php
/**
* Action Login
*
* Used to check if login is successful.
* Returns 200 OK upon success.
* Returns 401 Unauthorized upon fail. (May contain reason in
* X-Login-Error header)
*
class UsersController < ApplicationController
respond_to :json
def index
@users = User.all
respond_with(@users)
end
def show
@user = User.find_by_id(params[:id])
def create
@name = params[:name]
@password = params[:password]
@email = params[:email]
if not @email
respond_with({})
else
@user = User.create({:name => params[:name]})
respond_with(@user, :location => users_url, :status => :created)
end