Skip to content

Instantly share code, notes, and snippets.

function color(n) {
return '\u001b[38;5;' + n + 'm'
}
var clear_color = '\u001b[39m'
var str = ""
for (var i = 0; i < 256; i++) {
if (i && i % 32 === 0) str += "\n"
str += color(i) + "X" + clear_color
@dannycoates
dannycoates / log.js
Created August 31, 2013 18:31
logging with domains
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Domain = require('domain')
var inherits = require('util').inherits
var Logger = require('bunyan')
function Overdrive(options) {
Logger.call(this, options)
@sentientwaffle
sentientwaffle / README.md
Created March 24, 2012 19:08
linux text-to-mp3

Convert a text file into a directory of MP3 files. Perfect for do-it-yourself robot audiobooks!

Installation

You will need the following dependencies from apt-get:

  • espeak
  • lame

Install them with:

@sentientwaffle
sentientwaffle / config.json
Created February 10, 2012 02:42
my Stratus Editor configuration file
{ "fractus.autocomplete": "Control- "
, "file.recent.limit": 0
, "save-on-blur":
[ "CSS"
, "Sass"
, "Stylus"
]
}
@sentientwaffle
sentientwaffle / simple-tar.coffee
Created February 9, 2012 17:32
Node.js compress a directory with tar; and write it to a tmp dir.
###
Allow the user to download a file or a directory as a _.tar.gz_
compressed version.
###
fs = require "fs"
{exec} = require "child_process"
{resolve} = require "path"
# `callback` receives `(tarPath)`
@sentientwaffle
sentientwaffle / stratus_color.rb
Created February 7, 2012 20:53
Jekyll plugin for syntax highlighting via stratus-color
require 'shellwords'
module Jekyll
class StratusColorBlock < Liquid::Block
def initialize(tag_name, markup, tokens)
super
@lang = markup
end
def render(context)
@sentientwaffle
sentientwaffle / test.rb
Created February 6, 2012 14:57
CS235 Test runner
require 'term/ansicolor'
include Term::ANSIColor
dir = ARGV[0].gsub /\/$/, ""
def compile(d)
`(cd #{d} && g++ *.cpp)` # -Wall
return $? == 0
end
@sentientwaffle
sentientwaffle / table_of_contents.rb
Created February 5, 2012 02:17
Table of contents Jekyll plugin
# Be sure to set the following in the `_config.yml`.
#
# markdown: rdiscount
# rdiscount:
# extensions: [generate_toc]
#
module Jekyll
class MarkdownConverter
def convert(content)
setup
@sentientwaffle
sentientwaffle / stylus_converter.rb
Created February 5, 2012 02:14
Stylus plugin for Jekyll
require 'shellwords'
module Jekyll
class StylusConverter < Converter
safe true
def matches(ext)
ext =~ /\.styl/i
end