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
function Point(x, y) { | |
return { | |
getX: K(x), | |
getY: K(y), | |
getOriginDistance: function() { | |
return Math.sqrt(this.getX()**2 + this.getY()**2); | |
} | |
} | |
function Point(x, y) { |
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
Object.extend(NativeObject.prototype, function() { | |
// PDoc main documentation goes first, followed by normal implementation. | |
/** | |
* NativeObject#computeSomething() | |
* This methods definitely computes something. | |
**/ | |
function computeSomething() { | |
// The method, the normal way | |
} |
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
// original `Function#delay`, seems we could refactor it using `curry` right ? | |
function delay(timeout) { | |
var __method = this, args = slice.call(arguments, 1); | |
timeout = timeout * 1000 | |
return window.setTimeout(function() { | |
return __method.apply(__method, args); | |
}, timeout); | |
} | |
// Two ways of doing it ! |
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 File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe JavascriptObfuscator do | |
def obfuscate(js) | |
JavascriptObfuscator.obfuscate(js) | |
end | |
it "should rename properties starting with an underscore in accessing notation" do | |
obfuscate("object._aPrivateProperty").should == "object._a" | |
obfuscate("object . |
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
class JavascriptObfuscator | |
def self.obfuscate(source) | |
new(source).obfuscate | |
end | |
def initialize(source) | |
@source = source | |
@last_identifier = "a" | |
@translations = { } | |
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
public interface ICondition<T> { | |
boolean isSatisfiedBy(T object); | |
ICondition<T> negate(); | |
ICondition<T> and(ICondition<T> other); | |
ICondition<T> or(ICondition<T> other); | |
} | |
package com.maptimize.conditions; | |
public abstract class AbstractCondition<T> implements ICondition<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
#!/bin/bash | |
# Check if Internet Explorer is running, if so refresh | |
ps -xc|grep -sq "Internet Explorer" && osascript -e 'tell app "Internet Explorer"' -e 'activate' -e 'OpenURL "JavaScript:window.location.reload();" toWindow -1' -e 'end tell' | |
# Check if OmniWeb is running, if so refresh | |
ps -xc|grep -sq OmniWeb && osascript -e 'tell app "OmniWeb"' -e 'activate' -e 'reload first browser' -e 'end tell' | |
# Check if Firefox is running, if so refresh | |
ps -xc|grep -sqi firefox && osascript <<'APPLESCRIPT' |
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
Object.extend(Object, (function() { | |
function hashCode(object) { | |
if (!(object && Object.isFunction(object.hashCode))) { | |
object = String(object); | |
} | |
return object.hashCode(); | |
} | |
return { | |
hashCode: hashCode |
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
/* | |
Simpler, more robust super keyword for Prototype. | |
Given the following parent class: | |
var Person = Class.create({ | |
initialize: function(name) { | |
this.name = name; | |
}, | |
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 Memoized | |
def method_added(method_name) | |
if instance_method(method_name).arity.zero? | |
protecting_against_infinite_method_added_loop do | |
memoize(method_name) | |
end | |
end | |
end | |
def memoize(method_name) |
OlderNewer