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 / gist:7257389
Created October 31, 2013 21:20
Halloween Heroku
% heroku create
Creating frightful-flesh-4163... done, stack is cedar
http://frightful-flesh-4163.herokuapp.com/ | [email protected]:frightful-flesh-4163.git
Git remote heroku added
%
@chrismytton
chrismytton / gist:5195130
Created March 19, 2013 10:37
Get a markdown list of your plain text email templates
for file in app/views/**/*.text.erb; do
echo && echo "# `basename $file`" && echo && cat "$file" | sed 's/^/ /'
done | redcarpet --parse-no_intra_emphasis
@chrismytton
chrismytton / README.md
Last active August 2, 2024 09:52
Literate Ruby

Literate Ruby

Inspired by Literate CoffeeScript.

$ cat hello.rb.md
Here's a simple program

    puts "Hello, world"
$ ruby litrb.rb < hello.rb.md

Hello, world

@chrismytton
chrismytton / gist:5008426
Created February 21, 2013 21:29
Get Twitter List members
require 'open-uri'
require 'json'
user, list = ARGV[0].split('/')
abort "Usage: #$0 user/list" unless user && list
response = open("https://api.twitter.com/1/lists/members.json?slug=#{list}&owner_screen_name=#{user}&cursor=-1")
puts JSON.parse(response.read)['users'].map { |u| u['screen_name'] }
@chrismytton
chrismytton / gist:5003501
Created February 21, 2013 09:35
Dumb Ruby SMTP Server - Pre Pre Alpha
require 'socket'
require 'logger'
class MailServer
def initialize(port)
@sockets = Socket.tcp_server_sockets(port)
end
def start
Socket.accept_loop(@sockets) do |connection|
@chrismytton
chrismytton / index.html
Last active December 13, 2015 22:49
HTML5 FileSystem API
<!DOCTYPE html>
<html lang="en">
<head>
<title>Filesystem test</title>
</head>
<body>
<script>
function handleError(error) {
console.warn("An error occurred", error)
}
@chrismytton
chrismytton / progress_bar.coffee
Created February 11, 2013 23:11
Ember.js progress bar component for bootstrap. Simplified version of https://github.com/jamesarosen/progressbars
App.ProgressBar = Ember.View.extend
classNames: ['progress']
template: -> '<div class="bar"></div>'
percent: 0
percentDidChange: (->
percent = @get 'percent' || 0
@$('.bar').css 'width', percent + '%'
).observes('percent')
@chrismytton
chrismytton / gist:4754032
Last active July 8, 2021 22:14
Shell find and replace.
# Usage: find-replace <search> <replacement>
find-replace () {
ag -l $1 | xargs sed -i '' -e "s/$1/$2/g"
}
@chrismytton
chrismytton / config.ru
Created February 8, 2013 10:24
Simplest Rack server. Run with `rackup`.
run ->(env) { [200, {}, ['Hello, world']] }