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.
| 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) { | 
| 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 } } | 
| 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.
| var canvas, ctx; | |
| var points = []; | |
| var distance = 10; | |
| canvas = document.getElementById("map"); | |
| reset = document.getElementById("reset"); | |
| canvas.onclick = function(ev){ | |
| points.push(ev); | |
| draw(); | 
| // Playground - noun: a place where people can play | |
| import UIKit | |
| @objc public class Posts { | |
| var objects :AnyObject! | |
| init () { | |
| objects = [1, 2, 3] | |
| } | |
| func doSomething() { | 
I hereby claim:
To claim this, I am signing this object:
| // 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 } | |
| } | 
| class A { | |
| var a: NSObject | |
| } | |
| //not valid swift: | |
| class B: A { | |
| override var a: UIView | |
| } | |
| // type **theory** |