MyConstructor = ->
this.args = arguments
this
obj = applyToNew MyConstructor, [1, 2, 3]
obj.args # [ 1, 2, 3 ]
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
// https://gist.github.com/aleclarson/e076f1fa0fc4ebedc9a1 | |
// | |
// Check out this link for more information. | |
// https://gist.github.com/aleclarson/e076f1fa0fc4ebedc9a1#comment-1379921 | |
import Foundation | |
// MARK: Type checking |
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
Path = require "path" | |
getDirectories = (path) -> | |
dirs = [] | |
path = Path.resolve path unless Path.isAbsolute path | |
dirs.push Path.basename path if Path.extname(path) is "" | |
loop | |
dir = Path.dirname path | |
break if dir is "/" | |
dirs.push dir.slice dir.lastIndexOf("/") + 1 |
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
#!/bin/bash | |
# coffee-module <module-name> | |
coffee-module () { | |
if [ -d "$@" ]; then | |
echo "Directory named '$@' already exists!" | |
return | |
fi |
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
TimerMixin = require "react-timer-mixin" | |
combine = require "combine" | |
steal = require "steal" | |
hook = require "hook" | |
module.exports = (descriptor) -> | |
methods = combine {}, TimerMixin |
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
initialPosition = 0 | |
module.exports = | |
decay = | |
equation: "react" | |
dynamicsThreshold: 0.01 |
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
require "../../../lotus-require" | |
NamedFunction = require "named-function" | |
WeakMap = require "weak-map" | |
Namespace = module.exports = NamedFunction "Namespace", -> | |
return new Namespace unless @ instanceof Namespace | |
@cache = WeakMap() | |
@ |
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
module.exports = (n) -> | |
n = Math.abs n | |
return 1 if n < 1 | |
count = 0 | |
while n >= 1 | |
count += 1 | |
n /= 10 | |
count |
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
{Component, Device} = require "modx" | |
hexToRgb = require "hex-rgb" | |
type = Component "OuterBorder" | |
type.defineProps | |
style: Style | |
child: Element |
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
/// Generate a unique identifier for an AnyObject. | |
/// 2nd slowest. Converts to String. | |
public func obid (object: AnyObject) -> String { | |
return "\(obid(object) as Int)" | |
} | |
/// Generate a unique identifier for an AnyObject. | |
/// Fastest. Every other function relies on this one. | |
public func obid (object: AnyObject) -> Int { |