This is a Mootools-like class implementation for jQuery in just 37 NCLOC.
var Egg = new $.Class({
var Color = function() { | |
this.r = this.g = this.b = 0; | |
this.h = this.s = this.l = 0; | |
this.a = 1; | |
}; | |
/** RGB */ | |
Color.prototype.cssRGB = function() { | |
return "rgb("+Math.round(255*this.r)+","+Math.round(255*this.g)+","+Math.round(255*this.b)+")"; | |
}; | |
Color.prototype.cssRGBA = function() { |
package Catcher; | |
use strict; | |
use warnings; | |
use Carp; | |
use Carp qw (cluck); | |
use File::Basename; | |
use POSIX qw(strftime); | |
# Nagios error levels |
package com.hotelbb.crs.utils.mail; | |
import java.io.UnsupportedEncodingException; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import javax.activation.DataHandler; | |
import javax.activation.DataSource; |
@SuppressWarnings({ "unchecked", "rawtypes" }) | |
private int smartCompare(final Object o1, final Object o2, String field, final Class comparable) { | |
try { | |
if (o1 == o2) { | |
return 0; | |
} else if (o1 != null && o2 == null) { | |
return -1; | |
} else if (o1 == null && o2 != null) { | |
return 1; | |
} |
package com.neolitec.examples; | |
import org.apache.commons.codec.binary.Base64; | |
import org.apache.commons.lang.StringUtils; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import javax.servlet.*; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; |
util = require 'util' | |
printArgs = (method) -> | |
(args...) -> console.log method, util.inspect(args) | |
# Read a file and redirect it to standart output | |
fs = require 'fs' |
var utils = (function() { | |
var utils = {}, | |
PROPERTY_REGEXP = /^(([a-z_][a-z0-9_]*\.?)+[a-z0-9_]+)$/i; | |
var checkProperty = function(propName) { | |
if(!PROPERTY_REGEXP.test(propName)) | |
throw new Error('Property ' + propName + ' misspelled'); | |
return propName; | |
}; | |
function abbreviateIpv6(ip) { | |
var out = ip.replace(/(^|\:)0{1,3}([0-9]+)/g, "$1$2"); | |
out = out.replace(/0(\:0)+/, ":"); | |
out = out.replace(/\:{3,}/g, "::"); | |
if (out === ":") { | |
out = "::"; | |
} | |
return out; | |
} |
import json | |
class BaseDecoder: | |
def __init__(self, clazz): | |
json.JSONDecoder.__init__(self) | |
self.clazz = clazz | |
def decode(self, dct): | |
if type(dct) is str: |