Skip to content

Instantly share code, notes, and snippets.

View ydnar's full-sized avatar

Randy Reddig ydnar

View GitHub Profile
@ydnar
ydnar / vox2mtif.css
Created July 20, 2009 04:42
Export Vox blogs to Movable Type Import Format (MTIF)
/*
vox2mtif
Copyright 2009 Randy Reddig - http://ydnar.com
CSS suitable for basic styling of Vox enclosures in a TypePad or Movable Type blog.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
@ydnar
ydnar / vox2mtif.css
Created July 20, 2009 04:46
CSS for exported Vox blogs
/*
vox2mtif
Copyright 2009 Randy Reddig - http://ydnar.com
CSS suitable for basic styling of Vox enclosures in a TypePad or Movable Type blog.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
@ydnar
ydnar / minimal_safe_erb.rb
Created October 18, 2009 16:49
Minimal safe ERb for Rails 2.3 — escapes all expressions by default
# Minimal Safe ERb for Rails 2.3
# Automatically HTML-escapes: <%= expr %>
# To pass raw text through: <%== expr %>
#
# Based on Erubis 2.6.5 and a bit of Rails 3:
# http://github.com/rails/rails/commit/9415935902f120a9bac0bfce7129725a0db38ed3
#
# To use, add this file to config/initializers and this line to environment.rb:
# config.gem "erubis", :version => "2.6.5"
@ydnar
ydnar / robot_steps.rb
Created October 19, 2009 00:38
Test robots.txt with Cucumber & Robots
require 'robots'
# Cucumber steps for robots.txt
# Requires the robots gem: http://github.com/fizx/robots
# Note: url_for() returns a fully-qualified URL, similar to path_to()
When /^I am a robot named (.+)$/ do |user_agent|
@robots = Robots.new user_agent
end
@ydnar
ydnar / cucumber_eats_its_tail.rb
Created December 12, 2009 02:23
Yo dawg I heard you like Cucumber so we put scenarios in your steps so you can test while you test.
# Allow any Cucumber scenario to be called as a step in other scenarios
module Cucumber
module Ast
class Scenario
def initialize_with_awesome(*args)
initialize_without_awesome(*args)
src = @steps.map { |step| "When %Q{#{step.name}}" }.join("\n")
proc = Proc.new { eval src }
regexp = Regexp.new("^#{Regexp.escape(@name)}$")
Cucumber::RbSupport::RbDsl.register_rb_step_definition(regexp, proc)
@ydnar
ydnar / wrapper_helper.rb
Created December 25, 2009 02:04
Implementation of the wrapper pattern for Rails / ActionView
# Implementation of the wrapper pattern, borrowed from Template Toolkit:
# http://template-toolkit.org/docs/manual/Directives.html#section_WRAPPER
#
# The method captures a block and passes its content to a partial template.
# The partial template calls <%= yield %> to render the block content, e.g.:
#
# <% wrapper "shared/widget", { :title => "Hello" } do %>
# ...some ERb...
# <% end %>
#
@ydnar
ydnar / csspec.sample.js
Created January 3, 2010 19:47
CSSpec, BDD for CSS. Theoretical.
/* CSSpec: Theoretical BDD for CSS based on jQuery. Doesn’t exist yet. */
with(CSSpec) {
describe("all layouts", function() {
describe("body", function() {
it("has a white background", function() {
value(this.css("background-color")).should.be.color("#fff")
})
it("has black text", function() {
@ydnar
ydnar / capistrano_syslog.rb
Created January 19, 2010 01:40
Quick patch to enable Capistrano to use Syslog via the Logging gem.
# Workaround in case Logging symbol is partially loaded/defined
Object.send(:remove_const, :Logging) if defined?(Logging)
# http://gemcutter.org/gems/logging
require 'logging'
# Use Syslog
class Capistrano::Logger
LOGGER_NAME = "capistrano"
@ydnar
ydnar / README.md
Last active December 28, 2015 22:39 — forked from mbostock/.block

A treemap recursively subdivides area into rectangles; the area of any node in the tree corresponds to its value. This example uses color to encode different packages of the Flare visualization toolkit. Treemap design invented by Ben Shneiderman. Squarified algorithm by Bruls, Huizing and van Wijk. Data courtesy Jeff Heer.

@ydnar
ydnar / hitch-example.go
Last active December 26, 2017 01:24
hitch: middleware + routing for vanilla go http.Handlers — https://github.com/nbio/hitch
package main
import (
"fmt"
"net/http"
"github.com/nbio/hitch"
"github.com/nbio/httpcontext"
"github.com/nbio/httpgzip"
)