This comment thread has moved to simonw/simonwillisonblog#1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BatchIndexer(object): | |
| def __init__(self, batch_size): | |
| self.batch_size = batch_size | |
| def __enter__(self): | |
| self.batch = [] | |
| return self | |
| def index(self, item): | |
| self.batch.append(item) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Narcoossee Middle School | |
| 2700 N Narcoossee Rd, St Cloud, FL 34771 | |
| latitude=28.122861, longitude=-81.272736 | |
| Liberty High School | |
| 4250 Pleasant Hill Rd, Kissimmee, FL 34746 | |
| latitude=28.122861, longitude=-81.272736 | |
| ------- | |
| Livestock Shelter: Oconee Heritage Park | |
| 2380 Athens Hwy, Madison, GA, United States | |
| latitude=33.6284624, longitude=-83.4531959 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "date": "Mon Jan 23 13:03:00 2017 -0800", | |
| "message": "Recommended by Django https://docs.djangoproject.com/en/1.10/ref/databases/#setting-sql-mode", | |
| "title": "SET sql_mode='STRICT_TRANS_TABLES';", | |
| "hash": "a395f401c9a6d3e8602b80ecc729d736da871f46", | |
| "author": "Simon Willison <simonw@example.com>" | |
| }, | |
| { | |
| "date": "Mon Jan 23 11:37:38 2017 -0800", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # First, attach to the docker container | |
| bay attach elasticsearch | |
| # Now install tcpdump | |
| apt-get update && apt-get install tcpdump | |
| # Now run it, sniffing all traffic to port 9200 | |
| tcpdump -A -s 0 'tcp port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' |
A Python development environment is a folder which you keep your code in, plus a "virtual environment" which lets you install additional library dependencies for that project without those polluting the rest of your laptop.
mkdir my-new-python-project
cd my-new-python-project
virtualenv --python=python2.7 venv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import argparse | |
| import sys | |
| def convert_cleaned_to_openelex(filepath, office='Governor'): | |
| yield ( | |
| 'county', 'precinct', 'office', 'district', | |
| 'candidate', 'party', 'votes' | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =((A1-21600000)/86400000)+25569 | |
| # Then select the column and use Format -> Number -> Date time |