Skip to content

Instantly share code, notes, and snippets.

View thebinarypenguin's full-sized avatar

Ethan Zimmerman thebinarypenguin

View GitHub Profile
@thebinarypenguin
thebinarypenguin / APPNAME
Created July 14, 2011 02:17 — forked from eculver/APPNAME
node.js init.d script for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@thebinarypenguin
thebinarypenguin / simple-jquery-infinite-scroll.html
Created September 26, 2011 20:32
Simple jQuery Infinite Scroll
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Simple jQuery Infinite Scroll</title>
</head>
<body>
<h1>One</h1>
<br />
@thebinarypenguin
thebinarypenguin / movable-resizable-raphael
Created January 4, 2012 02:43
Movable and re-sizable rectangle using Raphael SVG
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Movable and Re-sizable Raphael JS Shape</title>
</head>
<body>
<div id="paper"></div>
@thebinarypenguin
thebinarypenguin / sublime-text-2.desktop
Created June 21, 2012 04:26
A desktop application launcher for Sublime Text 2
[Desktop Entry]
Type=Application
Terminal=false
StartupNotify=true
Name=Sublime Text 2
Name[en_US]=Sublime Text 2
GenericName=Text Editor
GenericName[en_US]=Text Editor
Comment=Edit text files
Comment[en_US]=Edit text files
@thebinarypenguin
thebinarypenguin / colorize.rb
Created June 29, 2012 14:09
A simple function to colorize console output of Ruby scripts using ANSI escape codes.
def colorize(value, color)
case color
when :black then "\e[30m" + value.to_s + "\e[0m"
when :red then "\e[31m" + value.to_s + "\e[0m"
when :green then "\e[32m" + value.to_s + "\e[0m"
when :yellow then "\e[33m" + value.to_s + "\e[0m"
when :blue then "\e[34m" + value.to_s + "\e[0m"
when :magenta then "\e[35m" + value.to_s + "\e[0m"
when :cyan then "\e[36m" + value.to_s + "\e[0m"
when :white then "\e[37m" + value.to_s + "\e[0m"
@thebinarypenguin
thebinarypenguin / greed-game.rb
Created July 2, 2012 20:47
This is a solution to the extra credit project from EdgeCase's excellent Ruby Koans; it is an implementation of a dice game called greed. Greed is a "push your luck" style dice game for 2 or more players using 5 six-sided dice.
#!/usr/bin/env ruby
class UI
def self.prompt_for_player_names
puts " _____ _____ ______ ______ _____ "
puts " / ____| | __ \\ | ____| | ____| | __ \\ "
puts " | | __ | |__) | | |__ | |__ | | | | "
puts " | | |_ | | _ / | __| | __| | | | | "
puts " | |__| | | | \\ \\ | |____ | |____ | |__| | "
puts " \\_____| |_| \\_\\ |______| |______| |_____/ "
@thebinarypenguin
thebinarypenguin / spreadsheet-examples.rb
Created November 9, 2012 04:48
Read and write spreadsheets with ruby using the spreadsheet gem
# Read and write spreadsheets with ruby using the spreadsheet gem
# Full Docs: http://spreadsheet.rubyforge.org/GUIDE_txt.html
require 'spreadsheet'
# Open source spreadsheet
workbook = Spreadsheet.open 'source.xls'
# READ
@thebinarypenguin
thebinarypenguin / uheprng.js
Created June 14, 2013 16:33
Gibson Research Corporation's Ultra-High Entropy Pseudo-Random Number Generator. Full documentation can be found here: https://www.grc.com/otg/uheprng.htm
"use strict";
/* ============================================================================
Gibson Research Corporation
UHEPRNG - Ultra High Entropy Pseudo-Random Number Generator
============================================================================
This is GRC's cryptographically strong PRNG (pseudo-random number generator)
for JavaScript. It is driven by 1536 bits of entropy, stored in an array of
48, 32-bit JavaScript variables. Since many applications of this generator,
including ours with the "Off The Grid" Latin Square generator, may require
the deteriministic re-generation of a sequence of PRNs, this PRNG's initial
@thebinarypenguin
thebinarypenguin / DiceRoller.js
Created June 19, 2013 01:27
A dice roller library for javascript
/*
* A virtual dice roller that accepts standard dice notation
*
*
* Dice Notation
*
* [Num Dice] d <Num Sides> [Modifier]
*
*
* Num Dice - Number of dice to roll (optional)
@thebinarypenguin
thebinarypenguin / UniqueCollection.js
Created July 27, 2013 22:55
A "unique collection" object. Implemented as a node.js module.
/**
* A Unique Collection Object
* Items are alphanumeric strings (defined by createItem function)
* Items are 7 characters long (defined by itemLength variable)
*/
function UniqueCollection() {
var items = [];
var itemLength = 7;
/* Create a new item */