Skip to content

Instantly share code, notes, and snippets.

View dougvk's full-sized avatar

dougvk dougvk

View GitHub Profile
@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
@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:
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 / 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:
@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
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-0.33649000000001,
45.69892000000001
@dougvk
dougvk / Dockerfile
Last active January 27, 2020 20:28
Building Urbit with Docker
FROM ubuntu:latest
RUN apt-get update -y && apt-get install -y \
libgmp3-dev libsigsegv-dev openssl libssl-dev \
libncurses5-dev git make exuberant-ctags automake autoconf libtool \
g++ ragel cmake re2c curl
RUN git clone https://github.com/urbit/urbit /urbit
WORKDIR /urbit

Keybase proof

I hereby claim:

  • I am dougvk on github.
  • I am dougvk (https://keybase.io/dougvk) on keybase.
  • I have a public key whose fingerprint is A94E DBDA 1DE6 7834 DDE2 5DFF BDED 2E9E ADEF 4B1A

To claim this, I am signing this object:

@dougvk
dougvk / alt-woke.md
Last active February 20, 2017 19:31

ALT WOKE. Feature list if you'd like to adopt it:

  1. Less clumsy than 'anti-authoritarian liberal who is suspicious but not knee-jerk opposed to language policing'

  2. Signals modern, urban, pro-tech liberal as opposed to 60s boomer liberal values clearly, includes hat tip to civil rights

  3. More pronounceable than 'liberal-tarian' (which is invariably misread as 'libertarian' if you don't include the hyphen and attach an explanation for those who haven't heard the term)

  4. Clearer to people under 30 than 'McGovern libertarian' (Marc Andreessen's preferred label), which is kinda where this came from

  • Description for running the Energy Hub services

Create a digital ocean docker box using the docker-machine command: https://docs.docker.com/machine/drivers/digital-ocean/ Run docker-compose -f docker-compose.yml.production build Run docker-compose -f docker-compose.yml.production up -d

If you look at the docker-compose file, you'll see it builds the nginx and node apps. nginx has a configurable .crt file, which you should change. Same with default.conf, based on your specifications.

The first time you run the docker-compose command, it will spin up the nginx and the ehub box. The ehub box will not work.