Skip to content

Instantly share code, notes, and snippets.

View waawal's full-sized avatar

Daniel Waardal waawal

View GitHub Profile
@sjakthol
sjakthol / s3_list_objects_parallel.py
Created January 11, 2019 20:20
Python code snippet for listing bucket objects in parallel.
#!/usr/bin/env python3
"""List S3 bucket objects in parallel.
This module contains a parallel implementation of S3 list_objects_v2()
API call. The implementation lists objects under every distinct prefix
in parallel. Hence, a speedup is achieved if objects are spread under
multiple distinct prefixes.
"""
import argparse
@tomdyson
tomdyson / wagtail-on-zappa.md
Last active June 20, 2023 02:22
Wagtail on AWS Lambda, with Zappa

Wagtail on AWS Lambda, with Zappa

Install Wagtail and Zappa, and create an empty site:

pip install wagtail zappa zappa-django-utils
pip install pip==9.0.3 # see https://github.com/Miserlou/Zappa/issues/1471
wagtail start foo
@gpittarelli
gpittarelli / node_prune.sh
Last active March 3, 2022 17:04
Prunes very-likely-uneeded files from node_modules directories
#!/usr/bin/env bash
# Port of https://github.com/tj/node-prune to bash
# Also,
# - fixed "*.ts" being overzealous and killing .d.ts files
# - added some more file types from https://github.com/npm/npm/issues/5264#issuecomment-259800486
#
# See also:
# - https://github.com/timoxley/cruft
# - https://yarnpkg.com/en/docs/cli/autoclean
# - https://github.com/ModClean/modclean
@tomfa
tomfa / handler.py
Last active February 14, 2023 15:08
AWS Lambda: Python store to S3
# This file is your Lambda function
import json
import boto3
def save_to_bucket(event, context):
AWS_BUCKET_NAME = 'my-bucket-name'
s3 = boto3.resource('s3')
bucket = s3.Bucket(AWS_BUCKET_NAME)
path = 'my-path-name.txt'
@jscattergood
jscattergood / serverless.yml
Last active March 10, 2019 13:57
Creating a custom serverless resource for subscribing to SNS topics in another region
# Welcome to Serverless!
#
# Happy Coding!
service: cross-region-sns-subscriber
# Keep environment specific configurations in separate files
custom: ${file(config/${env:STAGE}.json)}
provider:
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active June 16, 2024 02:26
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmvaldman
dmvaldman / promisesEM.md
Last active June 1, 2024 00:20
Promises as EventEmitters

Promises as EventEmitters

I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.

I read the spec, some blog posts, and looked through some code. I learned how to

@simonw
simonw / heroku-nginx-logging.md
Last active January 22, 2019 18:41
How to get Heroku to log full user_agent strings using nginx

How to get Heroku to log full user_agent strings using nginx

Heroku's default logging format omits user agent and referrer strings - but these are useful to have! Especially if you want to be able to run your own analysis on what kind of browsers are using your service.

A default Heroku log line looks like this:

heroku/router:  at=info method=GET path="/page-on-your-site/"

host=your-site.herokuapp.com

@superjamie
superjamie / raspberry-pi-vpn-router.md
Last active June 24, 2024 03:07
Raspberry Pi VPN Router

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@tweinfeld
tweinfeld / example.js
Last active May 28, 2016 23:11
A JSONP mixin for Lodash
_.jsonp('https://api.ipify.org/?format=jsonp', function(err, value){
console.log(err || value);
});