Skip to content

Instantly share code, notes, and snippets.

View javascripter's full-sized avatar

javascripter

View GitHub Profile
function ValueFinder() {
}
ValueFinder.NotFoundError = function () {
Error.apply(this, arguments);
};
ValueFinder.NotFoundError.prototype = new Error();
ValueFinder.prototype.find = function (array) {
if (array.length == 0) {
Object.defineProperties(Object, {
seal: {
configurable: true,
enumerable: false,
value: function (object) {
var properties = Object.getOwnPropertyNames(object);
properties.forEach(function (name) {
var desc = Object.getOwnPropertyDescriptor(object, name);
desc.configurable = false;
Object.defineProperty(object, name, desc);
var srand, rand;
(function () {
const a = 16807, b = 0, m = 2147483647;
var x = 1;
srand = function (seed) {
x = seed;
};
rand = function () {
x = (a * x + b) % m;
function abs(n) {
return n >= 0 ? 0+n : -n;
}
var querySelectorAll;
// multiple scoped selector not supported yet. e.g. ">embed,>object"
(function () {
var toArray = function (nodes) {
return [].slice.call(nodes, 0);
};
var squeezers = {
">": function (node) {
return toArray(node.children);
findElem elem [] = Nothing
findElem elem (x:xs)
| x == elem = Just 0
| otherwise = findElem elem xs >>= Just . (1 +)
module Program () where
import Control.Monad
main :: IO ()
main = let
a = [1..100]
fizz = do
s <- a
guard $ s `mod` 3 == 0
(function () {
function define(owner, prop, value) {
if (typeof owner[prop] !== "function") {
owner[prop] = value;
}
}
define(Object, "keys", function (object) {
var k,
result = [];
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
inline int bit2(char *bits) {
int n = 0;
assert(*bits);
for (; *bits != '\0'; bits++) {
assert(*bits == '0' || *bits == '1');
isqrt :: Integer -> Integer
isqrt n | n >= 0 = f n 0
| otherwise = error "domain error"
where
f n i | n < 0 = i - 1
|otherwise = f (n - (i * 2 + 1)) (i + 1)