Skip to content

Instantly share code, notes, and snippets.

Matthew Wells mdespuits

Block or report user

Report or block mdespuits

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mdespuits / book.rb
Created Aug 14, 2018 — forked from sirupsen/book.rb
Script to import books from Instapaper to Airtable
View book.rb
class Book < Airrecord::Table
class Endorser < Airrecord::Table
self.base_key = ""
self.table_name = "Endorser"
self.base_key = ""
self.table_name = "Books"
has_many :endorsements, class: 'Book::Endorser', column: 'Endorsements'
mdespuits /
Created May 3, 2012
Add to Mac OS X hosts file
main() {
if [[ $(has_lvh_me) == 1 ]]; then
echo ' is already specified in your hosts file'
echo ' was added to your hosts file!'
mdespuits /
Last active Dec 25, 2015
Rails setup for Rails production server using Nginx, Git, Postgresql, and the speedy Recap capistrano gem.
sudo apt-get -y update
sudo add-apt-repository ppa:nginx/stable
sudo apt-get -y update
sudo apt-get install -y git-core postgresql-9.1 mysql-server libpq-dev \
curl build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
mdespuits /
Last active Dec 20, 2015
Install Erlang on Mac OS X
# Script built from the reference at
sudo -v
tar -xzf otp_src_R16B01.tar.gz
mdespuits / performance.rb
Created Apr 3, 2013
Array concatenation benchmarks
View performance.rb
require 'benchmark'
ITERATIONS = 10_000 do |bm|"#<< -> #flatten!: ") do
array = [1,2,3]
array << [4,5,6]
mdespuits /
Last active Dec 15, 2015
My first Rust program
// My first Rust program
// Simply outputs fibbonaci numbers from 20 to 0
use core::task::spawn;
fn fib(number: int) -> int {
if number > 1 {
return fib(number - 1) + fib(number - 2);
} else {
return number;
mdespuits / dynamic_logger_progname.rb
Last active Dec 15, 2015
Singleton Logger wrapper including a progname
View dynamic_logger_progname.rb
require_relative './example_logger'
class ExampleClass
def initialize"Initializing ExampleClass")
mdespuits / update_repos.rb
Last active Dec 14, 2015
Update all git repositories in a given directory
View update_repos.rb
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'pathname'
class Text
attr_reader :string
mdespuits / account_decorator.rb
Last active Dec 12, 2015
Example of a basic decorator that uses `method_missing` rather than Delegation
View account_decorator.rb
class AccountDecorator
attr_accessor :account
def initialize(account)
@account = account
def method_missing(method_name, *args, &blk)
if account.respond_to?(method_name)
account_method_result(method_name, *args, &blk)
mdespuits / some_object_tap_uses.rb
Last active Dec 10, 2015
Example uses of Object#tap that I really like
View some_object_tap_uses.rb
# Logging some action in the console or log file
# Prevents lots of references to a variable
# Maybe not the best example, but potentially cleaner than the alternative
class ApplicationController
after_filter :log_action_without_tap
after_filter :log_action_with_tap
def log_action_with_tap
"[ACTION LOG]: #{} tried to #{action_name} #{controller_path}".tap{|l|
l <<{|k,v| "#{k}: #{v}"}.join(',') if flash.any?
You can’t perform that action at this time.