Skip to content

Instantly share code, notes, and snippets.

View tonini's full-sized avatar
💭
I may be slow to respond.

Samuel Tonini tonini

💭
I may be slow to respond.
View GitHub Profile
@sandro
sandro / bookmarklet_template.js
Created January 29, 2009 05:01
bookmarklet template
// TODO: remove spaces and newlines
javascript:(function(){
s=document.createElement('script');
s.type='text/javascript';
s.src='http://example.com/bookmarklet.js';
document.body.appendChild(s);
})();
// TODO: bookmarklet code needs to be in an anchor tag
// <a href="javascript:(function(){s=document.createElement('script');s.type='text/javascript';s.src='http://example.com/bookmarklet.js';document.body.appendChild(s);})();">My Bookmarklet</a>
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@edavis10
edavis10 / _config.yml
Created November 6, 2009 02:18
Pagination in Jekyll
# ....other stuff here
paginate: 10
set-window-option -g mode-keys emacs
set-window-option -g window-status-current-bg red
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-attr 'bold'
set-window-option -g window-status-current-attr 'bold'
set-window-option -g window-status-fg black
set-window-option -g window-status-bg white
set-window-option -g automatic-rename on
set-window-option -g utf8 on
require 'sj'
run SinatraJekyll
(defun ruby-send-region (start end)
"Send the current region to the inferior Ruby process."
(interactive "r")
(let (term (file (buffer-file-name)) line)
(save-excursion
(save-restriction
(widen)
(goto-char start)
(setq line (+ start (forward-line (- start)) 1))
(goto-char start)
GC.disable
objects = ObjectSpace.count_objects
start = objects[:TOTAL]
puts "objects: #{start}" # => 9811
1_000_000.times do
"I am a lonly" + " concatenated" + " string" + "."
end
end_objects = ObjectSpace.count_objects(objects)[:TOTAL]
puts "objects: #{end_objects}"
puts "difference: #{end_objects - start}"
@mattwynne
mattwynne / be_same_file_as.rb
Last active May 21, 2022 13:27
RSpec matcher to compare two file, using their MD5 hashes
RSpec::Matchers.define(:be_same_file_as) do |exected_file_path|
match do |actual_file_path|
expect(md5_hash(actual_file_path)).to eq(md5_hash(expected_file_path))
end
def md5_hash(file_path)
Digest::MD5.hexdigest(File.read(file_path))
end
end
;;; pbcopy.el --- Emacs Interface to pbcopy
;; Copyright (C) 2011 Daniel Nelson, based on xclip.el, by Leo Shidai Liu
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
@marzocchi
marzocchi / config.ru
Created July 1, 2011 09:15
Run Symfony apps with Rack (rackup! pow!)
# vim:se filetype=ruby
# vim:se foldlevel=3
#
# Hacks and monkeys to run Symfony 1.4 applications as Rack apps using
# the rack-legacy and rack-rewrite gems.
#
# A couple of rack-rewrite rules take care of handing requests to the
# default front controller (index.php) and a subclass of rack-legacy's
# Php fixes PATH_INFO for Symfony routing.
#