Skip to content

Instantly share code, notes, and snippets.

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

Martin Samson masom

💭
I may be slow to respond.
  • Shopify
  • Ottawa, Canada
View GitHub Profile

Keybase proof

I hereby claim:

  • I am masom on github.
  • I am masom (https://keybase.io/masom) on keybase.
  • I have a public key whose fingerprint is A335 A2A0 DD22 8705 1E58 9EF9 39AB 34CA F07F 7B2B

To claim this, I am signing this object:

@masom
masom / blueprint.py
Created August 27, 2015 18:44
net/http style middlewares for Flask
# -*- coding: utf-8 -*-
from flask import Blueprint, request
from .middlewares import (m, validate)
posts = Blueprint('posts', __name__, url_prefix='/posts')
def index():
posts = dict()
return dict(posts=posts)
@masom
masom / clean_music.rb
Created January 4, 2012 17:45
Ruby music tree cleaner
module MusicCleaner
class Cleaner
def initialize(dir, musicfiles = nil)
@types = musicfiles || ['.mp3', '.ogg', '.flac', '.m4a', '.aac']
@delete = ['.ini', '.txt', '.nfo', '.db', '.m3u']
@skip = ['.', '..']
@dir = dir
end
def clean!(dir = nil)
dir = dir || @dir
@masom
masom / vimrc
Created December 22, 2011 22:30
Vimrc based off jperras'
set encoding=utf-8
set nocompatible " be iMproved
filetype off " required!
set t_Co=256
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
#TODO: compute recipe food values
namespace :recipe do
desc "Imports JSON recipes"
task :json_import, [:source, :basepath] => :environment do |task,args|
require 'rubygems'
require 'json'
def import_recipe(source, raw)
recipe = Recipe.new
recipe.name = raw['name']
@masom
masom / connections.php
Created November 24, 2011 16:43 — forked from spacemonkey/connections.php
Example for connecting Lithium apps to a MongoDB replica set
/**
* Example of a production database called "db_prod" connecting to a replica set
* running on two systems, "db1" and "db2" with the replica set name of "prod_01".
*
* This setup assumes that you're running a recent version of MongoDB as well as
* the PHP extension.
**/
Connections::add('default', array(
'production' => array(
'type' => 'MongoDb',
@masom
masom / importer.rb
Created November 13, 2011 17:22
Import from Canadian food db to SQL using ruby
#http://erikonrails.snowedin.net/?p=212
desc "Imports a CSV file into an ActiveRecord table"
task :csv_model_import, :source, :model, :needs => :environment do |task,args|
def import_csv(classname, options = {})
lines = File.new(options[:filename]).readlines
header = lines.shift.strip
keys = header.split(',')
model = Module.const_get(classname)
@masom
masom / synergy.conf
Created October 13, 2011 13:58
Synergy server config
section: screens
msamson:
heroku-2:
end
section: links
msamson:
right(10,100) = heroku-2(10,100)
heroku-2:
left(10,100) = msamson(10,100)
end
@masom
masom / configuration.yml
Created October 13, 2011 13:25
Email setup for google apps
production:
email_delivery:
delivery_method: :async_smtp
smtp_settings:
tls: true
enable_starttls_auto: true
address: "smtp.gmail.com"
port: '587'
domain: "smtp.gmail.com"
authentication: :plain
@masom
masom / Peer_Review.php
Created October 4, 2011 17:44
Best Peer Review
<?php
public function pin(Array $params=array())
{
$pin="";
$options = array();
$ip = $_SERVER['REMOTE_ADDR'];
$q = "SELECT grv.ip_address,grs.printing_pin FROM guest_room_view grv INNER JOIN guest_room_settings grs on grv.room_id=grs.guest_room_id";