Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
jasonroelofs / dupefinder.js
Last active December 27, 2017 11:50 — forked from mattslack/dupefinder.js
Find duplicate IDs in a document.
(function () {
"use strict";
var find_dupes = function () {
var identified = document.querySelectorAll('[id]'),
found = {},
id,
idx;
for (idx = 0; idx < identified.length; idx++) {
id = (identified[idx]).getAttribute('id');
if(found[id]) {
@jasonroelofs
jasonroelofs / setup-statsd.sh
Created April 27, 2011 18:25 — forked from collegeman/setup-statsd.sh
Turn an Ubuntu 10.10 EC2 into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
class Animal
def noise(sound, &block)
block.call(sound)
end
end
class Cow < Animal
def moo(&block)
noise("moo", &block)
end
/* Basically, I want to throw a custom exception from C++. I'm kind of lost on how to do that :/ */
// exceptions.hpp
class V8UnknownReturnValueException : public Rice::Exception {
};
Rice::Object rb_eUnknownReturnValueException;
require 'mkmf-rice'
create_makefile('virtual')
// leaks memory because a copy of the value of scene is returned and the pointer is never deleted
Image Scene::draw() const {
Image scene = *(new Image());
// build the scene
return *scene;
}
// doesn't leak memory, but is ugly
CmdUtils.CreateCommand(
{
name: "rails",
takes: {"function": noun_arb_text},
icon: "http://ruby-doc.org/favicon.ico",
homepage: "http://jackndempsey.blogspot.com",
author: {name: "Jack Dempsey", email: "jack.dempsey@gmail.com"},
license: "MPL,GPL",
description: "Search rails functions documentation",
help: "Select a rails function",