Skip to content

Instantly share code, notes, and snippets.

View dougvk's full-sized avatar

dougvk dougvk

View GitHub Profile
@dougvk
dougvk / ingest_yahoo_finance.py
Created February 8, 2014 20:28
Ingest, scrub, and store intra-day yahoo financial ticker information in pandas DataFrame
"""
Import and process yahoo data
"""
from cStringIO import StringIO
import requests
from datetime import datetime
from pandas import DataFrame
from pandas.io.parsers import read_table
@dougvk
dougvk / cik_dict.py
Created January 19, 2014 01:40
(stock ticker -> CIK) dictionary using SEC EDGAR
import re
from cPickle import dump
from requests import get
DEFAULT_TICKERS = ['goog', 'aapl']
URL = 'http://www.sec.gov/cgi-bin/browse-edgar?CIK={}&Find=Search&owner=exclude&action=getcompany'
CIK_RE = re.compile(r'.*CIK=(\d{10}).*')
cik_dict = {}
for ticker in DEFAULT_TICKERS:
class PageObjectDelegator
include Capybara::DSL
include Rails.application.routes.url_helpers
def initialize(*args)
# Create a `path` => `page object model` hash
@pages = {}
@pages[foo_bar_path] = FooBarPage.new("Foo Bar")
@pages[baz_path] = BazPage.new("Baz")
end
@dougvk
dougvk / django_json_ajax_response
Created July 17, 2012 08:55
Example JSON response to Server
if request.is_ajax():
if form.is_valid():
# I doubt we would ever save on an ajax POST.
goal = form.save()
# Serialize the goal in json format and send the
# newly created object back in the reponse
# have to put it in a list even if it's just one instance.
data = serializers.serialize('json', [goal,])
else:
@dougvk
dougvk / django_ajax_post
Created July 17, 2012 08:38
Example Ajax POST to django server
$(document).on("submit", "#test_form", function(e) {
e.preventDefault();
var self = $(this),
url = self.attr("action"),
// Note: CSRF token already added to HTTP Headers
ajax_req = $.ajax({
url: url,
type: "POST",
data: {
// Send the form data with POST request