Skip to content

Instantly share code, notes, and snippets.

@natereed
natereed / read_fieldnames.py
Created November 5, 2015 21:12
Read the headers of a csv file into fieldnames for reading with csv.DictReader
def read_fieldnames(path):
with open(path, "r") as path_csv:
reader = csv.reader(path_csv)
row = reader.next()
return row
@natereed
natereed / CRMClientTest.java
Last active December 30, 2016 00:35
Stubbing/mocking Jersey Client. Inspired by WebMock.
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
public class CRMClientTest {
private CRMClient crmClient;
private StubbedClientHandler clientHandler;
@natereed
natereed / encode_post_params
Created January 17, 2013 23:10
Convert a postParams hash from an HAR file into a URL-encoded string.
def encode_post_params(params)
params.map do |param|
name = param['name']
value = param['value']
"#{CGI.escape(name)}=#{CGI.escape(value)}"
end.join('&')
end
class Post < ActiveRecord::Base
belongs_to :user
end