Skip to content

Instantly share code, notes, and snippets.

'use strict';
module.exports.addCors = async (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
response.statusCode = 200;
headers['x-serverless-time'] = [{ key: 'x-serverless-time', value: Date.now().toString() }];
headers['access-control-allow-origin'] = [{ key:'access-control-allow-origin', value: '*' }];
@eads
eads / scrapy_example.py
Last active April 11, 2019 19:56
simple scrapy example
# -*- coding: utf-8 -*-
import csv
import os
import scrapy
from scrapy.http import FormRequest
from my_scraper.models import TableRow
END_DATE = '01/01/2019'
BASE_PATH = os.path.dirname(__file__)
ID_FILE = os.path.join(BASE_PATH, 'ids.csv')

Keybase proof

I hereby claim:

  • I am eads on github.
  • I am eads (https://keybase.io/eads) on keybase.
  • I have a public key ASA9gsDUAdDYdRhlirC_EOtfzfMAvNiDFROz5QvQyGFkuQo

To claim this, I am signing this object:

# NPR Jupyter utilities
import cachecontrol
import requests
import os
from cachecontrol import CacheControlAdapter
from cachecontrol.caches import FileCache
from cachecontrol.heuristics import ExpiresAfter
adapter = CacheControlAdapter(heuristic=ExpiresAfter(days=1))
<html>
<head>
<meta property="og:title" content="I don't understand this at alll" />
<meta property="og:url" content="https://gist.githubusercontent.com/eads/38e66aa4067ce2e006bf0c99b1c61d0e/raw/fb-gif-demo.html" />
<meta property="og:type" content="article" />
<meta property="og:description" content="So weird!" />
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif" />
<meta property="og:site_name" content="NPR.org" />
<meta property="fb:app_id" content="138837436154588" />
<meta property="fb:pages" content="10643211755" />
@eads
eads / windoze.md
Created April 19, 2016 12:31
install windoze on mac

Get VirtualBox.

Install p7zip:

brew install p7zip

Make a directory for your stuff:

@eads
eads / README.md
Last active March 1, 2016 21:52 — forked from magnetikonline/README.md
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.

IE 7/8/9/10/11 Virtual machines from Microsoft

OS X installation notes, assuming VirtualBox is already installed on host.

First:

brew install p7zip
from decimal import Decimal, ROUND_DOWN
def percent_filter(value):
"""
Format percentage
"""
if value == 0:
return '0%'
elif value == 100:
return '100%'
from Flask import g, jsonify
@blueprint.route('mydata.json')
def mydata():
context = g.current_site.get_context()
mydata = context['sheetname']
# ... process / filter mydata
return jsonify(**mydata)
import requests
from app import app
from flask import Response, request, render_template
from urlparse import urlparse, parse_qsl
import json
from cStringIO import StringIO
import unicodecsv
from time import time
from slughifi import slugify