Skip to content

Instantly share code, notes, and snippets.

View mdespuits's full-sized avatar

Matthew Wells mdespuits

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mdespuits on github.
  • I am mdespuits (https://keybase.io/mdespuits) on keybase.
  • I have a public key whose fingerprint is 648F 681F 8EB6 B20C A852 98A8 4A01 720C 60D6 8D1F

To claim this, I am signing this object:

@mdespuits
mdespuits / add_lvhme.sh
Created May 3, 2012 15:34
Add lvh.me to Mac OS X hosts file
#!/bin/bash
main() {
if [[ $(has_lvh_me) == 1 ]]; then
echo 'lvh.me is already specified in your hosts file'
else
add_lvh_me
echo 'lvh.me was added to your hosts file!'
fi
flush_dns_cache
@mdespuits
mdespuits / book.rb
Created August 14, 2018 15:04 — forked from sirupsen/book.rb
Script to import books from Instapaper to Airtable
class Book < Airrecord::Table
class Endorser < Airrecord::Table
self.base_key = ""
self.table_name = "Endorser"
end
self.base_key = ""
self.table_name = "Books"
has_many :endorsements, class: 'Book::Endorser', column: 'Endorsements'
@mdespuits
mdespuits / setup-ubuntu.sh
Last active December 25, 2015 12:59
Rails setup for Rails production server using Nginx, Git, Postgresql, and the speedy Recap capistrano gem.
#!/bin/sh
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
mdespuits / install-erlang.sh
Last active December 20, 2015 00:59
Install Erlang on Mac OS X
#!/bin/sh
#
# Script built from the reference at
# http://digitalsanctum.com/2009/10/01/installing-erlang-on-mac-os-x/
sudo -v
wget http://www.erlang.org/download/otp_src_R16B01.tar.gz
tar -xzf otp_src_R16B01.tar.gz
@mdespuits
mdespuits / performance.rb
Created April 3, 2013 20:44
Array concatenation benchmarks
require 'benchmark'
ITERATIONS = 10_000
Benchmark.bm do |bm|
bm.report("#<< -> #flatten!: ") do
array = [1,2,3]
ITERATIONS.times do
array << [4,5,6]
array.flatten!
@mdespuits
mdespuits / fib.rs
Last active December 15, 2015 14:09
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
mdespuits / dynamic_logger_progname.rb
Last active December 15, 2015 06:29
Singleton Logger wrapper including a progname
require_relative './example_logger'
class ExampleClass
def initialize
ExampleLogger.info("Initializing ExampleClass")
end
end
ExampleClass.new
@mdespuits
mdespuits / update_repos.rb
Last active December 14, 2015 08:29
Update all git repositories in a given directory
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'pathname'
class Text
attr_reader :string
@mdespuits
mdespuits / account_decorator.rb
Last active December 12, 2015 04:38
Example of a basic decorator that uses `method_missing` rather than Delegation
class AccountDecorator
attr_accessor :account
def initialize(account)
@account = account
end
def method_missing(method_name, *args, &blk)
if account.respond_to?(method_name)
account_method_result(method_name, *args, &blk)