Skip to content

Instantly share code, notes, and snippets.

View samleb's full-sized avatar
:octocat:
CTO at Primo

Samuel Lebeau samleb

:octocat:
CTO at Primo
View GitHub Profile
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) {
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
}
// 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 !
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 .
class JavascriptObfuscator
def self.obfuscate(source)
new(source).obfuscate
end
def initialize(source)
@source = source
@last_identifier = "a"
@translations = { }
end
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> {
#!/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'
Object.extend(Object, (function() {
function hashCode(object) {
if (!(object && Object.isFunction(object.hashCode))) {
object = String(object);
}
return object.hashCode();
}
return {
hashCode: hashCode
/*
Simpler, more robust super keyword for Prototype.
Given the following parent class:
var Person = Class.create({
initialize: function(name) {
this.name = name;
},
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)