Skip to content

Instantly share code, notes, and snippets.

View crowdmatt's full-sized avatar

Matthew Moore crowdmatt

View GitHub Profile
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><!-- required to getJSON from our server -->
<script src="https://datejs.googlecode.com/files/date.js"></script><!-- required to parse dates in ISO format -->
<script>
var device_tracking_type = "mac_address";
var current_user_device_type = "android";
var current_user_country_code = "ca";
var current_user_mac_address = "11:11:11:11";
var current_user_location = "37.8188,-122.4784";
var current_impression_uuid = "mynetworkimpression-iowd23e823jsd094";
var current_time = new Date();
@crowdmatt
crowdmatt / ForeachLine.go
Last active December 14, 2015 07:29
The purpose of this function is to be as memory efficient as possible when operating on files with many, many lines, in Golang
import (
"bufio"
"os"
)
// readWholeLine returns a single line (without the ending \n) from the input buffered reader.
// An error is returned iff there is an error with the buffered reader.
func readWholeLine(r *bufio.Reader) (string, error) {
var (isPrefix bool = true
err error = nil
{
"IAB1": "Arts & Entertainment",
"IAB1-1": "Books & Literature",
"IAB1-2": "Celebrity Fan/Gossip",
"IAB1-3": "Fine Art",
"IAB1-4": "Humor",
"IAB1-5": "Movies",
"IAB1-6": "Music",
"IAB1-7": "Television",
"IAB2": "Automotive",
@crowdmatt
crowdmatt / linked_in_people_search_by_company_name.rb
Created July 7, 2012 16:46
How to query LinkedIn People Search by Company Name from Ruby with the LinkedIn Gem
# Call me with linked_in_by_company('Disney')
LINKEDIN = {
api_key: ENV['LINKEDIN_API_KEY'],
secret_key: ENV['LINKEDIN_SECRET_KEY'],
consumers: {
test_person: {
consumer_token: ENV['LINKEDIN_TESTPERSON_CONSUMER_TOKEN'],
consumer_secret: ENV['LINKEDIN_TESTPERSON_CONSUMER_SECRET']
@crowdmatt
crowdmatt / gist:2979403
Created June 23, 2012 18:42
Create a new Amazon CloudFront distribution for an S3 bucket in Ruby
# Here is some sample code to create a CloudFront distribution programmatically from Ruby.
# Tested to be working on 06-23-2012.
# Amazon's documentation is wrong, so we're putting the XML here!
#
# We're using this at http://www.crowdmob.com/ to simplify our development process.
#
# Prerequisite: You'll need the simple_aws gem which you can get from `gem install simple_aws`
#
require 'simple_aws/s3'
== RemoveNameFromOrganizations: migrating ====================================
-- remove_column(:organizations, :name)
-> 0.1580s
-- add_index(:organizations, :domain, {:unique=>true})
rake aborted!
An error has occurred, all later migrations canceled:
ActiveRecord::JDBCError: Key column 'domain' doesn't exist in table: CREATE UNIQUE INDEX `index_organizations_on_domain` ON `organizations` (`domain`)
Tasks: TOP => db:migrate