Skip to content

Instantly share code, notes, and snippets.

View aaroncrespo's full-sized avatar
🤷‍♂️
¯\_(ツ)_/¯

Aaron Crespo aaroncrespo

🤷‍♂️
¯\_(ツ)_/¯
View GitHub Profile
@aaroncrespo
aaroncrespo / gist:3145532
Created July 19, 2012 17:31
Architecture?
var metabolism = Raphael('metabolism', '940', '680');
var reactions = metabolism.set();
function replaceModal(data, reaction, products, diseases) {
//Load data in and out of the detail view.
}
function reactionsLoaded(){
reactions.attr({'stroke-width': '0','stroke-opacity': '1',opacity: '0.7', cursor: 'pointer'});
reactions.forEach(function (el) {
@aaroncrespo
aaroncrespo / Gemfile
Created September 13, 2012 16:17
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
require 'benchmark'
Benchmark.bm do |x|
x.report('w/o') do
10_000_000.times{ 2+2 }
end
x.report('with') do
a = Thread.new{ 5_000_000.times{ 2+2 } }
b = Thread.new{ 5_000_000.times{ 2+2 } }
@aaroncrespo
aaroncrespo / gist:4349129
Created December 20, 2012 22:29
Simple Match IP's
teststring.match(/(?<ip>(\d{1,3}\.){3}\d{1,3})/)[:ip]
# detects strings that look like IPv4 ip's

This is the code that powers the parallax effect on codetunes.com.

I think it’s quite chaotic at the moment and waits for being released as open source when it’s cleaned up.

@aaroncrespo
aaroncrespo / pipeline_plotter.js
Last active December 30, 2015 02:29
Quick and dirty example of creating rectangles from points, possibly to calculate an area around the vectors defined by a line between points.
var canvas, ctx;
var points = [];
var distance = 10;
canvas = document.getElementById("map");
reset = document.getElementById("reset");
canvas.onclick = function(ev){
points.push(ev);
draw();
@aaroncrespo
aaroncrespo / gist:62da472f06a431dcbc36
Last active August 29, 2015 14:04
Swift Public Object Conformance Typing issues.
// Playground - noun: a place where people can play
import UIKit
@objc public class Posts {
var objects :AnyObject!
init () {
objects = [1, 2, 3]
}
func doSomething() {
@aaroncrespo
aaroncrespo / keybase.md
Last active February 11, 2017 03:53
keybase.md

Keybase proof

I hereby claim:

  • I am aaroncrespo on github.
  • I am aaronc (https://keybase.io/aaronc) on keybase.
  • I have a public key ASAVig54_TeitH5mKNKy97CHkkM0JOxYsRzAyZvE1UCQ6Ao

To claim this, I am signing this object:

@aaroncrespo
aaroncrespo / Playgound.swift
Last active August 29, 2015 14:14
JSON: Dictionary <-> NSCoding
// Code highligting was down for this
// the idea is to create some protocols that allow you to treat NSCoders/Decoders as Subscriptable under swift
// allows code reuse between init(dictionary) and init(coder aDecoder)
// I threw this together in a playground and the compiler crashed so no garuntees this will work.
// also might be a bad idea for non object property types.
protocol Subscriptable {
subscript(key: String) -> AnyObject? { get set }
}
@aaroncrespo
aaroncrespo / gist:4ae10a19ec4a6915ecf6
Created April 9, 2015 03:05
Co-variance Contra-variance
class A {
var a: NSObject
}
//not valid swift:
class B: A {
override var a: UIView
}
// type **theory**