Skip to content

Instantly share code, notes, and snippets.

View micahlmartin's full-sized avatar

Micah Martin micahlmartin

View GitHub Profile
@micahlmartin
micahlmartin / closure.js
Last active December 26, 2015 16:49
Global namespace example
(function() {
global_var = "This is a globally scoped variable";
console.log(global_var);
return {
data: "example"
}
})()
console.log(global_var);
@micahlmartin
micahlmartin / Dockerfile
Last active August 29, 2015 14:02
Vagrant/Docker Setup
FROM quirky/rails
RUN mkdir /opt/app
WORKDIR /opt/app
ADD ./Gemfile /opt/app/Gemfile
ADD ./Gemfile.lock /opt/app/Gemfile.lock
RUN bundle install
@micahlmartin
micahlmartin / mass_sender
Created September 21, 2013 00:19
Send money on Venmo via CSV import
#!/usr/bin/env python
import sys
import os
import getopt
from decimal import Decimal
import csv
import locale
from subprocess import call
# Set the locale for currency formatting
@micahlmartin
micahlmartin / groups_and_users
Created July 3, 2013 01:54
List all users and their goups
#!/usr/bin/perl -T
#
# Lists members of all groups, or optionally just the group
# specified on the command line
#
# Copyright © 2010-2013 by Zed Pobre (zed@debian.org or zed@resonant.org)
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#!/bin/bash
#
# /etc/rc.d/init.d/
#
#
#
#
#
# Source function library.
@micahlmartin
micahlmartin / setup.py
Created May 20, 2013 21:54
Prevent multiple calls?
_hasBeenSetup = False
def setup():
global _hasBeenSetup
if _hasBeenSetup:
return
_hasBeenSetup = True
@micahlmartin
micahlmartin / Best2.cs
Last active December 15, 2015 04:08
Example of code that's easier to test and code that's harder to test. Instance vs. Static.
// Best 2
// Use of IoC is relegated only to the calling class.
// Injection of dependency is through an instance variable rather than through the constructor
public class UserService
{
public virtual User GetUserByID(long userID)
{
//Get user from database
@micahlmartin
micahlmartin / gist:4261551
Created December 11, 2012 19:53
Convert anonymous object to dictionary
public static IDictionary<string, object> ToDictionary(this object values)
{
var dict = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
if (values != null)
{
foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(values))
{
object obj = propertyDescriptor.GetValue(values);
dict.Add(propertyDescriptor.Name, obj);
@micahlmartin
micahlmartin / CoffeeScript.sublime-build
Created August 23, 2012 14:05
CoffeeScript.sublime-build
{
"cmd": ["coffee", "-c", "$file"],
"selector": "source.coffee",
"path": "/usr/local/bin"
}
@micahlmartin
micahlmartin / .bash_profile
Created August 12, 2012 22:45
Micah's Bash profile for mac
export PATH+=/usr/local/bin
#list all and colorize
alias ls='ls -Ga'
#fix for gitk
alias gitk='gitk 2>/dev/null'
#list files only
alias lf='ls -l | grep -v ^d'