This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Licensed under the MIT License | |
Copyright (c) 2011 Cédric Luthi | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Actor.Swift | |
// | |
// Copyright (c) 2017 Robert Brown | |
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_ipv4_address() do | |
:inet.getifaddrs() | |
|> elem(1) | |
|> Enum.find(fn {_interface, attr} -> | |
case attr |> Keyword.get_values(:addr) do | |
[] -> false | |
list -> list |> Enum.find(fn(addr) -> | |
case addr do | |
nil -> false | |
{127, 0, 0, 1} -> false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// | |
// MARK: - JSONError Type | |
// | |
public enum JSONError: ErrorType, CustomStringConvertible { | |
case KeyNotFound(key: JSONKeyType) | |
case NullValue(key: JSONKeyType) | |
case TypeMismatch(expected: Any, actual: Any) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Fun do | |
def arity(fun) do | |
case :erlang.fun_info(fun, :arity) do | |
{ :arity, arity } -> | |
arity | |
end | |
end | |
def adapt!(fun, 0) do | |
fn -> fun.([]) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RBSimpleSingleton.h | |
// | |
// Copyright (c) 2011 Robert Brown | |
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RBNetworkActivityIndicatorManager.h | |
// | |
// Copyright (c) 2011 Robert Brown | |
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground - noun: a place where people can play | |
import UIKit | |
import CoreGraphics | |
public enum Result<T> { | |
case Success(@autoclosure () -> T) | |
case Failure(String) | |
init(_ value:T) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground - noun: a place where people can play | |
import Foundation | |
infix operator >>- { associativity left precedence 150 } // Bind | |
infix operator <^> { associativity left } // Functor's fmap (usually <$>) | |
infix operator <*> { associativity left } // Applicative's apply | |
public typealias JSON = AnyObject | |
public typealias JSONObject = Dictionary<String, JSON> |
NewerOlder