Skip to content

Instantly share code, notes, and snippets.

@chrismytton
chrismytton / .gitignore
Created February 17, 2012 23:11
bookmarklet creater
/node_modules
@chrismytton
chrismytton / commit-bit.md
Created January 28, 2013 20:16
Open commit bit template

From this tweet which lead me to this comment.

Merged, thanks. I have an open commit bit policy on my repositories -- anyone with an accepted pull request gets added as a repository collaborator. I've added you as such; feel free to push changes you're confident in directly. Just follow the existing style, provide test coverage for changes, and ask if you're uncertain about anything. Cheers!

@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/ | git@heroku.com: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 December 14, 2015 05:19
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 / config.ru
Created February 8, 2013 10:24
Simplest Rack server. Run with `rackup`.
run ->(env) { [200, {}, ['Hello, world']] }