Skip to content

Instantly share code, notes, and snippets.

@chrismytton
chrismytton / Color-warp.markdown
Created September 14, 2014 22:21
A Pen by Chris Mytton.
@chrismytton
chrismytton / generateblog.rb
Last active August 29, 2015 14:07
Super simple static site system
#!/usr/bin/env ruby
require 'date'
require 'kramdown'
require 'erb'
abort "Usage: #$0 <posts_path>" if ARGV.empty?
Post = Struct.new(:path) do
def title
Date.strptime(File.basename(path, '.md'), '%Y-%m-%d').strftime('%d %B %Y')
@chrismytton
chrismytton / .gitignore
Last active August 29, 2015 14:13
Image which takes 6 seconds to load
/node_modules/
var calculator = {
add: function (a, b) {
return a + b
},
subtract: function (a, b) {
return a - b
},
multiply: function (a, b) {
return a * b
},
// bookmarklet to introspect the source of current page
javascript:(function(d,h){h=d.documentElement.innerHTML;d.open();d.write('<pre>'+('<!DOCTYPE html><html>'+h+'</html>').replace(/[<>]/g,function(m){return{'<':'&lt;','>':'&gt;'}[m]})+'</pre>')})(document);
@chrismytton
chrismytton / ideas_generator.rb
Created May 16, 2010 23:10
For when you just don't know what to do
module Idea
class Generator
def actions
@actions ||= %w{read write design contemplate}
end
def objects
@objects ||= ['code', 'books', 'art', 'poetry', 'blogs']
end
window.onload = function () {
if (! document.querySelectorAll) { // Quick & Dirty way to tell the good browsers from the bad ones.
alert("Please upgrade your browser to view this site.");
}
};
[/Users/chris/Code/Ruby/gist-550144 (master)] ruby-1.9.2-p0
$ time php php_string.php > /dev/null
real 0m0.237s
user 0m0.218s
sys 0m0.017s
[/Users/chris/Code/Ruby/gist-550144 (master)] ruby-1.9.2-p0
$ time php php_array.php > /dev/null
real 0m0.249s
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
@chrismytton
chrismytton / gist:603122
Created September 29, 2010 17:07
`gitify(1)` your remote repository
#!/bin/sh
# Get a website ready to deploy with git
REPO_HOST='example.com'
REPO_PATH=$HOME/repos
# Check that the user has provided a directory to use and it exists
if [ ! "$1" ]; then
echo "Usage: $0 DIRECTORY"
echo "Where DIRECTORY is the folder that you want to contain the working copy"