Skip to content

Instantly share code, notes, and snippets.

View simonw's full-sized avatar

Simon Willison simonw

View GitHub Profile
@vartec
vartec / install.txt
Last active April 22, 2020 01:30
Setting up new MBP
0. launch `term`
1. Install Homebrew (see http://brew.sh)
2. While Homebrew is installing this and following things, modify settings (see settings.txt)
3. `brew install cask`
4. `brew cask install iterm2`
5. Launch iterm2
6. `brew install python git` # pre-installed versions are old, see also https://opensource.com/article/19/5/python-3-default-mac
6.1. export PATH=/usr/local/bin:$PATH to make homebrew stuff take precedence
7. `brew cask install visual-studio-code slack google-chrome`
8. Powerline
'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: '*' }];
@haranjackson
haranjackson / scrapy_lambda_layer.sh
Last active May 7, 2022 09:24
Deploys Python Scrapy library to an AWS Lambda layer. You can specify the region, library version, and runtime.
REGION=eu-west-1
VER=1.7.3
RUNTIME=python3.7
docker run -v $(pwd):/out -it lambci/lambda:build-$RUNTIME \
pip install scrapy==$VER -t /out/build/scrapy/python
cd build/scrapy
zip -r ../../scrapy.zip python/
cd ../..
@rshorey
rshorey / voterfiles.md
Last active October 30, 2022 02:49
So you want to report using voterfiles

So you want to report using voterfiles

History

In 2002, the Help America Vote Act required (among other things) that states must maintain a "computerized statewide voter registration list". These lists (henceforth "voterfiles") contain information about every registered voter and their voting history.

But what about the secret ballot?

When people who have not worked with voterfile data before hear about voterfiles, their first response is almost always "But in my 8th grade civics class, I learned that a critical component of American democracy is the secret ballot! How can states have a list of how you vote?" Voterfiles do NOT include information about how an individual voted. They report whether an individual voted in a specific election.

What information do voterfiles contain?

The exact format and contents of a publicly available voterfile differ from state to state. At a minimum, a file will contain:

@atomotic
atomotic / himalayandatabase.md
Last active December 5, 2021 13:31
himalayandatabase - from dbf to json api

himalayandatabase

from a Visual FoxPro GUI to json api with datasette

http://himalayandatabase.com

The Himalayan Database is a compilation of records for all expeditions that have climbed in the Nepalese Himalaya. The database is based on the expedition archives of Elizabeth Hawley, a longtime journalist based in Kathmandu, and it is supplemented by information gathered from books, alpine journals and correspondence with Himalayan climbers.

The Himalayan Database is a Microsoft Visual Foxpro 9 program.

@bwhitman
bwhitman / picblast.sh
Created May 8, 2017 21:30
Make an audio collage out of your live photos
mkdir /tmp/picblast; cd ~/Pictures/Photos\ Library.photoslibrary; for i in `find . | grep jpegvideocompl`;do ffmpeg -i $i /tmp/picblast/${i:(-8)}.wav; done; cd /tmp/picblast; ffmpeg -safe 0 -f concat -i <( for f in *.wav; do echo "file '$(pwd)/$f'"; done ) ~/Desktop/picblast.wav; rm -rf /tmp/picblast
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

Creating a redis Module in 15 lines of code!

A quick guide to write a very very simple "ECHO" style module to redis and load it. It's not really useful of course, but the idea is to illustrate how little boilerplate it takes.

Step 1: open your favorite editor and write/paste the following code in a file called module.c

#include "redismodule.h"
/* ECHO <string> - Echo back a string sent from the client */
int EchoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
@pwm
pwm / openresty
Last active March 3, 2023 22:39
openresty init script
#!/bin/bash
#
# chkconfig: 2345 55 25
# description: Openresty
# processname: nginx
# config: /usr/local/openresty/nginx/conf/nginx.conf
# pidfile: /usr/local/openresty/nginx/logs/nginx.pid
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $named $syslog $time

Git Cheat Sheet

Commands

Getting Started

git init

or