Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
@bsodmike
bsodmike / migration.rb
Created March 13, 2015 15:34
Import table from tarball via Rails 4 migration
require 'rubygems'
require 'rubygems/package'
require 'zlib'
require 'fileutils'
module Util
module Tar
# Creates a tar file in memory recursively
# from the given path.
#

Predicting Email Addresses

At AlphaSights, we often want to contact advisors even when we don't know know their email address.

This presents us with the challenge of having to predict what their actual email address will be.

To help with this process, we have the following information available:

  1. The advisor's name.
  2. The domain name of the company he works for.
  3. The names and emails of other advisors in our database that work for the same company (and domain name).
@bsodmike
bsodmike / API.swift
Last active August 29, 2015 14:23 — forked from higepon/API.swift
//
// API.swift
//
// Created by Taro Minowa on 6/10/14.
// Copyright (c) 2014 Higepon Taro Minowa. All rights reserved.
//
import Foundation
typealias JSONDictionary = Dictionary<String, AnyObject>
@bsodmike
bsodmike / webfont-reloader.js
Created September 19, 2015 14:35
Automatically reload page if it takes longer than 20 seconds to fetch fonts via Web Font Loader
var reloadTimeout = window.reloadTimeout;
var triggerReload = false;
var refreshBrowser = function(timeout) {
triggerReload = true;
console.log('Will attempt reload in '+timeout+' ms.');
reloadTimeout = setTimeout(function() {
console.log('reloading now...');
window.location.reload();
}, timeout);
}
@bsodmike
bsodmike / gist:912747
Created April 10, 2011 21:33
Capistrano-ext puzzling behaviour....
cap deploy:restart
triggering start callbacks for `deploy:restart'
* executing `multistage:ensure'
*** Defaulting to `production'
* executing `production'
* executing `deploy:restart'
[DEPRECATED] `deploy:restart` is going to be changed to Passenger mod_rails' method after 2.5.9 - see http://is.gd/2BPeA
* executing "/home/*******/current/script/process/reaper"
BUT!!
scope :current, where(:current=>true}
validate :only_one_current
protected
def only_one_current
errors.add_to_base("Only one event can be current") if Event.current.reject{|c| c.eql?(self)}.size>0
end
# Setup ruby for rails development. Installs [:rvm, :homebrew, :wget]
echo -e '\n\n###########################################\nThanks! Now grab a beverage...\nThis may take awhile\n###########################################\n\n'
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
brew install wget
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo -e "\n[[ -s '$HOME/.rvm/scripts/rvm' ]] && . '$HOME/.rvm/scripts/rvm' # This loads RVM into a shell session." >> ~/.bash_profile
source ~/.bash_profile
echo -e '\n\n###########################################\nDone!\n###########################################\n\n'
@bsodmike
bsodmike / ssh.conf
Created May 2, 2011 12:31
Update ssh.conf to avoid IP-address binding issue in Ubuntu Server 10.04 LTS
# ssh - OpenBSD Secure Shell server
#
# The OpenSSH server provides secure shell access to the system.
description "OpenSSH server"
# For Media Temple Linux (ve) VPS, use:
# start on filesystem and net-device-up IFACE=venet0:0
start on filesystem and net-device-up IFACE=eth0
stop on runlevel [!2345]
@bsodmike
bsodmike / gist:978979
Created May 18, 2011 16:46
MATLAB S-function m-file template
% low-pass FIR filter code goes like this:
%trialfirS An M-file S-function
function [sys,x0,str,ts] = trialfirS(t,x,u,flag)
h=fir1(32,0.5);
ipv=randn(1,100);
switch flag,
@bsodmike
bsodmike / Gemfile
Created May 19, 2011 22:07
Fancier client_side_validations Callbacks for element validation
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3'
# gem 'nifty-generators'
# gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'jquery-rails', '1.0.5'
gem 'client_side_validations'