Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
jasonroelofs / dupefinder.js
Last active Dec 27, 2017 — forked from mattslack/dupefinder.js
Find duplicate IDs in a document.
View dupefinder.js
(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 Apr 27, 2011 — forked from collegeman/setup-statsd.sh
Turn an Ubuntu 10.10 EC2 into a StatsD/Graphite server
View setup-statsd.sh
# 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
View animal.rb
class Animal
def noise(sound, &block)
block.call(sound)
end
end
class Cow < Animal
def moo(&block)
noise("moo", &block)
end
View rice_custom_exceptions.cpp
/* 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;
View extconf.rb
require 'mkmf-rice'
create_makefile('virtual')
View scene.cpp
// 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
View ruby-search.ubiquity-command.js
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",
You can’t perform that action at this time.