Skip to content

Instantly share code, notes, and snippets.

View NinoScript's full-sized avatar
🎩
Working my way to FI/RE

Cristián Arenas Ulloa NinoScript

🎩
Working my way to FI/RE
View GitHub Profile
module Helpers
def arguments(method:, binding:)
method.parameters.inject({}) do |args, (type, name)|
args[name] = {
type:type,
value:binding.eval(name.to_s)
}
args
end
end
@NinoScript
NinoScript / gist:4140437
Created November 24, 2012 16:41
yet another .vimrc
" Vim Pathogen
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
call pathogen#helptags()
" General Settings
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
import Cocoa
// My JSON Framework
protocol NinoScriptJSON {
init(json:String) throws
init(any:AnyObject) throws
}
extension NinoScriptJSON {
init(json:String) throws {
let data = json.dataUsingEncoding(NSUTF8StringEncoding)!
@NinoScript
NinoScript / Emptiable.swift
Last active January 26, 2017 17:11
Playing around with the concept of "emptiable" values
//: Playground - noun: a place where people can play
import Cocoa
protocol Emptiable {
static var emptyValue: Self { get }
}
extension Emptiable where Self: Equatable {
var nonEmptyValue: Self? {
//
// ThrowingUtils.swift
//
// Created by Cristián Arenas Ulloa on 1/13/17.
// WTFPLv2
//
import Foundation
// Usage example: try maybeValue.unwrapped()
@NinoScript
NinoScript / ThrowingUtils.swift
Last active March 9, 2017 16:48
Just some utility functions for when you are working inside a throwing function
//
// ThrowingUtils.swift
//
// Created by Cristián Arenas Ulloa on 1/13/17.
// WTFPLv2
//
// Usage example: try maybeValue.unwrapped()
extension Optional {
func unwrapped() throws -> Wrapped {
@NinoScript
NinoScript / SignalProducer+D3.swift
Created March 23, 2017 20:43
D3.js-like enter and exit functions for ReactiveSwift
//
// SignalProducer+D3.swift
//
// Created by Cristián Arenas Ulloa on 3/23/17.
// WTFPLv2
//
// This overcomplicated tool fits my use case.
// It will probably make a lot of sense to you too if you've ever used D3.js.
// There was probably an easier way to do it,
// but I'm just learning ReactiveSwift so don't hate me .
@NinoScript
NinoScript / mnesia_test.ex
Last active January 22, 2018 19:05
Macro for running tests that use Mnesia in a transaction
defmacro mnesia_test(description, context \\ quote(do: _), do: block) do
quote do
test unquote(description), unquote(context) do
{:aborted, error} =
Mnesia.transaction(fn ->
unquote(block)
Mnesia.abort(:ok)
end)
case error do
@NinoScript
NinoScript / UIViewRotate.playground
Created March 8, 2018 15:37
Rotate UIView with anchorPoint
//: Playground - noun: a place where people can play
import UIKit
let r = UIView(frame: CGRect(
x: 0,
y: 0,
width: 200,
height: 200
))
declare module 'post-robot' {
// Warning: This is not actually a Promise, but the interface is the same.
type ZalgoPromise<T> = Promise<T>;
// For our purposes, Window is cross domain enough. For now at least.
type CrossDomainWindowType = Window;
type WindowResolverType = CrossDomainWindowType | string | HTMLIFrameElement;
// Client
// Loosely based on: https://github.com/krakenjs/post-robot/blob/master/src/public/client.js